Пример #1
0
        private void 另存为ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (eDocState.eDoc_Modified != m_eDocState && eDocState.eDoc_NewOpen != m_eDocState)
            {
                MessageBox.Show("当前文档没有修改");
                return;
            }

            SaveFileDialog dlg = new SaveFileDialog();

            dlg.AddExtension = true;
            dlg.DefaultExt   = s_file_ext;
            DialogResult ret = dlg.ShowDialog();

            if (DialogResult.OK == ret)
            {
                if (saveFile(dlg.FileName))
                {
                    if (m_strCurDocPath == null)
                    {
                        m_strCurDocPath = dlg.FileName;
                        this.Text       = m_strCurDocPath;
                    }
                    m_eDocState = eDocState.eDoc_AlreadySaved;
                    MessageBox.Show("保存成功");
                }
            }
        }
Пример #2
0
        private void Form11_DragDrop(object sender, DragEventArgs e)
        {
            string[] files        = (string[])e.Data.GetData(DataFormats.FileDrop);
            string   strValidFile = null;

            foreach (string file in files)
            {
                if (string.Compare(Path.GetExtension(file), s_file_ext, true) == 0)
                {
                    strValidFile = file;
                    break;
                }
            }

            if (strValidFile == null)
            {
                MessageBox.Show("无法识别的文件格式");
                return;
            }

            // check if save current document ;
            if (m_eDocState == eDocState.eDoc_Modified)
            {
                DialogResult dlgret = MessageBox.Show("是否保存当前文档", "notices", MessageBoxButtons.YesNoCancel);
                if (dlgret == DialogResult.Cancel)
                {
                    return;
                }
                else if (dlgret == DialogResult.Yes)
                {
                    this.保存ToolStripMenuItem_Click(sender, e);
                }
                else
                {
                    m_eDocState = eDocState.eDoc_None;
                }
            }

            if (eDocState.eDoc_Modified == m_eDocState)
            {
                MessageBox.Show("cur document do not process can not open new");
                return;
            }

            // load files
            m_strCurDocPath = strValidFile;
            doLoadFile(m_strCurDocPath);
            m_eDocState = eDocState.eDoc_NewOpen;

            int nPos = m_strCurDocPath.LastIndexOf(s_unfinish_flag);

            if (nPos >= 0)
            {
                m_strCurDocPath = m_strCurDocPath.Remove(nPos, s_unfinish_flag.Length);
            }
            this.Text = m_strCurDocPath;
        }
Пример #3
0
        private void addNodeBtnClick(object sender, EventArgs e)
        {
            TreeNode addNode = m_vAddSettingPanel[(int)m_nCurNodeType].doAddChildNode();

            if (addNode == null)
            {
                return;
            }
            this.treeView1.SelectedNode.Nodes.Add(addNode);
            this.treeView1.SelectedNode.Expand();
            this.treeView1.SelectedNode = addNode;
            m_eDocState = eDocState.eDoc_Modified;
        }
Пример #4
0
        private void 打开文件ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            // check if save current document ;
            if (m_eDocState == eDocState.eDoc_Modified)
            {
                DialogResult dlgret = MessageBox.Show("是否保存当前文档", "notices", MessageBoxButtons.YesNoCancel);
                if (dlgret == DialogResult.Cancel)
                {
                    return;
                }
                else if (dlgret == DialogResult.Yes)
                {
                    this.保存ToolStripMenuItem_Click(sender, e);
                }
                else
                {
                    m_eDocState = eDocState.eDoc_None;
                }
            }

            if (eDocState.eDoc_Modified == m_eDocState)
            {
                MessageBox.Show("cur document do not process can not open new");
                return;
            }

            OpenFileDialog dt = new OpenFileDialog();

            dt.AddExtension = true;
            dt.DefaultExt   = s_file_ext;
            if (dt.ShowDialog() == DialogResult.OK)
            {
                m_strCurDocPath = dt.FileName;
                doLoadFile(m_strCurDocPath);
                m_eDocState = eDocState.eDoc_NewOpen;

                int nPos = m_strCurDocPath.LastIndexOf(s_unfinish_flag);
                if (nPos >= 0)
                {
                    m_strCurDocPath = m_strCurDocPath.Remove(nPos, s_unfinish_flag.Length);
                }
                this.Text = m_strCurDocPath;
            }
        }
