示例#1
0
        void MainFrm_FormClosing(object sender, FormClosingEventArgs e)
        {
            string fileName = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath),
                                           "DockPanel.config");

            //保留在2秒内关掉的文档(视为关闭工程时)在config文件中
            foreach (var docView in this.m_workspace.Documents)
            {
                var fileView = docView as FileTabPanel;

                if (fileView == null)
                {
                    continue;
                }

                if (!fileView.CloseTime.HasValue || fileView.CloseTime > DateTime.Now.AddSeconds(2))
                {
                    fileView.Close();
                    continue;
                }
            }


            this.m_workspace.SaveAsXml(fileName);

            var cmdHost_common = CommandHostManager.Instance().Get(CommandHostManager.HostType.Common);
            var cmd            = cmdHost_common.GetCommand(Dict.Commands.ExitProcess);

            cmd.Execute();
        }
示例#2
0
        internal override void OnRenameSelf(string oldPath, string newPath)
        {
            this.FullName = this.FullName.Replace(oldPath, newPath);

            if (this.FileId.HasValue)
            {
                var model = GlobalService.ModelManager.GetModel(this.FileId.Value);

                model.File = this.FullName;
            }

            var cmdHost_common = CommandHostManager.Instance().Get(CommandHostManager.HostType.Common);

            if (cmdHost_common != null)
            {
                var cmd = cmdHost_common.GetCommand(Dict.Commands.RenameModel)
                          as RenameModelCommand;

                cmd.OldName = System.IO.Path.Combine(oldPath, this.Name + this.Extension);
                cmd.NewName = System.IO.Path.Combine(newPath, this.Name + this.Extension);

                if (cmd.OldName != cmd.NewName)
                {
                    cmdHost_common.RunCommand(Dict.Commands.RenameModel);
                }
            }

            base.OnRenameSelf(oldPath, newPath);

            if (oldPath != newPath)
            {
                File.Move(oldPath, newPath);
            }
        }
示例#3
0
        void Init()
        {
            var cmdHost_common = CommandHostManager.Instance().Get(CommandHostManager.HostType.Common);

            cmdHost_common.AddCommand(new RenameModelCommand(this.Receiver));

            cmdHost_common.AddCommand(new CloseProjectCommand(this.Receiver));
            cmdHost_common.AddCommand(new ExitProcessCommand(this.Receiver));

            cmdHost_common.AddCommand(new NewProjectCommand(this.Receiver));
            cmdHost_common.AddCommand(new OpenProjectCommand(this.Receiver));
            cmdHost_common.AddCommand(new CloseFileCommand(this.Receiver));

            var cmdHost_dm = CommandHostManager.Instance().Get(CommandHostManager.HostType.DataModel);

            cmdHost_dm.AddCommand(new OpenDataModelCommand(this.Receiver));
            cmdHost_dm.AddCommand(new NewDataModelCommand(this.Receiver));

            var cmdHost_xm = CommandHostManager.Instance().Get(CommandHostManager.HostType.XmlMode);

            cmdHost_xm.AddCommand(new OpenXmlModelCommand(this.Receiver));
            cmdHost_xm.AddCommand(new NewXmlModelCommand(this.Receiver));

            var cmdHost_dv = CommandHostManager.Instance().Get(CommandHostManager.HostType.DataView);

            cmdHost_dv.AddCommand(new OpenDataViewCommand(this.Receiver));
            cmdHost_dv.AddCommand(new NewDataViewCommand(this.Receiver));

            var cmdHost_wf = CommandHostManager.Instance().Get(CommandHostManager.HostType.WorkFlow);

            cmdHost_wf.AddCommand(new OpenWorkFlowCommand(this.Receiver));
            cmdHost_wf.AddCommand(new NewWorkFlowCommand(this.Receiver));

            CommandHostManager.Instance().AddCommand(CommandHostManager.HostType.ViewModel,
                                                     new NewViewModelCommand(this.receiver));

            CommandHostManager.Instance().AddCommand(CommandHostManager.HostType.ViewModel,
                                                     new OpenViewModelCommand(this.receiver));

            CommandHostManager.Instance().AddCommand(CommandHostManager.HostType.Common,
                                                     new PropertySelectCommand(this.receiver));

            var prj = System.Configuration.ConfigurationManager.AppSettings["CurrentProject"];

            if (prj != null)
            {
                if (Directory.Exists(prj))
                {
                    GlobalService.CurrentPrj_Name = Path.GetFileName(prj);
                    GlobalService.CurrentPrj_Dir  = prj;
                    this.Receiver.OpenProject(prj);

                    //OpenPrject();
                }
            }
        }
