Skip to content

Commit

Permalink
fix:关闭卡死
Browse files Browse the repository at this point in the history
  • Loading branch information
HRxiaohu committed Jan 3, 2023
1 parent 65c89f8 commit af2331e
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 19 deletions.
6 changes: 3 additions & 3 deletions Launcher/LauncherInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ namespace SodaCL.Launcher
public class LauncherInfo
{
public static string currentDir = AppDomain.CurrentDomain.SetupInformation.ApplicationBase;
public static string sodaCLBasePath = currentDir + @"\SodaCL";
public static string sodaCLLogPath = currentDir + @"\SodaCL\logs";
public static string sodaCLBasePath = currentDir + @"SodaCL";
public static string sodaCLLogPath = currentDir + @"SodaCL\logs";
public static string sodaCLConfigPath = sodaCLBasePath + @"\Config.ini";
public static string mcDir = currentDir + @"\.minecraft";
public static string mcDir = currentDir + @".minecraft";
public static int launchTime;
private string version;
}
Expand Down
1 change: 0 additions & 1 deletion Launcher/LauncherInit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ public static void InitNewFolder()
if (!File.Exists(LauncherInfo.sodaCLConfigPath))
{
File.Create(LauncherInfo.sodaCLConfigPath);
Toolkits.IniFile.Write("LaunchTime", "1");
}
}
catch (Exception ex)
Expand Down
2 changes: 1 addition & 1 deletion MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
</Grid.ColumnDefinitions>
<StackPanel Name="TitleBar_TitlePan" Grid.Column="0" Orientation="Horizontal" Margin="3,6,0,10" HorizontalAlignment="Left" Grid.Row="1">
<Image Height="32" Width="32" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="15,0,0,0" Source="/Resources/Images/Dev.ico" />
<TextBlock Text="Soda Craft Launcher" Height="28" Margin="5,0,0,0" FontSize="18" Padding="5,3,5,0" ScrollViewer.CanContentScroll="True" />
<TextBlock Text="Soda Craft Launcher" Height="28" Margin="5,0,0,0" FontSize="16" Padding="5,4,5,0" ScrollViewer.CanContentScroll="True" />
</StackPanel>
<Button Name="TitleBar_GoBackBtn" Width="32" Height="32" Grid.Column="0" Grid.Row="1" HorizontalAlignment="Left" Margin="20,6,0,10" Visibility="Hidden" Click="TitleBar_GoBackBtn_Click" Style="{DynamicResource Btn_NoBackground}">
<Image Width="20" Height="20" Source="{StaticResource Svg_GoBack}" />
Expand Down
18 changes: 14 additions & 4 deletions MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,18 @@ private void Border_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
// 退出按钮
private void TitleBar_ExitBtn_Click(object sender, RoutedEventArgs e)
{
Toolkits.IniFile.Write("LaunchTime", Convert.ToString(int.Parse(Toolkits.IniFile.Read("LaunchTime")) + 1));
this.Close();
try
{
//Toolkits.IniFile.Write("LaunchTime", Convert.ToString(int.Parse(Toolkits.IniFile.Read("LaunchTime")??"0") + 1 ));
}
catch(Exception ex)
{
Log(ModuleList.Main, LogInfo.Error, ex.Message, ex.StackTrace);
}
finally
{
this.Close();
}
}

