Пример #1
0
        // /////////////////////////////////////////////////////////////////////////////////

        // /////////////////////////////////////////////////////////////////////////////////
        protected override void OnSettingUp()
        {
            base.OnSettingUp();

            if (!string.IsNullOrEmpty(Label))
            {
                labelRect   = new Rect(1, 1, Label.Length + 1, 1);
                upButtonPos = new Point(Label.Length + 2, 1);
            }
            else
            {
                upButtonPos = new Point(1, 1);
            }

            int  fieldWidth = NumberEntryTemplate.CalculateFieldWidth(MaximumValue, MinimumValue);
            Size fieldSize  = new Size(fieldWidth, 1);

            fieldRect = new Rect(upButtonPos.Shift(2, 0), fieldSize);

            downButtonPos = fieldRect.UpperRight.Shift(1, 0);

            numEntry = new NumberEntry(new NumberEntryTemplate()
            {
                HasFrameBorder    = false,
                MinimumValue      = this.MinimumValue,
                MaximumValue      = this.MaximumValue,
                StartingValue     = CurrentValue,
                CommitOnLostFocus = true,
                ReplaceOnFirstKey = true,
                UpperLeftPos      = fieldRect.UpperLeft
            });

            upButton = new EmitterButton(new EmitterButtonTemplate()
            {
                HasFrameBorder     = false,
                Label              = ((char)libtcod.TCODSpecialCharacter.ArrowNorthNoTail).ToString(),
                UpperLeftPos       = upButtonPos,
                StartEmittingDelay = SpinDelay,
                Speed              = SpinSpeed
            });

            downButton = new EmitterButton(new EmitterButtonTemplate()
            {
                HasFrameBorder     = false,
                Label              = ((char)libtcod.TCODSpecialCharacter.ArrowSouthNoTail).ToString(),
                UpperLeftPos       = downButtonPos,
                StartEmittingDelay = SpinDelay,
                Speed              = SpinSpeed
            });

            ParentWindow.AddControls(downButton, upButton, numEntry);

            upButton.Emit         += new EventHandler(upButton_Emit);
            downButton.Emit       += new EventHandler(downButton_Emit);
            numEntry.EntryChanged += new EventHandler(numEntry_EntryChanged);
        }
Пример #2
0
 protected internal override void OnAdded()
 {
     base.OnAdded();
     if (ShowLabel)
     {
         ParentWindow.AddControl(_numEntry);
     }
     ParentWindow.AddControls(_valueBar);
     ParentWindow.AddControls(_leftButton, _rightButton);
 }
Пример #3
0
        // /////////////////////////////////////////////////////////////////////////////////

        // /////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Creates the NumberEntry and ValueBar for this slider.
        /// </summary>
        protected override void OnSettingUp()
        {
            base.OnSettingUp();

            Point fieldPos;

            if (!string.IsNullOrEmpty(Label))
            {
                labelRect = new Rect(1, 1, Label.Length + 1, 1);
                fieldPos  = new Point(Label.Length + 2, 1);
            }
            else
            {
                fieldPos = new Point(1, 1);
            }

            int  fieldWidth = NumberEntryTemplate.CalculateFieldWidth(MaximumValue, MinimumValue);
            Size fieldSize  = new Size(fieldWidth, 1);

            fieldRect = new Rect(fieldPos, fieldSize);

            if (BarPigment == null)
            {
                BarPigment = DetermineMainPigment();
            }

            numEntry = new NumberEntry(new NumberEntryTemplate()
            {
                HasFrameBorder    = false,
                MinimumValue      = this.MinimumValue,
                MaximumValue      = this.MaximumValue,
                StartingValue     = CurrentValue,
                CommitOnLostFocus = true,
                ReplaceOnFirstKey = true,
                UpperLeftPos      = this.LocalToScreen(fieldRect.UpperLeft)
            });

            valueBar = new ValueBar(new ValueBarTemplate()
            {
                UpperLeftPos  = this.LocalToScreen(new Point(1, 2)),
                Width         = this.Size.Width - 4,
                MaximumValue  = this.MaximumValue,
                MinimumValue  = this.MinimumValue,
                StartingValue = this.CurrentValue,
                BarPigment    = this.BarPigment
            });

            ParentWindow.AddControls(valueBar, numEntry);

            numEntry.EntryChanged += new EventHandler(numEntry_EntryChanged);

            valueBar.MouseMoved += new EventHandler <MouseEventArgs>(valueBar_MouseMoved);

            valueBar.MouseButtonDown += new EventHandler <MouseEventArgs>(valueBar_MouseButtonDown);
        }
