protected virtual void Compose() { BoldButton = new ToolbarButton { IsCheckable = true }; BoldCommand = new CommandView { Action = s => ToggleAttribute <FontWeightTextAttribute> ( (a, bold) => a.Weight = (bold ? FontWeight.Bold : FontWeight.Normal), BoldButton), Image = Iconery.FontBoldIcon, Size = DefaultSize, ToolTipText = "Bold" }; BoldButton.SetCommand(BoldCommand); ItalicButton = new ToolbarButton { IsCheckable = true }; ItalicCommand = new CommandView { Action = s => ToggleAttribute <FontStyleTextAttribute> ( (a, italic) => a.Style = (italic ? FontStyle.Italic : FontStyle.Normal), ItalicButton), Image = Iconery.FontItalicIcon, Size = DefaultSize, ToolTipText = "Italic" }; ItalicButton.SetCommand(ItalicCommand); StrikeThroughButton = new ToolbarButton { IsCheckable = true }; StrikeThroughCommand = new CommandView { Action = s => ToggleAttribute <StrikethroughTextAttribute> ( (a, value) => a.Strikethrough = value, StrikeThroughButton), Image = Iconery.FontStrikeThroughIcon, Size = DefaultSize, ToolTipText = "StrikeThrough" }; StrikeThroughButton.SetCommand(StrikeThroughCommand); UnderlineButton = new ToolbarButton { IsCheckable = true }; UnderlineCommand = new CommandView { Action = s => ToggleAttribute <UnderlineTextAttribute> ( (a, value) => a.Underline = value, UnderlineButton), Image = Iconery.FontUnderlineIcon, Size = DefaultSize, ToolTipText = "Underline" }; UnderlineButton.SetCommand(UnderlineCommand); FontFamilyCombo = new ComboBox { Width = 100 }; Font.AvailableFontFamilies.ForEach(f => FontFamilyCombo.Items.Add(f)); FontFamilyCombo.SelectionChanged += (s, e) => { var attr = new FontDataAttribute { FontFamily = FontFamilyCombo.SelectedItem as string }; TextViewer.SetAttribute(attr); }; var fontFamilyComboHost = new ToolbarItemHost { Child = FontFamilyCombo }; FontSizeCombo = new ComboBox { Width = 50 }; new int[] { 6, 8, 10, 12, 14, 16, 18, 24, 32 } .ForEach(s => FontSizeCombo.Items.Add(s.ToString())); FontSizeCombo.SelectionChanged += (s, e) => { var i = -1d; if (FontSizeCombo.SelectedItem != null && double.TryParse(FontSizeCombo.SelectedItem.ToString(), out i)) { var attr = new FontDataAttribute { FontSize = i }; TextViewer.SetAttribute(attr); } }; var fontSizeComboHost = new ToolbarItemHost { Child = FontSizeCombo }; this.AddItems(BoldButton, ItalicButton, UnderlineButton, StrikeThroughButton, fontFamilyComboHost, fontSizeComboHost); }
protected virtual void Compose() { var size = new Xwt.Size(36, 36); GraphStreamViewCommand = new CommandView { Action = s => ViewMode = SplitView.ViewMode = SplitViewMode.GraphContent, Image = Iconery.GraphContentView, Size = size, ToolTipText = "show contents" }; GraphGraphViewCommand = new CommandView { Action = s => ViewMode = SplitView.ViewMode = SplitViewMode.GraphGraph, Image = Iconery.GraphGraphView, Size = size, ToolTipText = "show tiled graph" }; ToggleViewCommand = new CommandView { Action = s => SplitView.ToggleView(), Image = Iconery.ToggleView, Size = size, ToolTipText = "toogle view" }; OpenNewWindowCommand = new CommandView { Action = s => SplitView.ShowInNewWindow(), Image = Iconery.NewViewVisualNote, Size = size, ToolTipText = "open new window" }; Action <bool> goBackOrForward = backOrForward => { if (SplitView.CanGoBackOrForward(backOrForward)) { SplitView.GoBackOrForward(backOrForward); CheckBackForward(SplitView); } }; GoBackCommand = new CommandView { Action = s => goBackOrForward(false), Image = Iconery.GoPrevious, Size = size, ToolTipText = "navigate back" }; GoForwardCommand = new CommandView { Action = s => goBackOrForward(true), Image = Iconery.GoNext, Size = size, ToolTipText = "navigate forward" }; GoHomeCommand = new CommandView { Action = s => SplitView.GoHome(), Image = Iconery.GoHome, Size = size, ToolTipText = "go to favorites" }; NewSheetCommand = new CommandView { Action = s => SplitView.NewSheet(), Image = Iconery.NewSheet, Size = size, ToolTipText = "new sheet" }; NewNoteCommand = new CommandView { Action = s => SplitView.NewNote(), Image = Iconery.NewNote, Size = size, ToolTipText = "new note" }; SaveSheetCommand = new CommandView { Action = s => SplitView.SaveDocument(), Image = Iconery.SaveContent, Size = size, ToolTipText = "save content" }; GraphStreamViewButton = new ToolbarButton(GraphStreamViewCommand) { IsCheckable = true }; GraphGraphViewButton = new ToolbarButton(GraphGraphViewCommand) { IsCheckable = true }; var toggleViewButton = new ToolbarButton(ToggleViewCommand); var newWindowButton = new ToolbarButton(OpenNewWindowCommand); GoBackButton = new ToolbarButton(GoBackCommand); GoForwardButton = new ToolbarButton(GoForwardCommand); var goHomeButton = new ToolbarButton(GoHomeCommand); var newSheetButton = new ToolbarButton(NewSheetCommand); var newNoteButton = new ToolbarButton(NewNoteCommand); var saveSheetButton = new ToolbarButton(SaveSheetCommand); SheetCombo = new ComboBox { Width = 100 }; var sheetComboHost = new ToolbarItemHost() { Child = SheetCombo }; this.AddItems( sheetComboHost, saveSheetButton, new ToolbarSeparator(), GraphStreamViewButton, GraphGraphViewButton, toggleViewButton, new ToolbarSeparator(), GoBackButton, GoForwardButton, goHomeButton, new ToolbarSeparator(), newSheetButton, newNoteButton, newWindowButton, new ToolbarSeparator() ); }