Update directory layout

This commit is contained in:
2018-02-06 21:54:26 -05:00
parent ceea58b9bc
commit 38d692c9fc
19 changed files with 6 additions and 6 deletions

6
Library/App.config Normal file
View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
</configuration>

View File

@@ -0,0 +1,165 @@
<Window x:Class="FloatingStatusWindowLibrary.AppearanceWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="{x:Static properties:Resources.ChangeAppearanceWindow}" Height="290" Width="450" Binding.SourceUpdated="HandleWindowSourceUpdated"
xmlns:properties="clr-namespace:FloatingStatusWindowLibrary.Properties"
WindowStartupLocation="CenterScreen"
ResizeMode="NoResize" SizeToContent="Height"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:FloatingStatusWindowLibrary"
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
mc:Ignorable="d"
d:DataContext="{d:DesignInstance local:WindowSettings}"
Closing="HandleWindowClosing" x:ClassModifier="internal" Icon="pack://siteoforigin:,,,/Resources/gear.ico">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Label
Content="{x:Static properties:Resources.FontName}"
Name="FontNameLabel"
Target="{Binding ElementName=FontNameCombo}"
Margin="6" />
<ComboBox x:Name="FontNameCombo" Grid.Row="0" Grid.Column="1"
SelectedValuePath="Source"
SelectedValue="{Binding Path=FontName,UpdateSourceTrigger=PropertyChanged,NotifyOnSourceUpdated=True}"
Margin="6">
<ComboBox.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel />
</ItemsPanelTemplate>
</ComboBox.ItemsPanel>
<ComboBox.ItemTemplate>
<DataTemplate>
<Border BorderBrush="{x:Null}"
MinHeight="20">
<TextBlock Text="{Binding}"
FontFamily="{Binding}"
FontSize="14" Height="Auto"
VerticalAlignment="Center" />
</Border>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
<Label
Content="{x:Static properties:Resources.FontSize}"
Name="FontSizeLabel" Grid.Row="1" Grid.Column="0"
Target="{Binding ElementName=FontSizeCombo}"
Margin="6" />
<ComboBox Grid.Column="1" Grid.Row="1"
Name="FontSizeCombo"
Text="{Binding Path=FontSize,UpdateSourceTrigger=PropertyChanged,NotifyOnSourceUpdated=True}"
IsEditable="True" Margin="6">
<ComboBoxItem Content="8" />
<ComboBoxItem Content="9" />
<ComboBoxItem Content="10" />
<ComboBoxItem Content="11" />
<ComboBoxItem Content="12" />
<ComboBoxItem Content="14" />
<ComboBoxItem Content="16" />
<ComboBoxItem Content="18" />
<ComboBoxItem Content="20" />
<ComboBoxItem Content="22" />
<ComboBoxItem Content="24" />
<ComboBoxItem Content="26" />
<ComboBoxItem Content="28" />
<ComboBoxItem Content="36" />
<ComboBoxItem Content="48" />
<ComboBoxItem Content="72" />
</ComboBox>
<Label
Content="{x:Static properties:Resources.ForegroundColor}"
Grid.Row="2" Grid.Column="0" Name="ForegroundColorLabel"
Target="{Binding ElementName=ForegroundColorPicker}"
Margin="6" />
<xctk:ColorPicker Grid.Column="1" Grid.Row="2"
Name="ForegroundColorPicker"
DisplayColorAndName="True"
SelectedColor="{Binding Path=FontColor,UpdateSourceTrigger=PropertyChanged,NotifyOnSourceUpdated=True}"
Margin="6" />
<Label
Content="{x:Static properties:Resources.Padding}"
Grid.Row="3" Grid.Column="0" Name="PaddingLabel" Target="{Binding ElementName=PaddingUpDown}" Margin="6" />
<xctk:IntegerUpDown Grid.Column="1"
Grid.Row="3" Name="PaddingUpDown"
Minimum="0" Maximum="20"
Value="{Binding Path=Padding,UpdateSourceTrigger=PropertyChanged,NotifyOnSourceUpdated=True}"
TextAlignment="Left" Margin="6" />
<Label
Content="{x:Static properties:Resources.HorizontalAlignment}"
Grid.Row="4" Grid.Column="0" Name="HorizontalAlignmentLabel"
Target="{Binding ElementName=HorizontalAlignmentCombo}"
Margin="6" />
<ComboBox Grid.Column="1" Grid.Row="4"
Name="HorizontalAlignmentCombo"
SelectedValuePath="Tag"
SelectedValue="{Binding Path=HorizontalAlignment,UpdateSourceTrigger=PropertyChanged,NotifyOnSourceUpdated=True}"
Margin="6">
<ComboBoxItem
Content="{x:Static properties:Resources.Left}"
Tag="{x:Static HorizontalAlignment.Left}" />
<ComboBoxItem
Content="{x:Static properties:Resources.Right}"
Tag="{x:Static HorizontalAlignment.Right}" />
<ComboBoxItem
Content="{x:Static properties:Resources.Center}"
Tag="{x:Static HorizontalAlignment.Center}" />
</ComboBox>
<Label
Content="{x:Static properties:Resources.VerticalAlignment}"
Grid.Row="5" Grid.Column="0" Name="VerticalAlignmentLabel"
Target="{Binding ElementName=VerticalAlignmentCombo}"
Margin="6" />
<ComboBox Grid.Column="1" Grid.Row="5"
Name="VerticalAlignmentCombo"
SelectedValuePath="Tag"
SelectedValue="{Binding Path=VerticalAlignment,UpdateSourceTrigger=PropertyChanged,NotifyOnSourceUpdated=True}"
Margin="6">
<ComboBoxItem
Content="{x:Static properties:Resources.Top}"
Tag="{x:Static VerticalAlignment.Top}" />
<ComboBoxItem
Content="{x:Static properties:Resources.Bottom}"
Tag="{x:Static VerticalAlignment.Bottom}" />
<ComboBoxItem
Content="{x:Static properties:Resources.Center}"
Tag="{x:Static VerticalAlignment.Center}" />
</ComboBox>
<Grid Grid.Column="1" Grid.Row="6"
HorizontalAlignment="Right" Name="GridButtons" Width="Auto" Grid.IsSharedSizeScope="True"
Height="38" VerticalAlignment="Bottom">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"
SharedSizeGroup="buttons" />
<ColumnDefinition Width="Auto"
SharedSizeGroup="buttons" />
</Grid.ColumnDefinitions>
<Button
Content="{x:Static properties:Resources.OK}"
Height="23"
HorizontalAlignment="Stretch" Margin="6"
Name="OkayButton"
VerticalAlignment="Stretch" Width="75"
Padding="7,3" IsDefault="True"
Click="HandleOkayButtonClick" />
<Button
Content="{x:Static properties:Resources.Cancel}"
Grid.Column="1" Height="23"
HorizontalAlignment="Stretch" Margin="6"
Name="CancelButton"
VerticalAlignment="Stretch" Width="75"
Padding="7,3" IsCancel="True" />
</Grid>
</Grid>
</Window>

