public void copy(act dest) { if (dest == null) { return; } type = new string(dest.type.ToCharArray()); valid = false; if (type != null) { if (type != "none") { valid = true; } } time = dest.time; if (dest.i != null) { i = (int[])dest.i.Clone(); } if (dest.f != null) { f = (float[])dest.f.Clone(); } if (dest.slist != null) { slist.Clear(); slist.AddRange(dest.slist.ToArray()); } }
public MainForm() { InitializeComponent(); consoleControl1.InternalRichTextBox.TextChanged += InternalRichTextBox_TextChanged; consoleControl1.ProcessInterface.OnProcessExit += ProcessInterface_OnProcessExit; mainthreadact = mainthreadthingy; }
public void Act_Delay_min(act a, int min) { int ms = 60 * 1000 * min; timer.Enqueue(desinationTime.AddMilliseconds(ms)); actions.Enqueue(a); desinationTime = desinationTime.AddMilliseconds(ms); }
public void BeginAction() { if (_currentaction != null) { throw new Exception("Attempt to overwrite current undo state"); } _currentaction = new act(); }
public void CancelAction() { if (_currentaction == null) { throw new Exception("UndoManager current action null"); } DoAction(_currentaction, true); _currentaction = null; }
/// <summary> /// Применение изменений /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnApply_Click(object sender, EventArgs e) { try { int index = listSigns.SelectedIndex; if (index != -1) { road_sign sign = PE.road_sign.ToArray <road_sign>()[index]; PE.road_sign.Where(x => x.code_road_sign == sign.code_road_sign).First().description = tbDescription.Text; var lP = PE.item_list_prohibition.Where(x => x.code_road_sign == sign.code_road_sign); foreach (var item in lP) { PE.item_list_prohibition.Remove(item); } var lR = PE.item_list_resolution.Where(x => x.code_road_sign == sign.code_road_sign); foreach (var item in lR) { PE.item_list_resolution.Remove(item); } PE.SaveChanges(); foreach (string item in listResolution.Items) { act _act = PE.act.Where(x => x.name == item).First(); item_list_resolution iR = new item_list_resolution(); iR.code_road_sign = sign.code_road_sign; iR.code_act = _act.code_act; PE.item_list_resolution.Add(iR); PE.SaveChanges(); } foreach (string item in listProhibishin.Items) { act _act = PE.act.Where(x => x.name == item).First(); item_list_prohibition iP = new item_list_prohibition(); iP.code_road_sign = sign.code_road_sign; iP.code_act = _act.code_act; PE.item_list_prohibition.Add(iP); PE.SaveChanges(); } } } catch (Exception ex) { MessageBox.Show(ex.StackTrace); } }
void Start() { cact = null; actque = new act[actquemax]; for (int n = 0; n < actquemax; n++) { actque[n] = new act(); actque[n].body = this; } }
public void add(act dest) { if (dest == null || actnum >= actquemax) { return; } actquesort(); actque[actnum++].copy(dest); actindex = actnum - 1; }
public void Clock_tick() { if (timer.Count > 0) { if (DateTime.Compare(timer.Peek(), DateTime.Now) <= 0) { timer.Dequeue(); act a = actions.Dequeue(); a(); } } }
private void clearact() { foreach (act a in actque) { if (a == null) { continue; } a.reset(); } cact = null; }
private void BtnNY_Click(object sender, RoutedEventArgs e) { double a = 1; double n = double.Parse(n_text.Text); long y = long.Parse(y_text.Text); act ac = Mul; if (y < 0) { ac = Div; y *= -1; } for (long i = 0; i < y; i++) { a = ac(a, n); } MessageBox.Show(n + "^" + y + "=" + a); }
private void DoAction(act action, bool undo) { using (var trk = game.Track.CreateTrackWriter()) { trk.DisableUndo(); trk.DisableExtensionUpdating(); if (undo) { action.Undo(trk); } else { action.Redo(trk); } } game.Track.NotifyTrackChanged(); game.Track.Invalidate(); }
public void EndAction() { if (_currentaction == null) { throw new Exception("UndoManager current action null"); } if (_position != _actions.Count) { _actions.RemoveRange(_position, _actions.Count - _position); } if (_actions.Count > MaximumBufferSize) { _actions.RemoveRange(0, _actions.Count - (MaximumBufferSize / 2)); } _actions.Add(_currentaction); _position = _actions.Count; ActionCount++; _currentaction = null; }
private void AddNewSign() { road_sign newSign = new road_sign(); newSign.name = tbName.Text; newSign.pdd_number = tbNumber.Text; newSign.code_type_sign = PE.type_road_sign.ToArray <type_road_sign>()[cbType.SelectedIndex].code_type_road_sign; newSign.description = tbDescription.Text; ImageWorker IM = new ImageWorker(); IM.CopyImageByName(tbPath.Text, newSign.pdd_number.Replace('.', '_')); newSign.img = newSign.pdd_number.Replace('.', '_') + ".png"; PE.road_sign.Add(newSign); PE.SaveChanges(); foreach (string item in listResolution.Items) { act _act = PE.act.Where(x => x.name == item).First(); item_list_resolution iR = new item_list_resolution(); iR.code_road_sign = newSign.code_road_sign; iR.code_act = _act.code_act; PE.item_list_resolution.Add(iR); PE.SaveChanges(); } foreach (string item in listProhibishin.Items) { act _act = PE.act.Where(x => x.name == item).First(); item_list_prohibition iP = new item_list_prohibition(); iP.code_road_sign = newSign.code_road_sign; iP.code_act = _act.code_act; PE.item_list_prohibition.Add(iP); PE.SaveChanges(); } this.Close(); }
/// <summary> /// Удаление действия из списка /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnDelete_Click(object sender, EventArgs e) { try { if (listAct.SelectedIndex > -1) { int index = listAct.SelectedIndex; act _act = PE.act.ToArray <act>()[index]; PE.act.Remove(_act); PE.SaveChanges(); UpdateList(); } } catch (Exception ex) { MessageBox.Show(ex.StackTrace); } }
private bool loadtocact() { if (actnum <= 0) { return(false); } cact = actque[actindex]; actindex = --actnum - 1; if (actindex < 0) { actindex = 0; } if (!cact.valid) { cact.reset(); return(false); } actquesort(); return(true); }
/// <summary> /// Добавление действия /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnAdd_Click(object sender, EventArgs e) { try { if (listAct.Items.IndexOf(tbName.Text) < 0) { listAct.Items.Add(tbName.Text); act newAct = new act(); newAct.name = tbName.Text; PE.act.Add(newAct); PE.SaveChanges(); UpdateList(); } } catch (Exception ex) { MessageBox.Show(ex.StackTrace); } }
public void Act_Delay_ms(act a, int ms) { timer.Enqueue(desinationTime.AddMilliseconds(ms)); actions.Enqueue(a); desinationTime = desinationTime.AddMilliseconds(ms); /* * DateTime sourcetime = DateTime.Now; * DateTime destinationtime = sourcetime.AddMilliseconds(ms); * * while(DateTime.Compare(destinationtime,DateTime.Now) < 0) * { * // loop * } * * //finish delay * * // add to buffer or excute linear????? * // get this done latter * Thread thread = new Thread(new ThreadStart(CreatDelayThread)); * thread.Start(); */ }
await WaitForPredicateAsync(a => !EqualityComparer <T> .Default.Equals(a, default), act, timeout, interval);
// 自动执行最优解步骤 public void AutoAct() { int h = HumansOnRight.Count; int e = EvilsOnRight.Count; if (side == 0) { // 船在左侧,右岸增员 act nextMove = matLeft[h, e]; switch (nextMove) { case act.LE: GetOn(EvilsOnLeft.Pop()); break; case act.LH: GetOn(HumansOnLeft.Pop()); break; case act.LHE: GetOn(HumansOnLeft.Pop()); GetOn(EvilsOnLeft.Pop()); break; default: break; } /* * if ( (h == 3 && e < 3) || (h == 0 && e < 3)) * { * GetOn(EvilsOnLeft.Pop()); * } * if ((h == 2 && e == 2) ) * { * GetOn(HumansOnLeft.Pop()); * } * if ((h == 1 && e == 1)) * { * GetOn(HumansOnLeft.Pop()); * GetOn(EvilsOnLeft.Pop()); * } */ } else if (side == 1) { // 船在右侧,右岸减员 act nextMove = matRight[h, e]; switch (nextMove) { case act.REE: GetOn(EvilsOnRight.Pop()); GetOn(EvilsOnRight.Pop()); break; case act.RHH: GetOn(HumansOnRight.Pop()); GetOn(HumansOnRight.Pop()); break; case act.RHE: GetOn(EvilsOnRight.Pop()); GetOn(HumansOnRight.Pop()); break; default: break; } /* * if (h == 3 && e == 3) * { * GetOn(EvilsOnRight.Pop()); * GetOn(HumansOnRight.Pop()); * } * if ((h == 3 && e == 2) || (h == 0 && e > 1)) * { * GetOn(EvilsOnRight.Pop()); * GetOn(EvilsOnRight.Pop()); * } * if ((h == 3 && e == 1) || (h == 2 && e == 2)) * { * GetOn(HumansOnRight.Pop()); * GetOn(HumansOnRight.Pop()); * } */ } }
public void Action(act what) { funcDescribe thisfunc = mDictDescribes[what]; switch (thisfunc.type) { case Type.keyboard: //mJoyControl.Key(thisfunc.KeybdInput); mDxDeviceCtrl.Send(thisfunc.KeybdInput); RingPostM.RingPst(mProcessHwnd,thisfunc.VirtualKeyInput,RingPostM.RingPstType.press); break; case Type.mouseClick: mMouseCtrl.MoveRelatedToProcess(mProcessHwnd, thisfunc.point.X, thisfunc.point.Y); System.Threading.Thread.Sleep(thisfunc.delay); mDxDeviceCtrl.Send(DxDeviceCtrl.dxMouseButton.Left); System.Threading.Thread.Sleep(thisfunc.delay*2); mMouseCtrl.Release(); break; case Type.mouseMove: mMouseCtrl.MoveRelatedToProcess(mProcessHwnd, thisfunc.point.X, thisfunc.point.Y); System.Threading.Thread.Sleep(thisfunc.delay); mMouseCtrl.Release(); break; default: throw new Exception("Action Type didn't set!"); break; } System.Threading.Thread.Sleep(thisfunc.delay); }
public static act I_ask_to_sell_20_shares_of_MSFT_stock(this act fixtures) => fixtures.It(f => f.Stocks.Sell("MSFT", 20));
public act(act dest) { started = false; valid = false; copy(dest); }