예제 #1
0
        public void XPathDocumentLoading()
        {
            string xml = "<customer id='1' pp:id='aba' xmlns='urn-kzu' xmlns:pp='urn-pepenamespace'><pp:order /><order id='1'>Chocolates</order></customer>";

            XPathNavigator nav = new XPathDocument(new StringReader(xml)).CreateNavigator();

            XmlReader      reader = new XPathNavigatorReader(nav);
            XPathNavigator clone  = new XPathDocument(reader).CreateNavigator();

            clone.MoveToFirstChild();
            Assert.AreEqual("customer", clone.LocalName);
            Assert.AreEqual("urn-kzu", clone.NamespaceURI);

            clone.MoveToAttribute("id", "urn-pepenamespace");
            Assert.AreEqual("aba", clone.Value);

            clone.MoveToParent();
            clone.MoveToFirstChild();
            Assert.AreEqual("pp:order", clone.Name);
            Assert.IsTrue(clone.IsEmptyElement);
        }
예제 #2
0
        public bool LoadProfile(string profileName, bool absolutepath = false)
        {
            string str = !absolutepath ? HotKeyManager._profileRootDirectory + "\\" + profileName + ".keys" : profileName;

            if (profileName == "~Default")
            {
                str = this._assetdir + "\\" + profileName + ".keys";
            }
            if (!File.Exists(str))
            {
                return(false);
            }
            this.HotKeys.Clear();
            if (profileName == "~Default")
            {
                this.DefaultHotKeys.Clear();
            }
            this._profileName = profileName;
            XPathNavigator navigator = new XPathDocument(App.GetStreamForFile(str) != null ? App.GetStreamForFile(str) : (Stream) new FileStream(str, FileMode.Open)).CreateNavigator();

            navigator.MoveToFirstChild();
            do
            {
                if (navigator.HasChildren)
                {
                    navigator.MoveToFirstChild();
                    do
                    {
                        if (navigator.HasChildren)
                        {
                            HotKeyManager.KeyCombo      keyCombo = new HotKeyManager.KeyCombo();
                            HotKeyManager.HotKeyActions key      = HotKeyManager.HotKeyActions.NoAction;
                            navigator.MoveToFirstChild();
                            do
                            {
                                switch (navigator.Name)
                                {
                                case "event":
                                    if (Enum.IsDefined(typeof(HotKeyManager.HotKeyActions), (object)navigator.Value))
                                    {
                                        key = (HotKeyManager.HotKeyActions)Enum.Parse(typeof(HotKeyManager.HotKeyActions), navigator.Value, true);
                                        break;
                                    }
                                    break;

                                case "states":
                                    keyCombo.states = navigator.Value;
                                    break;

                                case "shift":
                                    keyCombo.shift = bool.Parse(navigator.Value);
                                    break;

                                case "ctrl":
                                    keyCombo.control = bool.Parse(navigator.Value);
                                    break;

                                case "alt":
                                    keyCombo.alt = bool.Parse(navigator.Value);
                                    break;

                                case "key":
                                    keyCombo.key = !Enum.IsDefined(typeof(Keys), (object)navigator.Value) ? Keys.None : (Keys)Enum.Parse(typeof(Keys), navigator.Value, true);
                                    break;
                                }
                            }while (navigator.MoveToNext());
                            if (key != HotKeyManager.HotKeyActions.NoAction && !this.HotKeys.ContainsKey(key))
                            {
                                this.HotKeys.Add(key, keyCombo);
                                if (profileName == "~Default")
                                {
                                    this.DefaultHotKeys.Add(key, keyCombo);
                                }
                            }
                            navigator.MoveToParent();
                        }
                    }while (navigator.MoveToNext());
                }
            }while (navigator.MoveToNext());
            this._loaded = true;
            foreach (HotKeyManager.HotKeyActions action in Enum.GetValues(typeof(HotKeyManager.HotKeyActions)))
            {
                if (!this.HotKeys.Keys.Contains <HotKeyManager.HotKeyActions>(action) && this.DefaultHotKeys.Keys.Contains <HotKeyManager.HotKeyActions>(action))
                {
                    this.SetHotKeyCombo(action, this.DefaultHotKeys[action]);
                }
            }
            this.SyncKeyProfile("");
            this.SaveProfile();
            return(true);
        }