Пример #1
0
        public void AddActionControl(ActionImplementation actImpl)
        {
            if (actImpl.Location.X == 0 && actImpl.Location.Y == 0)
            {
                actImpl.Location = new Point(-_translateTransform.X, -_translateTransform.Y);
            }
            ActionControl ac = new ActionControl();

            Canvas.SetLeft(ac, actImpl.Location.X);
            Canvas.SetTop(ac, actImpl.Location.Y);
            ac.ActionImplementation = actImpl;
            actImpl.UIActionControl = ac;
            dragCanvas.Children.Add(ac);
            ac.PreviewMouseRightButtonDown += UserControl_PreviewMouseRightButtonDown;
            DragCanvas.SetCanBeDragged(ac, false);

            ac.Equal.MouseDown        += new MouseButtonEventHandler(Output_MouseDown);
            ac.Smaller.MouseDown      += new MouseButtonEventHandler(Output_MouseDown);
            ac.SmallerEqual.MouseDown += new MouseButtonEventHandler(Output_MouseDown);
            ac.Larger.MouseDown       += new MouseButtonEventHandler(Output_MouseDown);
            ac.LargerEqual.MouseDown  += new MouseButtonEventHandler(Output_MouseDown);
            ac.NotEqual.MouseDown     += new MouseButtonEventHandler(Output_MouseDown);
            ac.EntryPoint.MouseDown   += new MouseButtonEventHandler(EntryPoint_MouseDown);
            ac.LayoutUpdated          += new EventHandler(ac_LayoutUpdated);
            ac.MouseEnter             += new MouseEventHandler(ac_MouseEnter);
            ac.MouseLeave             += new MouseEventHandler(ac_MouseLeave);

            ac.RenderTransform = _translateTransform;

            if (!(actImpl is ActionStart))
            {
                ac.ContextMenu = itemContextMenu;
            }
        }
Пример #2
0
 void b_PreviewMouseMove(object sender, MouseEventArgs e)
 {
     if (_clickedObject == sender)
     {
         if (e.LeftButton == MouseButtonState.Pressed)
         {
             Button b = sender as Button;
             if (b != null)
             {
                 Point p = e.GetPosition(b);
                 if (p.X != _clickPosition.X || p.Y != _clickPosition.Y)
                 {
                     ActionImplementation ai = b.Tag as ActionImplementation;
                     if (ai != null)
                     {
                         _clickedObject = null;
                         e.Handled      = true;
                         DragDrop.DoDragDrop(b, b.Tag.GetType().ToString(), DragDropEffects.Move);
                         Core.ApplicationData.Instance.Logger.AddLog(this, Core.Logger.Level.Info, "DragDrop.DoDragDrop");
                     }
                 }
             }
         }
     }
 }
Пример #3
0
        public void RemoveOutputConnection(ActionImplementation impl, Operator op)
        {
            var oci = (from c in _outputConnectionInfo where c.ConnectedAction == impl && c.OutputOperator == op select c).FirstOrDefault();

            if (oci != null)
            {
                _outputConnectionInfo.Remove(oci);
            }
        }
Пример #4
0
        public void RemoveOutputConnection(ActionImplementation impl)
        {
            List <OutputConnectionInfo> ocil = (from c in _outputConnectionInfo where c.ConnectedAction == impl select c).ToList();

            foreach (var oci in ocil)
            {
                _outputConnectionInfo.Remove(oci);
            }
        }
Пример #5
0
        void b_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            Type                 t           = (sender as Button).Tag.GetType();
            ConstructorInfo      constructor = t.GetConstructor(Type.EmptyTypes);
            ActionImplementation obj         = (ActionImplementation)constructor.Invoke(null);

            obj.ID = Guid.NewGuid().ToString("N");
            ActiveActionFlow.Actions.Add(obj);
            actionBuilderEditor1.AddActionControl(obj);
            _clickedObject = null;
        }
