Silverlight layout Panel Plus control methods
Ways to add text:
TextBlock txt = new TextBlock (); Txt. Text = TMC; Txt. FontSize = 12; Txt. Foreground = T_brush; Txt. FlowDirection = Flowdirection.lefttoright; Double Tt_angle = this. Getangle (EB, EE); Double t_angle = Tt_angle; T_angle = T_angle * 180.0/this. PI; if (T_angle >=) {t_angle-= 360; } t_angle = 360-t_angle; Fixed for clockwise Rotate direction//rotatetransform//skewtransform rotatetransform rt = new Rotate Transform (); Rt. Angle = T_angle; Clockwise rotate direction Rt. CenterX = 0; Rt. CenterY = 0; Txt. RenderTransform = RT; Txt. Rendertransformorigin = new Point (t_atp.x, t_atp.y); Txt. SEtvalue (Canvas.leftproperty, t_atp.x); Txt. SetValue (Canvas.topproperty, T_ATP.Y); THIS.CROOT.CHILDREN.ADD (TXT); //----
Ways to add a line:
Brush t_brush=new SolidColorBrush (this. LineColor); Double p_sx = This.wfView.MapToScreen_X ((double) rt_t.sx); Double P_sy = This.wfView.MapToScreen_Y ((double) rt_t.sy); Double p_ex = This.wfView.MapToScreen_X ((double) rt_t.ex); Double P_ey = This.wfView.MapToScreen_Y ((double) rt_t.ey); POINTD EB = new Pointd (); Eb. X = (double) rt_t.sx; Eb. Y = (double) rt_t.sy; Pointd ee = new Pointd (); Ee. X = (double) rt_t.ex; Ee. Y = (double) Rt_t.ey; Draw a line (with a Polygon object to add only two points to complete) Polygon T_line = new Polygon (); T_line. Points.Add (new Point (P_SX, P_sy)); T_line. Points.Add (new Point (P_EX, P_ey)); T_line. Points.Add (new Point (P_SX, P_sy)); T_line. StrokeThickness = 2; T_line. Opacity = 0.5; T_line. Width = 2; T_line. StrOke = T_brush; T_line. Fill = T_brush; THIS.CROOT.CHILDREN.ADD (T_line);
Ways to add pictures and rectangles:
BitmapImage img = new BitmapImage (); Img. CreateOptions = Bitmapcreateoptions.none; String path = "/appsilverlight;component/workflownodeimagedir/png/" + t; Stream s = application.getresourcestream (new Uri (Path, urikind.relative)). Stream; Img. SetSource (s); Image ui_img = new Image (); Ui_img. Source = img; COMPUTE node upper-left corner coordinates double top_x = (int) p_x; top_x = top_x-img. PIXELWIDTH/2; Double top_y = (int) p_y; Top_y = top_y-img. PIXELHEIGHT/2; Ui_img. SetValue (Canvas.leftproperty, top_x); Ui_img. SetValue (Canvas.topproperty, top_y); THIS.CROOT.CHILDREN.ADD (UI_IMG); Draw node Outer box {RectangleRect = new Rectangle (); Rect. Stroke = T_brush; Rect. Fill = new SolidColorBrush (colors.transparent); Rect. SetValue (Canvas.leftproperty, top_x); Rect. SetValue (Canvas.topproperty, top_y); Rect. Width = img. Pixelwidth; Rect. Height = img. Pixelheight; THIS.CROOT.CHILDREN.ADD (rect); }}//Add node name {//Draw node name string ACTMC = Rt_act. ACTMC; TextBlock txt = new TextBlock (); Txt. Text = ACTMC; Txt. FontSize = 12; Txt. Foreground = T_brush; char[] longline = ACTMC. ToCharArray (); Fixed node name display position double T_txtlen = longline.length/2.0; T_txtlen = T_txtlen * txt. FontSize; Double x = P_x-t_txtlen; Double y = p_y + 24 + 0; Txt. SetValue (Canvas.leftproperty, x); Txt. SetValue (Canvas.topproperty, y); THIS.CROOT.CHILDREN.ADD (TXT);
Silverlight layout Panel Plus control methods