Windowing

This commit is contained in:
2025-03-24 12:33:38 -04:00
parent f1f3cd2859
commit e20cc09a60
11 changed files with 228 additions and 217 deletions

View File

@@ -28,7 +28,83 @@
</Setter>
</Style>-->
<ControlTemplate x:Key="Button9xTemplate" TargetType="{x:Type Button}">
<DockPanel LastChildFill="True">
<Border x:Name="OuterRightBorder" DockPanel.Dock="Right" Background="#000000" Width="1" />
<Border x:Name="OuterBottomBorder" DockPanel.Dock="Bottom" Background="#000000" Height="1" />
<Border x:Name="OuterLeftBorder" DockPanel.Dock="Left" Background="#FFFFFF" Width="1" />
<Border x:Name="OuterTopBorder" DockPanel.Dock="Top" Background="#FFFFFF" Height="1" />
<!-- This child DockPanel needs to have Background set or the button is clickable on the text itself :shrug: -->
<DockPanel Background="{StaticResource Gray}" LastChildFill="True">
<Border x:Name="InnerRightBorder" DockPanel.Dock="Right" Background="{StaticResource MediumGray}" Width="1" />
<Border x:Name="InnerBottomBorder" DockPanel.Dock="Bottom" Background="{StaticResource MediumGray}" Height="1" />
<Border x:Name="InnerLeftBorder" DockPanel.Dock="Left" Background="{StaticResource LightGray}" Width="1" />
<Border x:Name="InnerTopBorder" DockPanel.Dock="Top" Background="{StaticResource LightGray}" Height="1" />
<ContentPresenter x:Name="ContentPresenter" HorizontalAlignment="Center" VerticalAlignment="Center" />
</DockPanel>
</DockPanel>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseCaptured" Value="True">
<Setter TargetName="OuterRightBorder" Property="Background" Value="#000000" />
<Setter TargetName="OuterBottomBorder" Property="Background" Value="#000000" />
<Setter TargetName="OuterLeftBorder" Property="Background" Value="#000000" />
<Setter TargetName="OuterTopBorder" Property="Background" Value="#000000" />
<Setter TargetName="InnerRightBorder" Property="Background" Value="{StaticResource MediumGray}" />
<Setter TargetName="InnerBottomBorder" Property="Background" Value="{StaticResource MediumGray}" />
<Setter TargetName="InnerLeftBorder" Property="Background" Value="{StaticResource MediumGray}" />
<Setter TargetName="InnerTopBorder" Property="Background" Value="{StaticResource MediumGray}" />
<Setter TargetName="ContentPresenter" Property="Margin" Value="1,1,0,0" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
<ControlTemplate x:Key="Window9xTemplate" TargetType="Window">
<DockPanel LastChildFill="True" Background="{StaticResource Gray}" Width="{TemplateBinding Width}" Height="{TemplateBinding Height}">
<Border DockPanel.Dock="Right" Background="#000000" Width="1" />
<Border DockPanel.Dock="Bottom" Background="#000000" Height="1" />
<Border DockPanel.Dock="Left" Background="{StaticResource LightGray}" Width="1" />
<Border DockPanel.Dock="Top" Background="{StaticResource LightGray}" Height="1" />
<DockPanel LastChildFill="True">
<Border DockPanel.Dock="Right" Background="{StaticResource MediumGray}" Width="1" />
<Border DockPanel.Dock="Bottom" Background="{StaticResource MediumGray}" Height="1" />
<Border DockPanel.Dock="Left" Background="#FFFFFF" Width="1" />
<Border DockPanel.Dock="Top" Background="#FFFFFF" Height="1" />
<Grid Margin="2">
<Grid.RowDefinitions>
<RowDefinition Height="24" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<DockPanel x:Name="Titlebar" LastChildFill="True" MouseDown="TitlebarMouseDown">
<DockPanel.Background>
<LinearGradientBrush StartPoint="0,0" EndPoint="1,0">
<GradientStop Color="{StaticResource ColorBlue}" Offset="0.0" />
<GradientStop Color="{StaticResource ColorLightBlue}" Offset="1.0" />
</LinearGradientBrush>
</DockPanel.Background>
<Image Source="../icons/envelope.ico" Width="16" Height="16" Margin="4,0" DockPanel.Dock="Left"/>
<Button x:Name="CloseButton" Template="{StaticResource Button9xTemplate}" DockPanel.Dock="Right" Width="19" Height="18" Margin="4,0" Click="CloseButtonClick">X</Button>
<TextBlock x:Name="TitlebarText" Foreground="#FFFFFF" FontWeight="Bold" Padding="0,3" Text="{TemplateBinding Title}"></TextBlock>
</DockPanel>
<ContentPresenter Grid.Row="1" />
</Grid>
</DockPanel>
</DockPanel>
</ControlTemplate>
<Style x:Key="Window9x" TargetType="Window">
<Setter Property="WindowStyle" Value="None" />
<Setter Property="ResizeMode" Value="CanMinimize" />
</Style>
<Style x:Key="ToolWindow9x" TargetType="Window" BasedOn="{StaticResource Window9x}">
<Setter Property="ShowInTaskbar" Value="False" />
<Setter Property="ResizeMode" Value="NoResize" />
</Style>
<Style x:Key="MenuSeparator" TargetType="{x:Type Separator}">
<Setter Property="Template">

