コード例 #1
0
 void _newLine_DeleteLine(object sender, RoutedEventArgs e)
 {
     if (sender is ArrowLine)
     {
         ArrowLine line = sender as ArrowLine;
         RemoveArrowLine(line);
     }
 }
コード例 #2
0
 void CreateArrowLine(ArrowLine _newLine)
 {
     if (null == _newLine)
     {
         return;
     }
     print.Children.Add(_newLine);
     DictControls.Add(_newLine.Name, _newLine);
 }
コード例 #3
0
        void _newLine_MouseEnter(object sender, MouseEventArgs e)
        {
            ArrowLine al = sender as ArrowLine;

            if (null == al)
            {
                return;
            }
            al.Connector.Stroke          = new SolidColorBrush(Colors.Black);
            al.Connector.StrokeThickness = 5;
        }
コード例 #4
0
 void CreateArrowLine(ArrowLine _newLine)
 {
     if (null == _newLine)
     {
         return;
     }
     _newLine.DeleteLine     += new RoutedEventHandler(_newLine_DeleteLine);
     _newLine.ResetDirection += new RoutedEventHandler(_newLine_ResetDirection);
     _newLine.Background      = new SolidColorBrush(Colors.Blue);
     _newLine.MouseEnter     += new MouseEventHandler(_newLine_MouseEnter);
     _newLine.MouseLeave     += new MouseEventHandler(_newLine_MouseLeave);
     print.Children.Add(_newLine);
     DictControls.Add(_newLine.Name, _newLine);
 }
コード例 #5
0
        void act_DotMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            if (IsActivity && null != _newLine)
            {
                //-->又到里面去了,不用创建此箭头
                RemoveArrowLine(_newLine);
            }
            print_MouseLeftButtonUp(print, e);

            var p = e.GetPosition(print);
            //-->更新所有箭头坐标。
            IActivity lb = sender as IActivity;

            lb.UpdateArrowCapPoint(p);
            lb.UpdateArrowFootPoint(p);
            _newLine = null;
        }
コード例 #6
0
        void act_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            e.Handled     = false;
            _UI_IsMoveing = false;
            IsActivity    = false;
            var p = e.GetPosition(print);

            if (IsActivity)
            {
                print_MouseLeftButtonUp(print, e);
            }
            else
            {
                UIElement uie = sender as UIElement;
                if (null == uie)
                {
                    return;
                }
                double newLeft = p.X;
                double newTop  = p.Y;
                Canvas.SetLeft(uie, newLeft - _UI_X);
                Canvas.SetTop(uie, newTop - _UI_Y);
                uie.ReleaseMouseCapture();
            }
            if (sender is IActivity)
            {
                p = new Point(p.X - _UI_X, p.Y - _UI_Y);
                (sender as IActivity).UpdateArrowCapPoint(p);
                (sender as IActivity).UpdateArrowFootPoint(p);
            }
            _newLine = null;
            string a = GetWorkFlowXml();

            if (_OperatorHistory.Count > 50)
            {
                _OperatorHistory.RemoveAt(_OperatorHistory.Count - 1);
            }
            _OperatorHistory.Insert(0, a);
        }
コード例 #7
0
        void print_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            e.Handled = true;
            isMove    = true;
            Point p = e.GetPosition(print);

            if (_newLine != null && p == _newLine.StartPoint)
            {
                return;
            }

            FrameworkElement element = sender as FrameworkElement;

            element.CaptureMouse();
            double top  = p.Y;
            double left = p.X;

            _newLine          = new ArrowLine(p, p);
            _newLine.Name     = string.Format("ArrowLine_{0}", ++Index);
            _newLine.LineGuid = Wrapper.GuidValue;
            CreateArrowLine(_newLine);
        }