示例#4
0
        public override void OnDoubleClick()
        {
            var cmd = CommandHostManager.Instance().Get <OpenWorkFlowCommand>(
                CommandHostManager.HostType.WorkFlow, Dict.Commands.OpenWorkFlow);

            cmd.File = this.FullName;

            cmd.Execute();

            base.OnDoubleClick();
        }
示例#5
0
        public override void OnDoubleClick()
        {
            var cmdHost = CommandHostManager.Instance().Get(
                CommandHostManager.HostType.DataView);
            var cmd = cmdHost.GetCommand(Dict.Commands.OpenDataView)
                      as OpenDataViewCommand;

            cmd.File = this.FullName;

            cmdHost.RunCommand(Dict.Commands.OpenDataView);

            base.OnDoubleClick();
        }
示例#6
0
        protected void OnNewDataModel(object sender, EventArgs args)
        {
            var dlg = new NewFrm();

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

            var newName = dlg.GetName();

            if (string.IsNullOrWhiteSpace(newName))
            {
                MessageBox.Show("名称不能为空");
                return;
            }

            var fileName = System.IO.Path.Combine(this.Path, newName) + Dict.Extenstions.XmlModel_Extension;

            if (File.Exists(fileName))
            {
                MessageBox.Show("文件已经存在");
                return;
            }

            var writer = File.CreateText(fileName);

            writer.Flush();
            writer.Close();

            var dataModel = new XmlModelNode();

            dataModel.Parent = this;

            dataModel.FileName = System.IO.Path.GetFileNameWithoutExtension(fileName);
            dataModel.Name     = dataModel.Text = System.IO.Path.GetFileNameWithoutExtension(fileName);
            dataModel.FullName = fileName;

            this.TreeNode.Expand();

            var cmdHost = CommandHostManager.Instance().Get(
                CommandHostManager.HostType.XmlMode);
            var cmd = cmdHost.GetCommand(Dict.Commands.NewXmlModel)
                      as NewXmlModelCommand;

            cmd.File = dataModel.FullName;

            cmdHost.RunCommand(Dict.Commands.NewXmlModel);
        }