View File

@@ -1,6 +1,7 @@
using System.Configuration;
using System.Data;
using System.Windows;
using System.Windows.Controls;
namespace ServiceBus98;
@@ -9,5 +10,19 @@ namespace ServiceBus98;
/// </summary>
public partial class App : Application
{
private void TitlebarMouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
Window parent = Window.GetWindow((DockPanel)sender);
if (e.ChangedButton == System.Windows.Input.MouseButton.Left)
{
parent.DragMove();
}
}
private void CloseButtonClick(object sender, RoutedEventArgs e)
{
Window parent = Window.GetWindow((Button)sender);
parent.Close();
}
}

View File

@@ -1,20 +0,0 @@
<UserControl x:Class="ServiceBus98.Controls.Titlebar9x"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:controls="clr-namespace:ServiceBus98.Controls"
mc:Ignorable="d">
<DockPanel LastChildFill="True" MouseDown="DockPanel_MouseDown">
<DockPanel.Background>
<LinearGradientBrush StartPoint="0,0" EndPoint="1,0">
<GradientStop Color="{StaticResource ColorBlue}" Offset="0.0" />
<GradientStop Color="{StaticResource ColorLightBlue}" Offset="1.0" />
</LinearGradientBrush>
</DockPanel.Background>
<Image Source="../icons/envelope.ico" Width="16" Height="16" Margin="4,0" DockPanel.Dock="Left"/>
<controls:Button9x Click="Button9x_Click" DockPanel.Dock="Right" Width="19" Height="18" Margin="4,0">X</controls:Button9x>
<TextBlock x:Name="TitlebarText" Foreground="#FFFFFF" FontWeight="Bold" Padding="0,3"></TextBlock>
</DockPanel>
</UserControl>

View File

@@ -1,31 +0,0 @@
using System.Windows;
using System.Windows.Controls;
namespace ServiceBus98.Controls
{
/// <summary>
/// Interaction logic for Titlebar9x.xaml
/// </summary>
public partial class Titlebar9x : UserControl
{
public Titlebar9x()
{
InitializeComponent();
//MessageBox.Show();
TitlebarText.Text = Application.Current.MainWindow.Title;
}
private void DockPanel_MouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
if (e.ChangedButton == System.Windows.Input.MouseButton.Left)
{
Application.Current.MainWindow.DragMove();
}
}
private void Button9x_Click(object sender, EventArgs e)
{
Application.Current.Shutdown();
}
}
}

View File

@@ -1,40 +0,0 @@
<UserControl x:Class="ServiceBus98.Controls.Window9x"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:controls="clr-namespace:ServiceBus98.Controls"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<UserControl.Template>
<ControlTemplate TargetType="UserControl">
<DockPanel LastChildFill="True">
<Border DockPanel.Dock="Right" Background="#000000" Width="1" />
<Border DockPanel.Dock="Bottom" Background="#000000" Height="1" />
<Border DockPanel.Dock="Left" Background="{StaticResource LightGray}" Width="1" />
<Border DockPanel.Dock="Top" Background="{StaticResource LightGray}" Height="1" />
<DockPanel LastChildFill="True">
<Border DockPanel.Dock="Right" Background="{StaticResource MediumGray}" Width="1" />
<Border DockPanel.Dock="Bottom" Background="{StaticResource MediumGray}" Height="1" />
<Border DockPanel.Dock="Left" Background="#FFFFFF" Width="1" />
<Border DockPanel.Dock="Top" Background="#FFFFFF" Height="1" />
<Grid Margin="2">
<Grid.RowDefinitions>
<RowDefinition Height="24" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<controls:Titlebar9x Grid.Row="0"></controls:Titlebar9x>
<ContentPresenter Grid.Row="1" />
</Grid>
</DockPanel>
</DockPanel>
</ControlTemplate>
</UserControl.Template>
</UserControl>

View File

