Ejemplo n.º 1
0
        // 编辑配置文件
        void menuItem_editCfgFile_Click(object sender, EventArgs e)
        {
            string strError   = "";
            string strContent = "";

            if (this.SelectedNode == null)
            {
                strError = "尚未选择要编辑的配置文件节点";
                goto ERROR1;
            }

            if (this.SelectedNode.ImageIndex != OFFS_CFGFILE)
            {
                strError = "所选择的节点不是配置文件类型";
                goto ERROR1;
            }

            string strPath = GetPath(this.SelectedNode, '/');

            if (Channel == null)
            {
                Channel = channelarray.CreateChannel(0);
            }

            Debug.Assert(Channel != null, "channel尚未初始化");

            Cursor.Current = Cursors.WaitCursor;
            int nRet = Channel.GetCfgFile(strPath,
                                          out strContent,
                                          out strError);

            Cursor.Current = Cursors.Default;

            if (nRet == -1)
            {
                goto ERROR1;
            }

            EditCfgForm dlg = new EditCfgForm();

            dlg.StartPosition = FormStartPosition.CenterScreen;
            dlg.CfgPath       = strPath;
            dlg.Content       = strContent;
            dlg.ShowDialog(this);

            if (dlg.DialogResult != DialogResult.OK)
            {
                return;
            }

            if (dlg.Changed == false)
            {
                return;
            }

            // 保存到(服务器端)配置文件
            // return:
            //      -1  出错
            //      0   成功
            Cursor.Current = Cursors.WaitCursor;
            nRet           = Channel.WriteCfgFile(dlg.CfgPath,
                                                  dlg.Content,
                                                  out strError);
            Cursor.Current = Cursors.Default;
            if (nRet == -1)
            {
                goto ERROR1;
            }

            MessageBox.Show(this, "配置文件 '" + dlg.CfgPath + "' 保存成功");
            return;

ERROR1:
            MessageBox.Show(this, strError);
        }
Ejemplo n.º 2
0
        // 编辑配置文件
        void menuItem_editCfgFile_Click(object sender, EventArgs e)
        {
            string strError = "";
            string strContent = "";

            if (this.SelectedNode == null)
            {
                strError = "尚未选择要编辑的配置文件节点";
                goto ERROR1;
            }

            if (this.SelectedNode.ImageIndex != OFFS_CFGFILE)
            {
                strError = "所选择的节点不是配置文件类型";
                goto ERROR1;
            }

            string strPath = GetPath(this.SelectedNode, '/');

            if (Channel == null)
            {
                Channel = channelarray.CreateChannel(0);
            }

            Debug.Assert(Channel != null, "channel尚未初始化");

            Cursor.Current = Cursors.WaitCursor;
            int nRet = Channel.GetCfgFile(strPath,
                out strContent,
                out strError);
            Cursor.Current = Cursors.Default;

            if (nRet == -1)
                goto ERROR1;

            EditCfgForm dlg = new EditCfgForm();
            dlg.StartPosition = FormStartPosition.CenterScreen;
            dlg.CfgPath = strPath;
            dlg.Content = strContent;
            dlg.ShowDialog(this);

            if (dlg.DialogResult != DialogResult.OK)
                return;

            if (dlg.Changed == false)
                return;

            // 保存到(服务器端)配置文件
            // return:
            //      -1  出错
            //      0   成功
            Cursor.Current = Cursors.WaitCursor;
            nRet = Channel.WriteCfgFile(dlg.CfgPath,
                dlg.Content,
                out strError);
            Cursor.Current = Cursors.Default;
            if (nRet == -1)
                goto ERROR1;

            MessageBox.Show(this, "配置文件 '" + dlg.CfgPath +"' 保存成功");
            return;
        ERROR1:
            MessageBox.Show(this, strError);

        }