View File

@@ -0,0 +1,50 @@
using Common.Wpf.Extensions;
using System.Linq;
using System.Windows.Media;
namespace FloatingStatusWindowLibrary
{
internal partial class AppearanceWindow
{
private WindowSettings _currentSettings;
private readonly WindowSettings _originalSettings;
public AppearanceWindow(WindowSettings windowSettings)
{
InitializeComponent();
_currentSettings = windowSettings;
_originalSettings = (WindowSettings) _currentSettings.Clone();
var allFonts = Fonts.SystemFontFamilies.OrderBy(x => x.Source);
var filteredFonts = allFonts.Where(f => FontExtensions.IsComposite(f) || (!FontExtensions.IsSymbol(f) && FontExtensions.IsVisible(f)));
FontNameCombo.ItemsSource = filteredFonts;
DataContext = _currentSettings;
}
private void HandleOkayButtonClick(object sender, System.Windows.RoutedEventArgs e)
{
DialogResult = true;
Close();
}
private void HandleWindowSourceUpdated(object sender, System.Windows.Data.DataTransferEventArgs e)
{
_currentSettings.Apply();
}
private void HandleWindowClosing(object sender, System.ComponentModel.CancelEventArgs e)
{
if (DialogResult == true)
return;
_currentSettings = _originalSettings;
_currentSettings.Apply();
}
}
}

1
Library/Common.Wpf Submodule

Submodule Library/Common.Wpf added at 8a82786166

View File

