Skip to content

Commit

Permalink
feat: 实现窗口最大化与还原
Browse files Browse the repository at this point in the history
1. 在菜单栏双击应用最大化与还原
  • Loading branch information
leven99 committed Oct 4, 2019
1 parent 3d308fd commit ea222a9
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 20 deletions.
18 changes: 14 additions & 4 deletions ViewModels/MainWindowVM.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ public string DepictInfo

#region 菜单栏

#region 选项 - 字节编码
#region 选项

#region 字节编码
public void ASCIIEnable()
{
SerialPortModel.UTF8Enable = false;
Expand Down Expand Up @@ -176,7 +178,7 @@ public void DtrEnable()
}
}

#region 选项 - 流控制
#region 流控制
public void NoneEnable()
{
SerialPortModel.XOnXOffEnable = false;
Expand Down Expand Up @@ -278,7 +280,7 @@ public void RequestToSendXOnXOffEnable()
}
#endregion

#region 选项 - 发送换行
#region 发送换行
public void NonesEnable()
{
SendModel.CrEnable = false;
Expand Down Expand Up @@ -316,6 +318,9 @@ public void CrLfEnable()
}
#endregion

#endregion

#region 视图
public void Reduced_Enable()
{
HelpModel.Reduced_Enable = !HelpModel.Reduced_Enable;
Expand All @@ -329,8 +334,11 @@ public void Reduced_Enable()
HelpModel.View_Visibility = "Visible";
}
}
#endregion

#region 帮助 - 检查更新
#region 帮助

#region 检查更新
public async void UpdateAsync()
{
HelpModel.httpClient = new HttpClient
Expand Down Expand Up @@ -436,6 +444,8 @@ private void ThreadStartingWPFUpdate()

#endregion

#endregion

#region 打开/关闭串口
public bool OpenSP()
{
Expand Down
2 changes: 1 addition & 1 deletion Views/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
</Grid.ColumnDefinitions>
<Image x:Name="IconImage" Source="/OSDA;component/icon/favicon.ico"
Margin="6,3,4,3" Width="18" Height="18"/>
<Menu x:Name="ItemMenu" Grid.Column="1" Background="White">
<Menu x:Name="ItemMenu" Grid.Column="1" Background="White" MouseDoubleClick="ItemMenu_MouseDoubleClick">
<MenuItem x:Name="FileMenuItem" Header="文件(_F)" Style="{StaticResource MainMenuItem}">
<MenuItem x:Name="ExitMenuItem" Header="退出(_X)"
Click="ExitMenuItem_Click"/>
Expand Down
73 changes: 58 additions & 15 deletions Views/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,43 @@ public MainWindow()
DataContext = mainWindowViewModel;
}

#region Menu Mouse movement Support
#region Menu Mouse Support
/// <summary>
/// 鼠标移动
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void MouseMove_Click(object sender, System.Windows.Input.MouseEventArgs e)
{
if (e.LeftButton == MouseButtonState.Pressed)
{
this.DragMove();
DragMove();
}
}

/// <summary>
/// 鼠标双击(最大化与还原)
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ItemMenu_MouseDoubleClick(object sender, MouseButtonEventArgs e)
{
if (WindowState == WindowState.Maximized)
{
WindowState = WindowState.Normal;
}
else
{
WindowState = WindowState.Maximized;
}
}
#endregion

#region 菜单栏

#region 文件
/// <summary>
/// 文件 - 退出
/// 退出
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
Expand All @@ -48,18 +72,23 @@ private void ExitMenuItem_Click(object sender, RoutedEventArgs e)

Close();
}
#endregion

#region 工具
/// <summary>
/// 工具 - 计算器
/// 计算器
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void CalcMenuItem_Click(object sender, RoutedEventArgs e)
{
Process.Start("calc.exe");
}
#endregion

#region 选项 - 字节编码
#region 选项

#region 字节编码
private void ASCIIMenuItem_Click(object sender, RoutedEventArgs e)
{
mainWindowViewModel.ASCIIEnable();
Expand All @@ -82,7 +111,7 @@ private void UTF32MenuItem_Click(object sender, RoutedEventArgs e)
#endregion

/// <summary>
/// 选项 - RtsEnable
/// RtsEnable
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
Expand All @@ -92,7 +121,7 @@ private void RtsEnableMenuItem_Click(object sender, RoutedEventArgs e)
}

/// <summary>
/// 选项 - DtrEnable
/// DtrEnable
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
Expand All @@ -101,7 +130,7 @@ private void DtrEnableMenuItem_Click(object sender, RoutedEventArgs e)
mainWindowViewModel.DtrEnable();
}

#region 选项 - 流控制
#region 流控制
private void NoneMenuItem_Click(object sender, RoutedEventArgs e)
{
mainWindowViewModel.NoneEnable();
Expand All @@ -123,7 +152,7 @@ private void RequestToSendXOnXOffMenuItem_Click(object sender, RoutedEventArgs e
}
#endregion

#region 选项 - 发送换行
#region 发送换行
private void NonesMenuItem_Click(object sender, RoutedEventArgs e)
{
mainWindowViewModel.NonesEnable();
Expand All @@ -145,6 +174,9 @@ private void CrLfMenuItem_Click(object sender, RoutedEventArgs e)
}
#endregion

#endregion

#region 视图
/// <summary>
/// 精简视图
/// </summary>
Expand All @@ -154,9 +186,11 @@ private void EveryMenuItem_Click(object sender, RoutedEventArgs e)
{
mainWindowViewModel.Reduced_Enable();
}
#endregion

#region 帮助
/// <summary>
/// 帮助 - 检查更新
/// 检查更新
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
Expand All @@ -166,7 +200,7 @@ private void VerUpMenuItem_Click(object sender, RoutedEventArgs e)
}

/// <summary>
/// 帮助 - Gitee Repository(码云存储库)
/// Gitee 存储库
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
Expand All @@ -176,14 +210,15 @@ private void RPMenuItem_Click(object sender, RoutedEventArgs e)
}

/// <summary>
/// 帮助 - Report issue(报告问题
/// 报告问题
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void IssueMenuItem_Click(object sender, RoutedEventArgs e)
{
Process.Start("https://gitee.com/leven9/OSDA/issues");
}
#endregion

/// <summary>
/// 最小化
Expand Down Expand Up @@ -256,14 +291,22 @@ private void ClearCount(object sender, RoutedEventArgs e)
}
#endregion

#region RecvTextBox Mouse Double Support
#region RecvTextBox Support
/// <summary>
/// Mouse Double(鼠标双击)
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void RecvTextBox_MouseDoubleClick(object sender, MouseButtonEventArgs e)
{
mainWindowViewModel.Enable_Recv();
}
#endregion

#region RecvTextBox ScrollToEnd Support
/// <summary>
/// ScrollToEnd
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void RecvTextBox_TextChanged(object sender, TextChangedEventArgs e)
{
RecvTextBox.ScrollToEnd();
Expand Down

0 comments on commit ea222a9

Please sign in to comment.