public void Replace (Gtk.Bin parent) { Gtk.Widget c = parent.Child; parent.Remove (c); Add (c); parent.Add (this); }
public static ImageMenuItem AddImageMenuButton(string title, string imgName, Gtk.Menu parent,EventHandler OnMenuClicked) { var sep = System.IO.Path.DirectorySeparatorChar; var menuItem = new ImageMenuItem(title); if (imgName != null) { var picFileName = SupportMethods.AppPath + sep + "Icons" + sep + imgName; if (System.IO.File.Exists(picFileName)) { menuItem.Image = new Gtk.Image(picFileName); } } if (OnMenuClicked != null) { menuItem.Activated+= OnMenuClicked; } if (parent != null) { parent.Add(menuItem); } return menuItem; }
protected void ConnectTextTagTable (Gtk.TextTagTable table, Monotalk.SourceView.Style [] styles) { foreach (Monotalk.SourceView.Style s in styles) { Gtk.TextTag tag = new TextTag(s.path); tag.Foreground = s.color; table.Add ( tag ); } }
public static Gtk.Window Show (Gtk.Window parent) { Gtk.Builder builder = new Gtk.Builder (null, "Mono.Addins.GuiGtk3.interfaces.AddinManagerDialog.ui", null); AddinManagerDialog dlg = new AddinManagerDialog (builder, builder.GetObject ("AddinManagerDialog").Handle); InitDialog (dlg); parent.Add (dlg); dlg.Show (); return dlg; }
public AuthoringPaneView(Gtk.VBox parent, Project project) { Project = project; active_item = -1; DragDataReceived += new DragDataReceivedHandler (HandleTargetDragDataReceived); EventBox eb = new EventBox (); // Provides a window for this windowless widget parent.Add (eb); eb.Add (this); Gtk.Drag.DestSet (this, DestDefaults.All, tag_dest_target_table, DragAction.Copy | DragAction.Move); eb.ButtonPressEvent += HandleButtonPress; eb.ButtonReleaseEvent += HandleButtonRelease; eb.MotionNotifyEvent += HandleMotionNotify; UpdateTheme (); }
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++; } }
private void AddSortContextMenuButton(Gtk.Menu menu, SongList.SortColumnEnum sortColumn, string title) { Gtk.MenuItem item = new MenuItem(title); item.ButtonPressEvent +=new ButtonPressEventHandler(contextMenu_ButtonPressEvent); item.Data["key"] = "sort"; item.Data["sort"] = sortColumn; menu.Add(item); }
private void AddSortContextMenu(Gtk.Menu menu) { Gtk.MenuItem sortItem = new MenuItem(Lng.Translate("Sort")); menu.Add(sortItem); // sort menu Gtk.Menu sortMenu = new Menu(); AddSortContextMenuButton(sortMenu,SongList.SortColumnEnum.FileName,Lng.Translate("FileName")); AddSortContextMenuButton(sortMenu,SongList.SortColumnEnum.Title,Lng.Translate("Title")); AddSortContextMenuButton(sortMenu,SongList.SortColumnEnum.Artist,Lng.Translate("Artist")); AddSortContextMenuButton(sortMenu,SongList.SortColumnEnum.Album,Lng.Translate("Album")); AddSortContextMenuButton(sortMenu,SongList.SortColumnEnum.Year,Lng.Translate("Year")); AddSortContextMenuButton(sortMenu,SongList.SortColumnEnum.Genre,Lng.Translate("Genre")); AddSortContextMenuButton(sortMenu,SongList.SortColumnEnum.Album,Lng.Translate("Comment")); AddSortContextMenuButton(sortMenu,SongList.SortColumnEnum.Track,Lng.Translate("TrackNumber")); AddSortContextMenuButton(sortMenu,SongList.SortColumnEnum.Changed,Lng.Translate("Changed")); sortItem.Submenu = sortMenu; }
private void AddRunContextMenu(Gtk.Menu menu) { Gtk.MenuItem runItem = new MenuItem(Lng.Translate("Run")); menu.Add(runItem); // submenu Gtk.Menu runMenu = new Menu(); foreach (var runApp in Configuration.RunApplications) { var item = AddContextMenuButton(runMenu,"run",runApp); item.Data["runApp"] = runApp; } runItem.Submenu = runMenu; }
private Gtk.MenuItem AddContextMenuButton(Gtk.Menu menu, string actionKey, string title) { Gtk.MenuItem item = new MenuItem(title); item.ButtonPressEvent +=new ButtonPressEventHandler(contextMenu_ButtonPressEvent); item.Data["key"] = actionKey; menu.Add(item); return item; }
public static void Add (Gtk.Container aContainer, Widget aWidget) { if (aWidget == null) return; if (aContainer == null) throw new Exception ("Adding widget to null container"); aContainer.Add (aWidget); }
void RunInstall (Gtk.Alignment commandBox, Update update) { installing = true; ProgressBarMonitor monitorBar = new ProgressBarMonitor (); monitorBar.ShowErrorsDialog = true; monitorBar.Show (); commandBox.Child.Destroy (); commandBox.Add (monitorBar); IAsyncOperation oper = update.InstallAction (monitorBar.CreateProgressMonitor ()); oper.Completed += delegate { DispatchService.GuiDispatch (delegate { monitorBar.Hide (); Gtk.Label result = new Gtk.Label (); if (oper.Success) result.Text = GettextCatalog.GetString ("Completed"); else result.Text = GettextCatalog.GetString ("Failed"); commandBox.Child.Destroy (); commandBox.Add (result); result.Show (); installing = false; if (installQueue.Count > 0) installQueue.Dequeue ()(); }); }; }
public void InitIE(Gtk.Box w) { wb = new System.Windows.Forms.WebBrowser(); w.SetSizeRequest(500, 500); wb.Height = 500; // w.GdkWindow.FrameExtents.Height; wb.Width = 500; // w.GdkWindow.FrameExtents.Width; wb.Navigate("about:blank"); wb.Document.Write(String.Empty); socket = new Gtk.Socket(); socket.SetSizeRequest(wb.Width, wb.Height); w.Add(socket); socket.Realize(); socket.Show(); socket.UnmapEvent += Socket_UnmapEvent; IntPtr browser_handle = wb.Handle; IntPtr window_handle = (IntPtr)socket.Id; SetParent(browser_handle, window_handle); /// Another interesting issue is that on Windows, the WebBrowser control by default is /// effectively an IE7 browser, and I don't think you can easily change that without /// changing registry settings. The lack of JSON parsing in IE7 triggers errors in google maps. /// See https://code.google.com/p/gmaps-api-issues/issues/detail?id=9004 for the details. /// Including the meta tag of <meta http-equiv="X-UA-Compatible" content="IE=edge"/> /// fixes the problem, but we can't do that in the HTML that we set as InnerHtml in the /// LoadHTML function, as the meta tag triggers a restart of the browser, so it /// just reloads "about:blank", without the new innerHTML, and we get a blank browser. /// Hence we set the browser type here. /// Another way to get around this problem is to add JSON.Parse support available from /// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON /// into the HTML Script added when loading Google Maps /// I am taking the belts-and-braces approach of doing both, primarily because the /// meta tag, while probably the technically better" solution, sometimes doesn't work. wb.DocumentText = @"<!DOCTYPE html> <html> <head> <meta http-equiv=""X-UA-Compatible"" content=""IE=edge,10""/> </head> </html>"; }
private void GetOutputMenu(ref Gtk.Menu outputMenu) { MenuItem miC = new MenuItem(MainClass.Languages.Translate("clear")); miC.Activated+= delegate { OutputConsole.Clear(); }; outputMenu.Add(miC); MenuItem miS = new MenuItem(MainClass.Languages.Translate("save")); miS.Activated+= delegate { OutputConsole.Save(); }; outputMenu.Add(miS); }
private void InsertMode(char item, ref Gtk.Layout vbox, ref int height) { string de = "unknown mode. Refer to ircd manual (/raw help)"; cm.Add(item); if (channel._Network.Descriptions.ContainsKey(item)) { de = channel._Network.Descriptions[item]; } CheckButton xx = new CheckButton(item.ToString() + " : " + de); xx.Active = channel.ChannelMode._Mode.Contains(item.ToString()); xx.Name = item.ToString(); options.Add(xx); vbox.Add(xx); global::Gtk.Layout.LayoutChild w1 = ((global::Gtk.Layout.LayoutChild)(vbox[xx])); w1.X = 0; w1.Y = height; height += 20; }
public override void HandleBuildToolBar(Gtk.Toolbar tb) { base.HandleBuildToolBar(tb); #region Show Arrows //Arrow separator. if (arrowSep == null) { arrowSep = new Gtk.SeparatorToolItem(); showOtherArrowOptions = false; } tb.AppendItem(arrowSep); if (arrowLabel == null) { arrowLabel = new ToolBarLabel(string.Format(" {0}: ", Catalog.GetString("Arrow"))); } tb.AppendItem(arrowLabel); //Show arrow 1. showArrowOneBox = new Gtk.CheckButton("1"); showArrowOneBox.Active = previousSettings1.Show; showArrowOneBox.Toggled += (o, e) => { //Determine whether to change the visibility of Arrow options in the toolbar based on the updated Arrow showing/hiding. if (!showArrowOneBox.Active && !showArrowTwoBox.Active) { if (showOtherArrowOptions) { tb.Remove(arrowSizeLabel); tb.Remove(arrowSizeMinus); tb.Remove(arrowSize); tb.Remove(arrowSizePlus); tb.Remove(arrowAngleOffsetLabel); tb.Remove(arrowAngleOffsetMinus); tb.Remove(arrowAngleOffset); tb.Remove(arrowAngleOffsetPlus); tb.Remove(arrowLengthOffsetLabel); tb.Remove(arrowLengthOffsetMinus); tb.Remove(arrowLengthOffset); tb.Remove(arrowLengthOffsetPlus); showOtherArrowOptions = false; } } else { if (!showOtherArrowOptions) { tb.Add(arrowSizeLabel); tb.Add(arrowSizeMinus); tb.Add(arrowSize); tb.Add(arrowSizePlus); tb.Add(arrowAngleOffsetLabel); tb.Add(arrowAngleOffsetMinus); tb.Add(arrowAngleOffset); tb.Add(arrowAngleOffsetPlus); tb.Add(arrowLengthOffsetLabel); tb.Add(arrowLengthOffsetMinus); tb.Add(arrowLengthOffset); tb.Add(arrowLengthOffsetPlus); showOtherArrowOptions = true; } } LineCurveSeriesEngine activeEngine = (LineCurveSeriesEngine)ActiveShapeEngine; if (activeEngine != null) { activeEngine.Arrow1.Show = showArrowOneBox.Active; DrawActiveShape(false, false, true, false, false); StorePreviousSettings(); } }; tb.AddWidgetItem(showArrowOneBox); //Show arrow 2. showArrowTwoBox = new Gtk.CheckButton("2"); showArrowTwoBox.Active = previousSettings2.Show; showArrowTwoBox.Toggled += (o, e) => { //Determine whether to change the visibility of Arrow options in the toolbar based on the updated Arrow showing/hiding. if (!showArrowOneBox.Active && !showArrowTwoBox.Active) { if (showOtherArrowOptions) { tb.Remove(arrowSizeLabel); tb.Remove(arrowSizeMinus); tb.Remove(arrowSize); tb.Remove(arrowSizePlus); tb.Remove(arrowAngleOffsetLabel); tb.Remove(arrowAngleOffsetMinus); tb.Remove(arrowAngleOffset); tb.Remove(arrowAngleOffsetPlus); tb.Remove(arrowLengthOffsetLabel); tb.Remove(arrowLengthOffsetMinus); tb.Remove(arrowLengthOffset); tb.Remove(arrowLengthOffsetPlus); showOtherArrowOptions = false; } } else { if (!showOtherArrowOptions) { tb.Add(arrowSizeLabel); tb.Add(arrowSizeMinus); tb.Add(arrowSize); tb.Add(arrowSizePlus); tb.Add(arrowAngleOffsetLabel); tb.Add(arrowAngleOffsetMinus); tb.Add(arrowAngleOffset); tb.Add(arrowAngleOffsetPlus); tb.Add(arrowLengthOffsetLabel); tb.Add(arrowLengthOffsetMinus); tb.Add(arrowLengthOffset); tb.Add(arrowLengthOffsetPlus); showOtherArrowOptions = true; } } LineCurveSeriesEngine activeEngine = (LineCurveSeriesEngine)ActiveShapeEngine; if (activeEngine != null) { activeEngine.Arrow2.Show = showArrowTwoBox.Active; DrawActiveShape(false, false, true, false, false); StorePreviousSettings(); } }; tb.AddWidgetItem(showArrowTwoBox); #endregion Show Arrows #region Arrow Size if (arrowSizeLabel == null) { arrowSizeLabel = new ToolBarLabel(string.Format(" {0}: ", Catalog.GetString("Size"))); } if (arrowSizeMinus == null) { arrowSizeMinus = new ToolBarButton("Toolbar.MinusButton.png", "", Catalog.GetString("Decrease arrow size")); arrowSizeMinus.Clicked += new EventHandler(arrowSizeMinus_Clicked); } if (arrowSize == null) { arrowSize = new ToolBarComboBox(65, 7, true, "3", "4", "5", "6", "7", "8", "9", "10", "12", "15", "18", "20", "25", "30", "40", "50", "60", "70", "80", "90", "100"); arrowSize.ComboBox.Changed += (o, e) => { if (arrowSize.ComboBox.ActiveText.Length < 1) { //Ignore the change until the user enters something. return; } else { double newSize = 10d; if (arrowSize.ComboBox.ActiveText == "-") { //The user is trying to enter a negative value: change it to 1. newSize = 1d; } else { if (Double.TryParse(arrowSize.ComboBox.ActiveText, out newSize)) { if (newSize < 1d) { //Less than 1: change it to 1. newSize = 1d; } else if (newSize > 100d) { //Greater than 100: change it to 100. newSize = 100d; } } else { //Not a number: wait until the user enters something. return; } } (arrowSize.ComboBox as Gtk.ComboBoxEntry).Entry.Text = newSize.ToString(); LineCurveSeriesEngine activeEngine = (LineCurveSeriesEngine)ActiveShapeEngine; if (activeEngine != null) { activeEngine.Arrow1.ArrowSize = newSize; activeEngine.Arrow2.ArrowSize = newSize; DrawActiveShape(false, false, true, false, false); StorePreviousSettings(); } } }; } if (arrowSizePlus == null) { arrowSizePlus = new ToolBarButton("Toolbar.PlusButton.png", "", Catalog.GetString("Increase arrow size")); arrowSizePlus.Clicked += new EventHandler(arrowSizePlus_Clicked); } #endregion Arrow Size #region Angle Offset if (arrowAngleOffsetLabel == null) { arrowAngleOffsetLabel = new ToolBarLabel(string.Format(" {0}: ", Catalog.GetString("Angle"))); } if (arrowAngleOffsetMinus == null) { arrowAngleOffsetMinus = new ToolBarButton("Toolbar.MinusButton.png", "", Catalog.GetString("Decrease angle offset")); arrowAngleOffsetMinus.Clicked += new EventHandler(arrowAngleOffsetMinus_Clicked); } if (arrowAngleOffset == null) { arrowAngleOffset = new ToolBarComboBox(65, 9, true, "-30", "-25", "-20", "-15", "-10", "-5", "0", "5", "10", "15", "20", "25", "30"); arrowAngleOffset.ComboBox.Changed += (o, e) => { if (arrowAngleOffset.ComboBox.ActiveText.Length < 1) { //Ignore the change until the user enters something. return; } else if (arrowAngleOffset.ComboBox.ActiveText == "-") { //The user is trying to enter a negative value: ignore the change until the user enters more. return; } else { double newAngle = 15d; if (Double.TryParse(arrowAngleOffset.ComboBox.ActiveText, out newAngle)) { if (newAngle < -89d) { //Less than -89: change it to -89. newAngle = -89d; } else if (newAngle > 89d) { //Greater than 89: change it to 89. newAngle = 89d; } } else { //Not a number: wait until the user enters something. return; } (arrowAngleOffset.ComboBox as Gtk.ComboBoxEntry).Entry.Text = newAngle.ToString(); LineCurveSeriesEngine activeEngine = (LineCurveSeriesEngine)ActiveShapeEngine; if (activeEngine != null) { activeEngine.Arrow1.AngleOffset = newAngle; activeEngine.Arrow2.AngleOffset = newAngle; DrawActiveShape(false, false, true, false, false); StorePreviousSettings(); } } }; } if (arrowAngleOffsetPlus == null) { arrowAngleOffsetPlus = new ToolBarButton("Toolbar.PlusButton.png", "", Catalog.GetString("Increase angle offset")); arrowAngleOffsetPlus.Clicked += new EventHandler(arrowAngleOffsetPlus_Clicked); } #endregion Angle Offset #region Length Offset if (arrowLengthOffsetLabel == null) { arrowLengthOffsetLabel = new ToolBarLabel(string.Format(" {0}: ", Catalog.GetString("Length"))); } if (arrowLengthOffsetMinus == null) { arrowLengthOffsetMinus = new ToolBarButton("Toolbar.MinusButton.png", "", Catalog.GetString("Decrease length offset")); arrowLengthOffsetMinus.Clicked += new EventHandler(arrowLengthOffsetMinus_Clicked); } if (arrowLengthOffset == null) { arrowLengthOffset = new ToolBarComboBox(65, 8, true, "-30", "-25", "-20", "-15", "-10", "-5", "0", "5", "10", "15", "20", "25", "30"); arrowLengthOffset.ComboBox.Changed += (o, e) => { if (arrowLengthOffset.ComboBox.ActiveText.Length < 1) { //Ignore the change until the user enters something. return; } else if (arrowLengthOffset.ComboBox.ActiveText == "-") { //The user is trying to enter a negative value: ignore the change until the user enters more. return; } else { double newLength = 10d; if (Double.TryParse(arrowLengthOffset.ComboBox.ActiveText, out newLength)) { if (newLength < -100d) { //Less than -100: change it to -100. newLength = -100d; } else if (newLength > 100d) { //Greater than 100: change it to 100. newLength = 100d; } } else { //Not a number: wait until the user enters something. return; } (arrowLengthOffset.ComboBox as Gtk.ComboBoxEntry).Entry.Text = newLength.ToString(); LineCurveSeriesEngine activeEngine = (LineCurveSeriesEngine)ActiveShapeEngine; if (activeEngine != null) { activeEngine.Arrow1.LengthOffset = newLength; activeEngine.Arrow2.LengthOffset = newLength; DrawActiveShape(false, false, true, false, false); StorePreviousSettings(); } } }; } if (arrowLengthOffsetPlus == null) { arrowLengthOffsetPlus = new ToolBarButton("Toolbar.PlusButton.png", "", Catalog.GetString("Increase length offset")); arrowLengthOffsetPlus.Clicked += new EventHandler(arrowLengthOffsetPlus_Clicked); } #endregion Length Offset if (showOtherArrowOptions) { tb.Add(arrowSizeLabel); tb.Add(arrowSizeMinus); tb.Add(arrowSize); tb.Add(arrowSizePlus); tb.Add(arrowAngleOffsetLabel); tb.Add(arrowAngleOffsetMinus); tb.Add(arrowAngleOffset); tb.Add(arrowAngleOffsetPlus); tb.Add(arrowLengthOffsetLabel); tb.Add(arrowLengthOffsetMinus); tb.Add(arrowLengthOffset); tb.Add(arrowLengthOffsetPlus); } }
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); } }
private void GetOutputMenu(ref Gtk.Menu outputMenu,ITaskOutput taskOut ) { MenuItem miC = new MenuItem(MainClass.Languages.Translate("clear")); miC.Activated+= delegate { taskOut.ClearOutput(); }; outputMenu.Add(miC); }
void Install (Gtk.Alignment commandBox, Button installButton, Update update) { if (update.InstallAction == null) { DesktopService.ShowUrl (update.Url); return; } installButton.Hide (); if (installing) { Gtk.Label lab = new Gtk.Label (GettextCatalog.GetString ("Waiting")); commandBox.Child.Destroy (); commandBox.Add (lab); lab.Show (); installQueue.Enqueue (delegate { lab.Hide (); RunInstall (commandBox, update); }); return; } RunInstall (commandBox, update); }
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++; } }
protected Gtk.RadioButton AddButton(Gtk.VBox vbox, string label, EventHandler handler) { Gtk.RadioButton btn; if (_groupButton != null) { btn = new Gtk.RadioButton (_groupButton, label); } else { btn = new Gtk.RadioButton (label); _groupButton = btn; btn.Toggle (); btn.Active = true; } btn.Toggled += handler; btn.KeyPressEvent += OnKeyPressEvent; vbox.Add (btn); btn.Show(); return btn; }
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 MenuItem (label); thisInstanceMenuItem.Activated += new ContextActionRunner (fix, document, currentSmartTagBegin).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, this.currentSmartTagBegin).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")); menuItem.Activated += delegate { inspector.DisableOnce (document, arbitraryFixInGroup.DocumentRegion); }; subMenu.Add (menuItem); } if (inspector.CanDisableAndRestore) { var menuItem = new Gtk.MenuItem (GettextCatalog.GetString ("Disable _and Restore")); 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 Rule")); optionsMenuItem.Activated += arbitraryFixInGroup.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; 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++; } }