diff --git a/How-to/Hide-SubMenu-Item-Show-In-MainToolbar/SaveAndPrintButtonInToolbar/App.config b/How-to/Hide-SubMenu-Item-Show-In-MainToolbar/SaveAndPrintButtonInToolbar/App.config new file mode 100644 index 0000000..193aecc --- /dev/null +++ b/How-to/Hide-SubMenu-Item-Show-In-MainToolbar/SaveAndPrintButtonInToolbar/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/How-to/Hide-SubMenu-Item-Show-In-MainToolbar/SaveAndPrintButtonInToolbar/Data/1-output.pdf b/How-to/Hide-SubMenu-Item-Show-In-MainToolbar/SaveAndPrintButtonInToolbar/Data/1-output.pdf new file mode 100644 index 0000000..a10dbed Binary files /dev/null and b/How-to/Hide-SubMenu-Item-Show-In-MainToolbar/SaveAndPrintButtonInToolbar/Data/1-output.pdf differ diff --git a/How-to/Hide-SubMenu-Item-Show-In-MainToolbar/SaveAndPrintButtonInToolbar/Form1.Designer.cs b/How-to/Hide-SubMenu-Item-Show-In-MainToolbar/SaveAndPrintButtonInToolbar/Form1.Designer.cs new file mode 100644 index 0000000..380fe4b --- /dev/null +++ b/How-to/Hide-SubMenu-Item-Show-In-MainToolbar/SaveAndPrintButtonInToolbar/Form1.Designer.cs @@ -0,0 +1,40 @@ +namespace SaveAndPrintButtonInToolbar +{ + partial class Form1 + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(800, 450); + this.Text = "Form1"; + } + + #endregion + } +} + diff --git a/How-to/Hide-SubMenu-Item-Show-In-MainToolbar/SaveAndPrintButtonInToolbar/Form1.cs b/How-to/Hide-SubMenu-Item-Show-In-MainToolbar/SaveAndPrintButtonInToolbar/Form1.cs new file mode 100644 index 0000000..145aba0 --- /dev/null +++ b/How-to/Hide-SubMenu-Item-Show-In-MainToolbar/SaveAndPrintButtonInToolbar/Form1.cs @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using System.Windows.Forms.Integration; + +namespace SaveAndPrintButtonInToolbar +{ + public partial class Form1 : Form + { + ElementHost elementHost = null; + WPFControl wpfControl = null; + public Form1() + { + InitializeComponent(); + this.Load += Form1_Load; + } + + private void Form1_Load(object sender, EventArgs e) + { + elementHost = new ElementHost(); + elementHost.Margin = new Padding(0, 0, 0, 0); + elementHost.Region = new Region(); + elementHost.BackColor = System.Drawing.Color.White; + elementHost.AutoSize = true; + elementHost.Size = this.Size; + elementHost.Dock = DockStyle.Fill; + this.Controls.Add(elementHost); + + wpfControl = new WPFControl(); + elementHost.Child = wpfControl; + + this.WindowState = FormWindowState.Maximized; + } + } +} diff --git a/How-to/Hide-SubMenu-Item-Show-In-MainToolbar/SaveAndPrintButtonInToolbar/Program.cs b/How-to/Hide-SubMenu-Item-Show-In-MainToolbar/SaveAndPrintButtonInToolbar/Program.cs new file mode 100644 index 0000000..e9f7e84 --- /dev/null +++ b/How-to/Hide-SubMenu-Item-Show-In-MainToolbar/SaveAndPrintButtonInToolbar/Program.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace SaveAndPrintButtonInToolbar +{ + internal static class Program + { + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new Form1()); + } + } +} diff --git a/How-to/Hide-SubMenu-Item-Show-In-MainToolbar/SaveAndPrintButtonInToolbar/Properties/AssemblyInfo.cs b/How-to/Hide-SubMenu-Item-Show-In-MainToolbar/SaveAndPrintButtonInToolbar/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..9b3bba5 --- /dev/null +++ b/How-to/Hide-SubMenu-Item-Show-In-MainToolbar/SaveAndPrintButtonInToolbar/Properties/AssemblyInfo.cs @@ -0,0 +1,27 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyDescription("")] +[assembly: AssemblyCopyright("Copyright © 2025")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("26acec63-620b-4bec-a209-f40ddf2da60e")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// diff --git a/How-to/Hide-SubMenu-Item-Show-In-MainToolbar/SaveAndPrintButtonInToolbar/Properties/Resources.Designer.cs b/How-to/Hide-SubMenu-Item-Show-In-MainToolbar/SaveAndPrintButtonInToolbar/Properties/Resources.Designer.cs new file mode 100644 index 0000000..9e85b96 --- /dev/null +++ b/How-to/Hide-SubMenu-Item-Show-In-MainToolbar/SaveAndPrintButtonInToolbar/Properties/Resources.Designer.cs @@ -0,0 +1,71 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace SaveAndPrintButtonInToolbar.Properties +{ + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources + { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() + { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager + { + get + { + if ((resourceMan == null)) + { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("SaveAndPrintButtonInToolbar.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture + { + get + { + return resourceCulture; + } + set + { + resourceCulture = value; + } + } + } +} diff --git a/How-to/Hide-SubMenu-Item-Show-In-MainToolbar/SaveAndPrintButtonInToolbar/Properties/Resources.resx b/How-to/Hide-SubMenu-Item-Show-In-MainToolbar/SaveAndPrintButtonInToolbar/Properties/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/How-to/Hide-SubMenu-Item-Show-In-MainToolbar/SaveAndPrintButtonInToolbar/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/How-to/Hide-SubMenu-Item-Show-In-MainToolbar/SaveAndPrintButtonInToolbar/Properties/Settings.Designer.cs b/How-to/Hide-SubMenu-Item-Show-In-MainToolbar/SaveAndPrintButtonInToolbar/Properties/Settings.Designer.cs new file mode 100644 index 0000000..8b3d5f0 --- /dev/null +++ b/How-to/Hide-SubMenu-Item-Show-In-MainToolbar/SaveAndPrintButtonInToolbar/Properties/Settings.Designer.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace SaveAndPrintButtonInToolbar.Properties +{ + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/How-to/Hide-SubMenu-Item-Show-In-MainToolbar/SaveAndPrintButtonInToolbar/Properties/Settings.settings b/How-to/Hide-SubMenu-Item-Show-In-MainToolbar/SaveAndPrintButtonInToolbar/Properties/Settings.settings new file mode 100644 index 0000000..3964565 --- /dev/null +++ b/How-to/Hide-SubMenu-Item-Show-In-MainToolbar/SaveAndPrintButtonInToolbar/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/How-to/Hide-SubMenu-Item-Show-In-MainToolbar/SaveAndPrintButtonInToolbar/SaveAndPrintButtonInToolbar.csproj b/How-to/Hide-SubMenu-Item-Show-In-MainToolbar/SaveAndPrintButtonInToolbar/SaveAndPrintButtonInToolbar.csproj new file mode 100644 index 0000000..6dda7cf --- /dev/null +++ b/How-to/Hide-SubMenu-Item-Show-In-MainToolbar/SaveAndPrintButtonInToolbar/SaveAndPrintButtonInToolbar.csproj @@ -0,0 +1,97 @@ + + + + + Debug + AnyCPU + {26ACEC63-620B-4BEC-A209-F40DDF2DA60E} + WinExe + SaveAndPrintButtonInToolbar + SaveAndPrintButtonInToolbar + v4.8 + 512 + true + true + + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + + + + Form + + + Form1.cs + + + + + WPFControl.xaml + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + + + + Designer + MSBuild:Compile + + + + \ No newline at end of file diff --git a/How-to/Hide-SubMenu-Item-Show-In-MainToolbar/SaveAndPrintButtonInToolbar/SaveAndPrintButtonInToolbar.sln b/How-to/Hide-SubMenu-Item-Show-In-MainToolbar/SaveAndPrintButtonInToolbar/SaveAndPrintButtonInToolbar.sln new file mode 100644 index 0000000..d376c07 --- /dev/null +++ b/How-to/Hide-SubMenu-Item-Show-In-MainToolbar/SaveAndPrintButtonInToolbar/SaveAndPrintButtonInToolbar.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.12.35707.178 d17.12 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SaveAndPrintButtonInToolbar", "SaveAndPrintButtonInToolbar.csproj", "{26ACEC63-620B-4BEC-A209-F40DDF2DA60E}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {26ACEC63-620B-4BEC-A209-F40DDF2DA60E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {26ACEC63-620B-4BEC-A209-F40DDF2DA60E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {26ACEC63-620B-4BEC-A209-F40DDF2DA60E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {26ACEC63-620B-4BEC-A209-F40DDF2DA60E}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/How-to/Hide-SubMenu-Item-Show-In-MainToolbar/SaveAndPrintButtonInToolbar/SaveAndPrintButtonInToolbar_NET.csproj b/How-to/Hide-SubMenu-Item-Show-In-MainToolbar/SaveAndPrintButtonInToolbar/SaveAndPrintButtonInToolbar_NET.csproj new file mode 100644 index 0000000..83cb700 --- /dev/null +++ b/How-to/Hide-SubMenu-Item-Show-In-MainToolbar/SaveAndPrintButtonInToolbar/SaveAndPrintButtonInToolbar_NET.csproj @@ -0,0 +1,16 @@ + + + + WinExe + net8.0-windows + enable + true + true + enable + + + + + + + \ No newline at end of file diff --git a/How-to/Hide-SubMenu-Item-Show-In-MainToolbar/SaveAndPrintButtonInToolbar/SaveAndPrintButtonInToolbar_NET.sln b/How-to/Hide-SubMenu-Item-Show-In-MainToolbar/SaveAndPrintButtonInToolbar/SaveAndPrintButtonInToolbar_NET.sln new file mode 100644 index 0000000..78df4c0 --- /dev/null +++ b/How-to/Hide-SubMenu-Item-Show-In-MainToolbar/SaveAndPrintButtonInToolbar/SaveAndPrintButtonInToolbar_NET.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.12.35707.178 d17.12 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SaveAndPrintButtonInToolbar_NET", "SaveAndPrintButtonInToolbar_NET.csproj", "{3A296036-3264-41FA-9FB0-2269642BD986}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {3A296036-3264-41FA-9FB0-2269642BD986}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3A296036-3264-41FA-9FB0-2269642BD986}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3A296036-3264-41FA-9FB0-2269642BD986}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3A296036-3264-41FA-9FB0-2269642BD986}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/How-to/Hide-SubMenu-Item-Show-In-MainToolbar/SaveAndPrintButtonInToolbar/WPFControl.xaml b/How-to/Hide-SubMenu-Item-Show-In-MainToolbar/SaveAndPrintButtonInToolbar/WPFControl.xaml new file mode 100644 index 0000000..80690b0 --- /dev/null +++ b/How-to/Hide-SubMenu-Item-Show-In-MainToolbar/SaveAndPrintButtonInToolbar/WPFControl.xaml @@ -0,0 +1,59 @@ + + + + + + + diff --git a/How-to/Hide-SubMenu-Item-Show-In-MainToolbar/SaveAndPrintButtonInToolbar/WPFControl.xaml.cs b/How-to/Hide-SubMenu-Item-Show-In-MainToolbar/SaveAndPrintButtonInToolbar/WPFControl.xaml.cs new file mode 100644 index 0000000..e1169c3 --- /dev/null +++ b/How-to/Hide-SubMenu-Item-Show-In-MainToolbar/SaveAndPrintButtonInToolbar/WPFControl.xaml.cs @@ -0,0 +1,145 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; +using Button = System.Windows.Controls.Button; +using System.Windows.Controls.Primitives; +using Path = System.Windows.Shapes.Path; +using Syncfusion.Windows.PdfViewer; +using System.IO; +using UserControl = System.Windows.Controls.UserControl; + +namespace SaveAndPrintButtonInToolbar +{ + /// + /// Interaction logic for WPFControl.xaml + /// + public partial class WPFControl : UserControl + { + string filePath; + private Button saveAsButton; + private Button printButton; + public WPFControl() + { + InitializeComponent(); + } + + private void UserControl_Loaded(object sender, RoutedEventArgs e) + { +#if NETCOREAPP + filePath = @"../../../Data/1-output.pdf"; +#else + filePath = @"../../Data/1-output.pdf"; +#endif + pdfViewer.Load(filePath); + pdfViewer.Loaded += PdfViewer_Loaded; + pdfViewer.DocumentLoaded += PdfViewer_DocumentLoaded; + pdfViewer.DocumentUnloaded += PdfViewer_DocumentUnloaded; + } + + private void PdfViewer_DocumentUnloaded(object sender, EventArgs e) + { + saveAsButton.IsEnabled = false; + printButton.IsEnabled = true; + } + + private void PdfViewer_DocumentLoaded(object sender, EventArgs args) + { + saveAsButton.IsEnabled = true; + printButton.IsEnabled = true; + } + + private void SaveAsButton_Click(object sender, RoutedEventArgs e) + { + Microsoft.Win32.SaveFileDialog save = new Microsoft.Win32.SaveFileDialog(); + save.Filter = "PDF Files (*.pdf)|*.pdf"; + if (save.ShowDialog() == true) + { + FileInfo saveFi = new FileInfo(save.FileName); + if (save.FileName != string.Empty) + { + pdfViewer.LoadedDocument.Save(save.FileName); + System.Windows.MessageBox.Show("File saved succesfully"); + } + } + } + + private void PrintButton_Click(object sender, RoutedEventArgs e) + { + pdfViewer.Print(); + } + + private void PdfViewer_Loaded(object sender, RoutedEventArgs e) + { + DocumentToolbar toolbar = pdfViewer.Template.FindName("PART_Toolbar", pdfViewer) as DocumentToolbar; + Button signatureButton = (Button)toolbar.Template.FindName("PART_ButtonSignature", toolbar); + signatureButton.Visibility = Visibility.Collapsed; + Button searchButton = (Button)toolbar.Template.FindName("PART_ButtonTextSearch", toolbar); + searchButton.Visibility = Visibility.Collapsed; + ToggleButton annotationsButton = (ToggleButton)toolbar.Template.FindName("PART_Annotations", toolbar); + annotationsButton.Visibility = Visibility.Collapsed; + ToggleButton FileButton = (ToggleButton)toolbar.Template.FindName("PART_FileToggleButton", toolbar); + + ContextMenu FileContextMenu = FileButton.ContextMenu; + foreach (MenuItem FileMenuItem in FileContextMenu.Items) + { + if (FileMenuItem.Name == "PART_OpenMenuItem") + FileMenuItem.Visibility = Visibility.Collapsed; + if (FileMenuItem.Name == "PART_SaveAsMenuItem") + FileMenuItem.Visibility = Visibility.Collapsed; + if (FileMenuItem.Name == "PART_PrintMenuItem") + FileMenuItem.Visibility = Visibility.Collapsed; + } + saveAsButton = new Button(); + saveAsButton.Height = 25; + saveAsButton.Width = 25; + Path saveAsPath = new Path + { + Data = Geometry.Parse("M10.919004,9.5349956 L12.456006,11.068996 7.5370017,15.999999 6.0000001,15.999999 6.0000001,14.466998 z M12.631999,8.0000043 C12.736498,8.0000043 12.840998,8.0397506 12.920998,8.1192422 L13.879993,9.076138 C14.039991,9.2361207 14.039991,9.493093 13.879993,9.6530757 L13.129996,10.400995 11.593004,8.8681607 12.343,8.1192422 C12.423,8.0397506 12.527499,8.0000043 12.631999,8.0000043 z M7.0000001,4.7683714E-07 L9.0000001,4.7683714E-07 9.0000001,3.0000005 7.0000001,3.0000005 z M0.99999999,0 L4.0000001,0 4.0000001,3.9999943 10,3.9999943 10,0 10.287994,0 14,3.2020049 14,7.7830009 13.626007,7.4099994 C13.358994,7.1460071 13.007004,6.9999957 12.632004,6.9999957 12.255997,6.9999957 11.901993,7.1460071 11.636993,7.4110065 L10.921997,8.1240048 10.916,8.1209989 10.039993,8.9999967 1.9999999,8.9999967 1.9999999,13.999999 5.0540009,13.999999 5.0000001,14.054 5.0000001,16 0.99999999,16 C0.44700628,16 5.2262678E-08,15.553009 0,15 L0,1.0000004 C5.2262678E-08,0.44799826 0.44700628,0 0.99999999,0 z"), // Example shape + Width = 20, + Height = 20, + Style = (Style)this.pdfViewer.FindResource("MenuIconStyle"), + Stretch = Stretch.Uniform, // Set the stretch mode + }; + saveAsButton.Style = (Style)this.pdfViewer.FindResource("newButtonStyle"); + saveAsButton.Content = saveAsPath; + saveAsButton.Click += SaveAsButton_Click; ; + saveAsButton.ToolTip = "SaveAs"; + saveAsButton.BorderThickness = new Thickness(0); + saveAsButton.Margin = new Thickness(10, 0, 0, 0); + + printButton = new Button(); + printButton.Height = 25; + printButton.Width = 25; + Path printPath = new Path + { + Data = Geometry.Parse("F1M235.967,99.88L229.46,99.88L229.46,96.688L235.967,96.688z M229.46,84.563L235.967,84.563L235.967,86.793L229.46,86.793z M241.783,86.793L237.046,86.793L237.046,83.371L228.361,83.371L228.361,86.793L223.783,86.793L223.783,96.688L228.361,96.688L228.361,101.072L237.046,101.072L237.046,96.688L241.783,96.688z"), // Example shape + Width = 20, + Height = 20, + Style = (Style)this.pdfViewer.FindResource("MenuIconStyle"), + Stretch = Stretch.Uniform, // Set the stretch mode + }; + printButton.Content = printPath; + printButton.Style = (Style)this.pdfViewer.FindResource("newButtonStyle"); + printButton.Click += PrintButton_Click; ; + printButton.ToolTip = "Print"; + printButton.BorderThickness = new Thickness(0); + printButton.Margin = new Thickness(10, 0, 0, 0); + + StackPanel stackPanel = (StackPanel)toolbar.Template.FindName("PART_FileMenuStack", toolbar); + + stackPanel.Children.Insert(1, printButton); + stackPanel.Children.Insert(1, saveAsButton); + } + } +} diff --git a/How-to/Hide-SubMenu-Item-Show-In-MainToolbar/SaveAndPrintButtonInToolbar/packages.config b/How-to/Hide-SubMenu-Item-Show-In-MainToolbar/SaveAndPrintButtonInToolbar/packages.config new file mode 100644 index 0000000..d6e73f2 --- /dev/null +++ b/How-to/Hide-SubMenu-Item-Show-In-MainToolbar/SaveAndPrintButtonInToolbar/packages.config @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file