void IMenuItemContainer.ShowContextMenu(ActionItem aitem) { ActionMenuItem menuItem = aitem as ActionMenuItem; Gtk.Menu m = new Gtk.Menu(); Gtk.MenuItem item = new Gtk.ImageMenuItem(Gtk.Stock.Cut, null); m.Add(item); item.Activated += delegate(object s, EventArgs a) { Cut(menuItem); }; item.Visible = false; // No copy & paste for now item = new Gtk.ImageMenuItem(Gtk.Stock.Copy, null); m.Add(item); item.Activated += delegate(object s, EventArgs a) { Copy(menuItem); }; item.Visible = false; // No copy & paste for now item = new Gtk.ImageMenuItem(Gtk.Stock.Paste, null); m.Add(item); item.Activated += delegate(object s, EventArgs a) { Paste(menuItem); }; item.Visible = false; // No copy & paste for now item = new Gtk.ImageMenuItem(Gtk.Stock.Delete, null); m.Add(item); item.Activated += delegate(object s, EventArgs a) { Delete(menuItem); }; m.ShowAll(); m.Popup(); }
public SearchEntry() { WidthRequest = 300; Gtk.Menu searchMenu = Menu; Gtk.RadioMenuItem searchMenuItemAll = new Gtk.RadioMenuItem("All"); Gtk.RadioMenuItem searchMenuItemAuthor = new Gtk.RadioMenuItem(searchMenuItemAll, "Author"); Gtk.RadioMenuItem searchMenuItemTitle = new Gtk.RadioMenuItem(searchMenuItemAll, "Title"); Gtk.RadioMenuItem searchMenuItemArticle = new Gtk.RadioMenuItem(searchMenuItemAll, "Article"); searchMenuItemAll.Data.Add("searchField", BibtexSearchField.All); searchMenuItemAuthor.Data.Add("searchField", BibtexSearchField.Author); searchMenuItemTitle.Data.Add("searchField", BibtexSearchField.Title); searchMenuItemArticle.Data.Add("searchField", BibtexSearchField.Article); searchMenu.Add(searchMenuItemAll); searchMenu.Add(searchMenuItemAuthor); searchMenu.Add(searchMenuItemTitle); searchMenu.Add(searchMenuItemArticle); searchMenuItemAll.Activated += OnSearchEntryChanged; searchMenuItemAuthor.Activated += OnSearchEntryChanged; searchMenuItemTitle.Activated += OnSearchEntryChanged; searchMenuItemArticle.Activated += OnSearchEntryChanged; Changed += OnSearchEntryChanged; Show(); }
public void ShowContextMenu(ActionItem aitem) { ActionToolItem menuItem = aitem as ActionToolItem; Gtk.Menu m = new Gtk.Menu(); Gtk.MenuItem item = new Gtk.MenuItem(Catalog.GetString("Insert Before")); m.Add(item); item.Activated += delegate(object s, EventArgs a) { InsertActionAt(menuItem, false, false); }; item = new Gtk.MenuItem(Catalog.GetString("Insert After")); m.Add(item); item.Activated += delegate(object s, EventArgs a) { InsertActionAt(menuItem, true, false); }; item = new Gtk.MenuItem(Catalog.GetString("Insert Separator Before")); m.Add(item); item.Activated += delegate(object s, EventArgs a) { InsertActionAt(menuItem, false, true); }; item = new Gtk.MenuItem(Catalog.GetString("Insert Separator After")); m.Add(item); item.Activated += delegate(object s, EventArgs a) { InsertActionAt(menuItem, true, true); }; m.Add(new Gtk.SeparatorMenuItem()); item = new Gtk.ImageMenuItem(Gtk.Stock.Cut, null); m.Add(item); item.Activated += delegate(object s, EventArgs a) { menuItem.Cut(); }; item = new Gtk.ImageMenuItem(Gtk.Stock.Copy, null); m.Add(item); item.Activated += delegate(object s, EventArgs a) { menuItem.Copy(); }; item = new Gtk.ImageMenuItem(Gtk.Stock.Paste, null); m.Add(item); item.Activated += delegate(object s, EventArgs a) { Paste(menuItem); }; item = new Gtk.ImageMenuItem(Gtk.Stock.Delete, null); m.Add(item); item.Activated += delegate(object s, EventArgs a) { menuItem.Delete(); }; m.ShowAll(); m.Popup(); }
public void PopulateFixes(Gtk.Menu menu) { int mnemonic = 1; foreach (var fix_ in fixes.OrderByDescending(i => GetUsage(i.IdString))) { var fix = fix_; var escapedLabel = fix.Title.Replace("_", "__"); var label = (mnemonic <= 10) ? "_" + (mnemonic++ % 10).ToString() + " " + escapedLabel : " " + escapedLabel; var menuItem = new Gtk.MenuItem(label); menuItem.Activated += new ContextActionRunner(fix, document, loc).Run; menuItem.Activated += delegate { ConfirmUsage(fix.IdString); menu.Destroy(); }; menu.Add(menuItem); } var first = true; var alreadyInserted = new HashSet <CodeIssueProvider> (); foreach (var analysisFix_ in fixes.OfType <AnalysisContextActionProvider.AnalysisCodeAction>().Where(f => f.Result is InspectorResults)) { var analysisFix = analysisFix_; var ir = analysisFix.Result as InspectorResults; if (ir == null) { continue; } if (first) { menu.Add(new Gtk.SeparatorMenuItem()); first = false; } if (alreadyInserted.Contains(ir.Inspector)) { continue; } alreadyInserted.Add(ir.Inspector); var label = GettextCatalog.GetString("_Inspection options for \"{0}\"", ir.Inspector.Title); var menuItem = new Gtk.MenuItem(label); menuItem.Activated += analysisFix.ShowOptions; menuItem.Activated += delegate { menu.Destroy(); }; menu.Add(menuItem); } }
protected override void Run(RefactoringOptions options) { Gtk.Menu menu = new Gtk.Menu(); bool resolveDirect; List <string> namespaces = GetResolveableNamespaces(options, out resolveDirect); foreach (string ns in namespaces) { // remove used namespaces for conflict resolving. if (options.Document.CompilationUnit.IsNamespaceUsedAt(ns, options.ResolveResult.ResolvedExpression.Region.Start)) { continue; } Gtk.MenuItem menuItem = new Gtk.MenuItem(string.Format(GettextCatalog.GetString("Add using '{0}'"), ns)); CurrentRefactoryOperationsHandler.ResolveNameOperation resolveNameOperation = new CurrentRefactoryOperationsHandler.ResolveNameOperation(options.Dom, options.Document, options.ResolveResult, ns); menuItem.Activated += delegate { resolveNameOperation.AddImport(); }; menu.Add(menuItem); } if (resolveDirect) { foreach (string ns in namespaces) { Gtk.MenuItem menuItem = new Gtk.MenuItem(string.Format(GettextCatalog.GetString("Add '{0}'"), ns)); CurrentRefactoryOperationsHandler.ResolveNameOperation resolveNameOperation = new CurrentRefactoryOperationsHandler.ResolveNameOperation(options.Dom, options.Document, options.ResolveResult, ns); menuItem.Activated += delegate { resolveNameOperation.ResolveName(); }; menu.Add(menuItem); } } if (menu.Children != null && menu.Children.Length > 0) { menu.ShowAll(); ICompletionWidget widget = options.Document.GetContent <ICompletionWidget> (); CodeCompletionContext codeCompletionContext = widget.CreateCodeCompletionContext(options.GetTextEditorData().Caret.Offset); menu.Popup(null, null, delegate(Gtk.Menu menu2, out int x, out int y, out bool pushIn) { x = codeCompletionContext.TriggerXCoord; y = codeCompletionContext.TriggerYCoord; pushIn = false; }, 0, Gtk.Global.CurrentEventTime); menu.SelectFirst(true); } }
void PopupQuickFixMenu(Gdk.EventButton evt) { Gtk.Menu menu = new Gtk.Menu(); Dictionary <Gtk.MenuItem, ContextAction> fixTable = new Dictionary <Gtk.MenuItem, ContextAction> (); int mnemonic = 1; foreach (ContextAction fix in fixes) { var escapedLabel = fix.GetMenuText(document, loc).Replace("_", "__"); var label = (mnemonic <= 10) ? "_" + (mnemonic++ % 10).ToString() + " " + escapedLabel : " " + escapedLabel; Gtk.MenuItem menuItem = new Gtk.MenuItem(label); fixTable [menuItem] = fix; menuItem.Activated += delegate(object sender, EventArgs e) { // ensure that the Ast is recent. document.UpdateParseDocument(); var runFix = fixTable [(Gtk.MenuItem)sender]; runFix.Run(document, loc); document.Editor.Document.CommitUpdateAll(); menu.Destroy(); }; menu.Add(menuItem); } menu.ShowAll(); menu.SelectFirst(true); menuPushed = true; menu.Destroyed += delegate { menuPushed = false; QueueDraw(); }; GtkWorkarounds.ShowContextMenu(menu, this, evt, Allocation); }
protected override void Run (RefactoringOptions options) { Gtk.Menu menu = new Gtk.Menu (); bool resolveDirect; List<string> namespaces = GetResolveableNamespaces (options, out resolveDirect); foreach (string ns in namespaces) { // remove used namespaces for conflict resolving. if (options.Document.CompilationUnit.IsNamespaceUsedAt (ns, options.ResolveResult.ResolvedExpression.Region.Start)) continue; Gtk.MenuItem menuItem = new Gtk.MenuItem (string.Format (GettextCatalog.GetString ("Add using '{0}'"), ns)); CurrentRefactoryOperationsHandler.ResolveNameOperation resolveNameOperation = new CurrentRefactoryOperationsHandler.ResolveNameOperation (options.Dom, options.Document, options.ResolveResult, ns); menuItem.Activated += delegate { resolveNameOperation.AddImport (); }; menu.Add (menuItem); } if (resolveDirect) { foreach (string ns in namespaces) { Gtk.MenuItem menuItem = new Gtk.MenuItem (string.Format (GettextCatalog.GetString ("Add '{0}'"), ns)); CurrentRefactoryOperationsHandler.ResolveNameOperation resolveNameOperation = new CurrentRefactoryOperationsHandler.ResolveNameOperation (options.Dom, options.Document, options.ResolveResult, ns); menuItem.Activated += delegate { resolveNameOperation.ResolveName (); }; menu.Add (menuItem); } } if (menu.Children != null && menu.Children.Length > 0) { menu.ShowAll (); ICompletionWidget widget = options.Document.GetContent<ICompletionWidget> (); CodeCompletionContext codeCompletionContext = widget.CreateCodeCompletionContext (options.GetTextEditorData ().Caret.Offset); menu.Popup (null, null, delegate (Gtk.Menu menu2, out int x, out int y, out bool pushIn) { x = codeCompletionContext.TriggerXCoord; y = codeCompletionContext.TriggerYCoord; pushIn = false; }, 0, Gtk.Global.CurrentEventTime); menu.SelectFirst (true); } }
// HERZUM SPRINT 2.3 TLAB-56 TLAB-57 TLAB-58 TLAB-59 /* * private void PopupContextMenu(IPrimaryToolDelegator mainTool, IDrawingEditor editor, ITool dt, MouseEvent ev) * { * m_contextMenu = new Gtk.Menu(); * Gtk.MenuItem editLabel = new Gtk.MenuItem("Edit label"); * * editLabel.Activated += delegate(object sender, EventArgs e) * { * SimpleTextTool textTool = new SimpleTextTool(editor, this, dt, ev); * mainTool.DelegateTool = textTool; * textTool.StartEditing(); * }; * * m_contextMenu.Add(editLabel); * m_contextMenu.ShowAll(); * * m_contextMenu.Popup(); * } */ private void PopupContextMenu(IPrimaryToolDelegator mainTool, IDrawingEditor editor, ITool dt, MouseEvent ev) { m_contextMenu = new Gtk.Menu(); Gtk.MenuItem editLabel = new Gtk.MenuItem("Edit label"); Gtk.MenuItem copy = new Gtk.MenuItem("Copy"); Gtk.MenuItem cut = new Gtk.MenuItem("Cut"); // Gtk.MenuItem paste = new Gtk.MenuItem("Paste"); editLabel.Activated += delegate(object sender, EventArgs e) { SimpleTextTool textTool = new SimpleTextTool(editor, this, dt, ev); mainTool.DelegateTool = textTool; textTool.StartEditing(); }; copy.Activated += delegate(object sender, EventArgs e) { Clipboard.Copy(ExperimentNode.Owner as BaseExperiment); }; cut.Activated += delegate(object sender, EventArgs e) { Clipboard.Cut(ExperimentNode.Owner as BaseExperiment); }; /* * paste.Activated += delegate(object sender, EventArgs e) * { * Clipboard.Paste(ExperimentNode.Owner as BaseExperiment); * ExperimentCanvasPad ecp = ExperimentCanvasPadFactory.GetExperimentCanvasPad(m_applicationContext, this); * ecp.DisplayAddedSubgraph(ExperimentNode.Owner as BaseExperiment); * }; */ m_contextMenu.Add(editLabel); m_contextMenu.Add(copy); m_contextMenu.Add(cut); // m_contextMenu.Add(paste); m_contextMenu.ShowAll(); m_contextMenu.Popup(); }
private void OnStatusIconPopupMenu(object sender, EventArgs e) { Trace.Call(sender, e); Gtk.Menu menu = new Gtk.Menu(); Gtk.ImageMenuItem preferencesItem = new Gtk.ImageMenuItem( Gtk.Stock.Preferences, null ); preferencesItem.Activated += delegate { try { var builder = new Gtk.Builder(null, "PreferencesDialog2.ui", null); var widget = (Gtk.Widget)builder.GetObject("PreferencesDialog"); var dialog = new PreferencesDialog(f_MainWindow, builder, widget.Handle); dialog.Show(); } catch (Exception ex) { Frontend.ShowException(ex); } }; menu.Add(preferencesItem); menu.Add(new Gtk.SeparatorMenuItem()); Gtk.ImageMenuItem quitItem = new Gtk.ImageMenuItem( Gtk.Stock.Quit, null ); quitItem.Activated += delegate { try { Frontend.Quit(); } catch (Exception ex) { Frontend.ShowException(ex); } }; menu.Add(quitItem); menu.ShowAll(); menu.Popup(); }
private void OnStatusIconPopupMenu(object sender, EventArgs e) { Trace.Call(sender, e); Gtk.Menu menu = new Gtk.Menu(); Gtk.ImageMenuItem preferencesItem = new Gtk.ImageMenuItem( Gtk.Stock.Preferences, null ); preferencesItem.Activated += delegate { try { PreferencesDialog dialog = new PreferencesDialog(f_MainWindow); dialog.CurrentPage = PreferencesDialog.Page.Interface; dialog.CurrentInterfacePage = PreferencesDialog.InterfacePage.Notification; } catch (Exception ex) { Frontend.ShowException(ex); } }; menu.Add(preferencesItem); menu.Add(new Gtk.SeparatorMenuItem()); Gtk.ImageMenuItem quitItem = new Gtk.ImageMenuItem( Gtk.Stock.Quit, null ); quitItem.Activated += delegate { try { Frontend.Quit(); } catch (Exception ex) { Frontend.ShowException(ex); } }; menu.Add(quitItem); menu.ShowAll(); menu.Popup(); }
public void PopupQuickFixMenu() { Gtk.Menu menu = new Gtk.Menu(); Dictionary <Gtk.MenuItem, ContextAction> fixTable = new Dictionary <Gtk.MenuItem, ContextAction> (); int mnemonic = 1; foreach (ContextAction fix in fixes) { var escapedLabel = fix.GetMenuText(document, loc).Replace("_", "__"); var label = (mnemonic <= 10) ? "_" + (mnemonic++ % 10).ToString() + " " + escapedLabel : " " + escapedLabel; Gtk.MenuItem menuItem = new Gtk.MenuItem(label); fixTable [menuItem] = fix; menuItem.Activated += delegate(object sender, EventArgs e) { // ensure that the Ast is recent. document.UpdateParseDocument(); var runFix = fixTable [(Gtk.MenuItem)sender]; runFix.Run(document, loc); document.Editor.Document.CommitUpdateAll(); menu.Destroy(); }; menu.Add(menuItem); } menu.ShowAll(); int dx, dy; this.ParentWindow.GetOrigin(out dx, out dy); dx += ((TextEditorContainer.EditorContainerChild)(this.document.Editor.Parent.Parent as TextEditorContainer) [this]).X; dy += ((TextEditorContainer.EditorContainerChild)(this.document.Editor.Parent.Parent as TextEditorContainer) [this]).Y - (int)document.Editor.VAdjustment.Value; menu.Popup(null, null, delegate(Gtk.Menu menu2, out int x, out int y, out bool pushIn) { x = dx; y = dy + Allocation.Height; pushIn = false; menuPushed = true; QueueDraw(); }, 0, Gtk.Global.CurrentEventTime); menu.SelectFirst(true); menu.Destroyed += delegate { menuPushed = false; QueueDraw(); }; }
private void PopupContextMenu(IPrimaryToolDelegator mainTool, IDrawingEditor editor, ITool dt, MouseEvent ev) { m_contextMenu = new Gtk.Menu(); Gtk.MenuItem editLabel = new Gtk.MenuItem("Edit label"); editLabel.Activated += delegate(object sender, EventArgs e) { SimpleTextTool textTool = new SimpleTextTool(editor, this, dt, ev); mainTool.DelegateTool = textTool; textTool.StartEditing(); }; m_contextMenu.Add(editLabel); m_contextMenu.ShowAll(); m_contextMenu.Popup(); }
protected void OnRight(object sender, Gtk.ButtonPressEventArgs e) { if (e.Event.Button == 3) // Botón derecho. { Gtk.TreePath RowPath; if (Exercises.GetPathAtPos(Convert.ToInt32(e.Event.X), Convert.ToInt32(e.Event.Y), out RowPath)) { int ActiveRow = RowPath.Indices[0]; Gtk.Menu m = new Gtk.Menu(); Gtk.MenuItem DeleteExercise = new Gtk.MenuItem("Delete exercise"); DeleteExercise.ButtonPressEvent += (o, a) => OnDelete(ActiveRow); m.Add(DeleteExercise); m.ShowAll(); m.Popup(); } } }
public void Step1_SetWidget(Gtk.Widget widget) { // Add right-click context menu to control. var menu = new Gtk.Menu(); var resetMenuItem = new Gtk.MenuItem("Reset Camera Offset"); resetMenuItem.Activated += delegate(object sender, EventArgs e) { SetCameraOffset(0, 0); }; menu.Add(resetMenuItem); // Handle mouse move events. widget.MotionNotifyEvent += delegate(object o, Gtk.MotionNotifyEventArgs args) { if (!m_enabled) return; if (!m_mouseDown) return; double x = args.Event.X; double y = args.Event.Y; double dx = x - m_mouseDownX; double dy = y - m_mouseDownY; SetCameraOffset(m_offsetDownX + dx, m_offsetDownY + dy); }; widget.ButtonPressEvent += delegate(object o, Gtk.ButtonPressEventArgs args) { if (m_enablePopupMenu && (args.Event.Button & 2) == 2) { menu.ShowAll(); menu.Popup(); return; } m_mouseDown = true; m_mouseDownX = args.Event.X; m_mouseDownY = args.Event.Y; m_offsetDownX = m_offsetX; m_offsetDownY = m_offsetY; }; widget.ButtonReleaseEvent += delegate(object o, Gtk.ButtonReleaseEventArgs args) { m_mouseDown = false; }; }
protected virtual void Populate(Gtk.Menu menu) { foreach (var w in menu.Children.ToArray()) { menu.Remove(w); } foreach (var child in Children) { var wGtk = child.ToGtk() as Gtk.Widget; var image = wGtk; var ti = wGtk as Gtk.ToolItem; if (ti != null && ti.Child is Gtk.EventBox) { ((Gtk.EventBox)ti.Child).VisibleWindow = false; } var but = wGtk as Gtk.ToolButton; if (but != null) { image = but.IconWidget; } var item = new Gtk.ImageMenuItem("") { Image = image, TooltipText = wGtk.TooltipText }; item.Show(); menu.Add(item); var b = child as IGtkToolbarItemBackend; if (b != null) { item.ButtonPressEvent += (s, e) => b.Click(s, e); } item.ModifyBg(Gtk.StateType.Prelight, Notifycolor); } }
private static void OnStatusIconPopupMenu(object sender, EventArgs e) { Trace.Call(sender, e); Gtk.Menu menu = new Gtk.Menu(); Gtk.ImageMenuItem preferencesItem = new Gtk.ImageMenuItem(Gtk.Stock.Preferences, null); preferencesItem.Activated += delegate { try { PreferencesDialog dialog = new PreferencesDialog(_MainWindow); dialog.CurrentPage = PreferencesDialog.Page.Interface; dialog.CurrentInterfacePage = PreferencesDialog.InterfacePage.Notification; } catch (Exception ex) { ShowException(ex); } }; menu.Add(preferencesItem); menu.Add(new Gtk.SeparatorMenuItem()); Gtk.ImageMenuItem quitItem = new Gtk.ImageMenuItem(Gtk.Stock.Quit, null); quitItem.Activated += delegate { try { Quit(); } catch (Exception ex) { ShowException(ex); } }; menu.Add(quitItem); menu.ShowAll(); menu.Popup(); }
void PopupQuickFixMenu(Gdk.EventButton evt) { var menu = new Gtk.Menu(); Gtk.Menu fixMenu = menu; ResolveResult resolveResult; ICSharpCode.NRefactory.CSharp.AstNode node; if (ResolveCommandHandler.ResolveAt(document, out resolveResult, out node)) { var possibleNamespaces = MonoDevelop.Refactoring.ResolveCommandHandler.GetPossibleNamespaces( document, node, resolveResult ); bool addUsing = !(resolveResult is AmbiguousTypeResolveResult); if (addUsing) { foreach (string ns_ in possibleNamespaces) { string ns = ns_; var menuItem = new Gtk.MenuItem(string.Format("using {0};", ns)); menuItem.Activated += delegate { new MonoDevelop.Refactoring.ResolveCommandHandler.AddImport(document, resolveResult, ns, true, node).Run(); menu.Destroy(); }; menu.Add(menuItem); } } bool resolveDirect = !(resolveResult is UnknownMemberResolveResult); if (resolveDirect) { foreach (string ns in possibleNamespaces) { var menuItem = new Gtk.MenuItem(GettextCatalog.GetString("{0}", ns + "." + document.Editor.GetTextBetween(node.StartLocation, node.EndLocation))); menuItem.Activated += delegate { new MonoDevelop.Refactoring.ResolveCommandHandler.AddImport(document, resolveResult, ns, false, node).Run(); menu.Destroy(); }; menu.Add(menuItem); } } if (menu.Children.Any() && fixes.Any()) { fixMenu = new Gtk.Menu(); var menuItem = new Gtk.MenuItem(GettextCatalog.GetString("Quick Fixes")); menuItem.Submenu = fixMenu; menu.Add(menuItem); } } PopulateFixes(fixMenu); menu.ShowAll(); menu.SelectFirst(true); menuPushed = true; menu.Destroyed += delegate { menuPushed = false; Hide(); }; var container = (TextEditorContainer)document.Editor.Parent.Parent; var child = (TextEditorContainer.EditorContainerChild)container [this]; GtkWorkarounds.ShowContextMenu(menu, document.Editor.Parent, null, new Gdk.Rectangle(child.X, child.Y + Allocation.Height - (int)document.Editor.VAdjustment.Value, 0, 0)); }
private void ConstructMenuHelp() { Debug.WriteLine("ConstructMenuHelp"); ConstructImageMenuItemHelpAbout(); menuHelp = new Gtk.Menu { Name = "menuHelp", Visible = true, }; menuHelp.Add(imageMenuItemHelpAbout); }
// HERZUM SPRINT 2.3 TLAB-56 TLAB-57 TLAB-58 TLAB-59 /* private void PopupContextMenu(IPrimaryToolDelegator mainTool, IDrawingEditor editor, ITool dt, MouseEvent ev) { m_contextMenu = new Gtk.Menu(); Gtk.MenuItem editLabel = new Gtk.MenuItem("Edit label"); editLabel.Activated += delegate(object sender, EventArgs e) { SimpleTextTool textTool = new SimpleTextTool(editor, this, dt, ev); mainTool.DelegateTool = textTool; textTool.StartEditing(); }; m_contextMenu.Add(editLabel); m_contextMenu.ShowAll(); m_contextMenu.Popup(); } */ private void PopupContextMenu(IPrimaryToolDelegator mainTool, IDrawingEditor editor, ITool dt, MouseEvent ev) { m_contextMenu = new Gtk.Menu(); Gtk.MenuItem editLabel = new Gtk.MenuItem("Edit label"); Gtk.MenuItem copy = new Gtk.MenuItem("Copy"); Gtk.MenuItem cut = new Gtk.MenuItem("Cut"); // Gtk.MenuItem paste = new Gtk.MenuItem("Paste"); editLabel.Activated += delegate(object sender, EventArgs e) { SimpleTextTool textTool = new SimpleTextTool(editor, this, dt, ev); mainTool.DelegateTool = textTool; textTool.StartEditing(); }; copy.Activated += delegate(object sender, EventArgs e) { Clipboard.Copy(ExperimentNode.Owner as BaseExperiment); }; cut.Activated += delegate(object sender, EventArgs e) { Clipboard.Cut(ExperimentNode.Owner as BaseExperiment); }; /* paste.Activated += delegate(object sender, EventArgs e) { Clipboard.Paste(ExperimentNode.Owner as BaseExperiment); ExperimentCanvasPad ecp = ExperimentCanvasPadFactory.GetExperimentCanvasPad(m_applicationContext, this); ecp.DisplayAddedSubgraph(ExperimentNode.Owner as BaseExperiment); }; */ m_contextMenu.Add(editLabel); m_contextMenu.Add(copy); m_contextMenu.Add(cut); // m_contextMenu.Add(paste); m_contextMenu.ShowAll(); m_contextMenu.Popup(); }
private void ConfigureDlg() { notebook1.CurrentPage = 0; notebook1.ShowTabs = false; buttonDeleteResponsiblePerson.Sensitive = false; ytreeviewResponsiblePersons.ColumnsConfig = FluentColumnsConfig <Contact> .Create() .AddColumn("Ответственные лица").AddTextRenderer(x => x.FullName) .AddColumn("Телефоны").AddTextRenderer(x => String.Join("\n", x.Phones)) .Finish(); ytreeviewResponsiblePersons.Selection.Mode = Gtk.SelectionMode.Multiple; ytreeviewResponsiblePersons.ItemsDataSource = Entity.ObservableContacts; ytreeviewResponsiblePersons.Selection.Changed += YtreeviewResponsiblePersons_Selection_Changed; textComment.Binding.AddBinding(Entity, e => e.Comment, w => w.Buffer.Text).InitializeFromSource(); labelCompiledAddress.Binding.AddBinding(Entity, e => e.CompiledAddress, w => w.LabelProp).InitializeFromSource(); checkIsActive.Binding.AddBinding(Entity, e => e.IsActive, w => w.Active).InitializeFromSource(); ylabelDistrictOfCity.Binding.AddFuncBinding(Entity, entity => entity.StreetDistrict != null ? entity.StreetDistrict.Replace(",", "\n") : null, widget => widget.LabelProp) .InitializeFromSource(); yentryAddition.Binding.AddBinding(Entity, e => e.АddressAddition, w => w.Text).InitializeFromSource(); ylabelFoundOnOsm.Binding.AddFuncBinding(Entity, entity => entity.СoordinatesExist ? String.Format("<span foreground='{1}'>{0}</span>", entity.СoordinatesText, (entity.FoundOnOsm ? "green" : "blue")) : "<span foreground='red'>Не найден на карте.</span>", widget => widget.LabelProp) .InitializeFromSource(); ycheckOsmFixed.Binding.AddBinding(Entity, e => e.IsFixedInOsm, w => w.Active).InitializeFromSource(); ycheckOsmFixed.Visible = QSMain.User.Admin; entryCity.CitySelected += (sender, e) => { entryStreet.CityId = entryCity.OsmId; entryStreet.Street = string.Empty; entryStreet.StreetDistrict = string.Empty; }; entryStreet.StreetSelected += (sender, e) => { entryBuilding.Street = new OsmStreet(-1, entryStreet.CityId, entryStreet.Street, entryStreet.StreetDistrict); }; entryBuilding.CompletionLoaded += EntryBuilding_Changed; entryBuilding.Changed += EntryBuilding_Changed; entryCity.Binding .AddSource(Entity) .AddBinding(entity => entity.CityDistrict, widget => widget.CityDistrict) .AddBinding(entity => entity.City, widget => widget.City) .AddBinding(entity => entity.LocalityType, widget => widget.Locality) .InitializeFromSource(); entryStreet.Binding .AddSource(Entity) .AddBinding(entity => entity.StreetDistrict, widget => widget.StreetDistrict) .AddBinding(entity => entity.Street, widget => widget.Street) .InitializeFromSource(); entryBuilding.Binding .AddSource(Entity) .AddBinding(entity => entity.Building, widget => widget.House) .InitializeFromSource(); yentryLitter.Binding.AddBinding(Entity, e => e.Letter, w => w.Text).InitializeFromSource(); //make actions menu var menu = new Gtk.Menu(); var menuItem = new Gtk.MenuItem("Открыть контрагента"); menuItem.Activated += OpenCounterparty; menu.Add(menuItem); menuActions.Menu = menu; menu.ShowAll(); //Configure map MapWidget = new GMap.NET.GtkSharp.GMapControl(); MapWidget.MapProvider = GMapProviders.YandexMap; MapWidget.Position = new PointLatLng(59.93900, 30.31646); MapWidget.MinZoom = 0; MapWidget.MaxZoom = 24; MapWidget.Zoom = 9; MapWidget.WidthRequest = 450; MapWidget.HasFrame = true; MapWidget.Overlays.Add(addressOverlay); MapWidget.ButtonPressEvent += MapWidget_ButtonPressEvent; MapWidget.ButtonReleaseEvent += MapWidget_ButtonReleaseEvent; MapWidget.MotionNotifyEvent += MapWidget_MotionNotifyEvent; rightsidepanel1.Panel = MapWidget; rightsidepanel1.PanelOpened += Rightsidepanel1_PanelOpened; rightsidepanel1.PanelHided += Rightsidepanel1_PanelHided; Entity.PropertyChanged += Entity_PropertyChanged; UpdateAddressOnMap(); }
void PopupQuickFixMenu (Gdk.EventButton evt) { var menu = new Gtk.Menu (); var caretOffset = document.Editor.Caret.Offset; Gtk.Menu fixMenu = menu; DomRegion region; var resolveResult = document.GetLanguageItem (caretOffset, out region); if (resolveResult != null) { var possibleNamespaces = MonoDevelop.Refactoring.ResolveCommandHandler.GetPossibleNamespaces (document, resolveResult); bool addUsing = !(resolveResult is AmbiguousTypeResolveResult); if (addUsing) { foreach (string ns_ in possibleNamespaces) { string ns = ns_; var menuItem = new Gtk.MenuItem (GettextCatalog.GetString ("Import Namespace {0}", ns)); menuItem.Activated += delegate { new MonoDevelop.Refactoring.ResolveCommandHandler.AddImport (document, resolveResult, ns, true).Run (); }; menu.Add (menuItem); } } bool resolveDirect = !(resolveResult is UnknownMemberResolveResult); if (resolveDirect) { foreach (string ns in possibleNamespaces) { var menuItem = new Gtk.MenuItem (GettextCatalog.GetString ("Use {0}", ns + "." + document.Editor.GetTextBetween (region.Begin, region.End))); menuItem.Activated += delegate { new MonoDevelop.Refactoring.ResolveCommandHandler.AddImport (document, resolveResult, ns, false).Run (); }; menu.Add (menuItem); } } if (menu.Children.Any () && fixes.Any ()) { fixMenu = new Gtk.Menu (); var menuItem = new Gtk.MenuItem (GettextCatalog.GetString ("Quick Fixes")); menuItem.Submenu = fixMenu; menu.Add (menuItem); } } PopulateFixes (fixMenu); menu.ShowAll (); menu.SelectFirst (true); menuPushed = true; menu.Destroyed += delegate { menuPushed = false; }; var container = (TextEditorContainer)document.Editor.Parent.Parent; var child = (TextEditorContainer.EditorContainerChild)container [this]; GtkWorkarounds.ShowContextMenu (menu, document.Editor.Parent, null, new Gdk.Rectangle (child.X, child.Y + Allocation.Height - (int)document.Editor.VAdjustment.Value, 0, 0)); }
public void PopulateFixes (Gtk.Menu menu, ref int items) { int mnemonic = 1; bool gotImportantFix = false, addedSeparator = false; var fixesAdded = new List<string> (); foreach (var fix_ in fixes.OrderByDescending (i => Tuple.Create (IsAnalysisOrErrorFix(i), (int)i.Severity, GetUsage (i.IdString)))) { // filter out code actions that are already resolutions of a code issue if (fixesAdded.Any (f => fix_.IdString.IndexOf (f, StringComparison.Ordinal) >= 0)) continue; fixesAdded.Add (fix_.IdString); if (IsAnalysisOrErrorFix (fix_)) gotImportantFix = true; if (!addedSeparator && gotImportantFix && !IsAnalysisOrErrorFix(fix_)) { menu.Add (new Gtk.SeparatorMenuItem ()); addedSeparator = true; } var fix = fix_; var escapedLabel = fix.Title.Replace ("_", "__"); var label = (mnemonic <= 10) ? "_" + (mnemonic++ % 10).ToString () + " " + escapedLabel : " " + escapedLabel; var thisInstanceMenuItem = new Gtk.MenuItem (label); thisInstanceMenuItem.Activated += new ContextActionRunner (fix, document, loc).Run; thisInstanceMenuItem.Activated += delegate { ConfirmUsage (fix.IdString); menu.Destroy (); }; menu.Add (thisInstanceMenuItem); items++; } bool first = true; var alreadyInserted = new HashSet<BaseCodeIssueProvider> (); foreach (var analysisFix_ in fixes.OfType <AnalysisContextActionProvider.AnalysisCodeAction>().Where (f => f.Result is InspectorResults)) { var analysisFix = analysisFix_; var ir = analysisFix.Result as InspectorResults; if (ir == null) continue; if (first) { menu.Add (new Gtk.SeparatorMenuItem ()); first = false; } if (alreadyInserted.Contains (ir.Inspector)) continue; alreadyInserted.Add (ir.Inspector); var subMenu = new Gtk.Menu (); if (analysisFix.SupportsBatchRunning) { var batchRunMenuItem = new Gtk.MenuItem (GettextCatalog.GetString ("Fix all in this file")); batchRunMenuItem.Activated += delegate { ConfirmUsage (analysisFix.IdString); menu.Destroy (); }; batchRunMenuItem.Activated += new ContextActionRunner (analysisFix, document, loc).BatchRun; subMenu.Add (batchRunMenuItem); subMenu.Add (new Gtk.SeparatorMenuItem ()); } var inspector = ir.Inspector; if (inspector.CanSuppressWithAttribute) { var menuItem = new Gtk.MenuItem (GettextCatalog.GetString ("_Suppress with attribute")); menuItem.Activated += delegate { inspector.SuppressWithAttribute (document, analysisFix.DocumentRegion); }; subMenu.Add (menuItem); } if (inspector.CanDisableWithPragma) { var menuItem = new Gtk.MenuItem (GettextCatalog.GetString ("_Suppress with #pragma")); menuItem.Activated += delegate { inspector.DisableWithPragma (document, analysisFix.DocumentRegion); }; subMenu.Add (menuItem); } if (inspector.CanDisableOnce) { var menuItem = new Gtk.MenuItem (GettextCatalog.GetString ("_Disable once with comment")); menuItem.Activated += delegate { inspector.DisableOnce (document, analysisFix.DocumentRegion); }; subMenu.Add (menuItem); } if (inspector.CanDisableAndRestore) { var menuItem = new Gtk.MenuItem (GettextCatalog.GetString ("Disable _and restore with comments")); menuItem.Activated += delegate { inspector.DisableAndRestore (document, analysisFix.DocumentRegion); }; subMenu.Add (menuItem); } var label = GettextCatalog.GetString ("_Options for \"{0}\"", InspectorResults.GetTitle (ir.Inspector)); var subMenuItem = new Gtk.MenuItem (label); var optionsMenuItem = new Gtk.MenuItem (GettextCatalog.GetString ("_Configure inspection")); optionsMenuItem.Activated += analysisFix.ShowOptions; optionsMenuItem.Activated += delegate { menu.Destroy (); }; subMenu.Add (optionsMenuItem); subMenuItem.Submenu = subMenu; menu.Add (subMenuItem); items++; } }
public void PopulateFixes(Gtk.Menu menu, ref int items) { int mnemonic = 1; bool gotImportantFix = false, addedSeparator = false; foreach (var fix_ in fixes.OrderByDescending(i => Tuple.Create(IsAnalysisOrErrorFix(i), (int)i.Severity, GetUsage(i.IdString)))) { if (IsAnalysisOrErrorFix(fix_)) { gotImportantFix = true; } if (!addedSeparator && gotImportantFix && !IsAnalysisOrErrorFix(fix_)) { menu.Add(new Gtk.SeparatorMenuItem()); addedSeparator = true; } var fix = fix_; var escapedLabel = fix.Title.Replace("_", "__"); var label = (mnemonic <= 10) ? "_" + (mnemonic++ % 10).ToString() + " " + escapedLabel : " " + escapedLabel; var thisInstanceMenuItem = new Gtk.MenuItem(label); thisInstanceMenuItem.Activated += new ContextActionRunner(fix, document, loc).Run; thisInstanceMenuItem.Activated += delegate { ConfirmUsage(fix.IdString); menu.Destroy(); }; menu.Add(thisInstanceMenuItem); items++; } bool first = true; var alreadyInserted = new HashSet <BaseCodeIssueProvider> (); foreach (var analysisFix_ in fixes.OfType <AnalysisContextActionProvider.AnalysisCodeAction>().Where(f => f.Result is InspectorResults)) { var analysisFix = analysisFix_; var ir = analysisFix.Result as InspectorResults; if (ir == null) { continue; } if (first) { menu.Add(new Gtk.SeparatorMenuItem()); first = false; } if (alreadyInserted.Contains(ir.Inspector)) { continue; } alreadyInserted.Add(ir.Inspector); var subMenu = new Gtk.Menu(); if (analysisFix.SupportsBatchRunning) { var batchRunMenuItem = new Gtk.MenuItem(GettextCatalog.GetString("Fix all in this file")); batchRunMenuItem.Activated += delegate { ConfirmUsage(analysisFix.IdString); menu.Destroy(); }; batchRunMenuItem.Activated += new ContextActionRunner(analysisFix, document, loc).BatchRun; subMenu.Add(batchRunMenuItem); subMenu.Add(new Gtk.SeparatorMenuItem()); } var inspector = ir.Inspector; if (inspector.CanSuppressWithAttribute) { var menuItem = new Gtk.MenuItem(GettextCatalog.GetString("_Suppress with attribute")); menuItem.Activated += delegate { inspector.SuppressWithAttribute(document, analysisFix.DocumentRegion); }; subMenu.Add(menuItem); } if (inspector.CanDisableWithPragma) { var menuItem = new Gtk.MenuItem(GettextCatalog.GetString("_Suppress with #pragma")); menuItem.Activated += delegate { inspector.DisableWithPragma(document, analysisFix.DocumentRegion); }; subMenu.Add(menuItem); } if (inspector.CanDisableOnce) { var menuItem = new Gtk.MenuItem(GettextCatalog.GetString("_Disable once with comment")); menuItem.Activated += delegate { inspector.DisableOnce(document, analysisFix.DocumentRegion); }; subMenu.Add(menuItem); } if (inspector.CanDisableAndRestore) { var menuItem = new Gtk.MenuItem(GettextCatalog.GetString("Disable _and restore with comments")); menuItem.Activated += delegate { inspector.DisableAndRestore(document, analysisFix.DocumentRegion); }; subMenu.Add(menuItem); } var label = GettextCatalog.GetString("_Options for \"{0}\"", InspectorResults.GetTitle(ir.Inspector)); var subMenuItem = new Gtk.MenuItem(label); var optionsMenuItem = new Gtk.MenuItem(GettextCatalog.GetString("_Configure inspection")); optionsMenuItem.Activated += analysisFix.ShowOptions; optionsMenuItem.Activated += delegate { menu.Destroy(); }; subMenu.Add(optionsMenuItem); subMenuItem.Submenu = subMenu; menu.Add(subMenuItem); items++; } }
private void ConstructMenuFile() { Debug.WriteLine("ConstructMenuFile"); ConstructImageMenuItemFileNew(); ConstructImageMenuItemFileOpen(); ConstructImageMenuItemFileSave(); ConstructImageMenuItemFileSaveAs(); ConstructImageMenuItemFileClose(); ConstructSeparatorMenuItemFile1(); ConstructImageMenuItemFileQuit(); menuFile = new Gtk.Menu { Name = "menuFile", Visible = true, }; menuFile.Add(imageMenuItemFileNew); menuFile.Add(imageMenuItemFileOpen); menuFile.Add(imageMenuItemFileSave); menuFile.Add(imageMenuItemFileSaveAs); menuFile.Add(imageMenuItemFileClose); menuFile.Add(separatorMenuItemFile1); menuFile.Add(imageMenuItemFileQuit); }
public void PopulateFixes (Gtk.Menu menu, ref int items) { int mnemonic = 1; foreach (var fix_ in fixes.OrderByDescending (i => GetUsage (i.IdString))) { var fix = fix_; var escapedLabel = fix.Title.Replace ("_", "__"); var label = (mnemonic <= 10) ? "_" + (mnemonic++ % 10).ToString () + " " + escapedLabel : " " + escapedLabel; var thisInstanceMenuItem = new Gtk.MenuItem (label); thisInstanceMenuItem.Activated += new ContextActionRunner (fix, document, loc).Run; thisInstanceMenuItem.Activated += delegate { ConfirmUsage (fix.IdString); menu.Destroy (); }; menu.Add (thisInstanceMenuItem); items++; } var first = true; var alreadyInserted = new HashSet<BaseCodeIssueProvider> (); foreach (var analysisFix_ in fixes.OfType <AnalysisContextActionProvider.AnalysisCodeAction>().Where (f => f.Result is InspectorResults)) { var analysisFix = analysisFix_; var ir = analysisFix.Result as InspectorResults; if (ir == null) continue; if (first) { menu.Add (new Gtk.SeparatorMenuItem ()); first = false; } if (alreadyInserted.Contains (ir.Inspector)) continue; alreadyInserted.Add (ir.Inspector); var subMenu = new Gtk.Menu (); if (analysisFix.SupportsBatchRunning) { var batchRunMenuItem = new Gtk.MenuItem (GettextCatalog.GetString ("Fix all in this file")); batchRunMenuItem.Activated += delegate { ConfirmUsage (analysisFix.IdString); menu.Destroy (); }; batchRunMenuItem.Activated += new ContextActionRunner (analysisFix, document, loc).BatchRun; subMenu.Add (batchRunMenuItem); subMenu.Add (new Gtk.SeparatorMenuItem ()); } var inspector = ir.Inspector; if (inspector.CanSuppressWithAttribute) { var menuItem = new Gtk.MenuItem (GettextCatalog.GetString ("_Suppress with attribute")); menuItem.Activated += delegate { inspector.SuppressWithAttribute (document, analysisFix.DocumentRegion); }; subMenu.Add (menuItem); } if (inspector.CanDisableWithPragma) { var menuItem = new Gtk.MenuItem (GettextCatalog.GetString ("_Suppress with #pragma")); menuItem.Activated += delegate { inspector.DisableWithPragma (document, analysisFix.DocumentRegion); }; subMenu.Add (menuItem); } if (inspector.CanDisableOnce) { var menuItem = new Gtk.MenuItem (GettextCatalog.GetString ("_Disable once with comment")); menuItem.Activated += delegate { inspector.DisableOnce (document, analysisFix.DocumentRegion); }; subMenu.Add (menuItem); } if (inspector.CanDisableAndRestore) { var menuItem = new Gtk.MenuItem (GettextCatalog.GetString ("Disable _and restore with comments")); menuItem.Activated += delegate { inspector.DisableAndRestore (document, analysisFix.DocumentRegion); }; subMenu.Add (menuItem); } var label = GettextCatalog.GetString ("_Options for \"{0}\"", InspectorResults.GetTitle (ir.Inspector)); var subMenuItem = new Gtk.MenuItem (label); var optionsMenuItem = new Gtk.MenuItem (GettextCatalog.GetString ("_Configure inspection severity")); optionsMenuItem.Activated += analysisFix.ShowOptions; optionsMenuItem.Activated += delegate { menu.Destroy (); }; subMenu.Add (optionsMenuItem); subMenuItem.Submenu = subMenu; menu.Add (subMenuItem); items++; } foreach (var fix_ in fixes.Where (f => f.BoundToIssue != null)) { var fix = fix_; foreach (var inspector_ in RefactoringService.GetInspectors (document.Editor.MimeType).Where (i => i.GetSeverity () != Severity.None)) { var inspector = inspector_; if (inspector.IdString.IndexOf (fix.BoundToIssue.FullName, StringComparison.Ordinal) < 0) continue; if (first) { menu.Add (new Gtk.SeparatorMenuItem ()); first = false; } if (alreadyInserted.Contains (inspector)) continue; alreadyInserted.Add (inspector); var label = GettextCatalog.GetString ("_Options for \"{0}\"", InspectorResults.GetTitle (inspector)); var subMenuItem = new Gtk.MenuItem (label); Gtk.Menu subMenu = new Gtk.Menu (); if (inspector.CanSuppressWithAttribute) { var menuItem = new Gtk.MenuItem (GettextCatalog.GetString ("_Suppress with attribute")); menuItem.Activated += delegate { inspector.SuppressWithAttribute (document, fix.DocumentRegion); }; subMenu.Add (menuItem); } if (inspector.CanDisableWithPragma) { var menuItem = new Gtk.MenuItem (GettextCatalog.GetString ("_Suppress with #pragma")); menuItem.Activated += delegate { inspector.DisableWithPragma (document, fix.DocumentRegion); }; subMenu.Add (menuItem); } if (inspector.CanDisableOnce) { var menuItem = new Gtk.MenuItem (GettextCatalog.GetString ("_Disable once with comment")); menuItem.Activated += delegate { inspector.DisableOnce (document, fix.DocumentRegion); }; subMenu.Add (menuItem); } if (inspector.CanDisableAndRestore) { var menuItem = new Gtk.MenuItem (GettextCatalog.GetString ("Disable _and restore with comments")); menuItem.Activated += delegate { inspector.DisableAndRestore (document, fix.DocumentRegion); }; subMenu.Add (menuItem); } var confItem = new Gtk.MenuItem (GettextCatalog.GetString ("_Configure inspection severity")); confItem.Activated += delegate { MessageService.RunCustomDialog (new CodeIssueOptionsDialog (inspector), MessageService.RootWindow); menu.Destroy (); }; subMenu.Add (confItem); subMenuItem.Submenu = subMenu; subMenu.ShowAll (); menu.Add (subMenuItem); break; } items++; } }
void PopupQuickFixMenu(Gdk.EventButton evt, Action <Gtk.Menu> menuAction) { var menu = new Gtk.Menu(); menu.Events |= Gdk.EventMask.AllEventsMask; Gtk.Menu fixMenu = menu; ResolveResult resolveResult; ICSharpCode.NRefactory.CSharp.AstNode node; int items = 0; if (ResolveCommandHandler.ResolveAt(document, out resolveResult, out node)) { var possibleNamespaces = MonoDevelop.Refactoring.ResolveCommandHandler.GetPossibleNamespaces( document, node, ref resolveResult ); bool addUsing = !(resolveResult is AmbiguousTypeResolveResult); if (addUsing) { foreach (var t in possibleNamespaces.Where(tp => tp.IsAccessibleWithGlobalUsing)) { string ns = t.Namespace; var reference = t.Reference; var menuItem = new Gtk.MenuItem(string.Format("using {0};", ns)); menuItem.Activated += delegate { new ResolveCommandHandler.AddImport(document, resolveResult, ns, reference, true, node).Run(); if (reference != null) { document.Project.Items.Add(reference); } menu.Destroy(); }; menu.Add(menuItem); items++; } } bool resolveDirect = !(resolveResult is UnknownMemberResolveResult); if (resolveDirect) { foreach (var t in possibleNamespaces) { string ns = t.Namespace; var reference = t.Reference; var menuItem = new Gtk.MenuItem(GettextCatalog.GetString("{0}", ns + "." + document.Editor.GetTextBetween(node.StartLocation, node.EndLocation))); menuItem.Activated += delegate { new ResolveCommandHandler.AddImport(document, resolveResult, ns, reference, false, node).Run(); menu.Destroy(); }; menu.Add(menuItem); items++; } } if (menu.Children.Any() && fixes.Any()) { fixMenu = new Gtk.Menu(); var menuItem = new Gtk.MenuItem(GettextCatalog.GetString("Quick Fixes")); menuItem.Submenu = fixMenu; menu.Add(menuItem); items++; } } PopulateFixes(fixMenu, ref items); if (items == 0) { menu.Destroy(); return; } document.Editor.SuppressTooltips = true; document.Editor.Parent.HideTooltip(); if (menuAction != null) { menuAction(menu); } menu.ShowAll(); menu.SelectFirst(true); menuPushed = true; menu.Hidden += delegate { document.Editor.SuppressTooltips = false; }; menu.Destroyed += delegate { menuPushed = false; Hide(); }; var container = document.Editor.Parent; var child = (TextEditor.EditorContainerChild)container [this]; Gdk.Rectangle rect; /* if (child != null) { * rect = new Gdk.Rectangle (child.X, child.Y + Allocation.Height - (int)document.Editor.VAdjustment.Value, 0, 0); * } else {*/ var p = container.LocationToPoint(loc); rect = new Gdk.Rectangle(p.X + container.Allocation.X, p.Y + (int)document.Editor.LineHeight + container.Allocation.Y, 0, 0); //} GtkWorkarounds.ShowContextMenu(menu, document.Editor.Parent, null, rect); }
void PopupQuickFixMenu (Gdk.EventButton evt) { var menu = new Gtk.Menu (); Gtk.Menu fixMenu = menu; ResolveResult resolveResult; ICSharpCode.NRefactory.CSharp.AstNode node; if (ResolveCommandHandler.ResolveAt (document, out resolveResult, out node)) { var possibleNamespaces = MonoDevelop.Refactoring.ResolveCommandHandler.GetPossibleNamespaces ( document, node, resolveResult ); bool addUsing = !(resolveResult is AmbiguousTypeResolveResult); if (addUsing) { foreach (string ns_ in possibleNamespaces) { string ns = ns_; var menuItem = new Gtk.MenuItem (string.Format ("using {0};", ns)); menuItem.Activated += delegate { new MonoDevelop.Refactoring.ResolveCommandHandler.AddImport (document, resolveResult, ns, true).Run (); menu.Destroy (); }; menu.Add (menuItem); } } bool resolveDirect = !(resolveResult is UnknownMemberResolveResult); if (resolveDirect) { foreach (string ns in possibleNamespaces) { var menuItem = new Gtk.MenuItem (GettextCatalog.GetString ("{0}", ns + "." + document.Editor.GetTextBetween (node.StartLocation, node.EndLocation))); menuItem.Activated += delegate { new MonoDevelop.Refactoring.ResolveCommandHandler.AddImport (document, resolveResult, ns, false).Run (); menu.Destroy (); }; menu.Add (menuItem); } } if (menu.Children.Any () && fixes.Any ()) { fixMenu = new Gtk.Menu (); var menuItem = new Gtk.MenuItem (GettextCatalog.GetString ("Quick Fixes")); menuItem.Submenu = fixMenu; menu.Add (menuItem); } } PopulateFixes (fixMenu); menu.ShowAll (); menu.SelectFirst (true); menuPushed = true; menu.Destroyed += delegate { menuPushed = false; Hide (); }; var container = (TextEditorContainer)document.Editor.Parent.Parent; var child = (TextEditorContainer.EditorContainerChild)container [this]; GtkWorkarounds.ShowContextMenu (menu, document.Editor.Parent, null, new Gdk.Rectangle (child.X, child.Y + Allocation.Height - (int)document.Editor.VAdjustment.Value, 0, 0)); }
public virtual void Initialize (PropertyDescriptor prop) { CheckType (prop); this.prop = prop; mainHBox = new Gtk.HBox (false, 6); PackStart (mainHBox, false, false, 0); if (!prop.Translatable) return; button = new Gtk.Button (); try { globe = Gdk.Pixbuf.LoadFromResource ("globe.png"); globe_not = Gdk.Pixbuf.LoadFromResource ("globe-not.png"); } catch (Exception e) { Console.WriteLine ("Error while loading pixbuf: " + e); } image = new Gtk.Image (globe); button.Add (image); button.ButtonPressEvent += ButtonPressed; mainHBox.PackEnd (button, false, false, 0); mainHBox.ShowAll (); menu = new Gtk.Menu (); markItem = new Gtk.CheckMenuItem ("Mark for Translation"); markItem.Toggled += ToggleMark; markItem.Show (); menu.Add (markItem); addContextItem = new Gtk.MenuItem ("Add Translation Context Hint"); addContextItem.Activated += AddContext; menu.Add (addContextItem); remContextItem = new Gtk.MenuItem ("Remove Translation Context Hint"); remContextItem.Activated += RemoveContext; menu.Add (remContextItem); addCommentItem = new Gtk.MenuItem ("Add Comment for Translators"); addCommentItem.Activated += AddComment; menu.Add (addCommentItem); remCommentItem = new Gtk.MenuItem ("Remove Comment for Translators"); remCommentItem.Activated += RemoveComment; menu.Add (remCommentItem); contextBox = new Gtk.HBox (false, 6); Gtk.Label contextLabel = new Gtk.Label ("Translation context"); contextLabel.Xalign = 0.0f; contextBox.PackStart (contextLabel, false, false, 0); contextEntry = new Gtk.Entry (); contextEntry.WidthChars = 8; contextBox.PackStart (contextEntry, true, true, 0); contextBox.ShowAll (); contextEntry.Changed += ContextChanged; commentBox = new Gtk.VBox (false, 3); Gtk.Label commentLabel = new Gtk.Label ("Comment for Translators:"); commentLabel.Xalign = 0.0f; commentBox.PackStart (commentLabel, false, false, 0); commentText = new TextBox (3); commentBox.PackStart (commentText, false, false, 0); commentBox.ShowAll (); commentText.Changed += CommentChanged; }
public void ShowContextMenu(ActionItem aitem) { ActionMenuItem menuItem = (ActionMenuItem) aitem; Gtk.Menu m = new Gtk.Menu (); Gtk.MenuItem item = new Gtk.MenuItem (Catalog.GetString ("Insert Before")); m.Add (item); item.Activated += delegate (object s, EventArgs a) { InsertActionAt (menuItem, false, false); }; item = new Gtk.MenuItem (Catalog.GetString ("Insert After")); m.Add (item); item.Activated += delegate (object s, EventArgs a) { InsertActionAt (menuItem, true, false); }; m.Add (new Gtk.SeparatorMenuItem ()); item = new Gtk.ImageMenuItem (Gtk.Stock.Cut, null); m.Add (item); item.Activated += delegate (object s, EventArgs a) { menuItem.Cut (); }; item.Visible = false; // No copy & paste for now item = new Gtk.ImageMenuItem (Gtk.Stock.Copy, null); m.Add (item); item.Activated += delegate (object s, EventArgs a) { menuItem.Copy (); }; item.Visible = false; // No copy & paste for now item = new Gtk.ImageMenuItem (Gtk.Stock.Paste, null); m.Add (item); item.Activated += delegate (object s, EventArgs a) { Paste (menuItem); }; item.Visible = false; // No copy & paste for now item = new Gtk.ImageMenuItem (Gtk.Stock.Delete, null); m.Add (item); item.Activated += delegate (object s, EventArgs a) { menuItem.Delete (); }; m.ShowAll (); m.Popup (); }
public void PopupQuickFixMenu () { Gtk.Menu menu = new Gtk.Menu (); Dictionary<Gtk.MenuItem, ContextAction> fixTable = new Dictionary<Gtk.MenuItem, ContextAction> (); int mnemonic = 1; foreach (ContextAction fix in fixes) { var escapedLabel = fix.GetMenuText (document, loc).Replace ("_", "__"); var label = (mnemonic <= 10) ? "_" + (mnemonic++ % 10).ToString () + " " + escapedLabel : " " + escapedLabel; Gtk.MenuItem menuItem = new Gtk.MenuItem (label); fixTable [menuItem] = fix; menuItem.Activated += delegate(object sender, EventArgs e) { // ensure that the Ast is recent. document.UpdateParseDocument (); var runFix = fixTable [(Gtk.MenuItem)sender]; runFix.Run (document, loc); document.Editor.Document.CommitUpdateAll (); menu.Destroy (); }; menu.Add (menuItem); } menu.ShowAll (); int dx, dy; this.ParentWindow.GetOrigin (out dx, out dy); dx += ((TextEditorContainer.EditorContainerChild)(this.document.Editor.Parent.Parent as TextEditorContainer) [this]).X; dy += ((TextEditorContainer.EditorContainerChild)(this.document.Editor.Parent.Parent as TextEditorContainer) [this]).Y - (int)document.Editor.VAdjustment.Value; menu.Popup (null, null, delegate (Gtk.Menu menu2, out int x, out int y, out bool pushIn) { x = dx; y = dy + Allocation.Height; pushIn = false; menuPushed = true; QueueDraw (); }, 0, Gtk.Global.CurrentEventTime); menu.SelectFirst (true); menu.Destroyed += delegate { menuPushed = false; QueueDraw (); }; }
public virtual void Initialize(PropertyDescriptor prop) { CheckType(prop); this.prop = prop; mainHBox = new Gtk.HBox(false, 6); PackStart(mainHBox, false, false, 0); if (!prop.Translatable) { return; } button = new Gtk.Button(); try { globe = Gdk.Pixbuf.LoadFromResource("globe.png"); globe_not = Gdk.Pixbuf.LoadFromResource("globe-not.png"); } catch (Exception e) { Console.WriteLine("Error while loading pixbuf: " + e); } image = new Gtk.Image(globe); button.Add(image); button.ButtonPressEvent += ButtonPressed; mainHBox.PackEnd(button, false, false, 0); mainHBox.ShowAll(); menu = new Gtk.Menu(); markItem = new Gtk.CheckMenuItem("Mark for Translation"); markItem.Toggled += ToggleMark; markItem.Show(); menu.Add(markItem); addContextItem = new Gtk.MenuItem("Add Translation Context Hint"); addContextItem.Activated += AddContext; menu.Add(addContextItem); remContextItem = new Gtk.MenuItem("Remove Translation Context Hint"); remContextItem.Activated += RemoveContext; menu.Add(remContextItem); addCommentItem = new Gtk.MenuItem("Add Comment for Translators"); addCommentItem.Activated += AddComment; menu.Add(addCommentItem); remCommentItem = new Gtk.MenuItem("Remove Comment for Translators"); remCommentItem.Activated += RemoveComment; menu.Add(remCommentItem); contextBox = new Gtk.HBox(false, 6); Gtk.Label contextLabel = new Gtk.Label("Translation context"); contextLabel.Xalign = 0.0f; contextBox.PackStart(contextLabel, false, false, 0); contextEntry = new Gtk.Entry(); contextEntry.WidthChars = 8; contextBox.PackStart(contextEntry, true, true, 0); contextBox.ShowAll(); contextEntry.Changed += ContextChanged; commentBox = new Gtk.VBox(false, 3); Gtk.Label commentLabel = new Gtk.Label("Comment for Translators:"); commentLabel.Xalign = 0.0f; commentBox.PackStart(commentLabel, false, false, 0); commentText = new TextBox(3); commentBox.PackStart(commentText, false, false, 0); commentBox.ShowAll(); commentText.Changed += CommentChanged; }
void IMenuItemContainer.ShowContextMenu(ActionItem aitem) { ActionMenuItem menuItem = aitem as ActionMenuItem; Gtk.Menu m = new Gtk.Menu (); Gtk.MenuItem item = new Gtk.ImageMenuItem (Gtk.Stock.Cut, null); m.Add (item); item.Activated += delegate (object s, EventArgs a) { Cut (menuItem); }; item.Visible = false; // No copy & paste for now item = new Gtk.ImageMenuItem (Gtk.Stock.Copy, null); m.Add (item); item.Activated += delegate (object s, EventArgs a) { Copy (menuItem); }; item.Visible = false; // No copy & paste for now item = new Gtk.ImageMenuItem (Gtk.Stock.Paste, null); m.Add (item); item.Activated += delegate (object s, EventArgs a) { Paste (menuItem); }; item.Visible = false; // No copy & paste for now item = new Gtk.ImageMenuItem (Gtk.Stock.Delete, null); m.Add (item); item.Activated += delegate (object s, EventArgs a) { Delete (menuItem); }; m.ShowAll (); m.Popup (); }
void PopupQuickFixMenu (Gdk.EventButton evt) { var menu = new Gtk.Menu (); Gtk.Menu fixMenu = menu; ResolveResult resolveResult; ICSharpCode.NRefactory.CSharp.AstNode node; int items = 0; if (ResolveCommandHandler.ResolveAt (document, out resolveResult, out node)) { var possibleNamespaces = MonoDevelop.Refactoring.ResolveCommandHandler.GetPossibleNamespaces ( document, node, ref resolveResult ); bool addUsing = !(resolveResult is AmbiguousTypeResolveResult); if (addUsing) { foreach (var t in possibleNamespaces.Where (tp => tp.Item2)) { string ns = t.Item1; var menuItem = new Gtk.MenuItem (string.Format ("using {0};", ns)); menuItem.Activated += delegate { new MonoDevelop.Refactoring.ResolveCommandHandler.AddImport (document, resolveResult, ns, true, node).Run (); menu.Destroy (); }; menu.Add (menuItem); items++; } } bool resolveDirect = !(resolveResult is UnknownMemberResolveResult); if (resolveDirect) { foreach (var t in possibleNamespaces) { string ns = t.Item1; var menuItem = new Gtk.MenuItem (GettextCatalog.GetString ("{0}", ns + "." + document.Editor.GetTextBetween (node.StartLocation, node.EndLocation))); menuItem.Activated += delegate { new MonoDevelop.Refactoring.ResolveCommandHandler.AddImport (document, resolveResult, ns, false, node).Run (); menu.Destroy (); }; menu.Add (menuItem); items++; } } if (menu.Children.Any () && fixes.Any ()) { fixMenu = new Gtk.Menu (); var menuItem = new Gtk.MenuItem (GettextCatalog.GetString ("Quick Fixes")); menuItem.Submenu = fixMenu; menu.Add (menuItem); items++; } } PopulateFixes (fixMenu, ref items); if (items == 0) { menu.Destroy (); return; } document.Editor.SuppressTooltips = true; document.Editor.Parent.HideTooltip (); menu.ShowAll (); menu.SelectFirst (true); menuPushed = true; menu.Hidden += delegate { document.Editor.SuppressTooltips = false; }; menu.Destroyed += delegate { menuPushed = false; Hide (); }; var container = document.Editor.Parent; var child = (TextEditor.EditorContainerChild)container [this]; Gdk.Rectangle rect; /* if (child != null) { rect = new Gdk.Rectangle (child.X, child.Y + Allocation.Height - (int)document.Editor.VAdjustment.Value, 0, 0); } else {*/ var p = container.LocationToPoint (loc); rect = new Gdk.Rectangle (p.X + container.Allocation.X , p.Y + (int)document.Editor.LineHeight + container.Allocation.Y, 0, 0); //} GtkWorkarounds.ShowContextMenu (menu, document.Editor.Parent, null, rect); }
public void PopulateFixes(Gtk.Menu menu, ref int items) { int mnemonic = 1; bool gotImportantFix = false, addedSeparator = false; var fixesAdded = new List <string> (); foreach (var fix_ in fixes.OrderByDescending(i => Tuple.Create(IsAnalysisOrErrorFix(i), (int)i.Severity, GetUsage(i.IdString)))) { // filter out code actions that are already resolutions of a code issue if (fixesAdded.Any(f => fix_.IdString.IndexOf(f, StringComparison.Ordinal) >= 0)) { continue; } fixesAdded.Add(fix_.IdString); if (IsAnalysisOrErrorFix(fix_)) { gotImportantFix = true; } if (!addedSeparator && gotImportantFix && !IsAnalysisOrErrorFix(fix_)) { menu.Add(new Gtk.SeparatorMenuItem()); addedSeparator = true; } var fix = fix_; var escapedLabel = fix.Title.Replace("_", "__"); var label = (mnemonic <= 10) ? "_" + (mnemonic++ % 10).ToString() + " " + escapedLabel : " " + escapedLabel; var thisInstanceMenuItem = new Gtk.MenuItem(label); thisInstanceMenuItem.Activated += new ContextActionRunner(fix, document, loc).Run; thisInstanceMenuItem.Activated += delegate { ConfirmUsage(fix.IdString); menu.Destroy(); }; menu.Add(thisInstanceMenuItem); items++; } bool first = true; var settingsMenuFixes = fixes .OfType <AnalysisContextActionProvider.AnalysisCodeAction> () .Where(f => f.Result is InspectorResults) .GroupBy(f => ((InspectorResults)f.Result).Inspector); foreach (var analysisFixGroup_ in settingsMenuFixes) { var analysisFixGroup = analysisFixGroup_; var arbitraryFixInGroup = analysisFixGroup.First(); var ir = (InspectorResults)arbitraryFixInGroup.Result; if (first) { menu.Add(new Gtk.SeparatorMenuItem()); first = false; } var subMenu = new Gtk.Menu(); foreach (var analysisFix_ in analysisFixGroup) { var analysisFix = analysisFix_; if (analysisFix.SupportsBatchRunning) { var batchRunMenuItem = new Gtk.MenuItem(string.Format(GettextCatalog.GetString("Apply in file: {0}"), analysisFix.Title)); batchRunMenuItem.Activated += delegate { ConfirmUsage(analysisFix.IdString); menu.Destroy(); }; batchRunMenuItem.Activated += new ContextActionRunner(analysisFix, document, loc).BatchRun; subMenu.Add(batchRunMenuItem); subMenu.Add(new Gtk.SeparatorMenuItem()); } } var inspector = ir.Inspector; if (inspector.CanSuppressWithAttribute) { var menuItem = new Gtk.MenuItem(GettextCatalog.GetString("_Suppress with attribute")); menuItem.Activated += delegate { inspector.SuppressWithAttribute(document, arbitraryFixInGroup.DocumentRegion); }; subMenu.Add(menuItem); } if (inspector.CanDisableWithPragma) { var menuItem = new Gtk.MenuItem(GettextCatalog.GetString("_Suppress with #pragma")); menuItem.Activated += delegate { inspector.DisableWithPragma(document, arbitraryFixInGroup.DocumentRegion); }; subMenu.Add(menuItem); } if (inspector.CanDisableOnce) { var menuItem = new Gtk.MenuItem(GettextCatalog.GetString("_Disable once with comment")); menuItem.Activated += delegate { inspector.DisableOnce(document, arbitraryFixInGroup.DocumentRegion); }; subMenu.Add(menuItem); } if (inspector.CanDisableAndRestore) { var menuItem = new Gtk.MenuItem(GettextCatalog.GetString("Disable _and restore with comments")); menuItem.Activated += delegate { inspector.DisableAndRestore(document, arbitraryFixInGroup.DocumentRegion); }; subMenu.Add(menuItem); } var label = GettextCatalog.GetString("_Options for \"{0}\"", InspectorResults.GetTitle(ir.Inspector)); var subMenuItem = new Gtk.MenuItem(label); var optionsMenuItem = new Gtk.MenuItem(GettextCatalog.GetString("_Configure inspection")); optionsMenuItem.Activated += arbitraryFixInGroup.ShowOptions; optionsMenuItem.Activated += delegate { menu.Destroy(); }; subMenu.Add(optionsMenuItem); subMenuItem.Submenu = subMenu; menu.Add(subMenuItem); items++; } }
void Update (CommandInfo cmdInfo) { lastCmdInfo = cmdInfo; if (isArray && !isArrayItem) { this.Visible = false; Gtk.Menu menu = (Gtk.Menu) Parent; if (itemArray != null) { foreach (Gtk.MenuItem item in itemArray) menu.Remove (item); } itemArray = new ArrayList (); int i = Array.IndexOf (menu.Children, this); if (cmdInfo.ArrayInfo != null) { foreach (CommandInfo info in cmdInfo.ArrayInfo) { Gtk.MenuItem item; if (info.IsArraySeparator) { item = new Gtk.SeparatorMenuItem (); item.Show (); } else { item = CommandEntry.CreateMenuItem (commandManager, commandId, false); ICommandMenuItem mi = (ICommandMenuItem) item; mi.SetUpdateInfo (info, initialTarget); } menu.Insert (item, ++i); itemArray.Add (item); } } } else { Gtk.Widget child = Child; if (child == null) return; Gtk.Label accel_label = null; Gtk.Label label = null; if (!(child is Gtk.HBox)) { child = new Gtk.HBox (false, 0); accel_label = new Gtk.Label (""); accel_label.UseUnderline = false; accel_label.Xalign = 1.0f; accel_label.Show (); label = new Gtk.Label (""); label.UseUnderline = true; label.Xalign = 0.0f; label.Show (); ((Gtk.Box) child).PackStart (label); ((Gtk.Box) child).PackStart (accel_label); child.Show (); this.Remove (Child); this.Add (child); } else { accel_label = (Gtk.Label) ((Gtk.Box) child).Children[1]; label = (Gtk.Label) ((Gtk.Box) child).Children[0]; } if (cmdInfo.AccelKey != null) accel_label.Text = " " + KeyBindingManager.BindingToDisplayLabel (cmdInfo.AccelKey, true); else accel_label.Text = String.Empty; if (cmdInfo.UseMarkup) { label.Markup = overrideLabel ?? cmdInfo.Text; label.UseMarkup = true; } else { label.Text = overrideLabel ?? cmdInfo.Text; label.UseMarkup = false; } label.UseUnderline = true; this.Sensitive = cmdInfo.Enabled; this.Visible = cmdInfo.Visible && (disabledVisible || cmdInfo.Enabled); if (!cmdInfo.Icon.IsNull && cmdInfo.Icon != lastIcon) { Image = new Gtk.Image (cmdInfo.Icon, Gtk.IconSize.Menu); lastIcon = cmdInfo.Icon; } if (cmdInfo is CommandInfoSet) { CommandInfoSet ciset = (CommandInfoSet) cmdInfo; Gtk.Menu smenu = new Gtk.Menu (); Submenu = smenu; foreach (CommandInfo info in ciset.CommandInfos) { Gtk.MenuItem item; if (info.IsArraySeparator) { item = new Gtk.SeparatorMenuItem (); item.Show (); } else { item = CommandEntry.CreateMenuItem (commandManager, commandId, false); ICommandMenuItem mi = (ICommandMenuItem) item; mi.SetUpdateInfo (info, initialTarget); } smenu.Add (item); } } } }
public void PopulateFixes(Gtk.Menu menu, ref int items) { int mnemonic = 1; foreach (var fix_ in fixes.OrderByDescending(i => GetUsage(i.IdString))) { var fix = fix_; var escapedLabel = fix.Title.Replace("_", "__"); var label = (mnemonic <= 10) ? "_" + (mnemonic++ % 10).ToString() + " " + escapedLabel : " " + escapedLabel; var thisInstanceMenuItem = new Gtk.MenuItem(label); thisInstanceMenuItem.Activated += new ContextActionRunner(fix, document, loc).Run; thisInstanceMenuItem.Activated += delegate { ConfirmUsage(fix.IdString); menu.Destroy(); }; menu.Add(thisInstanceMenuItem); items++; } var first = true; var alreadyInserted = new HashSet <BaseCodeIssueProvider> (); foreach (var analysisFix_ in fixes.OfType <AnalysisContextActionProvider.AnalysisCodeAction>().Where(f => f.Result is InspectorResults)) { var analysisFix = analysisFix_; var ir = analysisFix.Result as InspectorResults; if (ir == null) { continue; } if (first) { menu.Add(new Gtk.SeparatorMenuItem()); first = false; } if (alreadyInserted.Contains(ir.Inspector)) { continue; } alreadyInserted.Add(ir.Inspector); var subMenu = new Gtk.Menu(); if (analysisFix.SupportsBatchRunning) { var batchRunMenuItem = new Gtk.MenuItem(GettextCatalog.GetString("Fix all in this file")); batchRunMenuItem.Activated += delegate { ConfirmUsage(analysisFix.IdString); menu.Destroy(); }; batchRunMenuItem.Activated += new ContextActionRunner(analysisFix, document, loc).BatchRun; subMenu.Add(batchRunMenuItem); subMenu.Add(new Gtk.SeparatorMenuItem()); } var inspector = ir.Inspector; if (inspector.CanDisableWithPragma) { var menuItem = new Gtk.MenuItem(GettextCatalog.GetString("_Suppress with #pragma")); menuItem.Activated += delegate { inspector.DisableWithPragma(document, loc); }; subMenu.Add(menuItem); } if (inspector.CanDisableOnce) { var menuItem = new Gtk.MenuItem(GettextCatalog.GetString("_Disable once with comment")); menuItem.Activated += delegate { inspector.DisableOnce(document, loc); }; subMenu.Add(menuItem); } if (inspector.CanDisableAndRestore) { var menuItem = new Gtk.MenuItem(GettextCatalog.GetString("Disable _and restore with comments")); menuItem.Activated += delegate { inspector.DisableAndRestore(document, loc); }; subMenu.Add(menuItem); } var label = GettextCatalog.GetString("_Options for \"{0}\"", InspectorResults.GetTitle(ir.Inspector)); var subMenuItem = new Gtk.MenuItem(label); var optionsMenuItem = new Gtk.MenuItem(GettextCatalog.GetString("_Configure inspection severity")); optionsMenuItem.Activated += analysisFix.ShowOptions; optionsMenuItem.Activated += delegate { menu.Destroy(); }; subMenu.Add(optionsMenuItem); subMenuItem.Submenu = subMenu; menu.Add(subMenuItem); items++; } foreach (var fix_ in fixes.Where(f => f.BoundToIssue != null)) { var fix = fix_; foreach (var inspector_ in RefactoringService.GetInspectors(document.Editor.MimeType).Where(i => i.GetSeverity() != Severity.None)) { var inspector = inspector_; if (inspector.IdString.IndexOf(fix.BoundToIssue.FullName, StringComparison.Ordinal) < 0) { continue; } if (first) { menu.Add(new Gtk.SeparatorMenuItem()); first = false; } if (alreadyInserted.Contains(inspector)) { continue; } alreadyInserted.Add(inspector); var label = GettextCatalog.GetString("_Options for \"{0}\"", InspectorResults.GetTitle(inspector)); var subMenuItem = new Gtk.MenuItem(label); Gtk.Menu subMenu = new Gtk.Menu(); if (inspector.CanSuppressWithAttribute) { var menuItem = new Gtk.MenuItem(GettextCatalog.GetString("_Suppress with attribute")); menuItem.Activated += delegate { inspector.SuppressWithAttribute(document, loc); }; subMenu.Add(menuItem); } if (inspector.CanDisableWithPragma) { var menuItem = new Gtk.MenuItem(GettextCatalog.GetString("_Suppress with #pragma")); menuItem.Activated += delegate { inspector.DisableWithPragma(document, loc); }; subMenu.Add(menuItem); } if (inspector.CanDisableOnce) { var menuItem = new Gtk.MenuItem(GettextCatalog.GetString("_Disable once with comment")); menuItem.Activated += delegate { inspector.DisableOnce(document, loc); }; subMenu.Add(menuItem); } if (inspector.CanDisableAndRestore) { var menuItem = new Gtk.MenuItem(GettextCatalog.GetString("Disable _and restore with comments")); menuItem.Activated += delegate { inspector.DisableAndRestore(document, loc); }; subMenu.Add(menuItem); } var confItem = new Gtk.MenuItem(GettextCatalog.GetString("_Configure inspection severity")); confItem.Activated += delegate { MessageService.RunCustomDialog(new CodeIssueOptionsDialog(inspector), MessageService.RootWindow); menu.Destroy(); }; subMenu.Add(confItem); subMenuItem.Submenu = subMenu; subMenu.ShowAll(); menu.Add(subMenuItem); break; } items++; } }
public void PopulateFixes(Gtk.Menu menu, ref int items) { int mnemonic = 1; foreach (var fix_ in fixes.OrderByDescending(i => GetUsage(i.IdString))) { var fix = fix_; var escapedLabel = fix.Title.Replace("_", "__"); var label = (mnemonic <= 10) ? "_" + (mnemonic++ % 10).ToString() + " " + escapedLabel : " " + escapedLabel; var menuItem = new Gtk.MenuItem(label); menuItem.Activated += new ContextActionRunner(fix, document, loc).Run; menuItem.Activated += delegate { ConfirmUsage(fix.IdString); menu.Destroy(); }; menu.Add(menuItem); items++; } var first = true; var alreadyInserted = new HashSet <CodeIssueProvider> (); foreach (var analysisFix_ in fixes.OfType <AnalysisContextActionProvider.AnalysisCodeAction>().Where(f => f.Result is InspectorResults)) { var analysisFix = analysisFix_; var ir = analysisFix.Result as InspectorResults; if (ir == null) { continue; } if (first) { menu.Add(new Gtk.SeparatorMenuItem()); first = false; } if (alreadyInserted.Contains(ir.Inspector)) { continue; } alreadyInserted.Add(ir.Inspector); var label = GettextCatalog.GetString("_Inspection options for \"{0}\"", ir.Inspector.Title); var menuItem = new Gtk.MenuItem(label); menuItem.Activated += analysisFix.ShowOptions; menuItem.Activated += delegate { menu.Destroy(); }; menu.Add(menuItem); items++; } foreach (var fix_ in fixes.Where(f => f.BoundToIssue != null)) { var fix = fix_; foreach (var inspector_ in RefactoringService.GetInspectors(document.Editor.MimeType).Where(i => i.GetSeverity() != ICSharpCode.NRefactory.CSharp.Severity.None)) { var inspector = inspector_; if (inspector.IdString.IndexOf(fix.BoundToIssue.FullName, StringComparison.Ordinal) < 0) { continue; } if (first) { menu.Add(new Gtk.SeparatorMenuItem()); first = false; } if (alreadyInserted.Contains(inspector)) { continue; } alreadyInserted.Add(inspector); var label = GettextCatalog.GetString("_Inspection options for \"{0}\"", inspector.Title); var menuItem = new Gtk.MenuItem(label); menuItem.Activated += delegate { MessageService.RunCustomDialog(new CodeIssueOptionsDialog(inspector), MessageService.RootWindow); menu.Destroy(); }; menu.Add(menuItem); break; } items++; } }
private void BuildMenu() { var accel = new Gtk.AccelGroup(); this.mbMainMenu = new Gtk.MenuBar(); // File var miFile = new Gtk.MenuItem( "_File" ); var mFile = new Gtk.Menu(); miFile.Submenu = mFile; var opNew = this.actNew.CreateMenuItem(); opNew.AddAccelerator( "activate", accel, new Gtk.AccelKey( Gdk.Key.n, Gdk.ModifierType.ControlMask, Gtk.AccelFlags.Visible ) ); var opOpen = this.actOpen.CreateMenuItem(); opOpen.AddAccelerator( "activate", accel, new Gtk.AccelKey( Gdk.Key.o, Gdk.ModifierType.ControlMask, Gtk.AccelFlags.Visible ) ); var opSave = this.actSave.CreateMenuItem(); opSave.AddAccelerator( "activate", accel, new Gtk.AccelKey( Gdk.Key.s, Gdk.ModifierType.ControlMask, Gtk.AccelFlags.Visible ) ); var opQuit = this.actQuit.CreateMenuItem(); opQuit.AddAccelerator( "activate", accel, new Gtk.AccelKey( Gdk.Key.q, Gdk.ModifierType.ControlMask, Gtk.AccelFlags.Visible ) ); mFile.Add( opNew ); mFile.Add( this.actImport.CreateMenuItem() ); mFile.Add( opOpen ); mFile.Add( this.actAppend.CreateMenuItem() ); mFile.Add( opSave ); mFile.Add( this.actSaveAs.CreateMenuItem() ); mFile.Add( this.actExport.CreateMenuItem() ); mFile.Add( this.actClose.CreateMenuItem() ); mFile.Add( opQuit ); // Edit var miEdit = new Gtk.MenuItem( "_Edit" ); var mEdit = new Gtk.Menu(); miEdit.Submenu = mEdit; mEdit.Add( this.actAddQuestion.CreateMenuItem() ); mEdit.Add( this.actRemoveQuestion.CreateMenuItem() ); mEdit.Add( this.actAddAnswer.CreateMenuItem() ); mEdit.Add( this.actRemoveAnswer.CreateMenuItem() ); // Tools var miTools = new Gtk.MenuItem( "_Tools" ); var mTools = new Gtk.Menu(); miTools.Submenu = mTools; mTools.Add( this.actShuffle.CreateMenuItem() ); mTools.Add( this.actTakeTest.CreateMenuItem() ); // About var miAbout = new Gtk.MenuItem( "_About" ); var mAbout = new Gtk.Menu(); miAbout.Submenu = mAbout; mAbout.Add( this.actAbout.CreateMenuItem() ); // Finish this.mbMainMenu.Add( miFile ); this.mbMainMenu.Add( miEdit ); this.mbMainMenu.Add( miTools ); this.mbMainMenu.Add( miAbout ); }
void Update(CommandInfo cmdInfo) { if (lastCmdInfo != null) { lastCmdInfo.CancelAsyncUpdate(); lastCmdInfo.Changed -= CommandInfoChanged; } lastCmdInfo = cmdInfo; lastCmdInfo.Changed += CommandInfoChanged; if (isArray && !isArrayItem) { this.Visible = false; Gtk.Menu menu = (Gtk.Menu)Parent; if (itemArray != null) { foreach (Gtk.MenuItem item in itemArray) { menu.Remove(item); } } itemArray = new ArrayList(); int i = Array.IndexOf(menu.Children, this); if (cmdInfo.ArrayInfo != null) { foreach (CommandInfo info in cmdInfo.ArrayInfo) { Gtk.MenuItem item; if (info.IsArraySeparator) { item = new Gtk.SeparatorMenuItem(); item.Show(); } else { item = CommandEntry.CreateMenuItem(commandManager, commandId, false); ICommandMenuItem mi = (ICommandMenuItem)item; mi.SetUpdateInfo(info, initialTarget); } menu.Insert(item, ++i); itemArray.Add(item); } } } else { Gtk.Widget child = Child; if (child == null) { return; } Gtk.Label accel_label = null; Gtk.Label label = null; if (!(child is Gtk.HBox)) { child = new Gtk.HBox(false, 0); accel_label = new Gtk.Label(""); accel_label.UseUnderline = false; accel_label.Xalign = 1.0f; accel_label.Show(); label = new Gtk.Label(""); label.UseUnderline = true; label.Xalign = 0.0f; label.Show(); ((Gtk.Box)child).PackStart(label); ((Gtk.Box)child).PackStart(accel_label); child.Show(); this.Remove(Child); this.Add(child); } else { accel_label = (Gtk.Label)((Gtk.Box)child).Children[1]; label = (Gtk.Label)((Gtk.Box)child).Children[0]; } if (cmdInfo.AccelKey != null) { accel_label.Text = " " + KeyBindingManager.BindingToDisplayLabel(cmdInfo.AccelKey, true); } else { accel_label.Text = String.Empty; } if (cmdInfo.UseMarkup) { label.Markup = overrideLabel ?? cmdInfo.Text; label.UseMarkup = true; } else { label.Text = overrideLabel ?? cmdInfo.Text; label.UseMarkup = false; } if (!string.IsNullOrEmpty(cmdInfo.Description) && label.TooltipText != cmdInfo.Description) { label.TooltipText = cmdInfo.Description; } label.UseUnderline = true; this.Sensitive = cmdInfo.Enabled; this.Visible = cmdInfo.Visible && (disabledVisible || cmdInfo.Enabled); if (!cmdInfo.Icon.IsNull && cmdInfo.Icon != lastIcon) { Image = new ImageView(cmdInfo.Icon, Gtk.IconSize.Menu); lastIcon = cmdInfo.Icon; } if (cmdInfo is CommandInfoSet) { CommandInfoSet ciset = (CommandInfoSet)cmdInfo; Gtk.Menu smenu = new Gtk.Menu(); Submenu = smenu; foreach (CommandInfo info in ciset.CommandInfos) { Gtk.MenuItem item; if (info.IsArraySeparator) { item = new Gtk.SeparatorMenuItem(); item.Show(); } else { item = CommandEntry.CreateMenuItem(commandManager, commandId, false); ICommandMenuItem mi = (ICommandMenuItem)item; mi.SetUpdateInfo(info, initialTarget); } smenu.Add(item); } } } }
private void ConstructMenuEdit() { Debug.WriteLine("ConstructMenuEdit"); ConstrcutImageMenuItemEditUndo(); ConstrcutImageMenuItemEditRedo(); ConstructSeparatorMenuItemEdit1(); ConstrcutImageMenuItemEditCut(); ConstrcutImageMenuItemEditCopy(); ConstrcutImageMenuItemEditPaste(); ConstrcutImageMenuItemEditDelete(); menuEdit = new Gtk.Menu { Name = "menuEdit", Visible = true, }; menuEdit.Add(imageMenuItemEditUndo); menuEdit.Add(imageMenuItemEditRedo); menuEdit.Add(separatorMenuItemEdit1); menuEdit.Add(imageMenuItemEditCut); menuEdit.Add(imageMenuItemEditCopy); menuEdit.Add(imageMenuItemEditPaste); menuEdit.Add(imageMenuItemEditDelete); }