Exemple #1
0
        private void Form1_Closed(object sender, System.EventArgs e)
        {
            this.Channels.AskAccountInfo -= new AskAccountInfoEventHandle(this.Servers.OnAskAccountInfo);

            // 如果缺了此句,则Servers.Save会出现问题
            this.Servers.ServerChanged -= new ServerChangedEventHandle(Servers_ServerChanged);

            // 保存到文件
            // parameters:
            //		strFileName	文件名。如果==null,表示使用装载时保存的那个文件名
            Servers.Save(null);
            Servers = null;

            LinkInfos.Save(null);
            LinkInfos = null;

            // 保存窗口尺寸状态
            if (AppInfo != null)
            {
                AppInfo.SaveFormStates(this,
                                       "mainformstate");
            }

            //记住save,保存信息XML文件
            AppInfo.Save();
            AppInfo = null;             // 避免后面再用这个对象
        }
Exemple #2
0
        // 从文件中装载创建一个ServerCollection对象
        // parameters:
        //		bIgnorFileNotFound	是否不抛出FileNotFoundException异常。
        //							如果==true,函数直接返回一个新的空ServerCollection对象
        // Exception:
        //			FileNotFoundException	文件没找到
        //			SerializationException	版本迁移时容易出现
        public static LinkInfoCollection Load(
            string strFileName,
            bool bIgnorFileNotFound)
        {
            LinkInfoCollection infos = null;

            try
            {
                using (Stream stream = File.Open(strFileName, FileMode.Open))
                {
                    BinaryFormatter formatter = new BinaryFormatter();

                    infos = (LinkInfoCollection)formatter.Deserialize(stream);
                    infos.m_strFileName = strFileName;

                    for (int i = 0; i < infos.Count; i++)
                    {
                        LinkInfo info = (LinkInfo)infos[i];
                        info.Container = infos;
                    }

                    return(infos);
                }
            }
            catch (FileNotFoundException ex)
            {
                if (bIgnorFileNotFound == false)
                {
                    throw ex;
                }

                infos = new LinkInfoCollection();
                infos.m_strFileName = strFileName;

                // 让调主有一个新的空对象可用
                return(infos);
            }
        }
Exemple #3
0
		// 从文件中装载创建一个ServerCollection对象
		// parameters:
		//		bIgnorFileNotFound	是否不抛出FileNotFoundException异常。
		//							如果==true,函数直接返回一个新的空ServerCollection对象
		// Exception:
		//			FileNotFoundException	文件没找到
		//			SerializationException	版本迁移时容易出现
		public static LinkInfoCollection Load(
			string strFileName,
			bool bIgnorFileNotFound)
		{
			Stream stream = null;
			LinkInfoCollection infos = null;

			try 
			{
				stream = File.Open(strFileName, FileMode.Open);
			}
			catch (FileNotFoundException ex)
			{
				if (bIgnorFileNotFound == false)
					throw ex;

				infos = new LinkInfoCollection();
				infos.m_strFileName = strFileName;

				// 让调主有一个新的空对象可用
				return infos;
			}


			BinaryFormatter formatter = new BinaryFormatter();

			infos = (LinkInfoCollection)formatter.Deserialize(stream);
			stream.Close();
			infos.m_strFileName = strFileName;

			for(int i=0;i<infos.Count;i++)
			{
				LinkInfo info = (LinkInfo)infos[i];
				info.Container = infos;
			}

			return infos;
		}
Exemple #4
0
		private void Form1_Closed(object sender, System.EventArgs e)
		{
            this.Channels.AskAccountInfo -= new AskAccountInfoEventHandle(this.Servers.OnAskAccountInfo);

            // 如果缺了此句,则Servers.Save会出现问题
            this.Servers.ServerChanged -= new ServerChangedEventHandle(Servers_ServerChanged);

			// 保存到文件
			// parameters:
			//		strFileName	文件名。如果==null,表示使用装载时保存的那个文件名
			Servers.Save(null);
			Servers = null;

			LinkInfos.Save(null);
			LinkInfos = null;

			// 保存窗口尺寸状态
			if (AppInfo != null) 
			{

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

			//记住save,保存信息XML文件
			AppInfo.Save();
			AppInfo = null;	// 避免后面再用这个对象	
		}
Exemple #5
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);
		
		}
Exemple #6
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);
            }
        }