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; WPF.JoshSmith.Controls.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; } }
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); } }
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); } }
void b_Click(object sender, EventArgs e) { Type t = (sender as Button).Tag.GetType(); ConstructorInfo constructor = t.GetConstructor(new Type[] { typeof(Framework.Interfaces.ICore) }); object[] parameters = new object[] { Core }; ActionImplementation obj = (ActionImplementation)constructor.Invoke(parameters); obj.ID = Guid.NewGuid().ToString("N"); _activeFlow.Actions.Add(obj); actionBuilderEditor1.AddActionControl(obj); }
public ServerConnectionForm(ActionBuilder owner, Framework.Interfaces.ICore core) : this() { _owner = owner; _core = core; var af = (owner.ChildForm as ActionBuilderForm).AvailableActionFlows; if (af != null) { foreach (var a in af) { ActionImplementation startAction = (from sa in a.Actions where sa is ActionStart select sa).FirstOrDefault(); if (startAction != null) { FlowInfo fi = new FlowInfo(); fi.Author = ""; fi.Created = DateTime.MinValue; fi.Modified = DateTime.MinValue; fi.Description = ""; fi.Name = a.Name; fi.ID = startAction.ID; fi.IsPublic = false; fi.ActionFlow = a; comboBox1.Items.Add(fi); } } } flowsList1.flowList.SelectionChanged += new System.Windows.Controls.SelectionChangedEventHandler(flowList_SelectionChanged); this.Text = string.Format("{0} - {1}", Utils.LanguageSupport.Instance.GetTranslation(STR_TITLE1), Utils.LanguageSupport.Instance.GetTranslation(STR_TITLE2)); this.groupBox2.Text = Utils.LanguageSupport.Instance.GetTranslation(STR_SERVERFLOWS); this.groupBox3.Text = Utils.LanguageSupport.Instance.GetTranslation(STR_YOURFLOWS); this.radioButton1.Text = Utils.LanguageSupport.Instance.GetTranslation(STR_YOURUPLOADED); this.radioButton2.Text = Utils.LanguageSupport.Instance.GetTranslation(STR_ALLPUBLICFLOWS); this.label3.Text = Utils.LanguageSupport.Instance.GetTranslation(STR_DESCRIPTION); this.label6.Text = Utils.LanguageSupport.Instance.GetTranslation(STR_DESCRIPTION); flowsList1.flowList.Columns[0].Header = Utils.LanguageSupport.Instance.GetTranslation(STR_NAME); flowsList1.flowList.Columns[1].Header = Utils.LanguageSupport.Instance.GetTranslation(STR_AUTHOR); flowsList1.flowList.Columns[2].Header = Utils.LanguageSupport.Instance.GetTranslation(STR_CREATED); flowsList1.flowList.Columns[3].Header = Utils.LanguageSupport.Instance.GetTranslation(STR_MODIFIED); flowsList1.flowList.Columns[4].Header = Utils.LanguageSupport.Instance.GetTranslation(STR_PUBLIC); this.button3.Text = Utils.LanguageSupport.Instance.GetTranslation(STR_DOWNLOAD); this.button4.Text = Utils.LanguageSupport.Instance.GetTranslation(STR_DELETE); this.label4.Text = Utils.LanguageSupport.Instance.GetTranslation(STR_FLOW); this.button5.Text = Utils.LanguageSupport.Instance.GetTranslation(STR_UPLOAD); this.checkBox1.Text = Utils.LanguageSupport.Instance.GetTranslation(STR_PUBLIC); this.button6.Text = Utils.LanguageSupport.Instance.GetTranslation(STR_OK); }
private ActionFlow CopyAs(ActionFlow fq, string newName) { ActionFlow target = new ActionFlow(); target.Name = newName; target.Actions = new List <ActionImplementation>(); Hashtable renamedIds = new Hashtable(); foreach (ActionImplementation ai in fq.Actions) { Type t = ai.GetType(); ConstructorInfo constructor = t.GetConstructor(new Type[] { typeof(Framework.Interfaces.ICore) }); object[] parameters = new object[] { Core }; ActionImplementation obj = (ActionImplementation)constructor.Invoke(parameters); obj.ID = Guid.NewGuid().ToString("N"); obj.Location = new System.Windows.Point(ai.Location.X, ai.Location.Y); obj.Values.AddRange(ai.Values); renamedIds.Add(ai.ID, obj.ID); target.Actions.Add(obj); } foreach (ActionImplementation ai in fq.Actions) { string actId = (string)renamedIds[ai.ID]; ActionImplementation act = (from a in target.Actions where a.ID == actId select a).FirstOrDefault(); List <ActionImplementation.OutputConnectionInfo> srcCons = ai.GetOutputConnections(); List <ActionImplementation.OutputConnectionInfo> dstCons = act.GetOutputConnections(); foreach (ActionImplementation.OutputConnectionInfo con in srcCons) { if (con.ConnectedAction != null) { ActionImplementation.OutputConnectionInfo nCon = new ActionImplementation.OutputConnectionInfo(); nCon.OutputOperator = con.OutputOperator; string conToActId = renamedIds[con.ConnectedAction.ID] as string; if (conToActId != null) { nCon.ConnectedAction = (from a in target.Actions where a.ID == conToActId select a).FirstOrDefault(); } else { nCon.ConnectedAction = con.ConnectedAction; } dstCons.Add(nCon); } } } return(target); }
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); WPF.JoshSmith.Controls.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); WPF.JoshSmith.Controls.DragCanvas.SetCanBeDragged(lb, false); el.LayoutUpdated += new EventHandler(el_LayoutUpdated); PositionConnectionLineLabel(ci); }
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); } }
void b_MouseMove(object sender, MouseEventArgs e) { if (e.Button == System.Windows.Forms.MouseButtons.Left && _clickedObject == sender) { Button b = sender as Button; if (b != null) { ActionImplementation ai = b.Tag as ActionImplementation; if (ai != null) { b.DoDragDrop(b.Tag.GetType().ToString(), DragDropEffects.Move); _clickedObject = null; } } } }
private void button5_Click(object sender, EventArgs e) { FlowInfo fi = comboBox1.SelectedItem as FlowInfo; if (fi != null) { ActionImplementation scriptAction = (from sa in fi.ActionFlow.Actions where sa is ActionScriptAction select sa).FirstOrDefault(); ActionImplementation scriptCondition = (from sa in fi.ActionFlow.Actions where sa is ActionScript select sa).FirstOrDefault(); if (!checkBox1.Checked || (scriptAction == null && scriptCondition == null)) { List <ActionBuilderForm.ActionFlow> flowList = new List <ActionBuilderForm.ActionFlow>(); flowList.Add(fi.ActionFlow); XmlDocument content = (_owner.ChildForm as ActionBuilderForm).CreateFlowXml(flowList); if (content != null) { fi.Description = textBox1.Text; fi.IsPublic = checkBox1.Checked; Dictionary <string, string> pars = new Dictionary <string, string>(); pars.Add("IsPublic", fi.IsPublic.ToString()); pars.Add("FlowID", fi.ID); pars.Add("FlowName", fi.Name); pars.Add("FlowDescription", fi.Description); pars.Add("FlowContent", content.OuterXml); XmlDocument doc; if (ServerCall("STOREFLOW", pars, out doc) == 0) { //MessageBox.Show("SUCCESS"); if (radioButton1.Checked || fi.IsPublic) { downloadData(); } } } else { MessageBox.Show(Utils.LanguageSupport.Instance.GetTranslation(STR_ERROR), Utils.LanguageSupport.Instance.GetTranslation(STR_ERROR), MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show(Utils.LanguageSupport.Instance.GetTranslation(STR_NOSCRIPTS), Utils.LanguageSupport.Instance.GetTranslation(STR_SERVERERROR), MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
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)) { Type t = Assembly.GetExecutingAssembly().GetType(ai); ConstructorInfo constructor = t.GetConstructor(new Type[] { typeof(Framework.Interfaces.ICore) }); object[] parameters = new object[] { _activeActionListImplementations[0].Core }; ActionImplementation obj = (ActionImplementation)constructor.Invoke(parameters); 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); } } }
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { _activeFlow = comboBox1.SelectedItem as ActionFlow; if (_activeFlow == null) { actionBuilderEditor1.CommitData(); actionBuilderEditor1.Clear(null); } else { actionBuilderEditor1.CommitData(); actionBuilderEditor1.Clear(_activeFlow.Actions); ActionImplementation startAction = (from a in _activeFlow.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}", Utils.LanguageSupport.Instance.GetTranslation(STR_START), _activeFlow.Name); } } } checkButtonStates(); }
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; } }
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); } }
public override bool PrepareRun() { base.PrepareRun(); _ai = null; if (Values.Count > 0) { ActionBuilderForm.ActionFlow af = (from a in ActionBuilderForm.ActionBuilderFormInstance.AvailableActionFlows where a.Name == Values[0] select a).FirstOrDefault(); if (af != null) { _ai = (from a in af.Actions where a is ActionStart select a).FirstOrDefault(); } } return true; }
private void button3_Click(object sender, EventArgs e) { FlowInfo fi = flowsList1.flowList.SelectedItem as FlowInfo; if (fi != null) { Dictionary <string, string> pars = new Dictionary <string, string>(); pars.Add("id", fi.ID); XmlDocument doc; if (ServerCall("GETFLOWID", pars, out doc) == 0) { try { //extract flow xml XmlNode nl = doc.SelectSingleNode("/Response/FlowContent"); if (nl != null) { string xmlDoc = nl.InnerText; //add to current flows if ((_owner.ChildForm as ActionBuilderForm).ImportXmlFlow(xmlDoc)) { //add to combo comboBox1.Items.Clear(); var af = (_owner.ChildForm as ActionBuilderForm).AvailableActionFlows; if (af != null) { foreach (var a in af) { ActionImplementation startAction = (from sa in a.Actions where sa is ActionStart select sa).FirstOrDefault(); if (startAction != null) { FlowInfo afi = new FlowInfo(); afi.Author = ""; afi.Created = DateTime.MinValue; afi.Modified = DateTime.MinValue; afi.Description = ""; afi.Name = a.Name; afi.ID = startAction.ID; afi.IsPublic = false; afi.ActionFlow = a; comboBox1.Items.Add(afi); } } } comboBox1_SelectedIndexChanged(this, EventArgs.Empty); if (radioButton1.Checked) { downloadData(); } MessageBox.Show(Utils.LanguageSupport.Instance.GetTranslation(STR_DOWNLOADSUCCESS), Utils.LanguageSupport.Instance.GetTranslation(STR_SUCCESS), MessageBoxButtons.OK, MessageBoxIcon.Information); } } } catch { MessageBox.Show(Utils.LanguageSupport.Instance.GetTranslation(STR_ERROR), Utils.LanguageSupport.Instance.GetTranslation(STR_ERROR), MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }
public bool ImportXmlFlow(string xmlDoc) { bool result = false; try { XmlDocument doc = new XmlDocument(); doc.LoadXml(xmlDoc); List <ActionFlow> flows = GetActionFlowsFromXml(doc); if (flows != null && flows.Count > 0) { //for now assume 1 ActionFlow naf = flows[0]; //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; foreach (var af in _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) { //ask overwrite DialogResult dr = MessageBox.Show(Utils.LanguageSupport.Instance.GetTranslation(STR_OVERWRITE), Utils.LanguageSupport.Instance.GetTranslation(STR_WARNING), MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning); if (dr == System.Windows.Forms.DialogResult.Cancel) { return(result); } else if (dr == System.Windows.Forms.DialogResult.Yes) { //remove old comboBox1.Items.Remove(found); _actionFlows.Remove(found); (this.OwnerPlugin as ActionBuilder).DeleteAction(found.Name); Framework.Interfaces.IPluginUIMainWindow main = (from Framework.Interfaces.IPluginUIMainWindow a in Core.GetPlugin(Framework.PluginType.UIMainWindow) select a).FirstOrDefault(); main.RemoveAction(OwnerPlugin, "Action builder", found.Name); //insert new //but first check name int index = 0; while ((from a in _actionFlows where a.Name.ToLower() == naf.Name.ToLower() select a).Count() > 0) { index++; naf.Name = string.Format("{0}{1}", naf.Name, index); } _actionFlows.Add(naf); (this.OwnerPlugin as ActionBuilder).AddNewAction(naf.Name); main.AddAction(OwnerPlugin, "Action builder", naf.Name); comboBox1.Items.Add(naf); comboBox1_SelectedIndexChanged(this, EventArgs.Empty); result = true; } else { //copy and add //but first check name int index = 0; while ((from a in _actionFlows where a.Name.ToLower() == naf.Name.ToLower() select a).Count() > 0) { index++; naf.Name = string.Format("{0}{1}", naf.Name, index); } naf = CopyAs(naf, naf.Name); _actionFlows.Add(naf); (this.OwnerPlugin as ActionBuilder).AddNewAction(naf.Name); Framework.Interfaces.IPluginUIMainWindow main = (from Framework.Interfaces.IPluginUIMainWindow a in Core.GetPlugin(Framework.PluginType.UIMainWindow) select a).FirstOrDefault(); main.AddAction(OwnerPlugin, "Action builder", naf.Name); comboBox1.Items.Add(naf); result = true; } } else { //add //but first check name int index = 0; while ((from a in _actionFlows where a.Name.ToLower() == naf.Name.ToLower() select a).Count() > 0) { index++; naf.Name = string.Format("{0}{1}", naf.Name, index); } _actionFlows.Add(naf); (this.OwnerPlugin as ActionBuilder).AddNewAction(naf.Name); Framework.Interfaces.IPluginUIMainWindow main = (from Framework.Interfaces.IPluginUIMainWindow a in Core.GetPlugin(Framework.PluginType.UIMainWindow) select a).FirstOrDefault(); main.AddAction(OwnerPlugin, "Action builder", naf.Name); comboBox1.Items.Add(naf); result = true; } } button14_Click(this, EventArgs.Empty); } } catch { MessageBox.Show(Utils.LanguageSupport.Instance.GetTranslation(STR_ERRORIMPORTINGFLOW), Utils.LanguageSupport.Instance.GetTranslation(STR_ERROR), MessageBoxButtons.OK, MessageBoxIcon.Error); } return(result); }
private List <ActionFlow> GetActionFlowsFromXml(XmlDocument doc) { List <ActionFlow> 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.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(new Type[] { typeof(Framework.Interfaces.ICore) }); object[] parameters = new object[] { Core }; ActionImplementation obj = (ActionImplementation)constructor.Invoke(parameters); 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); }