Ejemplo n.º 1
0
        private void RuleComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            SwitchOperState();

            this._ParamPanel.Controls.Clear();
            //清空正文规则列表 on2008年7月18日
            this.TextRuleNameComboBox.Items.Clear();

            //显示参数列表
            string ruleName = this.RuleComboBox.Text;

            activeRule = activeRules[ruleName];

            Dictionary <string, ParamState> paramDic = activeRule.ParamStates;

            Debug.Assert(paramDic != null, "paramDic为空");
            if (paramDic == null)
            {
                return;
            }
            foreach (string key in paramDic.Keys)
            {
                ParamState  state = paramDic[key];
                ParamCotrol ctr   = new ParamCotrol();
                ctr.ParaName = key;
                ctr.KeyValid = state.KeyState;
                ctr.Size     = new Size(140, 28);
                this._ParamPanel.Controls.Add(ctr);
            }

            this._ParamPanel.Enabled = false;

            //add by zl on2008年7月18日
            ShowTextRuleName(activeRules[ruleName]);
        }
Ejemplo n.º 2
0
 public ParamNode(string name, string paramType, bool multiple, string description="", PlanNode parent=null) : base(name, description, parent)
 {
     this._paramType = paramType;
     this._multiple = multiple;
     this._paramState = ParamState.Unknown;
     this._subActions = new ArrayList();
     this._values = new ArrayList();
 }
Ejemplo n.º 3
0
 public ParamNode(string name, string paramType, bool multiple, string description = "", PlanNode parent = null) : base(name, description, parent)
 {
     this._paramType  = paramType;
     this._multiple   = multiple;
     this._paramState = ParamState.Unknown;
     this._subActions = new ArrayList();
     this._values     = new ArrayList();
 }
        public OperationStateTileViewModel(Unit unit)
        {
            Unit = unit;
            Title = Unit.ShortName;
            Description = Unit.Address;
            State = Unit.State;
            Index = Unit.SymbolicName;

            Unit.UnitStateChangedEvent += UnitStateChangedEvent;
        }
Ejemplo n.º 5
0
        public void Initialize(string[] parameters)
        {
            originParam = GetSingleOrPlural(parameters, "Origin", "Origins");
            directionParam = GetSingleOrPlural(parameters, "Direction", "Directions");
            speedParam = GetSingleOrPlural(parameters, "Speed", "Speeds");

            if (originParam == ParamState.Multi ||
                directionParam == ParamState.Multi ||
                speedParam == ParamState.Multi)
                multi = true;

            foreach (string param in parameters)
                if (param == "Param")
                    paramCount++;
        }
Ejemplo n.º 6
0
        public NotificationAlarm(Unit unit, ParamState state, string code, string description, bool ack)
        {
            this.Unit = unit;
            this.Date = DateTime.Now;
            this.State = state;
            this.Prefix = "UN";
            this.Code = code;
            this.Description = description;
            this.Ack = ack;

            string[] codeComp = code.Split(new Char[] { '-' });

            if (codeComp.Length > 1)
            {
                this.Prefix = codeComp[0].Substring(0, 2).ToUpper();
            }
        }
Ejemplo n.º 7
0
 public static string ToString(ParamState state)
 {
     switch (state)
     {
         case ParamState.A:
             return "A";
         case ParamState.B:
             return "B";
         case ParamState.C:
             return "C";
         case ParamState.Idle:
             return "Idle";
         case ParamState.Unknown:
         default:
             return "Unknown";
     }
 }
Ejemplo n.º 8
0
        private int Run(string[] args)
        {
            CommandLineParser parser = new CommandLineParser(System.Environment.CommandLine, this);

            parser.Parse();

            ParamState    state           = ParamState.READY;
            string        searchPattern   = "";
            List <string> searchFilenames = new List <string>();

            for (int i = 0; i < parser.Parameters.Length; i++)
            {
                switch (state)
                {
                case ParamState.READY:
                    searchPattern = parser.Parameters[i];
                    state         = ParamState.STRING_FOUND;
                    break;

                case ParamState.STRING_FOUND:
                case ParamState.FILENAMES_FOUND:
                    searchFilenames.Add(parser.Parameters[i]);
                    state = ParamState.FILENAMES_FOUND;
                    break;
                }
            }

            if (state == ParamState.FILENAMES_FOUND)
            {
                return(doSearch(searchPattern, searchFilenames));
            }

            Console.Write(String.Format("\r\n{0}", Path.GetFileNameWithoutExtension(parser.ApplicationName)));
            CommandLineParser.SwitchInfo[] switches = parser.Switches;
            foreach (CommandLineParser.SwitchInfo si in switches)
            {
                Console.Write(String.Format(" [/{0}]", si.Name));
            }
            Console.WriteLine(" <pattern> <files>");
            foreach (CommandLineParser.SwitchInfo si in switches)
            {
                Console.WriteLine(String.Format("\t/{0} - {1}", si.Name, si.Description));
            }
            return(-1);
        }
Ejemplo n.º 9
0
 private void SetGeneralState(ParamState state)
 {
     switch (state)
     {
         case ParamState.C:
             AppearanceManager.Current.AccentColor = Color.FromRgb(0xd2, 0x00, 0x00);
             break;
         case ParamState.B:
             AppearanceManager.Current.AccentColor = Color.FromRgb(0xf0, 0xd8, 0x00);
             break;
         case ParamState.A:
             AppearanceManager.Current.AccentColor = Color.FromRgb(0x69, 0xd2, 0x00);
             break;
         default:
             AppearanceManager.Current.AccentColor = Color.FromRgb(0xa4, 0xa4, 0xa4);
             break;
     }
 }
