// ///////////////////////////////////////////////////////////////////////////////// // ///////////////////////////////////////////////////////////////////////////////// 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); }
// ///////////////////////////////////////////////////////////////////////////////// #endregion #region Private // ///////////////////////////////////////////////////////////////////////////////// void numEntry_EntryChanged(object sender, EventArgs e) { NumberEntry entry = sender as NumberEntry; if (this.CurrentValue != entry.CurrentValue) { this.CurrentValue = entry.CurrentValue; OnValueChanged(); } }
// ///////////////////////////////////////////////////////////////////////////////// // ///////////////////////////////////////////////////////////////////////////////// /// <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); }
// ///////////////////////////////////////////////////////////////////////////////// // ///////////////////////////////////////////////////////////////////////////////// /// <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); }