7 Commits

Author SHA1 Message Date
72ddd0ad88 Allow our messages from non-elevated processes 2025-07-01 12:38:22 -04:00
5849525029 Fix color and newline handling 2024-10-17 20:50:57 -04:00
7c196787c9 Upgrade to .NET 8 2024-09-23 17:08:12 -04:00
12045ce474 Maybe this way? 2023-05-01 21:09:24 -04:00
df3af764f1 Fix build path 2023-05-01 21:07:29 -04:00
55ed61e013 Adjust namespace 2023-05-01 21:04:17 -04:00
5610542ce9 Start upgrading to .NET 7 2023-05-01 20:45:23 -04:00
28 changed files with 1246 additions and 1421 deletions

3
.gitmodules vendored
View File

@@ -1,3 +0,0 @@
[submodule "Library/Common.Wpf"]
path = Library/Common.Wpf
url = https://github.com/ckaczor/Common.Wpf.git

View File

@@ -1,25 +1,18 @@
Microsoft Visual Studio Solution File, Format Version 12.00 Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15 # Visual Studio Version 17
VisualStudioVersion = 15.0.27130.2036 VisualStudioVersion = 17.5.33530.505
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FloatingStatusWindow", "Library\FloatingStatusWindow.csproj", "{F023A16C-2F13-4A87-A8B7-22C43C4A58A4}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FloatingStatusWindow", "Library\FloatingStatusWindow.csproj", "{F023A16C-2F13-4A87-A8B7-22C43C4A58A4}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestWindow", "TestWindow\TestWindow.csproj", "{0C541788-8FFD-47B6-8E6B-653A884CFA55}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestWindow", "TestWindow\TestWindow.csproj", "{0C541788-8FFD-47B6-8E6B-653A884CFA55}"
EndProject EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution", "Solution", "{C4E7C6BF-86B2-433B-B842-31B82811FAC9}" Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution", "Solution", "{C4E7C6BF-86B2-433B-B842-31B82811FAC9}"
ProjectSection(SolutionItems) = preProject ProjectSection(SolutionItems) = preProject
.gitignore = .gitignore azure-pipelines.yml = azure-pipelines.yml
appveyor.yml = appveyor.yml
Library\FloatingStatusWindow.nuspec = Library\FloatingStatusWindow.nuspec
LICENSE.md = LICENSE.md LICENSE.md = LICENSE.md
README.md = README.md README.md = README.md
EndProjectSection EndProjectSection
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Common.Wpf", "Library\Common.Wpf\Common.Wpf.csproj", "{0074C983-550E-4094-9E8C-F566FB669297}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Common.Native", "Library\Common.Wpf\Common.Native\Common.Native.csproj", "{ED1C07A1-54F5-4796-8B06-2A0BB1960D84}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
@@ -46,30 +39,6 @@ Global
{0C541788-8FFD-47B6-8E6B-653A884CFA55}.Release|Any CPU.Build.0 = Release|Any CPU {0C541788-8FFD-47B6-8E6B-653A884CFA55}.Release|Any CPU.Build.0 = Release|Any CPU
{0C541788-8FFD-47B6-8E6B-653A884CFA55}.Release|x64.ActiveCfg = Release|Any CPU {0C541788-8FFD-47B6-8E6B-653A884CFA55}.Release|x64.ActiveCfg = Release|Any CPU
{0C541788-8FFD-47B6-8E6B-653A884CFA55}.Release|x86.ActiveCfg = Release|Any CPU {0C541788-8FFD-47B6-8E6B-653A884CFA55}.Release|x86.ActiveCfg = Release|Any CPU
{0074C983-550E-4094-9E8C-F566FB669297}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0074C983-550E-4094-9E8C-F566FB669297}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0074C983-550E-4094-9E8C-F566FB669297}.Debug|x64.ActiveCfg = Debug|x64
{0074C983-550E-4094-9E8C-F566FB669297}.Debug|x64.Build.0 = Debug|x64
{0074C983-550E-4094-9E8C-F566FB669297}.Debug|x86.ActiveCfg = Debug|x86
{0074C983-550E-4094-9E8C-F566FB669297}.Debug|x86.Build.0 = Debug|x86
{0074C983-550E-4094-9E8C-F566FB669297}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0074C983-550E-4094-9E8C-F566FB669297}.Release|Any CPU.Build.0 = Release|Any CPU
{0074C983-550E-4094-9E8C-F566FB669297}.Release|x64.ActiveCfg = Release|x64
{0074C983-550E-4094-9E8C-F566FB669297}.Release|x64.Build.0 = Release|x64
{0074C983-550E-4094-9E8C-F566FB669297}.Release|x86.ActiveCfg = Release|x86
{0074C983-550E-4094-9E8C-F566FB669297}.Release|x86.Build.0 = Release|x86
{ED1C07A1-54F5-4796-8B06-2A0BB1960D84}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{ED1C07A1-54F5-4796-8B06-2A0BB1960D84}.Debug|Any CPU.Build.0 = Debug|Any CPU
{ED1C07A1-54F5-4796-8B06-2A0BB1960D84}.Debug|x64.ActiveCfg = Debug|x64
{ED1C07A1-54F5-4796-8B06-2A0BB1960D84}.Debug|x64.Build.0 = Debug|x64
{ED1C07A1-54F5-4796-8B06-2A0BB1960D84}.Debug|x86.ActiveCfg = Debug|x86
{ED1C07A1-54F5-4796-8B06-2A0BB1960D84}.Debug|x86.Build.0 = Debug|x86
{ED1C07A1-54F5-4796-8B06-2A0BB1960D84}.Release|Any CPU.ActiveCfg = Release|Any CPU
{ED1C07A1-54F5-4796-8B06-2A0BB1960D84}.Release|Any CPU.Build.0 = Release|Any CPU
{ED1C07A1-54F5-4796-8B06-2A0BB1960D84}.Release|x64.ActiveCfg = Release|x64
{ED1C07A1-54F5-4796-8B06-2A0BB1960D84}.Release|x64.Build.0 = Release|x64
{ED1C07A1-54F5-4796-8B06-2A0BB1960D84}.Release|x86.ActiveCfg = Release|x86
{ED1C07A1-54F5-4796-8B06-2A0BB1960D84}.Release|x86.Build.0 = Release|x86
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

View File

@@ -0,0 +1,2 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Boolean x:Key="/Default/UserDictionary/Words/=Kaczor/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>

View File

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

View File

