Beispiel #1
0
        /// <summary>
        /// 保存文件
        /// </summary>
        private void OnFileSave(object sender, EventArgs e)
        {
            DocumentForm activeDocForm = this.ActiveMdiChild as DocumentForm;

            if (activeDocForm == null)
            {
                return;
            }

            LitCAD.DatabaseServices.Database db = activeDocForm.document.database;
            if (db.fileName == null)
            {
                SaveFileDialog savedialog = new SaveFileDialog();
                savedialog.Title            = "保存";
                savedialog.Filter           = "LitCAD文件(*.litcad)|*.litcad";
                savedialog.FilterIndex      = 0;
                savedialog.RestoreDirectory = true;
                savedialog.CheckPathExists  = true;
                savedialog.FileName         = activeDocForm.Text;
                if (savedialog.ShowDialog() == DialogResult.OK)
                {
                    string fileFullPath = savedialog.FileName;
                    activeDocForm.SaveAs(fileFullPath, true);
                }
            }
            else
            {
                activeDocForm.Save();
            }
        }
Beispiel #2
0
        private void OpenFile(string fileFullPath)
        {
            // 检查是否已经打开
            string fileFullPathLower = fileFullPath.ToLower();

            foreach (Form form in this.MdiChildren)
            {
                DocumentForm childDocForm = form as DocumentForm;
                if (childDocForm == null)
                {
                    continue;
                }

                string strDocPath = childDocForm.fileFullPath.ToLower();
                if (fileFullPathLower == strDocPath)
                {
                    childDocForm.Activate();
                    return;
                }
            }

            // 打开文件
            DocumentForm docForm = new DocumentForm();

            if (fileFullPath != null &&
                System.IO.File.Exists(fileFullPath))
            {
                docForm.Open(fileFullPath);
            }
            docForm.MdiParent   = this;
            docForm.WindowState = FormWindowState.Maximized;
            docForm.Show();
        }
Beispiel #3
0
        void OpenDocument(string filename)
        {
            DocumentForm f = new DocumentForm();

            f.MdiParent   = this;
            f.WindowState = FormWindowState.Maximized;
            f.Show();
        }
Beispiel #4
0
        /// <summary>
        /// 新建文件
        /// </summary>
        private void OnFileNew(object sender, EventArgs e)
        {
            DocumentForm docForm = new DocumentForm();

            docForm.MdiParent   = this;
            docForm.WindowState = FormWindowState.Maximized;
            docForm.Show();
        }
Beispiel #5
0
        private void OnIdle(object sender, EventArgs e)
        {
            DocumentForm currActiveDocForm = this.ActiveMdiChild as DocumentForm;

            if (currActiveDocForm != null)
            {
                currActiveDocForm.UpdateUI();
            }
        }
Beispiel #6
0
        private void NewFile()
        {
            DocumentForm docForm = new DocumentForm();

            docForm.Text        = GetNextNewFileName();
            docForm.MdiParent   = this;
            docForm.WindowState = FormWindowState.Maximized;
            docForm.Show();
        }
Beispiel #7
0
        /// <summary>
        /// 构造函数
        /// </summary>
        private LayersManagementForm()
        {
            InitializeComponent();
            InitializeLayerListView();
            this.Owner = MainWin.Instance;
            DocumentForm activeDocForm = MainWin.Instance.ActiveMdiChild as DocumentForm;

            if (activeDocForm != null)
            {
                _docForm = activeDocForm;
            }
            else
            {
                _docForm = null;
            }
            MainWin.Instance.MdiChildActivate += this.OnDocumentFormActivated;
        }
Beispiel #8
0
        /// <summary>
        /// 文档窗口激活相应函数
        /// </summary>
        private void OnDocumentFormActivated(object sender, EventArgs e)
        {
            DocumentForm docForm = MainWin.Instance.ActiveMdiChild as DocumentForm;

            if (docForm != null)
            {
                _docForm = docForm;;
                if (this.Visible)
                {
                    this.ReUpdateListView();
                }
            }
            else
            {
                _docForm = null;
                this.Hide();
            }
        }
