public static TerminalTriggerSet LoadFromXml(XmlElement parent)
        {
            var sets     = new TerminalTriggerSet();
            var nodeList = parent.GetElementsByTagName("triggerSet");

            if (nodeList == null || nodeList.Count == 0)
            {
                return(sets);
            }
            var node = (XmlElement)nodeList[0];

            if (node.Attributes["formula"] != null)
            {
                sets.Formula = node.Attributes["formula"].Value;
            }

            foreach (XmlElement child in node.ChildNodes)
            {
                var trigger = TerminalScriptTrigger.LoadFromXml(child);
                if (trigger != null)
                {
                    sets.triggers.Add(trigger);
                }
            }

            return(sets);
        }
        private void BtnAcceptClick(object sender, EventArgs e)
        {
            if (tabControl.SelectedTab == tabPageEmpty)
            {
                trigger      = null;
                DialogResult = DialogResult.OK;
                return;
            }

            // котировки
            if (tabControl.SelectedTab == tabPageQuote)
            {
                trigger = new ScriptTriggerNewQuote
                {
                    quotesToCheck = cbQuote.GetCheckedItems().Cast <string>().ToList()
                };
                DialogResult = DialogResult.OK;
                return;
            }

            // ордера
            if (tabControl.SelectedTab == tabPageOrder)
            {
                trigger = new ScriptTriggerDealEvent();
                for (var i = 0; i < cbOrder.Items.Count; i++)
                {
                    if (!cbOrder[i])
                    {
                        continue;
                    }
                    var evType = (ScriptTriggerDealEventType)cbOrder.Items[i];
                    ((ScriptTriggerDealEvent)trigger).eventType |= evType;
                }

                DialogResult = DialogResult.OK;
                return;
            }

            // формула
            if (tabControl.SelectedTab == tabPageFormula)
            {
                var trigForm = new ScriptTriggerPriceFormula {
                    Formula = tbFormula.Text
                };
                if (!string.IsNullOrEmpty(trigForm.FormulaError))
                {
                    MessageBox.Show("Ошибка в формуле: \n" + trigForm.FormulaError,
                                    "Ошибка ввода", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                trigger      = trigForm;
                DialogResult = DialogResult.OK;
            }
        }
        private void BtnAcceptClick(object sender, EventArgs e)
        {
            if (tabControl.SelectedTab == tabPageEmpty)
            {
                trigger = null;
                DialogResult = DialogResult.OK;
                return;
            }

            // котировки
            if (tabControl.SelectedTab == tabPageQuote)
            {
                trigger = new ScriptTriggerNewQuote
                    {
                        quotesToCheck = cbQuote.GetCheckedItems().Cast<string>().ToList()
                    };
                DialogResult = DialogResult.OK;
                return;
            }

            // ордера
            if (tabControl.SelectedTab == tabPageOrder)
            {
                trigger = new ScriptTriggerDealEvent();
                for (var i = 0; i < cbOrder.Items.Count; i++)
                {
                    if (!cbOrder[i]) continue;
                    var evType = (ScriptTriggerDealEventType) cbOrder.Items[i];
                    ((ScriptTriggerDealEvent) trigger).eventType |= evType;
                }

                DialogResult = DialogResult.OK;
                return;
            }

            // формула
            if (tabControl.SelectedTab == tabPageFormula)
            {
                var trigForm = new ScriptTriggerPriceFormula {Formula = tbFormula.Text};
                if (!string.IsNullOrEmpty(trigForm.FormulaError))
                {
                    MessageBox.Show("Ошибка в формуле: \n" + trigForm.FormulaError,
                                    "Ошибка ввода", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                trigger = trigForm;
                DialogResult = DialogResult.OK;
            }
        }
Example #4
0
 protected virtual TerminalScript LoadScriptFromXml(XmlElement node)
 {
     try
     {
         PropertyXMLTagAttribute.InitObjectProperties(this, node);
         var triggers = node.GetElementsByTagName("trigger");
         if (triggers.Count > 0)
         {
             Trigger = TerminalScriptTrigger.LoadFromXml((XmlElement)triggers[0]);
         }
     }
     catch (Exception ex)
     {
         Logger.ErrorFormat("Error while LoadScriptFromXml() for \"{0}\": {1}",
                            ScriptName, ex);
         return(null);
     }
     return(this);
 }
 public TriggerSetupDialog(TerminalScriptTrigger trigger) : this()
 {
     this.trigger = trigger;
     SetupUI();
 }
Example #6
0
 protected virtual TerminalScript LoadScriptFromXml(XmlElement node)
 {
     try
     {
         PropertyXMLTagAttribute.InitObjectProperties(this, node);
         var triggers = node.GetElementsByTagName("trigger");
         if (triggers.Count > 0)
             Trigger = TerminalScriptTrigger.LoadFromXml((XmlElement)triggers[0]);
     }
     catch (Exception ex)
     {
         Logger.ErrorFormat("Error while LoadScriptFromXml() for \"{0}\": {1}",
             ScriptName, ex);
         return null;
     }
     return this;
 }
 public TriggerSetupDialog(TerminalScriptTrigger trigger)
     : this()
 {
     this.trigger = trigger;
     SetupUI();
 }