private void Init() { _lsAttachmentGroup = new List <CustomButton> { cbAbsolute, cbDataCoordinate, cbRelative }; _lsAnnotationGroup = new List <CustomButton> { cbText, cbCircle, cbEllipse, cbRectangle, cbSquare, cbLine, cbPolygon }; tbTitle.Text = Localizer.GetItem("introduction", "title"); ToolTipService.SetToolTip(cbAbsolute, Localizer.GetItem("Absolute", "description")); ToolTipService.SetPlacement(cbAbsolute, Windows.UI.Xaml.Controls.Primitives.PlacementMode.Bottom); ToolTipService.SetToolTip(cbRelative, Localizer.GetItem("Relative", "description")); ToolTipService.SetPlacement(cbRelative, Windows.UI.Xaml.Controls.Primitives.PlacementMode.Bottom); ToolTipService.SetToolTip(cbDataCoordinate, Localizer.GetItem("DataCoordinate", "description")); ToolTipService.SetPlacement(cbDataCoordinate, Windows.UI.Xaml.Controls.Primitives.PlacementMode.Bottom); ToolTipService.SetToolTip(cbAllowMove, Localizer.GetItem("allowMove", "description")); ToolTipService.SetPlacement(cbAllowMove, Windows.UI.Xaml.Controls.Primitives.PlacementMode.Bottom); ToolTipService.SetToolTip(cbText, Localizer.GetItem("textAnno", "description")); ToolTipService.SetPlacement(cbText, Windows.UI.Xaml.Controls.Primitives.PlacementMode.Bottom); ToolTipService.SetToolTip(cbLine, Localizer.GetItem("lineAnno", "description")); ToolTipService.SetPlacement(cbLine, Windows.UI.Xaml.Controls.Primitives.PlacementMode.Bottom); ToolTipService.SetToolTip(cbCircle, Localizer.GetItem("circleAnno", "description")); ToolTipService.SetPlacement(cbCircle, Windows.UI.Xaml.Controls.Primitives.PlacementMode.Bottom); ToolTipService.SetToolTip(cbEllipse, Localizer.GetItem("ellipseAnno", "description")); ToolTipService.SetPlacement(cbEllipse, Windows.UI.Xaml.Controls.Primitives.PlacementMode.Bottom); ToolTipService.SetToolTip(cbRectangle, Localizer.GetItem("rectAnno", "description")); ToolTipService.SetPlacement(cbRectangle, Windows.UI.Xaml.Controls.Primitives.PlacementMode.Bottom); ToolTipService.SetToolTip(cbSquare, Localizer.GetItem("squareAnno", "description")); ToolTipService.SetPlacement(cbSquare, Windows.UI.Xaml.Controls.Primitives.PlacementMode.Bottom); ToolTipService.SetToolTip(cbPolygon, Localizer.GetItem("polygonAnno", "description")); ToolTipService.SetPlacement(cbPolygon, Windows.UI.Xaml.Controls.Primitives.PlacementMode.Bottom); cbAbsolute.Tag = AnnotationAttachment.Absolute; cbRelative.Tag = AnnotationAttachment.Relative; cbDataCoordinate.Tag = AnnotationAttachment.DataCoordinate; cbAllowMove.Tag = "AllowMove"; cbText.Tag = "Text"; cbLine.Tag = "Line"; cbCircle.Tag = "Circle"; cbEllipse.Tag = "Ellipse"; cbRectangle.Tag = "Rectangle"; cbSquare.Tag = "Square"; cbPolygon.Tag = "Polygon"; txtDescription.Text = Localizer.GetItem("introduction", "description"); InitChart(); _flexChartContextMenu = new C1ContextMenu() { Background = new SolidColorBrush(Colors.DarkGray) }; C1MenuItem item = new C1MenuItem(); Windows.UI.Xaml.Controls.Image img = new Windows.UI.Xaml.Controls.Image(); string url = "ms-appx:///Resources/cross.png"; img.Source = new BitmapImage() { UriSource = new Uri(url) }; //RandomAccessStreamReference.CreateFromUri(new Uri(url)); item.Icon = new BitmapIcon() { UriSource = new Uri(url) }; item.HeaderBackground = new SolidColorBrush(Colors.DarkGray); item.Header = "Delete"; _flexChartContextMenu.Items.Add(item); _flexChartContextMenu.ItemClick += _flexChartContextMenu_ItemClick; cbAbsolute.Checked = true; cbAllowMove.Checked = true; }
private void button1_Click(object sender, System.EventArgs e) { try { // Create the command holder. This is essential for all C1Command operation C1CommandHolder ch = C1CommandHolder.CreateCommandHolder(this); // Use the pre-built image list ch.ImageList = this.imageList1; // Create and set up the Cut command C1Command cmdCut = ch.CreateCommand(); cmdCut.Text = "C&ut"; cmdCut.Shortcut = Shortcut.CtrlX; cmdCut.ImageIndex = 0; cmdCut.Click += new C1.Win.C1Command.ClickEventHandler(clickCut); cmdCut.CommandStateQuery += new C1.Win.C1Command.CommandStateQueryEventHandler(queryCut); // Create and set up the Copy command C1Command cmdCopy = ch.CreateCommand(); cmdCopy.Text = "&Copy"; cmdCopy.Shortcut = Shortcut.CtrlC; cmdCopy.ImageIndex = 1; cmdCopy.Click += new C1.Win.C1Command.ClickEventHandler(clickCopy); cmdCopy.CommandStateQuery += new C1.Win.C1Command.CommandStateQueryEventHandler(queryCopy); // Create and set up the Paste command C1Command cmdPaste = ch.CreateCommand(); cmdPaste.Text = "&Paste"; cmdPaste.Shortcut = Shortcut.CtrlV; cmdPaste.ImageIndex = 2; cmdPaste.Click += new C1.Win.C1Command.ClickEventHandler(clickPaste); cmdPaste.CommandStateQuery += new C1.Win.C1Command.CommandStateQueryEventHandler(queryPaste); // Create and set up the Undo command C1Command cmdUndo = ch.CreateCommand(); cmdUndo.Text = "&Undo"; cmdUndo.Shortcut = Shortcut.CtrlZ; cmdUndo.ImageIndex = -1; cmdUndo.Click += new C1.Win.C1Command.ClickEventHandler(clickUndo); cmdUndo.CommandStateQuery += new C1.Win.C1Command.CommandStateQueryEventHandler(queryUndo); // Create the context menu to hold other commands C1ContextMenu cm = ch.CreateCommand(typeof(C1ContextMenu)) as C1ContextMenu; // Fill it with the links to the commands cm.CommandLinks.Add(new C1CommandLink(cmdCut)); cm.CommandLinks.Add(new C1CommandLink(cmdCopy)); cm.CommandLinks.Add(new C1CommandLink(cmdPaste)); C1CommandLink cl = new C1CommandLink(cmdUndo); // This will show a delimiter before the Undo link. // Another option is to create a separate empty link with the text "-". cl.Delimiter = true; cm.CommandLinks.Add(cl); // Assign the new context menu to the text box ch.SetC1ContextMenu(textBox1, cm); } catch { // Not the best way to code, but used here to illustrate a point: // It is impossible to create more than one command holder for a form. // The 2nd attempt will fail with an exception. Here we catch and ignore // it... } }