mirror of
https://github.com/LorisYounger/VPet.git
synced 2024-08-30 18:42:36 +00:00
手动设置活动外包矩形功能
This commit is contained in:
parent
5ea3d2d90b
commit
e6051e04f5
@ -16,38 +16,30 @@ namespace VPet_Simulator.Windows
|
||||
this.mw = mw;
|
||||
}
|
||||
|
||||
private bool _screenDetected = false;
|
||||
private Rectangle _screenBorder;
|
||||
private bool _isPrimaryScreen = true;
|
||||
public bool IsPrimaryScreen
|
||||
private static Rectangle _screenBorder;
|
||||
private static bool _isPrimaryScreen = true;
|
||||
public static bool IsPrimaryScreen
|
||||
{
|
||||
get
|
||||
{
|
||||
if(!_screenDetected) DetectCurrentScreen();
|
||||
return _isPrimaryScreen;
|
||||
}
|
||||
}
|
||||
public Rectangle ScreenBorder
|
||||
public static Rectangle ScreenBorder
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!_screenDetected) DetectCurrentScreen();
|
||||
return _screenBorder;
|
||||
}
|
||||
}
|
||||
private void DetectCurrentScreen()
|
||||
set
|
||||
{
|
||||
var windowInteropHelper = new WindowInteropHelper(mw);
|
||||
var currentScreen = Screen.FromHandle(windowInteropHelper.Handle);
|
||||
// TODO 多屏+非100%缩放下以上API跟Left、Top一样都是错的
|
||||
|
||||
_isPrimaryScreen = currentScreen.Primary;
|
||||
_screenBorder = currentScreen.Bounds;
|
||||
_screenDetected = true;
|
||||
_screenBorder = value;
|
||||
_isPrimaryScreen = false;
|
||||
}
|
||||
public void ClearScreenBorderCache()
|
||||
}
|
||||
public static void ResetScreenBorder()
|
||||
{
|
||||
_screenDetected = false;
|
||||
_isPrimaryScreen = true;
|
||||
}
|
||||
|
||||
public double GetWindowsDistanceLeft()
|
||||
@ -92,7 +84,6 @@ namespace VPet_Simulator.Windows
|
||||
{
|
||||
mw.Left += X * ZoomRatio;
|
||||
mw.Top += Y * ZoomRatio;
|
||||
ClearScreenBorderCache();
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -655,7 +655,6 @@ namespace VPet_Simulator.Windows
|
||||
Main.DisplayToNomal();
|
||||
Left = (SystemParameters.PrimaryScreenWidth - Width) / 2;
|
||||
Top = (SystemParameters.PrimaryScreenHeight - Height) / 2;
|
||||
(Core.Controller as MWController).ClearScreenBorderCache();
|
||||
}));
|
||||
m_menu.MenuItems.Add(new MenuItem("反馈中心".Translate(), (x, y) => { new winReport(this).Show(); }));
|
||||
m_menu.MenuItems.Add(new MenuItem("开发控制台".Translate(), (x, y) => { new winConsole(this).Show(); }));
|
||||
|
@ -377,6 +377,8 @@
|
||||
<RowDefinition Height="35" />
|
||||
<RowDefinition Height="35" />
|
||||
<RowDefinition Height="35" />
|
||||
<RowDefinition Height="35" />
|
||||
<RowDefinition Height="35" />
|
||||
</Grid.RowDefinitions>
|
||||
<pu:Switch x:Name="CalFunctionBox" Grid.Column="2" Background="Transparent"
|
||||
BorderBrush="{DynamicResource PrimaryDark}" BoxHeight="18" BoxWidth="35"
|
||||
@ -404,7 +406,7 @@
|
||||
<ComboBoxItem Content="Ill" />
|
||||
</ComboBox>
|
||||
</Grid>
|
||||
<Grid Grid.Row="5" Grid.RowSpan="2" Grid.Column="2">
|
||||
<Grid Grid.Row="5" Grid.RowSpan="4" Grid.Column="2">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="*" />
|
||||
@ -491,7 +493,37 @@
|
||||
</ComboBoxItem>
|
||||
</ComboBox>
|
||||
</Grid>
|
||||
|
||||
<Grid Grid.Row="7" Grid.RowSpan="2" Grid.Column="3">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="35" />
|
||||
<RowDefinition Height="35" />
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock Grid.Row="0" Text="{ll:Str '当前区域:'}"/>
|
||||
<TextBlock Grid.Column="1" Grid.ColumnSpan="2" Text="{ll:Str '主屏幕'}"/>
|
||||
<Button x:Name="BtnSetScreen_Default" Grid.Row="1" Grid.Column="0" Margin="5,5,5,5" Padding="1"
|
||||
pu:ButtonHelper.CornerRadius="4" Background="{DynamicResource SecondaryLight}"
|
||||
Click="BtnSetScreen_Default_Click" Content="{ll:Str 重置为主屏}"/>
|
||||
<Button x:Name="BtnSetScreen_DetectScreen" Grid.Row="1" Grid.Column="1" Margin="5,5,5,5" Padding="1"
|
||||
pu:ButtonHelper.CornerRadius="4" Background="{DynamicResource SecondaryLight}"
|
||||
Click="BtnSetScreen_DetectScreen_Click" Content="{ll:Str 设为桌宠屏幕}"
|
||||
ToolTip="{ll:Str 当屏幕分辨率不为100%时可能识别有误}"/>
|
||||
<Button x:Name="BtnSetScreen_Window" Grid.Row="1" Grid.Column="2" Margin="5,5,5,5" Padding="1"
|
||||
pu:ButtonHelper.CornerRadius="4" Background="{DynamicResource SecondaryLight}"
|
||||
Click="BtnSetScreen_Window_Click" Content="{ll:Str 设为窗口范围}">
|
||||
<Button.ToolTip>
|
||||
<TextBlock>
|
||||
<TextBlock Text="{ll:Str 使用设置窗口框选范围后点击}"/>
|
||||
<LineBreak />
|
||||
<TextBlock Text="{ll:Str 注:双击顶端可最大化设置页}"/>
|
||||
</TextBlock>
|
||||
</Button.ToolTip>
|
||||
</Button>
|
||||
</Grid>
|
||||
<TextBlock Grid.Row="0" VerticalAlignment="Center" Text="{ll:Str 数据计算}" />
|
||||
<TextBlock Grid.Row="1" VerticalAlignment="Center" Text="{ll:Str 显示状态}" />
|
||||
<TextBlock Grid.Row="5" VerticalAlignment="Center" Text="{ll:Str 桌宠移动}" />
|
||||
|
@ -615,6 +615,25 @@ namespace VPet_Simulator.Windows
|
||||
}
|
||||
}
|
||||
|
||||
private void BtnSetScreen_Default_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
MWController.ResetScreenBorder();
|
||||
}
|
||||
|
||||
private void BtnSetScreen_DetectScreen_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var windowInteropHelper = new System.Windows.Interop.WindowInteropHelper(mw);
|
||||
var currentScreen = System.Windows.Forms.Screen.FromHandle(windowInteropHelper.Handle);
|
||||
MWController.ScreenBorder = currentScreen.Bounds;
|
||||
}
|
||||
|
||||
private void BtnSetScreen_Window_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
MWController.ScreenBorder = new System.Drawing.Rectangle(
|
||||
(int)Left, (int)Top,
|
||||
(int)Width, (int)Height
|
||||
);
|
||||
}
|
||||
|
||||
private void hyper_moreInfo(object sender, RoutedEventArgs e)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user