Exemplo n.º 1
0
        private FrameState GetFrameState()
        {
            FrameState fs = new FrameState();

            fs.bShowMaximized = this.WindowState == FormWindowState.Maximized;
            fs.bShowTreeControl = navTree.Visible;
            fs.bReadOnly = this.menuItem_Save.Enabled ? false : true;
            fs.left = this.Location.X;
            fs.top = this.Location.Y;
            fs.bottom = fs.top + this.Size.Height - 1;
            fs.right = fs.left + this.Size.Width - 1;

            return fs;
        }
Exemplo n.º 2
0
        public void ReadPluginNodeInfoFromConsoleSettings(string filePath, FrameState state)
        {
            XmlDocument xmldoc = new XmlDocument();

            try
            {
                xmldoc.Load(filePath);

                if (xmldoc == null)
                {
                    return;
                }

                // restore the main window state
                string nodepath = "LMC_ConsoleFile/FrameState";
                XmlNode FrameStateNode = xmldoc.SelectSingleNode(nodepath);
                if (FrameStateNode != null)
                {
                    state.bShowMaximized = bool.Parse(FrameStateNode.Attributes["ShowMaximized"].Value);
                    state.bShowStatusBar = bool.Parse(FrameStateNode.Attributes["ShowStatusBar"].Value);
                    state.bShowNavigationBar = bool.Parse(FrameStateNode.Attributes["ShowNavigationBar"].Value);
                    state.bShowTreeControl = bool.Parse(FrameStateNode.Attributes["ShowNavigationTree"].Value);
                    state.bReadOnly = bool.Parse(FrameStateNode.Attributes["ReadOnly"].Value);
                }

                nodepath = "LMC_ConsoleFile/FrameState/Rectangle";
                XmlNode RectangleNode = xmldoc.SelectSingleNode(nodepath);
                if (RectangleNode != null)
                {
                    state.left = int.Parse(RectangleNode.Attributes["Left"].Value);
                    state.top = int.Parse(RectangleNode.Attributes["Top"].Value);
                    state.right = int.Parse(RectangleNode.Attributes["Right"].Value);
                    state.bottom = int.Parse(RectangleNode.Attributes["Bottom"].Value);
                }

                // reload persisted state
                nodepath = "LMC_ConsoleFile/State";
                XmlNode StateNode = xmldoc.SelectSingleNode(nodepath);
                if (StateNode != null && StateNode.ChildNodes.Count != 0)
                {
                    htState.Clear();
                    foreach (XmlNode node in StateNode.ChildNodes)
                    {
                        string sKey = node.Attributes["Name"].Value as string;
                        string sType = node.Attributes["Type"].Value as string;

                        object value = null;
                        if (sType == "String")
                            value = node.InnerText;
                        else
                            value = Convert.FromBase64String(node.InnerText);

                        htState.Add(sKey, value);
                    }
                }

                nodepath = "LMC_ConsoleFile/Views";
                XmlNode ViewsNode = xmldoc.SelectSingleNode(nodepath);
                if (ViewsNode != null && ViewsNode.ChildNodes.Count != 0)
                {
                    foreach (XmlNode node in ViewsNode.ChildNodes)
                    {
                        LACTreeNode pluginnode = null;
                        RecursivePluginNodeInfo(node, ref pluginnode, nodepath);

                        if (pluginnode != null)
                        {
                            rootNode.Nodes.Add(pluginnode);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.LogException("Manage.ReadPluginNodeInfoFromConsoleSettings()", ex);
            }
        }
Exemplo n.º 3
0
        private void ReadConsoleFile(string sFileName)
        {
            FileInfo fileInfo = new FileInfo(sFileName);
            if (fileInfo != null && fileInfo.Extension.Trim().Equals(".lmc"))
            {
                FrameState fs = new FrameState();
                sc.manage.ReadPluginNodeInfoFromConsoleSettings(sFileName, fs);

                // reestablish frame state
                if (fs.bShowMaximized)
                    this.WindowState = FormWindowState.Maximized;
                this.pivotPanel.Visible = this.splitter1.Visible = fs.bShowTreeControl;
                this.menuItem_Save.Enabled = fs.bReadOnly ? false : true;

                if (navTree.SelectedNode.Nodes.Count == 0)
                {
                    navTree.SelectedNode.Expand();
                    sc.ShowControl(navTree.SelectedNode as LACTreeNode);
                }
                else
                {
                    LACTreeNode node = navTree.SelectedNode.Nodes[0] as LACTreeNode;
                    sc.ShowControl(node);
                    node.Expand();
                    navTree.SelectedNode = node;
                }
                navTree.Select();
                IsFileOpened = true;
            }
        }
Exemplo n.º 4
0
        // public string SaveConsoleSettingsToXml(bool staturbar, Size maxPos, Size minPos)
        public string SaveConsoleSettingsToXml( FrameState state )
        {
            XmlDocument XmlDoc = new XmlDocument();

            string filePath = Path.Combine(Configurations.tempDirectory, "Console1.lmc");

            try
            {
                XmlDoc.LoadXml(Resources.ConsoleSettings);

                if (XmlDoc == null)
                {
                    return null;
                }
                XmlElement frameNode = (XmlElement)XmlDoc.GetElementsByTagName("FrameState")[0];
                if (frameNode != null && frameNode.Attributes["ShowStatusBar"] != null)
                {
                    frameNode.Attributes["ShowMaximized"].Value = state.bShowMaximized.ToString();
                    frameNode.Attributes["ShowStatusBar"].Value = state.bShowStatusBar.ToString();
                    frameNode.Attributes["ShowNavigationBar"].Value = state.bShowNavigationBar.ToString();
                    frameNode.Attributes["ShowNavigationTree"].Value = state.bShowTreeControl.ToString();
                    frameNode.Attributes["ReadOnly"].Value = state.bReadOnly.ToString();
                }
                XmlElement rectNode = (XmlElement)XmlDoc.GetElementsByTagName("Rectangle")[0];
                if (rectNode != null)
                {
                    rectNode.Attributes["Top"].Value = state.top.ToString();;
                    rectNode.Attributes["Left"].Value = state.left.ToString();;
                    rectNode.Attributes["Bottom"].Value = state.bottom.ToString();
                    rectNode.Attributes["Right"].Value = state.right.ToString();
                }
                XmlElement StateNode = (XmlElement)XmlDoc.GetElementsByTagName("State")[0];
                if (StateNode != null)
                {
                    foreach (string sKey in htState.Keys)
                    {
                        XmlElement stateElement = StateNode.OwnerDocument.CreateElement("Key");
                        stateElement.SetAttribute("Name", sKey);
                        if (htState[sKey] is string)
                        {
                            stateElement.SetAttribute("Type", "String");
                            stateElement.InnerText = htState[sKey] as string;
                        }
                        else if (htState[sKey] is byte[])
                        {
                            stateElement.SetAttribute("Type", "ByteArray");
                            stateElement.InnerText = Convert.ToBase64String(htState[sKey] as byte[]);
                        }
                        StateNode.AppendChild(stateElement);
                    }
                }
                XmlElement ViewsNode = (XmlElement)XmlDoc.GetElementsByTagName("Views")[0];
                if (ViewsNode != null)
                {
                    int Id = 0;
                    XmlElement viewElement = null;
                    TreeNodeCollection childNodes = lmcLWTreeView.Nodes[0].Nodes;

                    foreach (LACTreeNode pluginNode in childNodes)
                    {
                        pluginNode.Plugin.SerializePluginInfo(pluginNode, ref Id, out viewElement, ViewsNode, lmcLWTreeView.SelectedNode);
                        if (viewElement != null)
                        {
                            ViewsNode.AppendChild(viewElement);
                        }
                    }
                }
                XmlDoc.Save(filePath);
            }
            catch(Exception ex)
            {
                Logger.LogException("Manage.SaveConsoleSettingsToXml()", ex);
            }

            return filePath;
        }