Implement Demo feature.
- NEU: Eingebautes Demo-Dokument zum Ausprobieren.
This commit is contained in:
		
							
								
								
									
										
											BIN
										
									
								
								gimp/d.xcf
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								gimp/d.xcf
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										75
									
								
								zaaReloaded2/Demo/Demo.cs
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										75
									
								
								zaaReloaded2/Demo/Demo.cs
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,75 @@ | |||||||
|  | /* Demo.cs | ||||||
|  |  * part of zaaReloaded2 | ||||||
|  |  *  | ||||||
|  |  * Copyright 2015 Daniel Kraus | ||||||
|  |  *  | ||||||
|  |  * Licensed under the Apache License, Version 2.0 (the "License"); | ||||||
|  |  * you may not use this file except in compliance with the License. | ||||||
|  |  * You may obtain a copy of the License at | ||||||
|  |  *  | ||||||
|  |  *     http://www.apache.org/licenses/LICENSE-2.0 | ||||||
|  |  *  | ||||||
|  |  * Unless required by applicable law or agreed to in writing, software | ||||||
|  |  * distributed under the License is distributed on an "AS IS" BASIS, | ||||||
|  |  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||||||
|  |  * See the License for the specific language governing permissions and | ||||||
|  |  * limitations under the License. | ||||||
|  |  */ | ||||||
|  | using System; | ||||||
|  | using System.Collections.Generic; | ||||||
|  | using System.IO; | ||||||
|  | using System.Linq; | ||||||
|  | using System.Text; | ||||||
|  | using Microsoft.Office.Interop.Word; | ||||||
|  |  | ||||||
|  | namespace zaaReloaded2.Demo | ||||||
|  | { | ||||||
|  |     /// <summary> | ||||||
|  |     /// Static class that serves to load an embedded Word document | ||||||
|  |     /// into a temporary file and open that temporary file in Word. | ||||||
|  |     /// </summary> | ||||||
|  |     static class Demo | ||||||
|  |     { | ||||||
|  |         #region Public methods | ||||||
|  |  | ||||||
|  |         /// <summary> | ||||||
|  |         /// Opens a demo document. The document's Saved property is set to | ||||||
|  |         /// false so that a user who wants to save changes will be prompted | ||||||
|  |         /// for a file name. | ||||||
|  |         /// </summary> | ||||||
|  |         public static void OpenDemoDocument() | ||||||
|  |         { | ||||||
|  |             string tempFile = CreateTempFileFromResource(); | ||||||
|  |             Document demoDoc = Globals.ThisAddIn.Application.Documents | ||||||
|  |                 .Add(Template: tempFile); | ||||||
|  |             File.Delete(tempFile); | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         #endregion | ||||||
|  |  | ||||||
|  |         #region Private methods | ||||||
|  |  | ||||||
|  |         /// <summary> | ||||||
|  |         /// Copies the built-in demo file from a resource stream to a | ||||||
|  |         /// temporary file and returns the path to that file. | ||||||
|  |         /// </summary> | ||||||
|  |         /// <returns>Path to the newly created temporary file.</returns> | ||||||
|  |         static string CreateTempFileFromResource() | ||||||
|  |         { | ||||||
|  |             string resourceName = "zaaReloaded2.Demo.Demo.docx"; | ||||||
|  |             Stream resourceStream = typeof(Demo).Assembly | ||||||
|  |                 .GetManifestResourceStream(resourceName); | ||||||
|  |             if (resourceStream == null) | ||||||
|  |             { | ||||||
|  |                 throw new IOException("Unable to open stream " + resourceName); | ||||||
|  |             } | ||||||
|  |             string fileName = Path.GetTempFileName() + ".docx"; | ||||||
|  |             Stream tempStream = File.Create(fileName); | ||||||
|  |             resourceStream.CopyTo(tempStream); | ||||||
|  |             tempStream.Close(); | ||||||
|  |             return fileName; | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         #endregion | ||||||
|  |     } | ||||||
|  | } | ||||||
							
								
								
									
										
											BIN
										
									
								
								zaaReloaded2/Demo/Demo.docx
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								zaaReloaded2/Demo/Demo.docx
									
									
									
									
									
										Executable file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								zaaReloaded2/Icons/d.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								zaaReloaded2/Icons/d.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 1012 B | 
| @@ -95,6 +95,9 @@ namespace zaaReloaded2 | |||||||
|                             Globals.ThisAddIn.Application.ActiveDocument, |                             Globals.ThisAddIn.Application.ActiveDocument, | ||||||
|                             Globals.ThisAddIn.Application.Selection); |                             Globals.ThisAddIn.Application.Selection); | ||||||
|                         break; |                         break; | ||||||
|  |                     case "zrlDemo": | ||||||
|  |                         Demo.Demo.OpenDemoDocument(); | ||||||
|  |                         break; | ||||||
|                     default: |                     default: | ||||||
|                         throw new InvalidOperationException("No operation defined for " + control.Id); |                         throw new InvalidOperationException("No operation defined for " + control.Id); | ||||||
|                 } |                 } | ||||||
|   | |||||||
| @@ -32,6 +32,9 @@ | |||||||
| 							getVisible="Daniel_GetVisible"/> | 							getVisible="Daniel_GetVisible"/> | ||||||
| 				</group> | 				</group> | ||||||
| 				<group id="zrlInfoGroup" label="Info"> | 				<group id="zrlInfoGroup" label="Info"> | ||||||
|  | 					<button id="zrlDemo" label="Demo" image="d.png" onAction="Ribbon_Click" size="large" | ||||||
|  | 							screentip="Demo-Dokument öffnen" | ||||||
|  | 							supertip="Öffnet ein eingebautes Demo-Dokument, das zum Ausprobieren verwendet werden kann." /> | ||||||
| 					<button id="zrlAbout" label="Über..." image="i.png" onAction="Ribbon_Click" size="large" | 					<button id="zrlAbout" label="Über..." image="i.png" onAction="Ribbon_Click" size="large" | ||||||
| 							screentip="Über zaaReloaded" | 							screentip="Über zaaReloaded" | ||||||
| 							supertip="Zeigt Informationen über das Add-in an." /> | 							supertip="Zeigt Informationen über das Add-in an." /> | ||||||
|   | |||||||
| @@ -176,6 +176,7 @@ | |||||||
|     <Compile Include="Controller\Elements\CustomText.cs" /> |     <Compile Include="Controller\Elements\CustomText.cs" /> | ||||||
|     <Compile Include="Controller\Settings.cs" /> |     <Compile Include="Controller\Settings.cs" /> | ||||||
|     <Compile Include="Controller\SettingsRepository.cs" /> |     <Compile Include="Controller\SettingsRepository.cs" /> | ||||||
|  |     <Compile Include="Demo\Demo.cs" /> | ||||||
|     <Compile Include="ExceptionHandler\ExceptionDetailView.xaml.cs" /> |     <Compile Include="ExceptionHandler\ExceptionDetailView.xaml.cs" /> | ||||||
|     <Compile Include="ExceptionHandler\ExceptionView.xaml.cs" /> |     <Compile Include="ExceptionHandler\ExceptionView.xaml.cs" /> | ||||||
|     <Compile Include="ExceptionHandler\ExceptionViewModel.cs" /> |     <Compile Include="ExceptionHandler\ExceptionViewModel.cs" /> | ||||||
| @@ -240,6 +241,7 @@ | |||||||
|       <DependentUpon>Resources.resx</DependentUpon> |       <DependentUpon>Resources.resx</DependentUpon> | ||||||
|     </Compile> |     </Compile> | ||||||
|     <None Include="app.config" /> |     <None Include="app.config" /> | ||||||
|  |     <EmbeddedResource Include="Demo\Demo.docx" /> | ||||||
|     <None Include="packages.config" /> |     <None Include="packages.config" /> | ||||||
|     <None Include="Properties\Settings.settings"> |     <None Include="Properties\Settings.settings"> | ||||||
|       <Generator>SettingsSingleFileGenerator</Generator> |       <Generator>SettingsSingleFileGenerator</Generator> | ||||||
| @@ -317,6 +319,9 @@ | |||||||
|   <ItemGroup> |   <ItemGroup> | ||||||
|     <Resource Include="Icons\fff.png" /> |     <Resource Include="Icons\fff.png" /> | ||||||
|   </ItemGroup> |   </ItemGroup> | ||||||
|  |   <ItemGroup> | ||||||
|  |     <Resource Include="Icons\d.png" /> | ||||||
|  |   </ItemGroup> | ||||||
|   <PropertyGroup> |   <PropertyGroup> | ||||||
|     <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion> |     <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion> | ||||||
|     <VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath> |     <VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath> | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user