@@ -1,17 +1,27 @@
<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" <Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:properties="clr-namespace:FloatingStatusWindowLibrary.Properties" xmlns:properties="clr-namespace:ChrisKaczor.Wpf.Windows.FloatingStatusWindow.Properties"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:FloatingStatusWindowLibrary" xmlns:local="clr-namespace:ChrisKaczor.Wpf.Windows.FloatingStatusWindow"
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit" xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
xmlns:Windows="clr-namespace:Common.Wpf.Windows;assembly=Common.Wpf" x:Class="FloatingStatusWindowLibrary.AppearanceWindow" xmlns:windows="clr-namespace:ChrisKaczor.Wpf.Windows;assembly=ChrisKaczor.Wpf.Windows.ControlBox"
Title="{x:Static properties:Resources.ChangeAppearanceWindow}" Height="290" Width="450" Binding.SourceUpdated="HandleWindowSourceUpdated" x:Class="ChrisKaczor.Wpf.Windows.FloatingStatusWindow.AppearanceWindow"
Title="{x:Static properties:Resources.ChangeAppearanceWindow}"
Height="290"
Width="450"
Binding.SourceUpdated="HandleWindowSourceUpdated"
WindowStartupLocation="CenterScreen" WindowStartupLocation="CenterScreen"
ResizeMode="NoResize" SizeToContent="Height" ResizeMode="NoResize"
SizeToContent="Height"
mc:Ignorable="d" mc:Ignorable="d"
d:DataContext="{d:DesignInstance {x:Type local:WindowSettings}}" d:DataContext="{d:DesignInstance {x:Type local:WindowSettings}}"
Closing="HandleWindowClosing" x:ClassModifier="internal" Windows:ControlBox.HasMaximizeButton="False" Windows:ControlBox.HasMinimizeButton="False" Windows:ControlBox.HasSystemMenu="False" WindowStyle="ToolWindow"> Closing="HandleWindowClosing"
x:ClassModifier="internal"
windows:ControlBox.HasMaximizeButton="False"
windows:ControlBox.HasMinimizeButton="False"
windows:ControlBox.HasSystemMenu="False"
WindowStyle="ToolWindow">
<Grid> <Grid>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" />
@@ -26,12 +36,13 @@
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="*" /> <RowDefinition Height="*" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Label <Label Content="{x:Static properties:Resources.FontName}"
Content="{x:Static properties:Resources.FontName}"
x:Name="FontNameLabel" x:Name="FontNameLabel"
Target="{Binding ElementName=FontNameCombo}" Target="{Binding ElementName=FontNameCombo}"
Margin="6" /> Margin="6" />
<ComboBox x:Name="FontNameCombo" Grid.Row="0" Grid.Column="1" <ComboBox x:Name="FontNameCombo"
Grid.Row="0"
Grid.Column="1"
SelectedValuePath="Source" SelectedValuePath="Source"
SelectedValue="{Binding FontName, NotifyOnSourceUpdated=True, UpdateSourceTrigger=PropertyChanged}" SelectedValue="{Binding FontName, NotifyOnSourceUpdated=True, UpdateSourceTrigger=PropertyChanged}"
Margin="6"> Margin="6">
@@ -46,21 +57,25 @@
MinHeight="20"> MinHeight="20">
<TextBlock Text="{Binding}" <TextBlock Text="{Binding}"
FontFamily="{Binding}" FontFamily="{Binding}"
FontSize="14" Height="Auto" FontSize="14"
Height="Auto"
VerticalAlignment="Center" /> VerticalAlignment="Center" />
</Border> </Border>
</DataTemplate> </DataTemplate>
</ComboBox.ItemTemplate> </ComboBox.ItemTemplate>
</ComboBox> </ComboBox>
<Label <Label Content="{x:Static properties:Resources.FontSize}"
Content="{x:Static properties:Resources.FontSize}" x:Name="FontSizeLabel"
x:Name="FontSizeLabel" Grid.Row="1" Grid.Column="0" Grid.Row="1"
Grid.Column="0"
Target="{Binding ElementName=FontSizeCombo}" Target="{Binding ElementName=FontSizeCombo}"
Margin="6" /> Margin="6" />
<ComboBox Grid.Column="1" Grid.Row="1" <ComboBox Grid.Column="1"
Grid.Row="1"
x:Name="FontSizeCombo" x:Name="FontSizeCombo"
Text="{Binding FontSize, NotifyOnSourceUpdated=True, UpdateSourceTrigger=PropertyChanged}" Text="{Binding FontSize, NotifyOnSourceUpdated=True, UpdateSourceTrigger=PropertyChanged}"
IsEditable="True" Margin="6"> IsEditable="True"
Margin="6">
<ComboBoxItem Content="8" /> <ComboBoxItem Content="8" />
<ComboBoxItem Content="9" /> <ComboBoxItem Content="9" />
<ComboBoxItem Content="10" /> <ComboBoxItem Content="10" />
@@ -78,88 +93,104 @@
<ComboBoxItem Content="48" /> <ComboBoxItem Content="48" />
<ComboBoxItem Content="72" /> <ComboBoxItem Content="72" />
</ComboBox> </ComboBox>
<Label <Label Content="{x:Static properties:Resources.ForegroundColor}"
Content="{x:Static properties:Resources.ForegroundColor}" Grid.Row="2"
Grid.Row="2" Grid.Column="0" x:Name="ForegroundColorLabel" Grid.Column="0"
x:Name="ForegroundColorLabel"
Target="{Binding ElementName=ForegroundColorPicker}" Target="{Binding ElementName=ForegroundColorPicker}"
Margin="6" /> Margin="6" />
<xctk:ColorPicker Grid.Column="1" Grid.Row="2" <xctk:ColorPicker Grid.Column="1"
Grid.Row="2"
x:Name="ForegroundColorPicker" x:Name="ForegroundColorPicker"
DisplayColorAndName="True" DisplayColorAndName="True"
SelectedColor="{Binding FontColor, NotifyOnSourceUpdated=True, UpdateSourceTrigger=PropertyChanged}" SelectedColor="{Binding FontColor, NotifyOnSourceUpdated=True, UpdateSourceTrigger=PropertyChanged}"
Margin="6" /> Margin="6" />
<Label <Label Content="{x:Static properties:Resources.Padding}"
Content="{x:Static properties:Resources.Padding}" Grid.Row="3"
Grid.Row="3" Grid.Column="0" x:Name="PaddingLabel" Target="{Binding ElementName=PaddingUpDown}" Margin="6" /> Grid.Column="0"
x:Name="PaddingLabel"
Target="{Binding ElementName=PaddingUpDown}"
Margin="6" />
<xctk:IntegerUpDown Grid.Column="1" <xctk:IntegerUpDown Grid.Column="1"
Grid.Row="3" x:Name="PaddingUpDown" Grid.Row="3"
Minimum="0" Maximum="20" x:Name="PaddingUpDown"
Minimum="0"
Maximum="20"
Value="{Binding Padding, NotifyOnSourceUpdated=True, UpdateSourceTrigger=PropertyChanged}" Value="{Binding Padding, NotifyOnSourceUpdated=True, UpdateSourceTrigger=PropertyChanged}"
TextAlignment="Left" Margin="6" /> TextAlignment="Left"
<Label Margin="6" />
Content="{x:Static properties:Resources.HorizontalAlignment}" <Label Content="{x:Static properties:Resources.HorizontalAlignment}"
Grid.Row="4" Grid.Column="0" x:Name="HorizontalAlignmentLabel" Grid.Row="4"
Grid.Column="0"
x:Name="HorizontalAlignmentLabel"
Target="{Binding ElementName=HorizontalAlignmentCombo}" Target="{Binding ElementName=HorizontalAlignmentCombo}"
Margin="6" /> Margin="6" />
<ComboBox Grid.Column="1" Grid.Row="4" <ComboBox Grid.Column="1"
Grid.Row="4"
x:Name="HorizontalAlignmentCombo" x:Name="HorizontalAlignmentCombo"
SelectedValuePath="Tag" SelectedValuePath="Tag"
SelectedValue="{Binding HorizontalAlignment, NotifyOnSourceUpdated=True, UpdateSourceTrigger=PropertyChanged}" SelectedValue="{Binding HorizontalAlignment, NotifyOnSourceUpdated=True, UpdateSourceTrigger=PropertyChanged}"
Margin="6"> Margin="6">
<ComboBoxItem <ComboBoxItem Content="{x:Static properties:Resources.Left}"
Content="{x:Static properties:Resources.Left}"
Tag="{x:Static HorizontalAlignment.Left}" /> Tag="{x:Static HorizontalAlignment.Left}" />
<ComboBoxItem <ComboBoxItem Content="{x:Static properties:Resources.Right}"
Content="{x:Static properties:Resources.Right}"
Tag="{x:Static HorizontalAlignment.Right}" /> Tag="{x:Static HorizontalAlignment.Right}" />
<ComboBoxItem <ComboBoxItem Content="{x:Static properties:Resources.Center}"
Content="{x:Static properties:Resources.Center}"
Tag="{x:Static HorizontalAlignment.Center}" /> Tag="{x:Static HorizontalAlignment.Center}" />
</ComboBox> </ComboBox>
<Label <Label Content="{x:Static properties:Resources.VerticalAlignment}"
Content="{x:Static properties:Resources.VerticalAlignment}" Grid.Row="5"
Grid.Row="5" Grid.Column="0" x:Name="VerticalAlignmentLabel" Grid.Column="0"
x:Name="VerticalAlignmentLabel"
Target="{Binding ElementName=VerticalAlignmentCombo}" Target="{Binding ElementName=VerticalAlignmentCombo}"
Margin="6" /> Margin="6" />
<ComboBox Grid.Column="1" Grid.Row="5" <ComboBox Grid.Column="1"
Grid.Row="5"
x:Name="VerticalAlignmentCombo" x:Name="VerticalAlignmentCombo"
SelectedValuePath="Tag" SelectedValuePath="Tag"
SelectedValue="{Binding VerticalAlignment, NotifyOnSourceUpdated=True, UpdateSourceTrigger=PropertyChanged}" SelectedValue="{Binding VerticalAlignment, NotifyOnSourceUpdated=True, UpdateSourceTrigger=PropertyChanged}"
Margin="6"> Margin="6">
<ComboBoxItem <ComboBoxItem Content="{x:Static properties:Resources.Top}"
Content="{x:Static properties:Resources.Top}"
Tag="{x:Static VerticalAlignment.Top}" /> Tag="{x:Static VerticalAlignment.Top}" />
<ComboBoxItem <ComboBoxItem Content="{x:Static properties:Resources.Bottom}"
Content="{x:Static properties:Resources.Bottom}"
Tag="{x:Static VerticalAlignment.Bottom}" /> Tag="{x:Static VerticalAlignment.Bottom}" />
<ComboBoxItem <ComboBoxItem Content="{x:Static properties:Resources.Center}"
Content="{x:Static properties:Resources.Center}"
Tag="{x:Static VerticalAlignment.Center}" /> Tag="{x:Static VerticalAlignment.Center}" />
</ComboBox> </ComboBox>
<Grid Grid.Column="1" Grid.Row="6" <Grid Grid.Column="1"
HorizontalAlignment="Right" x:Name="GridButtons" Width="Auto" Grid.IsSharedSizeScope="True" Grid.Row="6"
Height="38" VerticalAlignment="Bottom"> HorizontalAlignment="Right"
x:Name="GridButtons"
Width="Auto"
Grid.IsSharedSizeScope="True"
Height="38"
VerticalAlignment="Bottom">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" <ColumnDefinition Width="Auto"
SharedSizeGroup="buttons" /> SharedSizeGroup="buttons" />
<ColumnDefinition Width="Auto" <ColumnDefinition Width="Auto"
SharedSizeGroup="buttons" /> SharedSizeGroup="buttons" />
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Button <Button Content="{x:Static properties:Resources.OK}"
Content="{x:Static properties:Resources.OK}"
Height="23" Height="23"
HorizontalAlignment="Stretch" Margin="6" HorizontalAlignment="Stretch"
Margin="6"
x:Name="OkayButton" x:Name="OkayButton"
VerticalAlignment="Stretch" Width="75" VerticalAlignment="Stretch"
Padding="7,3" IsDefault="True" Width="75"
Padding="7,3"
IsDefault="True"
Click="HandleOkayButtonClick" /> Click="HandleOkayButtonClick" />
<Button <Button Content="{x:Static properties:Resources.Cancel}"
Content="{x:Static properties:Resources.Cancel}" Grid.Column="1"
Grid.Column="1" Height="23" Height="23"
HorizontalAlignment="Stretch" Margin="6" HorizontalAlignment="Stretch"
Margin="6"
x:Name="CancelButton" x:Name="CancelButton"
VerticalAlignment="Stretch" Width="75" VerticalAlignment="Stretch"
Padding="7,3" IsCancel="True" /> Width="75"
Padding="7,3"
IsCancel="True" />
</Grid> </Grid>
</Grid> </Grid>
</Window> </Window>

