public void Load(string path)
        {
            TreeViewFrame treeView = LayoutManager.TreeView;

            try
            {
                if (!File.Exists(path))
                {
                    treeView.CreateTreeView();
                }

                // Clear TreeView.
                treeView.ClearTreeViewNodes();

                using (var stream = new FileStream(path, FileMode.OpenOrCreate))
                {
                    XmlSerializer     deserializer = new XmlSerializer(typeof(XmlProjectPersist));
                    XmlProjectPersist appPersist   = (XmlProjectPersist)deserializer.Deserialize(stream);

                    // Add databases in TreeView.
                    foreach (var database in appPersist.Databases)
                    {
                        treeView.CreateTreeViewNode(database.Key, database.Value, appPersist.IsCategoryOrder);
                    }

                    foreach (var comboBox in appPersist.ComboBoxItems)
                    {
                        LayoutManager.ComboBoxes.First(x => x.Name == comboBox.Key).Text = comboBox.Value;
                    }

                    foreach (var btn in appPersist.Buttons)
                    {
                        var currentBtn = LayoutManager.Buttons.First(x => x.Name == btn.Key);
                        currentBtn.Checked = !btn.Value;
                        currentBtn.PerformClick();
                    }

                    foreach (var stepFrame in appPersist.ChartSettings)
                    {
                        LayoutManager.StepFrames[stepFrame.Key].SetSettings(stepFrame.Value);
                    }

                    LayoutManager.TrackBar.Value = appPersist.TrackBarValue;
                }

                treeView.ExpandAll();
                treeView.SelectFirstNode();

                LayoutManager.RefreshPropertyFrame();
            }
            catch (Exception exc)
            {
                Logger.Error("Persist load error ...", exc);
                treeView.CreateTreeView();
            }
        }
Ejemplo n.º 2
0
        public void ShowTreeViewFrame()
        {
            if (TreeView.IsDisposed)
            {
                TreeView = new TreeViewFrame();
                TreeView.CreateTreeView();
            }

            TreeView.Activate();

            TreeView.Text = "Databases";
            TreeView.Show(Panel);

            TreeView.DockState = DockState.DockLeft;

            TreeView.SelectedDatabaseChanged += TreeView_SlectedDatabaseChanged;
            TreeView.PropertiesClick         += TreeView_PropertiesClick;
        }