public void AddCommand(I_CommandManager item, bool indirect) { if (grdMain == null) { grdMain = new Grid(); grdOther = new Grid(); Toolbar.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto }); Toolbar.ColumnDefinitions.Add(new ColumnDefinition()); Toolbar.Children.Add(grdMain); Toolbar.Children.Add(grdOther); Grid.SetColumn(grdOther, 1); } //Button btnCommand = UIHelper.GenerateCommand(item); ////item.EnabledChanged += (sender, e) => item_EnabledChanged(sender, e, btnCommand); //btnCommand.Click += btnCommand_Click; //if (Toolbar.ColumnDefinitions.Count == 0) // Toolbar.ColumnDefinitions.Add(new ColumnDefinition()); if (indirect == false) { grdMain.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto }); grdMain.Children.Add((item as CommandManager).Button); Grid.SetColumn((item as CommandManager).Button, grdMain.ColumnDefinitions.Count - 1); } else { if (dropDownButton == null) { dropDownButton = new RadDropDownButton(); dropDownButton.Height = 22; dropDownButton.Width = 35; //dropDownButton.HorizontalAlignment = HorizontalAlignment.Left; dropDownButton.Margin = new System.Windows.Thickness(2); listBox = new ListBox(); dropDownButton.DropDownContent = listBox; Image img = new Image(); img.Width = 15; Uri uriSource = new Uri("../../Images/report.png", UriKind.Relative); img.Source = new BitmapImage(uriSource); dropDownButton.Content = img; var listitem = new ListBoxItem(); dropDownButton.HorizontalAlignment = HorizontalAlignment.Right; grdOther.Children.Add(dropDownButton); } //(item as CommandManager).Button.HorizontalContentAlignment = HorizontalAlignment.Left; listBox.Items.Add((item as CommandManager).Button); } if (dropDownButton != null) { //Toolbar.Items.Remove(dropDownButton); } }
/// <summary> /// When overridden in a derived class, is invoked whenever application code /// or internal processes (such as a rebuilding layout pass) call System.Windows.Controls.Control.ApplyTemplate(). /// In simplest terms, this means the method is called just before a UI element /// displays in an application. For more information, see Remarks. /// </summary> public override void OnApplyTemplate() { base.OnApplyTemplate (); _background = GetTemplateChild ( "BackgroundVisual" ) as Border; _dropDown = GetTemplateChild("PART_DropDownButton") as RadDropDownButton; _textBox = GetTemplateChild("PART_DateTimeInput") as RadWatermarkTextBox; SetBinding ( IsReadOnlyWatcherProperty, new Binding { Source = this, Path = new PropertyPath ( "IsReadOnly" ) } ); _textBox.Style = ( Style )Application.Current.Resources["EditableWatermarkTextBoxStyle"]; }
/// <summary> /// When overridden in a derived class, is invoked whenever application code /// or internal processes (such as a rebuilding layout pass) call System.Windows.Controls.Control.ApplyTemplate(). /// In simplest terms, this means the method is called just before a UI element /// displays in an application. For more information, see Remarks. /// </summary> public override void OnApplyTemplate() { base.OnApplyTemplate(); _background = GetTemplateChild("BackgroundVisual") as Border; _dropDown = GetTemplateChild("PART_DropDownButton") as RadDropDownButton; _textBox = GetTemplateChild("PART_DateTimeInput") as RadWatermarkTextBox; SetBinding(IsReadOnlyWatcherProperty, new Binding { Source = this, Path = new PropertyPath("IsReadOnly") }); _textBox.Style = ( Style )Application.Current.Resources["EditableWatermarkTextBoxStyle"]; }
private void CreateMenuItems(RadDropDownButton btn) { RadMenuItem mnuCancel = new RadMenuItem(Properties.Resources.CancelText); mnuCancel.Tag = btn.Tag; mnuCancel.Click += MnuCancel_Click; btn.Items.Add(mnuCancel); RadMenuItem mnuSave = new RadMenuItem(Properties.Resources.SaveAs); mnuSave.Tag = btn.Tag; mnuSave.Click += MnuSave_Click; btn.Items.Add(mnuSave); }
public void AddButtonMenu(ConrolPackageMenu menu) { if (dropDownButton == null) { dropDownButton = new RadDropDownButton(); dropDownButton.Height = 22; dropDownButton.Width = 60; //dropDownButton.HorizontalAlignment = HorizontalAlignment.Left; dropDownButton.Margin = new System.Windows.Thickness(2); listBox = new ListBox(); dropDownButton.DropDownContent = listBox; dropDownButton.Content = "منو"; var listitem = new ListBoxItem(); dropDownButton.HorizontalAlignment = HorizontalAlignment.Right; theGrid.ColumnDefinitions.Add(new ColumnDefinition()); Grid.SetColumn(dropDownButton, theGrid.ColumnDefinitions.Count); theGrid.Children.Add(dropDownButton); } var menuButton = new Button(); menuButton.Name = menu.Name; menuButton.Content = menu.Title; if (!string.IsNullOrEmpty(menu.Tooltip)) { ToolTipService.SetToolTip(menuButton, menu.Tooltip); } menuButton.Click += (sender, e) => MenuButton_Click(sender, e, menu); listBox.Items.Add(menuButton); //(item as CommandManager).Button.HorizontalContentAlignment = HorizontalAlignment.Left; //theGrid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(50) }); //var menuButton = new Button(); //menuButton.Name = menu.Name; //menuButton.Content = menu.Title; //menuButton.Click += (sender, e) => MenuButton_Click(sender, e, menu); //Grid.SetColumn(menuButton, theGrid.ColumnDefinitions.Count); //theGrid.Children.Add(menuButton); }
private void CreateDownloadObject(DownloadDataModel downloadDataModel) { var tbl = CreateTableLayoutPanel(downloadDataModel); RadDropDownButton btn = new RadDropDownButton(); btn.Text = downloadDataModel.Name; btn.Tag = downloadDataModel.Id; btn.Dock = DockStyle.Fill; CreateMenuItems(btn); if (downloadDataModel.Data == null) { //not downloaded yet btn.Enabled = false; tbl.Controls.Add(btn, 0, 0); tbl.Controls.Add(createWatingBar(downloadDataModel), 1, 0); } else { //downloaded data tbl.Controls.Add(btn, 0, 0); tbl.ColumnStyles.RemoveAt(1); } flowLayoutPanel1.Controls.Add(tbl); }