Exemplo n.º 1
0
        private void GetDp2ResDlg_Load(object sender, EventArgs e)
        {
            this.dp2ResTree1.Servers = this.Servers;    // 引用
#if OLD_CHANNEL
            this.dp2ResTree1.Channels = this.dp2Channels;
#endif
            this.dp2ResTree1.ChannelManager = this.ChannelManager;

            this.dp2ResTree1.EnabledIndices = this.EnabledIndices;  // new int[] { dp2ResTree.RESTYPE_DB };
            this.dp2ResTree1.Fill(null);

            this.m_bLoaded = true;

            if (String.IsNullOrEmpty(this.textBox_path.Text) == false)
            {
                this.dp2ResTree1.ExpandPath(this.textBox_path.Text);
            }

            if (this.EnableNotAsk == true)
            {
                this.checkBox_notAsk.Enabled = true;
            }

            if (this.AutoClose == true)
            {
                API.PostMessage(this.Handle, WM_AUTO_CLOSE, 0, 0);
            }
        }
Exemplo n.º 2
0
        // 将另一对象的数组内容灌入本对象
        public void Import(dp2ServerCollectionNew servers)
        {
            this.Clear();
            this._servers.AddRange(servers.Servers);
            this.m_bChanged = true;

            // 新增加的动作
            dp2ServerChangedEventArgs e = new dp2ServerChangedEventArgs();

            e.Url = "";
            e.ServerChangeAction = dp2ServerChangeAction.Import;
            OnServerChanged(this, e);
        }
Exemplo n.º 3
0
        // 克隆。
        // 新数组中的对象完全是新创建的。
        public dp2ServerCollectionNew Dup()
        {
            dp2ServerCollectionNew newServers = new dp2ServerCollectionNew();

            foreach (var server in _servers)
            {
                dp2Server newServer = new dp2Server(server);
                newServers.Add(newServer);
            }

            newServers.FileName = this.FileName;
            newServers.Changed  = this.Changed;
            // newServers.ownerForm = this.ownerForm;

            return(newServers);
        }
Exemplo n.º 4
0
        // 从文件中装载创建一个ServerCollection对象
        // parameters:
        //		bIgnorFileNotFound	是否不抛出FileNotFoundException异常。
        //							如果==true,函数直接返回一个新的空ServerCollection对象
        // Exception:
        //			FileNotFoundException	文件没找到
        //			SerializationException	版本迁移时容易出现
        public static dp2ServerCollectionNew Load(
            string strFileName,
            bool bIgnoreFileNotFound)
        {
            try
            {
                lock (_syncRoot_file)
                {
                    string value   = File.ReadAllText(strFileName);
                    var    servers = JsonConvert.DeserializeObject <dp2ServerCollectionNew>(value);
                    if (servers == null)
                    {
                        servers = new dp2ServerCollectionNew();
                    }
                    if (servers._servers == null)
                    {
                        servers._servers = new List <dp2Server>();
                    }

                    servers.m_strFileName = strFileName;
                    return(servers);
                }
            }
            catch (FileNotFoundException ex)
            {
                if (bIgnoreFileNotFound == false)
                {
                    throw ex;
                }

                var servers = new dp2ServerCollectionNew();
                servers.m_strFileName = strFileName;

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