It's been a long time since I have posted anything new, I've been too busy studying for the MCPD and learning the new features of .NET 3.5 and Silverlight.
I'm going to be posting a bunch of examples I have created with silverlight and .NET 3.5.
The snippet below is a nice javascript object which will move objects around your canvas allowing you to drag and drag and throw.
// File: Movement.js
PointMap.Movement = function(s, noderef) {
this.noderef = noderef;
this.time_to_move=0.6;
var plugin = s;
this.main = s.findName("Page")
this.loader_bar=200;
this.stage_wid=800;
this.friction=0.93;
this.init_opacity=0.95;
this.img_wid=200;
this.scroll_amount=10;
this.time_to_move=500; //in ms
this.cur_img=0;
this.num_images_loaded=0;
this.prev_wid=0;
this._root_xmouse=0;
this._root_ymouse=0;
this.scaleUpInt=0;
this.mouseCheckInt=0;
this.cur_node0X=0;
this.cur_node0Y=0;
this.img_scaling=false;
this.point1X = 0;
this.point1Y = 0;
this.point2X = 0;
this.point2Y = 0;
this.start_time = 0;
this.main_mouse_down = false;
this.p3X = 0;
this.p3Y = 0;
this.start_scale_time = 0;
setInterval(Silverlight.createDelegate(this, this.node0Tracker),10)
}
PointMap.Movement.prototype =
{
mainDown : function(s,e) {
var pt = e.getPosition(null);
clearInterval(this.scaleUpInt)
this.point1X=pt.X
this.point1Y=pt.Y
this.start_time=new Date().getTime()
var node0Ref=s.findName(this.noderef)
this.main_mouse_down=true
this.cur_node0X=node0Ref["Canvas.Left"]
this.cur_node0Y = node0Ref["Canvas.Top"];
s.captureMouse()
},
mainUp: function (s,e) {
var pt = e.getPosition(null);
this.main_mouse_down=false
this.point2X=pt.X
this.point2Y=pt.Y
//alert(point2Y)
this.chkX=Math.abs(this.point2X-this.point1X)
this.chkY=Math.abs(this.point2Y-this.point1Y)
//alert([chkX,chkY])
if(this.chkY<600 && this.chkX<600) {
this.end_time=new Date().getTime()
var elapsed=this.end_time-this.start_time
//alert(elapsed)
if(elapsed<220) {
this.p3Y=this.point2Y-this.point1Y
this.p3X=this.point2X-this.point1X
}
}
s.releaseMouseCapture()
},
mainMouseMove : function (s, e) {
var pt = e.getPosition(null);
this._root_xmouse = pt.x
this._root_ymouse = pt.y
},
node0Tracker : function() {
var check_zeroX = Math.abs(this.p3X)
this.end=0.7
var node0Ref=this.main.findName(this.noderef)
this.diff=this.prev_wid-this.stage_wid
if(this.main_mouse_down) {
var newleft = this.cur_node0X-(this.point1X-this._root_xmouse);
var newtop = this.cur_node0Y-(this.point1Y-this._root_ymouse);
if (newleft < 500) {
node0Ref["Canvas.Left"]=newleft;
}
if (newtop < 500) {
node0Ref["Canvas.Top"]=newtop;
}
this.lineTracker(node0Ref);
}
if(check_zeroX>this.end) {
if(!this.main_mouse_down) {
var newX = node0Ref["Canvas.Left"]+this.p3X/3.2;
var newY = node0Ref["Canvas.Top"]+=this.p3Y/3.2;
if (newX < 500){
node0Ref["Canvas.Left"]=newX;
}
if (newY<500) {
node0Ref["Canvas.Top"]=newY;
}
this.p3X*=this.friction
this.p3Y*=this.friction
this.lineTracker(node0Ref);
}
else {
this.p3X=0
this.p3Y=0
}
}
},
mouseChecker : function (s,me) {
if(this.img_mouse_down) {
s["Canvas.Left"]=this._root_xmouse-this.img_offset_x
s["Canvas.Top"]=this._root_ymouse-this.img_offset_y
}
}
}
}
Sharing Master Pages Accross Multipile IIS Applications
Posted by Lucas Stark at 3:20 AM
I've been searching for a way to share master pages accross multipile IIS applicaitons for a long time. There are several options out there from using the VirtualPageProvider to creating your Master Page in the GAC. I've not had the time to look into any of these options.
What I did find was a very easy solution. Use Virtual Directories.
All you have to do is:
Create a shared location on your web server where the master pages will reside. Dump your shared master page in there.
Add a new virtual directory to your web application via IIS. You can now reference the new virtual directory as though the master page is inside of your web application. Changes made to the global master page will result in the changes being made accrosss the entire set of web projects that you have configured with the master page in the virtual folder.
Easy, quick and works with out much hassle. Just keep in mind that paths are still referenced agianst the content page that is using that master page, so if you have shared images, be sure to set these up in the master page with links that will be able to figure out where the images are regardless of the location of the content page.
What I did find was a very easy solution. Use Virtual Directories.
All you have to do is:
Create a shared location on your web server where the master pages will reside. Dump your shared master page in there.
Add a new virtual directory to your web application via IIS. You can now reference the new virtual directory as though the master page is inside of your web application. Changes made to the global master page will result in the changes being made accrosss the entire set of web projects that you have configured with the master page in the virtual folder.
Easy, quick and works with out much hassle. Just keep in mind that paths are still referenced agianst the content page that is using that master page, so if you have shared images, be sure to set these up in the master page with links that will be able to figure out where the images are regardless of the location of the content page.
Visual Studio Power Toys
Posted by Lucas Stark at 4:48 AM
The Pack Installer is a tool that will let you see the latest Power Toys for Visual Studio, and other great developer oriented tools. It allows you to easily mark any tool or set of tools for download and installation, and streamline the installation process.
http://www.codeplex.com/PackInstaller
This tool will allow you to install hundreds of code snippets, sample projects as well as some very useful Visual Studio add on's.
http://www.codeplex.com/PackInstaller
This tool will allow you to install hundreds of code snippets, sample projects as well as some very useful Visual Studio add on's.
Subscribe to:
Posts (Atom)