Ejemplo n.º 10
0
        private ParamState GetSingleOrPlural(string[] parameters, string single, string plural)
        {
            ParamState state = ParamState.None;

            if (parameters.Contains(single))
            {
                state = ParamState.Single;
            }

            if (parameters.Contains(plural))
            {
                if (state == ParamState.Single)
                {
                    throw new BehaviourException(
                              String.Format("MultiSpawn cannot have both {0} and {1} defined.", single, plural)
                              );
                }
                state = ParamState.Multi;
            }
            return(state);
        }
Ejemplo n.º 11
0
        public void Initialize(string[] parameters)
        {
            originParam    = GetSingleOrPlural(parameters, "Origin", "Origins");
            directionParam = GetSingleOrPlural(parameters, "Direction", "Directions");
            speedParam     = GetSingleOrPlural(parameters, "Speed", "Speeds");

            if (originParam == ParamState.Multi ||
                directionParam == ParamState.Multi ||
                speedParam == ParamState.Multi)
            {
                multi = true;
            }

            foreach (string param in parameters)
            {
                if (param == "Param")
                {
                    paramCount++;
                }
            }
        }
Ejemplo n.º 12
0
        private void UpdateUnitState()
        {
            ThreadPool.QueueUserWorkItem(delegate(object target)
            {
                ParamState currentState = Processing.Params["common_state"].State;

                foreach (var alarmInternal in AlarmsInternal)
                {
                    if (alarmInternal.State > currentState)
                    {
                        currentState = alarmInternal.State;

                        if (currentState == ParamState.C)
                        {
                            break;
                        }
                    }
                }

                if (LastState != currentState)
                {
                    LastState = currentState;

                    if (UnitStateChangedEvent != null)
                    {
                        UnitStateChangedEvent(this, LastState);
                    }
                }
            }, null);            
        }
Ejemplo n.º 13
0
        private void CoreUpdateGeneralState()
        {
            ParamState newState = ParamState.Unknown;

            foreach (Unit unit in Units)
            {
                if (unit.State > newState)
                {
                    newState = unit.State;
                }
            }

            if (CoreGeneralState != newState) 
            {
                CoreGeneralState = newState;

                if (CoreGeneralStateChangedEvent != null)
                {
                    MainThread.EnqueueTask(delegate()
                    {
                        CoreGeneralStateChangedEvent(this, CoreGeneralState);
                    });                    
                }
            }
        }
Ejemplo n.º 14
0
 public ParamCombination(Param param, ParamState state)
 {
     this.Param = param;
     this.State = state;
 }
Ejemplo n.º 15
0
        private void BuildRuleBtn_Click(object sender, EventArgs e)
        {
            string url = this.urlTextBox.Text.Trim();

            #region  判断url的合理性
            if (!url.StartsWith("http://", StringComparison.OrdinalIgnoreCase))
            {
                url = "http://" + url;
            }

            //检查url是否是在此域名下的 及url的格式是否正确
            bool flag = CheckURl(url);
            if (!flag)
            {
                MessageBox.Show("此url不是当前域名下的网址,请重新填写");
                this.urlTextBox.Focus();
                this.urlTextBox.SelectAll();
                return;
            }

            flag = Uri.IsWellFormedUriString(url, UriKind.RelativeOrAbsolute);
            if (!flag)
            {
                MessageBox.Show("Url的网址格式不正确,请重新填写");
                this.urlTextBox.Focus();
                this.urlTextBox.SelectAll();
                return;
            }

            if (url.IndexOf("?") == -1)
            {
                MessageBox.Show("请输入动态的网址,当前网址是不能生成规则的!");
                this.urlTextBox.Focus();
                this.urlTextBox.SelectAll();
                return;
            }
            #endregion

            this._ParamPanel.Controls.Clear();
            this._ParamPanel.Enabled  = true;
            this.BuildRuleBtn.Enabled = false;
            this.SaveRuleBtn.Enabled  = true;


            Uri uri = new Uri(url);
            activeRule = new WebRule(uri);
            bool isExist = activeRules.IsExistRule(activeRule.RuleName);
            if (isExist)
            {
                MessageBox.Show("此规则已存在,请重新输入Url!");
                this.urlTextBox.Focus();
                this.urlTextBox.SelectAll();
                return;
            }
            this.ruleNameTextBox.Text = activeRule.RuleName;
            this.RuleComboBox.Text    = activeRule.RuleName;

            //如果是静态网址,则不需要显示参数列表

            Dictionary <string, ParamState> paramDic = activeRule.ParamStates;
            foreach (string key in paramDic.Keys)
            {
                ParamState  state = paramDic[key];
                ParamCotrol ctr   = new ParamCotrol();
                ctr.ParaName = key;
                ctr.KeyValid = state.KeyState;
                ctr.Size     = new Size(140, 28);
                this._ParamPanel.Controls.Add(ctr);
            }

            //add on 2008年7月18日
            TextRuleControlEnable(true);

            ruleState = WebRuleState.New;

            this.urlTextBox.ReadOnly = true;
        }
Ejemplo n.º 16
0
 public ParamRelation(List<ParamCombination> combinations, ParamState state)
 {
     this.Combinations = combinations;
     this.State = state;
 }
Ejemplo n.º 17
0
 public Alarm(string code, string description, ParamState state)
 {
     this.Code = code;
     this.Description = description;
     this.State = state;
 }
 private void UnitStateChangedEvent(object sender, ParamState state)
 {
     State = state;
     NotifyPropertyChanged("State");
 }
Ejemplo n.º 19
0
 public DebugAlarm(string code, string description, ParamState state)
 {
     Code = code;
     Description = description;
     State = state;
 }
Ejemplo n.º 20
0
 public ParamMapValue(ParamState state, string value)
 {
     this.State = state;
     this.Value = value;
 }