@@ -0,0 +1,245 @@
using FloatingStatusWindowLibrary.Properties;
using Hardcodet.Wpf.TaskbarNotification;
using System;
using System.Windows;
using System.Windows.Controls;
using Point = System.Windows.Point;
using Size = System.Windows.Size;
namespace FloatingStatusWindowLibrary
{
public class FloatingStatusWindow : IDisposable
{
public event EventHandler WindowResized = delegate { };
public event EventHandler WindowClosed = delegate { };
private readonly MainWindow _mainWindow;
private readonly TaskbarIcon _taskbarIcon;
private readonly MenuItem _allWindowsMenuItem;
private readonly Separator _allWindowsSeparator;
private readonly MenuItem _lockMenuItem;
private readonly MenuItem _autoStartMenuItem;
private readonly IWindowSource _windowSource;
public FloatingStatusWindow(IWindowSource windowSource)
{
_windowSource = windowSource;
var contextMenu = new ContextMenu();
contextMenu.Opened += HandleContextMenuOpened;
MenuItem menuItem;
if (_windowSource.HasSettingsMenu)
{
menuItem = new MenuItem { Header = Resources.ContextMenuSettings };
menuItem.Click += (sender, args) => _windowSource.ShowSettings();
contextMenu.Items.Add(menuItem);
contextMenu.Items.Add(new Separator());
}
if (_windowSource.HasRefreshMenu)
{
menuItem = new MenuItem { Header = Resources.ContextMenuRefresh };
menuItem.Click += (sender, args) => _windowSource.Refresh();
contextMenu.Items.Add(menuItem);
contextMenu.Items.Add(new Separator());
}
_allWindowsMenuItem = new MenuItem { Header = Resources.AllWindowsMenu };
contextMenu.Items.Add(_allWindowsMenuItem);
menuItem = new MenuItem { Header = Resources.ContextMenuLock };
menuItem.Click += (sender, args) => WindowManager.SetLockOnAll(true);
_allWindowsMenuItem.Items.Add(menuItem);
menuItem = new MenuItem { Header = Resources.ContextMenuUnlock };
menuItem.Click += (sender, args) => WindowManager.SetLockOnAll(false);
_allWindowsMenuItem.Items.Add(menuItem);
_allWindowsMenuItem.Items.Add(new Separator());
menuItem = new MenuItem { Header = Resources.ContextMenuClose };
menuItem.Click += (sender, args) => WindowManager.CloseAll();
_allWindowsMenuItem.Items.Add(menuItem);
_allWindowsSeparator = new Separator();
contextMenu.Items.Add(_allWindowsSeparator);
var optionsMenu = new MenuItem { Name = "contextMenuItemOptions", Header = Resources.WindowMenu };
contextMenu.Items.Add(optionsMenu);
_lockMenuItem = new MenuItem
{
Name = "contextMenuItemLocked",
IsChecked = false,
Header = Resources.ContextMenuLocked
};
_lockMenuItem.Click += HandleLockedMenuItemClicked;
optionsMenu.Items.Add(_lockMenuItem);
if (StartManager.ManageAutoStart)
{
optionsMenu.Items.Add(new Separator());
_autoStartMenuItem = new MenuItem
{
Name = "contextMenuItemAutoStart",
IsChecked = StartManager.AutoStartEnabled,
Header = Resources.ContextMenuAutoStart
};
_autoStartMenuItem.Click += (sender, args) => StartManager.AutoStartEnabled = !StartManager.AutoStartEnabled;
optionsMenu.Items.Add(_autoStartMenuItem);
}
optionsMenu.Items.Add(new Separator());
menuItem = new MenuItem
{
Name = "contextMenuChangeAppearance",
Header = Resources.ContextMenuChangeAppearance
};
menuItem.Click += HandleChangeAppearancemMenuItemClick;
optionsMenu.Items.Add(menuItem);
contextMenu.Items.Add(new Separator());
menuItem = new MenuItem
{
Name = "contextMenuItemExit",
Header = Resources.ContextMenuExit
};
menuItem.Click += HandleExitMenuItemClick;
contextMenu.Items.Add(menuItem);
_taskbarIcon = new TaskbarIcon
{
ToolTipText = _windowSource.Name,
Icon = _windowSource.Icon,
ContextMenu = contextMenu
};
_mainWindow = new MainWindow(windowSource);
_mainWindow.Closed += HandleMainWindowClosed;
_mainWindow.SizeChanged += HandleWindowSizeChanged;
_mainWindow.LocationChanged += HandleWindowLocationChanged;
_mainWindow.LockStateChanged += HandleWindowLockStateChanged;
_mainWindow.Show();
}
private void HandleWindowLockStateChanged(object sender, EventArgs e)
{
Save();
}
private void HandleWindowLocationChanged(object sender, EventArgs e)
{
Save();
}
private void HandleWindowSizeChanged(object sender, SizeChangedEventArgs e)
{
WindowResized(this, new EventArgs());
Save();
}
private void HandleChangeAppearancemMenuItemClick(object sender, RoutedEventArgs e)
{
var appearanceWindow = new AppearanceWindow(_mainWindow.WindowSettings);
appearanceWindow.ShowDialog();
Save();
}
private void HandleMainWindowClosed(object sender, EventArgs e)
{
Save();
WindowClosed(null, new EventArgs());
_taskbarIcon.Dispose();
}
public ContextMenu ContextMenu
{
get { return _taskbarIcon.ContextMenu; }
}
private void HandleContextMenuOpened(object sender, RoutedEventArgs e)
{
_lockMenuItem.IsChecked = _mainWindow.WindowSettings.Locked;
if (_autoStartMenuItem != null)
_autoStartMenuItem.IsChecked = StartManager.AutoStartEnabled;
var windowCount = WindowManager.GetWindowList().Count;
_allWindowsMenuItem.Visibility = windowCount <= 1 ? Visibility.Collapsed : Visibility.Visible;
_allWindowsSeparator.Visibility = _allWindowsMenuItem.Visibility;
}
public void SetText(string text)
{
_mainWindow.HtmlLabel.Text = text;
}
private void HandleLockedMenuItemClicked(object sender, RoutedEventArgs e)
{
_mainWindow.WindowSettings.Locked = !_mainWindow.WindowSettings.Locked;
_mainWindow.WindowSettings.Apply();
}
private void HandleExitMenuItemClick(object sender, RoutedEventArgs e)
{
Save();
_mainWindow.Close();
}
public void Save()
{
_windowSource.WindowSettings = _mainWindow.WindowSettings.Save();
}
public void Dispose()
{
_taskbarIcon.Dispose();
_mainWindow.Close();
}
public Point Location
{
get { return new Point(_mainWindow.Left, _mainWindow.Top); }
}
public Size Size
{
get { return new Size(_mainWindow.Width, _mainWindow.Height); }
}
public Size ContentSize
{
get { return new Size(_mainWindow.HtmlLabel.ActualWidth, _mainWindow.HtmlLabel.ActualHeight); }
}
public WindowSettings Settings
{
get { return _mainWindow.WindowSettings; }
}
public string IconToolTipText
{
get { return _taskbarIcon.ToolTipText; }
set { _taskbarIcon.ToolTipText = value; }
}
}
}

