Пример #1
0
        protected override void LoadFile()
        {
            var directory = new DirectoryInfo(Path);

            foreach (var dm in directory.GetFiles("*" + Dict.Extenstions.WorkFlow_Extension))
            {
                var dmNode = new WorkFlowNode();
                dmNode.FullName = dm.FullName;
                dmNode.Parent   = this;
            }
        }
Пример #2
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.WorkFlow_Extension;

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

            var writer = File.CreateText(fileName);

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

            var dataModel = new WorkFlowNode();

            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.WorkFlow);
            var cmd = cmdHost.GetCommand(Dict.Commands.NewWorkFlow)
                      as NewWorkFlowCommand;

            cmd.File = dataModel.FullName;

            cmdHost.RunCommand(Dict.Commands.NewWorkFlow);
        }