Пример #6
0
        private void addConnector(ActionImplementation a, ActionImplementation c, Grid g)
        {
            ConnectionInfo ci = new ConnectionInfo();

            ci.StartActionControl = a.UIActionControl;
            ci.StartConnector     = g;
            ci.EndActionControl   = c.UIActionControl;
            ci.EndConnector       = c.UIActionControl.EntryPoint;

            Line el = new Line();

            el.Cursor          = Cursors.Pen;
            el.RenderTransform = _translateTransform;
            Point p = g.TranslatePoint(new Point(g.ActualWidth / 2, g.ActualHeight), dragCanvas);

            el.X1              = p.X;
            el.Y1              = p.Y;
            p                  = c.UIActionControl.EntryPoint.TranslatePoint(new Point(c.UIActionControl.EntryPoint.ActualWidth / 2, c.UIActionControl.EntryPoint.ActualHeight), dragCanvas);
            el.X2              = p.X;
            el.Y2              = p.Y;
            el.Stroke          = (g.Children[0] as Label).Foreground;
            el.StrokeThickness = 2.0;
            dragCanvas.Children.Insert(0, el);
            DragCanvas.SetCanBeDragged(el, false);
            ci.ConnectionLine = el;
            _connectionInfo.Add(ci);
            el.MouseEnter += new MouseEventHandler(el_MouseEnter);
            el.MouseLeave += new MouseEventHandler(el_MouseLeave);
            el.ContextMenu = itemContextMenu;

            Label lb = new Label();

            ci.Label      = lb;
            lb.FontWeight = FontWeights.Bold;
            lb.Background = new SolidColorBrush(Colors.LightGray);
            if (_showConnectionLabels)
            {
                lb.Visibility = System.Windows.Visibility.Visible;
            }
            else
            {
                lb.Visibility = System.Windows.Visibility.Hidden;
            }
            lb.RenderTransform = _translateTransform;
            dragCanvas.Children.Add(lb);
            DragCanvas.SetCanBeDragged(lb, false);
            el.LayoutUpdated += new EventHandler(el_LayoutUpdated);
            PositionConnectionLineLabel(ci);
        }
Пример #7
0
 public bool ConnectToOutput(ActionImplementation impl, Operator op)
 {
     if ((from c in _outputConnectionInfo where c.ConnectedAction == impl && c.OutputOperator == op select c).FirstOrDefault() == null)
     {
         OutputConnectionInfo oci = new OutputConnectionInfo();
         oci.OutputOperator  = op;
         oci.ConnectedAction = impl;
         _outputConnectionInfo.Add(oci);
         return(true);
     }
     else
     {
         return(false);
     }
 }
Пример #8
0
        private void dragCanvas_Drop(object sender, DragEventArgs e)
        {
            if (_activeActionListImplementations != null && _activeActionListImplementations.Count > 0)
            {
                string ai = e.Data.GetData(typeof(string)) as string;
                if (!string.IsNullOrEmpty(ai))
                {
                    //Core.ApplicationData.Instance.Logger.AddLog(this, Core.Logger.Level.Info, "dragCanvas_Drop");

                    Type                 t           = Assembly.GetExecutingAssembly().GetType(ai);
                    ConstructorInfo      constructor = t.GetConstructor(Type.EmptyTypes);
                    ActionImplementation obj         = (ActionImplementation)constructor.Invoke(null);
                    obj.ID = Guid.NewGuid().ToString("N");
                    _activeActionListImplementations.Add(obj);
                    Point p = e.GetPosition(this);
                    obj.Location = new Point(-_translateTransform.X + p.X / scaler.ScaleX, -_translateTransform.Y + p.Y / scaler.ScaleY);
                    AddActionControl(obj);
                }
            }
        }
Пример #9
0
 private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (ActiveActionFlow == null)
     {
         actionBuilderEditor1.CommitData();
         actionBuilderEditor1.Clear(null);
     }
     else
     {
         actionBuilderEditor1.CommitData();
         actionBuilderEditor1.Clear(ActiveActionFlow.Actions);
         ActionImplementation startAction = (from a in ActiveActionFlow.Actions where a is ActionStart select a).FirstOrDefault();
         if (startAction != null)
         {
             if (startAction.UIActionControl != null)
             {
                 startAction.UIActionControl.Title.Content = string.Format("{0}\r\n{1}", Localization.TranslationManager.Instance.Translate("Start"), ActiveActionFlow.Name);
             }
         }
     }
 }