@@ -1,28 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace ServiceBus98.Controls
{
/// <summary>
/// Interaction logic for Window9x.xaml
/// </summary>
public partial class Window9x : UserControl
{
public Window9x()
{
InitializeComponent();
}
}
}

View File

@@ -8,8 +8,8 @@
Title="Service Bus 98" Height="600" Width="800"
Background="{StaticResource Gray}"
WindowStartupLocation="CenterScreen"
ResizeMode="NoResize"
WindowStyle="None"
Template="{StaticResource Window9xTemplate}"
Style="{StaticResource Window9x}"
>
<Window.CommandBindings>
@@ -143,9 +143,6 @@
</Window.Resources>
<!-- the real app and real menu -->
<controls:Window9x>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="27" />
@@ -171,7 +168,7 @@
<MenuItem Header="_Help" Template="{StaticResource TopMenuItem}">
<MenuItem Header="_Help Topics" Template="{StaticResource NestedMenuItem}" Command="ApplicationCommands.Help" />
<Separator Style="{StaticResource MenuSeparator}"/>
<MenuItem Header="_About Service Bus 98" Template="{StaticResource NestedMenuItem}" />
<MenuItem Header="_About Service Bus 98" Template="{StaticResource NestedMenuItem}" Click="HelpAboutClick" />
</MenuItem>
</Menu>
@@ -238,6 +235,4 @@
</StatusBar>
</Grid>
</controls:Window9x>
</Window>

View File

@@ -48,6 +48,12 @@ public partial class MainWindow : Window
MessageBox.Show("Open git.ratermania.net");
}
private void HelpAboutClick(object sender, RoutedEventArgs e)
{
AboutWindow aboutWindow = new AboutWindow();
aboutWindow.ShowDialog();
}
/*
private async void Send_Click(object sender, RoutedEventArgs e)
{

View File

@@ -1,17 +0,0 @@
<Window x:Class="ServiceBus98.About"
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:local="clr-namespace:ServiceBus98"
mc:Ignorable="d"
Title="About" Height="450" Width="800">
<StackPanel>
<TextBlock Text="Service Bus 98" Style="{StaticResource Header}">
<TextBlock.Effect>
<DropShadowEffect ShadowDepth="2" Direction="315" Color="Black" Opacity="1" BlurRadius="0"/>
</TextBlock.Effect>
</TextBlock>
</StackPanel>
</Window>

View File

@@ -0,0 +1,45 @@
<Window x:Class="ServiceBus98.AboutWindow"
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:local="clr-namespace:ServiceBus98"
xmlns:controls="clr-namespace:ServiceBus98.Controls"
mc:Ignorable="d"
Title="About Service Bus 98"
Width="360"
Height="240"
WindowStartupLocation="CenterScreen"
Template="{StaticResource Window9xTemplate}"
Style="{StaticResource ToolWindow9x}">
<Window.Resources>
<Style x:Key="Header" TargetType="{x:Type TextBlock}">
<Setter Property="Foreground" Value="Teal" />
<Setter Property="FontSize" Value="24" />
<Setter Property="FontWeight" Value="Bold" />
<Setter Property="FontStyle" Value="Italic" />
<Setter Property="FontFamily" Value="Comic Sans MS" />
<Setter Property="Margin" Value="0" />
</Style>
</Window.Resources>
<Window.CommandBindings>
<CommandBinding Command="ApplicationCommands.Close" CanExecute="CloseCanExecute" Executed="CloseExecuted" />
</Window.CommandBindings>
<StackPanel>
<TextBlock Style="{StaticResource Header}" Text="Service Bus 98">
<!--<TextBlock.RenderTransform>
<RotateTransform Angle="270" />
</TextBlock.RenderTransform>-->
<TextBlock.Effect>
<DropShadowEffect ShadowDepth="2" Direction="315" Color="Black" Opacity="1" BlurRadius="0"/>
</TextBlock.Effect>
</TextBlock>
<TextBlock>Copyright (C) 1998-2025 Tommy</TextBlock>
<Button Command="ApplicationCommands.Close">OK</Button>
</StackPanel>
</Window>

View File

@@ -17,11 +17,21 @@ namespace ServiceBus98
/// <summary>
/// Interaction logic for About.xaml
/// </summary>
public partial class About : Window
public partial class AboutWindow : Window
{
public About()
public AboutWindow()
{
InitializeComponent();
}
private void CloseCanExecute(object sender, CanExecuteRoutedEventArgs e)
{
e.CanExecute = true;
}
private void CloseExecuted(object sender, ExecutedRoutedEventArgs e)
{
this.Close();
}
}
}