Exemplo n.º 1
0
        private void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
        {
            TabPage page = this.tabControl1.SelectedTab;

            KexplorerPanel panel = null;

            foreach (Control control in page.Controls)
            {
                if (control is KexplorerPanel)
                {
                    panel = (KexplorerPanel)control;
                    break;
                }
            }
            if (panel != null)
            {
                panel.InitializeOnce();
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Load state, or, start with a fresh new panel.
        /// </summary>
        private void LoadSavedPanels()
        {
            string saveFile = Application.StartupPath + "\\KexplorerStateSave.xml";
            if (!File.Exists( saveFile ) )
            {
                this.AddNewPanel();
            } else {

                XmlDocument savedDoc = new XmlDocument();
                savedDoc.Load( saveFile );

                XmlNodeList panels = savedDoc.SelectNodes("/KexplorerState/KexplorerTab");

                if ( panels.Count == 0 )
                {
                    this.AddNewPanel();

                }
                else
                {

                    TabPage selectedPage = null;
                    foreach ( XmlNode panel in panels )
                    {

                        XmlNode nameNode = panel.SelectSingleNode("TabName");

                        XmlNode servicesNode = panel.SelectSingleNode("ServicesTab");

                        XmlNode ftpSiteNode = panel.SelectSingleNode("FtpTab");

                        if ( servicesNode != null )
                        {

                            XmlNodeList visibleServices = panel.SelectNodes("Service");
                            ArrayList serviceNames = new ArrayList();
                            foreach ( XmlNode serviceNode in visibleServices )
                            {
                                serviceNames.Add( serviceNode.InnerText );
                            }

                            TabPage x = new TabPage( nameNode.InnerText);

                            if ( panel.SelectSingleNode( "Selected" ) != null )
                            {
                                selectedPage = x;

                            }
                            ServicesPanel servicesPanel = new ServicesPanel( this );

                            ServiceMgrWorkUnit worker = new ServiceMgrWorkUnit( servicesPanel, servicesPanel);
                            servicesPanel.Manager = worker;

                            servicesPanel.Dock = System.Windows.Forms.DockStyle.Fill;

                            this.tabControl1.TabPages.Add( x );

                            x.Controls.Add( servicesPanel);
                            worker.InitalizeControl( serviceNames,null,null );

                        }
                        else if (ftpSiteNode != null)
                        {
                            //
                            // TODO: Add any constructor code after InitializeComponent call
                            //
                            var hostNode = ftpSiteNode.SelectSingleNode("Host");
                            var userNameNode = ftpSiteNode.SelectSingleNode("UserName");
                            var pwdNode = ftpSiteNode.SelectSingleNode("Pwd");
                            var targetFolderNode = ftpSiteNode.SelectSingleNode("TargetFolder");
                            var typeNode = ftpSiteNode.SelectSingleNode("Type");

                            KexplorerPanel newPanel = new KexplorerPanel(this
                                , new FtpSite(
                                    hostNode.InnerText
                                    , userNameNode.InnerText
                                    , pwdNode.InnerText
                                    , targetFolderNode.InnerText
                                    , typeNode.InnerText

                                    ));

                            newPanel.MainForm = this;

                            TabPage y = new TabPage(nameNode.InnerText);

                            newPanel.Dock = System.Windows.Forms.DockStyle.Fill;

                            y.Controls.Add(newPanel);

                            this.tabControl1.TabPages.Add(y);
                        }
                        else
                        {

                            XmlNode currentFolderNode = panel.SelectSingleNode("CurrentFolder");

                            XmlNodeList driveNodes = panel.SelectNodes("Drive");
                            ArrayList drives = new ArrayList();
                            foreach (XmlNode node in driveNodes)
                            {
                                drives.Add(node.InnerText);
                            }

                            KexplorerPanel newPanel = new KexplorerPanel(this, currentFolderNode.InnerText, drives);

                            newPanel.MainForm = this;

                            TabPage x = new TabPage(nameNode.InnerText);

                            newPanel.Dock = System.Windows.Forms.DockStyle.Fill;

                            x.Controls.Add(newPanel);

                            this.tabControl1.TabPages.Add(x);

                            if (panel.SelectSingleNode("Selected") != null)
                            {
                                selectedPage = x;
                                newPanel.InitializeOnce();
                            }
                        }

                    }

                    if ( selectedPage != null )
                    {
                        this.tabControl1.SelectedTab = selectedPage;

                    }
                }

            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Load state, or, start with a fresh new panel.
        /// </summary>
        private void LoadSavedPanels()
        {
            string saveFile = Application.StartupPath + "\\KexplorerStateSave.xml";

            if (!File.Exists(saveFile))
            {
                this.AddNewPanel();
            }
            else
            {
                XmlDocument savedDoc = new XmlDocument();
                savedDoc.Load(saveFile);


                XmlNodeList panels = savedDoc.SelectNodes("/KexplorerState/KexplorerTab");

                if (panels.Count == 0)
                {
                    this.AddNewPanel();
                }
                else
                {
                    TabPage selectedPage = null;
                    foreach (XmlNode panel in panels)
                    {
                        XmlNode nameNode = panel.SelectSingleNode("TabName");

                        XmlNode servicesNode = panel.SelectSingleNode("ServicesTab");

                        XmlNode ftpSiteNode = panel.SelectSingleNode("FtpTab");

                        if (servicesNode != null)
                        {
                            XmlNodeList visibleServices = panel.SelectNodes("Service");
                            ArrayList   serviceNames    = new ArrayList();
                            foreach (XmlNode serviceNode in visibleServices)
                            {
                                serviceNames.Add(serviceNode.InnerText);
                            }


                            TabPage x = new TabPage(nameNode.InnerText);


                            if (panel.SelectSingleNode("Selected") != null)
                            {
                                selectedPage = x;
                            }
                            ServicesPanel servicesPanel = new ServicesPanel(this);

                            ServiceMgrWorkUnit worker = new ServiceMgrWorkUnit(servicesPanel, servicesPanel);
                            servicesPanel.Manager = worker;

                            servicesPanel.Dock = System.Windows.Forms.DockStyle.Fill;

                            this.tabControl1.TabPages.Add(x);

                            x.Controls.Add(servicesPanel);
                            worker.InitalizeControl(serviceNames, null, null);
                        }
                        else if (ftpSiteNode != null)
                        {
                            //
                            // TODO: Add any constructor code after InitializeComponent call
                            //
                            var hostNode         = ftpSiteNode.SelectSingleNode("Host");
                            var userNameNode     = ftpSiteNode.SelectSingleNode("UserName");
                            var pwdNode          = ftpSiteNode.SelectSingleNode("Pwd");
                            var targetFolderNode = ftpSiteNode.SelectSingleNode("TargetFolder");
                            var typeNode         = ftpSiteNode.SelectSingleNode("Type");

                            KexplorerPanel newPanel = new KexplorerPanel(this
                                                                         , new FtpSite(
                                                                             hostNode.InnerText
                                                                             , userNameNode.InnerText
                                                                             , pwdNode.InnerText
                                                                             , targetFolderNode.InnerText
                                                                             , typeNode.InnerText

                                                                             ));


                            newPanel.MainForm = this;


                            TabPage y = new TabPage(nameNode.InnerText);


                            newPanel.Dock = System.Windows.Forms.DockStyle.Fill;

                            y.Controls.Add(newPanel);


                            this.tabControl1.TabPages.Add(y);
                        }
                        else
                        {
                            XmlNode currentFolderNode = panel.SelectSingleNode("CurrentFolder");

                            XmlNodeList driveNodes = panel.SelectNodes("Drive");
                            ArrayList   drives     = new ArrayList();
                            foreach (XmlNode node in driveNodes)
                            {
                                drives.Add(node.InnerText);
                            }

                            KexplorerPanel newPanel = new KexplorerPanel(this, currentFolderNode.InnerText, drives);


                            newPanel.MainForm = this;


                            TabPage x = new TabPage(nameNode.InnerText);


                            newPanel.Dock = System.Windows.Forms.DockStyle.Fill;

                            x.Controls.Add(newPanel);


                            this.tabControl1.TabPages.Add(x);

                            if (panel.SelectSingleNode("Selected") != null)
                            {
                                selectedPage = x;
                                newPanel.InitializeOnce();
                            }
                        }
                    }

                    if (selectedPage != null)
                    {
                        this.tabControl1.SelectedTab = selectedPage;
                    }
                }
            }
        }