mirror of
https://github.com/ckaczor/FloatingStatusWindow.git
synced 2026-01-14 01:25:36 -05:00
Initial commit
This commit is contained in:
6
FloatingStatusWindowLibrary/App.config
Normal file
6
FloatingStatusWindowLibrary/App.config
Normal 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>
|
||||
165
FloatingStatusWindowLibrary/AppearanceWindow.xaml
Normal file
165
FloatingStatusWindowLibrary/AppearanceWindow.xaml
Normal 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" MinWidth="450" MinHeight="290"
|
||||
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}"
|
||||
WindowStyle="ToolWindow" Closing="HandleWindowClosing" x:ClassModifier="internal">
|
||||
<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}"
|
||||
ShowAdvancedButton="False" 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>
|
||||
50
FloatingStatusWindowLibrary/AppearanceWindow.xaml.cs
Normal file
50
FloatingStatusWindowLibrary/AppearanceWindow.xaml.cs
Normal 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
98
FloatingStatusWindowLibrary/FloatingStatusWindow.cs
Normal file
98
FloatingStatusWindowLibrary/FloatingStatusWindow.cs
Normal file
@@ -0,0 +1,98 @@
|
||||
using Hardcodet.Wpf.TaskbarNotification;
|
||||
using System;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace FloatingStatusWindowLibrary
|
||||
{
|
||||
public class FloatingStatusWindow : IDisposable
|
||||
{
|
||||
private readonly MainWindow _mainWindow;
|
||||
private readonly TaskbarIcon _taskbarIcon;
|
||||
private readonly MenuItem _lockMenuItem;
|
||||
|
||||
private readonly IWindowSource _windowSource;
|
||||
|
||||
public FloatingStatusWindow(IWindowSource windowSource)
|
||||
{
|
||||
_windowSource = windowSource;
|
||||
|
||||
var contextMenu = new ContextMenu();
|
||||
contextMenu.Opened += HandleContextMenuOpened;
|
||||
|
||||
_lockMenuItem = new MenuItem
|
||||
{
|
||||
Name = "contextMenuItemLocked",
|
||||
IsChecked = false,
|
||||
Header = Properties.Resources.ContextMenuLocked
|
||||
};
|
||||
_lockMenuItem.Click += HandleLockedMenuItemClicked;
|
||||
contextMenu.Items.Add(_lockMenuItem);
|
||||
|
||||
contextMenu.Items.Add(new Separator());
|
||||
|
||||
var menuItem = new MenuItem
|
||||
{
|
||||
Name = "contextMenuItemExit",
|
||||
Header = Properties.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.Show();
|
||||
}
|
||||
|
||||
private void HandleMainWindowClosed(object sender, EventArgs e)
|
||||
{
|
||||
_taskbarIcon.Dispose();
|
||||
}
|
||||
|
||||
public ContextMenu ContextMenu
|
||||
{
|
||||
get { return _taskbarIcon.ContextMenu; }
|
||||
}
|
||||
|
||||
private void HandleContextMenuOpened(object sender, RoutedEventArgs e)
|
||||
{
|
||||
_lockMenuItem.IsChecked = _mainWindow.WindowSettings.Locked;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
_mainWindow.Close();
|
||||
}
|
||||
|
||||
public void Save()
|
||||
{
|
||||
_windowSource.WindowSettings = _mainWindow.WindowSettings.Save();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_taskbarIcon.Dispose();
|
||||
|
||||
_mainWindow.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
114
FloatingStatusWindowLibrary/FloatingStatusWindowLibrary.csproj
Normal file
114
FloatingStatusWindowLibrary/FloatingStatusWindowLibrary.csproj
Normal file
@@ -0,0 +1,114 @@
|
||||
<?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="Hardcodet.Wpf.TaskbarNotification">
|
||||
<HintPath>..\packages\Hardcodet.NotifyIcon.Wpf.1.0.5\lib\net45\Hardcodet.Wpf.TaskbarNotification.dll</HintPath>
|
||||
</Reference>
|
||||
<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" />
|
||||
<Reference Include="Xceed.Wpf.Toolkit, Version=2.1.0.0, Culture=neutral, PublicKeyToken=3e4669d2f30244f4, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\Extended.Wpf.Toolkit.2.1.0\lib\net40\Xceed.Wpf.Toolkit.dll</HintPath>
|
||||
</Reference>
|
||||
</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="WindowSettings.cs" />
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>PublicResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
<None Include="packages.config" />
|
||||
<AppDesigner Include="Properties\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\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>
|
||||
<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>
|
||||
<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>
|
||||
12
FloatingStatusWindowLibrary/IWindowSource.cs
Normal file
12
FloatingStatusWindowLibrary/IWindowSource.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using System.Drawing;
|
||||
|
||||
namespace FloatingStatusWindowLibrary
|
||||
{
|
||||
public interface IWindowSource
|
||||
{
|
||||
string Name { get; }
|
||||
string WindowSettings { get; set; }
|
||||
|
||||
Icon Icon { get; }
|
||||
}
|
||||
}
|
||||
31
FloatingStatusWindowLibrary/MainWindow.xaml
Normal file
31
FloatingStatusWindowLibrary/MainWindow.xaml
Normal file
@@ -0,0 +1,31 @@
|
||||
<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:p="clr-namespace:FloatingStatusWindowLibrary.Properties"
|
||||
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">
|
||||
Testing
|
||||
</Label>
|
||||
<Button Name="SettingsButton" Height="18" Width="18" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0, 0, 5, 0" WindowChrome.IsHitTestVisibleInChrome="True" Click="HandleSettingsButtonClick">
|
||||
<Button.ContextMenu>
|
||||
<ContextMenu>
|
||||
<MenuItem Name="MenuChangeAppearance" Header="{x:Static p:Resources.ChangeAppearance}" Click="HandleChangeAppearanceMenuClick" />
|
||||
</ContextMenu>
|
||||
</Button.ContextMenu>
|
||||
</Button>
|
||||
</Grid>
|
||||
</Border>
|
||||
<htmlLabelControl:HtmlLabel Name="HtmlLabel" Foreground="White" Margin="0,20,0,0" />
|
||||
</Grid>
|
||||
</Border>
|
||||
</windows:SnappingWindow>
|
||||
|
||||
133
FloatingStatusWindowLibrary/MainWindow.xaml.cs
Normal file
133
FloatingStatusWindowLibrary/MainWindow.xaml.cs
Normal file
@@ -0,0 +1,133 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows;
|
||||
using System.Windows.Interop;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Shell;
|
||||
using Common.Native;
|
||||
|
||||
namespace FloatingStatusWindowLibrary
|
||||
{
|
||||
internal partial class MainWindow
|
||||
{
|
||||
private const int WindowCaptionHeight = 24;
|
||||
|
||||
private readonly WindowChrome _windowChrome;
|
||||
|
||||
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);
|
||||
|
||||
// Show the header border if the window is unlocked
|
||||
HeaderBorder.Visibility = (_locked ? Visibility.Hidden : Visibility.Visible);
|
||||
|
||||
// Show and enable the window border if the window is unlocked
|
||||
BorderFull.BorderBrush = (_locked ? Brushes.Transparent : SystemColors.ActiveCaptionBrush);
|
||||
BorderFull.IsEnabled = !_locked;
|
||||
}
|
||||
}
|
||||
|
||||
public MainWindow(IWindowSource windowSource)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
// 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();
|
||||
|
||||
HtmlLabel.Text = "Testing";
|
||||
}
|
||||
|
||||
private void HandleChangeAppearanceMenuClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var appearanceWindow = new AppearanceWindow(_windowSettings);
|
||||
appearanceWindow.ShowDialog();
|
||||
}
|
||||
|
||||
private void HandleSettingsButtonClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
SettingsButton.ContextMenu.IsOpen = true;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
private List<Rect> _windowList;
|
||||
private IntPtr _windowHandle;
|
||||
protected override List<Rect> OtherWindows
|
||||
{
|
||||
get
|
||||
{
|
||||
_windowList = new List<Rect>();
|
||||
_windowHandle = new WindowInteropHelper(this).Handle;
|
||||
|
||||
Functions.User32.EnumWindows(EnumWindowProc, IntPtr.Zero);
|
||||
|
||||
return _windowList;
|
||||
}
|
||||
}
|
||||
|
||||
private bool EnumWindowProc(IntPtr hWnd, IntPtr lParam)
|
||||
{
|
||||
var windowText = Functions.Window.GetText(hWnd);
|
||||
|
||||
if (windowText == "FloatingStatusWindow" && hWnd != _windowHandle)
|
||||
{
|
||||
var windowPlacement = new Structures.WindowPlacement();
|
||||
Functions.User32.GetWindowPlacement(hWnd, ref windowPlacement);
|
||||
|
||||
var p = windowPlacement.NormalPosition;
|
||||
|
||||
_windowList.Add(new Rect(p.X, p.Y, p.Width, p.Height));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
19
FloatingStatusWindowLibrary/Properties/AssemblyInfo.cs
Normal file
19
FloatingStatusWindowLibrary/Properties/AssemblyInfo.cs
Normal 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")]
|
||||
216
FloatingStatusWindowLibrary/Properties/Resources.Designer.cs
generated
Normal file
216
FloatingStatusWindowLibrary/Properties/Resources.Designer.cs
generated
Normal file
@@ -0,0 +1,216 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.34014
|
||||
//
|
||||
// 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", "4.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 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 ChangeAppearance {
|
||||
get {
|
||||
return ResourceManager.GetString("ChangeAppearance", 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 Exit.
|
||||
/// </summary>
|
||||
public static string ContextMenuExit {
|
||||
get {
|
||||
return ResourceManager.GetString("ContextMenuExit", 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 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 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
171
FloatingStatusWindowLibrary/Properties/Resources.resx
Normal file
171
FloatingStatusWindowLibrary/Properties/Resources.resx
Normal file
@@ -0,0 +1,171 @@
|
||||
<?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="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="ChangeAppearance" xml:space="preserve">
|
||||
<value>Change Appearance...</value>
|
||||
</data>
|
||||
<data name="ChangeAppearanceWindow" xml:space="preserve">
|
||||
<value>Change Appearance</value>
|
||||
</data>
|
||||
<data name="ContextMenuExit" xml:space="preserve">
|
||||
<value>Exit</value>
|
||||
</data>
|
||||
<data name="ContextMenuLocked" xml:space="preserve">
|
||||
<value>Locked</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>
|
||||
</root>
|
||||
103
FloatingStatusWindowLibrary/WindowSettings.cs
Normal file
103
FloatingStatusWindowLibrary/WindowSettings.cs
Normal file
@@ -0,0 +1,103 @@
|
||||
using Common.Wpf.HtmlLabelControl;
|
||||
using System;
|
||||
using System.Configuration;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
using System.Xml.Serialization;
|
||||
|
||||
namespace FloatingStatusWindowLibrary
|
||||
{
|
||||
public class WindowSettings : ICloneable
|
||||
{
|
||||
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; }
|
||||
|
||||
internal void SetWindow(MainWindow floatingWindow)
|
||||
{
|
||||
Window = floatingWindow;
|
||||
HtmlLabel = floatingWindow.HtmlLabel;
|
||||
}
|
||||
|
||||
private WindowSettings()
|
||||
{
|
||||
FontName = SystemFonts.MessageFontFamily.Source;
|
||||
FontColor = (System.Drawing.SystemColors.Desktop.GetBrightness() < 0.5 ? Colors.White : Colors.Black);
|
||||
FontSize = SystemFonts.MessageFontSize;
|
||||
Padding = 10;
|
||||
HorizontalAlignment = HorizontalAlignment.Left;
|
||||
VerticalAlignment = VerticalAlignment.Top;
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
5
FloatingStatusWindowLibrary/packages.config
Normal file
5
FloatingStatusWindowLibrary/packages.config
Normal file
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Extended.Wpf.Toolkit" version="2.1.0" targetFramework="net45" />
|
||||
<package id="Hardcodet.NotifyIcon.Wpf" version="1.0.5" targetFramework="net45" />
|
||||
</packages>
|
||||
Reference in New Issue
Block a user