コード例 #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
        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);
            }
        }
コード例 #3
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);
            }
        }
コード例 #4
0
ファイル: Control.xaml.cs プロジェクト: Verturin/GSAKWrapper
        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;
        }
コード例 #5
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);
        }
コード例 #6
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);
     }
 }
コード例 #7
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);
                }
            }
        }
コード例 #8
0
ファイル: Control.xaml.cs プロジェクト: Verturin/GSAKWrapper
 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);
             }
         }
     }
 }
コード例 #9
0
ファイル: Control.xaml.cs プロジェクト: Verturin/GSAKWrapper
 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);
                     }
                 }
             }
         }
     }
 }
コード例 #10
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);
     }
 }
コード例 #11
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);
     }
 }
コード例 #12
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;
     }
 }
コード例 #13
0
ファイル: Control.xaml.cs プロジェクト: Verturin/GSAKWrapper
        private void Button_Click_3(object sender, RoutedEventArgs e)
        {
            Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
            dlg.FileName   = "";                               // Default file name
            dlg.DefaultExt = ".gwf";                           // Default file extension
            dlg.Filter     = "GSAKWrapper Flows (.gwf)|*.gwf"; // Filter files by extension

            // Show open file dialog box
            Nullable <bool> result = dlg.ShowDialog();

            // Process open file dialog box results
            if (result == true)
            {
                try
                {
                    var aflws = Manager.Instance.GetActionFlows(System.IO.File.ReadAllText(dlg.FileName));
                    foreach (var naf in aflws)
                    {
                        //check if ID is already in list
                        //check for ID and name
                        ActionImplementation startAction = (from sa in naf.Actions where sa is ActionStart select sa).FirstOrDefault();
                        if (startAction != null)
                        {
                            ActionFlow found = null;
                            bool       doAdd = false;
                            foreach (var af in Manager.Instance.ActionFlows)
                            {
                                ActionImplementation startAct = (from sa in af.Actions where sa is ActionStart select sa).FirstOrDefault();
                                if (startAct != null)
                                {
                                    if (startAct.ID == startAction.ID)
                                    {
                                        found = af;
                                        break;
                                    }
                                }
                            }
                            if (found != null)
                            {
                                if (System.Windows.MessageBox.Show(string.Format(Localization.TranslationManager.Instance.Translate("Overwrite_flow_") as string, found.Name), "Warning", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
                                {
                                    if (ActiveActionFlow == found)
                                    {
                                        ActiveActionFlow = null;
                                    }
                                    Manager.Instance.ActionFlows.Remove(found);
                                    doAdd = true;
                                }
                            }
                            else
                            {
                                doAdd = true;
                            }
                            if (doAdd)
                            {
                                //insert new
                                //but first check name
                                int index = 0;
                                while ((from a in Manager.Instance.ActionFlows where a.Name.ToLower() == naf.Name.ToLower() select a).Count() > 0)
                                {
                                    index++;
                                    naf.Name = string.Format("{0}{1}", naf.Name, index);
                                }

                                Manager.Instance.ActionFlows.Add(naf);
                            }
                        }
                    }
                    SaveData();
                }
                catch
                {
                    System.Windows.MessageBox.Show("Unable to load the file.", "Error");
                }
            }
        }
コード例 #14
0
 public void FinalizeRun(ActionImplementation owner)
 {
 }
コード例 #15
0
 public void Process(ActionImplementation owner, ActionImplementation.Operator op, string inputTableName, string targetTableName)
 {
 }
コード例 #16
0
 public bool PrepareRun(ActionImplementation owner, Database.DBCon db, string tableName)
 {
     return true;
 }
コード例 #17
0
ファイル: Control.xaml.cs プロジェクト: Verturin/GSAKWrapper
        public Control()
        {
            InitializeComponent();

            DataContext = this;

            Localization.TranslationManager.Instance.LanguageChanged += Instance_LanguageChanged;

            try
            {
                Assembly asm   = Assembly.GetExecutingAssembly();
                Type[]   types = asm.GetTypes();
                foreach (Type t in types)
                {
                    if (t.IsClass &&
                        t != typeof(ActionImplementationText) &&
                        t != typeof(ActionImplementationYesNo) &&
                        t != typeof(ActionImplementationNumericValue) &&
                        t != typeof(ActionImplementationDate) &&
                        (t.BaseType == typeof(ActionImplementationCondition) ||
                         t.BaseType == typeof(ActionImplementationText) ||
                         t.BaseType == typeof(ActionImplementationYesNo) ||
                         t.BaseType == typeof(ActionImplementationNumericValue) ||
                         t.BaseType == typeof(ActionImplementationDate) ||
                         t.BaseType == typeof(ActionImplementationExecuteOnce) ||
                         t.BaseType == typeof(ActionImplementationAction)
                        )
                        )
                    {
                        ConstructorInfo      constructor = t.GetConstructor(Type.EmptyTypes);
                        ActionImplementation obj         = (ActionImplementation)constructor.Invoke(null);

                        //exception for the start
                        if (obj is ActionStart)
                        {
                            //skip. auto
                        }
                        else
                        {
                            Button b = new Button();
                            b.Tag    = obj;
                            b.Height = 25;
                            b.PreviewMouseLeftButtonDown += b_PreviewMouseLeftButtonDown;
                            b.PreviewMouseMove           += b_PreviewMouseMove;
                            b.PreviewMouseLeftButtonUp   += b_PreviewMouseLeftButtonUp;
                            switch (obj.SearchTypeTarget)
                            {
                            case SearchType.Action:
                                actionPanel.Children.Add(b);
                                break;

                            case SearchType.ExecuteOnce:
                                oncePanel.Children.Add(b);
                                break;

                            case SearchType.Attributes:
                                conditionAttributesPanel.Children.Add(b);
                                break;

                            case SearchType.Children:
                                conditionChildrenPanel.Children.Add(b);
                                break;

                            case SearchType.Custom:
                                conditionCustomPanel.Children.Add(b);
                                break;

                            case SearchType.Dates:
                                conditionDatesPanel.Children.Add(b);
                                break;

                            case SearchType.Logs:
                                conditionLogsPanel.Children.Add(b);
                                break;

                            case SearchType.Other:
                                conditionOtherPanel.Children.Add(b);
                                break;

                            case SearchType.Where:
                                conditionWherePanel.Children.Add(b);
                                break;

                            case SearchType.Extra:
                                conditionExtraPanel.Children.Add(b);
                                break;

                            case SearchType.General:
                            default:
                                conditionPanel.Children.Add(b);
                                break;
                            }
                        }
                    }
                }
            }
            catch
            {
            }

            Instance_LanguageChanged(this, EventArgs.Empty);

            if (!string.IsNullOrEmpty(Settings.Settings.Default.ActionBuilderActiveFlowName))
            {
                ActiveActionFlow = (from a in Manager.Instance.ActionFlows where a.Name == Settings.Settings.Default.ActionBuilderActiveFlowName select a).FirstOrDefault();
            }
        }
コード例 #18
0
        public List <ActionFlow> GetActionFlows(XmlDocument doc)
        {
            var result = new List <ActionFlow>();
            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);
                    }
                }

                result.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);
                    }
                }
            }
            return(result);
        }