View File

@@ -0,0 +1,121 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{F023A16C-2F13-4A87-A8B7-22C43C4A58A4}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>FloatingStatusWindowLibrary</RootNamespace>
<AssemblyName>FloatingStatusWindowLibrary</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<StartupObject />
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Drawing" />
<Reference Include="System.Xml" />
<Reference Include="System.Core" />
<Reference Include="System.Xaml">
<RequiredTargetFramework>4.0</RequiredTargetFramework>
</Reference>
<Reference Include="WindowsBase" />
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
</ItemGroup>
<ItemGroup>
<Compile Include="AppearanceWindow.xaml.cs">
<DependentUpon>AppearanceWindow.xaml</DependentUpon>
</Compile>
<Compile Include="FloatingStatusWindow.cs" />
<Compile Include="IWindowSource.cs" />
<Compile Include="MainWindow.xaml.cs">
<DependentUpon>MainWindow.xaml</DependentUpon>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="StartManager.cs" />
<Compile Include="WindowManager.cs" />
<Compile Include="WindowSettings.cs" />
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>PublicResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<AppDesigner Include="Properties\" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<Page Include="AppearanceWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="MainWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<None Include="Resources\gear.ico">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="Common.Wpf\Common.Native\Common.Native.csproj">
<Project>{ed1c07a1-54f5-4796-8b06-2a0bb1960d84}</Project>
<Name>Common.Native</Name>
</ProjectReference>
<ProjectReference Include="Common.Wpf\Common.Wpf.csproj">
<Project>{0074c983-550e-4094-9e8c-f566fb669297}</Project>
<Name>Common.Wpf</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Extended.Wpf.Toolkit">
<Version>3.2.0</Version>
</PackageReference>
<PackageReference Include="Hardcodet.NotifyIcon.Wpf">
<Version>1.0.8</Version>
</PackageReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

17
Library/IWindowSource.cs Normal file
View File

@@ -0,0 +1,17 @@
using System.Drawing;
namespace FloatingStatusWindowLibrary
{
public interface IWindowSource
{
string Name { get; }
string WindowSettings { get; set; }
Icon Icon { get; }
bool HasSettingsMenu { get; }
bool HasRefreshMenu { get; }
void ShowSettings();
void Refresh();
}
}

53
Library/MainWindow.xaml Normal file
View File