示例#7
0
        void docView_FormClosing(object sender, FormClosingEventArgs e)
        {
            try
            {
                var docView = sender as FileTabPanel;
                this.m_documentViewContainer.FindForm();
                if (docView != null)
                {
                    if (docView.TabText.EndsWith("*"))
                    {
                        var result = MessageBox.Show(string.Format("是否保存文件{0}", docView.TabText.Replace("*", "")), "提醒", MessageBoxButtons.YesNoCancel);

                        if (result == DialogResult.Yes)
                        {
                            var model = GlobalService.ModelManager.GetModel((Guid)docView.Tag);
                            model.Save();
                        }

                        if (result == DialogResult.No)
                        {
                        }

                        if (result == DialogResult.Cancel)
                        {
                            e.Cancel = true;
                            return;
                        }
                    }
                }

                if (this.m_documentViews.Contains(docView))
                {
                    var cmd = CommandHostManager.Instance().Get <CloseFileCommand>
                                  (CommandHostManager.HostType.Common, Dict.Commands.CloseFile);
                    cmd.FileId = (Guid)docView.Tag;
                    cmd.Execute();
                }

                docView.CloseTime = DateTime.Now;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#8
0
        void treeView1_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
        {
            BaseNode node = e.Node.Tag as BaseNode;

            DBGlobalService.DbType = DatabaseType.UnKnown;

            while (node != null)
            {
                if (node is ConnectionNode)
                {
                    DBGlobalService.ConnectionString    = ((ConnectionNode)node).ConncetionString;
                    DBGlobalService.DbType              = ((ConnectionNode)node).DbType;
                    DBGlobalService.DbContexUsingClause = ((ConnectionNode)node).DbContexUsingClause;
                    DBGlobalService.UseAutoMapper       = ((ConnectionNode)node).UseAutoMapper;
                    ((ConnectionNode)node).OnChange();
                    break;
                }
                node = node.Parent;
            }

            if (e.Button == System.Windows.Forms.MouseButtons.Right && e.Clicks == 1)
            {
                node = e.Node.Tag as BaseNode;
                if (node != null)
                {
                    ContextMenu menu = node.GetPopMenu();
                    e.Node.ContextMenu = menu;
                    e.Node.ContextMenu.Show(this.treeView1, e.Location);
                    e.Node.ContextMenu = null;
                }
            }

            if (e.Button == System.Windows.Forms.MouseButtons.Left)
            {
                node = e.Node.Tag as BaseNode;
                if (node != null)
                {
                    var cmd = CommandHostManager.Instance().Get <PropertySelectCommand>(CommandHostManager.HostType.Common, Dict.Commands.PropertySelect);
                    cmd.SelectedObj = node;
                    cmd.Execute();
                    //CommandHostManager.Instance().Run(CommandHostManager.HostType.Common, Dict.Commands.PropertySelect);
                    //this.Receiver.PropertySelect(node);
                }
            }
        }
示例#9
0
        public static void OpenFile(this CommandHostManager mgr, string file)
        {
            var extension = System.IO.Path.GetExtension(file);

            if (extension == Dict.Extenstions.DataModel_Extension)
            {
                var host = CommandHostManager.Instance().Get(CommandHostManager.HostType.DataModel);

                var cmd = host.GetCommand(Dict.Commands.OpenDataModel)
                          as OpenDataModelCommand;

                cmd.File = file;

                cmd.Execute();

                return;
            }
            if (extension == Dict.Extenstions.XmlModel_Extension)
            {
                var host = CommandHostManager.Instance().Get(CommandHostManager.HostType.XmlMode);

                var cmd = host.GetCommand(Dict.Commands.OpenXmlModel)
                          as OpenXmlModelCommand;

                cmd.File = file;

                cmd.Execute();

                return;
            }

            if (extension == Dict.Extenstions.ViewModel_Extension)
            {
                var host = CommandHostManager.Instance().Get(CommandHostManager.HostType.ViewModel);

                var cmd = host.GetCommand(Dict.Commands.OpenViewModel)
                          as OpenViewModelCommand;

                cmd.File = file;

                cmd.Execute();

                return;
            }

            if (extension == Dict.Extenstions.WorkFlow_Extension)
            {
                var host = CommandHostManager.Instance().Get(CommandHostManager.HostType.WorkFlow);

                var cmd = host.GetCommand(Dict.Commands.OpenWorkFlow)
                          as OpenWorkFlowCommand;

                cmd.File = file;

                cmd.Execute();

                return;
            }

            throw new Exception("在打开不支持的文件");
        }
示例#10
0
        void dgvError_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex == -1)
            {
                #region sort
                var dataSource = this.dgvError.DataSource as List <ParseErrorInfo>;

                var column = this.dgvError.Columns[e.ColumnIndex];
                if (column.Tag == null)
                {
                    column.Tag = 0;
                }

                var asc = !column.Tag.Equals(1)?true:false;

                if (column.Name == this.Line.Name)
                {
                    if (asc)
                    {
                        dataSource = dataSource.OrderBy(x => x.Line).ToList();
                    }
                    else
                    {
                        dataSource = dataSource.OrderByDescending(x => x.Line).ToList();
                    }
                }
                if (column.Name == this.CharIndexInLine.Name)
                {
                    if (asc)
                    {
                        dataSource = dataSource.OrderBy(x => x.CharPositionInLine).ToList();
                    }
                    else
                    {
                        dataSource = dataSource.OrderByDescending(x => x.CharPositionInLine).ToList();
                    }
                }
                if (column.Name == this.Message.Name)
                {
                    if (asc)
                    {
                        dataSource = dataSource.OrderBy(x => x.Message).ToList();
                    }
                    else
                    {
                        dataSource = dataSource.OrderByDescending(x => x.Message).ToList();
                    }
                }
                if (column.Name == this.File.Name)
                {
                    if (asc)
                    {
                        dataSource = dataSource.OrderBy(x => x.File).ToList();
                    }
                    else
                    {
                        dataSource = dataSource.OrderByDescending(x => x.File).ToList();
                    }
                }
                if (column.Name == this.ColumnFileId.Name)
                {
                    if (asc)
                    {
                        dataSource = dataSource.OrderBy(x => x.FileId).ToList();
                    }
                    else
                    {
                        dataSource = dataSource.OrderByDescending(x => x.FileId).ToList();
                    }
                }
                if (column.Name == this.ColumnErrorType.Name)
                {
                    if (asc)
                    {
                        dataSource = dataSource.OrderBy(x => x.ErrorType).ToList();
                    }
                    else
                    {
                        dataSource = dataSource.OrderByDescending(x => x.ErrorType).ToList();
                    }
                }
                if (asc)
                {
                    column.Tag = 1;
                }
                else
                {
                    column.Tag = 0;
                }

                this.dgvError.DataSource = dataSource;
                #endregion
            }
            if (e.RowIndex > -1)
            {
                var dataSource = this.dgvError.DataSource as List <ParseErrorInfo>;

                if (dataSource != null)
                {
                    var errorInfo = dataSource[e.RowIndex];

                    if (string.IsNullOrWhiteSpace(errorInfo.File) && errorInfo.FileId == Guid.Empty)
                    {
                        return;
                    }
                    if (!errorInfo.FileId.HasValue)
                    {
                        return;
                    }

                    var ctx = GlobalService.EditorContextManager.Get(errorInfo.FileId.Value);

                    if (ctx != null)
                    {
                        ctx.Controller.RePosition(errorInfo.Line - 1,
                                                  errorInfo.CharPositionInLine, RePositionType.Error, errorInfo.Message);

                        DocumentViewManager.Instance().ActiveView(ctx.Model.FileId);
                    }
                    else
                    {
                        //Assemble.CreateEditor(errorInfo.File);

                        //var cmdHost_common = CommandHostManager.Instance().Get(CommandHostManager.HostType.Common);
                        ////var cmd = cmdHost_common.GetCommand(Dict.Commands.OpenFile);
                        //cmdHost_common.RunCommand(Dict.Commands.OpenFile);
                        if (string.IsNullOrWhiteSpace(errorInfo.File) && errorInfo.FileId.HasValue)
                        {
                            var model = GlobalService.ModelManager.GetModel(errorInfo.FileId.Value);
                            errorInfo.File = model.File;
                        }

                        CommandHostManager.Instance().OpenFile(errorInfo.File);

                        ctx = GlobalService.EditorContextManager.Get(errorInfo.FileId.Value);

                        ctx.Controller.RePosition(errorInfo.Line - 1,
                                                  errorInfo.CharPositionInLine, RePositionType.Error, errorInfo.Message);
                    }
                }
            }
        }