Add ribbon, AboutViewModel and AboutView.

This commit is contained in:
Daniel Kraus 2015-07-26 14:50:05 +02:00
parent 9df937138d
commit 3a4c17f148
17 changed files with 635 additions and 1 deletions

BIN
gimp/f.xcf Normal file

Binary file not shown.

BIN
gimp/i.xcf Normal file

Binary file not shown.

BIN
zaaReloaded2/Icons/f.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 617 B

BIN
zaaReloaded2/Icons/i.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 482 B

View File

@ -33,5 +33,65 @@ namespace zaaReloaded2.Properties {
this["SettingsRepository"] = value;
}
}
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("zaaReloaded2")]
public string AddinName {
get {
return ((string)(this["AddinName"]));
}
}
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("2015")]
public string PubYear {
get {
return ((string)(this["PubYear"]));
}
}
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("Daniel Kraus")]
public string Authors {
get {
return ((string)(this["Authors"]));
}
}
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("http://zaa.nephrowiki.de")]
public global::System.Uri Homepage {
get {
return ((global::System.Uri)(this["Homepage"]));
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("http://zaa.nephrowiki.de/updates")]
public string UpdatesUrl {
get {
return ((string)(this["UpdatesUrl"]));
}
set {
this["UpdatesUrl"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("versioninfo.txt")]
public string VersionInfoFile {
get {
return ((string)(this["VersionInfoFile"]));
}
set {
this["VersionInfoFile"] = value;
}
}
}
}

View File

@ -5,5 +5,23 @@
<Setting Name="SettingsRepository" Type="zaaReloaded2.Controller.SettingsRepository" Scope="User">
<Value Profile="(Default)" />
</Setting>
<Setting Name="AddinName" Type="System.String" Scope="Application">
<Value Profile="(Default)">zaaReloaded2</Value>
</Setting>
<Setting Name="PubYear" Type="System.String" Scope="Application">
<Value Profile="(Default)">2015</Value>
</Setting>
<Setting Name="Authors" Type="System.String" Scope="Application">
<Value Profile="(Default)">Daniel Kraus</Value>
</Setting>
<Setting Name="Homepage" Type="System.Uri" Scope="Application">
<Value Profile="(Default)">http://zaa.nephrowiki.de</Value>
</Setting>
<Setting Name="UpdatesUrl" Type="System.String" Scope="User">
<Value Profile="(Default)">http://zaa.nephrowiki.de/updates</Value>
</Setting>
<Setting Name="VersionInfoFile" Type="System.String" Scope="User">
<Value Profile="(Default)">versioninfo.txt</Value>
</Setting>
</Settings>
</SettingsFile>

134
zaaReloaded2/Ribbon.cs Executable file
View File

@ -0,0 +1,134 @@
/* Ribbon.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.Reflection;
using System.Runtime.InteropServices;
using System.Text;
using System.Windows;
using System.Drawing;
using System.Windows.Resources;
using Office = Microsoft.Office.Core;
// TODO: Follow these steps to enable the Ribbon (XML) item:
// 1: Copy the following code block into the ThisAddin, ThisWorkbook, or ThisDocument class.
// protected override Microsoft.Office.Core.IRibbonExtensibility CreateRibbonExtensibilityObject()
// {
// return new Ribbon();
// }
// 2. Create callback methods in the "Ribbon Callbacks" region of this class to handle user
// actions, such as clicking a button. Note: if you have exported this Ribbon from the Ribbon designer,
// move your code from the event handlers to the callback methods and modify the code to work with the
// Ribbon extensibility (RibbonX) programming model.
// 3. Assign attributes to the control tags in the Ribbon XML file to identify the appropriate callback methods in your code.
// For more information, see the Ribbon XML documentation in the Visual Studio Tools for Office Help.
namespace zaaReloaded2
{
[ComVisible(true)]
public class Ribbon : Office.IRibbonExtensibility
{
private Office.IRibbonUI ribbon;
public Ribbon()
{
}
#region IRibbonExtensibility Members
public string GetCustomUI(string ribbonID)
{
return GetResourceText("zaaReloaded2.Ribbon.xml");
}
#endregion
#region Ribbon Callbacks
//Create callback methods here. For more information about adding callback methods, visit http://go.microsoft.com/fwlink/?LinkID=271226
public void Ribbon_Load(Office.IRibbonUI ribbonUI)
{
this.ribbon = ribbonUI;
}
public void Ribbon_Click(Office.IRibbonControl control)
{
switch (control.Id)
{
case "zrlAbout":
ViewModels.AboutViewModel vm = new ViewModels.AboutViewModel();
vm.InjectInto<Views.AboutView>().ShowDialog();
break;
default:
throw new InvalidOperationException("No operation defined for " + control.Id);
}
}
/// <summary>
/// Returns an Image object for the ribbon.
/// </summary>
/// <remarks>
/// The image file is expected to be a WPF resource file, not an embedded resource.
/// To be consistent accross the application which uses WPF resources for its WPF
/// windows, all images are to be built as resources rather than embedded resources.
/// </remarks>
/// <param name="imageId">The file name (without path) of the image.</param>
/// <returns>Image object</returns>
public object Ribbon_LoadImage(string imageId)
{
string initPackScheme = System.IO.Packaging.PackUriHelper.UriSchemePack;
StreamResourceInfo sri = Application.GetResourceStream(
new Uri(@"pack://application:,,,/zaaReloaded2;component/Icons/" + imageId));
return Image.FromStream(sri.Stream);
}
#endregion
#region Helpers
private static string GetResourceText(string resourceName)
{
Assembly asm = Assembly.GetExecutingAssembly();
string[] resourceNames = asm.GetManifestResourceNames();
for (int i = 0; i < resourceNames.Length; ++i)
{
if (string.Compare(resourceName, resourceNames[i], StringComparison.OrdinalIgnoreCase) == 0)
{
using (StreamReader resourceReader = new StreamReader(asm.GetManifestResourceStream(resourceNames[i])))
{
if (resourceReader != null)
{
return resourceReader.ReadToEnd();
}
}
}
}
return null;
}
#endregion
}
}

36
zaaReloaded2/Ribbon.xml Executable file
View File

@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Ribbon.xml
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.
-->
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui"
onLoad="Ribbon_Load" loadImage="Ribbon_LoadImage">
<ribbon>
<tabs>
<tab id="zaaReloaded2" label="zaaReloaded2">
<group id="zrlFormatGroup" label="Formatieren">
<button id="zrlFormat" label="Formatieren" image="f.png" onAction="Ribbon_Click" size="large" />
</group>
<group id="zrlInfoGroup" label="Info">
<button id="zrlAbout" label="Über..." image="i.png" onAction="Ribbon_Click" size="large" />
</group>
</tab>
</tabs>
</ribbon>
</customUI>

55
zaaReloaded2/Style.xaml Executable file
View File

@ -0,0 +1,55 @@
<!--
Style.xaml
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.
-->
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:conv="clr-namespace:Bovender.Mvvm.Converters;assembly=Bovender"
>
<Style TargetType="Window">
<Setter Property="ShowInTaskbar" Value="False" />
</Style>
<Style TargetType="{x:Type Button}">
<Setter Property="Padding" Value="10,5,10,5" />
</Style>
<Style TargetType="{x:Type ComboBox}">
<Setter Property="Padding" Value="10,5,10,5" />
</Style>
<Style TargetType="{x:Type TextBox}">
<Setter Property="Margin" Value="0,0,0,10" />
</Style>
<Style TargetType="{x:Type ProgressBar}">
<Setter Property="Height" Value="24" />
</Style>
<Style TargetType="{x:Type GroupBox}">
<Setter Property="Padding" Value="10" />
</Style>
<Style x:Key="ViewModelListBox" TargetType="{x:Type ListBoxItem}">
<Setter Property="Control.ToolTip" Value="{Binding Path=ToolTip, Mode=OneWay}" />
<Setter Property="IsSelected" Value="{Binding Path=IsSelected, Mode=TwoWay}" />
<Setter Property="IsEnabled" Value="{Binding Path=IsEnabled, Mode=OneTime}" />
</Style>
<Style TargetType="{x:Type ComboBoxItem}">
<Setter Property="Control.ToolTip" Value="{Binding Path=ToolTip, Mode=OneWay}" />
<Setter Property="IsEnabled" Value="{Binding Path=IsEnabled, Mode=OneWay}" />
</Style>
<conv:EnumBooleanConverter x:Key="enumBoolConv" />
<conv:VisibilityBooleanConverter x:Key="visBoolConv" />
<conv:BooleanNegationConverter x:Key="boolNegConv" />
</ResourceDictionary>

View File

@ -50,6 +50,38 @@ namespace zaaReloaded2
{
}
#region Properties
public Ribbon Ribbon
{
get
{
if (_ribbon == null)
{
_ribbon = new Ribbon();
}
return _ribbon;
}
}
#endregion
#region Ribbon
protected override Microsoft.Office.Core.IRibbonExtensibility CreateRibbonExtensibilityObject()
{
return Ribbon;
}
#endregion
#region Private fields
private Ribbon _ribbon;
#endregion
#region VSTO generated code
/// <summary>

44
zaaReloaded2/Updater/Version.cs Executable file
View File

@ -0,0 +1,44 @@
/* Version.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.Linq;
using System.Reflection;
using System.Text;
using Bovender.Versioning;
namespace zaaReloaded2.Updater
{
class Version : SemanticVersion
{
#region Static 'overrides'
/// <summary>
/// Returns the current version of the XL Toolbox addin.
/// </summary>
/// <returns></returns>
new public static SemanticVersion CurrentVersion()
{
return Bovender.Versioning.SemanticVersion.CurrentVersion(
Assembly.GetExecutingAssembly()
);
}
#endregion
}
}

1
zaaReloaded2/VERSION Executable file
View File

@ -0,0 +1 @@
2.0.0-alpha.1

View File

@ -0,0 +1,116 @@
/* AboutViewModel.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.Linq;
using System.Text;
using Bovender.Mvvm.ViewModels;
using Bovender.Mvvm;
using System.Diagnostics;
namespace zaaReloaded2.ViewModels
{
class AboutViewModel : ViewModelBase
{
#region Properties
public string AddinName
{
get
{
return Properties.Settings.Default.AddinName;
}
}
public string PubYear
{
get
{
string year = Properties.Settings.Default.PubYear;
if (year == "2015")
{
return year;
}
else
{
return "2015-" + year;
}
}
}
public string CopyrightString
{
get
{
return String.Format("(c) Copyright {0} {1}",
PubYear,
Properties.Settings.Default.Authors);
}
}
public string Version
{
get
{
return zaaReloaded2.Updater.Version.CurrentVersion().ToString();
}
}
public string Homepage
{
get
{
return Properties.Settings.Default.Homepage.ToString();
}
}
#endregion
#region Commands
public DelegatingCommand GotoHomepageCommand
{
get
{
if (_gotoHomepageCommand == null)
{
_gotoHomepageCommand = new DelegatingCommand(
param => { Process.Start(new ProcessStartInfo(Homepage)); });
}
return _gotoHomepageCommand;
}
}
#endregion
#region ViewModelBase implementation
public override object RevealModelObject()
{
throw new NotImplementedException();
}
#endregion
#region Fields
DelegatingCommand _gotoHomepageCommand;
#endregion
}
}

View File

@ -0,0 +1,43 @@
<!--
AboutView.xaml
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.
-->
<Window x:Class="zaaReloaded2.Views.AboutView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:b="clr-namespace:Bovender.Mvvm.Views.Settings;assembly=Bovender"
SizeToContent="WidthAndHeight" ResizeMode="NoResize" ShowInTaskbar="False"
b:WindowState.CenterScreen="True"
Title="Über..."
>
<Window.Resources>
<ResourceDictionary Source="/zaaReloaded2;component/Style.xaml" />
</Window.Resources>
<StackPanel Margin="20">
<TextBlock TextAlignment="Center" Text="{Binding AddinName}" FontSize="20" FontWeight="Bold" />
<TextBlock TextAlignment="Center" Text="{Binding Version}" Margin="0, 5, 0, 10" />
<TextBlock TextAlignment="Center" Text="{Binding CopyrightString}" Margin="0, 0, 0, 10" />
<TextBlock TextAlignment="Center" Margin="0, 10, 0, 10">
<Hyperlink Command="{Binding GotoHomepageCommand}">
<TextBlock Text="{Binding Homepage}" />
</Hyperlink>
</TextBlock>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="0, 10, 0, 0">
<Button Content="Schließen" Command="{Binding CloseViewCommand}" />
</StackPanel>
</StackPanel>
</Window>

View File

@ -0,0 +1,32 @@
/* AboutView.xaml.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.Windows;
namespace zaaReloaded2.Views
{
/// <summary>
/// Interaction logic for AboutView.xaml
/// </summary>
public partial class AboutView : Window
{
public AboutView()
{
InitializeComponent();
}
}
}

View File

@ -20,5 +20,37 @@
-->
<configuration>
<configSections>
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="zaaReloaded2.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</sectionGroup>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="zaaReloaded2.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<applicationSettings>
<zaaReloaded2.Properties.Settings>
<setting name="AddinName" serializeAs="String">
<value>zaaReloaded2</value>
</setting>
<setting name="PubYear" serializeAs="String">
<value>2015</value>
</setting>
<setting name="Authors" serializeAs="String">
<value>Daniel Kraus</value>
</setting>
<setting name="Homepage" serializeAs="String">
<value>http://zaa.nephrowiki.de</value>
</setting>
</zaaReloaded2.Properties.Settings>
</applicationSettings>
<userSettings>
<zaaReloaded2.Properties.Settings>
<setting name="UpdatesUrl" serializeAs="String">
<value>http://zaa.nephrowiki.de/updates</value>
</setting>
<setting name="VersionInfoFile" serializeAs="String">
<value>versioninfo.txt</value>
</setting>
</zaaReloaded2.Properties.Settings>
</userSettings>
</configuration>

View File

@ -114,6 +114,8 @@
<Reference Include="Bovender">
<HintPath>..\packages\Bovender.0.2.0.0\lib\net40\Bovender.dll</HintPath>
</Reference>
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
@ -121,11 +123,13 @@
<Reference Include="System.Windows.Interactivity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Expression.Blend.Sdk.1.0.2\lib\net40-client\System.Windows.Interactivity.dll</HintPath>
</Reference>
<Reference Include="System.Xaml" />
<Reference Include="System.Xml" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup>
<Reference Include="Microsoft.Office.Tools.v4.0.Framework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
@ -172,6 +176,7 @@
<Compile Include="Controller\Settings.cs" />
<Compile Include="Controller\SettingsRepository.cs" />
<Compile Include="Formatter\DocumentWriter.cs" />
<Compile Include="Ribbon.cs" />
<Compile Include="Thesaurus\ThesaurusBase.cs" />
<Compile Include="Formatter\IItemFormatterDictionary.cs" />
<Compile Include="Formatter\ItemFormatter.cs" />
@ -202,6 +207,11 @@
<Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="ViewModels\AboutViewModel.cs" />
<Compile Include="Views\AboutView.xaml.cs">
<DependentUpon>AboutView.xaml</DependentUpon>
</Compile>
<Compile Include="Updater\Version.cs" />
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
@ -239,7 +249,28 @@
<EmbeddedResource Include="Thesaurus\Defaults\parameters.txt" />
<EmbeddedResource Include="Thesaurus\Defaults\units.txt" />
</ItemGroup>
<ItemGroup />
<ItemGroup>
<Resource Include="Style.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Resource>
<Page Include="Views\AboutView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="VERSION" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Ribbon.xml" />
</ItemGroup>
<ItemGroup>
<Resource Include="Icons\i.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Icons\f.png" />
</ItemGroup>
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>