コード例 #1
0
ファイル: ProjectMgr.cs プロジェクト: fj1981/mvp_frame
        public bool NewFlow(String flow_name)
        {
            if (null == flow_name || 0 == flow_name.Length)
            {
                MessageBox.Show("流程名不能为空");
                return(false);
            }
            var flow_obj = new ToolObj();

            flow_obj.guid = FlowPlugFactory.Guid;
            flow_obj.name = flow_name;
            if (null == root_obj_)
            {
                root_obj_      = new ToolObj();
                root_obj_.type = PlugType.PT_FLOW;
                root_obj_.AddObj(-1, flow_obj, true);
                TaskMgr.Instance.Init(root_obj_);
                onPrjLoadFininsh?.Invoke(root_obj_);
                ToolObj.focusTool = flow_obj;
                return(true);
            }
            else
            {
                root_obj_.AddObj(-1, flow_obj, true);
                return(true);
            }
        }
コード例 #2
0
ファイル: ToolObj.cs プロジェクト: fj1981/mvp_frame
 public NotifyParam(TOOL_CHANGED_TYPE type,
                    ToolObj current, ToolObj parent, int index = -1)
 {
     Type    = type;
     Current = current;
     Parent  = parent;
     Index   = index;
 }
コード例 #3
0
ファイル: ToolObj.cs プロジェクト: fj1981/mvp_frame
        void ModifyNotify()
        {
            ToolObj parent1 = null;

            if (null != parent)
            {
                parent1 = parent.IsAlive ? parent.Target as ToolObj : null;
            }
            changedNotify?.Invoke(new NotifyParam(TOOL_CHANGED_TYPE.TCT_MODIFY, this, parent1));
        }
コード例 #4
0
 void OnUpdateProperty(ToolObj tool)
 {
     curTool_ = tool;
     if (null != tool && null != tool.plug_)
     {
         property_.SelectedObject = tool.plug_.GetProperty();
     }
     else
     {
         property_.SelectedObject = null;
     }
 }
コード例 #5
0
 public void OnFileloadFinish(ToolObj root)
 {
     treeList_.Nodes.Clear();
     if (null != root.children)
     {
         foreach (var a in root.children)
         {
             AppendTree(a, -1);
         }
     }
     root_ = root;
     ToolObj.changedNotify += OnToolChangedNotify;
 }
コード例 #6
0
        private TreeListNode AppendTree(ToolObj obj, int parent_id)
        {
            var node = treeList_.AppendNode(new object[] { obj.name }, parent_id, -1, 0, (int)obj.type);

            obj.tree_id_ = node.Id;
            if (null != obj.children)
            {
                foreach (var a in obj.children)
                {
                    AppendTree(a, node.Id);
                }
            }
            return(node);
        }
コード例 #7
0
ファイル: TaskMgr.cs プロジェクト: fj1981/mvp_frame
        public void Init(ToolObj tools)
        {
            if (tools != null)
            {
                tools.UpdateProperty(false);
            }

            tasks_ = new List <Task>();
            foreach (var tool in tools.children)
            {
                var task = new Task();
                task.Init(tool, OnTaskStateChanged);
                tasks_.Add(task);
            }
        }
コード例 #8
0
ファイル: ToolObj.cs プロジェクト: fj1981/mvp_frame
        public bool AddObj(int id, ToolObj obj, bool insert)
        {
            if (id == -1 && insert)
            {
                if (null == children)
                {
                    children = new List <ToolObj>();
                }
                obj.parent = new WeakReference(this);
                obj.UpdateProperty(false);
                children.Add(obj);
                changedNotify?.Invoke(new NotifyParam(TOOL_CHANGED_TYPE.TCT_ADD, obj, this));
                return(true);
            }
            if (children == null)
            {
                return(false);
            }
            bool ret   = false;
            int  index = 0;

            foreach (var e in children)
            {
                ++index;
                if (e != null && e.tree_id_ == id)
                {
                    if (insert)
                    {
                        if (e.children == null)
                        {
                            e.children = new List <ToolObj>();
                        }
                        obj.parent = new WeakReference(e);
                        e.children.Add(obj);
                        changedNotify?.Invoke(new NotifyParam(TOOL_CHANGED_TYPE.TCT_ADD, obj, e));
                    }
                    else
                    {
                        obj.parent = new WeakReference(this);
                        children.Insert(index, obj);
                        changedNotify?.Invoke(new NotifyParam(TOOL_CHANGED_TYPE.TCT_ADD, obj, this, index));
                    }
                    ret = true;
                    break;
                }
            }
            return(ret);
        }
コード例 #9
0
ファイル: ProjectMgr.cs プロジェクト: fj1981/mvp_frame
 public void OpenProject(string path)
 {
     path_ = path;
     using (FileStream fsRead = new FileStream(path, FileMode.Open)) {
         int    fsLen  = (int)fsRead.Length;
         byte[] heByte = new byte[fsLen];
         int    r      = fsRead.Read(heByte, 0, heByte.Length);
         string myStr  = System.Text.Encoding.UTF8.GetString(heByte);
         root_obj_ = JsonConvert.DeserializeObject <ToolObj>(myStr);
         if (root_obj_ != null)
         {
             // root_obj_.UpdateProperty()
         }
         TaskMgr.Instance.Init(root_obj_);
         onPrjLoadFininsh? .Invoke(root_obj_);
     }
 }
コード例 #10
0
ファイル: ProjectMgr.cs プロジェクト: fj1981/mvp_frame
        public bool NewProcess(IPlugin plug)
        {
            if (null == root_obj_)
            {
                MessageBox.Show("请先创建一个流程");
                return(false);
            }
            var focus = ToolObj.focusTool;

            if (null == focus)
            {
                MessageBox.Show("请选择插入的位置");
                return(false);
            }
            var prop = plug.GetProperty();

            prop.name        = plug.GetPlugInfo().GetPlugName();
            prop.description = plug.GetPlugInfo().GetDescription();
            prop.UpdateDefault();

            var proc_obj = new ToolObj();

            proc_obj.guid  = plug.GetPlugInfo().GetUUID();
            proc_obj.name  = prop.name;
            proc_obj.plug_ = plug;
            proc_obj.type  = plug.GetPlugInfo().GetPlugType();
            if (focus.type == PlugType.PT_FLOW)
            {
                focus.AddObj(-1, proc_obj, true);
                return(true);
            }

            var flow = focus;

            flow = flow.parent.Target as ToolObj;
            if (null != flow)
            {
                flow.AddObj(focus.tree_id_, proc_obj, false);
            }
            return(true);
        }
コード例 #11
0
 public void Init(ToolObj tool, NotifyTaskStateChanged notify)
 {
     toolObj_ = tool;
     notifyTaskStateChanged_ = notify;
 }