• Silverlight 布局面板加控件方法



    Silverlight 布局面板加控件方法 

    加入文字的方法:

     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 >= 360)
                        {
                            t_angle -= 360;
                        }
                        t_angle = 360 - t_angle;  //修正用于顺时针rotate方向
                        //RotateTransform  //SkewTransform
                        RotateTransform rt = new RotateTransform();
                        rt.Angle = t_angle;  //顺时针rotate方向
                        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);
                        //----

    加入直线的方法:

    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;
                //画线(用面对象仅仅加入两个点来完毕)
                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);  


    加入图片和矩形框的方法:

    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;
                        //计算节点左上角坐标
                        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);
                        //
                        //画节点外边框
                        {                        
                            Rectangle rect = 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);                        
                        }
                    }
                    //加入节点名称
                    {   //画节点名称
                        string actmc = rt_act.ACTMC;
                        TextBlock txt = new TextBlock();                   
                        txt.Text = actmc;
                        txt.FontSize = 12;
                        txt.Foreground = t_Brush; 
                        char[] longLine = actmc.ToCharArray();
                        //修正节点名称显示位置
                        double t_txtLen = longLine.Length / 2.0;
                        t_txtLen = t_txtLen * txt.FontSize;
                        //
                        double x = p_x - t_txtLen;
                        dou
  • 相关阅读:
    bootstrap不同屏幕区分数值
    jq星星评分
    大話西遊
    HDU 5353 Average 贪心
    HDU 5358 First One 数学+尺取法
    生活感受
    HDU 4372 Count the Buildings 组合数学
    暑假集训-合训第九场
    一些资料
    多校-HDU 5351 MZL's Border 数学规律
  • 原文地址:https://www.cnblogs.com/wgwyanfs/p/6914976.html
Copyright © 2020-2023  润新知