Beispiel #9
0
        private string GetNextNewFileName()
        {
            string strBase = "new";
            uint   id      = 1;

            foreach (Form form in this.MdiChildren)
            {
                DocumentForm docForm = form as DocumentForm;
                if (docForm == null)
                {
                    continue;
                }

                string fileName = "";
                LitCAD.DatabaseServices.Database db = docForm.document.database;
                if (db.fileName != null)
                {
                    fileName = System.IO.Path.GetFileNameWithoutExtension(db.fileName);
                }
                else
                {
                    fileName = docForm.Text;
                }
                fileName = fileName.ToLower();

                if (fileName.IndexOf(strBase) == 0)
                {
                    fileName = fileName.Substring(strBase.Length);
                    uint number = 0;
                    if (uint.TryParse(fileName, out number))
                    {
                        if (number >= id)
                        {
                            id = number + 1;
                        }
                    }
                }
            }

            return(string.Format("{0}{1}", strBase, id));
        }
Beispiel #10
0
        protected override void OnMdiChildActivate(EventArgs e)
        {
            base.OnMdiChildActivate(e);

            DocumentForm activeDocForm = this.ActiveMdiChild as DocumentForm;

            foreach (Control ctrl in Controls)
            {
                if (ctrl is ToolStripPanel)
                {
                    ((ToolStripPanel)ctrl).SuspendLayout();
                }
            }
            if (activeDocForm != null)
            {
                ToolStripManager.RevertMerge(_toolStripMgr.GetToolStrip("Edit"));
                ToolStripManager.Merge(activeDocForm.toolstripMgr.GetToolStrip("Edit"), _toolStripMgr.GetToolStrip("Edit"));

                ToolStripManager.RevertMerge(_toolStripMgr.GetToolStrip("Draw"));
                ToolStripManager.Merge(activeDocForm.toolstripMgr.GetToolStrip("Draw"), _toolStripMgr.GetToolStrip("Draw"));

                ToolStripManager.RevertMerge(_toolStripMgr.GetToolStrip("Modify"));
                ToolStripManager.Merge(activeDocForm.toolstripMgr.GetToolStrip("Modify"), _toolStripMgr.GetToolStrip("Modify"));

                ToolStripManager.RevertMerge(_toolStripMgr.GetToolStrip("Layer"));
                ToolStripManager.Merge(activeDocForm.toolstripMgr.GetToolStrip("Layer"), _toolStripMgr.GetToolStrip("Layer"));

                ToolStripManager.RevertMerge(_toolStripMgr.GetToolStrip("Property"));
                ToolStripManager.Merge(activeDocForm.toolstripMgr.GetToolStrip("Property"), _toolStripMgr.GetToolStrip("Property"));
            }
            foreach (Control ctrl in Controls)
            {
                if (ctrl is ToolStripPanel)
                {
                    ((ToolStripPanel)ctrl).ResumeLayout();
                }
            }
        }
Beispiel #11
0
        /// <summary>
        /// 文件另存为
        /// </summary>
        private void OnFileSaveAs(object sender, EventArgs e)
        {
            DocumentForm activeDocForm = this.ActiveMdiChild as DocumentForm;

            if (activeDocForm == null)
            {
                return;
            }

            SaveFileDialog savedialog = new SaveFileDialog();

            savedialog.Title            = "另存为";
            savedialog.Filter           = "LitCAD文件(*.litcad)|*.litcad";
            savedialog.FilterIndex      = 0;
            savedialog.RestoreDirectory = true;
            savedialog.CheckPathExists  = true;
            savedialog.FileName         = "";
            if (savedialog.ShowDialog() == DialogResult.OK)
            {
                string fileFullPath = savedialog.FileName;
                activeDocForm.SaveAs(fileFullPath);
            }
        }