Ejemplo n.º 1
0
        /// <summary>
        /// 文字列からパラメータを解析・実行する
        /// </summary>
        /// <param name="param"></param>
        public override void ParseParameter(string param)
        {
            var ss = param.Split(new char[] { ',' });

            foreach (var s in ss)
            {
                var s2 = s.Trim();

                // インターロックグループ
                var id = s2.IndexOf("(");
                if (id >= 0)
                {
                    var gr = s2.Substring(id + 1);
                    _interlockGroup = gr.Substring(0, gr.Length - 2);
                    var fcs = (IList)_interlockGroups[_interlockGroup];
                    if (fcs == null)
                    {
                        _interlockGroups[_interlockGroup] = fcs = new ArrayList();
                    }
                    fcs.Add(this);

                    s2 = s2.Substring(0, id) + "]";
                }
                // チェックボタンのイベント登録
                if (s2.StartsWith("["))
                {
                    var s3  = s2.Substring(1, s2.Length - 2);
                    var sss = s3.Split(new char[] { '=' });
                    s2 = sss[0];
                    if (sss.Length >= 2)
                    {
                        if (Const.IsFalse(sss[1]))
                        {
                            _isOn = false;
                        }
                    }
                    _initialState = _isOn;
                    _checkBox     = (System.Windows.Forms.CheckBox)GetControl(s2);
                    if (_checkBox != null)
                    {
                        AddTrigger(_checkBox, "Click", new EventHandler(onClickCheck));
                        ThreadSafe.SetChecked(_checkBox, _isOn);
                        ThreadSafe.SetEnabled(_checkBox, _canStart);
                    }
                }
            }
            _isNoToken = true;
            Finalizers.Add(new FinalizeManager.Finalize(resetSwitch));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// パラメーターの初期化
        /// </summary>
        /// <param name="param"></param>
        public override void ParseParameter(string param)
        {
            string[] coms = param.Split(new char[] { ';' });
            foreach (string com in coms)
            {
                string[] od = com.Split(new char[] { '=' });
                if (od.Length < 2)
                {
                    continue;
                }

                if (od[0].ToLower() == "centerlock")
                {
                    _isCenterLock = Const.IsTrue(od[1]);
                }
                if (od[0].ToLower() == "samexy")
                {
                    _isSameXY = Const.IsTrue(od[1]);
                }
                if (od[0].ToLower() == "trigger")
                {
                    _trigger = new MouseState.Buttons();

                    string[] ts = od[1].Split(new char[] { '+' });
                    foreach (string t in ts)
                    {
                        if (t.ToLower() == "middle")
                        {
                            _trigger.IsButtonMiddle = true;
                        }
                        if (t.ToLower() == "button" || t.ToLower() == "left")
                        {
                            _trigger.IsButton = true;
                        }
                        if (t.ToLower() == "ctrl")
                        {
                            _trigger.IsCtrl = true;
                        }
                        if (t.ToLower() == "shift")
                        {
                            _trigger.IsShift = true;
                        }
                    }
                }
                else if (od[0].ToLower() == "cursor")
                {
                    if (od.Length == 3)
                    {
                        string[]           ts  = od[2].Split(new char[] { '.' });
                        string[]           trs = od[1].Split(new char[] { '+' });
                        MouseState.Buttons trg = new Tono.GuiWinForm.MouseState.Buttons();
                        foreach (string t in trs)
                        {
                            if (t.ToLower() == "middle")
                            {
                                trg.IsButtonMiddle = true;
                            }

                            if (t.ToLower() == "button" || t.ToLower() == "left")
                            {
                                trg.IsButton = true;
                            }

                            if (t.ToLower() == "ctrl")
                            {
                                trg.IsCtrl = true;
                            }

                            if (t.ToLower() == "shift")
                            {
                                trg.IsShift = true;
                            }
                        }
                        if (od[2].ToLower().IndexOf("cursors") != -1)
                        {
                            Type t = typeof(System.Windows.Forms.Cursors);
                            System.Reflection.PropertyInfo pi = t.GetProperty(ts[ts.Length - 1].ToString());
                            if (pi != null)
                            {
                                _EventCursor = (Cursor)pi.GetValue(null, Array.Empty <object>());
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 3
0
 private void procFeature(XmlNode node)
 {
     try
     {
         var nameAtt = node.Attributes["class"];
         if (nameAtt != null)
         {
             var type = getType(nameAtt.Value);
             if (type != null)
             {
                 var feature = ((FeatureGroupBase)_group.Peek()).AddChildFeature(type);
                 try
                 {
                     var swAtt = node.Attributes["name"];
                     if (swAtt != null)
                     {
                         if (swAtt.Value != null && swAtt.Value.Length > 0)
                         {
                             feature.Name = swAtt.Value;
                         }
                     }
                 }
                 catch (Exception)
                 {
                 }
                 try
                 {
                     var swAtt = node.Attributes["com"];
                     if (swAtt != null)
                     {
                         if (swAtt.Value != null && swAtt.Value.Length > 0)
                         {
                             feature.CommandParameter = swAtt.Value;
                         }
                     }
                 }
                 catch (Exception)
                 {
                 }
                 try
                 {
                     var swAtt = node.Attributes["enabled"];
                     if (swAtt != null)
                     {
                         if (Const.IsFalse(swAtt.Value))
                         {
                             feature.Enabled = false;
                         }
                     }
                 }
                 catch (Exception)
                 {
                 }                   // メニュー情報
                                     // フィーチャーに引数を割り当てる
                 try
                 {
                     if (string.IsNullOrEmpty(node.InnerText) == false)
                     {
                         _fiParamString.SetValue(feature, node.InnerText);
                         feature.ParseParameter(node.InnerText);
                     }
                 }
                 catch (Exception)
                 {
                 }
                 procMenuItem(node, feature);
             }
             else
             {
                 System.Diagnostics.Debug.WriteLine("Feature Loader Error : '" + nameAtt.Value + "'は実装されていないフィーチャーです");
             }
         }
     }
     catch (Exception e)
     {
         System.Diagnostics.Debug.WriteLine("Feature Loader Error 例外 : '" + e.Message + "'");
     }
 }
Ejemplo n.º 4
0
        /// <summary>
        /// 指定ファイルのXMLからメッセージを読み込む
        /// </summary>
        /// <param name="filename">ファイル名(フルパス)</param>
        /// <param name="recCheck">循環参照防止用 ファイル名記憶辞書</param>
        private void _init(string filename, IDictionary recCheck)
        {
            // 循環参照防止
            if (recCheck.Contains(filename))
            {
                return;
            }
            else
            {
                recCheck[filename] = this;
            }

            // 読み込み処理
            var xd = new XmlDocument();

            xd.Load(filename);

            var root = xd.DocumentElement;
            var week = root.GetElementsByTagName("mes");

            foreach (XmlNode node in week)
            {
                // load 属性の処理
                if (node.Attributes != null)
                {
                    XmlNode n2 = node.Attributes["load"];
                    if (n2 != null)
                    {
                        object load = n2.Value;
                        _code = load.ToString();
                        _init(makeMesFilename(load.ToString()), recCheck);
                    }
                }

                // 値の処理
                string key;
                if (node.Attributes != null && node.Attributes["key"] != null)
                {
                    key = node.Attributes["key"].Value;
                }
                else
                {
                    continue;
                }
                if (node.Attributes != null && node.Attributes["ver"] != null)
                {
                    object ver = node.Attributes["ver"].Value;
                    key = key + "@" + ver.ToString();
                }

                // 下位メッセージの処理
                var innnerN = 0;
                foreach (XmlNode cnode in node.ChildNodes)
                {
                    if (node.NodeType == XmlNodeType.Element)
                    {
                        if (cnode.Attributes != null && cnode.Attributes["key"] != null)
                        {
                            var ckey = cnode.Attributes["key"].Value;
                            _dat[key + "@" + ckey] = cnode.InnerText;
                            innnerN++;
                        }
                    }
                }
                if (innnerN == 0)
                {
                    _dat[key] = node.InnerText;
                }
            }

            // フォントの読み込み
            foreach (XmlNode fnode in root.GetElementsByTagName("font"))
            {
                if (fnode.Attributes != null)
                {
                    if (fnode.Attributes["key"] == null)
                    {
                        continue;
                    }

                    if (fnode.Attributes["face"] == null)
                    {
                        continue;
                    }

                    if (fnode.Attributes["size"] == null)
                    {
                        continue;
                    }

                    var ckey = fnode.Attributes["key"].Value;
                    var face = fnode.Attributes["face"].Value;
                    var size = float.Parse(fnode.Attributes["size"].Value);


                    string b = "0", u = "0", s = "0", i = "0";
                    if (fnode.Attributes["bold"] != null)
                    {
                        b = fnode.Attributes["bold"].Value;
                    }

                    if (fnode.Attributes["underline"] != null)
                    {
                        u = fnode.Attributes["underline"].Value;
                    }

                    if (fnode.Attributes["stlikeout"] != null)
                    {
                        s = fnode.Attributes["stlikeout"].Value;
                    }

                    if (fnode.Attributes["italic"] != null)
                    {
                        i = fnode.Attributes["italic"].Value;
                    }

                    SetFont(ckey, face, size, Const.IsTrue(b), Const.IsTrue(u), Const.IsTrue(i), Const.IsTrue(s));
                }
            }
        }