Beispiel #1
0
        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            ServerCollection serverCollection = App.ServerCollection;

            serverCollection.Load();

            MainListBox.ItemsSource = serverCollection;
            serverCollection.GetStatus();

            if (serverCollection.Count == 0)
            {
                AddText.Visibility = System.Windows.Visibility.Visible;
            }
            else
            {
                AddText.Visibility = System.Windows.Visibility.Collapsed;
            }
        }
Beispiel #2
0
        private void MainFormNew_Load(object sender, EventArgs e)
        {
            Searching(false);   // 隐藏searching ToolStripLabel

            if (ApplicationDeployment.IsNetworkDeployed == true)
            {
                // MessageBox.Show(this, "network");
                DataDir = Application.LocalUserAppDataPath;
            }
            else
            {
                // MessageBox.Show(this, "no network");
                DataDir = Environment.CurrentDirectory;
            }


            this.SetMenuItemState();                 //任延华加 2006/1/5
            this.toolBarButton_stop.Enabled = false; //任延华加 2006/1/5


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

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

            string strError = "";
            int    nRet     = cfgCache.Load(this.DataDir
                                            + "\\cfgcache.xml",
                                            out strError);

            if (nRet == -1)
            {
                if (IsFirstRun == false)
                {
                    MessageBox.Show(strError + "\r\n\r\n程序稍后会尝试自动创建这个文件");
                }
            }


            cfgCache.TempDir = this.DataDir
                               + "\\cfgcache";
            cfgCache.InstantSave = true;


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

                MainForm.SetControlFont(this, this.DefaultFont);

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


            stopManager.Initial(toolBarButton_stop,
                                (object)this.toolStripStatusLabel_main,
                                (object)this.toolStripProgressBar_main);

            // 存在上次遗留的窗口
            int nLastSearchWindow = this.AppInfo.GetInt(
                "main_form",
                "last_search_window",
                1);

            if (nLastSearchWindow == 1)
            {
                MenuItem_openSearch_Click(null, null);  // 打开一个检索窗
            }

            if (IsFirstRun == true && this.Servers.Count == 0)
            {
                MessageBox.Show(this, "欢迎您安装使用dp2rms -- 资源管理。");
                ManageServers(true);
                ManagePreference();
            }
        }
Beispiel #3
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);
            }
        }