예제 #1
0
        private void OpenResDlg_Load(object sender, System.EventArgs e)
        {
            if (ap != null)
            {
                if (ApCfgTitle != "" && ApCfgTitle != null)
                {
                    ap.LoadFormStates(this,
                                      ApCfgTitle);
                }
                else
                {
                    Debug.Assert(true, "若要用ap保存和恢复窗口外观状态,必须先设置ApCfgTitle成员");
                }
            }

            if (this.resTree.Servers != null)
            {
                this.resTree.Servers.ServerChanged += new ServerChangedEventHandle(Servers_ServerChanged);
            }
            // resTree.EnabledIndices = new int[] { ResTree.RESTYPE_DB };

            // 填充内容
            resTree.Fill(null);

            if (MultiSelect == true)
            {
                resTree.CheckBoxes = true;                      // 允许复选
            }

            if (this.Path != "")
            {
                ResPath respath = new ResPath(this.Path);

                // 展开到指定的节点
                if (resTree.ExpandPath(respath) == true &&
                    resTree.SelectedNode != null &&
                    EnabledIndices != null)
                {
                    // 2013/2/15
                    // 如果下一级是全部灰色的节点,则不要展开它们
                    bool bFound = false;
                    foreach (TreeNode child in resTree.SelectedNode.Nodes)
                    {
                        if (StringUtil.IsInList(child.ImageIndex, EnabledIndices) == true)
                        {
                            bFound = true;
                        }
                    }

                    if (bFound == false)
                    {
                        resTree.SelectedNode.Collapse();
                    }
                }
            }



            if (this.Paths != "")
            {
                resTree.CheckBoxes = true;                      // 允许复选

                string[] aPath = this.Paths.Split(new char[] { ';' });

                for (int i = 0; i < aPath.Length; i++)
                {
                    if (aPath[i].Trim() == "")
                    {
                        continue;
                    }

                    ResPath respath = new ResPath(aPath[i].Trim());

                    // 展开到指定的节点
                    resTree.ExpandPath(respath);

                    bool bRet = this.resTree.CheckNode(respath,
                                                       true);
                }
            }
        }
예제 #2
0
        private void Form1_Load(object sender, System.EventArgs e)
        {
            if (ApplicationDeployment.IsNetworkDeployed == true)
            {
                // MessageBox.Show(this, "network");
                DataDir = Application.LocalUserAppDataPath;
            }
            else
            {
                // MessageBox.Show(this, "no network");
                DataDir = Environment.CurrentDirectory;
            }

            // 从文件中装载创建一个ServerCollection对象
            // parameters:
            //		bIgnorFileNotFound	是否不抛出FileNotFoundException异常。
            //							如果==true,函数直接返回一个新的空ServerCollection对象
            // Exception:
            //			FileNotFoundException	文件没找到
            //			SerializationException	版本迁移时容易出现

            try
            {
                Servers = ServerCollection.Load(this.DataDir
                                                + "\\manager_servers.bin",
                                                true);
                Servers.ownerForm = this;
            }
            catch (SerializationException ex)
            {
                MessageBox.Show(this, ex.Message);
                Servers = new ServerCollection();
                // 设置文件名,以便本次运行结束时覆盖旧文件
                Servers.FileName = this.DataDir
                                   + "\\manager_servers.bin";
            }

            this.Servers.ServerChanged += new ServerChangedEventHandle(Servers_ServerChanged);

            // 从文件中装载创建一个LinkInfoCollection对象
            // parameters:
            //		bIgnorFileNotFound	是否不抛出FileNotFoundException异常。
            //							如果==true,函数直接返回一个新的空ServerCollection对象
            // Exception:
            //			FileNotFoundException	文件没找到
            //			SerializationException	版本迁移时容易出现
            try
            {
                LinkInfos = LinkInfoCollection.Load(this.DataDir
                                                    + "\\manager_linkinfos.bin",
                                                    true);
            }
            catch (SerializationException ex)
            {
                MessageBox.Show(this, ex.Message);
                LinkInfos = new LinkInfoCollection();
                // 设置文件名,以便本次运行结束时覆盖旧文件
                LinkInfos.FileName = this.DataDir
                                     + "\\manager_linkinfos.bin";
            }



            // 设置窗口尺寸状态
            if (AppInfo != null)
            {
                SetFirstDefaultFont();

                MainForm.SetControlFont(this, this.DefaultFont);

                AppInfo.LoadFormStates(this,
                                       "mainformstate");
            }

            stopManager.Initial(toolBarButton_stop,
                                this.toolStripStatusLabel_main,
                                this.toolStripProgressBar_main);
            stop = new DigitalPlatform.Stop();
            stop.Register(this.stopManager, true);              // 和容器关联

            /*
             *          this.Channels.procAskAccountInfo =
             *                  new Delegate_AskAccountInfo(this.Servers.AskAccountInfo);
             */
            this.Channels.AskAccountInfo += new AskAccountInfoEventHandle(this.Servers.OnAskAccountInfo);



            // 简单检索界面准备工作
            treeView_res.AppInfo = this.AppInfo;                // 便于treeview中popup菜单修改配置文件时保存dialog尺寸位置

            treeView_res.stopManager = this.stopManager;

            treeView_res.Servers = this.Servers;                // 引用

            treeView_res.Channels = this.Channels;              // 引用

            treeView_res.Fill(null);

            //
            LinkInfos.Channels = this.Channels;

            int    nRet     = 0;
            string strError = "";

            nRet = this.LinkInfos.Link(out strError);
            if (nRet == -1)
            {
                MessageBox.Show(this, strError);
            }
        }