├── .editoricon.png
├── .gitignore
├── .nuget
├── NuGet.Config
└── NuGet.targets
├── CHANGELOG.md
├── LICENSE
├── README.md
├── RibbonGenerator.Console
├── ConsoleMessageOutput.cs
├── Program.cs
├── RibbonGenerator.Console.csproj
└── app.config
├── RibbonGenerator
├── FaildException.cs
├── IMessageOutput.cs
├── Manager.cs
├── Properties
│ └── AssemblyInfo.cs
├── ResXReader.cs
├── RibbonGenerator.csproj
├── RibbonGenerator.snk
├── Target.cs
├── Template.bat
├── Util.cs
└── VsMessageOutput.cs
├── RibbonLib.Sample
├── App.config
├── FormMain.Designer.cs
├── FormMain.cs
├── FormMain.resx
├── Program.cs
├── Properties
│ ├── AssemblyInfo.cs
│ ├── Resources.Designer.cs
│ ├── Resources.resx
│ ├── Settings.Designer.cs
│ └── Settings.settings
├── Resources
│ ├── Advanced32.bmp
│ ├── Drop16.bmp
│ ├── Drop32.bmp
│ ├── Exit16.bmp
│ ├── Exit32.bmp
│ ├── New16.bmp
│ ├── New32.bmp
│ ├── Open16.bmp
│ ├── Open32.bmp
│ ├── Save16.bmp
│ ├── Save32.bmp
│ ├── Simple32.bmp
│ ├── dropA32.bmp
│ ├── dropB32.bmp
│ └── dropC32.bmp
├── RibbonLib.Sample.csproj
├── RibbonMarkup.ribbon
├── RibbonMarkup.xml
└── packages.config
├── RibbonLib.sln
└── RibbonLib
├── ColorHelper.cs
├── Controls
├── BaseRibbonControl.cs
├── Events
│ ├── BaseEventsProvider.cs
│ ├── ExecuteEventArgs.cs
│ ├── ExecuteEventsProvider.cs
│ ├── IEventsProvider.cs
│ └── PreviewEventsProvider.cs
├── Properties
│ ├── BasePropertiesProvider.cs
│ ├── BooleanValuePropertyProvider.cs
│ ├── ColorPickerPropertiesProvider.cs
│ ├── ContextAvailablePropertiesProvider.cs
│ ├── EnabledPropertiesProvider.cs
│ ├── FontControlPropertiesProvider.cs
│ ├── GalleryPropertiesProvider.cs
│ ├── IPropertiesProvider.cs
│ ├── ImagePropertiesProvider.cs
│ ├── KeytipPropertiesProvider.cs
│ ├── LabelDescriptionPropertiesProvider.cs
│ ├── LabelPropertiesProvider.cs
│ ├── RecentItemsPropertiesProvider.cs
│ ├── RepresentativeStringPropertiesProvider.cs
│ ├── SpinnerPropertiesProvider.cs
│ ├── StringValueProperiesProvider.cs
│ └── TooltipPropertiesProvider.cs
├── RibbonApplicationMenu.cs
├── RibbonButton.cs
├── RibbonCheckBox.cs
├── RibbonComboBox.cs
├── RibbonDropDownButton.cs
├── RibbonDropDownColorPicker.cs
├── RibbonDropDownGallery.cs
├── RibbonFontControl.cs
├── RibbonGroup.cs
├── RibbonHelpButton.cs
├── RibbonInRibbonGallery.cs
├── RibbonMenuGroup.cs
├── RibbonQuickAccessToolbar.cs
├── RibbonRecentItems.cs
├── RibbonSpinner.cs
├── RibbonSplitButton.cs
├── RibbonSplitButtonGallery.cs
├── RibbonTab.cs
├── RibbonTabGroup.cs
└── RibbonToggleButton.cs
├── Design
└── ResourceFileNameEditor.cs
├── FontPropertyStore.cs
├── GalleryCommandPropertySet.cs
├── GalleryItemPropertySet.cs
├── IRibbonControl.cs
├── IRibbonForm.cs
├── Interop
├── CommonCOMInterfaces.cs
├── PropVariant.cs
├── PropertyKey.cs
├── RibbonCOMClasses.cs
├── RibbonCOMGuids.cs
├── RibbonCOMInterfaces.cs
├── RibbonProperties.cs
└── StreamAdapter.cs
├── Package.nuspec
├── Properties
├── AssemblyInfo.Common.cs
└── AssemblyInfo.cs
├── RecentItemsPropertySet.cs
├── Ribbon.cs
├── Ribbon.snk
├── RibbonLib.csproj
├── RibbonLib.targets
├── RibbonMarkup.ribbon
├── RibbonMarkup.xml
├── RibbonMarkup.xml.transform
├── RibbonShortcutTable.cs
├── RibbonUIApplication.cs
├── UICollection.cs
├── UICollectionChangedEvent.cs
├── UICollectionChangedEventArgs.cs
└── Util.cs
/.editoricon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ennerperez/RibbonLib/edba0c761a9542d102d9770071f1ff24a712a53e/.editoricon.png
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 |
4 | # User-specific files
5 | *.suo
6 | *.user
7 | *.userosscache
8 | *.sln.docstates
9 |
10 | # User-specific files (MonoDevelop/Xamarin Studio)
11 | *.userprefs
12 |
13 | # Build results
14 | [Dd]ebug/
15 | [Dd]ebugPublic/
16 | [Rr]elease/
17 | [Rr]eleases/
18 | x64/
19 | x86/
20 | bld/
21 | [Bb]in/
22 | [Oo]bj/
23 |
24 | # Visual Studio 2015 cache/options directory
25 | .vs/
26 | # Uncomment if you have tasks that create the project's static files in wwwroot
27 | #wwwroot/
28 |
29 | # MSTest test Results
30 | [Tt]est[Rr]esult*/
31 | [Bb]uild[Ll]og.*
32 |
33 | # NUNIT
34 | *.VisualState.xml
35 | TestResult.xml
36 |
37 | # Build Results of an ATL Project
38 | [Dd]ebugPS/
39 | [Rr]eleasePS/
40 | dlldata.c
41 |
42 | # DNX
43 | project.lock.json
44 | artifacts/
45 |
46 | *_i.c
47 | *_p.c
48 | *_i.h
49 | *.ilk
50 | *.meta
51 | *.obj
52 | *.pch
53 | *.pdb
54 | *.pgc
55 | *.pgd
56 | *.rsp
57 | *.sbr
58 | *.tlb
59 | *.tli
60 | *.tlh
61 | *.tmp
62 | *.tmp_proj
63 | *.log
64 | *.vspscc
65 | *.vssscc
66 | .builds
67 | *.pidb
68 | *.svclog
69 | *.scc
70 |
71 | # Chutzpah Test files
72 | _Chutzpah*
73 |
74 | # Visual C++ cache files
75 | ipch/
76 | *.aps
77 | *.ncb
78 | *.opendb
79 | *.opensdf
80 | *.sdf
81 | *.cachefile
82 |
83 | # Visual Studio profiler
84 | *.psess
85 | *.vsp
86 | *.vspx
87 | *.sap
88 |
89 | # TFS 2012 Local Workspace
90 | $tf/
91 |
92 | # Guidance Automation Toolkit
93 | *.gpState
94 |
95 | # ReSharper is a .NET coding add-in
96 | _ReSharper*/
97 | *.[Rr]e[Ss]harper
98 | *.DotSettings.user
99 |
100 | # JustCode is a .NET coding add-in
101 | .JustCode
102 |
103 | # TeamCity is a build add-in
104 | _TeamCity*
105 |
106 | # DotCover is a Code Coverage Tool
107 | *.dotCover
108 |
109 | # NCrunch
110 | _NCrunch_*
111 | .*crunch*.local.xml
112 | nCrunchTemp_*
113 |
114 | # MightyMoose
115 | *.mm.*
116 | AutoTest.Net/
117 |
118 | # Web workbench (sass)
119 | .sass-cache/
120 |
121 | # Installshield output folder
122 | [Ee]xpress/
123 |
124 | # DocProject is a documentation generator add-in
125 | DocProject/buildhelp/
126 | DocProject/Help/*.HxT
127 | DocProject/Help/*.HxC
128 | DocProject/Help/*.hhc
129 | DocProject/Help/*.hhk
130 | DocProject/Help/*.hhp
131 | DocProject/Help/Html2
132 | DocProject/Help/html
133 |
134 | # Click-Once directory
135 | publish/
136 |
137 | # Publish Web Output
138 | *.[Pp]ublish.xml
139 | *.azurePubxml
140 | # TODO: Comment the next line if you want to checkin your web deploy settings
141 | # but database connection strings (with potential passwords) will be unencrypted
142 | *.pubxml
143 | *.publishproj
144 |
145 | # NuGet Packages
146 | *.nupkg
147 | # The packages folder can be ignored because of Package Restore
148 | **/packages/*
149 | # except build/, which is used as an MSBuild target.
150 | !**/packages/build/
151 | # Uncomment if necessary however generally it will be regenerated when needed
152 | #!**/packages/repositories.config
153 | # NuGet v3's project.json files produces more ignoreable files
154 | *.nuget.props
155 | *.nuget.targets
156 | .nuget/NuGet.exe
157 |
158 | # Microsoft Azure Build Output
159 | csx/
160 | *.build.csdef
161 |
162 | # Microsoft Azure Emulator
163 | ecf/
164 | rcf/
165 |
166 | # Microsoft Azure ApplicationInsights config file
167 | ApplicationInsights.config
168 |
169 | # Windows Store app package directory
170 | AppPackages/
171 | BundleArtifacts/
172 |
173 | # Visual Studio cache files
174 | # files ending in .cache can be ignored
175 | *.[Cc]ache
176 | # but keep track of directories ending in .cache
177 | !*.[Cc]ache/
178 |
179 | # Others
180 | ClientBin/
181 | ~$*
182 | *~
183 | *.dbmdl
184 | *.dbproj.schemaview
185 | *.pfx
186 | *.publishsettings
187 | node_modules/
188 | orleans.codegen.cs
189 |
190 | # RIA/Silverlight projects
191 | Generated_Code/
192 |
193 | # Backup & report files from converting an old project file
194 | # to a newer Visual Studio version. Backup files are not needed,
195 | # because we have git ;-)
196 | _UpgradeReport_Files/
197 | Backup*/
198 | UpgradeLog*.XML
199 | UpgradeLog*.htm
200 |
201 | # SQL Server files
202 | *.mdf
203 | *.ldf
204 |
205 | # Business Intelligence projects
206 | *.rdl.data
207 | *.bim.layout
208 | *.bim_*.settings
209 |
210 | # Microsoft Fakes
211 | FakesAssemblies/
212 |
213 | # GhostDoc plugin setting file
214 | *.GhostDoc.xml
215 |
216 | # Node.js Tools for Visual Studio
217 | .ntvs_analysis.dat
218 |
219 | # Visual Studio 6 build log
220 | *.plg
221 |
222 | # Visual Studio 6 workspace options file
223 | *.opt
224 |
225 | # Visual Studio LightSwitch build output
226 | **/*.HTMLClient/GeneratedArtifacts
227 | **/*.DesktopClient/GeneratedArtifacts
228 | **/*.DesktopClient/ModelManifest.xml
229 | **/*.Server/GeneratedArtifacts
230 | **/*.Server/ModelManifest.xml
231 | _Pvt_Extensions
232 |
233 | # Paket dependency manager
234 | .paket/paket.exe
235 |
236 | # FAKE - F# Make
237 | .fake/
238 |
--------------------------------------------------------------------------------
/.nuget/NuGet.Config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Changelog
2 | All notable changes to this project will be documented in this file.
3 | This project adheres to [Semantic Versioning](http://semver.org/).
4 |
5 | ## [2.7.9] - [2016-05-25]
6 | ### Changed
7 | - Minor fixes
8 |
9 | ## [2.7.0] - [2016-05-25]
10 | ### Changed
11 | - NuGet Package
12 | - Integrated generator
13 | - Project cleaning
14 |
15 | ## [2.6.0] - [Obsolete]
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Microsoft Public License (Ms-PL)
2 | Microsoft Public License (Ms-PL)
3 |
4 | This license governs use of the accompanying software. If you use the software, you accept this license. If you do
5 | not accept the license, do not use the software.
6 |
7 | 1. Definitions
8 |
9 | The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning here as
10 | under U.S. copyright law.
11 |
12 | A "contribution" is the original software, or any additions or changes to the software.
13 |
14 | A "contributor" is any person that distributes its contribution under this license.
15 |
16 | "Licensed patents" are a contributor's patent claims that read directly on its contribution.
17 |
18 | 2. Grant of Rights
19 |
20 | (A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations
21 | in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to reproduce its
22 | contribution, prepare derivative works of its contribution, and distribute its contribution or any derivative works
23 | that you create.
24 |
25 | (B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in section 3,
26 | each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed patents to make,
27 | have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution in the software or
28 | derivative works of the contribution in the software.
29 |
30 | 3. Conditions and Limitations
31 |
32 | (A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or
33 | trademarks.
34 |
35 | (B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software,
36 | your patent license from such contributor to the software ends automatically.
37 |
38 | (C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution
39 | notices that are present in the software.
40 |
41 | (D) If you distribute any portion of the software in source code form, you may do so only under this license by
42 | including a complete copy of this license with your distribution. If you distribute any portion of the software in
43 | compiled or object code form, you may only do so under a license that complies with this license.
44 |
45 | (E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties,
46 | guarantees or conditions. You may have additional consumer rights under your local laws which this license cannot
47 | change. To the extent permitted under your local laws, the contributors exclude the implied warranties of
48 | merchantability, fitness for a particular purpose and non-infringement.
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | 
2 |
3 | # Windows Ribbon for WinForms
4 |
5 | Windows Ribbon for WinForms is a .NET wrapper for Windows Ribbon control.
6 | It will allow WinForms developers to use Microsoft Windows Ribbon control in their WinForms applications.
7 |
8 | The project includes the library RibbonLib, which adds support for Windows Ribbon to WinForms application.
9 |
10 | - Original based from [Windows Ribbon for WinForms](https://windowsribbon.codeplex.com/) by [Arik Poznanski](https://github.com/arikpoz)
11 |
12 | [](https://ci.appveyor.com/project/ennerperez/ribbonlib)
13 | [](https://www.nuget.org/packages/RibbonLib/)
14 |
15 | ---------------------------------------
16 |
17 | See the [changelog](CHANGELOG.md) for changes.
18 |
19 | ## Table of contents
20 |
21 | * [Implementing](#implementing)
22 | * [Bugs and feature requests](#bugs-and-feature-requests)
23 | * [Documentation](#documentation)
24 | * [License](#license)
25 |
26 | ### Implementing
27 |
28 | **Add the library to your project**
29 |
30 | Add the [NuGet Package](https://www.nuget.org/packages/RibbonLib/). Right click on your project and click 'Manage NuGet Packages...'. Search for 'RibbonLib' and click on install. Once installed the library will be included in your project references. (Or install it through the package manager console: PM> Install-Package RibbonLib).
31 |
32 | ### Bugs and feature requests
33 |
34 | Have a bug or a feature request? Please first search for existing and closed issues. If your problem or idea is not addressed yet, [please open a new issue](https://github.com/ennerperez/RibbonLib/issues/new).
35 |
36 | ### Documentation
37 |
38 | No more documentation required for now.
39 |
40 | ### License
41 |
42 | Code released under [Microsoft Public License (Ms-PL)](LICENSE)
--------------------------------------------------------------------------------
/RibbonGenerator.Console/ConsoleMessageOutput.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace RibbonGenerator.Console
7 | {
8 | ///
9 | /// Writes the output to the console window.
10 | ///
11 | class ConsoleMessageOutput : IMessageOutput
12 | {
13 | #region IOutput Members
14 |
15 | public void WriteLine(string value)
16 | {
17 | System.Console.WriteLine(value);
18 | }
19 |
20 | #endregion
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/RibbonGenerator.Console/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.IO;
6 | using System.Globalization;
7 |
8 | namespace RibbonGenerator.Console
9 | {
10 | class Program
11 | {
12 | static void Main(string[] args)
13 | {
14 | if (args.Length == 0)
15 | return;
16 |
17 | try
18 | {
19 | string fileName = args[0];
20 | string content = File.ReadAllText(fileName);
21 | Manager manager = new Manager(new ConsoleMessageOutput(), fileName, content);
22 |
23 | var targets = manager.Targets;
24 | foreach (var target in targets)
25 | {
26 | var buffer = manager.CreateRibbon(target);
27 | File.WriteAllBytes(target.RibbonFilename, buffer);
28 | }
29 | }
30 | catch (Exception ex)
31 | {
32 | System.Console.Error.WriteLine(ex.Message);
33 | }
34 |
35 | #if DEBUG
36 | System.Console.ReadKey();
37 | #endif
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/RibbonGenerator.Console/RibbonGenerator.Console.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | x86
7 | 8.0.30703
8 | 2.0
9 | {1E12E24D-CF2E-411D-8650-282DA9B864A9}
10 | Exe
11 | Properties
12 | RibbonGenerator.Console
13 | rgc
14 | v4.0
15 |
16 |
17 | 512
18 |
19 |
20 | true
21 | bin\Debug\
22 | DEBUG;TRACE
23 | full
24 | AnyCPU
25 | prompt
26 | MinimumRecommendedRules.ruleset
27 |
28 |
29 | bin\Release\
30 | TRACE;CONSOLE
31 | true
32 | pdbonly
33 | AnyCPU
34 | prompt
35 | MinimumRecommendedRules.ruleset
36 | false
37 |
38 |
39 | true
40 |
41 |
42 | ..\RibbonGenerator\RibbonGenerator.snk
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 | Properties\AssemblyInfo.cs
56 |
57 |
58 | Properties\AssemblyInfo.Common.cs
59 |
60 |
61 |
62 |
63 |
64 |
65 | RibbonGenerator.snk
66 |
67 |
68 |
69 |
70 |
71 | {7C88C713-78FF-4580-A32D-D9623F3AD2E4}
72 | RibbonGenerator
73 |
74 |
75 |
76 |
83 |
--------------------------------------------------------------------------------
/RibbonGenerator.Console/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/RibbonGenerator/FaildException.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace RibbonGenerator
7 | {
8 | public class FaildException : Exception
9 | {
10 | public FaildException(string message) : base(message) { }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/RibbonGenerator/IMessageOutput.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace RibbonGenerator
7 | {
8 | ///
9 | /// Common interface to forward message output for console and visual studio custom tool
10 | ///
11 | public interface IMessageOutput
12 | {
13 | void WriteLine(string value);
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/RibbonGenerator/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 |
9 | #if !CONSOLE
10 | [assembly: AssemblyTitle("RibbonGenerator")]
11 | [assembly: AssemblyDescription("Windows Ribbon Generator for WinForms")]
12 | [assembly: AssemblyProduct("RibbonGenerator")]
13 |
14 | // The following GUID is for the ID of the typelib if this project is exposed to COM
15 | [assembly: Guid("efa281c1-4e2f-486d-ac0c-ceea2ae85f9d")]
16 | #else
17 |
18 | [assembly: AssemblyTitle("RibbonGenerator Console")]
19 | [assembly: AssemblyDescription("Windows Ribbon Generator Console for WinForms")]
20 | [assembly: AssemblyProduct("RibbonGenerator Console")]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("1ac2aef2-e8b7-4663-a481-fc65bf4e618b")]
24 | #endif
25 |
26 | // Version information for an assembly consists of the following four values:
27 | //
28 | // Major Version
29 | // Minor Version
30 | // Build Number
31 | // Revision
32 | //
33 | // You can specify all the values or you can default the Build and Revision Numbers
34 | // by using the '*' as shown below:
35 | // [assembly: AssemblyVersion("1.0.*")]
36 | [assembly: AssemblyVersion("1.1.0.*")]
37 | [assembly: AssemblyFileVersion("1.1.0.0")]
--------------------------------------------------------------------------------
/RibbonGenerator/ResXReader.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Xml.XPath;
6 | using System.Xml;
7 | using System.Globalization;
8 |
9 | namespace RibbonGenerator
10 | {
11 | public class ResXReader
12 | {
13 | List _targets;
14 | Dictionary _navigators = new Dictionary();
15 |
16 | Target _currentTarget;
17 | Target _fallBackTarget;
18 | Target _defaultTarget;
19 |
20 | public ResXReader(List targets)
21 | {
22 | _targets = targets;
23 | foreach (var target in _targets)
24 | {
25 | var navigator = new XPathDocument(target.ResourceFilename).CreateNavigator();
26 | _navigators.Add(target, navigator);
27 | }
28 | }
29 |
30 | public void SetCulture(string cultureName)
31 | {
32 | _currentTarget = null;
33 | _fallBackTarget = null;
34 | if (!string.IsNullOrEmpty(cultureName))
35 | {
36 | var culture = new CultureInfo(cultureName);
37 | _currentTarget = _targets.FirstOrDefault(t => t.CultureName == cultureName);
38 |
39 | var parentCulture = culture.Parent;
40 |
41 | if (parentCulture != null && !string.IsNullOrEmpty(parentCulture.Name))
42 | {
43 | var parentCultureName = parentCulture.Name;
44 | _fallBackTarget = _targets.FirstOrDefault(t => t.CultureName == parentCultureName);
45 | }
46 | }
47 |
48 | _defaultTarget = _targets.FirstOrDefault(t => string.IsNullOrEmpty(t.CultureName));
49 | }
50 |
51 | public string GetString(string key)
52 | {
53 | XPathNavigator valueNavigator = null;
54 |
55 | if (_currentTarget != null)
56 | {
57 | var navigator = _navigators[_currentTarget];
58 | valueNavigator = GetValue(navigator, key);
59 | }
60 |
61 | // check fallback resource
62 | if (valueNavigator == null && _fallBackTarget != null)
63 | {
64 | var navigator = _navigators[_fallBackTarget];
65 | valueNavigator = GetValue(navigator, key);
66 | }
67 |
68 | // use default resource
69 | if (valueNavigator == null)
70 | {
71 | var navigator = _navigators[_defaultTarget];
72 | valueNavigator = GetValue(navigator, key);
73 | }
74 |
75 | // put out messages here if no value exists
76 | //if (valueNavigator == null)
77 | // throw new Exception(string.Format("no value found for key '{0}'!", );
78 |
79 | if (valueNavigator == null)
80 | return null;
81 |
82 | var result = valueNavigator.Value;
83 | return result;
84 | }
85 |
86 | private XPathNavigator GetValue(XPathNavigator navigator, string key)
87 | {
88 | var query = string.Format("//root/data[@name='{0}']/value", key);
89 | var result = navigator.SelectSingleNode(query);
90 | return result;
91 | }
92 | }
93 | }
94 |
--------------------------------------------------------------------------------
/RibbonGenerator/RibbonGenerator.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | 8.0.30703
8 | 2.0
9 | {7C88C713-78FF-4580-A32D-D9623F3AD2E4}
10 | Library
11 | Properties
12 | RibbonGenerator
13 | RibbonGenerator
14 | v4.0
15 | 512
16 |
17 |
18 |
19 | true
20 | full
21 | false
22 | bin\Debug\
23 | DEBUG;TRACE
24 | prompt
25 | 4
26 | false
27 | false
28 |
29 |
30 | pdbonly
31 | true
32 | bin\Release\
33 | TRACE
34 | prompt
35 | 4
36 | AnyCPU
37 | false
38 |
39 |
40 | true
41 |
42 |
43 | RibbonGenerator.snk
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 | Properties\AssemblyInfo.Common.cs
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
81 |
--------------------------------------------------------------------------------
/RibbonGenerator/RibbonGenerator.snk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ennerperez/RibbonLib/edba0c761a9542d102d9770071f1ff24a712a53e/RibbonGenerator/RibbonGenerator.snk
--------------------------------------------------------------------------------
/RibbonGenerator/Target.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace RibbonGenerator
7 | {
8 | public class Target
9 | {
10 | public string CultureName { get; set; }
11 | public string ResourceFilename { get; set; }
12 | public string RibbonFilename { get; set; }
13 | public bool Localize { get; set; }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/RibbonGenerator/Template.bat:
--------------------------------------------------------------------------------
1 | "{Windows7SDKToolsPath}UICC.exe" "{XmlFilename}" "{BmlFilename}" /res:"{RcFilename}"
2 | "{Windows7SDKToolsPath}rc.exe" /v "{RcFilename}"
3 | cmd /c "("%VS140COMNTOOLS%..\..\VC\bin\vcvars32.bat") && ("%VS140COMNTOOLS%..\..\VC\bin\link.exe" /VERBOSE /NOENTRY /DLL /OUT:"{DllFilename}" "{ResFilename}")"
--------------------------------------------------------------------------------
/RibbonGenerator/Util.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.IO;
6 | using System.Reflection;
7 | using Microsoft.Win32;
8 |
9 | namespace RibbonGenerator
10 | {
11 | ///
12 | /// Contains helper methods
13 | ///
14 | public static class Util
15 | {
16 | static Util()
17 | {
18 | // delete log file if file is bigger than...
19 | try
20 | {
21 | FileInfo info = new FileInfo(LogFile);
22 | if (info.Length > 1024 * 512)
23 | File.Delete(LogFile);
24 | }
25 | catch { }
26 | }
27 |
28 | ///
29 | /// Writes a message to the log file
30 | ///
31 | /// the message
32 | public static void LogMessage(string message)
33 | {
34 | string content = string.Format("{0} - {1}\r\n", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), message);
35 | File.AppendAllText(LogFile, content);
36 | }
37 | ///
38 | /// Writes a message to the log file
39 | ///
40 | /// the message
41 | /// the args(look at string format for more info)
42 | public static void LogMessage(string message, params object[] args)
43 | {
44 | LogMessage(string.Format(message, args));
45 | }
46 | ///
47 | /// Writes an exception to the log file
48 | ///
49 | ///
50 | public static void LogError(Exception ex)
51 | {
52 | string value = string.Format("{0}\r\n{1}", ex.Message, ex.ToString());
53 | LogMessage(value);
54 | }
55 | ///
56 | /// Contains the log filename
57 | ///
58 | static string _logFile;
59 | ///
60 | /// Gets the log filename. For example: C:\Users\\AppData\Local\RibbonGenerator\RibbonGenerator.log
61 | ///
62 | public static string LogFile
63 | {
64 | get
65 | {
66 | if (_logFile == null)
67 | _logFile = Path.Combine(GeneratorLocalAppData, "RibbonGenerator.log");
68 | return _logFile;
69 | }
70 | }
71 |
72 | ///
73 | /// Gets the local app data path for ribbongenerator. For example: C:\Users\\AppData\Local\RibbonGenerator\
74 | ///
75 | public static string GeneratorLocalAppData
76 | {
77 | get
78 | {
79 | string localAppData = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
80 | string path = Path.Combine(localAppData, "RibbonGenerator");
81 | if (!Directory.Exists(path))
82 | Directory.CreateDirectory(path);
83 | return path;
84 | }
85 | }
86 | ///
87 | /// Contains the template bat filename. For example: C:\Users\\AppData\Local\RibbonGenerator\Template.bat
88 | ///
89 | static string _templateBatFilename;
90 | ///
91 | /// Gets the template bat filename. For example: C:\Users\\AppData\Local\RibbonGenerator\Template.bat.
92 | ///
93 | public static string TemplateBatFilename
94 | {
95 | get
96 | {
97 | if (_templateBatFilename == null)
98 | {
99 | string template = Path.Combine(GeneratorLocalAppData, "Template.bat");
100 | var uri = new Uri(template);
101 | _templateBatFilename = uri.LocalPath;
102 | }
103 |
104 | return _templateBatFilename;
105 | }
106 | }
107 |
108 | public static string DetectAppropariateWindows7SdkPath()
109 | {
110 | RegistryKey hklm = Environment.Is64BitOperatingSystem
111 | ? RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64)
112 | : Registry.LocalMachine;
113 |
114 | var winSdkKey = hklm.OpenSubKey(@"SOFTWARE\Microsoft\Microsoft SDKs\Windows");
115 |
116 | // if no windows sdk is installed return default path
117 | if (winSdkKey == null)
118 | return DEFAULTWINDOWS7SDKPATH;
119 |
120 | var versions = winSdkKey.GetSubKeyNames();
121 | var desc = from s in versions
122 | orderby s descending
123 | select s;
124 |
125 | // search folder that contains uicc.exe to verify windows 7 sdk path
126 | string sdkToolsPath = null;
127 | foreach (var version in desc)
128 | {
129 | var versionKeyName = string.Format(@"SOFTWARE\Microsoft\Microsoft SDKs\Windows\{0}", version);
130 | var sdkToolsKey = hklm.OpenSubKey(versionKeyName);
131 | if (sdkToolsKey == null)
132 | continue;
133 | var installationFolder = sdkToolsKey.GetValue("InstallationFolder");
134 | if (installationFolder == null)
135 | continue;
136 | var uiccexePath = Path.Combine((string)installationFolder, "bin", "UICC.exe");
137 | if (File.Exists(uiccexePath))
138 | {
139 | sdkToolsPath = Path.Combine((string)installationFolder, "bin");
140 | break;
141 | }
142 | }
143 |
144 | // if no path found return default path
145 | if (sdkToolsPath == null)
146 | sdkToolsPath = DEFAULTWINDOWS7SDKPATH;
147 |
148 | if (!sdkToolsPath.EndsWith("\\"))
149 | sdkToolsPath += "\\";
150 | return sdkToolsPath;
151 | }
152 |
153 | public static string DEFAULTWINDOWS7SDKPATH = string.Format( @"%PROGRAMFILES{0}%\Microsoft SDKs\Windows\v7.1A\Bin\", Environment.Is64BitOperatingSystem ? "(x86)": "");
154 | }
155 | }
156 |
--------------------------------------------------------------------------------
/RibbonGenerator/VsMessageOutput.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Diagnostics;
6 | using System.IO;
7 |
8 | namespace RibbonGenerator
9 | {
10 | ///
11 | /// Used in custom tool. Write the output to a stream.
12 | ///
13 | class VsMessageOutput : IMessageOutput, IDisposable
14 | {
15 | StringWriter _writer = new StringWriter();
16 |
17 | public string GetOutput()
18 | {
19 | var result = _writer.ToString();
20 | return result;
21 | }
22 |
23 | #region IMessageOutput Members
24 |
25 | public void WriteLine(string value)
26 | {
27 | Trace.WriteLine(value);
28 | _writer.WriteLine(value);
29 | }
30 |
31 | #endregion
32 |
33 | #region IDisposable Members
34 |
35 | public void Dispose()
36 | {
37 | _writer.Dispose();
38 | }
39 |
40 | #endregion
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/RibbonLib.Sample/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/RibbonLib.Sample/FormMain.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace Sample
2 | {
3 | partial class FormMain
4 | {
5 | ///
6 | /// Variable del diseñador necesaria.
7 | ///
8 | private System.ComponentModel.IContainer components = null;
9 |
10 | ///
11 | /// Limpiar los recursos que se estén usando.
12 | ///
13 | /// true si los recursos administrados se deben desechar; false en caso contrario.
14 | protected override void Dispose(bool disposing)
15 | {
16 | if (disposing && (components != null))
17 | {
18 | components.Dispose();
19 | }
20 | base.Dispose(disposing);
21 | }
22 |
23 | #region Código generado por el Diseñador de Windows Forms
24 |
25 | ///
26 | /// Método necesario para admitir el Diseñador. No se puede modificar
27 | /// el contenido de este método con el editor de código.
28 | ///
29 | private void InitializeComponent()
30 | {
31 | this.propertyGrid1 = new System.Windows.Forms.PropertyGrid();
32 | this._ribbon = new RibbonLib.Ribbon();
33 | this.SuspendLayout();
34 | //
35 | // propertyGrid1
36 | //
37 | this.propertyGrid1.Dock = System.Windows.Forms.DockStyle.Right;
38 | this.propertyGrid1.Location = new System.Drawing.Point(517, 100);
39 | this.propertyGrid1.Name = "propertyGrid1";
40 | this.propertyGrid1.SelectedObject = this._ribbon;
41 | this.propertyGrid1.Size = new System.Drawing.Size(267, 461);
42 | this.propertyGrid1.TabIndex = 1;
43 | //
44 | // ribbon
45 | //
46 | this._ribbon.Location = new System.Drawing.Point(0, 0);
47 | this._ribbon.Minimized = false;
48 | this._ribbon.Name = "ribbon";
49 | this._ribbon.ResourceName = "Sample.RibbonMarkup.ribbon";
50 | this._ribbon.ShortcutTableResourceName = null;
51 | this._ribbon.Size = new System.Drawing.Size(784, 100);
52 | this._ribbon.TabIndex = 0;
53 | //
54 | // FormMain
55 | //
56 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
57 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
58 | this.ClientSize = new System.Drawing.Size(784, 561);
59 | this.Controls.Add(this.propertyGrid1);
60 | this.Controls.Add(this._ribbon);
61 | this.Name = "FormMain";
62 | this.Text = "Form1";
63 | this.ResumeLayout(false);
64 |
65 | }
66 |
67 | #endregion
68 |
69 | private System.Windows.Forms.PropertyGrid propertyGrid1;
70 | private RibbonLib.Ribbon _ribbon;
71 | }
72 | }
73 |
74 |
--------------------------------------------------------------------------------
/RibbonLib.Sample/FormMain.cs:
--------------------------------------------------------------------------------
1 | using RibbonLib.Controls;
2 | using RibbonLib.Controls.Events;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.ComponentModel;
6 | using System.Data;
7 | using System.Drawing;
8 | using System.Linq;
9 | using System.Text;
10 | using System.Threading.Tasks;
11 | using System.Windows.Forms;
12 |
13 | namespace Sample
14 | {
15 | public enum RibbonMarkupCommands : uint
16 | {
17 | cmdTabMain = 1001,
18 | cmdGroupCommon = 1002,
19 | cmdGroupSimple = 1003,
20 | cmdGroupAdvanced = 1004,
21 | cmdButtonNew = 1005,
22 | cmdButtonOpen = 1006,
23 | cmdButtonSave = 1007,
24 | cmdButtonDropA = 1008,
25 | cmdButtonDropB = 1009,
26 | cmdButtonDropC = 1010,
27 | cmdButtonSwitchToAdvanced = 1011,
28 | cmdButtonSwitchToSimple = 1012,
29 | cmdMenuGroupFile = 10051,
30 | cmdMenuGroupExit = 10061,
31 | cmdDropDownButton = 10071,
32 | cmdButtonExit= 10041,
33 |
34 | }
35 |
36 | public partial class FormMain : Form
37 | {
38 |
39 | private RibbonTab _tabMain;
40 | private RibbonGroup _groupCommon;
41 | private RibbonGroup _groupSimple;
42 | private RibbonGroup _groupAdvanced;
43 | private RibbonButton _buttonNew;
44 | private RibbonButton _buttonOpen;
45 | private RibbonButton _buttonSave;
46 | private RibbonButton _buttonDropA;
47 | private RibbonButton _buttonDropB;
48 | private RibbonButton _buttonDropC;
49 | private RibbonButton _buttonSwitchToAdvanced;
50 | private RibbonButton _buttonSwitchToSimple;
51 |
52 | private RibbonButton _buttonExit;
53 |
54 | public FormMain()
55 | {
56 |
57 | InitializeComponent();
58 | _tabMain = new RibbonTab(_ribbon, (uint)RibbonMarkupCommands.cmdTabMain);
59 | _groupCommon = new RibbonGroup(_ribbon, (uint)RibbonMarkupCommands.cmdGroupCommon);
60 | _groupSimple = new RibbonGroup(_ribbon, (uint)RibbonMarkupCommands.cmdGroupSimple);
61 | _groupAdvanced = new RibbonGroup(_ribbon, (uint)RibbonMarkupCommands.cmdGroupAdvanced);
62 | _buttonNew = new RibbonButton(_ribbon, (uint)RibbonMarkupCommands.cmdButtonNew);
63 | _buttonOpen = new RibbonButton(_ribbon, (uint)RibbonMarkupCommands.cmdButtonOpen);
64 | _buttonSave = new RibbonButton(_ribbon, (uint)RibbonMarkupCommands.cmdButtonSave);
65 | _buttonDropA = new RibbonButton(_ribbon, (uint)RibbonMarkupCommands.cmdButtonDropA);
66 | _buttonDropB = new RibbonButton(_ribbon, (uint)RibbonMarkupCommands.cmdButtonDropB);
67 | _buttonDropC = new RibbonButton(_ribbon, (uint)RibbonMarkupCommands.cmdButtonDropC);
68 | _buttonSwitchToAdvanced = new RibbonButton(_ribbon, (uint)RibbonMarkupCommands.cmdButtonSwitchToAdvanced);
69 | _buttonSwitchToSimple = new RibbonButton(_ribbon, (uint)RibbonMarkupCommands.cmdButtonSwitchToSimple);
70 |
71 | _buttonExit = new RibbonButton(_ribbon, (uint)RibbonMarkupCommands.cmdButtonExit);
72 |
73 | _buttonSwitchToAdvanced.ExecuteEvent += new EventHandler(_buttonSwitchToAdvanced_ExecuteEvent);
74 | _buttonSwitchToSimple.ExecuteEvent += new EventHandler(_buttonSwitchToSimple_ExecuteEvent);
75 |
76 | _buttonExit.ExecuteEvent += _buttonExit_ExecuteEvent;
77 | }
78 |
79 | private void _buttonExit_ExecuteEvent(object sender, ExecuteEventArgs e)
80 | {
81 | Environment.Exit(0);
82 | }
83 |
84 | void _buttonSwitchToAdvanced_ExecuteEvent(object sender, ExecuteEventArgs e)
85 | {
86 | _ribbon.SetModes(1);
87 | }
88 |
89 | void _buttonSwitchToSimple_ExecuteEvent(object sender, ExecuteEventArgs e)
90 | {
91 | _ribbon.SetModes(0);
92 | }
93 |
94 | }
95 | }
96 |
--------------------------------------------------------------------------------
/RibbonLib.Sample/FormMain.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
--------------------------------------------------------------------------------
/RibbonLib.Sample/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Threading.Tasks;
5 | using System.Windows.Forms;
6 |
7 | namespace Sample
8 | {
9 | static class Program
10 | {
11 | ///
12 | /// Punto de entrada principal para la aplicación.
13 | ///
14 | [STAThread]
15 | static void Main()
16 | {
17 | Application.EnableVisualStyles();
18 | Application.SetCompatibleTextRenderingDefault(false);
19 | Application.Run(new FormMain());
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/RibbonLib.Sample/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // La información general de un ensamblado se controla mediante el siguiente
6 | // conjunto de atributos. Cambie estos valores de atributo para modificar la información
7 | // asociada con un ensamblado.
8 | [assembly: AssemblyTitle("Sample")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("Sample")]
13 | [assembly: AssemblyCopyright("Copyright © 2016")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Si establece ComVisible en false, los tipos de este ensamblado no estarán visibles
18 | // para los componentes COM. Si necesita obtener acceso a un tipo de este ensamblado desde
19 | // COM, establezca el atributo ComVisible en true en este tipo.
20 | [assembly: ComVisible(false)]
21 |
22 | // El siguiente GUID sirve como id. de typelib si este proyecto se expone a COM.
23 | [assembly: Guid("fce564c9-c111-4d0a-9ad9-b62b2b4cec0c")]
24 |
25 | // La información de versión de un ensamblado consta de los cuatro valores siguientes:
26 | //
27 | // Versión principal
28 | // Versión secundaria
29 | // Número de compilación
30 | // Revisión
31 | //
32 | // Puede especificar todos los valores o usar los valores predeterminados de número de compilación y de revisión
33 | // mediante el carácter '*', como se muestra a continuación:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/RibbonLib.Sample/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.42000
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace Sample.Properties
12 | {
13 |
14 |
15 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
16 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
17 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
18 | {
19 |
20 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
21 |
22 | public static Settings Default
23 | {
24 | get
25 | {
26 | return defaultInstance;
27 | }
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/RibbonLib.Sample/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/RibbonLib.Sample/Resources/Advanced32.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ennerperez/RibbonLib/edba0c761a9542d102d9770071f1ff24a712a53e/RibbonLib.Sample/Resources/Advanced32.bmp
--------------------------------------------------------------------------------
/RibbonLib.Sample/Resources/Drop16.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ennerperez/RibbonLib/edba0c761a9542d102d9770071f1ff24a712a53e/RibbonLib.Sample/Resources/Drop16.bmp
--------------------------------------------------------------------------------
/RibbonLib.Sample/Resources/Drop32.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ennerperez/RibbonLib/edba0c761a9542d102d9770071f1ff24a712a53e/RibbonLib.Sample/Resources/Drop32.bmp
--------------------------------------------------------------------------------
/RibbonLib.Sample/Resources/Exit16.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ennerperez/RibbonLib/edba0c761a9542d102d9770071f1ff24a712a53e/RibbonLib.Sample/Resources/Exit16.bmp
--------------------------------------------------------------------------------
/RibbonLib.Sample/Resources/Exit32.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ennerperez/RibbonLib/edba0c761a9542d102d9770071f1ff24a712a53e/RibbonLib.Sample/Resources/Exit32.bmp
--------------------------------------------------------------------------------
/RibbonLib.Sample/Resources/New16.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ennerperez/RibbonLib/edba0c761a9542d102d9770071f1ff24a712a53e/RibbonLib.Sample/Resources/New16.bmp
--------------------------------------------------------------------------------
/RibbonLib.Sample/Resources/New32.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ennerperez/RibbonLib/edba0c761a9542d102d9770071f1ff24a712a53e/RibbonLib.Sample/Resources/New32.bmp
--------------------------------------------------------------------------------
/RibbonLib.Sample/Resources/Open16.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ennerperez/RibbonLib/edba0c761a9542d102d9770071f1ff24a712a53e/RibbonLib.Sample/Resources/Open16.bmp
--------------------------------------------------------------------------------
/RibbonLib.Sample/Resources/Open32.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ennerperez/RibbonLib/edba0c761a9542d102d9770071f1ff24a712a53e/RibbonLib.Sample/Resources/Open32.bmp
--------------------------------------------------------------------------------
/RibbonLib.Sample/Resources/Save16.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ennerperez/RibbonLib/edba0c761a9542d102d9770071f1ff24a712a53e/RibbonLib.Sample/Resources/Save16.bmp
--------------------------------------------------------------------------------
/RibbonLib.Sample/Resources/Save32.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ennerperez/RibbonLib/edba0c761a9542d102d9770071f1ff24a712a53e/RibbonLib.Sample/Resources/Save32.bmp
--------------------------------------------------------------------------------
/RibbonLib.Sample/Resources/Simple32.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ennerperez/RibbonLib/edba0c761a9542d102d9770071f1ff24a712a53e/RibbonLib.Sample/Resources/Simple32.bmp
--------------------------------------------------------------------------------
/RibbonLib.Sample/Resources/dropA32.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ennerperez/RibbonLib/edba0c761a9542d102d9770071f1ff24a712a53e/RibbonLib.Sample/Resources/dropA32.bmp
--------------------------------------------------------------------------------
/RibbonLib.Sample/Resources/dropB32.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ennerperez/RibbonLib/edba0c761a9542d102d9770071f1ff24a712a53e/RibbonLib.Sample/Resources/dropB32.bmp
--------------------------------------------------------------------------------
/RibbonLib.Sample/Resources/dropC32.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ennerperez/RibbonLib/edba0c761a9542d102d9770071f1ff24a712a53e/RibbonLib.Sample/Resources/dropC32.bmp
--------------------------------------------------------------------------------
/RibbonLib.Sample/RibbonLib.Sample.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {FCE564C9-C111-4D0A-9AD9-B62B2B4CEC0C}
8 | WinExe
9 | Properties
10 | Sample
11 | Sample
12 | v4.5
13 | 512
14 |
15 |
16 |
17 |
18 | AnyCPU
19 | true
20 | full
21 | false
22 | bin\Debug\
23 | DEBUG;TRACE
24 | prompt
25 | 4
26 |
27 |
28 | AnyCPU
29 | pdbonly
30 | true
31 | bin\Release\
32 | TRACE
33 | prompt
34 | 4
35 |
36 |
37 |
38 | ..\packages\RibbonLib.2.7.0.42394\lib\net40\RibbonLib.dll
39 | True
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 | Form
56 |
57 |
58 | FormMain.cs
59 |
60 |
61 |
62 |
63 | FormMain.cs
64 |
65 |
66 | ResXFileCodeGenerator
67 | Resources.Designer.cs
68 | Designer
69 |
70 |
71 | True
72 | Resources.resx
73 | True
74 |
75 |
76 |
77 | SettingsSingleFileGenerator
78 | Settings.Designer.cs
79 |
80 |
81 | True
82 | Settings.settings
83 | True
84 |
85 |
86 | RibbonMarkup.xml
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 | Este proyecto hace referencia a los paquetes NuGet que faltan en este equipo. Use la restauración de paquetes NuGet para descargarlos. Para obtener más información, consulte http://go.microsoft.com/fwlink/?LinkID=322105. El archivo que falta es {0}.
115 |
116 |
117 |
118 |
125 |
--------------------------------------------------------------------------------
/RibbonLib.Sample/RibbonMarkup.ribbon:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ennerperez/RibbonLib/edba0c761a9542d102d9770071f1ff24a712a53e/RibbonLib.Sample/RibbonMarkup.ribbon
--------------------------------------------------------------------------------
/RibbonLib.Sample/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/RibbonLib.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 14
4 | VisualStudioVersion = 14.0.25123.0
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RibbonLib", "RibbonLib\RibbonLib.csproj", "{0D4F3C14-B605-4471-B581-79784A89675C}"
7 | ProjectSection(ProjectDependencies) = postProject
8 | {7C88C713-78FF-4580-A32D-D9623F3AD2E4} = {7C88C713-78FF-4580-A32D-D9623F3AD2E4}
9 | {1E12E24D-CF2E-411D-8650-282DA9B864A9} = {1E12E24D-CF2E-411D-8650-282DA9B864A9}
10 | EndProjectSection
11 | EndProject
12 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Generator", "Generator", "{783AF2FC-7AB6-4EDD-9655-38421F57AF9C}"
13 | EndProject
14 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RibbonGenerator", "RibbonGenerator\RibbonGenerator.csproj", "{7C88C713-78FF-4580-A32D-D9623F3AD2E4}"
15 | EndProject
16 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RibbonGenerator.Console", "RibbonGenerator.Console\RibbonGenerator.Console.csproj", "{1E12E24D-CF2E-411D-8650-282DA9B864A9}"
17 | EndProject
18 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{130FA927-ACE4-4B15-8492-1FEDE64035DB}"
19 | ProjectSection(SolutionItems) = preProject
20 | .nuget\NuGet.Config = .nuget\NuGet.Config
21 | .nuget\NuGet.targets = .nuget\NuGet.targets
22 | EndProjectSection
23 | EndProject
24 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".docs", ".docs", "{F2CB20FD-1A19-49B9-8722-22E31CC83160}"
25 | ProjectSection(SolutionItems) = preProject
26 | CHANGELOG.md = CHANGELOG.md
27 | LICENSE = LICENSE
28 | README.md = README.md
29 | EndProjectSection
30 | EndProject
31 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RibbonLib.Sample", "RibbonLib.Sample\RibbonLib.Sample.csproj", "{FCE564C9-C111-4D0A-9AD9-B62B2B4CEC0C}"
32 | EndProject
33 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".files", ".files", "{4CF96F40-031C-4EBB-8EB4-24B1567A77FE}"
34 | ProjectSection(SolutionItems) = preProject
35 | .editoricon.png = .editoricon.png
36 | .gitignore = .gitignore
37 | EndProjectSection
38 | EndProject
39 | Global
40 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
41 | Debug|Any CPU = Debug|Any CPU
42 | Release|Any CPU = Release|Any CPU
43 | EndGlobalSection
44 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
45 | {0D4F3C14-B605-4471-B581-79784A89675C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
46 | {0D4F3C14-B605-4471-B581-79784A89675C}.Debug|Any CPU.Build.0 = Debug|Any CPU
47 | {0D4F3C14-B605-4471-B581-79784A89675C}.Release|Any CPU.ActiveCfg = Release|Any CPU
48 | {0D4F3C14-B605-4471-B581-79784A89675C}.Release|Any CPU.Build.0 = Release|Any CPU
49 | {7C88C713-78FF-4580-A32D-D9623F3AD2E4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
50 | {7C88C713-78FF-4580-A32D-D9623F3AD2E4}.Debug|Any CPU.Build.0 = Debug|Any CPU
51 | {7C88C713-78FF-4580-A32D-D9623F3AD2E4}.Release|Any CPU.ActiveCfg = Release|Any CPU
52 | {7C88C713-78FF-4580-A32D-D9623F3AD2E4}.Release|Any CPU.Build.0 = Release|Any CPU
53 | {1E12E24D-CF2E-411D-8650-282DA9B864A9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
54 | {1E12E24D-CF2E-411D-8650-282DA9B864A9}.Debug|Any CPU.Build.0 = Debug|Any CPU
55 | {1E12E24D-CF2E-411D-8650-282DA9B864A9}.Release|Any CPU.ActiveCfg = Release|Any CPU
56 | {1E12E24D-CF2E-411D-8650-282DA9B864A9}.Release|Any CPU.Build.0 = Release|Any CPU
57 | {FCE564C9-C111-4D0A-9AD9-B62B2B4CEC0C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
58 | {FCE564C9-C111-4D0A-9AD9-B62B2B4CEC0C}.Debug|Any CPU.Build.0 = Debug|Any CPU
59 | {FCE564C9-C111-4D0A-9AD9-B62B2B4CEC0C}.Release|Any CPU.ActiveCfg = Release|Any CPU
60 | EndGlobalSection
61 | GlobalSection(SolutionProperties) = preSolution
62 | HideSolutionNode = FALSE
63 | EndGlobalSection
64 | GlobalSection(NestedProjects) = preSolution
65 | {7C88C713-78FF-4580-A32D-D9623F3AD2E4} = {783AF2FC-7AB6-4EDD-9655-38421F57AF9C}
66 | {1E12E24D-CF2E-411D-8650-282DA9B864A9} = {783AF2FC-7AB6-4EDD-9655-38421F57AF9C}
67 | EndGlobalSection
68 | EndGlobal
69 |
--------------------------------------------------------------------------------
/RibbonLib/ColorHelper.cs:
--------------------------------------------------------------------------------
1 | //*****************************************************************************
2 | //
3 | // File: ColorHelper.cs
4 | //
5 | // Contents: Class which supply color related helper functions for
6 | // transforming from one color format to the other
7 | //
8 | //*****************************************************************************
9 |
10 | using System;
11 | using System.Drawing;
12 |
13 | namespace RibbonLib
14 | {
15 | internal struct HSL
16 | {
17 | public double H;
18 | public double S;
19 | public double L;
20 | }
21 |
22 | internal struct HSB
23 | {
24 | public byte H;
25 | public byte S;
26 | public byte B;
27 | }
28 |
29 | internal static class ColorHelper
30 | {
31 | // based on http://www.geekymonkey.com/Programming/CSharp/RGB2HSL_HSL2RGB.htm
32 | // Given H,S,L in range of 0-1
33 | // Returns a Color (RGB struct) in range of 0-255
34 | public static Color HSL2RGB(HSL hsl)
35 | {
36 | double v;
37 | double r, g, b;
38 |
39 | r = hsl.L; // default to gray
40 | g = hsl.L;
41 | b = hsl.L;
42 | v = (hsl.L <= 0.5) ? (hsl.L * (1.0 + hsl.S)) : (hsl.L + hsl.S - hsl.L * hsl.S);
43 | if (v > 0)
44 | {
45 | double m;
46 | double sv;
47 | int sextant;
48 | double fract, vsf, mid1, mid2;
49 |
50 | m = hsl.L + hsl.L - v;
51 | sv = (v - m) / v;
52 | hsl.H *= 6.0;
53 | sextant = (int)hsl.H;
54 | fract = hsl.H - sextant;
55 | vsf = v * sv * fract;
56 | mid1 = m + vsf;
57 | mid2 = v - vsf;
58 |
59 | switch (sextant)
60 | {
61 | case 0:
62 | r = v;
63 | g = mid1;
64 | b = m;
65 | break;
66 |
67 | case 1:
68 | r = mid2;
69 | g = v;
70 | b = m;
71 | break;
72 |
73 | case 2:
74 | r = m;
75 | g = v;
76 | b = mid1;
77 | break;
78 |
79 | case 3:
80 | r = m;
81 | g = mid2;
82 | b = v;
83 | break;
84 |
85 | case 4:
86 | r = mid1;
87 | g = m;
88 | b = v;
89 | break;
90 |
91 | case 5:
92 | r = v;
93 | g = m;
94 | b = mid2;
95 | break;
96 | }
97 | }
98 |
99 | return Color.FromArgb(Convert.ToByte(r * 255.0f), Convert.ToByte(g * 255.0f), Convert.ToByte(b * 255.0f));
100 | }
101 |
102 | // Given a Color (RGB Struct) in range of 0-255
103 | // Return H,S,L in range of 0-1
104 | public static HSL RGB2HSL(Color rgb)
105 | {
106 | HSL hsl;
107 |
108 | double r = rgb.R / 255.0;
109 | double g = rgb.G / 255.0;
110 | double b = rgb.B / 255.0;
111 | double v;
112 | double m;
113 | double vm;
114 | double r2, g2, b2;
115 |
116 | hsl.H = 0; // default to black
117 | hsl.S = 0;
118 | hsl.L = 0;
119 | v = Math.Max(r, g);
120 | v = Math.Max(v, b);
121 | m = Math.Min(r, g);
122 | m = Math.Min(m, b);
123 | hsl.L = (m + v) / 2.0;
124 |
125 | if (hsl.L <= 0.0)
126 | {
127 | return hsl;
128 | }
129 |
130 | vm = v - m;
131 | hsl.S = vm;
132 |
133 | if (hsl.S > 0.0)
134 | {
135 | hsl.S /= (hsl.L <= 0.5) ? (v + m) : (2.0 - v - m);
136 | }
137 | else
138 | {
139 | return hsl;
140 | }
141 |
142 | r2 = (v - r) / vm;
143 | g2 = (v - g) / vm;
144 | b2 = (v - b) / vm;
145 |
146 | if (r == v)
147 | {
148 | hsl.H = (g == m ? 5.0 + b2 : 1.0 - g2);
149 | }
150 | else if (g == v)
151 | {
152 | hsl.H = (b == m ? 1.0 + r2 : 3.0 - b2);
153 | }
154 | else
155 | {
156 | hsl.H = (r == m ? 3.0 + g2 : 5.0 - r2);
157 | }
158 |
159 | hsl.H /= 6.0;
160 |
161 | return hsl;
162 | }
163 |
164 | public static HSB HSL2HSB(HSL hsl)
165 | {
166 | HSB hsb;
167 |
168 | hsb.H = (byte)(255.0 * hsl.H);
169 | hsb.S = (byte)(255.0 * hsl.S);
170 | if ((0.1793 <= hsl.L) && (hsl.L <= 0.9821))
171 | {
172 | hsb.B = (byte)(257.7 + 149.9 * Math.Log(hsl.L));
173 | }
174 | else
175 | {
176 | hsb.B = 0;
177 | }
178 |
179 | return hsb;
180 | }
181 |
182 | public static uint HSB2Uint(HSB hsb)
183 | {
184 | return (uint)(hsb.H | (hsb.S << 8) | (hsb.B << 16));
185 | }
186 | }
187 | }
188 |
--------------------------------------------------------------------------------
/RibbonLib/Controls/BaseRibbonControl.cs:
--------------------------------------------------------------------------------
1 | //*****************************************************************************
2 | //
3 | // File: BaseRibbonControl.cs
4 | //
5 | // Contents: Base class for all ribbon control helper classes, provides
6 | // common functionality for ribbon controls.
7 | //
8 | //*****************************************************************************
9 |
10 | using System.Collections.Generic;
11 | using System.Diagnostics;
12 | using RibbonLib.Controls.Events;
13 | using RibbonLib.Controls.Properties;
14 | using RibbonLib.Interop;
15 |
16 | namespace RibbonLib.Controls
17 | {
18 | public class BaseRibbonControl : IRibbonControl
19 | {
20 | ///
21 | /// reference for parent ribbon class
22 | ///
23 | protected Ribbon _ribbon;
24 |
25 | ///
26 | /// ribbon control command id
27 | ///
28 | protected uint _commandID;
29 |
30 | ///
31 | /// map of registered properties for this ribbon control
32 | ///
33 | protected Dictionary _mapProperties = new Dictionary();
34 |
35 | ///
36 | /// map of registered events for this ribbon control
37 | ///
38 | protected Dictionary _mapEvents = new Dictionary();
39 |
40 | ///
41 | /// BaseRibbonControl ctor
42 | ///
43 | /// parent ribbon
44 | /// command id attached to this control
45 | protected BaseRibbonControl(Ribbon ribbon, uint commandID)
46 | {
47 | _ribbon = ribbon;
48 | _commandID = commandID;
49 |
50 | ribbon.AddRibbonControl(this);
51 | }
52 |
53 | ///
54 | /// Register a properties provider with this ribbon control
55 | ///
56 | /// properties provider
57 | protected void AddPropertiesProvider(IPropertiesProvider propertiesProvider)
58 | {
59 | foreach (PropertyKey propertyKey in propertiesProvider.SupportedProperties)
60 | {
61 | _mapProperties[propertyKey] = propertiesProvider;
62 | }
63 | }
64 |
65 | ///
66 | /// Register an events provider with this ribbon control
67 | ///
68 | /// events provider
69 | protected void AddEventsProvider(IEventsProvider eventsProvider)
70 | {
71 | foreach (ExecutionVerb verb in eventsProvider.SupportedEvents)
72 | {
73 | _mapEvents[verb] = eventsProvider;
74 | }
75 | }
76 |
77 | #region IRibbonControl Members
78 |
79 | public uint CommandID
80 | {
81 | get
82 | {
83 | return _commandID;
84 | }
85 | }
86 |
87 | ///
88 | /// Handles IUICommandHandler.Execute function for this ribbon control
89 | ///
90 | /// the mode of execution
91 | /// the property that has changed
92 | /// the new value of the property that has changed
93 | /// additional data for this execution
94 | /// Returns S_OK if successful, or an error value otherwise
95 | public virtual HRESULT Execute(ExecutionVerb verb, PropertyKeyRef key, PropVariantRef currentValue, IUISimplePropertySet commandExecutionProperties)
96 | {
97 | // check if verb is registered with this ribbon control
98 | if (_mapEvents.ContainsKey(verb))
99 | {
100 | // find events provider
101 | IEventsProvider eventsProvider = _mapEvents[verb];
102 |
103 | // delegates execution to events provider
104 | return eventsProvider.Execute(verb, key, currentValue, commandExecutionProperties);
105 | }
106 |
107 | Debug.WriteLine(string.Format("Class {0} does not support verb: {1}.", GetType(), verb));
108 | return HRESULT.E_NOTIMPL;
109 | }
110 |
111 | ///
112 | /// Handles IUICommandHandler.UpdateProperty function for this ribbon control
113 | ///
114 | /// The Property Key to update
115 | /// A pointer to the current value for key. This parameter can be NULL
116 | /// When this method returns, contains a pointer to the new value for key
117 | /// Returns S_OK if successful, or an error value otherwise
118 | public virtual HRESULT UpdateProperty(ref PropertyKey key, PropVariantRef currentValue, ref PropVariant newValue)
119 | {
120 | // check if property is registered with this ribbon control
121 | if (_mapProperties.ContainsKey(key))
122 | {
123 | // find property provider
124 | IPropertiesProvider propertiesProvider = _mapProperties[key];
125 |
126 | // delegates execution to property provider
127 | return propertiesProvider.UpdateProperty(ref key, currentValue, ref newValue);
128 | }
129 |
130 | Debug.WriteLine(string.Format("Class {0} does not support property: {1}.", GetType(), RibbonProperties.GetPropertyKeyName(ref key)));
131 | return HRESULT.S_OK;
132 | }
133 |
134 | #endregion
135 | }
136 | }
137 |
--------------------------------------------------------------------------------
/RibbonLib/Controls/Events/BaseEventsProvider.cs:
--------------------------------------------------------------------------------
1 | //*****************************************************************************
2 | //
3 | // File: BaseEventsProvider.cs
4 | //
5 | // Contents: Base class for all events provider classes.
6 | // provides common members like: _supportedEvents.
7 | //
8 | //*****************************************************************************
9 |
10 | using System.Collections.Generic;
11 | using RibbonLib.Interop;
12 |
13 | namespace RibbonLib.Controls.Events
14 | {
15 | public class BaseEventsProvider : IEventsProvider
16 | {
17 | ///
18 | /// list of supported events
19 | ///
20 | private List _supportedEvents = new List();
21 |
22 | protected BaseEventsProvider()
23 | {
24 | }
25 |
26 | #region IEventsProvider Members
27 |
28 | ///
29 | /// Get supported "execution verbs", or events
30 | ///
31 | public IList SupportedEvents
32 | {
33 | get
34 | {
35 | return _supportedEvents;
36 | }
37 | }
38 |
39 | ///
40 | /// Handles IUICommandHandler.Execute function for supported events
41 | ///
42 | /// the mode of execution
43 | /// the property that has changed
44 | /// the new value of the property that has changed
45 | /// additional data for this execution
46 | /// Returns S_OK if successful, or an error value otherwise
47 | public virtual HRESULT Execute(ExecutionVerb verb, PropertyKeyRef key, PropVariantRef currentValue, IUISimplePropertySet commandExecutionProperties)
48 | {
49 | return HRESULT.S_OK;
50 | }
51 |
52 | #endregion
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/RibbonLib/Controls/Events/ExecuteEventArgs.cs:
--------------------------------------------------------------------------------
1 | //*****************************************************************************
2 | //
3 | // File: ExecuteEventsArgs.cs
4 | //
5 | // Contents: Definition for execute events arguments
6 | //
7 | //*****************************************************************************
8 |
9 | using System;
10 | using RibbonLib.Interop;
11 |
12 | namespace RibbonLib.Controls.Events
13 | {
14 | ///
15 | /// Execute event args
16 | ///
17 | public class ExecuteEventArgs : EventArgs
18 | {
19 | private PropertyKeyRef _key;
20 | private PropVariantRef _currentValue;
21 | private IUISimplePropertySet _commandExecutionProperties;
22 |
23 | public ExecuteEventArgs(PropertyKeyRef key, PropVariantRef currentValue, IUISimplePropertySet commandExecutionProperties)
24 | {
25 | _key = key;
26 | _currentValue = currentValue;
27 | _commandExecutionProperties = commandExecutionProperties;
28 | }
29 |
30 | public PropertyKeyRef Key
31 | {
32 | get
33 | {
34 | return _key;
35 | }
36 | }
37 |
38 | public PropVariantRef CurrentValue
39 | {
40 | get
41 | {
42 | return _currentValue;
43 | }
44 | }
45 |
46 | public IUISimplePropertySet CommandExecutionProperties
47 | {
48 | get
49 | {
50 | return _commandExecutionProperties;
51 | }
52 | }
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/RibbonLib/Controls/Events/ExecuteEventsProvider.cs:
--------------------------------------------------------------------------------
1 | //*****************************************************************************
2 | //
3 | // File: ExecuteEventsProvider.cs
4 | //
5 | // Contents: Definition for execute events provider
6 | //
7 | //*****************************************************************************
8 |
9 | using RibbonLib.Interop;
10 | using System;
11 |
12 | namespace RibbonLib.Controls.Events
13 | {
14 | ///
15 | /// Definition for Execute events provider
16 | ///
17 | public interface IExecuteEventsProvider
18 | {
19 | ///
20 | /// Execute event
21 | ///
22 | event EventHandler ExecuteEvent;
23 | }
24 |
25 | ///
26 | /// Implementation of IExecuteEventsProvider
27 | ///
28 | public class ExecuteEventsProvider : BaseEventsProvider, IExecuteEventsProvider
29 | {
30 | private object _sender;
31 |
32 | public ExecuteEventsProvider(object sender)
33 | {
34 | _sender = sender;
35 | SupportedEvents.Add(ExecutionVerb.Execute);
36 | }
37 |
38 | ///
39 | /// Handles IUICommandHandler.Execute function for supported events
40 | ///
41 | /// the mode of execution
42 | /// the property that has changed
43 | /// the new value of the property that has changed
44 | /// additional data for this execution
45 | /// Returns S_OK if successful, or an error value otherwise
46 | public override HRESULT Execute(ExecutionVerb verb, PropertyKeyRef key, PropVariantRef currentValue, IUISimplePropertySet commandExecutionProperties)
47 | {
48 | if (verb == ExecutionVerb.Execute)
49 | {
50 | if (ExecuteEvent != null)
51 | {
52 | ExecuteEvent(_sender, new ExecuteEventArgs(key, currentValue, commandExecutionProperties));
53 | }
54 | }
55 |
56 | return HRESULT.S_OK;
57 | }
58 |
59 | #region IExecuteEventsProvider Members
60 |
61 | ///
62 | /// Execute event
63 | ///
64 | public event EventHandler ExecuteEvent;
65 |
66 | #endregion
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/RibbonLib/Controls/Events/IEventsProvider.cs:
--------------------------------------------------------------------------------
1 | //*****************************************************************************
2 | //
3 | // File: IEventsProvider.cs
4 | //
5 | // Contents: Interface for components that provides events
6 | //
7 | //*****************************************************************************
8 |
9 | using System.Collections.Generic;
10 | using RibbonLib.Interop;
11 |
12 | namespace RibbonLib.Controls.Events
13 | {
14 | public interface IEventsProvider
15 | {
16 | ///
17 | /// Get supported "execution verbs", or events
18 | ///
19 | IList SupportedEvents { get; }
20 |
21 | ///
22 | /// Handles IUICommandHandler.Execute function for supported events
23 | ///
24 | /// the mode of execution
25 | /// the property that has changed
26 | /// the new value of the property that has changed
27 | /// additional data for this execution
28 | /// Returns S_OK if successful, or an error value otherwise
29 | HRESULT Execute(ExecutionVerb verb, PropertyKeyRef key, PropVariantRef currentValue, IUISimplePropertySet commandExecutionProperties);
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/RibbonLib/Controls/Events/PreviewEventsProvider.cs:
--------------------------------------------------------------------------------
1 | //*****************************************************************************
2 | //
3 | // File: PreviewEventsProvider.cs
4 | //
5 | // Contents: definition for preview events provider
6 | //
7 | //*****************************************************************************
8 |
9 | using RibbonLib.Interop;
10 | using System;
11 |
12 | namespace RibbonLib.Controls.Events
13 | {
14 | ///
15 | /// Definition for Execute events provider
16 | ///
17 | public interface IPreviewEventsProvider
18 | {
19 | ///
20 | /// Preview event
21 | ///
22 | event EventHandler PreviewEvent;
23 |
24 | ///
25 | /// Cancel Preview event
26 | ///
27 | event EventHandler CancelPreviewEvent;
28 | }
29 |
30 | ///
31 | /// Implementation of IPreviewEventsProvider
32 | ///
33 | class PreviewEventsProvider : BaseEventsProvider, IPreviewEventsProvider
34 | {
35 | private object _sender;
36 |
37 | public PreviewEventsProvider(object sender)
38 | {
39 | _sender = sender;
40 | SupportedEvents.Add(ExecutionVerb.Preview);
41 | SupportedEvents.Add(ExecutionVerb.CancelPreview);
42 | }
43 |
44 | ///
45 | /// Handles IUICommandHandler.Execute function for supported events
46 | ///
47 | /// the mode of execution
48 | /// the property that has changed
49 | /// the new value of the property that has changed
50 | /// additional data for this execution
51 | /// Returns S_OK if successful, or an error value otherwise
52 | public override HRESULT Execute(ExecutionVerb verb, PropertyKeyRef key, PropVariantRef currentValue, IUISimplePropertySet commandExecutionProperties)
53 | {
54 | switch (verb)
55 | {
56 | case ExecutionVerb.Preview:
57 | if (PreviewEvent != null)
58 | {
59 | PreviewEvent(_sender, new ExecuteEventArgs(key, currentValue, commandExecutionProperties));
60 | }
61 | break;
62 |
63 | case ExecutionVerb.CancelPreview:
64 | if (CancelPreviewEvent != null)
65 | {
66 | CancelPreviewEvent(_sender, new ExecuteEventArgs(key, currentValue, commandExecutionProperties));
67 | }
68 | break;
69 | }
70 | return HRESULT.S_OK;
71 | }
72 |
73 | #region IPreviewEventsProvider Members
74 |
75 | ///
76 | /// Preview event
77 | ///
78 | public event EventHandler PreviewEvent;
79 |
80 | ///
81 | /// Cancel Preview event
82 | ///
83 | public event EventHandler CancelPreviewEvent;
84 |
85 | #endregion
86 | }
87 | }
88 |
--------------------------------------------------------------------------------
/RibbonLib/Controls/Properties/BasePropertiesProvider.cs:
--------------------------------------------------------------------------------
1 | //*****************************************************************************
2 | //
3 | // File: BasePropertiesProvider.cs
4 | //
5 | // Contents: Base class for all properties provider classes.
6 | // provides common members like: _ribbon, _command_id
7 | // and _supportedProperties.
8 | //
9 | //*****************************************************************************
10 |
11 | using System.Collections.Generic;
12 | using RibbonLib.Interop;
13 |
14 | namespace RibbonLib.Controls.Properties
15 | {
16 | public class BasePropertiesProvider : IPropertiesProvider
17 | {
18 | ///
19 | /// reference for parent ribbon class
20 | ///
21 | protected Ribbon _ribbon;
22 |
23 | ///
24 | /// ribbon control command id
25 | ///
26 | protected uint _commandID;
27 |
28 | ///
29 | /// list of supported properties
30 | ///
31 | protected List _supportedProperties = new List();
32 |
33 | ///
34 | /// BasePropertiesProvider ctor
35 | ///
36 | /// parent ribbon
37 | /// command id attached to this control
38 | protected BasePropertiesProvider(Ribbon ribbon, uint commandID)
39 | {
40 | _ribbon = ribbon;
41 | _commandID = commandID;
42 | }
43 |
44 | #region IPropertiesProvider Members
45 |
46 | ///
47 | /// Get supported properties
48 | ///
49 | public IList SupportedProperties
50 | {
51 | get
52 | {
53 | return _supportedProperties;
54 | }
55 | }
56 |
57 | ///
58 | /// Handles IUICommandHandler.UpdateProperty function for the supported properties
59 | ///
60 | /// The Property Key to update
61 | /// A pointer to the current value for key. This parameter can be NULL
62 | /// When this method returns, contains a pointer to the new value for key
63 | /// Returns S_OK if successful, or an error value otherwise
64 | public virtual HRESULT UpdateProperty(ref PropertyKey key, PropVariantRef currentValue, ref PropVariant newValue)
65 | {
66 | return HRESULT.S_OK;
67 | }
68 |
69 | #endregion
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/RibbonLib/Controls/Properties/BooleanValuePropertyProvider.cs:
--------------------------------------------------------------------------------
1 | //*****************************************************************************
2 | //
3 | // File: BooleanValuePropertyProvider.cs
4 | //
5 | // Contents: Definition for boolean value properties provider
6 | //
7 | //*****************************************************************************
8 |
9 | using RibbonLib.Interop;
10 |
11 | namespace RibbonLib.Controls.Properties
12 | {
13 | ///
14 | /// Definition for boolean value properties provider interface
15 | ///
16 | public interface IBooleanValuePropertyProvider
17 | {
18 | ///
19 | /// Boolean value property
20 | ///
21 | bool BooleanValue { get; set; }
22 | }
23 |
24 | ///
25 | /// Implementation of IBooleanValuePropertyProvider
26 | ///
27 | public class BooleanValuePropertyProvider : BasePropertiesProvider, IBooleanValuePropertyProvider
28 | {
29 | ///
30 | /// BooleanValuePropertyProvider ctor
31 | ///
32 | /// parent ribbon
33 | /// ribbon control command id
34 | public BooleanValuePropertyProvider(Ribbon ribbon, uint commandId)
35 | : base(ribbon, commandId)
36 | {
37 | // add supported properties
38 | _supportedProperties.Add(RibbonProperties.BooleanValue);
39 | }
40 |
41 | private bool? _booleanValue;
42 |
43 | ///
44 | /// Handles IUICommandHandler.UpdateProperty function for the supported properties
45 | ///
46 | /// The Property Key to update
47 | /// A pointer to the current value for key. This parameter can be NULL
48 | /// When this method returns, contains a pointer to the new value for key
49 | /// Returns S_OK if successful, or an error value otherwise
50 | public override HRESULT UpdateProperty(ref PropertyKey key, PropVariantRef currentValue, ref PropVariant newValue)
51 | {
52 | if (key == RibbonProperties.BooleanValue)
53 | {
54 | if (_booleanValue.HasValue)
55 | {
56 | newValue.SetBool(_booleanValue.Value);
57 | }
58 | }
59 |
60 | return HRESULT.S_OK;
61 | }
62 |
63 | #region IBooleanValuePropertyProvider Members
64 |
65 | ///
66 | /// Boolean value property
67 | ///
68 | public bool BooleanValue
69 | {
70 | get
71 | {
72 | if (_ribbon.Initalized)
73 | {
74 | PropVariant boolValue;
75 | HRESULT hr = _ribbon.Framework.GetUICommandProperty(_commandID, ref RibbonProperties.BooleanValue, out boolValue);
76 | if (NativeMethods.Succeeded(hr))
77 | {
78 | return (bool)boolValue.Value;
79 | }
80 | }
81 | return _booleanValue.GetValueOrDefault();
82 | }
83 | set
84 | {
85 | _booleanValue = value;
86 | if (_ribbon.Initalized)
87 | {
88 | PropVariant boolValue = PropVariant.FromObject(value);
89 | HRESULT hr = _ribbon.Framework.SetUICommandProperty(_commandID, ref RibbonProperties.BooleanValue, ref boolValue);
90 | }
91 | }
92 | }
93 |
94 | #endregion
95 | }
96 | }
97 |
--------------------------------------------------------------------------------
/RibbonLib/Controls/Properties/ContextAvailablePropertiesProvider.cs:
--------------------------------------------------------------------------------
1 | //*****************************************************************************
2 | //
3 | // File: ContextAvailablePropertiesProvider.cs
4 | //
5 | // Contents: Definition for context available properties provider
6 | //
7 | //*****************************************************************************
8 |
9 | using RibbonLib.Interop;
10 |
11 | namespace RibbonLib.Controls.Properties
12 | {
13 | ///
14 | /// Definition for context available properties interface
15 | ///
16 | public interface IContextAvailablePropertiesProvider
17 | {
18 | ///
19 | /// Context available property
20 | ///
21 | ContextAvailability ContextAvailable { get; set; }
22 | }
23 |
24 | ///
25 | /// Implementation of IContextAvailablePropertiesProvider
26 | ///
27 | public class ContextAvailablePropertiesProvider : BasePropertiesProvider, IContextAvailablePropertiesProvider
28 | {
29 | ///
30 | /// ContextAvailablePropertiesProvider ctor
31 | ///
32 | /// parent ribbon
33 | /// ribbon control command id
34 | public ContextAvailablePropertiesProvider(Ribbon ribbon, uint commandId)
35 | : base(ribbon, commandId)
36 | {
37 | // add supported properties
38 | _supportedProperties.Add(RibbonProperties.ContextAvailable);
39 | }
40 |
41 | private ContextAvailability? _contextAvailable;
42 |
43 | ///
44 | /// Handles IUICommandHandler.UpdateProperty function for the supported properties
45 | ///
46 | /// The Property Key to update
47 | /// A pointer to the current value for key. This parameter can be NULL
48 | /// When this method returns, contains a pointer to the new value for key
49 | /// Returns S_OK if successful, or an error value otherwise
50 | public override HRESULT UpdateProperty(ref PropertyKey key, PropVariantRef currentValue, ref PropVariant newValue)
51 | {
52 | if (key == RibbonProperties.ContextAvailable)
53 | {
54 | if (_contextAvailable.HasValue)
55 | {
56 | newValue.SetUInt((uint)_contextAvailable.Value);
57 | }
58 | }
59 |
60 | return HRESULT.S_OK;
61 | }
62 |
63 | #region IContextAvailablePropertiesProvider Members
64 |
65 | ///
66 | /// Context available property
67 | ///
68 | public ContextAvailability ContextAvailable
69 | {
70 | get
71 | {
72 | if (_ribbon.Initalized)
73 | {
74 | PropVariant uintValue;
75 | HRESULT hr = _ribbon.Framework.GetUICommandProperty(_commandID, ref RibbonProperties.ContextAvailable, out uintValue);
76 | if (NativeMethods.Succeeded(hr))
77 | {
78 | return (ContextAvailability)(uint)uintValue.Value;
79 | }
80 | }
81 |
82 | return _contextAvailable.GetValueOrDefault();
83 | }
84 | set
85 | {
86 | _contextAvailable = value;
87 | if (_ribbon.Initalized)
88 | {
89 | PropVariant uintValue = PropVariant.FromObject((uint)value);
90 | HRESULT hr = _ribbon.Framework.SetUICommandProperty(_commandID, ref RibbonProperties.ContextAvailable, ref uintValue);
91 | }
92 | }
93 | }
94 |
95 | #endregion
96 | }
97 | }
98 |
--------------------------------------------------------------------------------
/RibbonLib/Controls/Properties/EnabledPropertiesProvider.cs:
--------------------------------------------------------------------------------
1 | //*****************************************************************************
2 | //
3 | // File: EnabledPropertiesProvider.cs
4 | //
5 | // Contents: Definition for enabled properties provider
6 | //
7 | //*****************************************************************************
8 |
9 | using RibbonLib.Interop;
10 |
11 | namespace RibbonLib.Controls.Properties
12 | {
13 | ///
14 | /// Definition for enabled properties provider interface
15 | ///
16 | public interface IEnabledPropertiesProvider
17 | {
18 | ///
19 | /// Enabled property
20 | ///
21 | bool Enabled { get; set; }
22 | }
23 |
24 | ///
25 | /// Implementation of IEnabledPropertiesProvider
26 | ///
27 | public class EnabledPropertiesProvider : BasePropertiesProvider, IEnabledPropertiesProvider
28 | {
29 | ///
30 | /// EnabledPropertiesProvider ctor
31 | ///
32 | /// parent ribbon
33 | /// ribbon control command id
34 | public EnabledPropertiesProvider(Ribbon ribbon, uint commandId)
35 | : base(ribbon, commandId)
36 | {
37 | // add supported properties
38 | _supportedProperties.Add(RibbonProperties.Enabled);
39 | }
40 |
41 | private bool? _enabled;
42 |
43 | ///
44 | /// Handles IUICommandHandler.UpdateProperty function for the supported properties
45 | ///
46 | /// The Property Key to update
47 | /// A pointer to the current value for key. This parameter can be NULL
48 | /// When this method returns, contains a pointer to the new value for key
49 | /// Returns S_OK if successful, or an error value otherwise
50 | public override HRESULT UpdateProperty(ref PropertyKey key, PropVariantRef currentValue, ref PropVariant newValue)
51 | {
52 | if (key == RibbonProperties.Enabled)
53 | {
54 | if (_enabled.HasValue)
55 | {
56 | newValue.SetBool(_enabled.Value);
57 | }
58 | }
59 |
60 | return HRESULT.S_OK;
61 | }
62 |
63 | #region IEnabledPropertiesProvider Members
64 |
65 | ///
66 | /// Enabled property
67 | ///
68 | public bool Enabled
69 | {
70 | get
71 | {
72 | if (_ribbon.Initalized)
73 | {
74 | PropVariant boolValue;
75 | HRESULT hr = _ribbon.Framework.GetUICommandProperty(_commandID, ref RibbonProperties.Enabled, out boolValue);
76 | if (NativeMethods.Succeeded(hr))
77 | {
78 | return (bool)boolValue.Value;
79 | }
80 | }
81 |
82 | return _enabled.GetValueOrDefault();
83 | }
84 | set
85 | {
86 | _enabled = value;
87 | if (_ribbon.Initalized)
88 | {
89 | PropVariant boolValue = PropVariant.FromObject(value);
90 | HRESULT hr = _ribbon.Framework.SetUICommandProperty(_commandID, ref RibbonProperties.Enabled, ref boolValue);
91 | }
92 | }
93 | }
94 |
95 | #endregion
96 | }
97 | }
98 |
--------------------------------------------------------------------------------
/RibbonLib/Controls/Properties/IPropertiesProvider.cs:
--------------------------------------------------------------------------------
1 | //*****************************************************************************
2 | //
3 | // File: IPropertiesProvider.cs
4 | //
5 | // Contents: Interface for components that provides properties
6 | //
7 | //*****************************************************************************
8 |
9 | using System.Collections.Generic;
10 | using RibbonLib.Interop;
11 |
12 | namespace RibbonLib.Controls.Properties
13 | {
14 | public interface IPropertiesProvider
15 | {
16 | ///
17 | /// Get supported properties
18 | ///
19 | IList SupportedProperties { get; }
20 |
21 | ///
22 | /// Handles IUICommandHandler.UpdateProperty function for the supported properties
23 | ///
24 | /// The Property Key to update
25 | /// A pointer to the current value for key. This parameter can be NULL
26 | /// When this method returns, contains a pointer to the new value for key
27 | /// Returns S_OK if successful, or an error value otherwise
28 | HRESULT UpdateProperty(ref PropertyKey key, PropVariantRef currentValue, ref PropVariant newValue);
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/RibbonLib/Controls/Properties/KeytipPropertiesProvider.cs:
--------------------------------------------------------------------------------
1 | //*****************************************************************************
2 | //
3 | // File: KeytipPropertiesProvider.cs
4 | //
5 | // Contents: Definition for keytip properties provider
6 | //
7 | //*****************************************************************************
8 |
9 | using RibbonLib.Interop;
10 |
11 | namespace RibbonLib.Controls.Properties
12 | {
13 | ///
14 | /// Definition for keytip properties provider interface
15 | ///
16 | public interface IKeytipPropertiesProvider
17 | {
18 | ///
19 | /// Keytip property
20 | ///
21 | string Keytip { get; set; }
22 | }
23 |
24 | ///
25 | /// Implementation of IKeytipPropertiesProvider
26 | ///
27 | public class KeytipPropertiesProvider : BasePropertiesProvider, IKeytipPropertiesProvider
28 | {
29 | ///
30 | /// KeytipPropertiesProvider ctor
31 | ///
32 | /// parent ribbon
33 | /// ribbon control command id
34 | public KeytipPropertiesProvider(Ribbon ribbon, uint commandId)
35 | : base(ribbon, commandId)
36 | {
37 | // add supported properties
38 | _supportedProperties.Add(RibbonProperties.Keytip);
39 | }
40 |
41 | private string _keytip;
42 |
43 | ///
44 | /// Handles IUICommandHandler.UpdateProperty function for the supported properties
45 | ///
46 | /// The Property Key to update
47 | /// A pointer to the current value for key. This parameter can be NULL
48 | /// When this method returns, contains a pointer to the new value for key
49 | /// Returns S_OK if successful, or an error value otherwise
50 | public override HRESULT UpdateProperty(ref PropertyKey key, PropVariantRef currentValue, ref PropVariant newValue)
51 | {
52 | if (key == RibbonProperties.Keytip)
53 | {
54 | if (_keytip != null)
55 | {
56 | newValue.SetString(_keytip);
57 | }
58 | }
59 |
60 | return HRESULT.S_OK;
61 | }
62 |
63 | #region IKeytipPropertiesProvider Members
64 |
65 | ///
66 | /// Keytip property
67 | ///
68 | public string Keytip
69 | {
70 | get
71 | {
72 | return _keytip;
73 | }
74 | set
75 | {
76 | _keytip = value;
77 | if (_ribbon.Initalized)
78 | {
79 | HRESULT hr = _ribbon.Framework.InvalidateUICommand(_commandID, Invalidations.Property, PropertyKeyRef.From(RibbonProperties.Keytip));
80 | }
81 | }
82 | }
83 |
84 | #endregion
85 | }
86 | }
87 |
--------------------------------------------------------------------------------
/RibbonLib/Controls/Properties/LabelDescriptionPropertiesProvider.cs:
--------------------------------------------------------------------------------
1 | //*****************************************************************************
2 | //
3 | // File: LabelDescriptionPropertiesProvider.cs
4 | //
5 | // Contents: Definition for label description properties provider
6 | //
7 | //*****************************************************************************
8 |
9 | using RibbonLib.Interop;
10 |
11 | namespace RibbonLib.Controls.Properties
12 | {
13 | ///
14 | /// Definition for label description properties provider interface
15 | ///
16 | public interface ILabelDescriptionPropertiesProvider
17 | {
18 | ///
19 | /// LabelDescription property
20 | ///
21 | string LabelDescription { get; set; }
22 | }
23 |
24 | ///
25 | /// Implementation of ILabelDescriptionPropertiesProvider
26 | ///
27 | public class LabelDescriptionPropertiesProvider : BasePropertiesProvider, ILabelDescriptionPropertiesProvider
28 | {
29 | ///
30 | /// LabelDescriptionPropertiesProvider ctor
31 | ///
32 | /// parent ribbon
33 | /// ribbon control command id
34 | public LabelDescriptionPropertiesProvider(Ribbon ribbon, uint commandId)
35 | : base(ribbon, commandId)
36 | {
37 | // add supported properties
38 | _supportedProperties.Add(RibbonProperties.LabelDescription);
39 | }
40 |
41 | private string _labelDescription;
42 |
43 | ///
44 | /// Handles IUICommandHandler.UpdateProperty function for the supported properties
45 | ///
46 | /// The Property Key to update
47 | /// A pointer to the current value for key. This parameter can be NULL
48 | /// When this method returns, contains a pointer to the new value for key
49 | /// Returns S_OK if successful, or an error value otherwise
50 | public override HRESULT UpdateProperty(ref PropertyKey key, PropVariantRef currentValue, ref PropVariant newValue)
51 | {
52 | if (key == RibbonProperties.LabelDescription)
53 | {
54 | if (_labelDescription != null)
55 | {
56 | newValue.SetString(_labelDescription);
57 | }
58 | }
59 |
60 | return HRESULT.S_OK;
61 | }
62 |
63 | #region ILabelDescriptionPropertiesProvider Members
64 |
65 | ///
66 | /// Label description property
67 | ///
68 | public string LabelDescription
69 | {
70 | get
71 | {
72 | return _labelDescription;
73 | }
74 | set
75 | {
76 | _labelDescription = value;
77 | if (_ribbon.Initalized)
78 | {
79 | HRESULT hr = _ribbon.Framework.InvalidateUICommand(_commandID, Invalidations.Property, PropertyKeyRef.From(RibbonProperties.LabelDescription));
80 | }
81 | }
82 | }
83 |
84 | #endregion
85 | }
86 | }
87 |
--------------------------------------------------------------------------------
/RibbonLib/Controls/Properties/LabelPropertiesProvider.cs:
--------------------------------------------------------------------------------
1 | //*****************************************************************************
2 | //
3 | // File: LabelPropertiesProvider.cs
4 | //
5 | // Contents: Definition for label properties provider
6 | //
7 | //*****************************************************************************
8 |
9 | using RibbonLib.Interop;
10 |
11 | namespace RibbonLib.Controls.Properties
12 | {
13 | ///
14 | /// Definition for label properties provider interface
15 | ///
16 | public interface ILabelPropertiesProvider
17 | {
18 | ///
19 | /// Label property
20 | ///
21 | string Label { get; set; }
22 | }
23 |
24 | ///
25 | /// Implementation of ILabelPropertiesProvider
26 | ///
27 | public class LabelPropertiesProvider : BasePropertiesProvider, ILabelPropertiesProvider
28 | {
29 | ///
30 | /// LabelPropertiesProvider ctor
31 | ///
32 | /// parent ribbon
33 | /// ribbon control command id
34 | public LabelPropertiesProvider(Ribbon ribbon, uint commandId)
35 | : base(ribbon, commandId)
36 | {
37 | // add supported properties
38 | _supportedProperties.Add(RibbonProperties.Label);
39 | }
40 |
41 | private string _label;
42 |
43 | ///
44 | /// Handles IUICommandHandler.UpdateProperty function for the supported properties
45 | ///
46 | /// The Property Key to update
47 | /// A pointer to the current value for key. This parameter can be NULL
48 | /// When this method returns, contains a pointer to the new value for key
49 | /// Returns S_OK if successful, or an error value otherwise
50 | public override HRESULT UpdateProperty(ref PropertyKey key, PropVariantRef currentValue, ref PropVariant newValue)
51 | {
52 | if (key == RibbonProperties.Label)
53 | {
54 | if (_label != null)
55 | {
56 | newValue.SetString(_label);
57 | }
58 | }
59 |
60 | return HRESULT.S_OK;
61 | }
62 |
63 | #region ILabelPropertiesProvider Members
64 |
65 | ///
66 | /// Label property
67 | ///
68 | public string Label
69 | {
70 | get
71 | {
72 | return _label;
73 | }
74 | set
75 | {
76 | _label = value;
77 | if (_ribbon.Initalized)
78 | {
79 | HRESULT hr = _ribbon.Framework.InvalidateUICommand(_commandID, Invalidations.Property, PropertyKeyRef.From(RibbonProperties.Label));
80 | }
81 | }
82 | }
83 |
84 | #endregion
85 | }
86 | }
87 |
--------------------------------------------------------------------------------
/RibbonLib/Controls/Properties/RecentItemsPropertiesProvider.cs:
--------------------------------------------------------------------------------
1 | //*****************************************************************************
2 | //
3 | // File: RecentItemsPropertiesProvider.cs
4 | //
5 | // Contents: Definition for recent items properties provider
6 | //
7 | //*****************************************************************************
8 |
9 | using System.Collections.Generic;
10 | using System.Linq;
11 | using RibbonLib.Interop;
12 |
13 | namespace RibbonLib.Controls.Properties
14 | {
15 | ///
16 | /// Definition for recent items properties provider interface
17 | ///
18 | public interface IRecentItemsPropertiesProvider
19 | {
20 | ///
21 | /// Recent items property
22 | ///
23 | IList RecentItems { get; set; }
24 | }
25 |
26 | ///
27 | /// Implementation of IRecentItemsPropertiesProvider
28 | ///
29 | public class RecentItemsPropertiesProvider : BasePropertiesProvider, IRecentItemsPropertiesProvider
30 | {
31 | ///
32 | /// RecentItemsPropertiesProvider ctor
33 | ///
34 | /// parent ribbon
35 | /// ribbon control command id
36 | public RecentItemsPropertiesProvider(Ribbon ribbon, uint commandId)
37 | : base(ribbon, commandId)
38 | {
39 | // add supported properties
40 | _supportedProperties.Add(RibbonProperties.RecentItems);
41 | }
42 |
43 | private IList _recentItems;
44 |
45 | ///
46 | /// Handles IUICommandHandler.UpdateProperty function for the supported properties
47 | ///
48 | /// The Property Key to update
49 | /// A pointer to the current value for key. This parameter can be NULL
50 | /// When this method returns, contains a pointer to the new value for key
51 | /// Returns S_OK if successful, or an error value otherwise
52 | public override HRESULT UpdateProperty(ref PropertyKey key, PropVariantRef currentValue, ref PropVariant newValue)
53 | {
54 | if (key == RibbonProperties.RecentItems)
55 | {
56 | if (_recentItems != null)
57 | {
58 | newValue.SetSafeArray(_recentItems.ToArray());
59 | }
60 | }
61 |
62 | return HRESULT.S_OK;
63 | }
64 |
65 | #region IRecentItemsPropertiesProvider Members
66 |
67 | ///
68 | /// Recent items property
69 | ///
70 | public IList RecentItems
71 | {
72 | get
73 | {
74 | return _recentItems;
75 | }
76 | set
77 | {
78 | _recentItems = value;
79 | }
80 | }
81 |
82 | #endregion
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/RibbonLib/Controls/Properties/RepresentativeStringPropertiesProvider.cs:
--------------------------------------------------------------------------------
1 | //*****************************************************************************
2 | //
3 | // File: RepresentativeStringPropertiesProvider.cs
4 | //
5 | // Contents: Definition for representative string properties provider
6 | //
7 | //*****************************************************************************
8 |
9 | using RibbonLib.Interop;
10 |
11 | namespace RibbonLib.Controls.Properties
12 | {
13 | ///
14 | /// Definition for representative string properties provider interface
15 | ///
16 | public interface IRepresentativeStringPropertiesProvider
17 | {
18 | ///
19 | /// Representative string property
20 | ///
21 | string RepresentativeString { get; set; }
22 | }
23 |
24 | ///
25 | /// Implementation of IRepresentativeStringPropertiesProvider
26 | ///
27 | public class RepresentativeStringPropertiesProvider : BasePropertiesProvider, IRepresentativeStringPropertiesProvider
28 | {
29 | ///
30 | /// RepresentativeStringPropertiesProvider ctor
31 | ///
32 | /// parent ribbon
33 | /// ribbon control command id
34 | public RepresentativeStringPropertiesProvider(Ribbon ribbon, uint commandId)
35 | : base(ribbon, commandId)
36 | {
37 | // add supported properties
38 | _supportedProperties.Add(RibbonProperties.RepresentativeString);
39 | }
40 |
41 | private string _representativeString;
42 |
43 | ///
44 | /// Handles IUICommandHandler.UpdateProperty function for the supported properties
45 | ///
46 | /// The Property Key to update
47 | /// A pointer to the current value for key. This parameter can be NULL
48 | /// When this method returns, contains a pointer to the new value for key
49 | /// Returns S_OK if successful, or an error value otherwise
50 | public override HRESULT UpdateProperty(ref PropertyKey key, PropVariantRef currentValue, ref PropVariant newValue)
51 | {
52 | if (key == RibbonProperties.RepresentativeString)
53 | {
54 | if (_representativeString != null)
55 | {
56 | newValue.SetString(_representativeString);
57 | }
58 | }
59 |
60 | return HRESULT.S_OK;
61 | }
62 |
63 | #region IRepresentativeStringPropertiesProvider Members
64 |
65 | ///
66 | /// Representative string property
67 | ///
68 | public string RepresentativeString
69 | {
70 | get
71 | {
72 | return _representativeString;
73 | }
74 | set
75 | {
76 | _representativeString = value;
77 | if (_ribbon.Initalized)
78 | {
79 | HRESULT hr = _ribbon.Framework.InvalidateUICommand(_commandID, Invalidations.Property, PropertyKeyRef.From(RibbonProperties.RepresentativeString));
80 | }
81 | }
82 | }
83 |
84 | #endregion
85 | }
86 | }
87 |
--------------------------------------------------------------------------------
/RibbonLib/Controls/Properties/StringValueProperiesProvider.cs:
--------------------------------------------------------------------------------
1 | //*****************************************************************************
2 | //
3 | // File: StringValuePropertiesProvider.cs
4 | //
5 | // Contents: Definition for string value Properties provider
6 | //
7 | //*****************************************************************************
8 |
9 | using RibbonLib.Interop;
10 |
11 | namespace RibbonLib.Controls.Properties
12 | {
13 | ///
14 | /// Definition for string value properties provider interface
15 | ///
16 | public interface IStringValuePropertiesProvider
17 | {
18 | ///
19 | /// String value property
20 | ///
21 | string StringValue { get; set; }
22 | }
23 |
24 | ///
25 | /// Implementation of IStringValuePropertiesProvider
26 | ///
27 | public class StringValuePropertiesProvider : BasePropertiesProvider, IStringValuePropertiesProvider
28 | {
29 | ///
30 | /// StringValuePropertiesProvider ctor
31 | ///
32 | /// parent ribbon
33 | /// ribbon control command id
34 | public StringValuePropertiesProvider(Ribbon ribbon, uint commandId)
35 | : base(ribbon, commandId)
36 | {
37 | // add supported properties
38 | _supportedProperties.Add(RibbonProperties.StringValue);
39 | }
40 |
41 | private string _stringValue;
42 |
43 | ///
44 | /// Handles IUICommandHandler.UpdateProperty function for the supported properties
45 | ///
46 | /// The Property Key to update
47 | /// A pointer to the current value for key. This parameter can be NULL
48 | /// When this method returns, contains a pointer to the new value for key
49 | /// Returns S_OK if successful, or an error value otherwise
50 | public override HRESULT UpdateProperty(ref PropertyKey key, PropVariantRef currentValue, ref PropVariant newValue)
51 | {
52 | if (key == RibbonProperties.StringValue)
53 | {
54 | if (_stringValue != null)
55 | {
56 | newValue.SetString(_stringValue);
57 | }
58 | }
59 |
60 | return HRESULT.S_OK;
61 | }
62 |
63 | #region IStringValuePropertiesProvider Members
64 |
65 | ///
66 | /// String value property
67 | ///
68 | public string StringValue
69 | {
70 | get
71 | {
72 | if (_ribbon.Initalized)
73 | {
74 | PropVariant stringValue;
75 | HRESULT hr = _ribbon.Framework.GetUICommandProperty(_commandID, ref RibbonProperties.StringValue, out stringValue);
76 | if (NativeMethods.Succeeded(hr))
77 | {
78 | return (string)stringValue.Value;
79 | }
80 | }
81 |
82 | return _stringValue;
83 | }
84 | set
85 | {
86 | _stringValue = value;
87 |
88 | if (_ribbon.Initalized)
89 | {
90 | PropVariant stringValue;
91 | if ((_stringValue == null) || (_stringValue.Trim() == string.Empty))
92 | {
93 | stringValue = PropVariant.Empty;
94 | }
95 | else
96 | {
97 | stringValue = PropVariant.FromObject(_stringValue);
98 | }
99 | HRESULT hr = _ribbon.Framework.SetUICommandProperty(_commandID, ref RibbonProperties.StringValue, ref stringValue);
100 | }
101 | }
102 | }
103 |
104 | #endregion
105 | }
106 | }
107 |
--------------------------------------------------------------------------------
/RibbonLib/Controls/Properties/TooltipPropertiesProvider.cs:
--------------------------------------------------------------------------------
1 | //*****************************************************************************
2 | //
3 | // File: TooltipPropertiesProvider.cs
4 | //
5 | // Contents: Definition for tooltip properties provider
6 | //
7 | //*****************************************************************************
8 |
9 | using RibbonLib.Interop;
10 |
11 | namespace RibbonLib.Controls.Properties
12 | {
13 | ///
14 | /// Definition for tooltip properties provider interface
15 | ///
16 | public interface ITooltipPropertiesProvider
17 | {
18 | ///
19 | /// Tooltip title property
20 | ///
21 | string TooltipTitle { get; set; }
22 |
23 | ///
24 | /// Tooltip description property
25 | ///
26 | string TooltipDescription { get; set; }
27 | }
28 |
29 | ///
30 | /// Implementation of ITooltipPropertiesProvider
31 | ///
32 | public class TooltipPropertiesProvider : BasePropertiesProvider, ITooltipPropertiesProvider
33 | {
34 | ///
35 | /// TooltipPropertiesProvider ctor
36 | ///
37 | /// parent ribbon
38 | /// ribbon control command id
39 | public TooltipPropertiesProvider(Ribbon ribbon, uint commandId)
40 | : base(ribbon, commandId)
41 | {
42 | // add supported properties
43 | _supportedProperties.Add(RibbonProperties.TooltipTitle);
44 | _supportedProperties.Add(RibbonProperties.TooltipDescription);
45 | }
46 |
47 | private string _tooltipTitle;
48 | private string _tooltipDescription;
49 |
50 | ///
51 | /// Handles IUICommandHandler.UpdateProperty function for the supported properties
52 | ///
53 | /// The Property Key to update
54 | /// A pointer to the current value for key. This parameter can be NULL
55 | /// When this method returns, contains a pointer to the new value for key
56 | /// Returns S_OK if successful, or an error value otherwise
57 | public override HRESULT UpdateProperty(ref PropertyKey key, PropVariantRef currentValue, ref PropVariant newValue)
58 | {
59 | if (key == RibbonProperties.TooltipTitle)
60 | {
61 | if (_tooltipTitle != null)
62 | {
63 | newValue.SetString(_tooltipTitle);
64 | }
65 | }
66 | else if (key == RibbonProperties.TooltipDescription)
67 | {
68 | if (_tooltipDescription != null)
69 | {
70 | newValue.SetString(_tooltipDescription);
71 | }
72 | }
73 |
74 | return HRESULT.S_OK;
75 | }
76 |
77 | #region ITooltipPropertiesProvider Members
78 |
79 | ///
80 | /// Tooltip title property
81 | ///
82 | public string TooltipTitle
83 | {
84 | get
85 | {
86 | return _tooltipTitle;
87 | }
88 | set
89 | {
90 | _tooltipTitle = value;
91 | if (_ribbon.Initalized)
92 | {
93 | HRESULT hr = _ribbon.Framework.InvalidateUICommand(_commandID, Invalidations.Property, PropertyKeyRef.From(RibbonProperties.TooltipTitle));
94 | }
95 | }
96 | }
97 |
98 | ///
99 | /// Tooltip description property
100 | ///
101 | public string TooltipDescription
102 | {
103 | get
104 | {
105 | return _tooltipDescription;
106 | }
107 | set
108 | {
109 | _tooltipDescription = value;
110 | if (_ribbon.Initalized)
111 | {
112 | HRESULT hr = _ribbon.Framework.InvalidateUICommand(_commandID, Invalidations.Property, PropertyKeyRef.From(RibbonProperties.TooltipDescription));
113 | }
114 | }
115 | }
116 |
117 | #endregion
118 | }
119 | }
120 |
--------------------------------------------------------------------------------
/RibbonLib/Controls/RibbonApplicationMenu.cs:
--------------------------------------------------------------------------------
1 | //*****************************************************************************
2 | //
3 | // File: RibbonApplicationMenu.cs
4 | //
5 | // Contents: Helper class that wraps a ribbon application menu control.
6 | //
7 | //*****************************************************************************
8 |
9 | using RibbonLib.Controls.Properties;
10 |
11 | namespace RibbonLib.Controls
12 | {
13 | public class RibbonApplicationMenu : BaseRibbonControl,
14 | ITooltipPropertiesProvider
15 | {
16 | private TooltipPropertiesProvider _tooltipPropertiesProvider;
17 |
18 | public RibbonApplicationMenu(Ribbon ribbon, uint commandId)
19 | : base(ribbon, commandId)
20 | {
21 | AddPropertiesProvider(_tooltipPropertiesProvider = new TooltipPropertiesProvider(ribbon, commandId));
22 | }
23 |
24 | #region ITooltipPropertiesProvider Members
25 |
26 | public string TooltipTitle
27 | {
28 | get
29 | {
30 | return _tooltipPropertiesProvider.TooltipTitle;
31 | }
32 | set
33 | {
34 | _tooltipPropertiesProvider.TooltipTitle = value;
35 | }
36 | }
37 |
38 | public string TooltipDescription
39 | {
40 | get
41 | {
42 | return _tooltipPropertiesProvider.TooltipDescription;
43 | }
44 | set
45 | {
46 | _tooltipPropertiesProvider.TooltipDescription = value;
47 | }
48 | }
49 |
50 | #endregion
51 |
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/RibbonLib/Controls/RibbonDropDownButton.cs:
--------------------------------------------------------------------------------
1 | //*****************************************************************************
2 | //
3 | // File: RibbonDropDownButton.cs
4 | //
5 | // Contents: Helper class that wraps a ribbon drop down button control.
6 | //
7 | //*****************************************************************************
8 |
9 | using RibbonLib.Controls.Properties;
10 | using RibbonLib.Interop;
11 |
12 | namespace RibbonLib.Controls
13 | {
14 | public class RibbonDropDownButton : BaseRibbonControl,
15 | IEnabledPropertiesProvider,
16 | IKeytipPropertiesProvider,
17 | ILabelPropertiesProvider,
18 | ILabelDescriptionPropertiesProvider,
19 | IImagePropertiesProvider,
20 | ITooltipPropertiesProvider
21 | {
22 | private EnabledPropertiesProvider _enabledPropertiesProvider;
23 | private KeytipPropertiesProvider _keytipPropertiesProvider;
24 | private LabelPropertiesProvider _labelPropertiesProvider;
25 | private LabelDescriptionPropertiesProvider _labelDescriptionPropertiesProvider;
26 | private ImagePropertiesProvider _imagePropertiesProvider;
27 | private TooltipPropertiesProvider _tooltipPropertiesProvider;
28 |
29 | public RibbonDropDownButton(Ribbon ribbon, uint commandId)
30 | : base(ribbon, commandId)
31 | {
32 | AddPropertiesProvider(_enabledPropertiesProvider = new EnabledPropertiesProvider(ribbon, commandId));
33 | AddPropertiesProvider(_keytipPropertiesProvider = new KeytipPropertiesProvider(ribbon, commandId));
34 | AddPropertiesProvider(_labelPropertiesProvider = new LabelPropertiesProvider(ribbon, commandId));
35 | AddPropertiesProvider(_labelDescriptionPropertiesProvider = new LabelDescriptionPropertiesProvider(ribbon, commandId));
36 | AddPropertiesProvider(_imagePropertiesProvider = new ImagePropertiesProvider(ribbon, commandId));
37 | AddPropertiesProvider(_tooltipPropertiesProvider = new TooltipPropertiesProvider(ribbon, commandId));
38 | }
39 |
40 | #region IEnabledPropertiesProvider Members
41 |
42 | public bool Enabled
43 | {
44 | get
45 | {
46 | return _enabledPropertiesProvider.Enabled;
47 | }
48 | set
49 | {
50 | _enabledPropertiesProvider.Enabled = value;
51 | }
52 | }
53 |
54 | #endregion
55 |
56 | #region IKeytipPropertiesProvider Members
57 |
58 | public string Keytip
59 | {
60 | get
61 | {
62 | return _keytipPropertiesProvider.Keytip;
63 | }
64 | set
65 | {
66 | _keytipPropertiesProvider.Keytip = value;
67 | }
68 | }
69 |
70 | #endregion
71 |
72 | #region ILabelPropertiesProvider Members
73 |
74 | public string Label
75 | {
76 | get
77 | {
78 | return _labelPropertiesProvider.Label;
79 | }
80 | set
81 | {
82 | _labelPropertiesProvider.Label = value;
83 | }
84 | }
85 |
86 | #endregion
87 |
88 | #region ILabelDescriptionPropertiesProvider Members
89 |
90 | public string LabelDescription
91 | {
92 | get
93 | {
94 | return _labelDescriptionPropertiesProvider.LabelDescription;
95 | }
96 | set
97 | {
98 | _labelDescriptionPropertiesProvider.LabelDescription = value;
99 | }
100 | }
101 |
102 | #endregion
103 |
104 | #region IImagePropertiesProvider Members
105 |
106 | public IUIImage LargeImage
107 | {
108 | get
109 | {
110 | return _imagePropertiesProvider.LargeImage;
111 | }
112 | set
113 | {
114 | _imagePropertiesProvider.LargeImage = value;
115 | }
116 | }
117 |
118 | public IUIImage SmallImage
119 | {
120 | get
121 | {
122 | return _imagePropertiesProvider.SmallImage;
123 | }
124 | set
125 | {
126 | _imagePropertiesProvider.SmallImage = value;
127 | }
128 | }
129 |
130 | public IUIImage LargeHighContrastImage
131 | {
132 | get
133 | {
134 | return _imagePropertiesProvider.LargeHighContrastImage;
135 | }
136 | set
137 | {
138 | _imagePropertiesProvider.LargeHighContrastImage = value;
139 | }
140 | }
141 |
142 | public IUIImage SmallHighContrastImage
143 | {
144 | get
145 | {
146 | return _imagePropertiesProvider.SmallHighContrastImage;
147 | }
148 | set
149 | {
150 | _imagePropertiesProvider.SmallHighContrastImage = value;
151 | }
152 | }
153 |
154 | #endregion
155 |
156 | #region ITooltipPropertiesProvider Members
157 |
158 | public string TooltipTitle
159 | {
160 | get
161 | {
162 | return _tooltipPropertiesProvider.TooltipTitle;
163 | }
164 | set
165 | {
166 | _tooltipPropertiesProvider.TooltipTitle = value;
167 | }
168 | }
169 |
170 | public string TooltipDescription
171 | {
172 | get
173 | {
174 | return _tooltipPropertiesProvider.TooltipDescription;
175 | }
176 | set
177 | {
178 | _tooltipPropertiesProvider.TooltipDescription = value;
179 | }
180 | }
181 |
182 | #endregion
183 | }
184 | }
185 |
--------------------------------------------------------------------------------
/RibbonLib/Controls/RibbonGroup.cs:
--------------------------------------------------------------------------------
1 | //*****************************************************************************
2 | //
3 | // File: RibbonGroup.cs
4 | //
5 | // Contents: Helper class that wraps a ribbon group control.
6 | //
7 | //*****************************************************************************
8 |
9 | using RibbonLib.Controls.Properties;
10 | using RibbonLib.Interop;
11 |
12 | namespace RibbonLib.Controls
13 | {
14 | public class RibbonGroup : BaseRibbonControl,
15 | IKeytipPropertiesProvider,
16 | ILabelPropertiesProvider,
17 | IImagePropertiesProvider,
18 | ITooltipPropertiesProvider
19 | {
20 | private KeytipPropertiesProvider _keytipPropertiesProvider;
21 | private LabelPropertiesProvider _labelPropertiesProvider;
22 | private ImagePropertiesProvider _imagePropertiesProvider;
23 | private TooltipPropertiesProvider _tooltipPropertiesProvider;
24 |
25 | public RibbonGroup(Ribbon ribbon, uint commandId)
26 | : base(ribbon, commandId)
27 | {
28 | AddPropertiesProvider(_keytipPropertiesProvider = new KeytipPropertiesProvider(ribbon, commandId));
29 | AddPropertiesProvider(_labelPropertiesProvider = new LabelPropertiesProvider(ribbon, commandId));
30 | AddPropertiesProvider(_imagePropertiesProvider = new ImagePropertiesProvider(ribbon, commandId));
31 | AddPropertiesProvider(_tooltipPropertiesProvider = new TooltipPropertiesProvider(ribbon, commandId));
32 | }
33 |
34 | #region IKeytipPropertiesProvider Members
35 |
36 | public string Keytip
37 | {
38 | get
39 | {
40 | return _keytipPropertiesProvider.Keytip;
41 | }
42 | set
43 | {
44 | _keytipPropertiesProvider.Keytip = value;
45 | }
46 | }
47 |
48 | #endregion
49 |
50 | #region ILabelPropertiesProvider Members
51 |
52 | public string Label
53 | {
54 | get
55 | {
56 | return _labelPropertiesProvider.Label;
57 | }
58 | set
59 | {
60 | _labelPropertiesProvider.Label = value;
61 | }
62 | }
63 |
64 | #endregion
65 |
66 | #region IImagePropertiesProvider Members
67 |
68 | public IUIImage LargeImage
69 | {
70 | get
71 | {
72 | return _imagePropertiesProvider.LargeImage;
73 | }
74 | set
75 | {
76 | _imagePropertiesProvider.LargeImage = value;
77 | }
78 | }
79 |
80 | public IUIImage SmallImage
81 | {
82 | get
83 | {
84 | return _imagePropertiesProvider.SmallImage;
85 | }
86 | set
87 | {
88 | _imagePropertiesProvider.SmallImage = value;
89 | }
90 | }
91 |
92 | public IUIImage LargeHighContrastImage
93 | {
94 | get
95 | {
96 | return _imagePropertiesProvider.LargeHighContrastImage;
97 | }
98 | set
99 | {
100 | _imagePropertiesProvider.LargeHighContrastImage = value;
101 | }
102 | }
103 |
104 | public IUIImage SmallHighContrastImage
105 | {
106 | get
107 | {
108 | return _imagePropertiesProvider.SmallHighContrastImage;
109 | }
110 | set
111 | {
112 | _imagePropertiesProvider.SmallHighContrastImage = value;
113 | }
114 | }
115 |
116 | #endregion
117 |
118 | #region ITooltipPropertiesProvider Members
119 |
120 | public string TooltipTitle
121 | {
122 | get
123 | {
124 | return _tooltipPropertiesProvider.TooltipTitle;
125 | }
126 | set
127 | {
128 | _tooltipPropertiesProvider.TooltipTitle = value;
129 | }
130 | }
131 |
132 | public string TooltipDescription
133 | {
134 | get
135 | {
136 | return _tooltipPropertiesProvider.TooltipDescription;
137 | }
138 | set
139 | {
140 | _tooltipPropertiesProvider.TooltipDescription = value;
141 | }
142 | }
143 |
144 | #endregion
145 | }
146 | }
147 |
--------------------------------------------------------------------------------
/RibbonLib/Controls/RibbonHelpButton.cs:
--------------------------------------------------------------------------------
1 | //*****************************************************************************
2 | //
3 | // File: RibbonHelpButton.cs
4 | //
5 | // Contents: Helper class that wraps a ribbon help button control.
6 | //
7 | //*****************************************************************************
8 |
9 | using RibbonLib.Controls.Events;
10 | using RibbonLib.Controls.Properties;
11 | using System;
12 |
13 | namespace RibbonLib.Controls
14 | {
15 | public class RibbonHelpButton : BaseRibbonControl,
16 | IKeytipPropertiesProvider,
17 | ILabelPropertiesProvider,
18 | ITooltipPropertiesProvider,
19 | IExecuteEventsProvider
20 | {
21 | private KeytipPropertiesProvider _keytipPropertiesProvider;
22 | private LabelPropertiesProvider _labelPropertiesProvider;
23 | private TooltipPropertiesProvider _tooltipPropertiesProvider;
24 | private ExecuteEventsProvider _executeEventsProvider;
25 |
26 | public RibbonHelpButton(Ribbon ribbon, uint commandId)
27 | : base(ribbon, commandId)
28 | {
29 | AddPropertiesProvider(_keytipPropertiesProvider = new KeytipPropertiesProvider(ribbon, commandId));
30 | AddPropertiesProvider(_labelPropertiesProvider = new LabelPropertiesProvider(ribbon, commandId));
31 | AddPropertiesProvider(_tooltipPropertiesProvider = new TooltipPropertiesProvider(ribbon, commandId));
32 |
33 | AddEventsProvider(_executeEventsProvider = new ExecuteEventsProvider(this));
34 | }
35 |
36 | #region IKeytipPropertiesProvider Members
37 |
38 | public string Keytip
39 | {
40 | get
41 | {
42 | return _keytipPropertiesProvider.Keytip;
43 | }
44 | set
45 | {
46 | _keytipPropertiesProvider.Keytip = value;
47 | }
48 | }
49 |
50 | #endregion
51 |
52 | #region ILabelPropertiesProvider Members
53 |
54 | public string Label
55 | {
56 | get
57 | {
58 | return _labelPropertiesProvider.Label;
59 | }
60 | set
61 | {
62 | _labelPropertiesProvider.Label = value;
63 | }
64 | }
65 |
66 | #endregion
67 |
68 | #region ITooltipPropertiesProvider Members
69 |
70 | public string TooltipTitle
71 | {
72 | get
73 | {
74 | return _tooltipPropertiesProvider.TooltipTitle;
75 | }
76 | set
77 | {
78 | _tooltipPropertiesProvider.TooltipTitle = value;
79 | }
80 | }
81 |
82 | public string TooltipDescription
83 | {
84 | get
85 | {
86 | return _tooltipPropertiesProvider.TooltipDescription;
87 | }
88 | set
89 | {
90 | _tooltipPropertiesProvider.TooltipDescription = value;
91 | }
92 | }
93 |
94 | #endregion
95 |
96 | #region IExecuteEventsProvider Members
97 |
98 | public event EventHandler ExecuteEvent
99 | {
100 | add
101 | {
102 | _executeEventsProvider.ExecuteEvent += value;
103 | }
104 | remove
105 | {
106 | _executeEventsProvider.ExecuteEvent -= value;
107 | }
108 | }
109 |
110 | #endregion
111 | }
112 | }
113 |
--------------------------------------------------------------------------------
/RibbonLib/Controls/RibbonMenuGroup.cs:
--------------------------------------------------------------------------------
1 | //*****************************************************************************
2 | //
3 | // File: RibbonMenuGroup.cs
4 | //
5 | // Contents: Helper class that wraps a ribbon menu group control.
6 | //
7 | //*****************************************************************************
8 |
9 | using RibbonLib.Controls.Properties;
10 |
11 | namespace RibbonLib.Controls
12 | {
13 | public class RibbonMenuGroup : BaseRibbonControl,
14 | IEnabledPropertiesProvider,
15 | IKeytipPropertiesProvider,
16 | ILabelPropertiesProvider,
17 | ITooltipPropertiesProvider
18 | {
19 | private EnabledPropertiesProvider _enabledPropertiesProvider;
20 | private KeytipPropertiesProvider _keytipPropertiesProvider;
21 | private LabelPropertiesProvider _labelPropertiesProvider;
22 | private TooltipPropertiesProvider _tooltipPropertiesProvider;
23 |
24 | public RibbonMenuGroup(Ribbon ribbon, uint commandId)
25 | : base(ribbon, commandId)
26 | {
27 | AddPropertiesProvider(_enabledPropertiesProvider = new EnabledPropertiesProvider(ribbon, commandId));
28 | AddPropertiesProvider(_keytipPropertiesProvider = new KeytipPropertiesProvider(ribbon, commandId));
29 | AddPropertiesProvider(_labelPropertiesProvider = new LabelPropertiesProvider(ribbon, commandId));
30 | AddPropertiesProvider(_tooltipPropertiesProvider = new TooltipPropertiesProvider(ribbon, commandId));
31 | }
32 |
33 | #region IEnabledPropertiesProvider Members
34 |
35 | public bool Enabled
36 | {
37 | get
38 | {
39 | return _enabledPropertiesProvider.Enabled;
40 | }
41 | set
42 | {
43 | _enabledPropertiesProvider.Enabled = value;
44 | }
45 | }
46 |
47 | #endregion
48 |
49 | #region IKeytipPropertiesProvider Members
50 |
51 | public string Keytip
52 | {
53 | get
54 | {
55 | return _keytipPropertiesProvider.Keytip;
56 | }
57 | set
58 | {
59 | _keytipPropertiesProvider.Keytip = value;
60 | }
61 | }
62 |
63 | #endregion
64 |
65 | #region ILabelPropertiesProvider Members
66 |
67 | public string Label
68 | {
69 | get
70 | {
71 | return _labelPropertiesProvider.Label;
72 | }
73 | set
74 | {
75 | _labelPropertiesProvider.Label = value;
76 | }
77 | }
78 |
79 | #endregion
80 |
81 | #region ITooltipPropertiesProvider Members
82 |
83 | public string TooltipTitle
84 | {
85 | get
86 | {
87 | return _tooltipPropertiesProvider.TooltipTitle;
88 | }
89 | set
90 | {
91 | _tooltipPropertiesProvider.TooltipTitle = value;
92 | }
93 | }
94 |
95 | public string TooltipDescription
96 | {
97 | get
98 | {
99 | return _tooltipPropertiesProvider.TooltipDescription;
100 | }
101 | set
102 | {
103 | _tooltipPropertiesProvider.TooltipDescription = value;
104 | }
105 | }
106 |
107 | #endregion
108 | }
109 | }
110 |
--------------------------------------------------------------------------------
/RibbonLib/Controls/RibbonQuickAccessToolbar.cs:
--------------------------------------------------------------------------------
1 | //*****************************************************************************
2 | //
3 | // File: RibbonQuickAccessToolbar.cs
4 | //
5 | // Contents: Helper class that wraps the ribbon quick access toolbar.
6 | //
7 | //*****************************************************************************
8 |
9 | using RibbonLib.Controls.Events;
10 | using RibbonLib.Interop;
11 | using System;
12 |
13 | namespace RibbonLib.Controls
14 | {
15 | public class RibbonQuickAccessToolbar : IRibbonControl,
16 | IExecuteEventsProvider
17 | {
18 | ///
19 | /// reference for parent ribbon class
20 | ///
21 | protected Ribbon _ribbon;
22 |
23 | ///
24 | /// QAT command id
25 | ///
26 | protected uint _commandID;
27 |
28 | ///
29 | /// handler for the customize button
30 | ///
31 | protected RibbonButton _customizeButton;
32 |
33 | private IUICollection _itemsSource = new UICollection();
34 |
35 | public RibbonQuickAccessToolbar(Ribbon ribbon, uint commandId)
36 | {
37 | _ribbon = ribbon;
38 | _commandID = commandId;
39 | }
40 |
41 | public RibbonQuickAccessToolbar(Ribbon ribbon, uint commandId, uint customizeCommandId) : this(ribbon, commandId)
42 | {
43 | _customizeButton = new RibbonButton(_ribbon, customizeCommandId);
44 | }
45 |
46 | #region IRibbonControl Members
47 |
48 | public uint CommandID
49 | {
50 | get
51 | {
52 | return _commandID;
53 | }
54 | }
55 |
56 | public HRESULT Execute(ExecutionVerb verb, PropertyKeyRef key, PropVariantRef currentValue, IUISimplePropertySet commandExecutionProperties)
57 | {
58 | return HRESULT.S_OK;
59 | }
60 |
61 | public HRESULT UpdateProperty(ref PropertyKey key, PropVariantRef currentValue, ref PropVariant newValue)
62 | {
63 | if (key == RibbonProperties.ItemsSource)
64 | {
65 | if (_itemsSource != null)
66 | {
67 | IUICollection itemsSource = (IUICollection)currentValue.PropVariant.Value;
68 |
69 | itemsSource.Clear();
70 | uint count;
71 | _itemsSource.GetCount(out count);
72 | for (uint i = 0; i < count; ++i)
73 | {
74 | object item;
75 | _itemsSource.GetItem(i, out item);
76 | itemsSource.Add(item);
77 | }
78 | }
79 | }
80 | return HRESULT.S_OK;
81 | }
82 |
83 | ///
84 | /// Items source property
85 | ///
86 | public IUICollection ItemsSource
87 | {
88 | get
89 | {
90 | if (_ribbon.Initalized)
91 | {
92 | PropVariant unknownValue;
93 | HRESULT hr = _ribbon.Framework.GetUICommandProperty(_commandID, ref RibbonProperties.ItemsSource, out unknownValue);
94 | if (NativeMethods.Succeeded(hr))
95 | {
96 | return (IUICollection)unknownValue.Value;
97 | }
98 | }
99 |
100 | return _itemsSource;
101 | }
102 | }
103 |
104 | #endregion
105 |
106 | #region IExecuteEventsProvider Members
107 |
108 | public event EventHandler ExecuteEvent
109 | {
110 | add
111 | {
112 | if (_customizeButton != null)
113 | {
114 | _customizeButton.ExecuteEvent += value;
115 | }
116 | }
117 | remove
118 | {
119 | if (_customizeButton != null)
120 | {
121 | _customizeButton.ExecuteEvent -= value;
122 | }
123 | }
124 | }
125 |
126 | #endregion
127 | }
128 | }
129 |
--------------------------------------------------------------------------------
/RibbonLib/Controls/RibbonRecentItems.cs:
--------------------------------------------------------------------------------
1 | //*****************************************************************************
2 | //
3 | // File: RibbonRecentItems.cs
4 | //
5 | // Contents: Helper class that wraps a ribbon recent items.
6 | //
7 | //*****************************************************************************
8 |
9 | using System.Collections.Generic;
10 | using RibbonLib.Controls.Events;
11 | using RibbonLib.Controls.Properties;
12 | using System;
13 |
14 | namespace RibbonLib.Controls
15 | {
16 | public class RibbonRecentItems : BaseRibbonControl,
17 | IRecentItemsPropertiesProvider,
18 | IKeytipPropertiesProvider,
19 | IExecuteEventsProvider
20 | {
21 | private KeytipPropertiesProvider _keytipPropertiesProvider;
22 | private RecentItemsPropertiesProvider _recentItemsPropertiesProvider;
23 | private ExecuteEventsProvider _executeEventsProvider;
24 |
25 | public RibbonRecentItems(Ribbon ribbon, uint commandId)
26 | : base(ribbon, commandId)
27 | {
28 | AddPropertiesProvider(_recentItemsPropertiesProvider= new RecentItemsPropertiesProvider(ribbon, commandId));
29 | AddPropertiesProvider(_keytipPropertiesProvider = new KeytipPropertiesProvider(ribbon, commandId));
30 |
31 | AddEventsProvider(_executeEventsProvider = new ExecuteEventsProvider(this));
32 | }
33 |
34 | #region IRecentItemsPropertiesProvider Members
35 |
36 | public IList RecentItems
37 | {
38 | get
39 | {
40 | return _recentItemsPropertiesProvider.RecentItems;
41 | }
42 | set
43 | {
44 | _recentItemsPropertiesProvider.RecentItems = value;
45 | }
46 | }
47 |
48 | #endregion
49 |
50 | #region IKeytipPropertiesProvider Members
51 |
52 | public string Keytip
53 | {
54 | get
55 | {
56 | return _keytipPropertiesProvider.Keytip;
57 | }
58 | set
59 | {
60 | _keytipPropertiesProvider.Keytip = value;
61 | }
62 | }
63 |
64 | #endregion
65 |
66 | #region IExecuteEventsProvider Members
67 |
68 | public event EventHandler ExecuteEvent
69 | {
70 | add
71 | {
72 | _executeEventsProvider.ExecuteEvent += value;
73 | }
74 | remove
75 | {
76 | _executeEventsProvider.ExecuteEvent -= value;
77 | }
78 | }
79 |
80 | #endregion
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/RibbonLib/Controls/RibbonSplitButton.cs:
--------------------------------------------------------------------------------
1 | //*****************************************************************************
2 | //
3 | // File: RibbonSplitButton.cs
4 | //
5 | // Contents: Helper class that wraps a ribbon split button control.
6 | //
7 | //*****************************************************************************
8 |
9 | using RibbonLib.Controls.Properties;
10 |
11 | namespace RibbonLib.Controls
12 | {
13 | public class RibbonSplitButton : BaseRibbonControl,
14 | IEnabledPropertiesProvider,
15 | IKeytipPropertiesProvider,
16 | ITooltipPropertiesProvider
17 | {
18 | private EnabledPropertiesProvider _enabledPropertiesProvider;
19 | private KeytipPropertiesProvider _keytipPropertiesProvider;
20 | private TooltipPropertiesProvider _tooltipPropertiesProvider;
21 |
22 | public RibbonSplitButton(Ribbon ribbon, uint commandId)
23 | : base(ribbon, commandId)
24 | {
25 | AddPropertiesProvider(_enabledPropertiesProvider = new EnabledPropertiesProvider(ribbon, commandId));
26 | AddPropertiesProvider(_keytipPropertiesProvider = new KeytipPropertiesProvider(ribbon, commandId));
27 | AddPropertiesProvider(_tooltipPropertiesProvider = new TooltipPropertiesProvider(ribbon, commandId));
28 | }
29 |
30 | #region IEnabledPropertiesProvider Members
31 |
32 | public bool Enabled
33 | {
34 | get
35 | {
36 | return _enabledPropertiesProvider.Enabled;
37 | }
38 | set
39 | {
40 | _enabledPropertiesProvider.Enabled = value;
41 | }
42 | }
43 |
44 | #endregion
45 |
46 | #region IKeytipPropertiesProvider Members
47 |
48 | public string Keytip
49 | {
50 | get
51 | {
52 | return _keytipPropertiesProvider.Keytip;
53 | }
54 | set
55 | {
56 | _keytipPropertiesProvider.Keytip = value;
57 | }
58 | }
59 |
60 | #endregion
61 |
62 | #region ITooltipPropertiesProvider Members
63 |
64 | public string TooltipTitle
65 | {
66 | get
67 | {
68 | return _tooltipPropertiesProvider.TooltipTitle;
69 | }
70 | set
71 | {
72 | _tooltipPropertiesProvider.TooltipTitle = value;
73 | }
74 | }
75 |
76 | public string TooltipDescription
77 | {
78 | get
79 | {
80 | return _tooltipPropertiesProvider.TooltipDescription;
81 | }
82 | set
83 | {
84 | _tooltipPropertiesProvider.TooltipDescription = value;
85 | }
86 | }
87 |
88 | #endregion
89 | }
90 | }
91 |
--------------------------------------------------------------------------------
/RibbonLib/Controls/RibbonTab.cs:
--------------------------------------------------------------------------------
1 | //*****************************************************************************
2 | //
3 | // File: RibbonTab.cs
4 | //
5 | // Contents: Helper class that wraps a ribbon tab control.
6 | //
7 | //*****************************************************************************
8 |
9 | using RibbonLib.Controls.Properties;
10 |
11 | namespace RibbonLib.Controls
12 | {
13 | public class RibbonTab : BaseRibbonControl,
14 | IKeytipPropertiesProvider,
15 | ILabelPropertiesProvider,
16 | ITooltipPropertiesProvider
17 | {
18 | private KeytipPropertiesProvider _keytipPropertiesProvider;
19 | private LabelPropertiesProvider _labelPropertiesProvider;
20 | private TooltipPropertiesProvider _tooltipPropertiesProvider;
21 |
22 | public RibbonTab(Ribbon ribbon, uint commandId)
23 | : base(ribbon, commandId)
24 | {
25 | AddPropertiesProvider(_keytipPropertiesProvider = new KeytipPropertiesProvider(ribbon, commandId));
26 | AddPropertiesProvider(_labelPropertiesProvider = new LabelPropertiesProvider(ribbon, commandId));
27 | AddPropertiesProvider(_tooltipPropertiesProvider = new TooltipPropertiesProvider(ribbon, commandId));
28 | }
29 |
30 | #region IKeytipPropertiesProvider Members
31 |
32 | public string Keytip
33 | {
34 | get
35 | {
36 | return _keytipPropertiesProvider.Keytip;
37 | }
38 | set
39 | {
40 | _keytipPropertiesProvider.Keytip = value;
41 | }
42 | }
43 |
44 | #endregion
45 |
46 | #region ILabelPropertiesProvider Members
47 |
48 | public string Label
49 | {
50 | get
51 | {
52 | return _labelPropertiesProvider.Label;
53 | }
54 | set
55 | {
56 | _labelPropertiesProvider.Label = value;
57 | }
58 | }
59 |
60 | #endregion
61 |
62 | #region ITooltipPropertiesProvider Members
63 |
64 | public string TooltipTitle
65 | {
66 | get
67 | {
68 | return _tooltipPropertiesProvider.TooltipTitle;
69 | }
70 | set
71 | {
72 | _tooltipPropertiesProvider.TooltipTitle = value;
73 | }
74 | }
75 |
76 | public string TooltipDescription
77 | {
78 | get
79 | {
80 | return _tooltipPropertiesProvider.TooltipDescription;
81 | }
82 | set
83 | {
84 | _tooltipPropertiesProvider.TooltipDescription = value;
85 | }
86 | }
87 |
88 | #endregion
89 | }
90 | }
91 |
--------------------------------------------------------------------------------
/RibbonLib/Controls/RibbonTabGroup.cs:
--------------------------------------------------------------------------------
1 | //*****************************************************************************
2 | //
3 | // File: RibbonTabGroup.cs
4 | //
5 | // Contents: Helper class that wraps a ribbon tab group control.
6 | //
7 | //*****************************************************************************
8 |
9 | using RibbonLib.Controls.Properties;
10 | using RibbonLib.Interop;
11 |
12 | namespace RibbonLib.Controls
13 | {
14 | public class RibbonTabGroup : BaseRibbonControl,
15 | IContextAvailablePropertiesProvider,
16 | IKeytipPropertiesProvider,
17 | ILabelPropertiesProvider,
18 | ITooltipPropertiesProvider
19 | {
20 | private ContextAvailablePropertiesProvider _contextAvailablePropertiesProvider;
21 | private KeytipPropertiesProvider _keytipPropertiesProvider;
22 | private LabelPropertiesProvider _labelPropertiesProvider;
23 | private TooltipPropertiesProvider _tooltipPropertiesProvider;
24 |
25 | public RibbonTabGroup(Ribbon ribbon, uint commandId)
26 | : base(ribbon, commandId)
27 | {
28 | AddPropertiesProvider(_contextAvailablePropertiesProvider = new ContextAvailablePropertiesProvider(ribbon, commandId));
29 | AddPropertiesProvider(_keytipPropertiesProvider = new KeytipPropertiesProvider(ribbon, commandId));
30 | AddPropertiesProvider(_labelPropertiesProvider = new LabelPropertiesProvider(ribbon, commandId));
31 | AddPropertiesProvider(_tooltipPropertiesProvider = new TooltipPropertiesProvider(ribbon, commandId));
32 | }
33 |
34 | #region IContextAvailablePropertiesProvider Members
35 |
36 | public ContextAvailability ContextAvailable
37 | {
38 | get
39 | {
40 | return _contextAvailablePropertiesProvider.ContextAvailable;
41 | }
42 | set
43 | {
44 | _contextAvailablePropertiesProvider.ContextAvailable = value;
45 | }
46 | }
47 |
48 | #endregion
49 |
50 | #region IKeytipPropertiesProvider Members
51 |
52 | public string Keytip
53 | {
54 | get
55 | {
56 | return _keytipPropertiesProvider.Keytip;
57 | }
58 | set
59 | {
60 | _keytipPropertiesProvider.Keytip = value;
61 | }
62 | }
63 |
64 | #endregion
65 |
66 | #region ILabelPropertiesProvider Members
67 |
68 | public string Label
69 | {
70 | get
71 | {
72 | return _labelPropertiesProvider.Label;
73 | }
74 | set
75 | {
76 | _labelPropertiesProvider.Label = value;
77 | }
78 | }
79 |
80 | #endregion
81 |
82 | #region ITooltipPropertiesProvider Members
83 |
84 | public string TooltipTitle
85 | {
86 | get
87 | {
88 | return _tooltipPropertiesProvider.TooltipTitle;
89 | }
90 | set
91 | {
92 | _tooltipPropertiesProvider.TooltipTitle = value;
93 | }
94 | }
95 |
96 | public string TooltipDescription
97 | {
98 | get
99 | {
100 | return _tooltipPropertiesProvider.TooltipDescription;
101 | }
102 | set
103 | {
104 | _tooltipPropertiesProvider.TooltipDescription = value;
105 | }
106 | }
107 |
108 | #endregion
109 | }
110 | }
111 |
--------------------------------------------------------------------------------
/RibbonLib/Design/ResourceFileNameEditor.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Windows.Forms;
7 |
8 | namespace RibbonLib.Design
9 | {
10 | public class ResourceFileNameEditor : System.Windows.Forms.Design.FileNameEditor
11 | {
12 |
13 | protected override void InitializeDialog(OpenFileDialog openFileDialog)
14 | {
15 | base.InitializeDialog(openFileDialog);
16 | openFileDialog.DefaultExt = "*.ribbon";
17 | openFileDialog.Filter = "Ribbon resource definition|*.ribbon";
18 | }
19 |
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/RibbonLib/FontPropertyStore.cs:
--------------------------------------------------------------------------------
1 | //*****************************************************************************
2 | //
3 | // File: FontPropertyStore.cs
4 | //
5 | // Contents: Helper class that wraps an IPropertyStore interface that
6 | // contains font properties
7 | //
8 | //*****************************************************************************
9 |
10 | using System;
11 | using System.Drawing;
12 | using RibbonLib.Interop;
13 |
14 | namespace RibbonLib
15 | {
16 | public class FontPropertyStore
17 | {
18 | private IPropertyStore _propertyStore;
19 |
20 | public FontPropertyStore(IPropertyStore propertyStore)
21 | {
22 | if (propertyStore == null)
23 | {
24 | throw new ArgumentException("Parameter propertyStore cannot be null.", "propertyStore");
25 | }
26 | _propertyStore = propertyStore;
27 | }
28 |
29 | public string Family
30 | {
31 | get
32 | {
33 | PropVariant propFamily;
34 | HRESULT hr = _propertyStore.GetValue(ref RibbonProperties.FontProperties_Family, out propFamily);
35 | return (string)propFamily.Value;
36 | }
37 | }
38 |
39 | public decimal Size
40 | {
41 | get
42 | {
43 | PropVariant propSize;
44 | HRESULT hr = _propertyStore.GetValue(ref RibbonProperties.FontProperties_Size, out propSize);
45 | return (decimal)propSize.Value;
46 | }
47 | }
48 |
49 | public FontProperties Bold
50 | {
51 | get
52 | {
53 | PropVariant propBold;
54 | HRESULT hr = _propertyStore.GetValue(ref RibbonProperties.FontProperties_Bold, out propBold);
55 | return (FontProperties)(uint)propBold.Value;
56 | }
57 | }
58 |
59 | public FontProperties Italic
60 | {
61 | get
62 | {
63 | PropVariant propItalic;
64 | HRESULT hr = _propertyStore.GetValue(ref RibbonProperties.FontProperties_Italic, out propItalic);
65 | return (FontProperties)(uint)propItalic.Value;
66 | }
67 | }
68 |
69 |
70 | public FontUnderline Underline
71 | {
72 | get
73 | {
74 | PropVariant propUnderline;
75 | HRESULT hr = _propertyStore.GetValue(ref RibbonProperties.FontProperties_Underline, out propUnderline);
76 | return (FontUnderline)(uint)propUnderline.Value;
77 | }
78 | }
79 |
80 | public FontProperties Strikethrough
81 | {
82 | get
83 | {
84 | PropVariant propStrikethrough;
85 | HRESULT hr = _propertyStore.GetValue(ref RibbonProperties.FontProperties_Strikethrough, out propStrikethrough);
86 | return (FontProperties)(uint)propStrikethrough.Value;
87 | }
88 | }
89 |
90 | public Color ForegroundColor
91 | {
92 | get
93 | {
94 | PropVariant propForegroundColor;
95 | HRESULT hr = _propertyStore.GetValue(ref RibbonProperties.FontProperties_ForegroundColor, out propForegroundColor);
96 | return ColorTranslator.FromWin32((int)(uint)propForegroundColor.Value);
97 | }
98 | }
99 |
100 | public SwatchColorType ForegroundColorType
101 | {
102 | get
103 | {
104 | PropVariant propForegroundColorType;
105 | HRESULT hr = _propertyStore.GetValue(ref RibbonProperties.FontProperties_ForegroundColorType, out propForegroundColorType);
106 | return (SwatchColorType)(uint)propForegroundColorType.Value;
107 | }
108 | }
109 |
110 | public FontDeltaSize DeltaSize
111 | {
112 | get
113 | {
114 | PropVariant propDeltaSize;
115 | HRESULT hr = _propertyStore.GetValue(ref RibbonProperties.FontProperties_DeltaSize, out propDeltaSize);
116 | return (FontDeltaSize)(uint)propDeltaSize.Value;
117 | }
118 | }
119 |
120 | public Color BackgroundColor
121 | {
122 | get
123 | {
124 | PropVariant propBackgroundColor;
125 | HRESULT hr = _propertyStore.GetValue(ref RibbonProperties.FontProperties_BackgroundColor, out propBackgroundColor);
126 | return ColorTranslator.FromWin32((int)(uint)propBackgroundColor.Value);
127 | }
128 | }
129 |
130 | public SwatchColorType BackgroundColorType
131 | {
132 | get
133 | {
134 | PropVariant propBackgroundColorType;
135 | HRESULT hr = _propertyStore.GetValue(ref RibbonProperties.FontProperties_BackgroundColorType, out propBackgroundColorType);
136 | return (SwatchColorType)(uint)propBackgroundColorType.Value;
137 | }
138 | }
139 |
140 | public FontVerticalPosition VerticalPositioning
141 | {
142 | get
143 | {
144 | PropVariant propVerticalPositioning;
145 | HRESULT hr = _propertyStore.GetValue(ref RibbonProperties.FontProperties_VerticalPositioning, out propVerticalPositioning);
146 | return (FontVerticalPosition)(uint)propVerticalPositioning.Value;
147 | }
148 | }
149 |
150 | }
151 | }
152 |
--------------------------------------------------------------------------------
/RibbonLib/GalleryCommandPropertySet.cs:
--------------------------------------------------------------------------------
1 | //*****************************************************************************
2 | //
3 | // File: GalleryCommandPropertySet.cs
4 | //
5 | // Contents: Helper class that wraps a gallery command simple property set.
6 | //
7 | //*****************************************************************************
8 |
9 | using System.Diagnostics;
10 | using RibbonLib.Interop;
11 |
12 | namespace RibbonLib
13 | {
14 | public class GalleryCommandPropertySet : IUISimplePropertySet
15 | {
16 | private uint? _commandID;
17 | private CommandType? _commandType;
18 | private uint? _categoryID;
19 |
20 | public uint CommandID
21 | {
22 | get
23 | {
24 | return _commandID.GetValueOrDefault();
25 | }
26 | set
27 | {
28 | _commandID = value;
29 | }
30 | }
31 |
32 | public CommandType CommandType
33 | {
34 | get
35 | {
36 | return _commandType.GetValueOrDefault();
37 | }
38 | set
39 | {
40 | _commandType = value;
41 | }
42 | }
43 |
44 | public uint CategoryID
45 | {
46 | get
47 | {
48 | return _categoryID.GetValueOrDefault(Constants.UI_Collection_InvalidIndex);
49 | }
50 | set
51 | {
52 | _categoryID = value;
53 | }
54 | }
55 |
56 | #region IUISimplePropertySet Members
57 |
58 | public HRESULT GetValue(ref PropertyKey key, out PropVariant value)
59 | {
60 | if (key == RibbonProperties.CommandID)
61 | {
62 | if (_commandID.HasValue)
63 | {
64 | value = PropVariant.FromObject(_commandID.Value);
65 | }
66 | else
67 | {
68 | value = PropVariant.Empty;
69 | }
70 | return HRESULT.S_OK;
71 | }
72 |
73 | if (key == RibbonProperties.CommandType)
74 | {
75 | if (_commandType.HasValue)
76 | {
77 | value = PropVariant.FromObject((uint)_commandType.Value);
78 | }
79 | else
80 | {
81 | value = PropVariant.Empty;
82 | }
83 | return HRESULT.S_OK;
84 | }
85 |
86 | if (key == RibbonProperties.CategoryID)
87 | {
88 | if (_categoryID.HasValue)
89 | {
90 | value = PropVariant.FromObject(_categoryID.Value);
91 | }
92 | else
93 | {
94 | value = PropVariant.Empty;
95 | }
96 | return HRESULT.S_OK;
97 | }
98 |
99 | Debug.WriteLine(string.Format("Class {0} does not support property: {1}.", GetType(), RibbonProperties.GetPropertyKeyName(ref key)));
100 |
101 | value = PropVariant.Empty;
102 | return HRESULT.E_NOTIMPL;
103 | }
104 |
105 | #endregion
106 | }
107 | }
108 |
--------------------------------------------------------------------------------
/RibbonLib/GalleryItemPropertySet.cs:
--------------------------------------------------------------------------------
1 | //*****************************************************************************
2 | //
3 | // File: GalleryItemPropertySet.cs
4 | //
5 | // Contents: Helper class that wraps a gallery item simple property set.
6 | //
7 | //*****************************************************************************
8 |
9 | using System.Diagnostics;
10 | using RibbonLib.Interop;
11 |
12 | namespace RibbonLib
13 | {
14 | public class GalleryItemPropertySet : IUISimplePropertySet
15 | {
16 | private string _label;
17 | private uint? _categoryID;
18 | private IUIImage _itemImage;
19 |
20 | public string Label
21 | {
22 | get
23 | {
24 | return _label;
25 | }
26 | set
27 | {
28 | _label = value;
29 | }
30 | }
31 |
32 | public uint CategoryID
33 | {
34 | get
35 | {
36 | return _categoryID.GetValueOrDefault(Constants.UI_Collection_InvalidIndex);
37 | }
38 | set
39 | {
40 | _categoryID = value;
41 | }
42 | }
43 |
44 | public IUIImage ItemImage
45 | {
46 | get
47 | {
48 | return _itemImage;
49 | }
50 | set
51 | {
52 | _itemImage = value;
53 | }
54 | }
55 |
56 | #region IUISimplePropertySet Members
57 |
58 | public HRESULT GetValue(ref PropertyKey key, out PropVariant value)
59 | {
60 | if (key == RibbonProperties.Label)
61 | {
62 | if ((_label == null) || (_label.Trim() == string.Empty))
63 | {
64 | value = PropVariant.Empty;
65 | }
66 | else
67 | {
68 | value = PropVariant.FromObject(_label);
69 | }
70 | return HRESULT.S_OK;
71 | }
72 |
73 | if (key == RibbonProperties.CategoryID)
74 | {
75 | if (_categoryID.HasValue)
76 | {
77 | value = PropVariant.FromObject(_categoryID.Value);
78 | }
79 | else
80 | {
81 | value = PropVariant.Empty;
82 | }
83 | return HRESULT.S_OK;
84 | }
85 |
86 | if (key == RibbonProperties.ItemImage)
87 | {
88 | if (_itemImage != null)
89 | {
90 | value = new PropVariant();
91 | value.SetIUnknown(_itemImage);
92 | }
93 | else
94 | {
95 | value = PropVariant.Empty;
96 | }
97 | return HRESULT.S_OK;
98 | }
99 |
100 | Debug.WriteLine(string.Format("Class {0} does not support property: {1}.", GetType().ToString(), RibbonProperties.GetPropertyKeyName(ref key)));
101 |
102 | value = PropVariant.Empty;
103 | return HRESULT.E_NOTIMPL;
104 | }
105 |
106 | #endregion
107 | }
108 | }
109 |
--------------------------------------------------------------------------------
/RibbonLib/IRibbonControl.cs:
--------------------------------------------------------------------------------
1 | //*****************************************************************************
2 | //
3 | // File: IRibbonControl.cs
4 | //
5 | // Contents: Definition of IRibbonControl interface.
6 | // Each ribbon control helper class should implement this
7 | // interface according to the control's actions and properties.
8 | //
9 | //*****************************************************************************
10 |
11 | using RibbonLib.Interop;
12 |
13 | namespace RibbonLib
14 | {
15 | internal interface IRibbonControl
16 | {
17 | ///
18 | /// Ribbon control command id
19 | ///
20 | uint CommandID { get; }
21 |
22 | ///
23 | /// Handles IUICommandHandler.Execute function for this ribbon control
24 | ///
25 | /// the mode of execution
26 | /// the property that has changed
27 | /// the new value of the property that has changed
28 | /// additional data for this execution
29 | /// Returns S_OK if successful, or an error value otherwise
30 | HRESULT Execute(ExecutionVerb verb, PropertyKeyRef key, PropVariantRef currentValue, IUISimplePropertySet commandExecutionProperties);
31 |
32 | ///
33 | /// Handles IUICommandHandler.UpdateProperty function for this ribbon control
34 | ///
35 | /// The Property Key to update
36 | /// A pointer to the current value for key. This parameter can be NULL
37 | /// When this method returns, contains a pointer to the new value for key
38 | /// Returns S_OK if successful, or an error value otherwise
39 | HRESULT UpdateProperty(ref PropertyKey key, PropVariantRef currentValue, ref PropVariant newValue);
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/RibbonLib/IRibbonForm.cs:
--------------------------------------------------------------------------------
1 | //*****************************************************************************
2 | //
3 | // File: IRibbonForm.cs
4 | //
5 | // Contents: Definition of IRibbonForm interface.
6 | // Each WinForm that wan to have a ribbon in it should implement
7 | // this interface.
8 | //
9 | //*****************************************************************************
10 |
11 | using System;
12 |
13 | namespace RibbonLib
14 | {
15 | ///
16 | /// IRibbonForm interface should be implemented by the main form who want the ribbon
17 | ///
18 | public interface IRibbonForm
19 | {
20 | ///
21 | /// Getter for the main form window handle
22 | ///
23 | IntPtr WindowHandle { get; }
24 |
25 | ///
26 | /// Called when the ribbon height is changed,
27 | /// allowing the form to reposition its controls so the ribbon doesn't hide them.
28 | ///
29 | /// new height
30 | void RibbonHeightUpdated(int newHeight);
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/RibbonLib/Interop/CommonCOMInterfaces.cs:
--------------------------------------------------------------------------------
1 | //****************************************************************************
2 | //
3 | // File: CommonCOMInterfaces.cs
4 | //
5 | // Contents: Common COM Interfaces which are used with the Windows Ribbon
6 | // Framework.
7 | //
8 | //****************************************************************************
9 |
10 | using System;
11 | using System.Runtime.InteropServices;
12 |
13 | namespace RibbonLib.Interop
14 | {
15 | ///
16 | /// HRESULT Wrapper
17 | ///
18 | public enum HRESULT : uint
19 | {
20 | S_OK = 0x00000000,
21 | S_FALSE = 0x00000001,
22 | E_FAIL = 0x80004005,
23 | E_NOTIMPL = 0x80004001,
24 | }
25 |
26 | public static class NativeMethods
27 | {
28 | public const uint DONT_RESOLVE_DLL_REFERENCES = 0x00000001;
29 | public const uint LOAD_LIBRARY_AS_DATAFILE = 0x00000002;
30 | public const uint LOAD_WITH_ALTERED_SEARCH_PATH = 0x00000008;
31 | public const uint LOAD_IGNORE_CODE_AUTHZ_LEVEL = 0x00000010;
32 | public const uint LOAD_LIBRARY_AS_IMAGE_RESOURCE = 0x00000020;
33 | public const uint LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE = 0x00000040;
34 | public const uint LOAD_LIBRARY_REQUIRE_SIGNED_TARGET = 0x00000080;
35 |
36 | [DllImport("kernel32.dll", SetLastError = true)]
37 | public static extern IntPtr LoadLibrary([MarshalAs(UnmanagedType.LPStr)] string lpFileName);
38 |
39 | [DllImport("kernel32.dll", SetLastError = true)]
40 | public static extern IntPtr LoadLibraryEx(string lpFileName, IntPtr hFile, uint dwFlags);
41 |
42 | [DllImport("kernel32.dll", SetLastError = true)]
43 | public static extern bool FreeLibrary([In] IntPtr hModule);
44 |
45 | public static bool Succeeded(HRESULT hr)
46 | {
47 | return ((int)hr >= 0);
48 | }
49 |
50 | public static bool Failed(HRESULT hr)
51 | {
52 | return ((int)hr < 0);
53 | }
54 | }
55 |
56 | [ComImport]
57 | [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
58 | [Guid("00000100-0000-0000-C000-000000000046")]
59 | public interface IEnumUnknown
60 | {
61 | // Retrieves the specified number of items in the enumeration sequence
62 | [PreserveSig]
63 | HRESULT Next([In, MarshalAs(UnmanagedType.U4)] uint celt,
64 | [Out, MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.IUnknown, SizeParamIndex = 0)] object[] rgelt,
65 | [Out, MarshalAs(UnmanagedType.U4)] out uint pceltFetched);
66 |
67 | // Skips over the specified number of items in the enumeration sequence.
68 | [PreserveSig]
69 | HRESULT Skip([In, MarshalAs(UnmanagedType.U4)] uint celt);
70 |
71 | // Resets the enumeration sequence to the beginning.
72 | [PreserveSig]
73 | HRESULT Reset();
74 |
75 | // Creates a new enumerator that contains the same enumeration state as the current one.
76 | [PreserveSig]
77 | HRESULT Clone(out IEnumUnknown ppenum);
78 | }
79 |
80 | [ComImport]
81 | [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
82 | [Guid("886D8EEB-8CF2-4446-8D02-CDBA1DBDCF99")]
83 | public interface IPropertyStore
84 | {
85 | // Gets the number of properties attached to the file.
86 | [PreserveSig]
87 | HRESULT GetCount([Out] out uint cProps);
88 |
89 | // Gets a property key from an item's array of properties.
90 | [PreserveSig]
91 | HRESULT GetAt([In] uint iProp, out PropertyKey pkey);
92 |
93 | // Gets data for a specific property.
94 | [PreserveSig]
95 | HRESULT GetValue([In] ref PropertyKey key, out PropVariant pv);
96 |
97 | // Sets a new property value, or replaces or removes an existing value.
98 | [PreserveSig]
99 | HRESULT SetValue([In] ref PropertyKey key, [In] ref PropVariant pv);
100 |
101 | // Saves a property change.
102 | [PreserveSig]
103 | HRESULT Commit();
104 | }
105 |
106 | }
107 |
--------------------------------------------------------------------------------
/RibbonLib/Interop/PropertyKey.cs:
--------------------------------------------------------------------------------
1 | //****************************************************************************
2 | //
3 | // File: PropertyKey.cs
4 | //
5 | // Contents: Interop wrapper for native PropertyKey structure. Originally
6 | // sourced from http://code.msdn.microsoft.com/PreviewRibbon
7 | // project. My modifications:
8 | // 1. Separated PropertyKey definiton from Ribbon related code
9 | // 2. Exposed as public fields: FormatId and PropertyId
10 | //
11 | //****************************************************************************
12 |
13 | using System;
14 | using System.Globalization;
15 | using System.Runtime.InteropServices;
16 |
17 | namespace RibbonLib.Interop
18 | {
19 | [StructLayout(LayoutKind.Sequential)]
20 | public struct PropertyKey
21 | {
22 | #region Constructors
23 |
24 | public PropertyKey(Guid fmtid, uint pid)
25 | {
26 | this.FormatId = fmtid;
27 | this.PropertyId = pid;
28 | }
29 |
30 | #endregion
31 |
32 | #region Public methods
33 |
34 | public static bool operator ==(PropertyKey left, PropertyKey right)
35 | {
36 | return ((left.FormatId == right.FormatId) && (left.PropertyId == right.PropertyId));
37 | }
38 |
39 | public static bool operator !=(PropertyKey left, PropertyKey right)
40 | {
41 | return !(left == right);
42 | }
43 |
44 | public override string ToString()
45 | {
46 | return "PKey: " + FormatId.ToString() + ":" + PropertyId.ToString(CultureInfo.InvariantCulture.NumberFormat);
47 | }
48 |
49 | // Return pinned memory to unmanaged code so that it doesn't get freed while unmanaged code still needs it.
50 | public IntPtr ToPointer()
51 | {
52 | if (!s_pinnedCache.ContainsKey(this))
53 | {
54 | s_pinnedCache.Add(this, GCHandle.Alloc(this, GCHandleType.Pinned));
55 | }
56 |
57 | return s_pinnedCache[this].AddrOfPinnedObject();
58 | }
59 |
60 | public override bool Equals(object obj)
61 | {
62 | if (obj == null)
63 | {
64 | return false;
65 | }
66 |
67 | if (!(obj is PropertyKey))
68 | {
69 | return false;
70 | }
71 |
72 | return (this == (PropertyKey)obj);
73 | }
74 |
75 | public override int GetHashCode()
76 | {
77 | return (FormatId.GetHashCode() ^ PropertyId.GetHashCode());
78 | }
79 |
80 | #endregion
81 |
82 | #region Private fields
83 |
84 | // This cache allocates pinned memory for the property key so that it doesn't get garbage-collected
85 | // while the unmanaged code works with it on the other side of interop.
86 | // Use the ToPointer() function when calling interop methods which take property keys as parameters.
87 | static System.Collections.Generic.Dictionary s_pinnedCache =
88 | new System.Collections.Generic.Dictionary(16);
89 |
90 | public Guid FormatId;
91 |
92 | public uint PropertyId;
93 |
94 | #endregion
95 | }
96 |
97 | // It is sometimes useful to represent the struct as a reference-type
98 | // (eg, for methods that allow passing a null PropertyKey pointer).
99 | [StructLayout(LayoutKind.Sequential)]
100 | public class PropertyKeyRef
101 | {
102 | public PropertyKey PropertyKey;
103 |
104 | public static PropertyKeyRef From(PropertyKey value)
105 | {
106 | PropertyKeyRef obj = new PropertyKeyRef();
107 | obj.PropertyKey = value;
108 | return obj;
109 | }
110 | }
111 | }
112 |
--------------------------------------------------------------------------------
/RibbonLib/Interop/RibbonCOMClasses.cs:
--------------------------------------------------------------------------------
1 | //****************************************************************************
2 | //
3 | // File: RibbonCOMClasses.cs
4 | //
5 | // Contents: Classes of the Windows Ribbon Framework, based on
6 | // UIRibbon.idl from windows 7 SDK
7 | //
8 | //****************************************************************************
9 |
10 | using System.Runtime.InteropServices;
11 |
12 | namespace RibbonLib.Interop
13 | {
14 | // UIRibbonFramework class
15 | [ComImport]
16 | [ClassInterface(ClassInterfaceType.None)]
17 | [Guid(RibbonCLSIDGuid.UIRibbonFramework)]
18 | public class UIRibbonFramework
19 | {
20 | // implements IUIFramework
21 | }
22 |
23 |
24 | // UIRibbonImageFromBitmapFactory class
25 | [ComImport]
26 | [ClassInterface(ClassInterfaceType.None)]
27 | [Guid(RibbonCLSIDGuid.UIRibbonImageFromBitmapFactory)]
28 | public class UIRibbonImageFromBitmapFactory
29 | {
30 | // implements IUIImageFromBitmap
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/RibbonLib/Interop/RibbonCOMGuids.cs:
--------------------------------------------------------------------------------
1 | //****************************************************************************
2 | //
3 | // File: RibbonCOMGuids.cs
4 | //
5 | // Contents: Guids of the interfaces and classes related to Windows Ribbon
6 | // Framework, based on UIRibbon.idl from windows 7 SDK
7 | //
8 | //****************************************************************************
9 |
10 | namespace RibbonLib.Interop
11 | {
12 | public static class RibbonIIDGuid
13 | {
14 | // IID GUID strings for relevant Ribbon COM interfaces.
15 | public const string IUISimplePropertySet = "c205bb48-5b1c-4219-a106-15bd0a5f24e2";
16 | public const string IUIRibbon = "803982ab-370a-4f7e-a9e7-8784036a6e26";
17 | public const string IUIFramework = "F4F0385D-6872-43a8-AD09-4C339CB3F5C5";
18 | public const string IUIContextualUI = "EEA11F37-7C46-437c-8E55-B52122B29293";
19 | public const string IUICollection = "DF4F45BF-6F9D-4dd7-9D68-D8F9CD18C4DB";
20 | public const string IUICollectionChangedEvent = "6502AE91-A14D-44b5-BBD0-62AACC581D52";
21 | public const string IUICommandHandler = "75ae0a2d-dc03-4c9f-8883-069660d0beb6";
22 | public const string IUIApplication = "D428903C-729A-491d-910D-682A08FF2522";
23 | public const string IUIImage = "23c8c838-4de6-436b-ab01-5554bb7c30dd";
24 | public const string IUIImageFromBitmap = "18aba7f3-4c1c-4ba2-bf6c-f5c3326fa816";
25 | }
26 |
27 | public static class RibbonCLSIDGuid
28 | {
29 | // CLSID GUID strings for relevant coclasses.
30 | public const string UIRibbonFramework = "926749fa-2615-4987-8845-c33e65f2b957";
31 | public const string UIRibbonImageFromBitmapFactory = "0F7434B6-59B6-4250-999E-D168D6AE4293";
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/RibbonLib/Interop/StreamAdapter.cs:
--------------------------------------------------------------------------------
1 | //*****************************************************************************
2 | //
3 | // File: StreamAdapter.cs
4 | //
5 | // Contents: Helper class that wraps a .NET stream class as a COM IStream
6 | //
7 | //*****************************************************************************
8 |
9 | using System;
10 | using System.IO;
11 | using System.Runtime.InteropServices;
12 | using System.Runtime.InteropServices.ComTypes;
13 |
14 | namespace RibbonLib.Interop
15 | {
16 | public class StreamAdapter : IStream
17 | {
18 | private Stream _stream;
19 |
20 | public StreamAdapter(Stream stream)
21 | {
22 | if (stream == null)
23 | {
24 | throw new ArgumentNullException("stream");
25 | }
26 |
27 | _stream = stream;
28 | }
29 |
30 | #region IStream Members
31 |
32 | public void Clone(out IStream streamCopy)
33 | {
34 | streamCopy = null;
35 | throw new NotSupportedException();
36 | }
37 |
38 | public void Commit(int flags)
39 | {
40 | throw new NotSupportedException();
41 | }
42 |
43 | public void CopyTo(IStream targetStream, long bufferSize, IntPtr buffer, IntPtr bytesWrittenPtr)
44 | {
45 | throw new NotSupportedException();
46 | }
47 |
48 | public void LockRegion(long offset, long byteCount, int lockType)
49 | {
50 | throw new NotSupportedException();
51 | }
52 |
53 | public void Read(byte[] buffer, int bufferSize, IntPtr bytesReadPtr)
54 | {
55 | int val = _stream.Read(buffer, 0, bufferSize);
56 | if (bytesReadPtr != IntPtr.Zero)
57 | {
58 | Marshal.WriteInt32(bytesReadPtr, val);
59 | }
60 | }
61 |
62 | public void Revert()
63 | {
64 | throw new NotSupportedException();
65 | }
66 |
67 | public void Seek(long offset, int origin, IntPtr newPositionPtr)
68 | {
69 | SeekOrigin begin;
70 | switch (origin)
71 | {
72 | case 0:
73 | begin = SeekOrigin.Begin;
74 | break;
75 |
76 | case 1:
77 | begin = SeekOrigin.Current;
78 | break;
79 |
80 | case 2:
81 | begin = SeekOrigin.End;
82 | break;
83 |
84 | default:
85 | throw new ArgumentOutOfRangeException("origin");
86 | }
87 | long val = _stream.Seek(offset, begin);
88 | if (newPositionPtr != IntPtr.Zero)
89 | {
90 | Marshal.WriteInt64(newPositionPtr, val);
91 | }
92 | }
93 |
94 | public void SetSize(long libNewSize)
95 | {
96 | _stream.SetLength(libNewSize);
97 | }
98 |
99 | public void Stat(out System.Runtime.InteropServices.ComTypes.STATSTG streamStats, int grfStatFlag)
100 | {
101 | streamStats = new System.Runtime.InteropServices.ComTypes.STATSTG();
102 | streamStats.type = 2;
103 | streamStats.cbSize = _stream.Length;
104 | streamStats.grfMode = 0;
105 | if (_stream.CanRead && _stream.CanWrite)
106 | {
107 | streamStats.grfMode |= 2;
108 | }
109 | else if (_stream.CanRead)
110 | {
111 | //streamStats.grfMode = streamStats.grfMode;
112 | }
113 | else
114 | {
115 | if (!_stream.CanWrite)
116 | {
117 | throw new IOException("StreamObjectDisposed");
118 | }
119 | streamStats.grfMode |= 1;
120 | }
121 | }
122 |
123 | public void UnlockRegion(long offset, long byteCount, int lockType)
124 | {
125 | throw new NotSupportedException();
126 | }
127 |
128 | public void Write(byte[] buffer, int bufferSize, IntPtr bytesWrittenPtr)
129 | {
130 | _stream.Write(buffer, 0, bufferSize);
131 | if (bytesWrittenPtr != IntPtr.Zero)
132 | {
133 | Marshal.WriteInt32(bytesWrittenPtr, bufferSize);
134 | }
135 | }
136 |
137 | #endregion
138 | }
139 | }
140 |
--------------------------------------------------------------------------------
/RibbonLib/Package.nuspec:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | $id$
5 | $version$
6 | $id$
7 | $author$
8 | Enner Pérez
9 | https://raw.githubusercontent.com/ennerperez/RibbonLib/master/LICENSE
10 | https://github.com/ennerperez/RibbonLib
11 | https://raw.githubusercontent.com/ennerperez/RibbonLib/master/.editoricon.png
12 | true
13 | Windows Ribbon for WinForms is a .NET wrapper for Windows Ribbon control. It will allow WinForms developers to use Microsoft Windows Ribbon control in their WinForms applications.
14 | $description$
15 |
16 | $copyright$
17 | en
18 | WinForms Ribbon Generator
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/RibbonLib/Properties/AssemblyInfo.Common.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | #if DEBUG
6 | [assembly: AssemblyConfiguration("DEBUG")]
7 | #else
8 | [assembly: AssemblyConfiguration("RELEASE")]
9 | #endif
10 | [assembly: AssemblyCompany("Arik Poznanski")]
11 | [assembly: AssemblyCopyright("Copyright © Arik Poznanski")]
12 | [assembly: AssemblyTrademark("RibbonLib")]
13 | [assembly: AssemblyCulture("")]
14 |
15 | [assembly: ComVisible(false)]
16 |
--------------------------------------------------------------------------------
/RibbonLib/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 | using System.Resources;
5 |
6 | [assembly: AssemblyTitle("RibbonLib")]
7 | [assembly: AssemblyDescription("Windows Ribbon for WinForms")]
8 | [assembly: AssemblyProduct("RibbonLib")]
9 |
10 | [assembly: Guid("232C88FB-29DB-4650-82EA-EDE96B00EBC4")]
11 |
12 | [assembly: AssemblyVersion("2.7.0.*")]
13 | [assembly: AssemblyFileVersion("2.7.0.0")]
14 | [assembly: NeutralResourcesLanguage("en")]
15 |
16 |
--------------------------------------------------------------------------------
/RibbonLib/RecentItemsPropertySet.cs:
--------------------------------------------------------------------------------
1 | //*****************************************************************************
2 | //
3 | // File: RecentItemsPropertySet.cs
4 | //
5 | // Contents: Helper class that wraps a recent items simple property set.
6 | //
7 | //*****************************************************************************
8 |
9 | using System.Diagnostics;
10 | using RibbonLib.Interop;
11 |
12 | namespace RibbonLib
13 | {
14 | public class RecentItemsPropertySet : IUISimplePropertySet
15 | {
16 | private string _label;
17 | private string _labelDescription;
18 | private bool? _pinned;
19 |
20 | public string Label
21 | {
22 | get
23 | {
24 | return _label;
25 | }
26 | set
27 | {
28 | _label = value;
29 | }
30 | }
31 |
32 | public string LabelDescription
33 | {
34 | get
35 | {
36 | return _labelDescription;
37 | }
38 | set
39 | {
40 | _labelDescription = value;
41 | }
42 | }
43 |
44 | public bool Pinned
45 | {
46 | get
47 | {
48 | return _pinned.GetValueOrDefault();
49 | }
50 | set
51 | {
52 | _pinned = value;
53 | }
54 | }
55 |
56 | #region IUISimplePropertySet Members
57 |
58 | public HRESULT GetValue(ref PropertyKey key, out PropVariant value)
59 | {
60 | if (key == RibbonProperties.Label)
61 | {
62 | if ((_label == null) || (_label.Trim() == string.Empty))
63 | {
64 | value = PropVariant.Empty;
65 | }
66 | else
67 | {
68 | value = PropVariant.FromObject(_label);
69 | }
70 | return HRESULT.S_OK;
71 | }
72 |
73 | if (key == RibbonProperties.LabelDescription)
74 | {
75 | if ((_labelDescription == null) || (_labelDescription.Trim() == string.Empty))
76 | {
77 | value = PropVariant.Empty;
78 | }
79 | else
80 | {
81 | value = PropVariant.FromObject(_labelDescription);
82 | }
83 | return HRESULT.S_OK;
84 | }
85 |
86 | if (key == RibbonProperties.Pinned)
87 | {
88 | if (_pinned.HasValue)
89 | {
90 | value = PropVariant.FromObject(_pinned.Value);
91 | }
92 | else
93 | {
94 | value = PropVariant.Empty;
95 | }
96 | return HRESULT.S_OK;
97 | }
98 |
99 | Debug.WriteLine(string.Format("Class {0} does not support property: {1}.", GetType().ToString(), RibbonProperties.GetPropertyKeyName(ref key)));
100 |
101 | value = PropVariant.Empty;
102 | return HRESULT.E_NOTIMPL;
103 | }
104 |
105 | #endregion
106 | }
107 | }
108 |
--------------------------------------------------------------------------------
/RibbonLib/Ribbon.snk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ennerperez/RibbonLib/edba0c761a9542d102d9770071f1ff24a712a53e/RibbonLib/Ribbon.snk
--------------------------------------------------------------------------------
/RibbonLib/RibbonLib.targets:
--------------------------------------------------------------------------------
1 |
2 |
3 |
13 |
14 |
15 |
16 |
17 |
18 | "$(MSBuildThisFileDirectory)..\tools\rgc.exe" "$(MSBuildProjectDirectory)\RibbonMarkup.xml"
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/RibbonLib/RibbonMarkup.ribbon:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ennerperez/RibbonLib/edba0c761a9542d102d9770071f1ff24a712a53e/RibbonLib/RibbonMarkup.ribbon
--------------------------------------------------------------------------------
/RibbonLib/RibbonMarkup.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/RibbonLib/RibbonMarkup.xml.transform:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/RibbonLib/RibbonShortcutTable.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Windows.Forms;
6 | using System.Xml.Serialization;
7 |
8 | namespace RibbonLib
9 | {
10 | public class RibbonShortcut
11 | {
12 | [XmlAttribute]
13 | public uint CommandId { get; set; }
14 |
15 | string _shortcut;
16 |
17 | [XmlAttribute("Shortcut")]
18 | public string Shortcut
19 | {
20 | get
21 | {
22 | return _shortcut;
23 | }
24 | set
25 | {
26 | _shortcut = value;
27 | _shortcutKeys = ConvertToKeys(value);
28 | }
29 | }
30 |
31 | public Keys ConvertToKeys(string value)
32 | {
33 | if (string.IsNullOrEmpty(value))
34 | return Keys.None;
35 |
36 | Keys result = Keys.None;
37 |
38 | string[] keys = value.Split('+');
39 | foreach (string key in keys)
40 | {
41 | string formattedKey;
42 | if (key == "Ctrl")
43 | formattedKey = "Control";
44 | else
45 | formattedKey = key;
46 |
47 | try
48 | {
49 | Keys k = (Keys)Enum.Parse(typeof(Keys), formattedKey, true);
50 | result |= k;
51 | }
52 | catch (Exception ex)
53 | {
54 | throw new ArgumentException(string.Format("The ShortcutKey '{0}' is invalid. The token '{1}' is unknown", value, key), ex);
55 | }
56 | }
57 |
58 | return result;
59 | }
60 |
61 | Keys _shortcutKeys;
62 | [XmlIgnore]
63 | public Keys ShortcutKeys
64 | {
65 | get { return _shortcutKeys; }
66 | }
67 | }
68 |
69 | public class RibbonShortcutTable
70 | {
71 | public RibbonShortcut[] RibbonShortcutArray
72 | {
73 | get
74 | {
75 | if (_ribbonShortcuts == null)
76 | return null;
77 | return _ribbonShortcuts.ToArray();
78 | }
79 | set
80 | {
81 | if (value == null)
82 | _ribbonShortcuts = new List();
83 | else
84 | _ribbonShortcuts = new List(value);
85 | }
86 | }
87 |
88 | List _ribbonShortcuts = new List();
89 |
90 | [XmlIgnore()]
91 | public List RibbonShortcuts
92 | {
93 | get { return _ribbonShortcuts; }
94 | }
95 |
96 | ///
97 | /// Tests if the shortcut has an underlying command id
98 | ///
99 | /// the shortcut keys
100 | /// the command name
101 | public uint HitTest(Keys shortcutKeys)
102 | {
103 | var ribbonShortcut = this.RibbonShortcuts.FirstOrDefault(s => s.ShortcutKeys == shortcutKeys);
104 | if(ribbonShortcut == null)
105 | return 0;
106 | return ribbonShortcut.CommandId;
107 | }
108 | }
109 | }
110 |
--------------------------------------------------------------------------------
/RibbonLib/RibbonUIApplication.cs:
--------------------------------------------------------------------------------
1 | //*****************************************************************************
2 | //
3 | // File: RibbonUIApplication.cs
4 | //
5 | // Contents: Class which implements IUIApplication interface which allows
6 | // the interaction with the Windows Ribbon Framework.
7 | //
8 | //*****************************************************************************
9 |
10 | using System.Runtime.InteropServices;
11 | using RibbonLib.Interop;
12 | using System.Windows.Forms;
13 |
14 | namespace RibbonLib
15 | {
16 | [ComVisible(true)]
17 | [Guid("B13C3248-093D-4366-9832-A936610846FD")]
18 | internal class RibbonUIApplication : IUIApplication
19 | {
20 | private Ribbon _ribbon;
21 | private Ribbon _ribbonControl;
22 |
23 | ///
24 | /// RibbonUIApplication ctor
25 | ///
26 | /// Ribbon
27 | /// Form where ribbon should reside
28 | public RibbonUIApplication(Ribbon ribbon, Ribbon ribbonControl)
29 | {
30 | _ribbon = ribbon;
31 | _ribbonControl = ribbonControl;
32 | }
33 |
34 | ///
35 | /// Reference to IUIRibbon object
36 | ///
37 | public IUIRibbon UIRibbon { get; private set; }
38 |
39 |
40 | #region IUIApplication Members
41 |
42 | ///
43 | /// Called when the state of a View changes
44 | ///
45 | /// The ID for the View. Only a value of 0 is valid.
46 | /// The UI_VIEWTYPE hosted by the application.
47 | /// A pointer to the View interface.
48 | /// The UI_VIEWVERB (or action) performed by the View.
49 | /// Not defined.
50 | /// Returns S_OK if successful, or an error value otherwise.
51 | public HRESULT OnViewChanged(uint viewId, ViewType typeID, object view, ViewVerb verb, int uReasonCode)
52 | {
53 | HRESULT hr = HRESULT.E_FAIL;
54 |
55 | // Checks to see if the view that was changed was a Ribbon view.
56 | if (typeID == ViewType.Ribbon)
57 | {
58 | switch (verb)
59 | {
60 | // The view was newly created
61 | case ViewVerb.Create:
62 | if (UIRibbon == null)
63 | {
64 | UIRibbon = view as IUIRibbon;
65 | }
66 | _ribbonControl.BeginInvoke(new MethodInvoker(_ribbonControl.RaiseViewCreated));
67 | hr = HRESULT.S_OK;
68 | break;
69 |
70 | // The view has been resized. For the Ribbon view, the application should
71 | // call GetHeight to determine the height of the ribbon.
72 | case ViewVerb.Size:
73 | uint uRibbonHeight;
74 | // Call to the framework to determine the desired height of the Ribbon.
75 | hr = UIRibbon.GetHeight(out uRibbonHeight);
76 |
77 | if (NativeMethods.Failed(hr))
78 | {
79 | // error
80 | }
81 | else
82 | {
83 | _ribbonControl.Height = (int)uRibbonHeight;
84 | }
85 | break;
86 |
87 | // The view was destroyed.
88 | case ViewVerb.Destroy:
89 |
90 | UIRibbon = null;
91 | hr = HRESULT.S_OK;
92 | break;
93 |
94 | default:
95 | break;
96 | }
97 | }
98 |
99 | return hr;
100 | }
101 |
102 | ///
103 | /// Called for each Command specified in the Windows Ribbon (Ribbon) framework markup to bind
104 | /// the Command to an IUICommandHandler.
105 | ///
106 | /// The ID for the Command, which is specified in the markup resource file.
107 | /// The Command type that is associated with a specific control.
108 | /// When this method returns, contains the address of a pointer to an
109 | /// IUICommandHandler object. This object is a host application Command handler that is bound to one or
110 | /// more Commands.
111 | /// Returns S_OK if successful, or an error value otherwise.
112 | public HRESULT OnCreateUICommand(uint commandId, CommandType typeID, out IUICommandHandler commandHandler)
113 | {
114 | commandHandler = _ribbon;
115 | return HRESULT.S_OK;
116 | }
117 |
118 | ///
119 | /// Called for each Command specified in the Windows Ribbon (Ribbon) framework markup when the
120 | /// application window is destroyed.
121 | ///
122 | /// The ID for the Command, which is specified in the markup resource file.
123 | /// The Command type that is associated with a specific control.
124 | /// A pointer to an IUICommandHandler object. This value can be NULL.
125 | /// Returns S_OK if successful, or an error value otherwise.
126 | public HRESULT OnDestroyUICommand(uint commandId, CommandType typeID, IUICommandHandler commandHandler)
127 | {
128 | return HRESULT.S_OK;
129 | }
130 |
131 | #endregion
132 | }
133 | }
134 |
--------------------------------------------------------------------------------
/RibbonLib/UICollection.cs:
--------------------------------------------------------------------------------
1 | //*****************************************************************************
2 | //
3 | // File: UICollection.cs
4 | //
5 | // Contents: Helper class that provides an implementation of the
6 | // IUIColleciton interface.
7 | //
8 | //*****************************************************************************
9 |
10 | using System.Collections.Generic;
11 | using RibbonLib.Interop;
12 |
13 | namespace RibbonLib
14 | {
15 | public class UICollection : IUICollection
16 | {
17 | private List