@@ -0,0 +1,53 @@
<windows:SnappingWindow x:Class="FloatingStatusWindowLibrary.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:htmlLabelControl="clr-namespace:Common.Wpf.HtmlLabelControl;assembly=Common.Wpf"
xmlns:windows="clr-namespace:Common.Wpf.Windows;assembly=Common.Wpf"
windows:ControlBox.HasMaximizeButton="False"
windows:ControlBox.HasMinimizeButton="False"
windows:ControlBox.HasSystemMenu="False"
Title="FloatingStatusWindow"
Height="250"
Width="400"
WindowStyle="None"
AllowsTransparency="True"
ResizeMode="CanResize"
Background="Transparent"
ShowInTaskbar="False"
x:ClassModifier="internal">
<Border Name="BorderFull"
BorderThickness="4,0,4,4"
Background="Transparent"
Margin="0">
<Grid Background="Transparent">
<Border Name="HeaderBorder"
Height="24"
VerticalAlignment="Top">
<Grid>
<Label HorizontalAlignment="Stretch"
Name="HeaderLabel"
Margin="0,0,0,0"
HorizontalContentAlignment="Center"
VerticalContentAlignment="Center"
Padding="0">
</Label>
<Button Height="18"
Width="18"
HorizontalAlignment="Right"
Margin="0,0,5,0"
Click="HandleChangeAppearanceClick"
WindowChrome.IsHitTestVisibleInChrome="True"
Content="&#xE115;"
FontFamily="Segoe UI Symbol"
FontSize="12"
Padding="0"></Button>
</Grid>
</Border>
<htmlLabelControl:HtmlLabel Name="HtmlLabel"
Foreground="White"
Margin="0,24,0,0" />
</Grid>
</Border>
</windows:SnappingWindow>

138
Library/MainWindow.xaml.cs Normal file
View File

@@ -0,0 +1,138 @@
using Common.Wpf.Windows;
using System;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Interop;
using System.Windows.Media;
using System.Windows.Shell;
using System.Windows.Threading;
namespace FloatingStatusWindowLibrary
{
internal partial class MainWindow
{
public event EventHandler LockStateChanged = delegate { };
private const int WindowCaptionHeight = 24;
private readonly WindowChrome _windowChrome;
private readonly Dispatcher _dispatcher;
private WindowSettings _windowSettings;
public WindowSettings WindowSettings
{
get { return _windowSettings; }
set { _windowSettings = value; }
}
private bool _locked;
public bool Locked
{
get { return _locked; }
set
{
_locked = value;
_windowChrome.CaptionHeight = (_locked ? 0 : WindowCaptionHeight);
HtmlLabel.Margin = new Thickness(0, (_locked ? 0 : WindowCaptionHeight), 0, 0);
// Show the header border if the window is unlocked
HeaderBorder.Visibility = (_locked ? Visibility.Collapsed : Visibility.Visible);
// Show and enable the window border if the window is unlocked
BorderFull.BorderBrush = (_locked ? Brushes.Transparent : SystemColors.ActiveCaptionBrush);
BorderFull.IsEnabled = !_locked;
LockStateChanged(null, new EventArgs());
}
}
public MainWindow(IWindowSource windowSource)
{
InitializeComponent();
_dispatcher = Dispatcher.CurrentDispatcher;
// Create and set the window chrome
_windowChrome = new WindowChrome { CaptionHeight = WindowCaptionHeight };
WindowChrome.SetWindowChrome(this, _windowChrome);
// Load the window settings
_windowSettings = WindowSettings.Load(windowSource.WindowSettings);
_windowSettings.Name = windowSource.Name;
_windowSettings.SetWindow(this);
// Set the background of the border
HeaderBorder.Background = SystemColors.ActiveCaptionBrush;
// Configure the header label
HeaderLabel.Foreground = SystemColors.InactiveCaptionTextBrush;
HeaderLabel.Content = _windowSettings.Name;
// Get the thickness so we can size the visual border
var resizeThickness = _windowChrome.ResizeBorderThickness;
// Set the color of the border
BorderFull.BorderBrush = SystemColors.ActiveCaptionBrush;
BorderFull.BorderThickness = new Thickness(resizeThickness.Left, 0, resizeThickness.Right, resizeThickness.Bottom);
// Apply the stored settings
_windowSettings.Apply();
}
protected override IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
{
if (msg == WindowManager.SetLockMessage)
{
var lockState = (wParam == (IntPtr) 1);
_dispatcher.InvokeAsync(() =>
{
WindowSettings.Locked = lockState;
Locked = lockState;
});
return IntPtr.Zero;
}
if (msg == WindowManager.CloseMessage)
{
_dispatcher.InvokeAsync(Close);
return IntPtr.Zero;
}
return base.WndProc(hwnd, msg, wParam, lParam, ref handled);
}
protected override void OnLocationChanged(EventArgs e)
{
base.OnLocationChanged(e);
_windowSettings.Location = new Point(Left, Top);
}
protected override void OnRenderSizeChanged(SizeChangedInfo sizeInfo)
{
base.OnRenderSizeChanged(sizeInfo);
_windowSettings.Size = new Size(Width, Height);
}
protected override List<WindowInformation> OtherWindows
{
get
{
var windowHandle = new WindowInteropHelper(this).Handle;
return WindowManager.GetWindowList(windowHandle);
}
}
private void HandleChangeAppearanceClick(object sender, RoutedEventArgs e)
{
var appearanceWindow = new AppearanceWindow(WindowSettings);
appearanceWindow.ShowDialog();
}
}
}

