// ///////////////////////////////////////////////////////////////////////////////// // ///////////////////////////////////////////////////////////////////////////////// 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); }
// ///////////////////////////////////////////////////////////////////////////////// // ///////////////////////////////////////////////////////////////////////////////// /// <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); }
public override Size CalculateSize() { int width = 2; // for frame if (!string.IsNullOrEmpty(Label)) { width += Canvas.TextLength(Label) + 1; } width += NumberEntryTemplate.CalculateFieldWidth(MaximumValue, MinimumValue); width += 3; // for buttons return(new Size(width, 3)); }