コード例 #8
0
        void print_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            isMove     = false;
            IsActivity = false;
            //e.Handled = false;
            FrameworkElement element = sender as FrameworkElement;

            element.ReleaseMouseCapture();
            if (_newLine == null)
            {
                return;
            }
            Point p = e.GetPosition(print);

            if (p == _newLine.StartPoint)
            {
                RemoveArrowLine(_newLine);
            }
            else
            {
                //-->如果当前的箭头,所连接的控件,与移动进去的控件不是同一控件的话。
                foreach (var v in DictControls)
                {
                    IActivity iact = v.Value as IActivity;
                    if (null == iact)
                    {
                        continue;
                    }
                    //-->获取当前控件的
                    double top  = Canvas.GetTop(v.Value);
                    double left = Canvas.GetLeft(v.Value);
                    //-->判断当前的箭头进入Activity控件区域
                    if ((p.X >= left && p.X <= (left + v.Value.Width)) && (p.Y >= top && p.Y <= (top + v.Value.Height)))
                    {
                        //-->判断当前的箭头是否可以连接到Activity控件上去。
                        if (!iact.IsConnection())
                        {
                            MessageBox.Show("不能连接");
                            RemoveArrowLine(_newLine);
                            continue;
                        }
                        //-->当前线的尾部控件与当前进入的控件相同,不进行操作
                        if (null != _newLine.ArrowFootControl && _newLine.ArrowFootControl.Equals(v.Value))
                        {
                            continue;
                        }
                        IActivity arrowFoot = _newLine.ArrowFootControl as IActivity;
                        if (arrowFoot != null && arrowFoot.CheckedArrowIsExists(iact))
                        {
                            MessageBox.Show("已经存在相同的线了");
                            RemoveArrowLine(_newLine);
                            continue;
                        }
                        string _point = string.Format("X_{0}_Y_{1}", _newLine.StartPoint.X, _newLine.StartPoint.Y);
                        if (!iact.DictArrowFootPoint.ContainsKey(_newLine.Name))
                        {
                            iact.DictArrowCapPoint.Add(_newLine.Name, _newLine);
                            _newLine.ArrowCapControl = v.Value;
                        }
                        break;
                    }
                }
            }
            _newLine = null;
        }
コード例 #9
0
        /// <summary>
        /// 导入数据
        /// </summary>
        /// <param name="root"></param>
        void ImportWorkFlow(XElement root)
        {
            if (null == root)
            {
                return;
            }
            _OldWorkFlowStr = root.ToString();
            btnClear_Click(null, null);
            this.print.Children.Add(_Cm);
            this.print.Children.Add(_txtActivityContent);
            var controls = root.Element("Controls");

            Index = controls.GetAttributeValue("Index").ConvertTo <Int32>();
            var activitys  = controls.Elements("Activity");
            var arrowlines = controls.Elements("ArrowLine");

            foreach (var v in arrowlines)
            {
                ArrowLineInfo ali = v.ToModel <ArrowLineInfo>();
                if (null == ali)
                {
                    continue;
                }
                ArrowLine al = new ArrowLine(ali.StartPoint, ali.EndPoint);
                al.Name     = ali.Name;
                al.LineGuid = ali.Guid;
                CreateArrowLine(al);
            }
            foreach (var v in activitys)
            {
                ActivityInfo ai = v.ToModel <ActivityInfo>();
                if (null == ai)
                {
                    continue;
                }

                var config = ParseActivityConfig.GetActivityConfig(ai.Type);
                if (null == config)
                {
                    continue;
                }
                var ba = Wrapper.CreateControl <XtnBaseActivity>(config.AssemblyQualifiedName);
                ba.Name         = ai.Name;
                ba.Height       = ai.Height;
                ba.Width        = ai.Width;
                ba.ActivityGUID = ai.Guid;
                ba.LabelContent = ai.Content.IsNullOrEmpty() ? config.Description : ai.Content;
                ba.CurrentLeftButtonDownPoint = ai.CurrentLeftButtonDownPoint;
                ba.CurrentEnterPoint          = ai.CurrentEnterPoint;
                CreateActivity(ba);
                Canvas.SetTop(ba, ai.Top);
                Canvas.SetLeft(ba, ai.Left);
            }

            //-->规则
            var rules        = root.Element("Relationship");
            var rulesControl = rules.Elements("Control");

            foreach (var rule in rulesControl)
            {
                string          _r_name = rule.GetAttributeValue("Name");
                XtnBaseActivity iact    = GetControlByName <XtnBaseActivity>(_r_name);
                if (null == iact)
                {
                    continue;
                }
                var caps = rule.GetAttributeValue("Cap");
                if (!caps.IsNullOrEmpty())
                {
                    var capArray = caps.Split('|');
                    foreach (var cap in capArray)
                    {
                        ArrowLine _al = GetControlByName <ArrowLine>(cap);
                        if (null == _al)
                        {
                            continue;
                        }
                        _al.ArrowFootControl = iact;
                        iact.DictArrowCapPoint.Add(_al.Name, _al);
                    }
                }
                var foots = rule.GetAttributeValue("Foot");
                if (!foots.IsNullOrEmpty())
                {
                    var footArray = foots.Split('|');
                    foreach (var foot in footArray)
                    {
                        ArrowLine _al = GetControlByName <ArrowLine>(foot);
                        if (null == _al)
                        {
                            continue;
                        }
                        _al.ArrowCapControl = iact;
                        iact.DictArrowFootPoint.Add(_al.CtrName, _al);
                    }
                }
            }
        }