//最小化按钮
Expand Down Expand Up @@ -103,7 +113,7 @@ private void MainFram_Navigated(object sender, NavigationEventArgs e)
Storyboard.SetTarget(goBackBtnAni, TitleBar_GoBackBtn);
Storyboard.SetTargetProperty(goBackBtnAni, new PropertyPath("Margin"));
goBackSb.Children.Add(goBackBtnAni);
var goBackPanAni = new ThicknessAnimation(new Thickness(5, 0, 0, 0), new Thickness(-230, 6, 0, 0), AniTime);
var goBackPanAni = new ThicknessAnimation(new Thickness(5, 0, 0, 0), new Thickness(-240, 6, 0, 0), AniTime);
goBackPanAni.EasingFunction = easingFunc;
Storyboard.SetTarget(goBackPanAni, TitleBar_TitlePan);
Storyboard.SetTargetProperty(goBackPanAni, new PropertyPath("Margin"));
Expand All @@ -119,7 +129,7 @@ private void MainFram_Navigated(object sender, NavigationEventArgs e)
Storyboard.SetTarget(goBackBtnAni, TitleBar_GoBackBtn);
Storyboard.SetTargetProperty(goBackBtnAni, new PropertyPath("Margin"));
goBackSb.Children.Add(goBackBtnAni);
var goBackPanAni = new ThicknessAnimation(new Thickness(-230, 0, 0, 0), new Thickness(5, 0, 0, 0), AniTime);
var goBackPanAni = new ThicknessAnimation(new Thickness(-240, 0, 0, 0), new Thickness(5, 0, 0, 0), AniTime);
goBackPanAni.EasingFunction = easingFunc;
Storyboard.SetTarget(goBackPanAni, TitleBar_TitlePan);
Storyboard.SetTargetProperty(goBackPanAni, new PropertyPath("Margin"));
Expand Down
18 changes: 9 additions & 9 deletions Toolkits/Dialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class Dialog
{
private static TimeSpan DialogAniSpeed { get; } = TimeSpan.FromSeconds(0.9);
private static TimeSpan OpacAniSpeed { get; } = TimeSpan.FromSeconds(1);
private static CubicEase easingFunc { get; set; } = new CubicEase { EasingMode = EasingMode.EaseIn };
private static CubicEase EasingFunc { get; set; } = new CubicEase { EasingMode = EasingMode.EaseInOut };

public static void OpenDialog()
{
Expand All @@ -20,11 +20,11 @@ public static void OpenDialog()
Storyboard.SetTarget(rectBigOpacAni, MainWindow.mainWindow.DialogRect);
Storyboard.SetTargetProperty(rectBigOpacAni, new PropertyPath("Opacity"));
var borderBigWidthAni = new DoubleAnimation(0, 400, DialogAniSpeed);
borderBigWidthAni.EasingFunction = easingFunc;
borderBigWidthAni.EasingFunction = EasingFunc;
Storyboard.SetTarget(borderBigWidthAni, MainWindow.mainWindow.DialogBorder);
Storyboard.SetTargetProperty(borderBigWidthAni, new PropertyPath("Width"));
var borderBigHeightAni = new DoubleAnimation(0, 250, DialogAniSpeed);
borderBigHeightAni.EasingFunction = easingFunc;
borderBigHeightAni.EasingFunction = EasingFunc;
Storyboard.SetTarget(borderBigHeightAni, MainWindow.mainWindow.DialogBorder);
Storyboard.SetTargetProperty(borderBigHeightAni, new PropertyPath("Height"));
diaSbBig.Children.Add(rectBigOpacAni);
Expand All @@ -41,13 +41,13 @@ public static void ChangeDialog()
var froSbSmall = new Storyboard();

var borderSmallWidthAni = new DoubleAnimation(400, 0, DialogAniSpeed);
borderSmallWidthAni.EasingFunction = easingFunc;
borderSmallWidthAni.EasingFunction = EasingFunc;

Storyboard.SetTarget(borderSmallWidthAni, MainWindow.mainWindow.FrontBorder);
Storyboard.SetTargetProperty(borderSmallWidthAni, new PropertyPath("Width"));

var borderSmallHeightAni = new DoubleAnimation(250, 0, DialogAniSpeed);
borderSmallHeightAni.EasingFunction = easingFunc;
borderSmallHeightAni.EasingFunction = EasingFunc;

Storyboard.SetTarget(borderSmallHeightAni, MainWindow.mainWindow.FrontBorder);
Storyboard.SetTargetProperty(borderSmallHeightAni, new PropertyPath("Height"));
Expand All @@ -58,12 +58,12 @@ public static void ChangeDialog()
var diaSbBig = new Storyboard();

var forBorderBigWidthAni = new DoubleAnimation(0, 400, DialogAniSpeed);
forBorderBigWidthAni.EasingFunction = easingFunc;
forBorderBigWidthAni.EasingFunction = EasingFunc;
Storyboard.SetTarget(forBorderBigWidthAni, MainWindow.mainWindow.DialogBorder);
Storyboard.SetTargetProperty(forBorderBigWidthAni, new PropertyPath("Width"));

var forBorderBigHeightAni = new DoubleAnimation(0, 250, DialogAniSpeed);
forBorderBigHeightAni.EasingFunction = easingFunc;
forBorderBigHeightAni.EasingFunction = EasingFunc;
Storyboard.SetTarget(forBorderBigHeightAni, MainWindow.mainWindow.DialogBorder);
Storyboard.SetTargetProperty(forBorderBigHeightAni, new PropertyPath("Height"));
diaSbBig.Children.Add(forBorderBigWidthAni);
Expand All @@ -88,11 +88,11 @@ public static void CloseDialog()
Storyboard.SetTarget(rectSmallOpacAni, MainWindow.mainWindow.DialogRect);
Storyboard.SetTargetProperty(rectSmallOpacAni, new PropertyPath("Opacity"));
var borderSmallWidthAni = new DoubleAnimation(400, 0, DialogAniSpeed);
borderSmallWidthAni.EasingFunction = easingFunc;
borderSmallWidthAni.EasingFunction = EasingFunc;
Storyboard.SetTarget(borderSmallWidthAni, MainWindow.mainWindow.DialogBorder);
Storyboard.SetTargetProperty(borderSmallWidthAni, new PropertyPath("Width"));
var borderSmallHeightAni = new DoubleAnimation(250, 0, DialogAniSpeed);
borderSmallHeightAni.EasingFunction = easingFunc;
borderSmallHeightAni.EasingFunction = EasingFunc;
Storyboard.SetTarget(borderSmallHeightAni, MainWindow.mainWindow.DialogBorder);
Storyboard.SetTargetProperty(borderSmallHeightAni, new PropertyPath("Height"));
diaSbSmall.Children.Add(rectSmallOpacAni);
Expand Down
2 changes: 1 addition & 1 deletion Toolkits/IniFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace SodaCL.Toolkits
{
internal class IniFile
{
private static string EXE = Assembly.GetExecutingAssembly().GetName().Name;
private static string EXE = "SodaCL";

[DllImport("kernel32", CharSet = CharSet.Unicode)]
private static extern long WritePrivateProfileString(string Section, string Key, string Value, string FilePath);
Expand Down

0 comments on commit af2331e

Please sign in to comment.