diff --git a/.gitmodules b/.gitmodules
index 6599cee..e69de29 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -1,3 +0,0 @@
-[submodule "Library/Common.Wpf"]
- path = Library/Common.Wpf
- url = https://github.com/ckaczor/Common.Wpf.git
diff --git a/FloatingStatusWindow.sln b/FloatingStatusWindow.sln
index 781e0b9..14f3e6f 100644
--- a/FloatingStatusWindow.sln
+++ b/FloatingStatusWindow.sln
@@ -1,25 +1,18 @@
-
Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 15
-VisualStudioVersion = 15.0.27130.2036
+# Visual Studio Version 17
+VisualStudioVersion = 17.5.33530.505
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
-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
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution", "Solution", "{C4E7C6BF-86B2-433B-B842-31B82811FAC9}"
ProjectSection(SolutionItems) = preProject
- .gitignore = .gitignore
- appveyor.yml = appveyor.yml
- Library\FloatingStatusWindow.nuspec = Library\FloatingStatusWindow.nuspec
+ azure-pipelines.yml = azure-pipelines.yml
LICENSE.md = LICENSE.md
README.md = README.md
EndProjectSection
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
GlobalSection(SolutionConfigurationPlatforms) = preSolution
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|x64.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
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/Library/App.config b/Library/App.config
deleted file mode 100644
index bc3672d..0000000
--- a/Library/App.config
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Library/AppearanceWindow.xaml b/Library/AppearanceWindow.xaml
index fdfc405..f40917e 100644
--- a/Library/AppearanceWindow.xaml
+++ b/Library/AppearanceWindow.xaml
@@ -1,17 +1,27 @@
+ Closing="HandleWindowClosing"
+ x:ClassModifier="internal"
+ windows:ControlBox.HasMaximizeButton="False"
+ windows:ControlBox.HasMinimizeButton="False"
+ windows:ControlBox.HasSystemMenu="False"
+ WindowStyle="ToolWindow">
@@ -26,15 +36,16 @@
-
-
+
+
@@ -45,22 +56,26 @@
+ FontFamily="{Binding}"
+ FontSize="14"
+ Height="Auto"
+ VerticalAlignment="Center" />
-
-
+
+
@@ -78,88 +93,104 @@
-
-
-
+
+
+
-
-
-
-
-
+ Grid.Row="3"
+ x:Name="PaddingUpDown"
+ Minimum="0"
+ Maximum="20"
+ Value="{Binding Padding, NotifyOnSourceUpdated=True, UpdateSourceTrigger=PropertyChanged}"
+ TextAlignment="Left"
+ Margin="6" />
+
+
+
+
+
-
-
-
-
-
+
+
+
+
+
-
+
+ SharedSizeGroup="buttons" />
+ SharedSizeGroup="buttons" />
-
-
+ VerticalAlignment="Stretch"
+ Width="75"
+ Padding="7,3"
+ IsCancel="True" />
-
+
\ No newline at end of file
diff --git a/Library/AppearanceWindow.xaml.cs b/Library/AppearanceWindow.xaml.cs
index f9cd60d..b021b61 100644
--- a/Library/AppearanceWindow.xaml.cs
+++ b/Library/AppearanceWindow.xaml.cs
@@ -1,50 +1,46 @@
-using Common.Wpf.Extensions;
-using System.Linq;
+using System.Linq;
using System.Windows.Media;
-namespace FloatingStatusWindowLibrary
+namespace ChrisKaczor.Wpf.FloatingStatusWindow;
+
+internal partial class AppearanceWindow
{
- internal partial class AppearanceWindow
+ private WindowSettings _currentSettings;
+
+ private readonly WindowSettings _originalSettings;
+
+ public AppearanceWindow(WindowSettings windowSettings)
{
- private WindowSettings _currentSettings;
+ InitializeComponent();
- private readonly WindowSettings _originalSettings;
+ _currentSettings = windowSettings;
- public AppearanceWindow(WindowSettings windowSettings)
- {
- InitializeComponent();
+ _originalSettings = (WindowSettings)_currentSettings.Clone();
- _currentSettings = windowSettings;
+ var allFonts = Fonts.SystemFontFamilies.OrderBy(x => x.Source);
- _originalSettings = (WindowSettings) _currentSettings.Clone();
+ FontNameCombo.ItemsSource = allFonts;
- 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();
- }
+ 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();
+ }
+}
\ No newline at end of file
diff --git a/Library/Common.Wpf b/Library/Common.Wpf
deleted file mode 160000
index 8a82786..0000000
--- a/Library/Common.Wpf
+++ /dev/null
@@ -1 +0,0 @@
-Subproject commit 8a82786166d49271b22e48aba0ca34cf8d366872
diff --git a/Library/FloatingStatusWindow.cs b/Library/FloatingStatusWindow.cs
index 4cf4666..45afd95 100644
--- a/Library/FloatingStatusWindow.cs
+++ b/Library/FloatingStatusWindow.cs
@@ -1,270 +1,258 @@
-using FloatingStatusWindowLibrary.Properties;
-using Hardcodet.Wpf.TaskbarNotification;
+using ChrisKaczor.Wpf.FloatingStatusWindow.Properties;
+using H.NotifyIcon;
+using JetBrains.Annotations;
using System;
using System.Windows;
using System.Windows.Controls;
-using Point = System.Windows.Point;
-using Size = System.Windows.Size;
-namespace FloatingStatusWindowLibrary
+namespace ChrisKaczor.Wpf.FloatingStatusWindow;
+
+[PublicAPI]
+public class FloatingStatusWindow : IDisposable
{
- public class FloatingStatusWindow : IDisposable
+ public event EventHandler WindowResized = delegate { };
+ public event EventHandler WindowClosed = delegate { };
+
+ private readonly MainWindow _mainWindow;
+ private readonly TaskbarIcon _trayIcon;
+
+ private readonly MenuItem _allWindowsMenuItem;
+ private readonly Separator _allWindowsSeparator;
+
+ private readonly MenuItem _lockMenuItem;
+ private readonly MenuItem _autoStartMenuItem;
+
+ private readonly IWindowSource _windowSource;
+
+ public FloatingStatusWindow(IWindowSource windowSource)
{
- public event EventHandler WindowResized = delegate { };
- public event EventHandler WindowClosed = delegate { };
+ _windowSource = windowSource;
- private readonly MainWindow _mainWindow;
- private readonly TaskbarIcon _taskbarIcon;
+ var contextMenu = new ContextMenu();
+ contextMenu.Opened += HandleContextMenuOpened;
- private readonly MenuItem _allWindowsMenuItem;
- private readonly Separator _allWindowsSeparator;
+ MenuItem menuItem;
- private readonly MenuItem _lockMenuItem;
- private readonly MenuItem _autoStartMenuItem;
-
- private readonly IWindowSource _windowSource;
-
- public FloatingStatusWindow(IWindowSource windowSource)
+ if (_windowSource.HasSettingsMenu)
{
- _windowSource = windowSource;
-
- var contextMenu = new ContextMenu();
- contextMenu.Opened += HandleContextMenuOpened;
-
- MenuItem menuItem;
-
- if (_windowSource.HasSettingsMenu)
- {
- menuItem = new MenuItem { Header = Resources.ContextMenuSettings };
- menuItem.Click += (sender, args) => _windowSource.ShowSettings();
- contextMenu.Items.Add(menuItem);
-
- contextMenu.Items.Add(new Separator());
- }
-
- if (_windowSource.HasRefreshMenu)
- {
- menuItem = new MenuItem { Header = Resources.ContextMenuRefresh };
- menuItem.Click += (sender, args) => _windowSource.Refresh();
- contextMenu.Items.Add(menuItem);
-
- contextMenu.Items.Add(new Separator());
- }
-
- _allWindowsMenuItem = new MenuItem { Header = Resources.AllWindowsMenu };
- contextMenu.Items.Add(_allWindowsMenuItem);
-
- menuItem = new MenuItem { Header = Resources.ContextMenuLock };
- menuItem.Click += (sender, args) => WindowManager.SetLockOnAll(true);
- _allWindowsMenuItem.Items.Add(menuItem);
-
- menuItem = new MenuItem { Header = Resources.ContextMenuUnlock };
- menuItem.Click += (sender, args) => WindowManager.SetLockOnAll(false);
- _allWindowsMenuItem.Items.Add(menuItem);
-
- _allWindowsMenuItem.Items.Add(new Separator());
-
- menuItem = new MenuItem { Header = Resources.ContextMenuClose };
- menuItem.Click += (sender, args) => WindowManager.CloseAll();
- _allWindowsMenuItem.Items.Add(menuItem);
-
- _allWindowsSeparator = new Separator();
- contextMenu.Items.Add(_allWindowsSeparator);
-
- var optionsMenu = new MenuItem { Name = "contextMenuItemOptions", Header = Resources.WindowMenu };
- contextMenu.Items.Add(optionsMenu);
-
- _lockMenuItem = new MenuItem
- {
- Name = "contextMenuItemLocked",
- IsChecked = false,
- Header = Resources.ContextMenuLocked
- };
- _lockMenuItem.Click += HandleLockedMenuItemClicked;
- optionsMenu.Items.Add(_lockMenuItem);
-
- if (StartManager.ManageAutoStart)
- {
- optionsMenu.Items.Add(new Separator());
-
- _autoStartMenuItem = new MenuItem
- {
- Name = "contextMenuItemAutoStart",
- IsChecked = StartManager.AutoStartEnabled,
- Header = Resources.ContextMenuAutoStart
-
- };
- _autoStartMenuItem.Click += (sender, args) => StartManager.AutoStartEnabled = !StartManager.AutoStartEnabled;
- optionsMenu.Items.Add(_autoStartMenuItem);
- }
-
- optionsMenu.Items.Add(new Separator());
-
- menuItem = new MenuItem
- {
- Name = "contextMenuResetPosition",
- Header = Resources.ContextMenuResetPosition
- };
- menuItem.Click += HandleResetPositionMenuItemClick;
- optionsMenu.Items.Add(menuItem);
-
- menuItem = new MenuItem
- {
- Name = "contextMenuChangeAppearance",
- Header = Resources.ContextMenuChangeAppearance
- };
- menuItem.Click += HandleChangeAppearanceMenuItemClick;
- optionsMenu.Items.Add(menuItem);
-
- contextMenu.Items.Add(new Separator());
-
- if (_windowSource.HasAboutMenu)
- {
- menuItem = new MenuItem { Header = Resources.ContextMenuAbout };
- menuItem.Click += (sender, args) => _windowSource.ShowAbout();
- contextMenu.Items.Add(menuItem);
-
- contextMenu.Items.Add(new Separator());
- }
-
- menuItem = new MenuItem
- {
- Name = "contextMenuItemExit",
- Header = Resources.ContextMenuExit
- };
- menuItem.Click += HandleExitMenuItemClick;
+ menuItem = new MenuItem { Header = Resources.ContextMenuSettings };
+ menuItem.Click += (_, _) => _windowSource.ShowSettings();
contextMenu.Items.Add(menuItem);
- _taskbarIcon = new TaskbarIcon
+ contextMenu.Items.Add(new Separator());
+ }
+
+ if (_windowSource.HasRefreshMenu)
+ {
+ menuItem = new MenuItem { Header = Resources.ContextMenuRefresh };
+ menuItem.Click += (_, _) => _windowSource.Refresh();
+ contextMenu.Items.Add(menuItem);
+
+ contextMenu.Items.Add(new Separator());
+ }
+
+ _allWindowsMenuItem = new MenuItem { Header = Resources.AllWindowsMenu };
+ contextMenu.Items.Add(_allWindowsMenuItem);
+
+ menuItem = new MenuItem { Header = Resources.ContextMenuLock };
+ menuItem.Click += (_, _) => WindowManager.SetLockOnAll(true);
+ _allWindowsMenuItem.Items.Add(menuItem);
+
+ menuItem = new MenuItem { Header = Resources.ContextMenuUnlock };
+ menuItem.Click += (_, _) => WindowManager.SetLockOnAll(false);
+ _allWindowsMenuItem.Items.Add(menuItem);
+
+ _allWindowsMenuItem.Items.Add(new Separator());
+
+ menuItem = new MenuItem { Header = Resources.ContextMenuClose };
+ menuItem.Click += (_, _) => WindowManager.CloseAll();
+ _allWindowsMenuItem.Items.Add(menuItem);
+
+ _allWindowsSeparator = new Separator();
+ contextMenu.Items.Add(_allWindowsSeparator);
+
+ var optionsMenu = new MenuItem { Name = "contextMenuItemOptions", Header = Resources.WindowMenu };
+ contextMenu.Items.Add(optionsMenu);
+
+ _lockMenuItem = new MenuItem
+ {
+ Name = "contextMenuItemLocked",
+ IsChecked = false,
+ Header = Resources.ContextMenuLocked
+ };
+ _lockMenuItem.Click += HandleLockedMenuItemClicked;
+ optionsMenu.Items.Add(_lockMenuItem);
+
+ if (StartManager.ManageAutoStart)
+ {
+ optionsMenu.Items.Add(new Separator());
+
+ _autoStartMenuItem = new MenuItem
{
- ToolTipText = _windowSource.Name,
- Icon = _windowSource.Icon,
- ContextMenu = contextMenu
+ Name = "contextMenuItemAutoStart",
+ IsChecked = StartManager.AutoStartEnabled,
+ Header = Resources.ContextMenuAutoStart
};
-
- _mainWindow = new MainWindow(windowSource);
- _mainWindow.Closed += HandleMainWindowClosed;
- _mainWindow.SizeChanged += HandleWindowSizeChanged;
- _mainWindow.LocationChanged += HandleWindowLocationChanged;
- _mainWindow.LockStateChanged += HandleWindowLockStateChanged;
-
- _mainWindow.Show();
+ _autoStartMenuItem.Click += (_, _) => StartManager.AutoStartEnabled = !StartManager.AutoStartEnabled;
+ optionsMenu.Items.Add(_autoStartMenuItem);
}
- private void HandleResetPositionMenuItemClick(object sender, RoutedEventArgs e)
+ optionsMenu.Items.Add(new Separator());
+
+ menuItem = new MenuItem
{
- _mainWindow.Left = 0;
- _mainWindow.Top = 0;
- _mainWindow.Width = 300;
- _mainWindow.Height = 300;
- }
+ Name = "contextMenuResetPosition",
+ Header = Resources.ContextMenuResetPosition
+ };
+ menuItem.Click += HandleResetPositionMenuItemClick;
+ optionsMenu.Items.Add(menuItem);
- private void HandleWindowLockStateChanged(object sender, EventArgs e)
+ menuItem = new MenuItem
{
- Save();
- }
+ Name = "contextMenuChangeAppearance",
+ Header = Resources.ContextMenuChangeAppearance
+ };
+ menuItem.Click += HandleChangeAppearanceMenuItemClick;
+ optionsMenu.Items.Add(menuItem);
- private void HandleWindowLocationChanged(object sender, EventArgs e)
+ contextMenu.Items.Add(new Separator());
+
+ if (_windowSource.HasAboutMenu)
{
- Save();
+ menuItem = new MenuItem { Header = Resources.ContextMenuAbout };
+ menuItem.Click += (_, _) => _windowSource.ShowAbout();
+ contextMenu.Items.Add(menuItem);
+
+ contextMenu.Items.Add(new Separator());
}
- private void HandleWindowSizeChanged(object sender, SizeChangedEventArgs e)
+ menuItem = new MenuItem
{
- WindowResized(this, new EventArgs());
+ Name = "contextMenuItemExit",
+ Header = Resources.ContextMenuExit
+ };
+ menuItem.Click += HandleExitMenuItemClick;
+ contextMenu.Items.Add(menuItem);
- Save();
- }
-
- private void HandleChangeAppearanceMenuItemClick(object sender, RoutedEventArgs e)
+ _trayIcon = new TaskbarIcon
{
- var appearanceWindow = new AppearanceWindow(_mainWindow.WindowSettings);
- appearanceWindow.ShowDialog();
+ ToolTipText = _windowSource.Name,
+ Icon = _windowSource.Icon,
+ ContextMenu = contextMenu,
+ Id = _windowSource.Id
+ };
- Save();
- }
+ _trayIcon.ForceCreate();
- private void HandleMainWindowClosed(object sender, EventArgs e)
- {
- Save();
+ _mainWindow = new MainWindow(windowSource);
+ _mainWindow.Closed += HandleMainWindowClosed;
+ _mainWindow.SizeChanged += HandleWindowSizeChanged;
+ _mainWindow.LocationChanged += HandleWindowLocationChanged;
+ _mainWindow.LockStateChanged += HandleWindowLockStateChanged;
- WindowClosed(null, new EventArgs());
-
- _taskbarIcon.Dispose();
- }
-
- public ContextMenu ContextMenu
- {
- get { return _taskbarIcon.ContextMenu; }
- }
-
- private void HandleContextMenuOpened(object sender, RoutedEventArgs e)
- {
- _lockMenuItem.IsChecked = _mainWindow.WindowSettings.Locked;
-
- if (_autoStartMenuItem != null)
- _autoStartMenuItem.IsChecked = StartManager.AutoStartEnabled;
-
- var windowCount = WindowManager.GetWindowList().Count;
-
- _allWindowsMenuItem.Visibility = windowCount <= 1 ? Visibility.Collapsed : Visibility.Visible;
- _allWindowsSeparator.Visibility = _allWindowsMenuItem.Visibility;
- }
-
- public void SetText(string text)
- {
- _mainWindow.HtmlLabel.Text = text;
- }
-
- private void HandleLockedMenuItemClicked(object sender, RoutedEventArgs e)
- {
- _mainWindow.WindowSettings.Locked = !_mainWindow.WindowSettings.Locked;
- _mainWindow.WindowSettings.Apply();
- }
-
- private void HandleExitMenuItemClick(object sender, RoutedEventArgs e)
- {
- Save();
-
- _mainWindow.Close();
- }
-
- public void Save()
- {
- _windowSource.WindowSettings = _mainWindow.WindowSettings.Save();
- }
-
- public void Dispose()
- {
- _taskbarIcon.Dispose();
-
- _mainWindow.Close();
- }
-
- public Point Location
- {
- get { return new Point(_mainWindow.Left, _mainWindow.Top); }
- }
-
- public Size Size
- {
- get { return new Size(_mainWindow.Width, _mainWindow.Height); }
- }
-
- public Size ContentSize
- {
- get { return new Size(_mainWindow.HtmlLabel.ActualWidth, _mainWindow.HtmlLabel.ActualHeight); }
- }
-
- public WindowSettings Settings
- {
- get { return _mainWindow.WindowSettings; }
- }
-
- public string IconToolTipText
- {
- get { return _taskbarIcon.ToolTipText; }
- set { _taskbarIcon.ToolTipText = value; }
- }
+ _mainWindow.Show();
}
-}
+
+ private void HandleResetPositionMenuItemClick(object sender, RoutedEventArgs e)
+ {
+ _mainWindow.Left = 0;
+ _mainWindow.Top = 0;
+ _mainWindow.Width = 300;
+ _mainWindow.Height = 300;
+ }
+
+ private void HandleWindowLockStateChanged(object sender, EventArgs e)
+ {
+ Save();
+ }
+
+ private void HandleWindowLocationChanged(object sender, EventArgs e)
+ {
+ Save();
+ }
+
+ private void HandleWindowSizeChanged(object sender, SizeChangedEventArgs e)
+ {
+ WindowResized(this, EventArgs.Empty);
+
+ Save();
+ }
+
+ private void HandleChangeAppearanceMenuItemClick(object sender, RoutedEventArgs e)
+ {
+ var appearanceWindow = new AppearanceWindow(_mainWindow.WindowSettings);
+ appearanceWindow.ShowDialog();
+
+ Save();
+ }
+
+ private void HandleMainWindowClosed(object sender, EventArgs e)
+ {
+ Save();
+
+ WindowClosed(null, EventArgs.Empty);
+
+ _trayIcon.Dispose();
+ }
+
+ public ContextMenu ContextMenu => _trayIcon.ContextMenu;
+
+ private void HandleContextMenuOpened(object sender, RoutedEventArgs e)
+ {
+ _lockMenuItem.IsChecked = _mainWindow.WindowSettings.Locked;
+
+ if (_autoStartMenuItem != null)
+ _autoStartMenuItem.IsChecked = StartManager.AutoStartEnabled;
+
+ var windowCount = WindowManager.GetWindowList().Count;
+
+ _allWindowsMenuItem.Visibility = windowCount <= 1 ? Visibility.Collapsed : Visibility.Visible;
+ _allWindowsSeparator.Visibility = _allWindowsMenuItem.Visibility;
+ }
+
+ public void SetText(string text)
+ {
+ _mainWindow.HtmlLabel.Text = text;
+ }
+
+ private void HandleLockedMenuItemClicked(object sender, RoutedEventArgs e)
+ {
+ _mainWindow.WindowSettings.Locked = !_mainWindow.WindowSettings.Locked;
+ _mainWindow.WindowSettings.Apply();
+ }
+
+ private void HandleExitMenuItemClick(object sender, RoutedEventArgs e)
+ {
+ Save();
+
+ _mainWindow.Close();
+ }
+
+ public void Save()
+ {
+ _windowSource.WindowSettings = _mainWindow.WindowSettings.Save();
+ }
+
+ public void Dispose()
+ {
+ _trayIcon.Dispose();
+
+ _mainWindow.Close();
+
+ GC.SuppressFinalize(this);
+ }
+
+ public Point Location => new(_mainWindow.Left, _mainWindow.Top);
+
+ public Size Size => new(_mainWindow.Width, _mainWindow.Height);
+
+ public Size ContentSize => new(_mainWindow.HtmlLabel.ActualWidth, _mainWindow.HtmlLabel.ActualHeight);
+
+ public WindowSettings Settings => _mainWindow.WindowSettings;
+
+ public string IconToolTipText
+ {
+ get => _trayIcon.ToolTipText;
+ set => _trayIcon.ToolTipText = value;
+ }
+}
\ No newline at end of file
diff --git a/Library/FloatingStatusWindow.csproj b/Library/FloatingStatusWindow.csproj
index 601eefd..6fd8a0a 100644
--- a/Library/FloatingStatusWindow.csproj
+++ b/Library/FloatingStatusWindow.csproj
@@ -1,117 +1,42 @@
-
-
-
+
- Debug
- AnyCPU
- {F023A16C-2F13-4A87-A8B7-22C43C4A58A4}
+ net7.0-windows
Library
- Properties
- FloatingStatusWindowLibrary
- FloatingStatusWindowLibrary
- v4.5
- 512
- {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
- 4
-
-
- AnyCPU
- true
- full
- false
- bin\Debug\
- DEBUG;TRACE
- prompt
- 4
-
-
- AnyCPU
- pdbonly
- true
- bin\Release\
- TRACE
- prompt
- 4
-
-
-
+ ChrisKaczor.Wpf.FloatingStatusWindow
+ ChrisKaczor.Wpf.FloatingStatusWindow
+ false
+ true
+ true
+ true
+ FloatingStatusWindow
+ Chris Kaczor
+ Chris Kaczor
+ Library to create a "floating" window that blends in with the Windows desktop and allows displaying status text.
+ https://github.com/ckaczor/FloatingStatusWindow
+ wpf
-
-
-
-
-
- 4.0
-
-
-
-
-
-
-
- AppearanceWindow.xaml
-
-
-
-
- MainWindow.xaml
-
-
- Code
-
-
- True
- True
- Resources.resx
-
-
-
-
-
- PublicResXFileCodeGenerator
- Resources.Designer.cs
- Designer
-
-
+
+
+
+
+
+
-
- Designer
- MSBuild:Compile
-
-
- Designer
- MSBuild:Compile
-
+
+ True
+ True
+ Resources.resx
+
-
- {ed1c07a1-54f5-4796-8b06-2a0bb1960d84}
- Common.Native
-
-
- {0074c983-550e-4094-9e8c-f566fb669297}
- Common.Wpf
-
+
+ PublicResXFileCodeGenerator
+ Resources.Designer.cs
+
-
-
- 3.2.0
-
-
- 1.0.8
-
-
-
-
\ No newline at end of file
diff --git a/Library/FloatingStatusWindow.nuspec b/Library/FloatingStatusWindow.nuspec
deleted file mode 100644
index 0170e97..0000000
--- a/Library/FloatingStatusWindow.nuspec
+++ /dev/null
@@ -1,15 +0,0 @@
-
-
-
- FloatingStatusWindow
- $version$
- Chris Kaczor
- Library to create a "floating" window that blends in with the Windows desktop and allows displaying status text.
- https://github.com/ckaczor/FloatingStatusWindow
- https://raw.githubusercontent.com/ckaczor/FloatingStatusWindow/master/LICENSE.md
- wpf
-
-
-
-
-
diff --git a/Library/IWindowSource.cs b/Library/IWindowSource.cs
index 4567313..fa364c5 100644
--- a/Library/IWindowSource.cs
+++ b/Library/IWindowSource.cs
@@ -1,19 +1,20 @@
-using System.Drawing;
+using System;
+using System.Drawing;
-namespace FloatingStatusWindowLibrary
+namespace ChrisKaczor.Wpf.FloatingStatusWindow;
+
+public interface IWindowSource
{
- public interface IWindowSource
- {
- string Name { get; }
- string WindowSettings { get; set; }
- Icon Icon { get; }
+ Guid Id { get; }
+ string Name { get; }
+ string WindowSettings { get; set; }
+ Icon Icon { get; }
- bool HasSettingsMenu { get; }
- bool HasRefreshMenu { get; }
- bool HasAboutMenu { get; }
+ bool HasSettingsMenu { get; }
+ bool HasRefreshMenu { get; }
+ bool HasAboutMenu { get; }
- void ShowSettings();
- void Refresh();
- void ShowAbout();
- }
-}
+ void ShowSettings();
+ void Refresh();
+ void ShowAbout();
+}
\ No newline at end of file
diff --git a/Library/MainWindow.xaml b/Library/MainWindow.xaml
index d0e9cc6..54a3af0 100644
--- a/Library/MainWindow.xaml
+++ b/Library/MainWindow.xaml
@@ -1,20 +1,21 @@
-
+
+ Padding="0">
+
-
+
+
-
-
+
\ No newline at end of file
diff --git a/Library/MainWindow.xaml.cs b/Library/MainWindow.xaml.cs
index 005f533..47840c8 100644
--- a/Library/MainWindow.xaml.cs
+++ b/Library/MainWindow.xaml.cs
@@ -1,4 +1,4 @@
-using Common.Wpf.Windows;
+using ChrisKaczor.Wpf.Windows;
using System;
using System.Collections.Generic;
using System.Windows;
@@ -7,132 +7,125 @@ using System.Windows.Media;
using System.Windows.Shell;
using System.Windows.Threading;
-namespace FloatingStatusWindowLibrary
+namespace ChrisKaczor.Wpf.FloatingStatusWindow;
+
+internal partial class MainWindow
{
- internal partial class MainWindow
+ public event EventHandler LockStateChanged = delegate { };
+
+ private const int WindowCaptionHeight = 24;
+
+ private readonly WindowChrome _windowChrome;
+ private readonly Dispatcher _dispatcher;
+
+ public WindowSettings WindowSettings { get; set; }
+
+ private bool _locked;
+
+ public bool Locked
{
- public event EventHandler LockStateChanged = delegate { };
-
- private const int WindowCaptionHeight = 24;
-
- private readonly WindowChrome _windowChrome;
- private readonly Dispatcher _dispatcher;
-
- private WindowSettings _windowSettings;
- public WindowSettings WindowSettings
+ get => _locked;
+ set
{
- get { return _windowSettings; }
- set { _windowSettings = value; }
- }
+ _locked = value;
- private bool _locked;
- public bool Locked
- {
- get { return _locked; }
- set
- {
- _locked = value;
+ _windowChrome.CaptionHeight = (_locked ? 0 : WindowCaptionHeight);
- _windowChrome.CaptionHeight = (_locked ? 0 : WindowCaptionHeight);
+ HtmlLabel.Margin = new Thickness(0, (_locked ? 0 : WindowCaptionHeight), 0, 0);
- HtmlLabel.Margin = new Thickness(0, (_locked ? 0 : WindowCaptionHeight), 0, 0);
+ // Show the header border if the window is unlocked
+ HeaderBorder.Visibility = (_locked ? Visibility.Collapsed : Visibility.Visible);
- // Show the header border if the window is unlocked
- HeaderBorder.Visibility = (_locked ? Visibility.Collapsed : Visibility.Visible);
+ // Show and enable the window border if the window is unlocked
+ BorderFull.BorderBrush = (_locked ? Brushes.Transparent : SystemColors.ActiveCaptionBrush);
+ BorderFull.IsEnabled = !_locked;
- // Show and enable the window border if the window is unlocked
- BorderFull.BorderBrush = (_locked ? Brushes.Transparent : SystemColors.ActiveCaptionBrush);
- BorderFull.IsEnabled = !_locked;
-
- LockStateChanged(null, new EventArgs());
- }
- }
-
- public MainWindow(IWindowSource windowSource)
- {
- InitializeComponent();
-
- _dispatcher = Dispatcher.CurrentDispatcher;
-
- // Create and set the window chrome
- _windowChrome = new WindowChrome { CaptionHeight = WindowCaptionHeight };
- WindowChrome.SetWindowChrome(this, _windowChrome);
-
- // Load the window settings
- _windowSettings = WindowSettings.Load(windowSource.WindowSettings);
- _windowSettings.Name = windowSource.Name;
- _windowSettings.SetWindow(this);
-
- // Set the background of the border
- HeaderBorder.Background = SystemColors.ActiveCaptionBrush;
-
- // Configure the header label
- HeaderLabel.Foreground = SystemColors.InactiveCaptionTextBrush;
- HeaderLabel.Content = _windowSettings.Name;
-
- // Get the thickness so we can size the visual border
- var resizeThickness = _windowChrome.ResizeBorderThickness;
-
- // Set the color of the border
- BorderFull.BorderBrush = SystemColors.ActiveCaptionBrush;
- BorderFull.BorderThickness = new Thickness(resizeThickness.Left, 0, resizeThickness.Right, resizeThickness.Bottom);
-
- // Apply the stored settings
- _windowSettings.Apply();
- }
-
- protected override IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
- {
- if (msg == WindowManager.SetLockMessage)
- {
- var lockState = (wParam == (IntPtr) 1);
-
- _dispatcher.InvokeAsync(() =>
- {
- WindowSettings.Locked = lockState;
- Locked = lockState;
- });
-
- return IntPtr.Zero;
- }
-
- if (msg == WindowManager.CloseMessage)
- {
- _dispatcher.InvokeAsync(Close);
- return IntPtr.Zero;
- }
-
- return base.WndProc(hwnd, msg, wParam, lParam, ref handled);
- }
-
- protected override void OnLocationChanged(EventArgs e)
- {
- base.OnLocationChanged(e);
-
- _windowSettings.Location = new Point(Left, Top);
- }
-
- protected override void OnRenderSizeChanged(SizeChangedInfo sizeInfo)
- {
- base.OnRenderSizeChanged(sizeInfo);
-
- _windowSettings.Size = new Size(Width, Height);
- }
-
- protected override List OtherWindows
- {
- get
- {
- var windowHandle = new WindowInteropHelper(this).Handle;
-
- return WindowManager.GetWindowList(windowHandle);
- }
- }
-
- private void HandleChangeAppearanceClick(object sender, RoutedEventArgs e)
- {
- var appearanceWindow = new AppearanceWindow(WindowSettings);
- appearanceWindow.ShowDialog();
+ LockStateChanged(null, EventArgs.Empty);
}
}
-}
+
+ public MainWindow(IWindowSource windowSource)
+ {
+ InitializeComponent();
+
+ _dispatcher = Dispatcher.CurrentDispatcher;
+
+ // Create and set the window chrome
+ _windowChrome = new WindowChrome { CaptionHeight = WindowCaptionHeight };
+ WindowChrome.SetWindowChrome(this, _windowChrome);
+
+ // Load the window settings
+ WindowSettings = WindowSettings.Load(windowSource.WindowSettings);
+ WindowSettings.Name = windowSource.Name;
+ WindowSettings.SetWindow(this);
+
+ // Set the background of the border
+ HeaderBorder.Background = SystemColors.ActiveCaptionBrush;
+
+ // Configure the header label
+ HeaderLabel.Foreground = SystemColors.InactiveCaptionTextBrush;
+ HeaderLabel.Content = WindowSettings.Name;
+
+ // Get the thickness so we can size the visual border
+ var resizeThickness = _windowChrome.ResizeBorderThickness;
+
+ // Set the color of the border
+ BorderFull.BorderBrush = SystemColors.ActiveCaptionBrush;
+ BorderFull.BorderThickness = new Thickness(resizeThickness.Left, 0, resizeThickness.Right, resizeThickness.Bottom);
+
+ // Apply the stored settings
+ WindowSettings.Apply();
+ }
+
+ protected override IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
+ {
+ if (msg == WindowManager.SetLockMessage)
+ {
+ var lockState = (wParam == 1);
+
+ _dispatcher.InvokeAsync(() =>
+ {
+ WindowSettings.Locked = lockState;
+ Locked = lockState;
+ });
+
+ return IntPtr.Zero;
+ }
+
+ if (msg != WindowManager.CloseMessage)
+ return base.WndProc(hwnd, msg, wParam, lParam, ref handled);
+
+ _dispatcher.InvokeAsync(Close);
+ return IntPtr.Zero;
+ }
+
+ protected override void OnLocationChanged(EventArgs e)
+ {
+ base.OnLocationChanged(e);
+
+ WindowSettings.Location = new Point(Left, Top);
+ }
+
+ protected override void OnRenderSizeChanged(SizeChangedInfo sizeInfo)
+ {
+ base.OnRenderSizeChanged(sizeInfo);
+
+ WindowSettings.Size = new Size(Width, Height);
+ }
+
+ protected override List OtherWindows
+ {
+ get
+ {
+ var windowHandle = new WindowInteropHelper(this).Handle;
+
+ return WindowManager.GetWindowList(windowHandle);
+ }
+ }
+
+ private void HandleChangeAppearanceClick(object sender, RoutedEventArgs e)
+ {
+ var appearanceWindow = new AppearanceWindow(WindowSettings);
+ appearanceWindow.ShowDialog();
+ }
+}
\ No newline at end of file
diff --git a/Library/Properties/AssemblyInfo.cs b/Library/Properties/AssemblyInfo.cs
index d237a2f..3411910 100644
--- a/Library/Properties/AssemblyInfo.cs
+++ b/Library/Properties/AssemblyInfo.cs
@@ -1,19 +1,13 @@
using System.Reflection;
using System.Runtime.InteropServices;
+using System.Runtime.Versioning;
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: SupportedOSPlatform("windows")]
+
[assembly: ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)]
-[assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
+[assembly: AssemblyVersion("2.0.0.0")]
+[assembly: AssemblyFileVersion("2.0.0.0")]
diff --git a/Library/Properties/Resources.Designer.cs b/Library/Properties/Resources.Designer.cs
index b3f436e..963fa9f 100644
--- a/Library/Properties/Resources.Designer.cs
+++ b/Library/Properties/Resources.Designer.cs
@@ -8,7 +8,7 @@
//
//------------------------------------------------------------------------------
-namespace FloatingStatusWindowLibrary.Properties {
+namespace ChrisKaczor.Wpf.FloatingStatusWindow.Properties {
using System;
@@ -19,7 +19,7 @@ namespace FloatingStatusWindowLibrary.Properties {
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
public class Resources {
@@ -39,7 +39,7 @@ namespace FloatingStatusWindowLibrary.Properties {
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);
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ChrisKaczor.Wpf.FloatingStatusWindow.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
diff --git a/Library/StartManager.cs b/Library/StartManager.cs
index 1e01afc..ee305f0 100644
--- a/Library/StartManager.cs
+++ b/Library/StartManager.cs
@@ -1,34 +1,31 @@
-using Common.Wpf.Extensions;
+using ChrisKaczor.Wpf.Application;
using System;
using System.Windows;
-namespace FloatingStatusWindowLibrary
+namespace ChrisKaczor.Wpf.FloatingStatusWindow;
+
+public static class StartManager
{
- public static class StartManager
+ public delegate void AutoStartChangedEventHandler(bool autoStart);
+
+ public static event AutoStartChangedEventHandler AutoStartChanged = delegate { };
+
+ public static bool ManageAutoStart { get; set; }
+
+ private static bool _autoStartEnabled;
+
+ public static bool AutoStartEnabled
{
- public delegate void AutoStartChangedEventHandler(bool autoStart);
-
- public static event AutoStartChangedEventHandler AutoStartChanged = delegate { };
-
- public static bool ManageAutoStart { get; set; }
-
- private static bool _autoStartEnabled;
- public static bool AutoStartEnabled
+ get => ManageAutoStart && _autoStartEnabled;
+ set
{
- get
- {
- return ManageAutoStart && _autoStartEnabled;
- }
- set
- {
- if (!ManageAutoStart)
- throw new InvalidOperationException("Cannot set AutoStartEnabled when ManageAutoStart is False");
+ if (!ManageAutoStart)
+ throw new InvalidOperationException("Cannot set AutoStartEnabled when ManageAutoStart is False");
- _autoStartEnabled = value;
+ _autoStartEnabled = value;
- Application.Current.SetStartWithWindows(_autoStartEnabled);
- AutoStartChanged(_autoStartEnabled);
- }
+ System.Windows.Application.Current.SetStartWithWindows(_autoStartEnabled);
+ AutoStartChanged(_autoStartEnabled);
}
}
-}
+}
\ No newline at end of file
diff --git a/Library/WindowManager.cs b/Library/WindowManager.cs
index 97a30a3..c85354e 100644
--- a/Library/WindowManager.cs
+++ b/Library/WindowManager.cs
@@ -1,77 +1,104 @@
-using Common.Native;
-using Common.Wpf.Windows;
+using ChrisKaczor.Wpf.Windows;
using System;
using System.Collections.Generic;
+using System.Runtime.InteropServices;
+using System.Text;
-namespace FloatingStatusWindowLibrary
+namespace ChrisKaczor.Wpf.FloatingStatusWindow;
+
+public static partial class WindowManager
{
- public static class WindowManager
+ private delegate bool EnumWindowsProc(IntPtr hWnd, IntPtr lParam);
+
+ [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);
+
+ private const string WindowMessageSetLock = "FloatingStatusWindowLibrary_SetLock";
+ private const string WindowMessageClose = "FloatingStatusWindowLibrary_Close";
+
+ public static uint SetLockMessage { get; set; }
+ public static uint CloseMessage { get; set; }
+
+ static WindowManager()
{
- private const string WindowMessageSetLock = "FloatingStatusWindowLibrary_SetLock";
- private const string WindowMessageClose = "FloatingStatusWindowLibrary_Close";
+ SetLockMessage = RegisterWindowMessage(WindowMessageSetLock);
+ CloseMessage = RegisterWindowMessage(WindowMessageClose);
+ }
- public static uint SetLockMessage { get; set; }
- public static uint CloseMessage { get; set; }
+ private static readonly object WindowLocker = new();
- static WindowManager()
+ private static List _windowList;
+ private static IntPtr _excludeHandle;
+
+ public static List GetWindowList()
+ {
+ lock (WindowLocker)
{
- SetLockMessage = Functions.User32.RegisterWindowMessage(WindowMessageSetLock);
- CloseMessage = Functions.User32.RegisterWindowMessage(WindowMessageClose);
- }
+ _windowList = new List();
+ _excludeHandle = IntPtr.Zero;
- private static readonly object WindowLocker = new object();
+ EnumWindows(EnumWindowProc, IntPtr.Zero);
- private static List _windowList;
- private static IntPtr _excludeHandle;
-
- public static List GetWindowList()
- {
- lock (WindowLocker)
- {
- _windowList = new List();
- _excludeHandle = IntPtr.Zero;
-
- Functions.User32.EnumWindows(EnumWindowProc, IntPtr.Zero);
-
- return _windowList;
- }
- }
-
- public static List GetWindowList(IntPtr excludeHandle)
- {
- lock (WindowLocker)
- {
- _windowList = new List();
- _excludeHandle = excludeHandle;
-
- Functions.User32.EnumWindows(EnumWindowProc, IntPtr.Zero);
-
- return _windowList;
- }
- }
-
- private static bool EnumWindowProc(IntPtr hWnd, IntPtr lParam)
- {
- var windowText = Functions.Window.GetText(hWnd);
-
- if (windowText == "FloatingStatusWindow" && hWnd != _excludeHandle)
- _windowList.Add(new WindowInformation(hWnd));
-
- return true;
- }
-
- public static void SetLockOnAll(bool locked)
- {
- var lockState = locked ? (IntPtr) 1 : (IntPtr) 0;
-
- foreach (var w in GetWindowList())
- Functions.User32.SendMessage(w.Handle, SetLockMessage, lockState, IntPtr.Zero);
- }
-
- public static void CloseAll()
- {
- foreach (var w in GetWindowList())
- Functions.User32.SendMessage(w.Handle, CloseMessage, IntPtr.Zero, IntPtr.Zero);
+ return _windowList;
}
}
-}
+
+ public static List GetWindowList(IntPtr excludeHandle)
+ {
+ lock (WindowLocker)
+ {
+ _windowList = new List();
+ _excludeHandle = excludeHandle;
+
+ EnumWindows(EnumWindowProc, IntPtr.Zero);
+
+ 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)
+ {
+ var windowText = GetText(hWnd);
+
+ if (windowText == "FloatingStatusWindow" && hWnd != _excludeHandle)
+ _windowList.Add(new WindowInformation(hWnd));
+
+ return true;
+ }
+
+ public static void SetLockOnAll(bool locked)
+ {
+ var lockState = locked ? 1 : 0;
+
+ foreach (var w in GetWindowList())
+ SendMessage(w.Handle, SetLockMessage, lockState, IntPtr.Zero);
+ }
+
+ public static void CloseAll()
+ {
+ foreach (var w in GetWindowList())
+ SendMessage(w.Handle, CloseMessage, IntPtr.Zero, IntPtr.Zero);
+ }
+}
\ No newline at end of file
diff --git a/Library/WindowSettings.cs b/Library/WindowSettings.cs
index 8e8c8c5..29f94af 100644
--- a/Library/WindowSettings.cs
+++ b/Library/WindowSettings.cs
@@ -1,122 +1,119 @@
-using System.Drawing;
-using System.Drawing.Text;
-using System.Linq;
-using Common.Wpf.HtmlLabelControl;
+using ChrisKaczor.Wpf.Controls;
+using JetBrains.Annotations;
using System;
using System.IO;
+using System.Linq;
using System.Text;
using System.Windows;
+using System.Windows.Controls;
using System.Windows.Media;
using System.Xml.Serialization;
-using Color = System.Windows.Media.Color;
-using FontFamily = System.Windows.Media.FontFamily;
-using Point = System.Windows.Point;
-using Size = System.Windows.Size;
-using SystemFonts = System.Windows.SystemFonts;
-namespace FloatingStatusWindowLibrary
+namespace ChrisKaczor.Wpf.FloatingStatusWindow;
+
+[PublicAPI]
+public class WindowSettings : ICloneable
{
- public class WindowSettings : ICloneable
+ private const string DefaultFontName = "Consolas";
+ private const int DefaultFontSize = 14;
+
+ public string Name { get; set; }
+ public bool Visible { get; set; }
+ public Point Location { get; set; }
+ public Size Size { get; set; }
+ public int Padding { get; set; }
+ public HorizontalAlignment HorizontalAlignment { get; set; }
+ public VerticalAlignment VerticalAlignment { get; set; }
+ public bool Locked { get; set; }
+ public string FontName { get; set; }
+ public double FontSize { get; set; }
+ public Color FontColor { get; set; }
+
+ [XmlIgnore]
+ private MainWindow Window { get; set; }
+
+ [XmlIgnore]
+ private HtmlTextBlock HtmlLabel { get; set; }
+
+ [XmlIgnore]
+ private Grid ContentGrid { get; set; }
+
+ [XmlIgnore]
+ public System.Drawing.Font Font => new(FontName, (float)FontSize);
+
+ internal void SetWindow(MainWindow floatingWindow)
{
- private const string DefaultFontName = "Consolas";
- private const int DefaultFontSize = 14;
-
- public string Name { get; set; }
- public bool Visible { get; set; }
- public Point Location { get; set; }
- public Size Size { get; set; }
- public int Padding { get; set; }
- public HorizontalAlignment HorizontalAlignment { get; set; }
- public VerticalAlignment VerticalAlignment { get; set; }
- public bool Locked { get; set; }
- public string FontName { get; set; }
- public double FontSize { get; set; }
- public Color FontColor { get; set; }
-
- [XmlIgnore]
- private MainWindow Window { get; set; }
-
- [XmlIgnore]
- private HtmlLabel HtmlLabel { get; set; }
-
- [XmlIgnore]
- public Font Font
- {
- get { return new Font(FontName, (float) FontSize); }
- }
-
- internal void SetWindow(MainWindow floatingWindow)
- {
- Window = floatingWindow;
- HtmlLabel = floatingWindow.HtmlLabel;
- }
-
- private WindowSettings()
- {
- var allFonts = new InstalledFontCollection();
- var fontExists = allFonts.Families.Any(f => f.Name == DefaultFontName);
-
- FontName = fontExists ? DefaultFontName : SystemFonts.MessageFontFamily.Source;
- FontColor = (System.Drawing.SystemColors.Desktop.GetBrightness() < 0.5 ? Colors.Silver : Colors.Black);
- FontSize = fontExists ? DefaultFontSize : SystemFonts.MessageFontSize;
- Padding = 5;
- HorizontalAlignment = HorizontalAlignment.Left;
- VerticalAlignment = VerticalAlignment.Bottom;
- Locked = false;
- }
-
- internal void Apply()
- {
- // Configure the text label
- HtmlLabel.FontFamily = new FontFamily(FontName);
- HtmlLabel.FontSize = FontSize;
- HtmlLabel.Foreground = new SolidColorBrush(FontColor);
- HtmlLabel.Padding = new Thickness(Padding);
- HtmlLabel.HorizontalContentAlignment = HorizontalAlignment;
- HtmlLabel.VerticalContentAlignment = VerticalAlignment;
-
- // Put the window in its last position
- Window.Left = Location.X;
- Window.Top = Location.Y;
-
- // Set the last size if we have a valid size
- if (!Size.Width.Equals(0) && !Size.Height.Equals(0))
- {
- Window.Width = Size.Width;
- Window.Height = Size.Height;
- }
-
- Window.Locked = Locked;
- }
-
- public object Clone()
- {
- return MemberwiseClone();
- }
-
- internal static WindowSettings Load(string settings)
- {
- if (string.IsNullOrEmpty(settings))
- return new WindowSettings();
-
- var serializer = new XmlSerializer(typeof(WindowSettings));
- TextReader textReader = new StringReader(settings);
- var windowSettings = (WindowSettings) serializer.Deserialize(textReader);
- textReader.Close();
-
- return windowSettings;
- }
-
- internal string Save()
- {
- var builder = new StringBuilder();
-
- var serializer = new XmlSerializer(typeof(WindowSettings));
- TextWriter textWriter = new StringWriter(builder);
- serializer.Serialize(textWriter, this);
- textWriter.Close();
-
- return builder.ToString();
- }
+ Window = floatingWindow;
+ HtmlLabel = floatingWindow.HtmlLabel;
+ ContentGrid = floatingWindow.ContentGrid;
}
-}
+
+ private WindowSettings()
+ {
+ var allFonts = new System.Drawing.Text.InstalledFontCollection();
+ var fontExists = allFonts.Families.Any(f => f.Name == DefaultFontName);
+
+ FontName = fontExists ? DefaultFontName : SystemFonts.MessageFontFamily.Source;
+ FontColor = (System.Drawing.SystemColors.Desktop.GetBrightness() < 0.5 ? Colors.Silver : Colors.Black);
+ FontSize = fontExists ? DefaultFontSize : SystemFonts.MessageFontSize;
+ Padding = 5;
+ HorizontalAlignment = HorizontalAlignment.Left;
+ VerticalAlignment = VerticalAlignment.Bottom;
+ Locked = false;
+ }
+
+ internal void Apply()
+ {
+ // Configure the text label
+ HtmlLabel.FontFamily = new FontFamily(FontName);
+ HtmlLabel.FontSize = FontSize;
+ HtmlLabel.Foreground = new SolidColorBrush(FontColor);
+ HtmlLabel.Padding = new Thickness(Padding);
+
+ ContentGrid.HorizontalAlignment = HorizontalAlignment;
+ ContentGrid.VerticalAlignment = 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();
+ }
+}
\ No newline at end of file
diff --git a/TestWindow/App.xaml.cs b/TestWindow/App.xaml.cs
index eee8df3..ca9c8d9 100644
--- a/TestWindow/App.xaml.cs
+++ b/TestWindow/App.xaml.cs
@@ -1,42 +1,41 @@
-using FloatingStatusWindowLibrary;
+using ChrisKaczor.Wpf.FloatingStatusWindow;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Windows;
using Settings = TestWindow.Properties.Settings;
-namespace TestWindow
+namespace TestWindow;
+
+public partial class App
{
- public partial class App
+ private List _windowSourceList;
+
+ protected override void OnStartup(StartupEventArgs e)
{
- private List _windowSourceList;
+ base.OnStartup(e);
- protected override void OnStartup(StartupEventArgs e)
+ StartManager.ManageAutoStart = true;
+ StartManager.AutoStartEnabled = !Debugger.IsAttached && Settings.Default.AutoStart;
+ StartManager.AutoStartChanged += (value =>
{
- base.OnStartup(e);
+ Settings.Default.AutoStart = value;
+ Settings.Default.Save();
+ });
- StartManager.ManageAutoStart = true;
- StartManager.AutoStartEnabled = !Debugger.IsAttached && Settings.Default.AutoStart;
- StartManager.AutoStartChanged += (value =>
- {
- Settings.Default.AutoStart = value;
- Settings.Default.Save();
- });
-
- _windowSourceList = new List
- {
- new WindowSource1(),
- new WindowSource2(),
- new WindowSource3(),
- new WindowSource4()
- };
- }
-
- protected override void OnExit(ExitEventArgs e)
+ _windowSourceList = new List
{
- _windowSourceList.ForEach(ws => ws.Dispose());
-
- base.OnExit(e);
- }
+ new WindowSource1(),
+ new WindowSource2(),
+ new WindowSource3(),
+ new WindowSource4()
+ };
}
-}
+
+ protected override void OnExit(ExitEventArgs e)
+ {
+ _windowSourceList.ForEach(ws => ws.Dispose());
+
+ base.OnExit(e);
+ }
+}
\ No newline at end of file
diff --git a/TestWindow/Properties/AssemblyInfo.cs b/TestWindow/Properties/AssemblyInfo.cs
index 92d4a6d..08b0ee7 100644
--- a/TestWindow/Properties/AssemblyInfo.cs
+++ b/TestWindow/Properties/AssemblyInfo.cs
@@ -2,6 +2,7 @@
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
+using System.Runtime.Versioning;
using System.Windows;
// General Information about an assembly is controlled through the following
@@ -16,6 +17,9 @@ using System.Windows;
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
+[assembly: SupportedOSPlatform("windows7.0")]
+[assembly: NeutralResourcesLanguage("en-US")]
+
// 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
// COM, set the ComVisible attribute to true on that type.
diff --git a/TestWindow/Settings.cs b/TestWindow/Settings.cs
deleted file mode 100644
index c6a7a03..0000000
--- a/TestWindow/Settings.cs
+++ /dev/null
@@ -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.
- }
- }
-}
diff --git a/TestWindow/TestWindow.csproj b/TestWindow/TestWindow.csproj
index 02f6565..5bf4185 100644
--- a/TestWindow/TestWindow.csproj
+++ b/TestWindow/TestWindow.csproj
@@ -1,111 +1,20 @@
-
-
-
+
- Debug
- AnyCPU
- {0C541788-8FFD-47B6-8E6B-653A884CFA55}
+ net70-windows
WinExe
- Properties
- TestWindow
- TestWindow
- v4.5
- 512
- {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
- 4
-
-
- AnyCPU
- true
- full
- false
- bin\Debug\
- DEBUG;TRACE
- prompt
- 4
-
-
- AnyCPU
- pdbonly
- true
- bin\Release\
- TRACE
- prompt
- 4
+ false
+ true
+ true
-
-
-
-
-
-
-
-
-
- 4.0
-
-
-
-
-
-
-
- MSBuild:Compile
- Designer
-
-
- App.xaml
- Code
-
-
-
-
-
-
-
-
-
- Code
-
-
- True
- True
- Resources.resx
-
-
- True
- Settings.settings
- True
-
-
- ResXFileCodeGenerator
- Resources.Designer.cs
-
-
- SettingsSingleFileGenerator
- Settings.Designer.cs
-
-
+
-
- {f023a16c-2f13-4a87-a8b7-22c43c4a58a4}
- FloatingStatusWindowLibrary
-
+
+
+
-
-
-
-
-
\ No newline at end of file
diff --git a/TestWindow/WindowSource1.cs b/TestWindow/WindowSource1.cs
index 8092ae8..fea595c 100644
--- a/TestWindow/WindowSource1.cs
+++ b/TestWindow/WindowSource1.cs
@@ -1,92 +1,88 @@
-using FloatingStatusWindowLibrary;
+using ChrisKaczor.Wpf.FloatingStatusWindow;
using System;
using System.Globalization;
using System.Reflection;
using System.Timers;
using System.Windows.Threading;
-namespace TestWindow
+namespace TestWindow;
+
+internal class WindowSource1 : IWindowSource, IDisposable
{
- internal class WindowSource1 : IWindowSource, IDisposable
+ private readonly FloatingStatusWindow _floatingStatusWindow;
+ private readonly Timer _timer;
+ private readonly Dispatcher _dispatcher;
+
+ internal WindowSource1()
{
- private readonly FloatingStatusWindow _floatingStatusWindow;
- private readonly Timer _timer;
- private readonly Dispatcher _dispatcher;
+ _floatingStatusWindow = new FloatingStatusWindow(this);
+ _floatingStatusWindow.SetText("Loading...");
- internal WindowSource1()
+ _dispatcher = Dispatcher.CurrentDispatcher;
+
+ _timer = new Timer(1000);
+ _timer.Elapsed += HandleTimerElapsed;
+ _timer.Enabled = true;
+ }
+
+ private void HandleTimerElapsed(object sender, ElapsedEventArgs e)
+ {
+ _dispatcher.InvokeAsync(() => _floatingStatusWindow.SetText(DateTime.Now.ToString(CultureInfo.InvariantCulture)));
+ }
+
+ public void Dispose()
+ {
+ _timer.Enabled = false;
+ _timer.Dispose();
+
+ _floatingStatusWindow.Save();
+ _floatingStatusWindow.Dispose();
+ }
+
+ public Guid Id => Guid.Parse("0329D04D-B89B-4FEC-AFD0-4CB972E47FC8");
+
+ public string Name
+ {
+ get { return "Test Window 1"; }
+ }
+
+ public System.Drawing.Icon Icon
+ {
+ get { return Properties.Resources.ApplicationIcon; }
+ }
+
+ public bool HasSettingsMenu
+ {
+ get { return true; }
+ }
+
+ public bool HasAboutMenu => true;
+
+ public void ShowAbout()
+ {
+ _floatingStatusWindow.SetText(Assembly.GetEntryAssembly().GetName().Version.ToString());
+ }
+
+ public void ShowSettings()
+ {
+ }
+
+ public bool HasRefreshMenu
+ {
+ get { return true; }
+ }
+
+ public void Refresh()
+ {
+ }
+
+ public string WindowSettings
+ {
+ get { return Properties.Settings.Default.WindowSettings1; }
+ set
{
- _floatingStatusWindow = new FloatingStatusWindow(this);
- _floatingStatusWindow.SetText("Loading...");
-
- _dispatcher = Dispatcher.CurrentDispatcher;
-
- _timer = new Timer(1000);
- _timer.Elapsed += HandleTimerElapsed;
- _timer.Enabled = true;
- }
-
- private void HandleTimerElapsed(object sender, ElapsedEventArgs e)
- {
- _dispatcher.InvokeAsync(() => _floatingStatusWindow.SetText(DateTime.Now.ToString(CultureInfo.InvariantCulture)));
- }
-
- public void Dispose()
- {
- _timer.Enabled = false;
- _timer.Dispose();
-
- _floatingStatusWindow.Save();
- _floatingStatusWindow.Dispose();
- }
-
- public string Name
- {
- get { return "Test Window 1"; }
- }
-
- public System.Drawing.Icon Icon
- {
- get { return Properties.Resources.ApplicationIcon; }
- }
-
- public bool HasSettingsMenu
- {
- get { return true; }
- }
-
- public bool HasAboutMenu => true;
-
- public void ShowAbout()
- {
- _floatingStatusWindow.SetText(Assembly.GetEntryAssembly().GetName().Version.ToString());
- }
-
- public void ShowSettings()
- {
-
- }
-
- public bool HasRefreshMenu
- {
- get { return true; }
- }
-
- public void Refresh()
- {
-
- }
-
- public string WindowSettings
- {
- get
- {
- return Properties.Settings.Default.WindowSettings1;
- }
- set
- {
- Properties.Settings.Default.WindowSettings1 = value;
- Properties.Settings.Default.Save();
- }
+ Properties.Settings.Default.WindowSettings1 = value;
+ Properties.Settings.Default.Save();
}
}
-}
+}
\ No newline at end of file
diff --git a/TestWindow/WindowSource2.cs b/TestWindow/WindowSource2.cs
index b7b0a68..b95ecff 100644
--- a/TestWindow/WindowSource2.cs
+++ b/TestWindow/WindowSource2.cs
@@ -1,92 +1,88 @@
-using FloatingStatusWindowLibrary;
+using ChrisKaczor.Wpf.FloatingStatusWindow;
using System;
using System.Globalization;
using System.Reflection;
using System.Timers;
using System.Windows.Threading;
-namespace TestWindow
+namespace TestWindow;
+
+internal class WindowSource2 : IWindowSource, IDisposable
{
- internal class WindowSource2 : IWindowSource, IDisposable
+ private readonly FloatingStatusWindow _floatingStatusWindow;
+ private readonly Timer _timer;
+ private readonly Dispatcher _dispatcher;
+
+ internal WindowSource2()
{
- private readonly FloatingStatusWindow _floatingStatusWindow;
- private readonly Timer _timer;
- private readonly Dispatcher _dispatcher;
+ _floatingStatusWindow = new FloatingStatusWindow(this);
+ _floatingStatusWindow.SetText("Loading...");
- internal WindowSource2()
+ _dispatcher = Dispatcher.CurrentDispatcher;
+
+ _timer = new Timer(1000);
+ _timer.Elapsed += HandleTimerElapsed;
+ _timer.Enabled = true;
+ }
+
+ private void HandleTimerElapsed(object sender, ElapsedEventArgs e)
+ {
+ _dispatcher.InvokeAsync(() => _floatingStatusWindow.SetText(DateTime.Now.ToString(CultureInfo.InvariantCulture)));
+ }
+
+ public void Dispose()
+ {
+ _timer.Enabled = false;
+ _timer.Dispose();
+
+ _floatingStatusWindow.Save();
+ _floatingStatusWindow.Dispose();
+ }
+
+ public Guid Id => Guid.Parse("F42F92BC-D397-497A-8E01-E71D084BEDB6");
+
+ public string Name
+ {
+ get { return "Test Window 2"; }
+ }
+
+ public System.Drawing.Icon Icon
+ {
+ get { return Properties.Resources.ApplicationIcon; }
+ }
+
+ public bool HasSettingsMenu
+ {
+ get { return true; }
+ }
+
+ public bool HasAboutMenu => true;
+
+ public void ShowAbout()
+ {
+ _floatingStatusWindow.SetText(Assembly.GetEntryAssembly().GetName().Version.ToString());
+ }
+
+ public void ShowSettings()
+ {
+ }
+
+ public bool HasRefreshMenu
+ {
+ get { return true; }
+ }
+
+ public void Refresh()
+ {
+ }
+
+ public string WindowSettings
+ {
+ get { return Properties.Settings.Default.WindowSettings2; }
+ set
{
- _floatingStatusWindow = new FloatingStatusWindow(this);
- _floatingStatusWindow.SetText("Loading...");
-
- _dispatcher = Dispatcher.CurrentDispatcher;
-
- _timer = new Timer(1000);
- _timer.Elapsed += HandleTimerElapsed;
- _timer.Enabled = true;
- }
-
- private void HandleTimerElapsed(object sender, ElapsedEventArgs e)
- {
- _dispatcher.InvokeAsync(() => _floatingStatusWindow.SetText(DateTime.Now.ToString(CultureInfo.InvariantCulture)));
- }
-
- public void Dispose()
- {
- _timer.Enabled = false;
- _timer.Dispose();
-
- _floatingStatusWindow.Save();
- _floatingStatusWindow.Dispose();
- }
-
- public string Name
- {
- get { return "Test Window 2"; }
- }
-
- public System.Drawing.Icon Icon
- {
- get { return Properties.Resources.ApplicationIcon; }
- }
-
- public bool HasSettingsMenu
- {
- get { return true; }
- }
-
- public bool HasAboutMenu => true;
-
- public void ShowAbout()
- {
- _floatingStatusWindow.SetText(Assembly.GetEntryAssembly().GetName().Version.ToString());
- }
-
- public void ShowSettings()
- {
-
- }
-
- public bool HasRefreshMenu
- {
- get { return true; }
- }
-
- public void Refresh()
- {
-
- }
-
- public string WindowSettings
- {
- get
- {
- return Properties.Settings.Default.WindowSettings2;
- }
- set
- {
- Properties.Settings.Default.WindowSettings2 = value;
- Properties.Settings.Default.Save();
- }
+ Properties.Settings.Default.WindowSettings2 = value;
+ Properties.Settings.Default.Save();
}
}
-}
+}
\ No newline at end of file
diff --git a/TestWindow/WindowSource3.cs b/TestWindow/WindowSource3.cs
index 95a9d41..dca0d2d 100644
--- a/TestWindow/WindowSource3.cs
+++ b/TestWindow/WindowSource3.cs
@@ -1,92 +1,88 @@
-using FloatingStatusWindowLibrary;
+using ChrisKaczor.Wpf.FloatingStatusWindow;
using System;
using System.Globalization;
using System.Reflection;
using System.Timers;
using System.Windows.Threading;
-namespace TestWindow
+namespace TestWindow;
+
+internal class WindowSource3 : IWindowSource, IDisposable
{
- internal class WindowSource3 : IWindowSource, IDisposable
+ private readonly FloatingStatusWindow _floatingStatusWindow;
+ private readonly Timer _timer;
+ private readonly Dispatcher _dispatcher;
+
+ internal WindowSource3()
{
- private readonly FloatingStatusWindow _floatingStatusWindow;
- private readonly Timer _timer;
- private readonly Dispatcher _dispatcher;
+ _floatingStatusWindow = new FloatingStatusWindow(this);
+ _floatingStatusWindow.SetText("Loading...");
- internal WindowSource3()
+ _dispatcher = Dispatcher.CurrentDispatcher;
+
+ _timer = new Timer(1000);
+ _timer.Elapsed += HandleTimerElapsed;
+ _timer.Enabled = true;
+ }
+
+ private void HandleTimerElapsed(object sender, ElapsedEventArgs e)
+ {
+ _dispatcher.InvokeAsync(() => _floatingStatusWindow.SetText(DateTime.Now.ToString(CultureInfo.InvariantCulture)));
+ }
+
+ public void Dispose()
+ {
+ _timer.Enabled = false;
+ _timer.Dispose();
+
+ _floatingStatusWindow.Save();
+ _floatingStatusWindow.Dispose();
+ }
+
+ public Guid Id => Guid.Parse("CF7466DF-8980-452B-B2FA-290B26204BF2");
+
+ public string Name
+ {
+ get { return "Test Window 3"; }
+ }
+
+ public System.Drawing.Icon Icon
+ {
+ get { return Properties.Resources.ApplicationIcon; }
+ }
+
+ public bool HasSettingsMenu
+ {
+ get { return true; }
+ }
+
+ public bool HasAboutMenu => true;
+
+ public void ShowAbout()
+ {
+ _floatingStatusWindow.SetText(Assembly.GetEntryAssembly().GetName().Version.ToString());
+ }
+
+ public void ShowSettings()
+ {
+ }
+
+ public bool HasRefreshMenu
+ {
+ get { return true; }
+ }
+
+ public void Refresh()
+ {
+ }
+
+ public string WindowSettings
+ {
+ get { return Properties.Settings.Default.WindowSettings3; }
+ set
{
- _floatingStatusWindow = new FloatingStatusWindow(this);
- _floatingStatusWindow.SetText("Loading...");
-
- _dispatcher = Dispatcher.CurrentDispatcher;
-
- _timer = new Timer(1000);
- _timer.Elapsed += HandleTimerElapsed;
- _timer.Enabled = true;
- }
-
- private void HandleTimerElapsed(object sender, ElapsedEventArgs e)
- {
- _dispatcher.InvokeAsync(() => _floatingStatusWindow.SetText(DateTime.Now.ToString(CultureInfo.InvariantCulture)));
- }
-
- public void Dispose()
- {
- _timer.Enabled = false;
- _timer.Dispose();
-
- _floatingStatusWindow.Save();
- _floatingStatusWindow.Dispose();
- }
-
- public string Name
- {
- get { return "Test Window 3"; }
- }
-
- public System.Drawing.Icon Icon
- {
- get { return Properties.Resources.ApplicationIcon; }
- }
-
- public bool HasSettingsMenu
- {
- get { return true; }
- }
-
- public bool HasAboutMenu => true;
-
- public void ShowAbout()
- {
- _floatingStatusWindow.SetText(Assembly.GetEntryAssembly().GetName().Version.ToString());
- }
-
- public void ShowSettings()
- {
-
- }
-
- public bool HasRefreshMenu
- {
- get { return true; }
- }
-
- public void Refresh()
- {
-
- }
-
- public string WindowSettings
- {
- get
- {
- return Properties.Settings.Default.WindowSettings3;
- }
- set
- {
- Properties.Settings.Default.WindowSettings3 = value;
- Properties.Settings.Default.Save();
- }
+ Properties.Settings.Default.WindowSettings3 = value;
+ Properties.Settings.Default.Save();
}
}
-}
+}
\ No newline at end of file
diff --git a/TestWindow/WindowSource4.cs b/TestWindow/WindowSource4.cs
index 585dfc9..adc5d5e 100644
--- a/TestWindow/WindowSource4.cs
+++ b/TestWindow/WindowSource4.cs
@@ -1,92 +1,88 @@
-using FloatingStatusWindowLibrary;
+using ChrisKaczor.Wpf.FloatingStatusWindow;
using System;
using System.Globalization;
using System.Reflection;
using System.Timers;
using System.Windows.Threading;
-namespace TestWindow
+namespace TestWindow;
+
+internal class WindowSource4 : IWindowSource, IDisposable
{
- internal class WindowSource4 : IWindowSource, IDisposable
+ private readonly FloatingStatusWindow _floatingStatusWindow;
+ private readonly Timer _timer;
+ private readonly Dispatcher _dispatcher;
+
+ internal WindowSource4()
{
- private readonly FloatingStatusWindow _floatingStatusWindow;
- private readonly Timer _timer;
- private readonly Dispatcher _dispatcher;
+ _floatingStatusWindow = new FloatingStatusWindow(this);
+ _floatingStatusWindow.SetText("Loading...");
- internal WindowSource4()
+ _dispatcher = Dispatcher.CurrentDispatcher;
+
+ _timer = new Timer(1000);
+ _timer.Elapsed += HandleTimerElapsed;
+ _timer.Enabled = true;
+ }
+
+ private void HandleTimerElapsed(object sender, ElapsedEventArgs e)
+ {
+ _dispatcher.InvokeAsync(() => _floatingStatusWindow.SetText(DateTime.Now.ToString(CultureInfo.InvariantCulture)));
+ }
+
+ public void Dispose()
+ {
+ _timer.Enabled = false;
+ _timer.Dispose();
+
+ _floatingStatusWindow.Save();
+ _floatingStatusWindow.Dispose();
+ }
+
+ public Guid Id => Guid.Parse("0DD89F7E-3AD4-4226-8CBD-B75C8EBEEF32");
+
+ public string Name
+ {
+ get { return "Test Window 4"; }
+ }
+
+ public System.Drawing.Icon Icon
+ {
+ get { return Properties.Resources.ApplicationIcon; }
+ }
+
+ public bool HasSettingsMenu
+ {
+ get { return true; }
+ }
+
+ public bool HasAboutMenu => true;
+
+ public void ShowAbout()
+ {
+ _floatingStatusWindow.SetText(Assembly.GetEntryAssembly().GetName().Version.ToString());
+ }
+
+ public void ShowSettings()
+ {
+ }
+
+ public bool HasRefreshMenu
+ {
+ get { return true; }
+ }
+
+ public void Refresh()
+ {
+ }
+
+ public string WindowSettings
+ {
+ get { return Properties.Settings.Default.WindowSettings4; }
+ set
{
- _floatingStatusWindow = new FloatingStatusWindow(this);
- _floatingStatusWindow.SetText("Loading...");
-
- _dispatcher = Dispatcher.CurrentDispatcher;
-
- _timer = new Timer(1000);
- _timer.Elapsed += HandleTimerElapsed;
- _timer.Enabled = true;
- }
-
- private void HandleTimerElapsed(object sender, ElapsedEventArgs e)
- {
- _dispatcher.InvokeAsync(() => _floatingStatusWindow.SetText(DateTime.Now.ToString(CultureInfo.InvariantCulture)));
- }
-
- public void Dispose()
- {
- _timer.Enabled = false;
- _timer.Dispose();
-
- _floatingStatusWindow.Save();
- _floatingStatusWindow.Dispose();
- }
-
- public string Name
- {
- get { return "Test Window 4"; }
- }
-
- public System.Drawing.Icon Icon
- {
- get { return Properties.Resources.ApplicationIcon; }
- }
-
- public bool HasSettingsMenu
- {
- get { return true; }
- }
-
- public bool HasAboutMenu => true;
-
- public void ShowAbout()
- {
- _floatingStatusWindow.SetText(Assembly.GetEntryAssembly().GetName().Version.ToString());
- }
-
- public void ShowSettings()
- {
-
- }
-
- public bool HasRefreshMenu
- {
- get { return true; }
- }
-
- public void Refresh()
- {
-
- }
-
- public string WindowSettings
- {
- get
- {
- return Properties.Settings.Default.WindowSettings4;
- }
- set
- {
- Properties.Settings.Default.WindowSettings4 = value;
- Properties.Settings.Default.Save();
- }
+ Properties.Settings.Default.WindowSettings4 = value;
+ Properties.Settings.Default.Save();
}
}
-}
+}
\ No newline at end of file
diff --git a/appveyor.yml b/appveyor.yml
deleted file mode 100644
index 311f8bd..0000000
--- a/appveyor.yml
+++ /dev/null
@@ -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
\ No newline at end of file
diff --git a/azure-pipelines.yml b/azure-pipelines.yml
new file mode 100644
index 0000000..9a1959b
--- /dev/null
+++ b/azure-pipelines.yml
@@ -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: 'FloatingStatusWindow.csproj'
+
+- task: DotNetCoreCLI@2
+ displayName: "dotnet pack"
+ inputs:
+ command: 'pack'
+ arguments: '--configuration $(buildConfiguration)'
+ packagesToPack: '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
\ No newline at end of file