Skip to content

Commit

Permalink
多开限制只针对同一个路径下同一个程序;
Browse files Browse the repository at this point in the history
先上报错误再弹窗;
不导出pdb文件;
修正添加标签出现的错误;
  • Loading branch information
Nayaku committed Apr 13, 2023
1 parent 0e09d28 commit e88873d
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 23 deletions.
23 changes: 13 additions & 10 deletions ImageManager/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using HandyControl.Themes;
using ImageManager.Tools;
using System.Diagnostics;
using System.Reflection;
using System.Windows;
using System.Windows.Threading;

Expand Down Expand Up @@ -28,8 +29,10 @@ internal void UpdateTheme(ApplicationTheme theme)
// 每次启动应用程序,都会验证名称为OnlyRun的互斥是否存在
protected override void OnStartup(StartupEventArgs e)
{
mutex = new Mutex(true, ResourceAssembly.GetName().Name);
if (mutex.WaitOne(0, false))
var location = Assembly.GetEntryAssembly()!.Location;
var bs = System.Security.Cryptography.MD5.HashData(System.Text.Encoding.UTF8.GetBytes(location));
mutex = new Mutex(true, Convert.ToBase64String(bs), out var isNewInstance);
if (isNewInstance)
{
try
{
Expand All @@ -56,25 +59,25 @@ protected override void OnStartup(StartupEventArgs e)

void ThrowException(Exception e)
{

MessageBox.Show("我们很抱歉,当前应用程序遇到一些问题,该操作已经终止。我们将会上传错误日志以便开发人员解决问题。\n错误信息:" + e.Message, "意外的操作", MessageBoxButton.OK, MessageBoxImage.Information);
Log.Error(e.ToString());
Log.ReportError(e.ToString());
MessageBox.Show("我们很抱歉,当前应用程序遇到一些问题,该操作已经终止。我们将会上传错误日志以便开发人员解决问题。\n错误信息:" + e.Message, "意外的操作", MessageBoxButton.OK, MessageBoxImage.Information);
}

void Current_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
{
MessageBox.Show("我们很抱歉,当前应用程序遇到一些问题,该操作已经终止。我们将会上传错误日志以便开发人员解决问题。\n错误信息:" + e.Exception.ToString(), "意外的操作", MessageBoxButton.OK, MessageBoxImage.Information);
e.Handled = true;
Log.Error(e.Exception.ToString());
Log.ReportError(e.ToString());
Log.ReportError(e.Exception.ToString());
MessageBox.Show("我们很抱歉,当前应用程序遇到一些问题,该操作已经终止。我们将会上传错误日志以便开发人员解决问题。\n错误信息:" + e.Exception.Message.ToString(), "意外的操作", MessageBoxButton.OK, MessageBoxImage.Information);
e.Handled = true;
}

void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
MessageBox.Show("我们很抱歉,当前应用程序遇到一些问题,该操作已经终止。我们将会上传错误日志以便开发人员解决问题。\n错误信息:" + e.ToString(), "意外的操作", MessageBoxButton.OK, MessageBoxImage.Information);
Log.Error(e.ToString());
Log.ReportError(e.ToString());
var ex = (Exception)e.ExceptionObject;
Log.Error(ex.ToString());
Log.ReportError(ex.ToString());
MessageBox.Show("我们很抱歉,当前应用程序遇到一些问题,该操作已经终止。我们将会上传错误日志以便开发人员解决问题。\n错误信息:" + ex.Message, "意外的操作", MessageBoxButton.OK, MessageBoxImage.Information);
}

}
Expand Down
4 changes: 2 additions & 2 deletions ImageManager/ImageManager.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<UseWPF>true</UseWPF>
<AssemblyName>ImageManager</AssemblyName>
<RootNamespace>ImageManager</RootNamespace>
<Version>3.1.2.0</Version>
<Version>3.1.3.0</Version>
<Configurations>Debug;Release</Configurations>
<Copyright>Copyright © Nayaku 2022</Copyright>
<Nullable>enable</Nullable>
Expand All @@ -20,7 +20,7 @@
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<DefineConstants>TRACE;Core</DefineConstants>
<DebugType>portable</DebugType>
<DebugType>none</DebugType>
</PropertyGroup>
<ItemGroup>
<Resource Include="icon.ico">
Expand Down
10 changes: 3 additions & 7 deletions ImageManager/ViewModels/MainPageViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using ImageManager.Data.Model;
using ImageManager.Tools;
using Microsoft.EntityFrameworkCore;
using Stylet;
using StyletIoC;
using System.Collections.Specialized;
using System.Diagnostics;
Expand All @@ -16,9 +15,6 @@
using ImageManager.Windows;
using System.Windows.Input;
using System.Windows.Controls;
using System.Collections.Generic;
using System.Linq;
using System;

namespace ImageManager.ViewModels
{
Expand Down Expand Up @@ -96,9 +92,8 @@ public MainPageViewModel(object fatherViewModel)
};
}

public async void UpdatePicture()
public void UpdatePicture()
{

IQueryable<Picture> query;
if (_fatherViewModel is AddImageViewModel addImageViewModel)
query = addImageViewModel.Pictures.AsQueryable();
Expand Down Expand Up @@ -214,7 +209,8 @@ public void AddPictureLabel()
bool? res = WindowManager.ShowDialog(pictureAddLabelViewModel);
if (res ?? false)
{
var label = pictureAddLabelViewModel.ResultLabel;
var label = Context.Labels.SingleOrDefault(l => l.Name == pictureAddLabelViewModel.SearchText)
?? new Label { Name = pictureAddLabelViewModel.SearchText };

SelectedPictures.ForEach(p =>
{
Expand Down
4 changes: 0 additions & 4 deletions ImageManager/ViewModels/PictureAddLabelViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ public class PictureAddLabelViewModel : Screen
public string SearchText { get; set; }
public bool ShowLabelPopup { get; set; }
public List<Label> SearchedLabels { get; set; }
public Label ResultLabel { get; set; }
public PictureAddLabelViewModel()
{
}
Expand Down Expand Up @@ -70,9 +69,6 @@ public void WindowKeyDown(object sender, System.Windows.Input.KeyEventArgs e)
public void OK(string okString)
{
var ok = bool.Parse(okString);
if (ok)
ResultLabel = Context.Labels.SingleOrDefault(l => l.Name == SearchText)
?? new Label { Name = SearchText };

RequestClose(ok);
}
Expand Down
8 changes: 8 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@

## 更新日志

### 3.1.3 2023年4月13日

- 修正多开逻辑错误。
- 错误弹窗更加友好。
- 修正不能添加标签的错误。



### 3.1.2 2023年4月5日

- 修改截图的逻辑。
Expand Down

0 comments on commit e88873d

Please sign in to comment.