public bool SortUPProcess(Int32 id) { Dictionary <Int32, ProcessObjInfo> varDict = Collection.ToList().ToDictionary(key => key.ID, value => value); if (!varDict.ContainsKey(id)) { return(false); } Int32 index = id; Int32 pre_index = id - 1; if (pre_index <= 0) { pre_index = 1; } List <ProcessObjInfo> list = Collection.ToList(); ProcessObjInfo a = list[index - 1]; ProcessObjInfo b = list[pre_index - 1]; Int32 tmp = a.ID; a.ID = b.ID; b.ID = tmp; list[index - 1] = b; list[pre_index - 1] = a; AddProcess(list); return(true); }
public bool SortDownProcess(Int32 id) { Dictionary <Int32, ProcessObjInfo> varDict = Collection.ToList().ToDictionary(key => key.ID, value => value); if (!varDict.ContainsKey(id)) { return(false); } Int32 index = id; Int32 next_index = id + 1; if (next_index >= Collection.ToList().Count()) { next_index = Collection.ToList().Count(); } List <ProcessObjInfo> list = Collection.ToList(); ProcessObjInfo a = list[index - 1]; ProcessObjInfo b = list[next_index - 1]; Int32 tmp = a.ID; a.ID = b.ID; b.ID = tmp; list[index - 1] = b; list[next_index - 1] = a; AddProcess(list); return(true); }
public WinProcessDetail(FrameworkElement Owner, Proto.ProtoProcessDetail list, string net_id) { InitializeComponent(); RobotId = Convert.ToInt32(net_id); This = this; this.Owner = Tool.MainWindow.This; Left = 0; Top = 0; Width = Tool.MainWindow.This.Width; Height = Tool.MainWindow.This.Height; this.WindowStartupLocation = WindowStartupLocation.CenterOwner; int i = 0; foreach (var info in list.List) { ProcessObjInfo obj = new ProcessObjInfo(); obj.ID = ++i; obj.Name = info.ProcessName.value_; obj.Path = info.ProcessDir.value_; obj.Arg = info.ProcessArg.value_; obj.DelayTime = info.ProcessDelayTime.value_; List.Add(obj); } ProcessInfoCollect.GetInstance().AddProcess(List); Refresh(); }
private void OnClickAdd(object sender, RoutedEventArgs e) { string path = TBPath.Text.ToString(); if (path.Length > 250) { NotifyMessageEx.ShowNotify(Tool.MainWindow.This, "路径太长", "提示"); return; } if (path.Trim() == string.Empty) { NotifyMessageEx.ShowNotify(Tool.MainWindow.This, "请输入软件路径", "提示"); return; } string arg = TBArg.Text.ToString(); if (arg.Length > 250) { NotifyMessageEx.ShowNotify(Tool.MainWindow.This, "启动参数太长", "提示"); return; } string time = TBDeplyTime.Text.ToString().Trim(); if (time.Length > 4) { NotifyMessageEx.ShowNotify(Tool.MainWindow.This, "延迟时间太长,小于1000", "提示"); return; } if (time.Trim() == string.Empty) { NotifyMessageEx.ShowNotify(Tool.MainWindow.This, "请输入延迟时间", "提示"); return; } ProcessObjInfo info = new ProcessObjInfo(); info.Name = ""; info.Path = path; info.Arg = arg; info.DelayTime = Convert.ToInt32(time); if (!ProcessInfoCollect.GetInstance().AddProcess(info)) { NotifyMessageEx.ShowNotify(Tool.MainWindow.This, "添加失败!", "错误"); return; } Tool.ProcessConfig.WinProcessDetail.This.Refresh(); Tool.ProcessConfig.WinProcessDetail.This.UpdateProcessInfo(); this.Dispatcher.Invoke(() => { Close(); }); }
public bool AddProcess(ProcessObjInfo info) { Int32 id = 0; foreach (var obj in Collection.ToList()) { if (obj.ID > id) { id = obj.ID; } } if (id < 0) { return(false); } info.ID = id + 1; Collection.Add(info); return(true); }