Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update to dotnet7 #29

Merged
merged 1 commit into from
Nov 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions VMPlex/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,10 @@ private void LoadUserSettings()
}
catch (Exception exc)
{
MessageBox.Show(
$"Failed to load settings file \"{UserSettings.Instance.UserSettingsFile}\"\n{exc.Message}",
"VMPlex Fatal Settings Error",
MessageBoxButton.OK,
MessageBoxImage.Error);
UI.MessageBox.Show(
MessageBoxImage.Error,
"VMPlex Fatal Settings Error",
$"Failed to load settings file \"{UserSettings.Instance.UserSettingsFile}\"\n{exc.Message}");
//
// Unable to parse settings. Error already displayed. Quietly exit.
//
Expand Down
4 changes: 2 additions & 2 deletions VMPlex/Properties/PublishProfiles/FolderProfile.pubxml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
<PublishDir>..\bin\Publish\</PublishDir>
<PublishProtocol>FileSystem</PublishProtocol>
<DeleteExistingFiles>true</DeleteExistingFiles>
<TargetFramework>net6.0-windows10.0.19041</TargetFramework>
<TargetFramework>net7.0-windows</TargetFramework>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<SelfContained>true</SelfContained>
<PublishSingleFile>true</PublishSingleFile>
<PublishReadyToRun>true</PublishReadyToRun>
<PublishReadyToRun>false</PublishReadyToRun>
<!--
Windows Forms is not supported or recommended with trimming enabled.
Please go to https://aka.ms/dotnet-illink/windows-forms for more details.
Expand Down
40 changes: 28 additions & 12 deletions VMPlex/UI/AboutWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
Width="440"
ShowInTaskbar="False"
ResizeMode="NoResize"
WindowStartupLocation="CenterOwner"
ui:ThemeManager.IsThemeAware="True"
ui:WindowHelper.UseModernWindowStyle="True">
<Grid Background="{DynamicResource SystemControlPageBackgroundAltHighBrush}">
Expand Down Expand Up @@ -74,18 +75,6 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.


ModernWpf.MessageBox
MIT License

Copyright (c) OpenByte &lt;development.openbyte@gmail.com&gt;

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


ORMi
Expand All @@ -110,6 +99,33 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.


Devolutions.MsRdpEx
MIT License
Permission is hereby granted, free of charge, to any
person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the
Software without restriction, including without
limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software
is furnished to do so, subject to the following
conditions:

The above copyright notice and this permission notice
shall be included in all copies or substantial portions
of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
</TextBox>
</Grid>
</Window>
1 change: 1 addition & 0 deletions VMPlex/UI/MainPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800"
Title="MainPage">

<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
Expand Down
12 changes: 9 additions & 3 deletions VMPlex/UI/ManagerPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
* Copyright (c) 2022 Ira Strawser. All rights reserved.
*/

using ABI.Windows.ApplicationModel.Activation;
using System;
using System.Collections.Generic;
using System.Text;
Expand Down Expand Up @@ -270,10 +269,17 @@ private void OnDeleteCommand(object sender, RoutedEventArgs e)
}
if (vm.State != WMI.Msvm_ComputerSystem.SystemState.Off)
{
Utility.ErrorPopup("Virtual Machine must be off.");
UI.MessageBox.Show(
MessageBoxImage.Information,
"Virtual Machine must be off.");
return;
}
MessageBoxResult? res = ModernWpf.MessageBox.Show("Are you sure you want to delete " + vm.Name + "?", "Delete VM", MessageBoxButton.YesNo);
var res = UI.MessageBox.Show(
MessageBoxImage.Question,
$"Are you sure you want to delete {vm.Name}?",
"Deleting the virtual machine will remove it from the server. " +
"This can not be undone.",
MessageBoxButton.YesNo);
if (res == MessageBoxResult.Yes)
{
TabControl tc = (TabControl)(((TabItem)this.Parent).Parent);
Expand Down
142 changes: 142 additions & 0 deletions VMPlex/UI/MessageBox.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
/*
* Copyright (c) 2022 Johnny Shaw. All rights reserved.
*/

using System.Windows;
using ModernWpf.Controls;
using System.Windows.Media;
using System.Windows.Forms.Design;
using System.Linq;

namespace VMPlex.UI
{

public static class MessageBox
{
public static MessageBoxResult Show(string Text)
{
return ShowInternal(null, null, Text, null);
}

public static MessageBoxResult Show(string Caption, string Text)
{
return ShowInternal(null, Caption, Text, null);
}

public static MessageBoxResult Show(
string Text,
MessageBoxButton Button
)
{
return ShowInternal(null, null, Text, Button);
}

public static MessageBoxResult Show(
MessageBoxImage Image,
string Caption
)
{
return ShowInternal(Image, Caption, null, null);
}

public static MessageBoxResult Show(
MessageBoxImage Image,
string Caption,
string Text
)
{
return ShowInternal(Image, Caption, Text, null);
}

public static MessageBoxResult Show(
MessageBoxImage Image,
string Caption,
MessageBoxButton Button
)
{
return ShowInternal(Image, Caption, null, Button);
}

public static MessageBoxResult Show(
MessageBoxImage Image,
string Caption,
string Text,
MessageBoxButton Button
)
{
return ShowInternal(Image, Caption, Text, Button);
}

#nullable enable
private static MessageBoxResult ShowInternal(
MessageBoxImage? Image,
string? Caption,
string? Text,
MessageBoxButton? Button
)
#nullable restore
{
string symbolFont = null;
string symbolGlyph = null;

if (Image != null)
{
switch (Image)
{
case MessageBoxImage.Error:
{
symbolFont = "Segoe MDL2 Assets";
symbolGlyph = "\uEA39";
break;
}
case MessageBoxImage.Question:
{
symbolFont = "Segoe MDL2 Assets";
symbolGlyph = "\uF142";
break;
}
case MessageBoxImage.Warning:
{
symbolFont = "Segoe MDL2 Assets";
symbolGlyph = "\uE7BA";
break;
}
case MessageBoxImage.Information:
{
symbolFont = "Segoe MDL2 Assets";
symbolGlyph = "\uE946";
break;
}
}
}

return Application.Current.Dispatcher.Invoke(() =>
{
var window = new MessageBoxWindow(
symbolFont,
symbolGlyph,
Caption,
Text,
Button ?? MessageBoxButton.OK);

window.ShowInTaskbar = true;
window.WindowStartupLocation = WindowStartupLocation.CenterScreen;

foreach (Window owner in Application.Current.Windows)
{
if (owner.IsActive && owner.IsMouseOver)
{
window.Owner = owner;
window.ShowInTaskbar = false;
window.WindowStartupLocation = WindowStartupLocation.CenterOwner;
break;
}
}

window.ShowDialog();

return window.Result;
});
}
}
}
29 changes: 29 additions & 0 deletions VMPlex/UI/MessageBoxWindow.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<Window x:Class="VMPlex.UI.MessageBoxWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:ui="http://schemas.modernwpf.com/2019"
xmlns:local="clr-namespace:VMPlex.UI"
mc:Ignorable="d"
Title="VMPlex Workstation"
ResizeMode="NoResize"
SizeToContent="WidthAndHeight"
ui:ThemeManager.IsThemeAware="True"
ui:WindowHelper.UseModernWindowStyle="True">
<ui:SimpleStackPanel Orientation="Vertical" Margin="12 10 12 10" Spacing="20">
<ui:SimpleStackPanel Orientation="Horizontal" Spacing="12" Margin="0 0 12 0" >
<ui:FontIcon x:Name="SymbolIcon" Visibility="Collapsed" FontSize="35" VerticalAlignment="Top" />
<ui:SimpleStackPanel Orientation="Vertical" Spacing="14" Margin="0 5 0 0" >
<TextBlock x:Name="MessageBoxCaption" Visibility="Collapsed" TextWrapping="Wrap" VerticalAlignment="Center" Height="Auto" MaxWidth="350" FontSize="18" />
<TextBlock x:Name="MessageBoxText" Visibility="Collapsed" TextWrapping="Wrap" VerticalAlignment="Center" Height="Auto" MaxWidth="350" FontSize="12" />
</ui:SimpleStackPanel>
</ui:SimpleStackPanel>
<ui:SimpleStackPanel Orientation="Horizontal" Spacing="10" HorizontalAlignment="Right">
<Button x:Name="ButtonOk" Content="_Ok" Click="ButtonOk_Click" MinWidth="75" Visibility="Collapsed" Padding="12 6 12 6" />
<Button x:Name="ButtonYes" Content="_Yes" Click="ButtonYes_Click" MinWidth="75" Visibility="Collapsed" Padding="12 6 12 6" />
<Button x:Name="ButtonNo" Content="_No" Click="ButtonNo_Click" MinWidth="75" Visibility="Collapsed" Padding="12 6 12 6" />
<Button x:Name="ButtonCancel" Content="Cancel" Click="ButtonCancel_Click" MinWidth="75" Visibility="Collapsed" Padding="12 6 12 6" />
</ui:SimpleStackPanel>
</ui:SimpleStackPanel>
</Window>
Loading