View File

@@ -0,0 +1,19 @@
using System.Reflection;
using System.Runtime.InteropServices;
using System.Windows;
[assembly: AssemblyTitle("FloatingStatusWindowLibrary")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Chris Kaczor")]
[assembly: AssemblyProduct("FloatingStatusWindowLibrary")]
[assembly: AssemblyCopyright("Copyright © Chris Kaczor 2014")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
[assembly: ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)]
[assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyFileVersion("1.0.0.0")]

298
Library/Properties/Resources.Designer.cs generated Normal file
View File

@@ -0,0 +1,298 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace FloatingStatusWindowLibrary.Properties {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
public class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
public static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("FloatingStatusWindowLibrary.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
public static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
/// <summary>
/// Looks up a localized string similar to All Windows.
/// </summary>
public static string AllWindowsMenu {
get {
return ResourceManager.GetString("AllWindowsMenu", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Bottom.
/// </summary>
public static string Bottom {
get {
return ResourceManager.GetString("Bottom", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Cancel.
/// </summary>
public static string Cancel {
get {
return ResourceManager.GetString("Cancel", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Center.
/// </summary>
public static string Center {
get {
return ResourceManager.GetString("Center", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Change Appearance.
/// </summary>
public static string ChangeAppearanceWindow {
get {
return ResourceManager.GetString("ChangeAppearanceWindow", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Start with Windows.
/// </summary>
public static string ContextMenuAutoStart {
get {
return ResourceManager.GetString("ContextMenuAutoStart", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Change Appearance....
/// </summary>
public static string ContextMenuChangeAppearance {
get {
return ResourceManager.GetString("ContextMenuChangeAppearance", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Close.
/// </summary>
public static string ContextMenuClose {
get {
return ResourceManager.GetString("ContextMenuClose", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Exit.
/// </summary>
public static string ContextMenuExit {
get {
return ResourceManager.GetString("ContextMenuExit", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Lock.
/// </summary>
public static string ContextMenuLock {
get {
return ResourceManager.GetString("ContextMenuLock", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Locked.
/// </summary>
public static string ContextMenuLocked {
get {
return ResourceManager.GetString("ContextMenuLocked", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Refresh.
/// </summary>
public static string ContextMenuRefresh {
get {
return ResourceManager.GetString("ContextMenuRefresh", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Settings....
/// </summary>
public static string ContextMenuSettings {
get {
return ResourceManager.GetString("ContextMenuSettings", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Unlock.
/// </summary>
public static string ContextMenuUnlock {
get {
return ResourceManager.GetString("ContextMenuUnlock", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Font _name:.
/// </summary>
public static string FontName {
get {
return ResourceManager.GetString("FontName", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Font _size:.
/// </summary>
public static string FontSize {
get {
return ResourceManager.GetString("FontSize", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to _Foreground color:.
/// </summary>
public static string ForegroundColor {
get {
return ResourceManager.GetString("ForegroundColor", resourceCulture);
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
/// </summary>
public static System.Drawing.Icon gear {
get {
object obj = ResourceManager.GetObject("gear", resourceCulture);
return ((System.Drawing.Icon)(obj));
}
}
/// <summary>
/// Looks up a localized string similar to _Horizontal alignment:.
/// </summary>
public static string HorizontalAlignment {
get {
return ResourceManager.GetString("HorizontalAlignment", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Left.
/// </summary>
public static string Left {
get {
return ResourceManager.GetString("Left", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to OK.
/// </summary>
public static string OK {
get {
return ResourceManager.GetString("OK", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to _Padding:.
/// </summary>
public static string Padding {
get {
return ResourceManager.GetString("Padding", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Right.
/// </summary>
public static string Right {
get {
return ResourceManager.GetString("Right", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Top.
/// </summary>
public static string Top {
get {
return ResourceManager.GetString("Top", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to _Vertical alignment:.
/// </summary>
public static string VerticalAlignment {
get {
return ResourceManager.GetString("VerticalAlignment", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Window.
/// </summary>
public static string WindowMenu {
get {
return ResourceManager.GetString("WindowMenu", resourceCulture);
}
}
}
}

View File

@@ -0,0 +1,199 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="AllWindowsMenu" xml:space="preserve">
<value>All Windows</value>
</data>
<data name="Bottom" xml:space="preserve">
<value>Bottom</value>
</data>
<data name="Cancel" xml:space="preserve">
<value>Cancel</value>
</data>
<data name="Center" xml:space="preserve">
<value>Center</value>
</data>
<data name="ChangeAppearanceWindow" xml:space="preserve">
<value>Change Appearance</value>
</data>
<data name="ContextMenuAutoStart" xml:space="preserve">
<value>Start with Windows</value>
</data>
<data name="ContextMenuChangeAppearance" xml:space="preserve">
<value>Change Appearance...</value>
</data>
<data name="ContextMenuClose" xml:space="preserve">
<value>Close</value>
</data>
<data name="ContextMenuExit" xml:space="preserve">
<value>Exit</value>
</data>
<data name="ContextMenuLock" xml:space="preserve">
<value>Lock</value>
</data>
<data name="ContextMenuLocked" xml:space="preserve">
<value>Locked</value>
</data>
<data name="ContextMenuRefresh" xml:space="preserve">
<value>Refresh</value>
</data>
<data name="ContextMenuSettings" xml:space="preserve">
<value>Settings...</value>
</data>
<data name="ContextMenuUnlock" xml:space="preserve">
<value>Unlock</value>
</data>
<data name="FontName" xml:space="preserve">
<value>Font _name:</value>
</data>
<data name="FontSize" xml:space="preserve">
<value>Font _size:</value>
</data>
<data name="ForegroundColor" xml:space="preserve">
<value>_Foreground color:</value>
</data>
<data name="HorizontalAlignment" xml:space="preserve">
<value>_Horizontal alignment:</value>
</data>
<data name="Left" xml:space="preserve">
<value>Left</value>
</data>
<data name="OK" xml:space="preserve">
<value>OK</value>
</data>
<data name="Padding" xml:space="preserve">
<value>_Padding:</value>
</data>
<data name="Right" xml:space="preserve">
<value>Right</value>
</data>
<data name="Top" xml:space="preserve">
<value>Top</value>
</data>
<data name="VerticalAlignment" xml:space="preserve">
<value>_Vertical alignment:</value>
</data>
<data name="WindowMenu" xml:space="preserve">
<value>Window</value>
</data>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="gear" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\gear.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>

BIN
Library/Resources/gear.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 224 KiB

34
Library/StartManager.cs Normal file
View File

@@ -0,0 +1,34 @@
using Common.Wpf.Extensions;
using System;
using System.Windows;
namespace FloatingStatusWindowLibrary
{
public static class StartManager
{
public delegate void AutoStartChangedEventHandler(bool autoStart);
public static event AutoStartChangedEventHandler AutoStartChanged = delegate { };
public static bool ManageAutoStart { get; set; }
private static bool _autoStartEnabled;
public static bool AutoStartEnabled
{
get
{
return ManageAutoStart && _autoStartEnabled;
}
set
{
if (!ManageAutoStart)
throw new InvalidOperationException("Cannot set AutoStartEnabled when ManageAutoStart is False");
_autoStartEnabled = value;
Application.Current.SetStartWithWindows(_autoStartEnabled);
AutoStartChanged(_autoStartEnabled);
}
}
}
}

77
Library/WindowManager.cs Normal file
View File

@@ -0,0 +1,77 @@
using Common.Native;
using Common.Wpf.Windows;
using System;
using System.Collections.Generic;
namespace FloatingStatusWindowLibrary
{
public static class WindowManager
{
private const string WindowMessageSetLock = "FloatingStatusWindowLibrary_SetLock";
private const string WindowMessageClose = "FloatingStatusWindowLibrary_Close";
public static uint SetLockMessage { get; set; }
public static uint CloseMessage { get; set; }
static WindowManager()
{
SetLockMessage = Functions.User32.RegisterWindowMessage(WindowMessageSetLock);
CloseMessage = Functions.User32.RegisterWindowMessage(WindowMessageClose);
}
private static readonly object WindowLocker = new object();
private static List<WindowInformation> _windowList;
private static IntPtr _excludeHandle;
public static List<WindowInformation> GetWindowList()
{
lock (WindowLocker)
{
_windowList = new List<WindowInformation>();
_excludeHandle = IntPtr.Zero;
Functions.User32.EnumWindows(EnumWindowProc, IntPtr.Zero);
return _windowList;
}
}
public static List<WindowInformation> GetWindowList(IntPtr excludeHandle)
{
lock (WindowLocker)
{
_windowList = new List<WindowInformation>();
_excludeHandle = excludeHandle;
Functions.User32.EnumWindows(EnumWindowProc, IntPtr.Zero);
return _windowList;
}
}
private static bool EnumWindowProc(IntPtr hWnd, IntPtr lParam)
{
var windowText = Functions.Window.GetText(hWnd);
if (windowText == "FloatingStatusWindow" && hWnd != _excludeHandle)
_windowList.Add(new WindowInformation(hWnd));
return true;
}
public static void SetLockOnAll(bool locked)
{
var lockState = locked ? (IntPtr) 1 : (IntPtr) 0;
foreach (var w in GetWindowList())
Functions.User32.SendMessage(w.Handle, SetLockMessage, lockState, IntPtr.Zero);
}
public static void CloseAll()
{
foreach (var w in GetWindowList())
Functions.User32.SendMessage(w.Handle, CloseMessage, IntPtr.Zero, IntPtr.Zero);
}
}
}

122
Library/WindowSettings.cs Normal file
View File

@@ -0,0 +1,122 @@
using System.Drawing;
using System.Drawing.Text;
using System.Linq;
using Common.Wpf.HtmlLabelControl;
using System;
using System.IO;
using System.Text;
using System.Windows;
using System.Windows.Media;
using System.Xml.Serialization;
using Color = System.Windows.Media.Color;
using FontFamily = System.Windows.Media.FontFamily;
using Point = System.Windows.Point;
using Size = System.Windows.Size;
using SystemFonts = System.Windows.SystemFonts;
namespace FloatingStatusWindowLibrary
{
public class WindowSettings : ICloneable
{
private const string DefaultFontName = "Consolas";
private const int DefaultFontSize = 14;
public string Name { get; set; }
public bool Visible { get; set; }
public Point Location { get; set; }
public Size Size { get; set; }
public int Padding { get; set; }
public HorizontalAlignment HorizontalAlignment { get; set; }
public VerticalAlignment VerticalAlignment { get; set; }
public bool Locked { get; set; }
public string FontName { get; set; }
public double FontSize { get; set; }
public Color FontColor { get; set; }
[XmlIgnore]
private MainWindow Window { get; set; }
[XmlIgnore]
private HtmlLabel HtmlLabel { get; set; }
[XmlIgnore]
public Font Font
{
get { return new Font(FontName, (float) FontSize); }
}
internal void SetWindow(MainWindow floatingWindow)
{
Window = floatingWindow;
HtmlLabel = floatingWindow.HtmlLabel;
}
private WindowSettings()
{
var allFonts = new InstalledFontCollection();
var fontExists = allFonts.Families.Any(f => f.Name == DefaultFontName);
FontName = fontExists ? DefaultFontName : SystemFonts.MessageFontFamily.Source;
FontColor = (System.Drawing.SystemColors.Desktop.GetBrightness() < 0.5 ? Colors.Silver : Colors.Black);
FontSize = fontExists ? DefaultFontSize : SystemFonts.MessageFontSize;
Padding = 5;
HorizontalAlignment = HorizontalAlignment.Left;
VerticalAlignment = VerticalAlignment.Bottom;
Locked = false;
}
internal void Apply()
{
// Configure the text label
HtmlLabel.FontFamily = new FontFamily(FontName);
HtmlLabel.FontSize = FontSize;
HtmlLabel.Foreground = new SolidColorBrush(FontColor);
HtmlLabel.Padding = new Thickness(Padding);
HtmlLabel.HorizontalContentAlignment = HorizontalAlignment;
HtmlLabel.VerticalContentAlignment = VerticalAlignment;
// Put the window in its last position
Window.Left = Location.X;
Window.Top = Location.Y;
// Set the last size if we have a valid size
if (!Size.Width.Equals(0) && !Size.Height.Equals(0))
{
Window.Width = Size.Width;
Window.Height = Size.Height;
}
Window.Locked = Locked;
}
public object Clone()
{
return MemberwiseClone();
}
internal static WindowSettings Load(string settings)
{
if (string.IsNullOrEmpty(settings))
return new WindowSettings();
var serializer = new XmlSerializer(typeof(WindowSettings));
TextReader textReader = new StringReader(settings);
var windowSettings = (WindowSettings) serializer.Deserialize(textReader);
textReader.Close();
return windowSettings;
}
internal string Save()
{
var builder = new StringBuilder();
var serializer = new XmlSerializer(typeof(WindowSettings));
TextWriter textWriter = new StringWriter(builder);
serializer.Serialize(textWriter, this);
textWriter.Close();
return builder.ToString();
}
}
}