/// <summary> /// Creates dateTimePicker's children /// </summary> public override void CreateChildren() { this.textBoxElement = new RadMaskedEditBoxElement(); this.textBoxElement.KeyDown += new KeyEventHandler(textBoxElement_KeyDown); this.textBoxElement.KeyPress += new KeyPressEventHandler(textBoxElement_KeyPress); this.textBoxElement.KeyUp += new KeyEventHandler(textBoxElement_KeyUp); this.textBoxElement.Mask = ""; this.textBoxElement.MaskType = MaskType.DateTime; this.textBoxElement.ValueChanged += new EventHandler(maskBox_ValueChanged); this.textBoxElement.TextBoxItem.LostFocus += new EventHandler(maskBox_LostFocus); this.textBoxElement.TextBoxItem.TextChanged += new EventHandler(maskBox_TextChanged); this.textBoxElement.MouseDown += new MouseEventHandler(maskBox_MouseDown); this.textBoxElement.ShowBorder = false; this.textBoxElement.Class = "textbox"; this.textBoxElement.ThemeRole = "DateTimePickerMaskTextBoxElement"; this.dockLayout = new DockLayoutPanel(); this.border = new BorderPrimitive(); this.backGround = new FillPrimitive(); this.checkBox = new RadCheckBoxElement(); this.border.Class = "DateTimePickerBorder"; this.backGround.Class = "DateTimePickerBackGround"; this.backGround.GradientStyle = GradientStyles.Solid; this.checkBox.SetValue(DockLayoutPanel.DockProperty, Dock.Left); this.checkBox.Children[1].Alignment = ContentAlignment.MiddleLeft; this.checkBox.StretchHorizontally = false; this.textBoxElement.Alignment = ContentAlignment.MiddleLeft; this.upButton = new RadRepeatArrowElement(); this.upButton.ThemeRole = "UpButton"; this.upButton.Padding = new Padding(3, 1, 3, 1); this.upButton.Border.Visibility = ElementVisibility.Visible; this.upButton.Click += new EventHandler(upButton_Click); this.upButton.Direction = ArrowDirection.Up; this.upButton.Arrow.AutoSize = true; this.upButton.CanFocus = false; this.downButton = new RadRepeatArrowElement(); this.downButton.ThemeRole = "DownButton"; this.downButton.Padding = new Padding(3, 1, 3, 0); this.downButton.Border.Visibility = ElementVisibility.Visible; this.downButton.Click += new EventHandler(downButton_Click); this.downButton.Arrow.AutoSize = true; this.downButton.Direction = ArrowDirection.Down; this.downButton.CanFocus = false; BoxLayout stackLayout = new BoxLayout(); stackLayout.Orientation = Orientation.Vertical; BoxLayout.SetProportion(this.upButton, 1); BoxLayout.SetProportion(this.downButton, 1); stackLayout.Children.Add(this.upButton); stackLayout.Children.Add(this.downButton); if (this.dateTimePickerElement.RightToLeft) { this.checkBox.SetValue(DockLayoutPanel.DockProperty, Dock.Right); this.checkBox.Children[1].Alignment = ContentAlignment.MiddleLeft; stackLayout.SetValue(DockLayoutPanel.DockProperty, Dock.Left); stackLayout.RightToLeft = false; this.textBoxElement.TextBoxItem.HostedControl.RightToLeft = RightToLeft.Yes; } else { this.checkBox.SetValue(DockLayoutPanel.DockProperty, Dock.Left); this.checkBox.Children[1].Alignment = ContentAlignment.MiddleLeft; stackLayout.SetValue(DockLayoutPanel.DockProperty, Dock.Right); this.textBoxElement.TextBoxItem.HostedControl.RightToLeft = RightToLeft.No; } this.dockLayout.Children.Add(this.checkBox); this.dockLayout.Children.Add(stackLayout); this.dockLayout.Children.Add(this.textBoxElement); this.dateTimePickerElement.Children.Add(this.backGround); this.dateTimePickerElement.Children.Add(this.dockLayout); this.dateTimePickerElement.Children.Add(this.border); this.dateTimePickerElement.checkBox = this.checkBox; if (!this.dateTimePickerElement.ShowCheckBox) { this.checkBox.Visibility = Telerik.WinControls.ElementVisibility.Collapsed; } this.SetDateByValue(this.dateTimePickerElement.Value, this.dateTimePickerElement.Format); // The BorderPrimitive of the RadTextBoxElement should be collapsed. This makes the size of the editors equal this.textBoxElement.Children[this.textBoxElement.Children.Count - 1].Visibility = ElementVisibility.Collapsed; this.border.Visibility = ElementVisibility.Visible; this.SetDateByValue(this.dateTimePickerElement.Value, this.dateTimePickerElement.Format); }
/// <summary> /// create child elements /// </summary> protected override void CreateChildElements() { this.textItem = new RadTextBoxItem(); this.SetSpinValue(this.value, true); this.textItem.TextChanging += new TextChangingEventHandler(textItem_TextChanging); this.textItem.TextChanged += new EventHandler(textItem_TextChanged); this.textItem.LostFocus += new EventHandler(textItem_LostFocus); this.textItem.KeyPress += new KeyPressEventHandler(textItem_KeyPress); this.textItem.KeyDown += new KeyEventHandler(textItem_KeyDown); this.textItem.KeyUp += new KeyEventHandler(textItem_KeyUp); this.textItem.HostedControl.MouseWheel += new MouseEventHandler(textItem_MouseWheel); this.textItem.HostedControl.MouseUp += new MouseEventHandler(HostedControl_MouseUp); this.textItem.Alignment = ContentAlignment.MiddleLeft; this.textItem.StretchHorizontally = true; this.textItem.StretchVertically = false; this.buttonUp = new RadRepeatArrowElement(); this.buttonUp.ThemeRole = "UpButton"; this.buttonUp.Class = "UpButton"; //hack!!!!!!!!!!!! this.buttonUp.Padding = new Padding(1, 0, 3, 2); //this.buttonUp.Margin = new Padding(0, 1, 1, 0); //this.buttonUp.Border.Visibility = ElementVisibility.Collapsed; this.buttonUp.Click += new EventHandler(ButtonUp_Click); this.buttonUp.DoubleClick += new EventHandler(ButtonUp_Click); this.buttonUp.Direction = ArrowDirection.Up; this.buttonUp.Arrow.AutoSize = true; this.buttonDown = new RadRepeatArrowElement(); this.buttonDown.ThemeRole = "DownButton"; this.buttonDown.Class = "DownButton"; //hack!!!!!!!!!!!! this.buttonDown.Padding = new Padding(1, 1, 3, 1); //this.buttonDown.Margin = new Padding(0, 0, 1, 1); //this.buttonDown.Border.Visibility = ElementVisibility.Collapsed; this.buttonDown.Click += new EventHandler(ButtonDown_Click); this.buttonDown.DoubleClick += new EventHandler(ButtonDown_Click); this.buttonDown.Arrow.AutoSize = true; this.buttonDown.Direction = ArrowDirection.Down; this.stackLayout = new BoxLayout(); this.stackLayout.Orientation = Orientation.Vertical; BoxLayout.SetProportion(this.buttonUp, 1); BoxLayout.SetProportion(this.buttonDown, 1); this.stackLayout.Children.Add(this.buttonUp); this.stackLayout.Children.Add(this.buttonDown); this.textBoxFillPrimitive = new FillPrimitive(); this.textBoxFillPrimitive.Class = "SpinElementFill"; this.textBoxFillPrimitive.NumberOfColors = 1; this.textBoxFillPrimitive.MouseDown += delegate { this.textItem.Focus(); }; this.Children.Add(this.textBoxFillPrimitive); //this.textBoxFillPrimitive.BackColor = this.textItem.BackColor; this.dockLayout = new DockLayoutPanel(); this.dockLayout.LastChildFill = true; if (!this.RightToLeft) { DockLayoutPanel.SetDock(stackLayout, Dock.Right); } else { DockLayoutPanel.SetDock(stackLayout, Dock.Left); } DockLayoutPanel.SetDock(this.textBoxFillPrimitive, Dock.Bottom); DockLayoutPanel.SetDock(this.textItem, Dock.Top); dockLayout.Children.Add(stackLayout); dockLayout.Children.Add(this.textItem); this.border = new BorderPrimitive(); this.border.Class = "SpinElementBorder"; this.Children.Add(border); this.Children.Add(dockLayout); this.textItem.BindProperty(TextPrimitive.TextProperty, this, TextProperty, PropertyBindingOptions.TwoWay); this.textItem.Multiline = false; this.textItem.RouteMessages = false; this.StretchVertically = false; }