Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

wpf - Draw a line with a gradient brush (fade out from start to end point) -


my task pretty simple: draw line point point b , set different colors @ point , b, e.g. white @ , black @ b fade out line.

i tried doing using lineargradientbrush:

var brush = new lineargradientbrush(                     color.fromargb(255, 0, 0, 0),                     color.fromargb(255, 255, 0, 0), new point(0, 0), new point(1,1)); var pen = new pen(brush, 10.0);  dc.drawline(pen, new point (300, 300), new point(300, 100)); 

but not produce wanted results since gradientbrush mapped according bounding box of object. therefore, results line going 100/100 200/200 , line going opposite direction same (which not want).

how solve using wpf? thanks.

edit: need use low level graphics functions (such drawline) performance reasons because draw lot of lines.

how use lineargradientbrush article examples in both xaml , c# code.

try approach , please tell me need. take attention please lines drawn in opposite directions.

public partial class window1 : window   {     public window1()     {       initializecomponent();           var image = new image                     {                       source = new drawingimage(createdrawingvisualrectangle(new point(300,300), new point(300,100) ).drawing),                       stretch = stretch.none,                     };        var image2 = new image                      {                        margin = new thickness(10, 0, 0, 0),         source = new drawingimage(createdrawingvisualrectangle(new point(300, 100), new point(300, 300)).drawing),         stretch = stretch.none,       };        var stackpanel = new stackpanel() {orientation = orientation.horizontal};           stackpanel.children.add(image);       stackpanel.children.add(image2);        content = stackpanel;     }      // create drawingvisual contains rectangle.     private drawingvisual createdrawingvisualrectangle(point start, point end)     {       drawingvisual drawingvisual = new drawingvisual();        // retrieve drawingcontext in order create new drawing content.       drawingcontext drawingcontext = drawingvisual.renderopen();        // create rectangle , draw in drawingcontext.       var gradientstopcollection = new gradientstopcollection                                      {                                        new gradientstop(color.fromargb(255, 0, 0, 0), 0.0),                                        new gradientstop(color.fromargb(255, 255, 0, 0), 0.75)                                      };        var brush = new lineargradientbrush(gradientstopcollection);       var pen = new pen(brush, 10.0);        var vector1 = new vector(start.x, start.y);       var vector2 = new vector(end.x, end.y);        if (vector1.length < vector2.length)       {         brush.startpoint = new point(1, 1);         brush.endpoint = new point(0, 0);       }        drawingcontext.drawline(pen, start, end);       drawingcontext.close();       return drawingvisual;     }   } 

Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -