Skip to content

Commit

Permalink
添加窗体移动方法
Browse files Browse the repository at this point in the history
  • Loading branch information
micahh committed Jan 23, 2021
1 parent 9597053 commit 1f98d75
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 11 deletions.
2 changes: 1 addition & 1 deletion SoftwarePack/Close.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ private void image_min_MouseUp(object sender, MouseButtonEventArgs e)
private void image_close_MouseUp(object sender, MouseButtonEventArgs e)
{
Window win = Window.GetWindow(this);
if (MessageBoxX.Show("确认要退出吗?", "退出", Application.Current.MainWindow, MessageBoxButton.YesNo) == MessageBoxResult.Yes)
if (MessageBoxX.Show("确认要退出吗?", "退出", Application.Current.MainWindow, MessageBoxButton.OKCancel) == MessageBoxResult.OK)
{
Application.Current.Shutdown(-1);
}
Expand Down
4 changes: 2 additions & 2 deletions SoftwarePack/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
</Grid.RowDefinitions>


<Image Source="/images/bgtop.png" Stretch="Fill"/>
<Image Source="/images/bgtop.png" Stretch="Fill" MouseDown="Window_MouseDown"/>
<local:Close Margin="0,10,10,0" HorizontalAlignment="Right" VerticalAlignment="Top" Height="36" Width="82" />

<Label Name="lbl_Ver" Content="" Grid.Row="2" HorizontalAlignment="Center" Foreground="Gray" MouseUp="lbl_Ver_MouseUp"/>
<!--产品信息填写-->
<Grid x:Name="step1" Grid.Row="1" Visibility="Visible">

<Label Content="软件名称:" HorizontalAlignment="Left" Margin="62,45,0,0" VerticalAlignment="Top" Height="25" Width="70"/>
<TextBox HorizontalAlignment="Left" x:Name="txtSoftName" Width="250" Height="30" FontSize="18" Foreground="Black" VerticalContentAlignment="Top" Margin="132,45,0,388"
<TextBox HorizontalAlignment="Left" x:Name="txtSoftName" Width="250" Height="30" Foreground="Black" VerticalContentAlignment="Center" Margin="132,45,0,388"
pu:TextBoxHelper.Watermark="请输入软件名称"
pu:TextBoxHelper.FocusedBorderBrush="#00FFE2"
pu:TextBoxHelper.FocusedShadowColor="#00FFE2"
Expand Down
31 changes: 23 additions & 8 deletions SoftwarePack/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Panuon.UI.Silver;
using Panuon.UI.Silver.Core;
using SevenZip;
using System;
using System.Diagnostics;
Expand All @@ -22,9 +23,19 @@ public partial class MainWindow : Window
/// </summary>
private string rootDirPath = AppDomain.CurrentDomain.BaseDirectory;

/// <summary>
/// 版本信息
/// </summary>
private string verStr = "© 2021 Micahh MIT license";

/// <summary>
/// 是否压缩完成
/// </summary>
private bool IsCompleteCompressor;

/// <summary>
/// MainWindow
/// </summary>
public MainWindow()
{
InitializeComponent();
Expand Down Expand Up @@ -68,10 +79,13 @@ private void Window_Loaded(object sender, RoutedEventArgs e)
}

lbl_Ver.Content = verStr;

}


private void Window_MouseDown(object sender, MouseButtonEventArgs e)
{
// Begin dragging the window
this.DragMove();
}
/// <summary>
/// 按钮动作
/// </summary>
Expand Down Expand Up @@ -256,10 +270,11 @@ private void btnNext_Click(object sender, RoutedEventArgs e)
step1.Visibility = Visibility.Hidden;
step2.Visibility = Visibility.Visible;


}
catch (Exception ex)
{
System.Windows.MessageBox.Show($"异常错误:{ex.Message}", "错误", System.Windows.MessageBoxButton.OK, MessageBoxImage.Error);
MessageBoxX.Show($"异常错误:{ex.Message}", "错误", Application.Current.MainWindow, MessageBoxButton.OK, new MessageBoxXConfigurations() { MessageBoxIcon = MessageBoxIcon.Error });
}
}

Expand All @@ -283,7 +298,7 @@ private void CompressorSoftware()
btnBuild.IsEnabled = true;
btnLastStep.IsEnabled = true;
IsCompleteCompressor = true;
lbl_Ver.Content = "准备工作已全部完成,开始打属于你的安装包吧";
lbl_Ver.Content = "准备工作已全部完成,开始打包属于你的安装包吧";
};
}

Expand Down Expand Up @@ -314,25 +329,25 @@ private bool InitProductInfo(out string productInfoData)
productInfoData = string.Empty;
if (string.IsNullOrEmpty(txtSoftName.Text))
{
MessageBox.Show("请输入应用程序名称");
MessageBoxX.Show("请输入应用程序名称", "提示", Application.Current.MainWindow, MessageBoxButton.OK);
return false;
}

// 版本号验证
if (!Regex.IsMatch(softVersion, @"^([1-9]\d|[1-9])(\.([1-9]\d|\d)){3}$"))
{
MessageBox.Show("请输入版本号");
MessageBoxX.Show("请输入版本号", "提示", Application.Current.MainWindow, MessageBoxButton.OK);
return false;
}

if (string.IsNullOrEmpty(txtSoftPath.Text))
{
MessageBox.Show("请选择应用程序路径");
MessageBoxX.Show("请选择应用程序路径", "提示", Application.Current.MainWindow, MessageBoxButton.OK);
return false;
}
if (string.IsNullOrEmpty(txtMainSoftPath.Text))
{
MessageBox.Show("请选择应用程序主启动程序");
MessageBoxX.Show("请选择应用程序主启动程序", "提示", Application.Current.MainWindow, MessageBoxButton.OK);
return false;
}

Expand Down

0 comments on commit 1f98d75

Please sign in to comment.