public void FillContextMenuItems(ContextMenu contextMenu, SiteSetting siteSetting, object item, object inspector, object folder) { SC_MenuItems menuItems; if (item as IItem != null) { menuItems = ApplicationContext.Current.GetItemMenuItems(siteSetting, (IItem)item); } else if (item as Folder != null) { menuItems = ApplicationContext.Current.GetFolderMenuItems(siteSetting, (Folder)item); } else if (item as Task != null) { menuItems = ApplicationContext.Current.GetTaskMenuItems(siteSetting, (Task)item); } else { menuItems = ApplicationContext.Current.GetItemVersionMenuItems(siteSetting, (ItemVersion)item); } contextMenu.Items.Clear(); contextMenu.RemoveHandler(MenuItem.ClickEvent, new RoutedEventHandler(mi_Click)); contextMenu.AddHandler(MenuItem.ClickEvent, new RoutedEventHandler(mi_Click)); AddContextMenuItems(contextMenu.Items, siteSetting, item, menuItems, inspector, folder); }
public ProjectWindow() { InitializeComponent(); #if DEBUG this.AttachDevTools(); #endif UpdateTopmost(Preferences.AlwaysOnTop); Preferences.AlwaysOnTopChanged += UpdateTopmost; TrackContextMenu = (ContextMenu)this.Resources["TrackContextMenu"]; TrackContextMenu.AddHandler(MenuItem.ClickEvent, TrackContextMenu_Click); this.AddHandler(DragDrop.DropEvent, Drop); this.AddHandler(DragDrop.DragOverEvent, DragOver); for (int i = 0; i < Program.Project.Count; i++) { Contents_Insert(i, Program.Project[i]); } BPM.Text = Program.Project.BPM.ToString(CultureInfo.InvariantCulture); BPM.GetObservable(TextBox.TextProperty).Subscribe(BPM_Changed); Page.RawValue = Program.Project.Page; }
private void EditFiniteAnnotationValue(TimeIntervalAnnotationDisplayData displayData, int trackId) { // Get the schema definition AnnotationSchemaDefinition schemaDefinition = displayData.Definition.SchemaDefinitions[trackId]; // Get the collection of possible values Type schemaType = schemaDefinition.Schema.GetType(); MethodInfo valuesProperty = schemaType.GetProperty("Values").GetGetMethod(); IEnumerable values = (IEnumerable)valuesProperty.Invoke(schemaDefinition.Schema, new object[] { }); // Create a new context menu ContextMenu contextMenu = new ContextMenu(); // Create a menuitem for each value, with a command to update the value on the annotation. foreach (object value in values) { var metadata = this.GetAnnotationValueMetadata(value, schemaDefinition.Schema); contextMenu.Items.Add(MenuItemHelper.CreateAnnotationMenuItem( value.ToString(), metadata.BorderColor, metadata.FillColor, new PsiCommand(() => this.StreamVisualizationObject.SetAnnotationValue(displayData.Annotation, schemaDefinition.Name, value)))); } // Add a handler so that the timeline visualization panel continues to receive mouse move messages // while the context menu is displayed, and remove the handler once the context menu closes. MouseEventHandler mouseMoveHandler = new MouseEventHandler(this.FindTimelineVisualizationPanelView().ContextMenuMouseMove); contextMenu.AddHandler(MouseMoveEvent, mouseMoveHandler, true); contextMenu.Closed += (sender, e) => contextMenu.RemoveHandler(MouseMoveEvent, mouseMoveHandler); // Show the context menu contextMenu.IsOpen = true; }
public DeviceViewer(Device device) { InitializeComponent(); TitleText.Text = device.Name; _device = device; _device.Viewer = this; Deselect(); DeviceContextMenu = (ContextMenu)this.Resources["DeviceContextMenu"]; GroupContextMenu = (ContextMenu)this.Resources["GroupContextMenu"]; DeviceContextMenu.AddHandler(MenuItem.ClickEvent, ContextMenu_Click); GroupContextMenu.AddHandler(MenuItem.ClickEvent, ContextMenu_Click); this.AddHandler(DragDrop.DropEvent, Drop); this.AddHandler(DragDrop.DragOverEvent, DragOver); SpecificViewer = GetSpecificViewer(this, _device); if (SpecificViewer != null) { this.Get <Grid>("Contents").Children.Add(SpecificViewer); } SetEnabled(); }
public ChainViewer(Chain chain, bool backgroundBorder = false) { InitializeComponent(); _chain = chain; _chain.Viewer = this; DeviceContextMenuBefore = (ContextMenu)this.Resources["DeviceContextMenuBefore"]; DeviceContextMenuBefore.AddHandler(MenuItem.ClickEvent, DeviceContextMenu_Click); DeviceContextMenuAfter = (ContextMenu)this.Resources["DeviceContextMenuAfter"]; DeviceContextMenuAfter.AddHandler(MenuItem.ClickEvent, DeviceContextMenu_Click); this.AddHandler(DragDrop.DropEvent, Drop); this.AddHandler(DragDrop.DragOverEvent, DragOver); for (int i = 0; i < _chain.Count; i++) { Contents_Insert(i, _chain[i]); } if (backgroundBorder) { this.Get <Grid>("Root").Children.Insert(0, new DeviceBackground()); Background = (IBrush)Application.Current.Styles.FindResource("ThemeControlDarkenBrush"); } }
public TrackAdd() { InitializeComponent(); AllowRightClick = true; base.MouseLeave(this, null); ActionContextMenu = (ContextMenu)this.Resources["ActionContextMenu"]; ActionContextMenu.AddHandler(MenuItem.ClickEvent, ActionContextMenu_Click); }
public RecentProjectInfo(string path) { InitializeComponent(); _path = path; Filename.Text = Path.GetFileNameWithoutExtension(_path); Folder.Text = $"({Path.GetFileName(Path.GetDirectoryName(_path))})"; InfoContextMenu = (ContextMenu)this.Resources["InfoContextMenu"]; InfoContextMenu.AddHandler(MenuItem.ClickEvent, ContextMenu_Click); }
private void OnGuiModeChanged(DependencyPropertyChangedEventArgs e) { if (UiModeChanges == null) { return; } if (e.NewValue == null) { return; } var guiMode = (UiMode)e.NewValue; Checked += (_, __) => { if (ContextMenu != null) { ContextMenu.AddHandler(MenuItem.ClickEvent, (RoutedEventHandler)OnMenuItemClick); ContextMenu.Closed += OnContextMenuClosed; ContextMenu.PlacementTarget = this; ContextMenu.IsOpen = true; } else { UiModeChanges.EnterMode(guiMode, SubGuiMode); } }; Unchecked += (_, __) => { UiModeChanges.ExitMode(guiMode); }; Loaded += (_, __) => { UiModeChanges.CanEnterModeChanged += (___, ea) => { if (ea.Mode == guiMode) { IsEnabled = ea.CanEnter; } }; UiModeChanges.ModeChanged += (___, ea) => { IsChecked = ea.NewMode == guiMode; }; IsEnabled = UiModeChanges.CanEnterMode(guiMode, null); }; }
public DeviceAdd() { InitializeComponent(); AllowRightClick = true; base.MouseLeave(this, null); AddContextMenu = (ContextMenu)this.Resources["AddContextMenu"]; AddContextMenu.AddHandler(MenuItem.ClickEvent, AddContextMenu_Click); DeviceContextMenu = (ContextMenu)this.Resources["DeviceContextMenu"]; DeviceContextMenu.AddHandler(MenuItem.ClickEvent, DeviceContextMenu_Click); }
private void Init() { this.Title = "Popup Context Menu"; menu = new ContextMenu(); itemBold = new MenuItem(); itemBold.Header = "Bold"; menu.Items.Add(itemBold); itemItalic = new MenuItem(); itemItalic.Header = "Italic"; menu.Items.Add(itemItalic); TextDecorationLocation[] locs = (TextDecorationLocation[])Enum.GetValues(typeof(TextDecorationLocation)); //枚举文本装饰器的位置 itemDecor = new MenuItem[locs.Length]; for (int i = 0; i < locs.Length; i++) { //创建文本装饰器 TextDecoration decor = new TextDecoration(); decor.Location = locs[i]; //设置文本装饰器的垂直位置 itemDecor[i] = new MenuItem(); itemDecor[i].Header = locs[i].ToString(); itemDecor[i].Tag = decor; menu.Items.Add(itemDecor[i]); } //为所有菜单指定同一个Click处理函数 menu.AddHandler(MenuItem.ClickEvent, new RoutedEventHandler(MenuOnClick)); TextBlock text = new TextBlock(); text.FontSize = 32; text.HorizontalAlignment = HorizontalAlignment.Center; text.VerticalAlignment = VerticalAlignment.Center; this.Content = text; string strQuote = "To be, or not to be, that is the question"; string[] strWords = strQuote.Split(); foreach (string str in strWords) { Run run = new Run(str); run.TextDecorations = new TextDecorationCollection(); //为Run对象显示创建TextDecorationCollection型对象,这个collection默认是不存在的,而且TextDecorations通常是null text.Inlines.Add(run); text.Inlines.Add(" "); } }
public FrameDisplay(Frame frame, Pattern pattern) { InitializeComponent(); _pattern = pattern; Viewer.Frame = frame; FrameContextMenu = (ContextMenu)this.Resources["FrameContextMenu"]; FrameContextMenu.AddHandler(MenuItem.ClickEvent, ContextMenu_Click); this.AddHandler(DragDrop.DragOverEvent, DragOver); this.AddHandler(DragDrop.DropEvent, Drop); }
public PopupContextMenu() { Title = "Popup Context Menu"; menu = new ContextMenu(); itemBold = new MenuItem(); itemBold.Header = "Bold"; menu.Items.Add(itemBold); itemItalic = new MenuItem(); itemItalic.Header = "Italic"; menu.Items.Add(itemItalic); TextDecorationLocation[] locs = (TextDecorationLocation[])Enum.GetValues(typeof(TextDecorationLocation)); itemDecor = new MenuItem[locs.Length]; for (int i = 0; i < locs.Length; i++) { TextDecoration decor = new TextDecoration(); decor.Location = locs[i]; itemDecor[i] = new MenuItem(); itemDecor[i].Header = locs[i].ToString(); itemDecor[i].Tag = decor; menu.Items.Add(itemDecor[i]); } menu.AddHandler(MenuItem.ClickEvent, new RoutedEventHandler(MenuOnClick)); TextBlock text = new TextBlock(); text.FontSize = 32; text.HorizontalAlignment = HorizontalAlignment.Center; text.VerticalAlignment = VerticalAlignment.Center; Content = text; string strQuote = "To be, or not to be, that is the question"; string[] strWords = strQuote.Split(); foreach (string str in strWords) { Run run = new Run(str); run.TextDecorations = new TextDecorationCollection(); text.Inlines.Add(run); text.Inlines.Add(" "); } }
public ProjectWindow() { InitializeComponent(); #if DEBUG this.AttachDevTools(); #endif UpdateTopmost(Preferences.AlwaysOnTop); Preferences.AlwaysOnTopChanged += UpdateTopmost; TrackContextMenu = (ContextMenu)this.Resources["TrackContextMenu"]; TrackContextMenu.AddHandler(MenuItem.ClickEvent, TrackContextMenu_Click); this.AddHandler(DragDrop.DropEvent, Drop); this.AddHandler(DragDrop.DragOverEvent, DragOver); for (int i = 0; i < Program.Project.Count; i++) { Contents_Insert(i, Program.Project[i]); } BPM.Text = Program.Project.BPM.ToString(); BPM.GetObservable(TextBox.TextProperty).Subscribe(BPM_Changed); Page.RawValue = Program.Project.Page; Author.Text = Program.Project.Author.ToString(); Author.GetObservable(TextBox.TextProperty).Subscribe(Author_Changed); UpdateTime(null, EventArgs.Empty); Timer = new DispatcherTimer() { Interval = new TimeSpan(0, 0, 1) }; Timer.Tick += UpdateTime; Timer.Start(); Started.Text = $"Started {Program.Project.Started.LocalDateTime.ToString("MM/dd/yyyy HH:mm")}"; this.GetObservable(Visual.BoundsProperty).Subscribe(Bounds_Updated); TitleText.GetObservable(Visual.BoundsProperty).Subscribe(Bounds_Updated); TitleCenter.GetObservable(Visual.BoundsProperty).Subscribe(Bounds_Updated); CenteringLeft.GetObservable(Visual.BoundsProperty).Subscribe(Bounds_Updated); CenteringRight.GetObservable(Visual.BoundsProperty).Subscribe(Bounds_Updated); }
/// <summary> /// Creates the drag canvas context menu /// </summary> private void createDragCanvasMenu() { cmSelectionCanvas.RemoveHandler(MenuItem.ClickEvent, cmSelectionCanvasRoutedEventHandler); selectCanvForImg.ContextMenu = null; cmSelectionCanvas = null; cmDragCanvas = new ContextMenu(); MenuItem miCancel = new MenuItem(); miCancel.Header = "Cancel"; MenuItem miSave = new MenuItem(); miSave.Header = "Save"; cmDragCanvas.Items.Add(miCancel); cmDragCanvas.Items.Add(miSave); cmDragCanvasRoutedEventHandler = new RoutedEventHandler(MenuDragCanvasOnClick); cmDragCanvas.AddHandler(MenuItem.ClickEvent, cmDragCanvasRoutedEventHandler); dragCanvasForImg.ContextMenu = cmDragCanvas; }
public PopupContextMenu() { Title = "Popup Context Menu"; menu = new ContextMenu(); // Создание контекстного меню // Add an item for "Bold". itemBold = new MenuItem(); // Создание элемента меню itemBold.Header = "Bold"; menu.Items.Add(itemBold); // Добавление элемента в меню // Add an item for "Italic". itemItalic = new MenuItem(); itemItalic.Header = "Italic"; menu.Items.Add(itemItalic); TextDecorationLocation[] locs = (TextDecorationLocation[])Enum.GetValues(typeof(TextDecorationLocation)); // Получение всех доступных визульных украшений текста itemDecor = new MenuItem[locs.Length]; // Создание массива элементов меню for (int i = 0; i < locs.Length; i++) { TextDecoration decor = new TextDecoration(); // Новое визуальное украшение decor.Location = locs[i]; // Расположение украшения на тексте itemDecor[i] = new MenuItem(); itemDecor[i].Header = locs[i].ToString(); itemDecor[i].Tag = decor; menu.Items.Add(itemDecor[i]); } // Use one handler for the entire context menu. menu.AddHandler(MenuItem.ClickEvent, new RoutedEventHandler(MenuOnClick)); // Создание обработчика клика по меню TextBlock text = new TextBlock(); text.FontSize = 32; text.HorizontalAlignment = HorizontalAlignment.Center; text.VerticalAlignment = VerticalAlignment.Center; Content = text; string strQuote = "To be, or not to be , that is the question"; string[] strWords = strQuote.Split(); // Разбиение строки на массив слов // Make each word a Run, and add to the TextBlock. foreach (string str in strWords) { Run run = new Run(str); // Создание объекта типа Run содержащего одно слово из строки run.TextDecorations = new TextDecorationCollection(); // Создание визуальных украшений для объекта text.Inlines.Add(run); // Добавление объекта в текстовый блок text.Inlines.Add(" "); } }
public ChainInfo(Chain chain) { InitializeComponent(); _chain = chain; Deselect(); UpdateText(); _chain.ParentIndexChanged += UpdateText; ChainContextMenu = (ContextMenu)this.Resources["ChainContextMenu"]; ChainContextMenu.AddHandler(MenuItem.ClickEvent, ContextMenu_Click); this.AddHandler(DragDrop.DropEvent, Drop); this.AddHandler(DragDrop.DragOverEvent, DragOver); Input.GetObservable(TextBox.TextProperty).Subscribe(Input_Changed); SetEnabled(); }
/// <summary> /// Creates the selection canvas context menu /// </summary> private void createSelectionCanvasMenu() { _cmSelectionCanvas = new ContextMenu(); // NOTE: Youngjae (2017-08-11 17:32:19): crop zoomed image gives bad image result. So remove this function. //MenuItem miZoom25 = new MenuItem(); //miZoom25.Header = "Zoom 25%"; //miZoom25.Tag = "0.25"; //MenuItem miZoom50 = new MenuItem(); //miZoom50.Header = "Zoom 50%"; //miZoom50.Tag = "0.5"; MenuItem miZoom100 = new MenuItem(); miZoom100.Header = "Zoom 100%"; miZoom100.Tag = "1.0"; //cmSelectionCanvas.Items.Add(miZoom25); //cmSelectionCanvas.Items.Add(miZoom50); _cmSelectionCanvas.Items.Add(miZoom100); _cmSelectionCanvasRoutedEventHandler = new RoutedEventHandler(MenuSelectionCanvasOnClick); _cmSelectionCanvas.AddHandler(MenuItem.ClickEvent, _cmSelectionCanvasRoutedEventHandler); _selectCanvForImg.ContextMenu = _cmSelectionCanvas; }
/// <summary> /// Creates the selection canvas context menu /// </summary> private void createSelectionCanvasMenu() { cmSelectionCanvas = new ContextMenu(); MenuItem miZoom25 = new MenuItem(); miZoom25.Header = "Zoom 25%"; miZoom25.Tag = "0.25"; MenuItem miZoom50 = new MenuItem(); miZoom50.Header = "Zoom 50%"; miZoom50.Tag = "0.5"; MenuItem miZoom100 = new MenuItem(); miZoom100.Header = "Zoom 100%"; miZoom100.Tag = "1.0"; cmSelectionCanvas.Items.Add(miZoom25); cmSelectionCanvas.Items.Add(miZoom50); cmSelectionCanvas.Items.Add(miZoom100); cmSelectionCanvasRoutedEventHandler = new RoutedEventHandler(MenuSelectionCanvasOnClick); cmSelectionCanvas.AddHandler(MenuItem.ClickEvent, cmSelectionCanvasRoutedEventHandler); selectCanvForImg.ContextMenu = cmSelectionCanvas; }
public TrackInfo(Track track) { InitializeComponent(); _track = track; UpdateText(0); _track.ParentIndexChanged += UpdateText; UpdatePorts(); MIDI.DevicesUpdated += HandlePorts; TrackContextMenu = (ContextMenu)this.Resources["TrackContextMenu"]; TrackContextMenu.AddHandler(MenuItem.ClickEvent, ContextMenu_Click); this.AddHandler(DragDrop.DropEvent, Drop); this.AddHandler(DragDrop.DragOverEvent, DragOver); Deselect(); Input.GetObservable(TextBox.TextProperty).Subscribe(Input_Changed); SetEnabled(); }
public PopupContextMenu() { Title = "Popup Context Menu"; // Create ContextMenu. menu = new ContextMenu(); // Add an item for "Bold". itemBold = new MenuItem(); itemBold.Header = "Bold"; menu.Items.Add(itemBold); // Add an item for "Italic". itemItalic = new MenuItem(); itemItalic.Header = "Italic"; menu.Items.Add(itemItalic); // Get all the TextDecorationLocation members. TextDecorationLocation[] locs = (TextDecorationLocation[]) Enum.GetValues(typeof(TextDecorationLocation)); // Create an array of MenuItem objects and fill them up. itemDecor = new MenuItem[locs.Length]; for (int i = 0; i < locs.Length; i++) { TextDecoration decor = new TextDecoration(); decor.Location = locs[i]; itemDecor[i] = new MenuItem(); itemDecor[i].Header = locs[i].ToString(); itemDecor[i].Tag = decor; menu.Items.Add(itemDecor[i]); } // Use one handler for the entire context menu. menu.AddHandler(MenuItem.ClickEvent, new RoutedEventHandler(MenuOnClick)); // Create a TextBlock as content of the window. TextBlock text = new TextBlock(); text.FontSize = 32; text.HorizontalAlignment = HorizontalAlignment.Center; text.VerticalAlignment = VerticalAlignment.Center; Content = text; // Break a famous quotation up into words. string strQuote = "To be, or not to be, that is the question"; string[] strWords = strQuote.Split(); // Make each word a Run, and add to the TextBlock. foreach (string str in strWords) { Run run = new Run(str); // Make sure that TextDecorations is an actual collection! run.TextDecorations = new TextDecorationCollection(); text.Inlines.Add(run); text.Inlines.Add(" "); } }
private StackPanel CartLayout() { StackPanel p = new StackPanel() { Background = Brushes.Beige, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Top }; TextBlock storeText = new TextBlock { Margin = new Thickness(0, -50, 0, 0), FontSize = 30, HorizontalAlignment = HorizontalAlignment.Center, Text = "Cart" }; TextBlock productListText = new TextBlock { Margin = new Thickness(40, -550, 0, 550), FontSize = 20, HorizontalAlignment = HorizontalAlignment.Left, Text = "Currencies added to cart" }; cartTotalPrice = new TextBlock { HorizontalAlignment = HorizontalAlignment.Center, Margin = new Thickness(0, -450, 0, 450), Padding = new Thickness(1), FontSize = 42, Text = "Total price: $0" }; cartBox = new ListView { FontSize = 24, Width = 250, Height = 450, BorderBrush = Brushes.Red, HorizontalAlignment = HorizontalAlignment.Left, Margin = new Thickness(30, 0, 0, 0), Padding = new Thickness(1) }; ContextMenu contextMenu = new ContextMenu(); contextMenu.Items.Add("Remove"); contextMenu.AddHandler(MenuItem.ClickEvent, new RoutedEventHandler(RemoveCartItem)); cartBox.ContextMenu = contextMenu; backToMainBtn = new Button { HorizontalAlignment = HorizontalAlignment.Right, Width = 125, Height = 50, Margin = new Thickness(0, 0, 25, 0), Padding = new Thickness(5), Content = "Back" }; backToMainBtn.Click += BackToMainBtnClick; SaveCartBtn = new Button { HorizontalAlignment = HorizontalAlignment.Left, Width = 150, Height = 40, Margin = new Thickness(220, -90, 0, 50), Padding = new Thickness(1), Content = "Save cart" }; SaveCartBtn.Click += SaveCartBtnClick; loadCartBtn = new Button { HorizontalAlignment = HorizontalAlignment.Left, Width = 150, Height = 40, Margin = new Thickness(60, -60, 0, 50), Padding = new Thickness(1), Content = "Load cart" }; loadCartBtn.Click += LoadCartBtnClick; clearCartBtn = new Button { HorizontalAlignment = HorizontalAlignment.Left, Width = 150, Height = 40, Margin = new Thickness(60, -40, 0, 25), Padding = new Thickness(1), Content = "Clear cart" }; clearCartBtn.Click += ClearCartBtnClick; checkoutBtn = new Button { HorizontalAlignment = HorizontalAlignment.Right, Width = 125, Height = 50, Margin = new Thickness(0, -135, 25, 115), Padding = new Thickness(1), Content = "Checkout" }; checkoutBtn.Click += CheckoutBtnClick; applyCouponBtn = new Button { HorizontalAlignment = HorizontalAlignment.Center, Width = 125, Height = 50, Margin = new Thickness(0, -100, 0, 100), Padding = new Thickness(1), Content = "Apply Coupon" }; applyCouponBtn.Click += ApplyCouponBtnClick; couponTextBox = new TextBox { FontSize = 14, Width = 150, HorizontalAlignment = HorizontalAlignment.Center, Margin = new Thickness(0, -20, 0, 20), Padding = new Thickness(1) }; p.Width = windowWidth; p.Height = windowHeight; p.Children.Add(backToMainBtn); p.Children.Add(storeText); p.Children.Add(cartBox); p.Children.Add(cartTotalPrice); p.Children.Add(productListText); p.Children.Add(loadCartBtn); p.Children.Add(SaveCartBtn); p.Children.Add(clearCartBtn); p.Children.Add(couponTextBox); p.Children.Add(applyCouponBtn); p.Children.Add(checkoutBtn); return(p); }
private StackPanel GetStackPanel() { StackPanel p = new StackPanel() { HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Top }; productsBox = new ListBox { HorizontalAlignment = HorizontalAlignment.Left, FontSize = 20, Width = 300, Height = 400, Margin = new Thickness(25, 100, 0, 0) }; productsBox.SelectionChanged += ProductSelected; ContextMenu productMenu = new ContextMenu(); MenuItem removeProduct = new MenuItem { Header = "Remove Product", }; removeProduct.Click += RemoveProductClick; productMenu.Items.Add(removeProduct); productsBox.ContextMenu = productMenu; couponBox = new ListBox { HorizontalAlignment = HorizontalAlignment.Right, FontSize = 20, Width = 300, Height = 400, Margin = new Thickness(600, -375, 0, 0) }; ContextMenu couponMenu = new ContextMenu(); couponMenu.Items.Add("Remove coupon"); couponMenu.AddHandler(MenuItem.ClickEvent, new RoutedEventHandler(RemoveCouponItem)); couponBox.ContextMenu = couponMenu; couponNameBox = new TextBox { HorizontalAlignment = HorizontalAlignment.Right, Width = 200, Height = 25, FontSize = 18, Margin = new Thickness(0, 0, 100, 0) }; couponNameBox.PreviewTextInput += CouponNameBoxVerifier; couponDiscountBox = new TextBox { HorizontalAlignment = HorizontalAlignment.Right, Width = 50, Height = 25, FontSize = 18, Margin = new Thickness(0, 0, 250, 0), }; couponDiscountBox.PreviewTextInput += DiscountBoxVerifier; addCouponBtn = new Button { HorizontalAlignment = HorizontalAlignment.Right, Width = 100, Height = 50, Margin = new Thickness(0, 0, 200, 0), Content = "Add Coupon" }; addCouponBtn.Click += AddCouponBtnClick; productNameBox = new TextBox { HorizontalAlignment = HorizontalAlignment.Left, Width = 200, Height = 25, FontSize = 18, Margin = new Thickness(25, -225, 0, 0), }; productDescriptionBox = new TextBox { HorizontalAlignment = HorizontalAlignment.Left, Width = 300, Height = 25, FontSize = 18, Margin = new Thickness(25, -175, 0, 0), }; productPriceBox = new TextBox { HorizontalAlignment = HorizontalAlignment.Left, Width = 100, Height = 25, FontSize = 18, Margin = new Thickness(25, -125, 0, 0), }; productImagePathBox = new TextBox { HorizontalAlignment = HorizontalAlignment.Left, Width = 200, Height = 25, FontSize = 18, Margin = new Thickness(125, -155, 0, 0), }; addImageBtn = new Button { HorizontalAlignment = HorizontalAlignment.Left, Width = 100, Height = 50, Margin = new Thickness(25, -35, 0, 0), Content = "Add Image" }; addImageBtn.Click += AddImageBtnClick; addProductBtn = new Button { HorizontalAlignment = HorizontalAlignment.Left, Width = 100, Height = 50, Margin = new Thickness(125, -50, 0, 0), Content = "Add Product" }; addProductBtn.Click += AddProductBtnClick; saveBtn = new Button { HorizontalAlignment = HorizontalAlignment.Left, Width = 100, Height = 50, Margin = new Thickness(225, -50, 0, 0), Content = "Save store" }; saveBtn.Click += SaveBtnClick; clearBtn = new Button { HorizontalAlignment = HorizontalAlignment.Left, Width = 100, Height = 50, Margin = new Thickness(325, -50, 0, 0), Content = "Clear fields" }; clearBtn.Click += ClearBtnClick; updateProductBtn = new Button { HorizontalAlignment = HorizontalAlignment.Left, Width = 100, Height = 50, Margin = new Thickness(425, -50, 0, 0), Content = "Update product" }; updateProductBtn.Click += UpdateProductBtnClick; p.Children.Add(productsBox); p.Children.Add(couponBox); p.Children.Add(couponNameBox); p.Children.Add(couponDiscountBox); p.Children.Add(addCouponBtn); p.Children.Add(productNameBox); p.Children.Add(productDescriptionBox); p.Children.Add(productPriceBox); p.Children.Add(addImageBtn); p.Children.Add(addProductBtn); p.Children.Add(saveBtn); p.Children.Add(productImagePathBox); p.Children.Add(clearBtn); p.Children.Add(updateProductBtn); return(p); }
public DynamicMenu() { _menu = new ContextMenu(); _menu.Closed += _menu_Closed; _menu.AddHandler(MenuItem.ClickEvent, new RoutedEventHandler(_menu_Click)); }
public PopupContextMenu() { Title = "Popup Context Menu"; // Создать контекстное меню. menu = new ContextMenu(); //Добавьте элемент для "Bold". itemBold = new MenuItem(); itemBold.Header = "Bold"; menu.Items.Add(itemBold); // Добавьте пункт для «Курсив». itemItalic = new MenuItem(); itemItalic.Header = "Italic"; menu.Items.Add(itemItalic); //Получить всех членов текста украшения места. TextDecorationLocation[] locs = (TextDecorationLocation[]) Enum.GetValues(typeof(TextDecorationLocation)); // Create an array of MenuItem objects and fill them up. itemDecor = new MenuItem[locs.Length]; for (int i = 0; i < locs.Length; i++) { TextDecoration decor = new TextDecoration(); decor.Location = locs[i]; itemDecor[i] = new MenuItem(); itemDecor[i].Header = locs[i].ToString(); itemDecor[i].Tag = decor; menu.Items.Add(itemDecor[i]); } // Используйте один обработчик для всего контекстного меню. menu.AddHandler(MenuItem.ClickEvent, new RoutedEventHandler(MenuOnClick)); //Создайте TextBlock как содержимое окна. TextBlock text = new TextBlock(); text.FontSize = 32; text.HorizontalAlignment = HorizontalAlignment.Center; text.VerticalAlignment = VerticalAlignment.Center; Content = text; // Разбейте известную цитату на слова. string strQuote = "To be, or not to be, that is the question"; string[] strWords = strQuote.Split(); // Сделайте каждое слово выполненным и добавьте его в TextBlock. foreach (string str in strWords) { Run run = new Run(str); //Убедитесь, что TextDecorations является актуальной коллекцией! run.TextDecorations = new TextDecorationCollection(); text.Inlines.Add(run); text.Inlines.Add(" "); } }