예제 #1
0
            public void DropEverything(CMouseCaptureState this_state, CMouseCaptureState next_state)
            {
                HostForm.listBox1.Items.Add("DropEverything : " + this_state);

                MasterArrow = null;
                SlaveArrows.Clear();
            }
예제 #2
0
 void btnEditorOK_Click(object sender, SdlDotNet.Widgets.MouseButtonEventArgs e)
 {
     Arrows.Arrow arrowToSend = new Arrows.Arrow();
     arrowToSend.Name   = txtName.Text;
     arrowToSend.Pic    = hsbPic.Value;
     arrowToSend.Range  = hsbRange.Value;
     arrowToSend.Amount = hsbAmount.Value;
     Messenger.SendSaveArrow(itemNum, arrowToSend);
     pnlArrowEditor.Visible = false;
     pnlArrowList.Visible   = true;
     this.Size = new System.Drawing.Size(pnlArrowList.Width, pnlArrowList.Height);
 }
예제 #3
0
        public void DisplayArrowData()
        {
            // First, get the arrow instance based on the stored arrow index
            Arrows.Arrow arrow = Arrows.ArrowHelper.Arrows[itemNum];
            // Update the widgets with the arrow data
            txtName.Text = arrow.Name;
            //pic.Image = Tools.CropImage(Logic.Graphics.GraphicsManager.Arrows, new Rectangle(0, arrow.Pic * 32, 32, 32));
            hsbAmount.Value = arrow.Amount;
            hsbRange.Value  = arrow.Range;

            pnlArrowEditor.Visible = true;
            this.Size = new System.Drawing.Size(pnlArrowEditor.Width, pnlArrowEditor.Height);
        }
예제 #4
0
            public void DropSlave(CMouseCaptureState this_state, CMouseCaptureState next_state)
            {
                //   Переходы машины состояний [B1] и [B2]
                if ((next_state == CapturedSecond) || (next_state == CapturedMaster))
                {
                    HostForm.listBox1.Items.Add("DropSlave : " + this_state);

                    Arrows.Arrow arrow = ButtonToArrow(this_state.CapturedButton);
                    SlaveArrows.Remove(arrow);

                    this_state.CapturedButton = MouseButtons.None;
                }
            }
예제 #5
0
            //  Ответные события для машины состояний
            //---------------------------------------------------------------------------

            public void CaptureMaster(CMouseCaptureState this_state, CMouseCaptureState prev_state)
            {
                //   Захватываем основную "ведущую" стрелку.
                //   Нужно только в ситуации если вход в это состояние произошел
                //   из ситуации, когда ни одна кнопка мыши не была захвачена.
                if (prev_state == Released)
                {
                    HostForm.listBox1.Items.Add("CaptureMaster : " + this_state);

                    Arrows.Arrow arrow = ButtonToArrow(this_state.CapturedButton);
                    MasterArrow = arrow;
                    SlaveArrows.Clear();
                }
            }
예제 #6
0
            public void CaptureSlave(CMouseCaptureState this_state, CMouseCaptureState prev_state)
            {
                if
                (
                    //   Переход машины состояний [C1]
                    ((this_state == CapturedSecond) && (prev_state == CapturedMaster)) ||
                    //   Или переход машины состояний [C2]
                    ((this_state == CapturedThird) && (prev_state == CapturedSecond))
                )
                {
                    HostForm.listBox1.Items.Add("CaptureSlave : " + this_state);

                    Arrows.Arrow arrow = ButtonToArrow(this_state.CapturedButton);
                    SlaveArrows.Add(arrow);
                }
            }
예제 #7
0
 void btnEditorOK_Click(object sender, SdlDotNet.Widgets.MouseButtonEventArgs e)
 {
     Arrows.Arrow arrowToSend = new Arrows.Arrow();
     arrowToSend.Name = txtName.Text;
     arrowToSend.Pic = hsbPic.Value;
     arrowToSend.Range = hsbRange.Value;
     arrowToSend.Amount = hsbAmount.Value;
     Messenger.SendSaveArrow(itemNum, arrowToSend);
     pnlArrowEditor.Visible = false;
     pnlArrowList.Visible = true;
     this.Size = new System.Drawing.Size(pnlArrowList.Width, pnlArrowList.Height);
 }
예제 #8
0
            public CManipulator(ClockForm host)
            {
                HostForm = host;

                MasterArrow = null;
                SlaveArrows = new HashSet <Arrows.Arrow> ();

                ButtonToArrowMap = new Dictionary <MouseButtons, Arrows.Arrow>
                {
                    [MouseButtons.Left]   = HostForm.AllArrows.User1,
                    [MouseButtons.Right]  = HostForm.AllArrows.User2,
                    [MouseButtons.Middle] = HostForm.AllArrows.User3,
                };


                Released       = new CMouseCaptureState("Released");
                CapturedMaster = new CMouseCaptureState("Captured Master : First button");
                CapturedSecond = new CMouseCaptureState("Captured Slave : Second button");
                CapturedThird  = new CMouseCaptureState("Captured Slave : Third button");

                Released.OnEnter += DropEverything;

                CapturedMaster.OnEnter += CaptureMaster;

                CapturedSecond.OnEnter += CaptureSlave;
                CapturedSecond.OnLeave += DropSlave;

                CapturedThird.OnEnter += CaptureSlave;
                CapturedThird.OnLeave += DropSlave;

                //   Простая машина состояний для управления тремя векторами одновременно
                //   с использованием трех кнопок мыши. Используется для примера кода,
                //   а не потому, что это самое короткое или лучшее решение.
                //
                //   Три уровня «захвата» кнопок мыши.
                //
                //                                           .-------------------.
                //               .------------------------→  |   Зажата первая   |
                //               |               .---[R1]----|  "мастер" кнопка  |
                //               |               |           '-------------------'
                //              [C1]             |                   |    ↑
                //               |               |                 [C2]  [B1]
                //               |               |                   ↓    |
                //     .--------------------.    |           .---------------------.
                //     |  Мышь в свободном  | ←--O---[R2]----|  Две кнопки зажаты  |
                //     |      состоянии     |    |           '---------------------'
                //     '--------------------'    |                   |    ↑
                //                               |                 [C3]  [B2]
                //                               |                   ↓    |
                //                               |           .-------------------------.
                //                               '---[R3]----|  Все три кнопки зажаты  |
                //                                           '-------------------------'
                //
                //   Сокращения: C -- захват, B -- возврат, R -- сброс
                //
                //   Анализ состояния [CapturedMaster]
                //
                //     Точки входа:
                //     [C1]  ->  CapturedMaster.Enter  ->  делегат CaptureMaster из [C1]
                //     [B1]  ->  CapturedMaster.Enter  ->  делегат CaptureMaster из [B1]
                //
                //
                Machine = new СMouseStateMachine
                          (
                    new СMouseStateMachine.CStates
                    (
                        Released,
                        CapturedMaster,
                        CapturedSecond,
                        CapturedThird
                    )
                          );

                Machine.AttachTransition(CapturedMaster, CapturedSecond, TransDir.Any);
                Machine.AttachTransition(CapturedSecond, CapturedThird, TransDir.Any);
                Machine.AttachTransition(Released, CapturedMaster, TransDir.Forward);
                Machine.AttachTransition(Machine.Any, Released, TransDir.Forward);
            }