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

Add Mouse DPI to Tablet Area conversion #595

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
24 changes: 23 additions & 1 deletion TabletDriverGUI/MainWindow.Areas.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1514,7 +1514,29 @@ private void CanvasArea_ContextMenuOpening(object sender, ContextMenuEventArgs e

}


private void ConvertMouse_Click(object sender, RoutedEventArgs e)
{
var wcm = new WindowConvertMouse();
wcm.ShowDialog();
if (!wcm.DialogResult.HasValue || !wcm.DialogResult.Value) return;

const double inchesToMm = 25.4;
var width = config.DesktopSize.Width / wcm.Dpi * inchesToMm;
var height = config.DesktopSize.Height / wcm.Dpi * inchesToMm;
var x = config.TabletFullArea.Width / 2;
var y = config.TabletFullArea.Height / 2;

textTabletAreaWidth.Text = width.ToString();
textTabletAreaHeight.Text = height.ToString();
textTabletAreaX.Text = x.ToString();
textTabletAreaY.Text = y.ToString();
config.SelectedTabletArea.Width = width;
config.SelectedTabletArea.Height = height;
config.SelectedTabletArea.X = x;
config.SelectedTabletArea.Y = y;

UpdateSettingsToConfiguration();
}

#region Wacom / Draw area

Expand Down
12 changes: 11 additions & 1 deletion TabletDriverGUI/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,17 @@
</Button>

</StackPanel>
</StackPanel>
<Button x:Name="ConvertMouse" Content="Convert mouse DPI" Height="28" Width="115"
Margin="0,5,0,0" IsCancel="True" Click="ConvertMouse_Click">
<Button.ToolTip>
<TextBlock>
<TextBlock FontWeight="Bold" FontSize="14">Convert mouse DPI</TextBlock>
<LineBreak/>
Matches the physical movement of your mouse to the physical movement of your pen.
</TextBlock>
</Button.ToolTip>
</Button>
</StackPanel>

<!-- Tablet area canvas -->
<Canvas Grid.Column="1" Name="canvasTabletArea"
Expand Down
7 changes: 7 additions & 0 deletions TabletDriverGUI/TabletDriverGUI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@
<Compile Include="MainWindow.Areas.cs" />
<Compile Include="MultimediaTimer.cs" />
<Compile Include="NamedPipeClient.cs" />
<Compile Include="WindowConvertMouse.xaml.cs">
<DependentUpon>WindowConvertMouse.xaml</DependentUpon>
</Compile>
<Compile Include="WindowTabletViewSettings.xaml.cs">
<DependentUpon>WindowTabletViewSettings.xaml</DependentUpon>
</Compile>
Expand All @@ -106,6 +109,10 @@
<Compile Include="WindowAreaEditor.xaml.cs">
<DependentUpon>WindowAreaEditor.xaml</DependentUpon>
</Compile>
<Page Include="WindowConvertMouse.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="WindowTabletViewSettings.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
Expand Down
28 changes: 28 additions & 0 deletions TabletDriverGUI/WindowConvertMouse.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<Window x:Class="TabletDriverGUI.WindowConvertMouse"
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:TabletDriverGUI"
mc:Ignorable="d"
Title="Enter mouse DPI" Height="115.099" Width="205.247" ScrollViewer.VerticalScrollBarVisibility="Disabled" ResizeMode="CanMinimize" ShowInTaskbar="False" WindowStartupLocation="CenterOwner" Activated="Window_Activated">
<Grid HorizontalAlignment="Left" Width="197">
<Grid HorizontalAlignment="Center" VerticalAlignment="Center">

<Grid Margin="0">
<Label Content="Mouse DPI:" HorizontalAlignment="Left" VerticalAlignment="Top"/>
<TextBox x:Name="DpiText" HorizontalAlignment="Left" TextWrapping="Wrap" VerticalAlignment="Top" Width="95" VerticalContentAlignment="Center" Margin="70,2,0,0" Height="22"/>
<Label Content="dpi" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="138,0,0,0" Height="28"/>

</Grid>
<Grid Margin="0,31,0,0">

<Button x:Name="Ok" Content="_OK" VerticalAlignment="Center" Click="Ok_Click" Margin="70,0,5,0" Width="59" IsDefault="True" Height="28"/>
<Button x:Name="Cancel" Content="_Cancel" VerticalAlignment="Center" Click="Cancel_Click" Margin="0,0,70,0" Width="60" IsCancel="True" Height="28"/>

</Grid>

</Grid>

</Grid>
</Window>
54 changes: 54 additions & 0 deletions TabletDriverGUI/WindowConvertMouse.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
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;

namespace TabletDriverGUI
{
/// <summary>
/// Interaction logic for WindowConvertMouse.xaml
/// </summary>
public partial class WindowConvertMouse : Window
{
public double Dpi;

public WindowConvertMouse()
{
InitializeComponent();
}

private void Window_Activated(object sender, EventArgs e)
{
FocusManager.SetFocusedElement(this, DpiText);
}

private void Ok_Click(object sender, RoutedEventArgs e)
{
bool valid = double.TryParse(DpiText.Text, out Dpi);
if (valid)
{
DialogResult = true;
Close();
}
else
{
MessageBox.Show("The entered value is not a number.");
}
}

private void Cancel_Click(object sender, RoutedEventArgs e)
{
DialogResult = false;
Close();
}
}
}