예제 #1
0
        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());
            }
        }
예제 #2
0
 public MainForm()
 {
     InitializeComponent();
     consoleControl1.InternalRichTextBox.TextChanged += InternalRichTextBox_TextChanged;
     consoleControl1.ProcessInterface.OnProcessExit  += ProcessInterface_OnProcessExit;
     mainthreadact = mainthreadthingy;
 }
예제 #3
0
        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);
        }
예제 #4
0
 public void BeginAction()
 {
     if (_currentaction != null)
     {
         throw new Exception("Attempt to overwrite current undo state");
     }
     _currentaction = new act();
 }
예제 #5
0
 public void CancelAction()
 {
     if (_currentaction == null)
     {
         throw new Exception("UndoManager current action null");
     }
     DoAction(_currentaction, true);
     _currentaction = null;
 }
예제 #6
0
        /// <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);
            }
        }
예제 #7
0
 void Start()
 {
     cact   = null;
     actque = new act[actquemax];
     for (int n = 0; n < actquemax; n++)
     {
         actque[n]      = new act();
         actque[n].body = this;
     }
 }
예제 #8
0
    public void add(act dest)
    {
        if (dest == null || actnum >= actquemax)
        {
            return;
        }

        actquesort();
        actque[actnum++].copy(dest);
        actindex = actnum - 1;
    }
예제 #9
0
 public void Clock_tick()
 {
     if (timer.Count > 0)
     {
         if (DateTime.Compare(timer.Peek(), DateTime.Now) <= 0)
         {
             timer.Dequeue();
             act a = actions.Dequeue();
             a();
         }
     }
 }
예제 #10
0
    private void clearact()
    {
        foreach (act a in actque)
        {
            if (a == null)
            {
                continue;
            }

            a.reset();
        }
        cact = null;
    }
예제 #11
0
        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);
        }
예제 #12
0
 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();
 }
예제 #13
0
 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;
 }
예제 #14
0
        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();
        }
예제 #15
0
        /// <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);
            }
        }
예제 #16
0
    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);
    }
예제 #17
0
        /// <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);
            }
        }
예제 #18
0
        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();
             */
        }
예제 #19
0
 await WaitForPredicateAsync(a => !EqualityComparer <T> .Default.Equals(a, default), act, timeout, interval);
예제 #20
0
    // 自动执行最优解步骤
    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());
             * }
             */
        }
    }
예제 #21
0
파일: GameCtrl.cs 프로젝트: alastorid/gcac
        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);
        }
예제 #22
0
파일: Fixtures.cs 프로젝트: 8T4/gwtdo
 public static act I_ask_to_sell_20_shares_of_MSFT_stock(this act fixtures) =>
 fixtures.It(f => f.Stocks.Sell("MSFT", 20));
예제 #23
0
 public act(act dest)
 {
     started = false;
     valid   = false;
     copy(dest);
 }