Пример #5
0
        private void 保存ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (eDocState.eDoc_Modified != m_eDocState)
            {
                MessageBox.Show("当前文档没有修改");
                return;
            }

            if (m_strCurDocPath == null)
            {
                this.另存为ToolStripMenuItem_Click(sender, e);
                return;
            }

            if (saveFile(m_strCurDocPath))
            {
                m_eDocState = eDocState.eDoc_AlreadySaved;
                MessageBox.Show("保存成功");
            }
        }
Пример #6
0
        private void removeNodeBtnClick(object sender, EventArgs e)
        {
            TreeNode pnode  = this.treeView1.SelectedNode;
            TreeNode parent = pnode.Parent;

            if (parent == null)
            {
                return;
            }

            NodeData parentData = (NodeData)parent.Tag;
            NodeData chidData   = (NodeData)pnode.Tag;

            m_vAddSettingPanel[(int)chidData.nodeType].hide();
            parentData.removeChildNode(chidData);
            pnode.Remove();
            this.treeView1.SelectedNode = parent;

            m_eDocState = eDocState.eDoc_Modified;
        }
Пример #7
0
        private void 新建文档ToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            // check if save current document ;
            if (m_eDocState == eDocState.eDoc_Modified)
            {
                DialogResult dlgret = MessageBox.Show("是否保存当前文档", "notices", MessageBoxButtons.YesNoCancel);
                if (dlgret == DialogResult.Cancel)
                {
                    return;
                }
                else if (dlgret == DialogResult.Yes)
                {
                    this.保存ToolStripMenuItem_Click(sender, e);
                }
                else
                {
                    m_eDocState = eDocState.eDoc_None;
                }
            }

            if (eDocState.eDoc_Modified == m_eDocState)
            {
                MessageBox.Show("cur document do not process can not create new");
                return;
            }

            hideAllNodeSettingPanel();
            this.treeView1.Nodes.Clear();
            for (int nIdx = 0; nIdx < 4; ++nIdx)
            {
                TreeNode  pRound = new TreeNode();
                NodeRound tRound = new NodeRound(nIdx);
                pRound.Tag  = tRound;
                pRound.Text = tRound.desc;
                this.treeView1.Nodes.Add(pRound);
            }
            m_eDocState     = eDocState.eDoc_NewCreated;
            m_strCurDocPath = null;
            this.Text       = "untitled";
        }
Пример #8
0
        private void 新建文档ToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            // check if save current document ;
            if ( m_eDocState == eDocState.eDoc_Modified)
            {
                DialogResult dlgret = MessageBox.Show("是否保存当前文档", "notices", MessageBoxButtons.YesNoCancel);
                if (dlgret == DialogResult.Cancel)
                {
                    return;
                }
                else if (dlgret == DialogResult.Yes)
                {
                    this.保存ToolStripMenuItem_Click(sender, e);
                }
                else
                {
                    m_eDocState = eDocState.eDoc_None;
                }
            }

            if (eDocState.eDoc_Modified == m_eDocState)
            {
                MessageBox.Show("cur document do not process can not create new");
                return;
            }

            hideAllNodeSettingPanel();
            this.treeView1.Nodes.Clear();
            for ( int nIdx = 0; nIdx < 4; ++nIdx )
            {
                TreeNode pRound = new TreeNode() ;
                NodeRound tRound = new NodeRound(nIdx);
                pRound.Tag = tRound;
                pRound.Text = tRound.desc;
                this.treeView1.Nodes.Add(pRound);
            }
            m_eDocState = eDocState.eDoc_NewCreated;
            m_strCurDocPath = null;
            this.Text = "untitled";
        }
Пример #9
0
        private void 打开文件ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            // check if save current document ;
            if (m_eDocState == eDocState.eDoc_Modified)
            {
                DialogResult dlgret = MessageBox.Show("是否保存当前文档", "notices", MessageBoxButtons.YesNoCancel);
                if (dlgret == DialogResult.Cancel)
                {
                    return;
                }
                else if (dlgret == DialogResult.Yes)
                {
                    this.保存ToolStripMenuItem_Click(sender, e);
                }
                else
                {
                    m_eDocState = eDocState.eDoc_None;
                }
            }

            if (eDocState.eDoc_Modified == m_eDocState)
            {
                MessageBox.Show("cur document do not process can not open new");
                return;
            }

            OpenFileDialog dt = new OpenFileDialog();
            dt.AddExtension = true;
            dt.DefaultExt = s_file_ext ;
            if (dt.ShowDialog() == DialogResult.OK)
            {
                m_strCurDocPath = dt.FileName;
                doLoadFile(m_strCurDocPath);
                m_eDocState = eDocState.eDoc_NewOpen;

                int nPos = m_strCurDocPath.LastIndexOf(s_unfinish_flag);
                if (nPos >= 0)
                {
                    m_strCurDocPath = m_strCurDocPath.Remove(nPos, s_unfinish_flag.Length);
                }
                this.Text = m_strCurDocPath;
            }
        }
