-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f23a6d3
commit 12d6ee5
Showing
14 changed files
with
1,198 additions
and
743 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.