private void OnChangeFont(object sender, EventArgs e) { try { if (fontDialog != null) { fontDialog.Destroy(); } fontDialog = new FontSelectionDialog("Select a font"); // Center the dialog on the main window. fontDialog.TransientFor = MainWidget as Window; fontDialog.WindowPosition = WindowPosition.CenterOnParent; // Select the current font. if (Utility.Configuration.Settings.FontName != null) { fontDialog.SetFontName(Utility.Configuration.Settings.EditorFontName.ToString()); } // Event handlers. fontDialog.OkButton.Clicked += OnFontSelected; fontDialog.OkButton.Clicked += OnDestroyFontDialog; fontDialog.ApplyButton.Clicked += OnFontSelected; fontDialog.CancelButton.Clicked += OnDestroyFontDialog; // Show the dialog. fontDialog.ShowAll(); } catch (Exception err) { ShowError(err); } }
protected void On_FontAction_Activated(object sender, EventArgs e) { FontSelectionDialog fontDlg = new FontSelectionDialog("Select Your Font"); fontDlg.PreviewText = "样例字体 Example Text"; //if click ok if (fontDlg.Run() == (int)ResponseType.Ok) { //get fontDesc Pango.FontDescription selectFont = Pango.FontDescription.FromString(fontDlg.FontName); //set font font_tag.FontDesc = selectFont; //if user selected some text //change selected text font //else change all text font TextIter start, end; if (TextView.Buffer.GetSelectionBounds(out start, out end)) { TextView.Buffer.ApplyTag(font_tag, start, end); } else { TextView.ModifyFont(selectFont); } } //detory window fontDlg.Destroy(); }
/// <summary> /// Shows the font selection dialog. /// </summary> public void ShowFontChooser() { string title = "Select a font"; #if NETFRAMEWORK fontDialog = new FontSelectionDialog(title); #else fontDialog = new FontChooserDialog(title, window1); #endif // Center the dialog on the main window. fontDialog.TransientFor = MainWidget as Window; fontDialog.WindowPosition = WindowPosition.CenterOnParent; // Select the current font. if (Utility.Configuration.Settings.FontName != null) { fontDialog.SetFontName(Utility.Configuration.Settings.FontName.ToString()); } #if NETFRAMEWORK fontDialog.Response += OnChangeFont; //fontDialog.OkButton.Clicked += OnChangeFont; #else //fontDialog.FontActivated += OnChangeFont; fontDialog.Response += OnChangeFont; #endif // Show the dialog. fontDialog.ShowAll(); }
public void SetUp() => Schedule(() => { var language = new Bindable <FontUsage>(new FontUsage()); Child = dialog = new FontSelectionDialog { Current = language, }; });
public FontChooserPanelWidget() { this.Build(); foreach (var desc in FontService.FontDescriptions) { selectedFonts [desc.Name] = FontService.GetUnderlyingFontName(desc.Name); var fontNameLabel = new Label(GettextCatalog.GetString(desc.DisplayName)); fontNameLabel.Justify = Justification.Left; fontNameLabel.Xalign = 0; mainBox.PackStart(fontNameLabel, false, false, 0); var hBox = new HBox(); var setFontButton = new Button(); setFontButton.Label = FontService.FilterFontName(GetFont(desc.Name)); var descStr = GettextCatalog.GetString("Set the font options for {0}", GettextCatalog.GetString(desc.DisplayName)); setFontButton.Accessible.Description = descStr; setFontButton.Clicked += delegate { var selectionDialog = new FontSelectionDialog(GettextCatalog.GetString("Select Font")) { Modal = true, DestroyWithParent = true, TransientFor = this.Toplevel as Gtk.Window }; MonoDevelop.Components.IdeTheme.ApplyTheme(selectionDialog); try { string fontValue = FontService.FilterFontName(GetFont(desc.Name)); selectionDialog.SetFontName(fontValue); if (MessageService.RunCustomDialog(selectionDialog) != (int)Gtk.ResponseType.Ok) { return; } fontValue = selectionDialog.FontName; if (fontValue == FontService.FilterFontName(FontService.GetFont(desc.Name).FontDescription)) { fontValue = FontService.GetFont(desc.Name).FontDescription; } SetFont(desc.Name, fontValue); setFontButton.Label = selectionDialog.FontName; } finally { selectionDialog.Destroy(); selectionDialog.Dispose(); } }; hBox.PackStart(setFontButton, true, true, 0); var setDefaultFontButton = new Button(); setDefaultFontButton.Label = GettextCatalog.GetString("Set To Default"); setDefaultFontButton.Clicked += delegate { SetFont(desc.Name, FontService.GetFont(desc.Name).FontDescription); setFontButton.Label = FontService.FilterFontName(GetFont(desc.Name)); }; hBox.PackStart(setDefaultFontButton, false, false, 0); mainBox.PackStart(hBox, false, false, 0); } mainBox.ShowAll(); }
protected void OnFuenteActionActivated(object sender, EventArgs e) { FontSelectionDialog Fuente = new FontSelectionDialog("Fuente"); if (Fuente.Run() == (int)ResponseType.Ok) { Editor.Formato_de_Texto(Fuente.FontName); Fuente.Destroy(); } Fuente.Destroy(); }
public void OnFontActivate(object o, EventArgs args) { string fontname = null; FontSelectionDialog openFontSelection = new FontSelectionDialog("RSVP Font"); openFontSelection.SetFontName(fontName); openFontSelection.Run(); fontname = openFontSelection.FontName; fontName = fontname; ShowWord(curWord); openFontSelection.Destroy(); }
void CreateFontWidget() { var font = new Button(Stock.SelectFont); font.Clicked += delegate { var fs = new FontSelectionDialog(_("Select Font")); fs.Run(); fs.Hide(); }; AttachAligned(0, 2, _("Font:"), 0.0, 0.5, font, 1, true); }
public void SetUp() => Schedule(() => { var language = new BindableFontUsage(new FontUsage()) { MinFontSize = 32, MaxFontSize = 72 }; Child = dialog = new FontSelectionDialog { Current = language, }; });
public void OnSettingsSelectFont(object sender, EventArgs args) { FontSelectionDialog fsd = new FontSelectionDialog("Select Font"); try { fsd.SetFontName(Font); if (fsd.Run() == (int)Gtk.ResponseType.Ok) { Font = fsd.FontName; } } finally { fsd.Destroy(); } }
protected void OnFontAction1Activated(object sender, EventArgs e) { FontSelectionDialog font = new FontSelectionDialog("Select font name"); font.Response += delegate(object o, ResponseArgs resp) { if (resp.ResponseId == ResponseType.Ok) { Pango.FontDescription fontsel = Pango.FontDescription.FromString(font.FontName); textview1.ModifyFont(fontsel); } }; font.Run(); font.Destroy(); }
protected virtual void OnPipeFontBrowseButtonClicked(object sender, System.EventArgs e) { FontSelectionDialog FontDlg = new FontSelectionDialog("Select Pipe Font"); FontDlg.SetFontName(PipeFont); try { if (FontDlg.Run() == (int)ResponseType.Ok) { PipeFont = FontDlg.FontName; } } finally { FontDlg.Destroy(); } }
protected void changeFont(object o, EventArgs e) { FontSelectionDialog d = new FontSelectionDialog("FONT!"); d.SetFontName(settings.font); if ((ResponseType)d.Run() == ResponseType.Ok) { for (int i = 0; i < notebook.NPages; i++) { ((TextView)((ScrolledWindow)notebook.GetNthPage(i)).Child).ModifyFont(Pango.FontDescription.FromString(d.FontName)); } } settings.font = d.FontName; d.Destroy(); settings.save(); tree.ModifyFont(Pango.FontDescription.FromString(settings.font)); return; }
/// <summary> /// Shows the font selection dialog. /// </summary> public void ShowFontChooser() { fontDialog = new FontSelectionDialog("Select a font"); // Center the dialog on the main window. fontDialog.TransientFor = MainWidget as Window; fontDialog.WindowPosition = WindowPosition.CenterOnParent; // Select the current font. if (Utility.Configuration.Settings.Font != null) { fontDialog.SetFontName(Utility.Configuration.Settings.Font.ToString()); } // Event handlers. fontDialog.OkButton.Clicked += OnChangeFont; fontDialog.OkButton.Clicked += OnDestroyFontDialog; fontDialog.ApplyButton.Clicked += OnChangeFont; fontDialog.CancelButton.Clicked += OnDestroyFontDialog; // Show the dialog. fontDialog.ShowAll(); }
public FontSelectionButton() { AutoSizeAxes = Axes.Y; InternalChild = new GridContainer { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, ColumnDimensions = new[] { new Dimension(GridSizeMode.Distributed), new Dimension(GridSizeMode.Absolute, 5), new Dimension(GridSizeMode.Absolute, height), new Dimension(GridSizeMode.Absolute, 5), new Dimension(GridSizeMode.Absolute, height), }, RowDimensions = new[] { new Dimension(GridSizeMode.AutoSize) }, Content = new[] { new[] { fontButton = new TriangleButton { RelativeSizeAxes = Axes.X, Height = height, Action = () => { try { var displayContainer = Game.GetDisplayContainer(); if (displayContainer == null) { return; } // Should only has one instance. var dialog = displayContainer.Children.OfType <FontSelectionDialog>().FirstOrDefault(); if (dialog == null) { displayContainer.Add(dialog = new FontSelectionDialog()); } dialog.Current = Current; dialog?.Show(); } catch { // maybe this overlay has been moved into internal. } } }, null, new TriangleButton { RelativeSizeAxes = Axes.X, Height = height, Text = "-", Action = () => { var currentSize = current.Value.Size; var sizes = FontUtils.DefaultFontSize(); var nextSize = sizes.Reverse().FirstOrDefault(x => x < currentSize); if (nextSize == 0) { return; } current.Value = current.Value.With(size: nextSize); } }, null, new TriangleButton { RelativeSizeAxes = Axes.X, Height = height, Text = "+", Action = () => { var currentSize = current.Value.Size; var sizes = FontUtils.DefaultFontSize(); var nextSize = sizes.FirstOrDefault(x => x > currentSize); if (nextSize == 0) { return; } current.Value = current.Value.With(size: nextSize); } } }, } }; Current.BindValueChanged(e => { var font = e.NewValue; var family = font.Family ?? "[Unknown font]"; var weight = string.IsNullOrEmpty(font.Weight) ? $"-{font.Weight}" : ""; var size = FontUtils.GetText(font.Size); var fixedWidthText = font.FixedWidth ? "(fixed width)" : ""; var displayText = $"{family}{weight}, {size} {fixedWidthText}"; fontButton.Text = displayText; }); }
public FontChooserPanelWidget() { this.Build(); fontStore = new TreeStore(typeof(string), typeof(string), typeof(string)); treeviewFonts.Model = fontStore; treeviewFonts.AppendColumn(GettextCatalog.GetString("Name"), textRenderer, "text", colDisplayName); comboRenderer.Edited += delegate(object o, Gtk.EditedArgs args) { TreeIter iter; if (!fontStore.GetIterFromString(out iter, args.Path)) { return; } string fontName = (string)fontStore.GetValue(iter, colName); if (args.NewText == GettextCatalog.GetString("Default")) { SetFont(fontName, FontService.GetFont(fontName).FontDescription); fontStore.SetValue(iter, colValue, GettextCatalog.GetString("Default")); return; } var selectionDialog = new FontSelectionDialog(GettextCatalog.GetString("Select Font")); string fontValue = FontService.FilterFontName(GetFont(fontName)); selectionDialog.SetFontName(fontValue); selectionDialog.OkButton.Clicked += delegate { fontValue = selectionDialog.FontName; if (fontValue == FontService.FilterFontName(FontService.GetFont(fontName).FontDescription)) { fontValue = FontService.GetFont(fontName).FontDescription; } SetFont(fontName, fontValue); fontStore.SetValue(iter, colValue, selectionDialog.FontName); }; MessageService.ShowCustomDialog(selectionDialog); selectionDialog.Destroy(); }; comboRenderer.EditingStarted += delegate(object o, EditingStartedArgs args) { TreeIter iter; if (!fontStore.GetIterFromString(out iter, args.Path)) { return; } string fontName = (string)fontStore.GetValue(iter, colName); string fontValue = GetFont(fontName); comboBoxStore.Clear(); if (fontValue != FontService.GetFont(fontName).FontDescription) { comboBoxStore.AppendValues(fontValue); } comboBoxStore.AppendValues(GettextCatalog.GetString("Default")); comboBoxStore.AppendValues(GettextCatalog.GetString("Edit...")); }; var fontCol = new TreeViewColumn(); fontCol.Title = GettextCatalog.GetString("Font"); comboRenderer.HasEntry = false; comboRenderer.Mode = CellRendererMode.Activatable; comboRenderer.TextColumn = 0; comboRenderer.Editable = true; fontCol.PackStart(comboRenderer, true); fontCol.SetCellDataFunc(comboRenderer, delegate(Gtk.TreeViewColumn tree_column, Gtk.CellRenderer cell, Gtk.TreeModel model, Gtk.TreeIter iter) { string fontValue = (string)fontStore.GetValue(iter, colValue); string fontName = (string)fontStore.GetValue(iter, colName); var d = FontService.GetFont(fontName); if (d == null || d.FontDescription != fontValue) { comboRenderer.Text = fontValue; } else { comboRenderer.Text = GettextCatalog.GetString("Default"); } }); treeviewFonts.AppendColumn(fontCol); comboBoxStore = new ListStore(typeof(string)); comboRenderer.Model = comboBoxStore; LoadFonts(); }
public SelectFontDialogBackend () { dlg = new FontSelectionDialog (null); defaultTitle = dlg.Title; defaultPreviewText = dlg.PreviewText; }
public SelectFontDialogBackend() { dlg = new FontSelectionDialog(null); defaultTitle = dlg.Title; defaultPreviewText = dlg.PreviewText; }