Skip to content

Commit

Permalink
v2.0.0!
Browse files Browse the repository at this point in the history
  • Loading branch information
lingrottin committed Oct 2, 2024
1 parent f23a6d3 commit 12d6ee5
Show file tree
Hide file tree
Showing 14 changed files with 1,198 additions and 743 deletions.
2 changes: 1 addition & 1 deletion MapTP.App/AboutWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</WindowChrome.WindowChrome>
<StackPanel Height="450" Margin="20">
<TextBlock HorizontalAlignment="Left" Margin="5" Text="About MapTP" Style="{StaticResource TextBlockTitleBold}"/>
<TextBlock HorizontalAlignment="Left" Margin="5" Text="MapTP v1.0.0 © Lingrottin 2023, some rights reserved" Style="{StaticResource TextBlockDefault}"/>
<TextBlock HorizontalAlignment="Left" Margin="5" Text="MapTP v2.0.0 © Lingrottin 2023-2024, some rights reserved" Style="{StaticResource TextBlockDefault}"/>
<TextBlock HorizontalAlignment="Left" Margin="5" Text="Hugely inspired by emoacht/RawInput.Touchpad" Style="{StaticResource TextBlockDefaultPrimary}"/>
<TextBlock HorizontalAlignment="Left" Margin="5" Text="The program is open sourced under MIT license." Style="{StaticResource TextBlockDefault}" TextWrapping="Wrap"/>
<TextBlock HorizontalAlignment="Left" Margin="5" Style="{StaticResource TextBlockDefault}" TextWrapping="Wrap">
Expand Down
2 changes: 1 addition & 1 deletion MapTP.App/AdvancedWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:MapTP.App"
mc:Ignorable="d"
Title="AdvancedWindow" MinHeight="300" Width="430">
Title="MapTP - Log Window" Height="200" MinHeight="200" Width="430">
<Grid Margin="10,10,10,10">
<Grid.RowDefinitions>
<RowDefinition/>
Expand Down
Binary file added MapTP.App/Assets/logo-inactive.ico
Binary file not shown.
2 changes: 1 addition & 1 deletion MapTP.App/BlurManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ private void OnIsEnabledChanged(bool isEnabled)
private void Composite(IntPtr handle, bool isEnabled)
{
// 操作系统版本判定。
var osVersion = Environment.OSVersion.Version;
var osVersion = OSVersionExtension.OSVersion.GetOSVersion().Version;
var windows10_1809 = new Version(10, 0, 17763);
var windows10 = new Version(10, 0);
var windows11_buildver = 22000;
Expand Down
40 changes: 40 additions & 0 deletions MapTP.App/InspectorWindow.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<Window x:Class="MapTP.App.InspectorWindow"
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:MapTP.App"
mc:Ignorable="d"
Title="InspectorWindow" Height="450" Width="800" WindowStyle="None"
AllowsTransparency="True"
Topmost="True" ShowInTaskbar="False"
Background="#00ffffff">
<WindowChrome.WindowChrome>
<WindowChrome ResizeBorderThickness="5" x:Name="WindowChrome"></WindowChrome>
</WindowChrome.WindowChrome>
<Border Background="Transparent" BorderThickness="2" BorderBrush="AliceBlue" x:Name="MainBorder">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="30"></RowDefinition>
</Grid.RowDefinitions>
<Grid Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="6*"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Button x:Name="StartButton" Grid.Column="0" BorderBrush="Transparent" Background="Transparent" Foreground="White" Click="StartButtonClick">Start</Button>
<Button x:Name="StopButton" Grid.Column="0" BorderBrush="Transparent" Background="DarkRed" Foreground="White" Click="StopButtonClick" Visibility="Collapsed">Stop</Button>
<Border x:Name="TitleBar" Grid.Column="2" BorderThickness="0" Background="#33ffffff" MouseLeftButtonDown="OnTitleBarMouseDown">
<Label Background="Transparent" BorderBrush="Transparent" Foreground="White">Drag here to move</Label>
</Border>
<Grid x:Name="CloseGrid" Grid.Column="3" Background="#33112255"
MouseEnter="CloseGrid_MouseEnter" MouseLeave="CloseGrid_MouseLeave" MouseLeftButtonUp="CloseGrid_Click">
<Label Background="Transparent" BorderBrush="Transparent" Foreground="White" Margin="0,5,0,5" Width="Auto">Close</Label>
</Grid>
</Grid>
</Grid>
</Border>
</Window>
120 changes: 120 additions & 0 deletions MapTP.App/InspectorWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
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.Shapes;
using Windows.Graphics.Printing3D;

namespace MapTP.App
{
/// <summary>
/// InspectorWindow.xaml 的交互逻辑
/// </summary>
public partial class InspectorWindow : Window
{
private int width;
private int height;
private double DpiRatio;
public delegate void _SendScreenArea(int X, int Y, int eX, int eY);
public _SendScreenArea SendScreenArea;

public delegate void _TriggerEvent(object sender, RoutedEventArgs e);
public _TriggerEvent MainWindow_Stop;
public _TriggerEvent MainWindow_Start;
public _TriggerEvent MainWindow_Turtle;

private readonly int X,Y, eX, eY;

public InspectorWindow(int X, int Y, int eX, int eY)
{
InitializeComponent();
this.X= X;
this.Y= Y;
this.eX= eX;
this.eY= eY;
}

protected override void OnSourceInitialized(EventArgs e)
{
base.OnSourceInitialized(e);
this.LocationChanged+= OnTransformChanged;
this.SizeChanged += OnTransformChanged;
this.DpiRatio=ScreenManager.GetDpiRatio(this);
this.Loaded += OnLoaded;
}

private void OnLoaded(object sender, EventArgs e)
{
this.Top = X / DpiRatio;
this.Left = Y / DpiRatio;
this.Width = eX / DpiRatio - X / DpiRatio;
this.Height = eY / DpiRatio - Y / DpiRatio;
}

private void OnTransformChanged(object sender, EventArgs e)
{
this.width = (int)this.ActualWidth;
this.height = (int)this.ActualHeight;
var x = (int)(this.Left * DpiRatio);
var y = (int)(this.Top * DpiRatio);
var ex = (int)((this.Left + this.width) * DpiRatio);
var ey = (int)((this.Top + this.height) * DpiRatio);
if (x >= 0 && y >= 0 && ex <= ScreenManager.GetScreenWidth() && ey <= ScreenManager.GetScreenHeight()) {
TitleBar.Background = new SolidColorBrush(Color.FromArgb(0x33,0xff,0xff,0xff));
SendScreenArea(x, y, ex, ey);
}
else {
TitleBar.Background = new SolidColorBrush(Color.FromArgb(0x33,0xff,0x00,0x00));
}
}

private void OnTitleBarMouseDown(object sender, RoutedEventArgs e)
{
this.DragMove();
}

private void CloseGrid_MouseEnter(object sender, RoutedEventArgs e)
{
CloseGrid.Background = new SolidColorBrush(Color.FromRgb(255, 0, 0));
}

private void CloseGrid_MouseLeave(object sender, RoutedEventArgs e)
{
CloseGrid.Background = new SolidColorBrush(Color.FromArgb(0x33, 0x11, 0x22, 0x55));
}

private void CloseGrid_Click(object sender, RoutedEventArgs e)
{
this.Close();
}

private void StartButtonClick(object sender, RoutedEventArgs e)
{
if (MainWindow_Start != null)
{
MainWindow_Start(sender, e);
}
this.StopButton.Visibility=Visibility.Visible;
this.StartButton.Visibility=Visibility.Collapsed;
}

private void StopButtonClick(object sender, RoutedEventArgs e)
{
if (MainWindow_Stop != null)
{
MainWindow_Stop(sender, e);
}
this.StopButton.Visibility=Visibility.Collapsed;
this.StartButton.Visibility=Visibility.Visible;
}

}
}
58 changes: 44 additions & 14 deletions MapTP.App/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@
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:MapTP.App"
xmlns:local="clr-namespace:MapTP.App" xmlns:tray="http://schemas.lepo.co/wpfui/2022/xaml/tray"
mc:Ignorable="d"
Title="MapTP" Height="500" Width="800"
Title="MapTP" Height="552" Width="800"
Foreground="{DynamicResource SystemControlPageTextBaseHighBrush}"
WindowStyle="None"
Background="#33aaaaff">
Background="#33ff4444">
<WindowChrome.WindowChrome>
<WindowChrome x:Name="WindowChrome" GlassFrameThickness="0,0,-1,0"/>
</WindowChrome.WindowChrome>

<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
Expand All @@ -26,15 +27,8 @@
<TextBlock Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Left" Foreground="Black" Margin="20,0,0,0" Style="{StaticResource TextBlockDefault}">MapTP</TextBlock>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Center" Grid.Column="1" Margin="0,5,20,0">
<Grid HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,0,10,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Button x:Name="Advanced" VerticalAlignment="Bottom" Foreground="Black" BorderBrush="Transparent" Background="{x:Null}" Style="{StaticResource ButtonDefault}" Content="Advanced" Click="AdvancedButtonClick"/>
<Button x:Name="About" Grid.Column="1" VerticalAlignment="Bottom" Foreground="Black" BorderBrush="Transparent" Background="{x:Null}" Style="{StaticResource ButtonDefault}" Content="About" Click="AboutButtonClick"/>
<Button x:Name="StartButton" Grid.Column="2" Foreground="Black" BorderBrush="Transparent" Background="{x:Null}" HorizontalAlignment="Right" Margin="10,0,0,0" Style="{StaticResource ButtonPrimary}" Content="Start Mapping" Click="StartButtonClick" Width="150"/>
<Button x:Name="StopButton" Visibility="Collapsed" Grid.Column="2" HorizontalAlignment="Right" Margin="10,0,0,0" Style="{StaticResource ButtonDanger}" Content="Stop Mapping" Click="StopButtonClick" Width="150"/>
<Button x:Name="StartButton" Grid.Column="1" Foreground="Black" Background="LightPink" BorderBrush="Black" HorizontalAlignment="Right" Margin="10,0,0,0" Style="{StaticResource ButtonPrimary}" Content="Start Mapping" Click="StartButtonClick" Width="150"/>
<Button x:Name="StopButton" Visibility="Collapsed" Grid.Column="1" HorizontalAlignment="Right" Margin="10,0,0,0" Style="{StaticResource ButtonDanger}" Content="Stop Mapping" Click="StopButtonClick" Width="150"/>
</Grid>
<Button Style="{StaticResource ButtonIcon}" Foreground="Black" Click="OnMinButtonClick" hc:IconElement.Geometry="{StaticResource WindowMinGeometry}"/>
<Button Style="{StaticResource ButtonIcon}" Foreground="Black" Click="OnCloseButtonClick" hc:IconElement.Geometry="{StaticResource CloseGeometry}"/>
Expand All @@ -60,7 +54,7 @@
</Grid.ColumnDefinitions>
<Grid x:Name="TpRectGrid" Height="100" Width="150" Grid.Column="0">
<Rectangle x:Name="TpAreaRect" Height="100" Width="150" Stroke="Gray"></Rectangle>
<Rectangle x:Name="TpMapareaRect" VerticalAlignment="Top" HorizontalAlignment="Left" Fill="#5500BFF4" Stroke="#FF00BFF4" ></Rectangle>
<Rectangle x:Name="TpMapareaRect" VerticalAlignment="Top" HorizontalAlignment="Left" Fill="#55F00074" Stroke="#FFF00074" ></Rectangle>
</Grid>
<UniformGrid Margin="10,0,10,0" Grid.Column="1" Columns="2">
<TextBox x:Name="Tpsx" InputMethod.IsInputMethodEnabled="False" PreviewTextInput="limitnumber" TextChanged="OnTouchpadMapUpdate" Style="{StaticResource TextBoxExtend}" Margin="0,0,5,0" hc:InfoElement.Placeholder="Start X" VerticalAlignment="Center"/>
Expand All @@ -86,7 +80,7 @@
</Grid.ColumnDefinitions>
<Grid x:Name="ScRectGrid" Width="150" Height="100">
<Rectangle x:Name="ScAreaRect" Grid.Column="0" Height="100" Width="150" Stroke="Gray"></Rectangle>
<Rectangle x:Name="ScMapareaRect" HorizontalAlignment="Left" VerticalAlignment="Top" Grid.Column="0" Fill="#5500BFF4" Stroke="#FF00BFF4" ></Rectangle>
<Rectangle x:Name="ScMapareaRect" HorizontalAlignment="Left" VerticalAlignment="Top" Grid.Column="0" Fill="#55F00074" Stroke="#FFF00074" ></Rectangle>
</Grid>
<UniformGrid Margin="10,0,10,0" Grid.Column="1" Columns="2">
<TextBox x:Name="Scsx" TextChanged="OnScreenMapUpdate" InputMethod.IsInputMethodEnabled="False" PreviewTextInput="limitnumber" Style="{StaticResource TextBoxExtend}" Margin="0,0,5,0" hc:InfoElement.Placeholder="Start X" VerticalAlignment="Center"/>
Expand All @@ -101,8 +95,44 @@
</Grid>
</StackPanel>
</Border>
<Border x:Name="OptCard" Grid.Row="3" Background="#99FFFFFF" Style="{StaticResource BorderRegion}" Effect="{StaticResource EffectShadow2}" Margin="20,20,20,0">
<Grid>
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<TextBlock HorizontalAlignment="Left" Margin="5" Text="Options" Style="{StaticResource TextBlockTitle}"/>
<StackPanel Orientation="Horizontal" Grid.Row="1">
<Button Content="Launch inspector" Click="InspectorButtonClick"></Button>
<Button Content="Launch log window" Margin="10,0,0,0" Click="AdvancedButtonClick"></Button>
<Button Content="About MapTP" Margin="10,0,0,0" Click="AboutButtonClick"></Button>

</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,10,0,0" Grid.Row="2">
<CheckBox x:Name="TurtleCB" Content="Turtle mode" IsChecked="False" Click="TurtleCBClick"></CheckBox>
<CheckBox x:Name="TrayCB" Content="Enable Tray icon" Margin="10,0,0,0" IsChecked="True" Click="TrayCBClick"></CheckBox>
<CheckBox x:Name="HideCB" Content="Hide to tray when minimized" Margin="10,0,0,0" IsChecked="True"></CheckBox>
</StackPanel>
</Grid>
</Border>
</Grid>
</ScrollViewer>
<tray:NotifyIcon
x:Name="TrayIcon"
TooltipText="MapTP (Not Mapping)"
MenuOnRightClick="True"
FocusOnLeftClick="True"
LeftClick="TrayShowWindowClick"
Icon="pack://application:,,,/logo-inactive.ico"
>
<tray:NotifyIcon.Menu>
<ContextMenu>
<MenuItem x:Name="TrayWorkingMenuItem" Header="MapTP is not working..." IsEnabled="False" />
<MenuItem x:Name="TrayStartMenuItem" Header="Start" Click="StartButtonClick" />
<MenuItem x:Name="TrayShowMenuItem" Header="Show MapTP window" Click="TrayShowWindowClick" IsEnabled="False"/>
</ContextMenu>
</tray:NotifyIcon.Menu>
</tray:NotifyIcon>
</Grid>
</Window>
Loading

0 comments on commit 12d6ee5

Please sign in to comment.