Пример #4
0
        /// <summary>
        /// As mentioned, MyManager is responsible for initializing all of the buttons and
        /// user interface logic, which we do in the OnSettingUp method.
        /// </summary>
        protected override void OnSettingUp()
        {
            base.OnSettingUp();

            /// First define the teleport button template.  Here we are going to use the MinimumWidth
            /// properties for all of these buttons so that they are all the same size, and thus
            /// line up nicely.
            ButtonTemplate telButtonTemplate = new ButtonTemplate()
            {
                Label        = "Teleport",
                UpperLeftPos = new Point(3, 1),
                MinimumWidth = 12
            };

            /// Here we see a more intuitive way of positioning a control (or, more technically,
            /// a control template) relative to another one.  In this case, we are going to
            /// place our redButtonTemplate directly underneath the telButtonTemplate, with 1
            /// extra space in between.

            ButtonTemplate redButtonTemplate = new ButtonTemplate()
            {
                Label        = "Turn Red",
                MinimumWidth = 12
            };

            redButtonTemplate.AlignTo(LayoutDirection.South, telButtonTemplate, 1);

            /// This one will go directly to the right of the red button template.

            ButtonTemplate blueButtonTemplate = new ButtonTemplate()
            {
                Label        = "Turn Blue",
                MinimumWidth = 12
            };

            blueButtonTemplate.AlignTo(LayoutDirection.East, redButtonTemplate, 2);



            /// Create the buttons, add them to the window, and hook into their events.

            Button teleportButton = new Button(telButtonTemplate);
            Button turnRedButton  = new Button(redButtonTemplate);
            Button turnBlueButton = new Button(blueButtonTemplate);

            Button quitButton = new Button(new ButtonTemplate()
            {
                Label        = "QUIT",
                UpperLeftPos = new Point(74, 0)
            });

            ParentWindow.AddControls(quitButton, turnBlueButton, turnRedButton, teleportButton);

            quitButton.ButtonPushed += new EventHandler(quitButton_ButtonClicked);

            teleportButton.ButtonPushed += new EventHandler(teleportButton_ButtonClicked);

            turnBlueButton.ButtonPushed += new EventHandler(turnBlueButton_ButtonClicked);

            turnRedButton.ButtonPushed += new EventHandler(turnRedButton_ButtonClicked);



            /// Here we hilight the scheduling feature of the framework.  All descendents of Component, which
            /// includes our MyManager class, have access to the AddSchedule method.  This method takes as
            /// a parameter a Schedule instance, which in turn is constructed with 2 arguments:
            /// 1.  A delegate indiciating which method to call at the appropriate time
            /// 2.  A delay value in milliseconds.
            ///
            /// Here, we are telling the scheduler to call our Flicker method every 100 milliseconds.
            AddSchedule(new Schedule(Flicker, 100));
        }
Пример #5
0
 protected internal override void OnAdded()
 {
     base.OnAdded();
     ParentWindow.AddControls(_valueBar);
     ParentWindow.AddControls(_topButton, _bottomButton);
 }
Пример #6
0
		protected internal override void OnAdded() {
			base.OnAdded();
			ParentWindow.AddControls(_downButton, _upButton, _numEntry);
		}