Implement Demo feature.

- NEU: Eingebautes Demo-Dokument zum Ausprobieren.
This commit is contained in:
Daniel Kraus 2015-08-03 12:11:30 +02:00
parent db8f88c563
commit 8437f0907c
7 changed files with 86 additions and 0 deletions

BIN
gimp/d.xcf Normal file

Binary file not shown.

75
zaaReloaded2/Demo/Demo.cs Executable file
View 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

Binary file not shown.

BIN
zaaReloaded2/Icons/d.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1012 B

View File

@ -95,6 +95,9 @@ namespace zaaReloaded2
Globals.ThisAddIn.Application.ActiveDocument,
Globals.ThisAddIn.Application.Selection);
break;
case "zrlDemo":
Demo.Demo.OpenDemoDocument();
break;
default:
throw new InvalidOperationException("No operation defined for " + control.Id);
}

View File

@ -32,6 +32,9 @@
getVisible="Daniel_GetVisible"/>
</group>
<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"
screentip="Über zaaReloaded"
supertip="Zeigt Informationen über das Add-in an." />

View File

@ -176,6 +176,7 @@
<Compile Include="Controller\Elements\CustomText.cs" />
<Compile Include="Controller\Settings.cs" />
<Compile Include="Controller\SettingsRepository.cs" />
<Compile Include="Demo\Demo.cs" />
<Compile Include="ExceptionHandler\ExceptionDetailView.xaml.cs" />
<Compile Include="ExceptionHandler\ExceptionView.xaml.cs" />
<Compile Include="ExceptionHandler\ExceptionViewModel.cs" />
@ -240,6 +241,7 @@
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<None Include="app.config" />
<EmbeddedResource Include="Demo\Demo.docx" />
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
@ -317,6 +319,9 @@
<ItemGroup>
<Resource Include="Icons\fff.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Icons\d.png" />
</ItemGroup>
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>