Пример #10
0
        private void 另存为ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (eDocState.eDoc_Modified != m_eDocState && eDocState.eDoc_NewOpen != m_eDocState )
            {
                MessageBox.Show("当前文档没有修改");
                return;
            }

            SaveFileDialog dlg = new SaveFileDialog();
            dlg.AddExtension = true;
            dlg.DefaultExt = s_file_ext ;
            DialogResult ret = dlg.ShowDialog();
            if (DialogResult.OK == ret)
            {
                if ( saveFile(dlg.FileName) )
                {
                    if (m_strCurDocPath == null)
                    {
                        m_strCurDocPath = dlg.FileName;
                        this.Text = m_strCurDocPath;
                    }
                    m_eDocState = eDocState.eDoc_AlreadySaved;
                    MessageBox.Show("保存成功");
                }
            }
        }
Пример #11
0
        private void 保存ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if ( eDocState.eDoc_Modified != m_eDocState)
            {
                MessageBox.Show("当前文档没有修改");
                return;
            }

            if (m_strCurDocPath == null)
            {
                this.另存为ToolStripMenuItem_Click(sender, e);
                return;
            }

            if (saveFile(m_strCurDocPath))
            {
                m_eDocState = eDocState.eDoc_AlreadySaved;
                MessageBox.Show("保存成功");
            }
        }
Пример #12
0
        private void removeNodeBtnClick(object sender, EventArgs e)
        {
            TreeNode pnode = this.treeView1.SelectedNode;
            TreeNode parent = pnode.Parent;
            if (parent == null)
            {
                return;
            }

            NodeData parentData = (NodeData)parent.Tag;
            NodeData chidData = (NodeData)pnode.Tag;
            m_vAddSettingPanel[(int)chidData.nodeType].hide();
            parentData.removeChildNode(chidData);
            pnode.Remove();
            this.treeView1.SelectedNode = parent;

            m_eDocState = eDocState.eDoc_Modified;
        }
Пример #13
0
        private void Form11_DragDrop(object sender, DragEventArgs e)
        {
            string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
            string strValidFile = null ;
            foreach (string file in files)
            {
                if ( string.Compare(Path.GetExtension(file),s_file_ext,true) == 0)
                {
                    strValidFile = file;
                    break;
                }
            }

            if (strValidFile == null)
            {
                MessageBox.Show("无法识别的文件格式");
                return;
            }

            // check if save current document ;
            if (m_eDocState == eDocState.eDoc_Modified)
            {
                DialogResult dlgret = MessageBox.Show("是否保存当前文档", "notices", MessageBoxButtons.YesNoCancel);
                if (dlgret == DialogResult.Cancel)
                {
                    return;
                }
                else if (dlgret == DialogResult.Yes)
                {
                    this.保存ToolStripMenuItem_Click(sender, e);
                }
                else
                {
                    m_eDocState = eDocState.eDoc_None;
                }
            }

            if (eDocState.eDoc_Modified == m_eDocState)
            {
                MessageBox.Show("cur document do not process can not open new");
                return;
            }

            // load files
            m_strCurDocPath = strValidFile;
            doLoadFile(m_strCurDocPath);
            m_eDocState = eDocState.eDoc_NewOpen;

            int nPos = m_strCurDocPath.LastIndexOf(s_unfinish_flag);
            if (nPos >= 0)
            {
                m_strCurDocPath = m_strCurDocPath.Remove(nPos, s_unfinish_flag.Length);
            }
            this.Text = m_strCurDocPath;
        }
Пример #14
0
 private void addNodeBtnClick(object sender, EventArgs e)
 {
     TreeNode addNode = m_vAddSettingPanel[(int)m_nCurNodeType].doAddChildNode();
     if (addNode == null)
     {
         return;
     }
     this.treeView1.SelectedNode.Nodes.Add(addNode);
     this.treeView1.SelectedNode.Expand();
     this.treeView1.SelectedNode = addNode;
     m_eDocState = eDocState.eDoc_Modified;
 }