View File

@@ -1,9 +1,8 @@
using Common.Wpf.Extensions; using System.Linq;
using System.Linq;
using System.Windows.Media; using System.Windows.Media;
namespace FloatingStatusWindowLibrary namespace ChrisKaczor.Wpf.Windows.FloatingStatusWindow;
{
internal partial class AppearanceWindow internal partial class AppearanceWindow
{ {
private WindowSettings _currentSettings; private WindowSettings _currentSettings;
@@ -20,9 +19,7 @@ namespace FloatingStatusWindowLibrary
var allFonts = Fonts.SystemFontFamilies.OrderBy(x => x.Source); var allFonts = Fonts.SystemFontFamilies.OrderBy(x => x.Source);
var filteredFonts = allFonts.Where(f => FontExtensions.IsComposite(f) || (!FontExtensions.IsSymbol(f) && FontExtensions.IsVisible(f))); FontNameCombo.ItemsSource = allFonts;
FontNameCombo.ItemsSource = filteredFonts;
DataContext = _currentSettings; DataContext = _currentSettings;
} }
@@ -47,4 +44,3 @@ namespace FloatingStatusWindowLibrary
_currentSettings.Apply(); _currentSettings.Apply();
} }
} }
}

View File

@@ -1,20 +1,20 @@
using FloatingStatusWindowLibrary.Properties; using ChrisKaczor.Wpf.Windows.FloatingStatusWindow.Properties;
using Hardcodet.Wpf.TaskbarNotification; using H.NotifyIcon;
using JetBrains.Annotations;
using System; using System;
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using Point = System.Windows.Point;
using Size = System.Windows.Size;
namespace FloatingStatusWindowLibrary namespace ChrisKaczor.Wpf.Windows.FloatingStatusWindow;
{
[PublicAPI]
public class FloatingStatusWindow : IDisposable public class FloatingStatusWindow : IDisposable
{ {
public event EventHandler WindowResized = delegate { }; public event EventHandler WindowResized = delegate { };
public event EventHandler WindowClosed = delegate { }; public event EventHandler WindowClosed = delegate { };
private readonly MainWindow _mainWindow; private readonly MainWindow _mainWindow;
private readonly TaskbarIcon _taskbarIcon; private readonly TaskbarIcon _trayIcon;
private readonly MenuItem _allWindowsMenuItem; private readonly MenuItem _allWindowsMenuItem;
private readonly Separator _allWindowsSeparator; private readonly Separator _allWindowsSeparator;
@@ -36,7 +36,7 @@ namespace FloatingStatusWindowLibrary
if (_windowSource.HasSettingsMenu) if (_windowSource.HasSettingsMenu)
{ {
menuItem = new MenuItem { Header = Resources.ContextMenuSettings }; menuItem = new MenuItem { Header = Resources.ContextMenuSettings };
menuItem.Click += (sender, args) => _windowSource.ShowSettings(); menuItem.Click += (_, _) => _windowSource.ShowSettings();
contextMenu.Items.Add(menuItem); contextMenu.Items.Add(menuItem);
contextMenu.Items.Add(new Separator()); contextMenu.Items.Add(new Separator());
@@ -45,7 +45,7 @@ namespace FloatingStatusWindowLibrary
if (_windowSource.HasRefreshMenu) if (_windowSource.HasRefreshMenu)
{ {
menuItem = new MenuItem { Header = Resources.ContextMenuRefresh }; menuItem = new MenuItem { Header = Resources.ContextMenuRefresh };
menuItem.Click += (sender, args) => _windowSource.Refresh(); menuItem.Click += (_, _) => _windowSource.Refresh();
contextMenu.Items.Add(menuItem); contextMenu.Items.Add(menuItem);
contextMenu.Items.Add(new Separator()); contextMenu.Items.Add(new Separator());
@@ -55,17 +55,17 @@ namespace FloatingStatusWindowLibrary
contextMenu.Items.Add(_allWindowsMenuItem); contextMenu.Items.Add(_allWindowsMenuItem);
menuItem = new MenuItem { Header = Resources.ContextMenuLock }; menuItem = new MenuItem { Header = Resources.ContextMenuLock };
menuItem.Click += (sender, args) => WindowManager.SetLockOnAll(true); menuItem.Click += (_, _) => WindowManager.SetLockOnAll(true);
_allWindowsMenuItem.Items.Add(menuItem); _allWindowsMenuItem.Items.Add(menuItem);
menuItem = new MenuItem { Header = Resources.ContextMenuUnlock }; menuItem = new MenuItem { Header = Resources.ContextMenuUnlock };
menuItem.Click += (sender, args) => WindowManager.SetLockOnAll(false); menuItem.Click += (_, _) => WindowManager.SetLockOnAll(false);
_allWindowsMenuItem.Items.Add(menuItem); _allWindowsMenuItem.Items.Add(menuItem);
_allWindowsMenuItem.Items.Add(new Separator()); _allWindowsMenuItem.Items.Add(new Separator());
menuItem = new MenuItem { Header = Resources.ContextMenuClose }; menuItem = new MenuItem { Header = Resources.ContextMenuClose };
menuItem.Click += (sender, args) => WindowManager.CloseAll(); menuItem.Click += (_, _) => WindowManager.CloseAll();
_allWindowsMenuItem.Items.Add(menuItem); _allWindowsMenuItem.Items.Add(menuItem);
_allWindowsSeparator = new Separator(); _allWindowsSeparator = new Separator();
@@ -92,9 +92,8 @@ namespace FloatingStatusWindowLibrary
Name = "contextMenuItemAutoStart", Name = "contextMenuItemAutoStart",
IsChecked = StartManager.AutoStartEnabled, IsChecked = StartManager.AutoStartEnabled,
Header = Resources.ContextMenuAutoStart Header = Resources.ContextMenuAutoStart
}; };
_autoStartMenuItem.Click += (sender, args) => StartManager.AutoStartEnabled = !StartManager.AutoStartEnabled; _autoStartMenuItem.Click += (_, _) => StartManager.AutoStartEnabled = !StartManager.AutoStartEnabled;
optionsMenu.Items.Add(_autoStartMenuItem); optionsMenu.Items.Add(_autoStartMenuItem);
} }
@@ -121,7 +120,7 @@ namespace FloatingStatusWindowLibrary
if (_windowSource.HasAboutMenu) if (_windowSource.HasAboutMenu)
{ {
menuItem = new MenuItem { Header = Resources.ContextMenuAbout }; menuItem = new MenuItem { Header = Resources.ContextMenuAbout };
menuItem.Click += (sender, args) => _windowSource.ShowAbout(); menuItem.Click += (_, _) => _windowSource.ShowAbout();
contextMenu.Items.Add(menuItem); contextMenu.Items.Add(menuItem);
contextMenu.Items.Add(new Separator()); contextMenu.Items.Add(new Separator());
@@ -135,13 +134,16 @@ namespace FloatingStatusWindowLibrary
menuItem.Click += HandleExitMenuItemClick; menuItem.Click += HandleExitMenuItemClick;
contextMenu.Items.Add(menuItem); contextMenu.Items.Add(menuItem);
_taskbarIcon = new TaskbarIcon _trayIcon = new TaskbarIcon
{ {
ToolTipText = _windowSource.Name, ToolTipText = _windowSource.Name,
Icon = _windowSource.Icon, Icon = _windowSource.Icon,
ContextMenu = contextMenu ContextMenu = contextMenu,
Id = _windowSource.Id
}; };
_trayIcon.ForceCreate();
_mainWindow = new MainWindow(windowSource); _mainWindow = new MainWindow(windowSource);
_mainWindow.Closed += HandleMainWindowClosed; _mainWindow.Closed += HandleMainWindowClosed;
_mainWindow.SizeChanged += HandleWindowSizeChanged; _mainWindow.SizeChanged += HandleWindowSizeChanged;
@@ -171,7 +173,7 @@ namespace FloatingStatusWindowLibrary
private void HandleWindowSizeChanged(object sender, SizeChangedEventArgs e) private void HandleWindowSizeChanged(object sender, SizeChangedEventArgs e)
{ {
WindowResized(this, new EventArgs()); WindowResized(this, EventArgs.Empty);
Save(); Save();
} }
@@ -188,15 +190,12 @@ namespace FloatingStatusWindowLibrary
{ {
Save(); Save();
WindowClosed(null, new EventArgs()); WindowClosed(null, EventArgs.Empty);
_taskbarIcon.Dispose(); _trayIcon.Dispose();
} }
public ContextMenu ContextMenu public ContextMenu ContextMenu => _trayIcon.ContextMenu;
{
get { return _taskbarIcon.ContextMenu; }
}
private void HandleContextMenuOpened(object sender, RoutedEventArgs e) private void HandleContextMenuOpened(object sender, RoutedEventArgs e)
{ {
@@ -213,7 +212,7 @@ namespace FloatingStatusWindowLibrary
public void SetText(string text) public void SetText(string text)
{ {
_mainWindow.HtmlLabel.Text = text; _mainWindow.HtmlLabel.Html = text;
} }
private void HandleLockedMenuItemClicked(object sender, RoutedEventArgs e) private void HandleLockedMenuItemClicked(object sender, RoutedEventArgs e)
@@ -236,35 +235,24 @@ namespace FloatingStatusWindowLibrary
public void Dispose() public void Dispose()
{ {
_taskbarIcon.Dispose(); _trayIcon.Dispose();
_mainWindow.Close(); _mainWindow.Close();
GC.SuppressFinalize(this);
} }
public Point Location public Point Location => new(_mainWindow.Left, _mainWindow.Top);
{
get { return new Point(_mainWindow.Left, _mainWindow.Top); }
}
public Size Size public Size Size => new(_mainWindow.Width, _mainWindow.Height);
{
get { return new Size(_mainWindow.Width, _mainWindow.Height); }
}
public Size ContentSize public Size ContentSize => new(_mainWindow.HtmlLabel.ActualWidth, _mainWindow.HtmlLabel.ActualHeight);
{
get { return new Size(_mainWindow.HtmlLabel.ActualWidth, _mainWindow.HtmlLabel.ActualHeight); }
}
public WindowSettings Settings public WindowSettings Settings => _mainWindow.WindowSettings;
{
get { return _mainWindow.WindowSettings; }
}
public string IconToolTipText public string IconToolTipText
{ {
get { return _taskbarIcon.ToolTipText; } get => _trayIcon.ToolTipText;
set { _taskbarIcon.ToolTipText = value; } set => _trayIcon.ToolTipText = value;
}
} }
} }

View File

@@ -1,117 +1,42 @@
<?xml version="1.0" encoding="utf-8"?> <Project Sdk="Microsoft.NET.Sdk">
<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> <PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <TargetFramework>net8.0-windows7.0</TargetFramework>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{F023A16C-2F13-4A87-A8B7-22C43C4A58A4}</ProjectGuid>
<OutputType>Library</OutputType> <OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder> <RootNamespace>ChrisKaczor.Wpf.Windows.FloatingStatusWindow</RootNamespace>
<RootNamespace>FloatingStatusWindowLibrary</RootNamespace> <AssemblyName>ChrisKaczor.Wpf.Windows.FloatingStatusWindow</AssemblyName>
<AssemblyName>FloatingStatusWindowLibrary</AssemblyName> <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion> <UseWPF>true</UseWPF>
<FileAlignment>512</FileAlignment> <ImportWindowsDesktopTargets>true</ImportWindowsDesktopTargets>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<WarningLevel>4</WarningLevel> <Title>FloatingStatusWindow</Title>
</PropertyGroup> <Authors>Chris Kaczor</Authors>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <Company>Chris Kaczor</Company>
<PlatformTarget>AnyCPU</PlatformTarget> <Description>Library to create a "floating" window that blends in with the Windows desktop and allows displaying status text.</Description>
<DebugSymbols>true</DebugSymbols> <PackageProjectUrl>https://github.com/ckaczor/FloatingStatusWindow</PackageProjectUrl>
<DebugType>full</DebugType> <PackageTags>wpf</PackageTags>
<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> </PropertyGroup>
<ItemGroup> <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>
<SubType>Designer</SubType>
</EmbeddedResource>
<AppDesigner Include="Properties\" /> <AppDesigner Include="Properties\" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="App.config" /> <PackageReference Include="ChrisKaczor.Wpf.Application.StartWithWindows" Version="1.0.5" />
<PackageReference Include="ChrisKaczor.Wpf.Controls.HtmlTextBlock" Version="1.0.6" />
<PackageReference Include="ChrisKaczor.Wpf.Windows.ControlBox" Version="1.0.3" />
<PackageReference Include="ChrisKaczor.Wpf.Windows.SnappingWindow" Version="1.0.4" />
<PackageReference Include="Extended.Wpf.Toolkit" Version="4.6.1" />
<PackageReference Include="H.NotifyIcon.Wpf" Version="2.1.3" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Page Include="AppearanceWindow.xaml"> <Compile Update="Properties\Resources.Designer.cs">
<SubType>Designer</SubType> <DesignTime>True</DesignTime>
<Generator>MSBuild:Compile</Generator> <AutoGen>True</AutoGen>
</Page> <DependentUpon>Resources.resx</DependentUpon>
<Page Include="MainWindow.xaml"> </Compile>
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="Common.Wpf\Common.Native\Common.Native.csproj"> <EmbeddedResource Update="Properties\Resources.resx">
<Project>{ed1c07a1-54f5-4796-8b06-2a0bb1960d84}</Project> <Generator>PublicResXFileCodeGenerator</Generator>
<Name>Common.Native</Name> <LastGenOutput>Resources.Designer.cs</LastGenOutput>
</ProjectReference> </EmbeddedResource>
<ProjectReference Include="Common.Wpf\Common.Wpf.csproj">
<Project>{0074c983-550e-4094-9e8c-f566fb669297}</Project>
<Name>Common.Wpf</Name>
</ProjectReference>
</ItemGroup> </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> </Project>

View File

@@ -1,15 +0,0 @@
<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>FloatingStatusWindow</id>
<version>$version$</version>
<authors>Chris Kaczor</authors>
<description>Library to create a "floating" window that blends in with the Windows desktop and allows displaying status text.</description>
<projectUrl>https://github.com/ckaczor/FloatingStatusWindow</projectUrl>
<licenseUrl>https://raw.githubusercontent.com/ckaczor/FloatingStatusWindow/master/LICENSE.md</licenseUrl>
<tags>wpf</tags>
</metadata>
<files>
<file src="bin\$configuration$\**\*" target="lib\net45" />
</files>
</package>

View File

@@ -1,9 +1,11 @@
using System.Drawing; using System;
using System.Drawing;
namespace ChrisKaczor.Wpf.Windows.FloatingStatusWindow;
namespace FloatingStatusWindowLibrary
{
public interface IWindowSource public interface IWindowSource
{ {
Guid Id { get; }
string Name { get; } string Name { get; }
string WindowSettings { get; set; } string WindowSettings { get; set; }
Icon Icon { get; } Icon Icon { get; }
@@ -16,4 +18,3 @@ namespace FloatingStatusWindowLibrary
void Refresh(); void Refresh();
void ShowAbout(); void ShowAbout();
} }
}

View File

@@ -1,11 +1,12 @@
<windows:SnappingWindow x:Class="FloatingStatusWindowLibrary.MainWindow" <snappingWindow:SnappingWindow x:Class="ChrisKaczor.Wpf.Windows.FloatingStatusWindow.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:htmlLabelControl="clr-namespace:Common.Wpf.HtmlLabelControl;assembly=Common.Wpf" xmlns:snappingWindow="clr-namespace:ChrisKaczor.Wpf.Windows;assembly=ChrisKaczor.Wpf.Windows.SnappingWindow"
xmlns:windows="clr-namespace:Common.Wpf.Windows;assembly=Common.Wpf" xmlns:controlBox="clr-namespace:ChrisKaczor.Wpf.Windows;assembly=ChrisKaczor.Wpf.Windows.ControlBox"
windows:ControlBox.HasMaximizeButton="False" xmlns:controls="clr-namespace:ChrisKaczor.Wpf.Controls;assembly=ChrisKaczor.Wpf.Controls.HtmlTextBlock"
windows:ControlBox.HasMinimizeButton="False" controlBox:ControlBox.HasMaximizeButton="False"
windows:ControlBox.HasSystemMenu="False" controlBox:ControlBox.HasMinimizeButton="False"
controlBox:ControlBox.HasSystemMenu="False"
Title="FloatingStatusWindow" Title="FloatingStatusWindow"
Height="250" Height="250"
Width="400" Width="400"
@@ -41,13 +42,17 @@
Content="&#xE115;" Content="&#xE115;"
FontFamily="Segoe UI Symbol" FontFamily="Segoe UI Symbol"
FontSize="12" FontSize="12"
Padding="0"></Button> Padding="0">
</Button>
</Grid> </Grid>
</Border> </Border>
<htmlLabelControl:HtmlLabel Name="HtmlLabel" <Grid Name="ContentGrid">
<controls:HtmlTextBlock Name="HtmlLabel"
Foreground="White" Foreground="White"
HorizontalAlignment="Stretch"
VerticalAlignment="Center"
Margin="0,24,0,0" /> Margin="0,24,0,0" />
</Grid> </Grid>
</Grid>
</Border> </Border>
</windows:SnappingWindow> </snappingWindow:SnappingWindow>

View File

@@ -1,4 +1,4 @@
using Common.Wpf.Windows; using ChrisKaczor.Wpf.Windows;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Windows; using System.Windows;
@@ -7,8 +7,8 @@ using System.Windows.Media;
using System.Windows.Shell; using System.Windows.Shell;
using System.Windows.Threading; using System.Windows.Threading;
namespace FloatingStatusWindowLibrary namespace ChrisKaczor.Wpf.Windows.FloatingStatusWindow;
{
internal partial class MainWindow internal partial class MainWindow
{ {
public event EventHandler LockStateChanged = delegate { }; public event EventHandler LockStateChanged = delegate { };
@@ -18,17 +18,13 @@ namespace FloatingStatusWindowLibrary
private readonly WindowChrome _windowChrome; private readonly WindowChrome _windowChrome;
private readonly Dispatcher _dispatcher; private readonly Dispatcher _dispatcher;
private WindowSettings _windowSettings; public WindowSettings WindowSettings { get; set; }
public WindowSettings WindowSettings
{
get { return _windowSettings; }
set { _windowSettings = value; }
}
private bool _locked; private bool _locked;
public bool Locked public bool Locked
{ {
get { return _locked; } get => _locked;
set set
{ {
_locked = value; _locked = value;
@@ -44,7 +40,7 @@ namespace FloatingStatusWindowLibrary
BorderFull.BorderBrush = (_locked ? Brushes.Transparent : SystemColors.ActiveCaptionBrush); BorderFull.BorderBrush = (_locked ? Brushes.Transparent : SystemColors.ActiveCaptionBrush);
BorderFull.IsEnabled = !_locked; BorderFull.IsEnabled = !_locked;
LockStateChanged(null, new EventArgs()); LockStateChanged(null, EventArgs.Empty);
} }
} }
@@ -59,16 +55,16 @@ namespace FloatingStatusWindowLibrary
WindowChrome.SetWindowChrome(this, _windowChrome); WindowChrome.SetWindowChrome(this, _windowChrome);
// Load the window settings // Load the window settings
_windowSettings = WindowSettings.Load(windowSource.WindowSettings); WindowSettings = WindowSettings.Load(windowSource.WindowSettings);
_windowSettings.Name = windowSource.Name; WindowSettings.Name = windowSource.Name;
_windowSettings.SetWindow(this); WindowSettings.SetWindow(this);
// Set the background of the border // Set the background of the border
HeaderBorder.Background = SystemColors.ActiveCaptionBrush; HeaderBorder.Background = SystemColors.ActiveCaptionBrush;
// Configure the header label // Configure the header label
HeaderLabel.Foreground = SystemColors.InactiveCaptionTextBrush; HeaderLabel.Foreground = SystemColors.InactiveCaptionTextBrush;
HeaderLabel.Content = _windowSettings.Name; HeaderLabel.Content = WindowSettings.Name;
// Get the thickness so we can size the visual border // Get the thickness so we can size the visual border
var resizeThickness = _windowChrome.ResizeBorderThickness; var resizeThickness = _windowChrome.ResizeBorderThickness;
@@ -78,14 +74,22 @@ namespace FloatingStatusWindowLibrary
BorderFull.BorderThickness = new Thickness(resizeThickness.Left, 0, resizeThickness.Right, resizeThickness.Bottom); BorderFull.BorderThickness = new Thickness(resizeThickness.Left, 0, resizeThickness.Right, resizeThickness.Bottom);
// Apply the stored settings // Apply the stored settings
_windowSettings.Apply(); WindowSettings.Apply();
}
protected override void OnSourceInitialized(EventArgs e)
{
base.OnSourceInitialized(e);
var windowHandle = new WindowInteropHelper(this).Handle;
WindowManager.AllowMessagesThroughFilter(windowHandle);
} }
protected override IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled) protected override IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
{ {
if (msg == WindowManager.SetLockMessage) if (msg == WindowManager.SetLockMessage)
{ {
var lockState = (wParam == (IntPtr) 1); var lockState = (wParam == 1);
_dispatcher.InvokeAsync(() => _dispatcher.InvokeAsync(() =>
{ {
@@ -96,27 +100,25 @@ namespace FloatingStatusWindowLibrary
return IntPtr.Zero; return IntPtr.Zero;
} }
if (msg == WindowManager.CloseMessage) if (msg != WindowManager.CloseMessage)
{ return base.WndProc(hwnd, msg, wParam, lParam, ref handled);
_dispatcher.InvokeAsync(Close); _dispatcher.InvokeAsync(Close);
return IntPtr.Zero; return IntPtr.Zero;
} }
return base.WndProc(hwnd, msg, wParam, lParam, ref handled);
}
protected override void OnLocationChanged(EventArgs e) protected override void OnLocationChanged(EventArgs e)
{ {
base.OnLocationChanged(e); base.OnLocationChanged(e);
_windowSettings.Location = new Point(Left, Top); WindowSettings.Location = new Point(Left, Top);
} }
protected override void OnRenderSizeChanged(SizeChangedInfo sizeInfo) protected override void OnRenderSizeChanged(SizeChangedInfo sizeInfo)
{ {
base.OnRenderSizeChanged(sizeInfo); base.OnRenderSizeChanged(sizeInfo);
_windowSettings.Size = new Size(Width, Height); WindowSettings.Size = new Size(Width, Height);
} }
protected override List<WindowInformation> OtherWindows protected override List<WindowInformation> OtherWindows
@@ -135,4 +137,3 @@ namespace FloatingStatusWindowLibrary
appearanceWindow.ShowDialog(); appearanceWindow.ShowDialog();
} }
} }
}

View File

@@ -1,19 +1,13 @@
using System.Reflection; using System.Reflection;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Windows; 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: ComVisible(false)]
[assembly: SupportedOSPlatform("windows5.1.2600")]
[assembly: ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)] [assembly: ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)]
[assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("2.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyFileVersion("2.0.0.0")]

View File

@@ -8,7 +8,7 @@
// </auto-generated> // </auto-generated>
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
namespace FloatingStatusWindowLibrary.Properties { namespace ChrisKaczor.Wpf.Windows.FloatingStatusWindow.Properties {
using System; using System;
@@ -19,7 +19,7 @@ namespace FloatingStatusWindowLibrary.Properties {
// class via a tool like ResGen or Visual Studio. // class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen // To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project. // with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
public class Resources { public class Resources {
@@ -39,7 +39,7 @@ namespace FloatingStatusWindowLibrary.Properties {
public static global::System.Resources.ResourceManager ResourceManager { public static global::System.Resources.ResourceManager ResourceManager {
get { get {
if (object.ReferenceEquals(resourceMan, null)) { if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("FloatingStatusWindowLibrary.Properties.Resources", typeof(Resources).Assembly); global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ChrisKaczor.Wpf.Windows.FloatingStatusWindow.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp; resourceMan = temp;
} }
return resourceMan; return resourceMan;

View File

@@ -1,9 +1,9 @@
using Common.Wpf.Extensions; using ChrisKaczor.Wpf.Application;
using System; using System;
using System.Windows; using System.Windows;
namespace FloatingStatusWindowLibrary namespace ChrisKaczor.Wpf.Windows.FloatingStatusWindow;
{
public static class StartManager public static class StartManager
{ {
public delegate void AutoStartChangedEventHandler(bool autoStart); public delegate void AutoStartChangedEventHandler(bool autoStart);
@@ -13,12 +13,10 @@ namespace FloatingStatusWindowLibrary
public static bool ManageAutoStart { get; set; } public static bool ManageAutoStart { get; set; }
private static bool _autoStartEnabled; private static bool _autoStartEnabled;
public static bool AutoStartEnabled public static bool AutoStartEnabled
{ {
get get => ManageAutoStart && _autoStartEnabled;
{
return ManageAutoStart && _autoStartEnabled;
}
set set
{ {
if (!ManageAutoStart) if (!ManageAutoStart)
@@ -26,9 +24,8 @@ namespace FloatingStatusWindowLibrary
_autoStartEnabled = value; _autoStartEnabled = value;
Application.Current.SetStartWithWindows(_autoStartEnabled); System.Windows.Application.Current.SetStartWithWindows(_autoStartEnabled);
AutoStartChanged(_autoStartEnabled); AutoStartChanged(_autoStartEnabled);
} }
} }
} }
}

View File

@@ -1,12 +1,39 @@
using Common.Native; using System;
using Common.Wpf.Windows;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text;
namespace FloatingStatusWindowLibrary namespace ChrisKaczor.Wpf.Windows.FloatingStatusWindow;
public static partial class WindowManager
{ {
public static class WindowManager private delegate bool EnumWindowsProc(IntPtr hWnd, IntPtr lParam);
private enum ChangeWindowMessageFilterExAction : uint
{ {
Allow = 1
}
[LibraryImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
private static partial void EnumWindows(EnumWindowsProc lpEnumFunc, IntPtr lParam);
[LibraryImport("user32.dll", SetLastError = true, StringMarshalling = StringMarshalling.Utf16, EntryPoint = "RegisterWindowMessageW")]
private static partial uint RegisterWindowMessage(string lpString);
[DllImport("user32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
private static extern int GetWindowText(IntPtr hWnd, StringBuilder lpString, int nMaxCount);
[LibraryImport("user32.dll", SetLastError = true, EntryPoint = "GetWindowTextLengthW")]
private static partial int GetWindowTextLength(IntPtr hWnd);
[LibraryImport("user32.dll", EntryPoint = "SendMessageW")]
private static partial void SendMessage(IntPtr hWnd, uint msg, IntPtr wParam, IntPtr lParam);
[LibraryImport("user32.dll", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
private static partial void ChangeWindowMessageFilterEx(IntPtr hWnd, uint msg, ChangeWindowMessageFilterExAction action, IntPtr changeInfo);
private const string WindowMessageSetLock = "FloatingStatusWindowLibrary_SetLock"; private const string WindowMessageSetLock = "FloatingStatusWindowLibrary_SetLock";
private const string WindowMessageClose = "FloatingStatusWindowLibrary_Close"; private const string WindowMessageClose = "FloatingStatusWindowLibrary_Close";
@@ -15,15 +42,21 @@ namespace FloatingStatusWindowLibrary
static WindowManager() static WindowManager()
{ {
SetLockMessage = Functions.User32.RegisterWindowMessage(WindowMessageSetLock); SetLockMessage = RegisterWindowMessage(WindowMessageSetLock);
CloseMessage = Functions.User32.RegisterWindowMessage(WindowMessageClose); CloseMessage = RegisterWindowMessage(WindowMessageClose);
} }
private static readonly object WindowLocker = new object(); private static readonly object WindowLocker = new();
private static List<WindowInformation> _windowList; private static List<WindowInformation> _windowList;
private static IntPtr _excludeHandle; private static IntPtr _excludeHandle;
public static void AllowMessagesThroughFilter(IntPtr hWnd)
{
ChangeWindowMessageFilterEx(hWnd, SetLockMessage, ChangeWindowMessageFilterExAction.Allow, IntPtr.Zero);
ChangeWindowMessageFilterEx(hWnd, CloseMessage, ChangeWindowMessageFilterExAction.Allow, IntPtr.Zero);
}
public static List<WindowInformation> GetWindowList() public static List<WindowInformation> GetWindowList()
{ {
lock (WindowLocker) lock (WindowLocker)
@@ -31,7 +64,7 @@ namespace FloatingStatusWindowLibrary
_windowList = new List<WindowInformation>(); _windowList = new List<WindowInformation>();
_excludeHandle = IntPtr.Zero; _excludeHandle = IntPtr.Zero;
Functions.User32.EnumWindows(EnumWindowProc, IntPtr.Zero); EnumWindows(EnumWindowProc, IntPtr.Zero);
return _windowList; return _windowList;
} }
@@ -44,15 +77,24 @@ namespace FloatingStatusWindowLibrary
_windowList = new List<WindowInformation>(); _windowList = new List<WindowInformation>();
_excludeHandle = excludeHandle; _excludeHandle = excludeHandle;
Functions.User32.EnumWindows(EnumWindowProc, IntPtr.Zero); EnumWindows(EnumWindowProc, IntPtr.Zero);
return _windowList; return _windowList;
} }
} }
private static string GetText(IntPtr hWnd)
{
// Allocate correct string length first
var length = GetWindowTextLength(hWnd);
var sb = new StringBuilder(length + 1);
_ = GetWindowText(hWnd, sb, sb.Capacity);
return sb.ToString();
}
private static bool EnumWindowProc(IntPtr hWnd, IntPtr lParam) private static bool EnumWindowProc(IntPtr hWnd, IntPtr lParam)
{ {
var windowText = Functions.Window.GetText(hWnd); var windowText = GetText(hWnd);
if (windowText == "FloatingStatusWindow" && hWnd != _excludeHandle) if (windowText == "FloatingStatusWindow" && hWnd != _excludeHandle)
_windowList.Add(new WindowInformation(hWnd)); _windowList.Add(new WindowInformation(hWnd));
@@ -62,16 +104,15 @@ namespace FloatingStatusWindowLibrary
public static void SetLockOnAll(bool locked) public static void SetLockOnAll(bool locked)
{ {
var lockState = locked ? (IntPtr) 1 : (IntPtr) 0; var lockState = locked ? 1 : 0;
foreach (var w in GetWindowList()) foreach (var w in GetWindowList())
Functions.User32.SendMessage(w.Handle, SetLockMessage, lockState, IntPtr.Zero); SendMessage(w.Handle, SetLockMessage, lockState, IntPtr.Zero);
} }
public static void CloseAll() public static void CloseAll()
{ {
foreach (var w in GetWindowList()) foreach (var w in GetWindowList())
Functions.User32.SendMessage(w.Handle, CloseMessage, IntPtr.Zero, IntPtr.Zero); SendMessage(w.Handle, CloseMessage, IntPtr.Zero, IntPtr.Zero);
}
} }
} }

View File

@@ -1,21 +1,17 @@
using System.Drawing; using ChrisKaczor.Wpf.Controls;
using System.Drawing.Text; using JetBrains.Annotations;
using System.Linq;
using Common.Wpf.HtmlLabelControl;
using System; using System;
using System.IO; using System.IO;
using System.Linq;
using System.Text; using System.Text;
using System.Windows; using System.Windows;
using System.Windows.Controls;
using System.Windows.Media; using System.Windows.Media;
using System.Xml.Serialization; 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 namespace ChrisKaczor.Wpf.Windows.FloatingStatusWindow;
{
[PublicAPI]
public class WindowSettings : ICloneable public class WindowSettings : ICloneable
{ {
private const string DefaultFontName = "Consolas"; private const string DefaultFontName = "Consolas";
@@ -37,23 +33,24 @@ namespace FloatingStatusWindowLibrary
private MainWindow Window { get; set; } private MainWindow Window { get; set; }
[XmlIgnore] [XmlIgnore]
private HtmlLabel HtmlLabel { get; set; } private HtmlTextBlock HtmlLabel { get; set; }
[XmlIgnore] [XmlIgnore]
public Font Font private Grid ContentGrid { get; set; }
{
get { return new Font(FontName, (float) FontSize); } [XmlIgnore]
} public System.Drawing.Font Font => new(FontName, (float)FontSize);
internal void SetWindow(MainWindow floatingWindow) internal void SetWindow(MainWindow floatingWindow)
{ {
Window = floatingWindow; Window = floatingWindow;
HtmlLabel = floatingWindow.HtmlLabel; HtmlLabel = floatingWindow.HtmlLabel;
ContentGrid = floatingWindow.ContentGrid;
} }
private WindowSettings() private WindowSettings()
{ {
var allFonts = new InstalledFontCollection(); var allFonts = new System.Drawing.Text.InstalledFontCollection();
var fontExists = allFonts.Families.Any(f => f.Name == DefaultFontName); var fontExists = allFonts.Families.Any(f => f.Name == DefaultFontName);
FontName = fontExists ? DefaultFontName : SystemFonts.MessageFontFamily.Source; FontName = fontExists ? DefaultFontName : SystemFonts.MessageFontFamily.Source;
@@ -72,8 +69,9 @@ namespace FloatingStatusWindowLibrary
HtmlLabel.FontSize = FontSize; HtmlLabel.FontSize = FontSize;
HtmlLabel.Foreground = new SolidColorBrush(FontColor); HtmlLabel.Foreground = new SolidColorBrush(FontColor);
HtmlLabel.Padding = new Thickness(Padding); HtmlLabel.Padding = new Thickness(Padding);
HtmlLabel.HorizontalContentAlignment = HorizontalAlignment;
HtmlLabel.VerticalContentAlignment = VerticalAlignment; ContentGrid.HorizontalAlignment = HorizontalAlignment;
ContentGrid.VerticalAlignment = VerticalAlignment;
// Put the window in its last position // Put the window in its last position
Window.Left = Location.X; Window.Left = Location.X;
@@ -119,4 +117,3 @@ namespace FloatingStatusWindowLibrary
return builder.ToString(); return builder.ToString();
} }
} }
}

View File

@@ -1,12 +1,12 @@
using FloatingStatusWindowLibrary; using ChrisKaczor.Wpf.Windows.FloatingStatusWindow;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Windows; using System.Windows;
using Settings = TestWindow.Properties.Settings; using Settings = TestWindow.Properties.Settings;
namespace TestWindow namespace TestWindow;
{
public partial class App public partial class App
{ {
private List<IDisposable> _windowSourceList; private List<IDisposable> _windowSourceList;
@@ -39,4 +39,3 @@ namespace TestWindow
base.OnExit(e); base.OnExit(e);
} }
} }
}

View File

@@ -2,6 +2,7 @@
using System.Resources; using System.Resources;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Windows; using System.Windows;
// General Information about an assembly is controlled through the following // General Information about an assembly is controlled through the following
@@ -16,6 +17,9 @@ using System.Windows;
[assembly: AssemblyTrademark("")] [assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture("")]
[assembly: SupportedOSPlatform("windows7.0")]
[assembly: NeutralResourcesLanguage("en-US")]
// Setting ComVisible to false makes the types in this assembly not visible // Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from // to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type. // COM, set the ComVisible attribute to true on that type.

View File

@@ -1,28 +0,0 @@
namespace TestWindow.Properties {
// This class allows you to handle specific events on the settings class:
// The SettingChanging event is raised before a setting's value is changed.
// The PropertyChanged event is raised after a setting's value is changed.
// The SettingsLoaded event is raised after the setting values are loaded.
// The SettingsSaving event is raised before the setting values are saved.
internal sealed partial class Settings {
public Settings() {
// // To add event handlers for saving and changing settings, uncomment the lines below:
//
// this.SettingChanging += this.SettingChangingEventHandler;
//
// this.SettingsSaving += this.SettingsSavingEventHandler;
//
}
private void SettingChangingEventHandler(object sender, System.Configuration.SettingChangingEventArgs e) {
// Add code to handle the SettingChangingEvent event here.
}
private void SettingsSavingEventHandler(object sender, System.ComponentModel.CancelEventArgs e) {
// Add code to handle the SettingsSaving event here.
}
}
}

View File

@@ -1,111 +1,20 @@
<?xml version="1.0" encoding="utf-8"?> <Project Sdk="Microsoft.NET.Sdk">
<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> <PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <TargetFramework>net8.0-windows7.0</TargetFramework>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{0C541788-8FFD-47B6-8E6B-653A884CFA55}</ProjectGuid>
<OutputType>WinExe</OutputType> <OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder> <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<RootNamespace>TestWindow</RootNamespace> <UseWPF>true</UseWPF>
<AssemblyName>TestWindow</AssemblyName> <ImportWindowsDesktopTargets>true</ImportWindowsDesktopTargets>
<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>
<ItemGroup> <ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Xaml">
<RequiredTargetFramework>4.0</RequiredTargetFramework>
</Reference>
<Reference Include="WindowsBase" />
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
</ItemGroup>
<ItemGroup>
<ApplicationDefinition Include="App.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="Settings.cs" />
<Compile Include="WindowSource2.cs" />
<Compile Include="WindowSource4.cs" />
<Compile Include="WindowSource3.cs" />
<Compile Include="WindowSource1.cs" />
</ItemGroup>
<ItemGroup>
<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="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<AppDesigner Include="Properties\" /> <AppDesigner Include="Properties\" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="App.config" /> <ProjectReference Include="..\Library\FloatingStatusWindow.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Library\FloatingStatusWindow.csproj"> <PackageReference Include="ChrisKaczor.Wpf.Application.StartWithWindows" Version="1.0.5" />
<Project>{f023a16c-2f13-4a87-a8b7-22c43c4a58a4}</Project> <PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<Name>FloatingStatusWindowLibrary</Name> <PackageReference Include="System.Data.DataSetExtensions" Version="4.5.0" />
</ProjectReference>
</ItemGroup> </ItemGroup>
<ItemGroup>
<None Include="Resources\Application.ico" />
</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> </Project>

View File

@@ -1,12 +1,12 @@
using FloatingStatusWindowLibrary; using ChrisKaczor.Wpf.Windows.FloatingStatusWindow;
using System; using System;
using System.Globalization; using System.Globalization;
using System.Reflection; using System.Reflection;
using System.Timers; using System.Timers;
using System.Windows.Threading; using System.Windows.Threading;
namespace TestWindow namespace TestWindow;
{
internal class WindowSource1 : IWindowSource, IDisposable internal class WindowSource1 : IWindowSource, IDisposable
{ {
private readonly FloatingStatusWindow _floatingStatusWindow; private readonly FloatingStatusWindow _floatingStatusWindow;
@@ -27,7 +27,7 @@ namespace TestWindow
private void HandleTimerElapsed(object sender, ElapsedEventArgs e) private void HandleTimerElapsed(object sender, ElapsedEventArgs e)
{ {
_dispatcher.InvokeAsync(() => _floatingStatusWindow.SetText(DateTime.Now.ToString(CultureInfo.InvariantCulture))); _dispatcher.InvokeAsync(() => _floatingStatusWindow.SetText($"<font color='green'>{DateTime.Now.ToString(CultureInfo.InvariantCulture)}</font><br/><font color='red'>{DateTime.Now.ToString(CultureInfo.InvariantCulture)}</font>"));
} }
public void Dispose() public void Dispose()
@@ -39,6 +39,8 @@ namespace TestWindow
_floatingStatusWindow.Dispose(); _floatingStatusWindow.Dispose();
} }
public Guid Id => Guid.Parse("0329D04D-B89B-4FEC-AFD0-4CB972E47FC8");
public string Name public string Name
{ {
get { return "Test Window 1"; } get { return "Test Window 1"; }
@@ -63,7 +65,6 @@ namespace TestWindow
public void ShowSettings() public void ShowSettings()
{ {
} }
public bool HasRefreshMenu public bool HasRefreshMenu
@@ -73,15 +74,11 @@ namespace TestWindow
public void Refresh() public void Refresh()
{ {
} }
public string WindowSettings public string WindowSettings
{ {
get get { return Properties.Settings.Default.WindowSettings1; }
{
return Properties.Settings.Default.WindowSettings1;
}
set set
{ {
Properties.Settings.Default.WindowSettings1 = value; Properties.Settings.Default.WindowSettings1 = value;
@@ -89,4 +86,3 @@ namespace TestWindow
} }
} }
} }
}

View File

@@ -1,12 +1,12 @@
using FloatingStatusWindowLibrary; using ChrisKaczor.Wpf.Windows.FloatingStatusWindow;
using System; using System;
using System.Globalization; using System.Globalization;
using System.Reflection; using System.Reflection;
using System.Timers; using System.Timers;
using System.Windows.Threading; using System.Windows.Threading;
namespace TestWindow namespace TestWindow;
{
internal class WindowSource2 : IWindowSource, IDisposable internal class WindowSource2 : IWindowSource, IDisposable
{ {
private readonly FloatingStatusWindow _floatingStatusWindow; private readonly FloatingStatusWindow _floatingStatusWindow;
@@ -39,6 +39,8 @@ namespace TestWindow
_floatingStatusWindow.Dispose(); _floatingStatusWindow.Dispose();
} }
public Guid Id => Guid.Parse("F42F92BC-D397-497A-8E01-E71D084BEDB6");
public string Name public string Name
{ {
get { return "Test Window 2"; } get { return "Test Window 2"; }
@@ -63,7 +65,6 @@ namespace TestWindow
public void ShowSettings() public void ShowSettings()
{ {
} }
public bool HasRefreshMenu public bool HasRefreshMenu
@@ -73,15 +74,11 @@ namespace TestWindow
public void Refresh() public void Refresh()
{ {
} }
public string WindowSettings public string WindowSettings
{ {
get get { return Properties.Settings.Default.WindowSettings2; }
{
return Properties.Settings.Default.WindowSettings2;
}
set set
{ {
Properties.Settings.Default.WindowSettings2 = value; Properties.Settings.Default.WindowSettings2 = value;
@@ -89,4 +86,3 @@ namespace TestWindow
} }
} }
} }
}

View File

@@ -1,12 +1,12 @@
using FloatingStatusWindowLibrary; using ChrisKaczor.Wpf.Windows.FloatingStatusWindow;
using System; using System;
using System.Globalization; using System.Globalization;
using System.Reflection; using System.Reflection;
using System.Timers; using System.Timers;
using System.Windows.Threading; using System.Windows.Threading;
namespace TestWindow namespace TestWindow;
{
internal class WindowSource3 : IWindowSource, IDisposable internal class WindowSource3 : IWindowSource, IDisposable
{ {
private readonly FloatingStatusWindow _floatingStatusWindow; private readonly FloatingStatusWindow _floatingStatusWindow;
@@ -39,6 +39,8 @@ namespace TestWindow
_floatingStatusWindow.Dispose(); _floatingStatusWindow.Dispose();
} }
public Guid Id => Guid.Parse("CF7466DF-8980-452B-B2FA-290B26204BF2");
public string Name public string Name
{ {
get { return "Test Window 3"; } get { return "Test Window 3"; }
@@ -63,7 +65,6 @@ namespace TestWindow
public void ShowSettings() public void ShowSettings()
{ {
} }
public bool HasRefreshMenu public bool HasRefreshMenu
@@ -73,15 +74,11 @@ namespace TestWindow
public void Refresh() public void Refresh()
{ {
} }
public string WindowSettings public string WindowSettings
{ {
get get { return Properties.Settings.Default.WindowSettings3; }
{
return Properties.Settings.Default.WindowSettings3;
}
set set
{ {
Properties.Settings.Default.WindowSettings3 = value; Properties.Settings.Default.WindowSettings3 = value;
@@ -89,4 +86,3 @@ namespace TestWindow
} }
} }
} }
}

View File

@@ -1,12 +1,12 @@
using FloatingStatusWindowLibrary; using ChrisKaczor.Wpf.Windows.FloatingStatusWindow;
using System; using System;
using System.Globalization; using System.Globalization;
using System.Reflection; using System.Reflection;
using System.Timers; using System.Timers;
using System.Windows.Threading; using System.Windows.Threading;
namespace TestWindow namespace TestWindow;
{
internal class WindowSource4 : IWindowSource, IDisposable internal class WindowSource4 : IWindowSource, IDisposable
{ {
private readonly FloatingStatusWindow _floatingStatusWindow; private readonly FloatingStatusWindow _floatingStatusWindow;
@@ -39,6 +39,8 @@ namespace TestWindow
_floatingStatusWindow.Dispose(); _floatingStatusWindow.Dispose();
} }
public Guid Id => Guid.Parse("0DD89F7E-3AD4-4226-8CBD-B75C8EBEEF32");
public string Name public string Name
{ {
get { return "Test Window 4"; } get { return "Test Window 4"; }
@@ -63,7 +65,6 @@ namespace TestWindow
public void ShowSettings() public void ShowSettings()
{ {
} }
public bool HasRefreshMenu public bool HasRefreshMenu
@@ -73,15 +74,11 @@ namespace TestWindow
public void Refresh() public void Refresh()
{ {
} }
public string WindowSettings public string WindowSettings
{ {
get get { return Properties.Settings.Default.WindowSettings4; }
{
return Properties.Settings.Default.WindowSettings4;
}
set set
{ {
Properties.Settings.Default.WindowSettings4 = value; Properties.Settings.Default.WindowSettings4 = value;
@@ -89,4 +86,3 @@ namespace TestWindow
} }
} }
} }
}

View File

@@ -1,28 +0,0 @@
version: 1.0.0.{build}
pull_requests:
do_not_increment_build_number: true
skip_tags: true
image: Visual Studio 2017
configuration: Release
assembly_info:
patch: true
file: 'Library\Properties\AssemblyInfo.cs'
assembly_version: '{version}'
assembly_file_version: '{version}'
build:
project: FloatingStatusWindow.sln
verbosity: minimal
after_build:
- cmd: nuget pack Library\FloatingStatusWindow.nuspec -Version %appveyor_build_version% -Properties Configuration=Release -OutputDirectory Library\bin\Release\
artifacts:
- path: Library\bin\$(configuration)\FloatingStatusWindow.*.nupkg
name: NuGet
deploy:
- provider: Environment
name: GitHub
- provider: Environment
name: NuGet
install:
- cmd: git submodule update --init --recursive
before_build:
- cmd: msbuild /t:restore

63
azure-pipelines.yml Normal file
View File

@@ -0,0 +1,63 @@
name: 2.0.0.$(Rev:r)
pr: none
trigger:
batch: 'true'
branches:
include:
- main
pool:
vmImage: 'windows-latest'
variables:
buildConfiguration: 'Release'
steps:
- task: GetRevision@1
displayName: 'Get Revision'
inputs:
VariableName: Revision
- task: Assembly-Info-NetCore@3
displayName: 'Set Assembly Info'
inputs:
Path: '$(Build.SourcesDirectory)'
FileNames: 'Library/*.csproj'
InsertAttributes: true
FileEncoding: 'utf-8'
WriteBOM: true
FailOnWarning: true
Authors: 'Chris Kaczor'
Copyright: 'Copyright $(date:YYYY) Chris Kaczor'
FileVersion: '2.0.0.$(Revision)'
PackageVersion: '2.0.0.$(Revision)'
- task: DotNetCoreCLI@2
displayName: 'dotnet build'
inputs:
command: 'build'
arguments: '--configuration $(buildConfiguration)'
projects: 'Library\FloatingStatusWindow.csproj'
- task: DotNetCoreCLI@2
displayName: "dotnet pack"
inputs:
command: 'pack'
arguments: '--configuration $(buildConfiguration)'
packagesToPack: 'Library\FloatingStatusWindow.csproj'
nobuild: true
versioningScheme: 'byBuildNumber'
- task: NuGetCommand@2
displayName: 'nuget push'
inputs:
command: 'push'
feedsToUse: 'select'
packagesToPush: '$(Build.ArtifactStagingDirectory)/**/*.nupkg;!$(Build.ArtifactStagingDirectory)/**/*.symbols.nupkg'
nuGetFeedType: external
publishFeedCredentials: 'NuGet'
publishVstsFeed: 'Packages'
versioningScheme: 'byBuildNumber'
allowPackageConflicts: true