コード例 #1
0
        /// <summary>
        /// 设置规则线位置
        /// </summary>
        /// <param name="RuleName"></param>
        void SetRuleLinePos(string RuleName)//,string ActiveName,Point Pos)
        {
            RuleLine    class2      = FindName(RuleName) as RuleLine;
            StateActive StartActive = FindName(class2.StrStartActive) as StateActive;
            StateActive EndActive   = FindName(class2.StrEndActive) as StateActive;

            Double X1 = StartActive.ActualHeight + Convert.ToDouble(StartActive.GetValue(Canvas.TopProperty).ToString());
            Double Y1 = StartActive.ActualWidth / 2 + Convert.ToDouble(StartActive.GetValue(Canvas.LeftProperty).ToString());

            Double X2 = Convert.ToDouble(EndActive.GetValue(Canvas.TopProperty).ToString()) - X1;
            Double Y2 = Convert.ToDouble(EndActive.GetValue(Canvas.LeftProperty).ToString()) - Y1 + EndActive.ActualWidth / 2;

            class2.SetValue(Canvas.TopProperty, X1);
            class2.SetValue(Canvas.LeftProperty, Y1);

            class2.line.X2 = Y2;
            class2.line.Y2 = X2;
            class2.SetAngleByPoint(new Point(Y2, X2));
        }