Пример #10
0
        private void getActionFlowsFromXml(XmlDocument doc)
        {
            List <ActionImplementation> allActionImpl = new List <ActionImplementation>();

            XmlNodeList nl = doc.SelectNodes("/flows/flow");

            foreach (XmlNode n in nl)
            {
                ActionFlow af = new ActionFlow();
                af.Name    = n.Attributes["name"].Value;
                af.ID      = n.Attributes["id"].Value;
                af.Actions = new List <ActionImplementation>();

                XmlNodeList al = n.SelectNodes("action");
                foreach (XmlNode a in al)
                {
                    Type                 t           = Type.GetType(a.Attributes["type"].Value);
                    ConstructorInfo      constructor = t.GetConstructor(Type.EmptyTypes);
                    ActionImplementation obj         = (ActionImplementation)constructor.Invoke(null);
                    obj.ID       = a.Attributes["id"].Value;
                    obj.Location = new System.Windows.Point((double)int.Parse(a.Attributes["x"].Value), (double)int.Parse(a.Attributes["y"].Value));

                    af.Actions.Add(obj);
                    allActionImpl.Add(obj);

                    XmlNodeList vl = a.SelectNodes("values/value");
                    foreach (XmlNode v in vl)
                    {
                        obj.Values.Add(v.InnerText);
                    }
                }

                ActionFlows.Add(af);
            }

            //all actions are created, now we can match the ID's for the connections.
            nl = doc.SelectNodes("/flows/flow/action");
            foreach (XmlNode n in nl)
            {
                ActionImplementation          ai = (from ac in allActionImpl where ac.ID == n.Attributes["id"].Value select ac).FirstOrDefault();
                XmlNodeList                   conl;
                ActionImplementation.Operator op = ai.AllowOperators;
                if ((op & ActionImplementation.Operator.Equal) != 0)
                {
                    conl = n.SelectNodes("Equal/ID");
                    foreach (XmlNode con in conl)
                    {
                        ai.ConnectToOutput((from ac in allActionImpl where ac.ID == con.InnerText select ac).FirstOrDefault(), ActionImplementation.Operator.Equal);
                    }
                }
                if ((op & ActionImplementation.Operator.Larger) != 0)
                {
                    conl = n.SelectNodes("Larger/ID");
                    foreach (XmlNode con in conl)
                    {
                        ai.ConnectToOutput((from ac in allActionImpl where ac.ID == con.InnerText select ac).FirstOrDefault(), ActionImplementation.Operator.Larger);
                    }
                }
                if ((op & ActionImplementation.Operator.LargerOrEqual) != 0)
                {
                    conl = n.SelectNodes("LargerOrEqual/ID");
                    foreach (XmlNode con in conl)
                    {
                        ai.ConnectToOutput((from ac in allActionImpl where ac.ID == con.InnerText select ac).FirstOrDefault(), ActionImplementation.Operator.LargerOrEqual);
                    }
                }
                if ((op & ActionImplementation.Operator.Less) != 0)
                {
                    conl = n.SelectNodes("Less/ID");
                    foreach (XmlNode con in conl)
                    {
                        ai.ConnectToOutput((from ac in allActionImpl where ac.ID == con.InnerText select ac).FirstOrDefault(), ActionImplementation.Operator.Less);
                    }
                }
                if ((op & ActionImplementation.Operator.LessOrEqual) != 0)
                {
                    conl = n.SelectNodes("LessOrEqual/ID");
                    foreach (XmlNode con in conl)
                    {
                        ai.ConnectToOutput((from ac in allActionImpl where ac.ID == con.InnerText select ac).FirstOrDefault(), ActionImplementation.Operator.LessOrEqual);
                    }
                }
                if ((op & ActionImplementation.Operator.NotEqual) != 0)
                {
                    conl = n.SelectNodes("NotEqual/ID");
                    foreach (XmlNode con in conl)
                    {
                        ai.ConnectToOutput((from ac in allActionImpl where ac.ID == con.InnerText select ac).FirstOrDefault(), ActionImplementation.Operator.NotEqual);
                    }
                }
            }
        }
Пример #11
0
 public bool ConnectToOutput(ActionImplementation impl, Operator op)
 {
     if ((from c in _outputConnectionInfo where c.ConnectedAction == impl && c.OutputOperator == op select c).FirstOrDefault() == null)
     {
         OutputConnectionInfo oci = new OutputConnectionInfo();
         oci.OutputOperator = op;
         oci.ConnectedAction = impl;
         _outputConnectionInfo.Add(oci);
         return true;
     }
     else
     {
         return false;
     }
 }
Пример #12
0
 public void RemoveOutputConnection(ActionImplementation impl, Operator op)
 {
     var oci = (from c in _outputConnectionInfo where c.ConnectedAction == impl && c.OutputOperator == op select c).FirstOrDefault();
     if (oci != null)
     {
         _outputConnectionInfo.Remove(oci);
     }
 }
Пример #13
0
 public void RemoveOutputConnection(ActionImplementation impl)
 {
     List<OutputConnectionInfo> ocil = (from c in _outputConnectionInfo where c.ConnectedAction == impl select c).ToList();
     foreach (var oci in ocil)
     {
         _outputConnectionInfo.Remove(oci);
     }
 }