代码优化
This commit is contained in:
@@ -357,7 +357,7 @@ namespace Ink_Canvas
|
||||
if (themeKey != null) keyValue = (int)themeKey.GetValue("SystemUsesLightTheme");
|
||||
if (keyValue == 1) light = true;
|
||||
}
|
||||
catch { }
|
||||
catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
|
||||
|
||||
return light;
|
||||
}
|
||||
|
||||
@@ -1380,7 +1380,7 @@ namespace Ink_Canvas
|
||||
{
|
||||
InkCanvasForInkReplay.Strokes.Remove(s);
|
||||
}
|
||||
catch { }
|
||||
catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
|
||||
|
||||
stylusPoints.Add(stylusPoint);
|
||||
s = new Stroke(stylusPoints.Clone())
|
||||
@@ -1417,7 +1417,7 @@ namespace Ink_Canvas
|
||||
{
|
||||
InkCanvasForInkReplay.Strokes.Remove(s);
|
||||
}
|
||||
catch { }
|
||||
catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
|
||||
|
||||
stylusPoints.Add(stylusPoint);
|
||||
s = new Stroke(stylusPoints.Clone())
|
||||
@@ -2759,7 +2759,7 @@ namespace Ink_Canvas
|
||||
else
|
||||
((UIElement)((Button)sender).Content).Opacity = 0.25;
|
||||
}
|
||||
catch { }
|
||||
catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
|
||||
}
|
||||
|
||||
#endregion Left Side Panel
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Windows;
|
||||
using System;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace Ink_Canvas
|
||||
@@ -39,7 +40,7 @@ namespace Ink_Canvas
|
||||
{
|
||||
SymbolIconUndo_MouseUp(lastBorderMouseDownObject, null);
|
||||
}
|
||||
catch { }
|
||||
catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
|
||||
}
|
||||
|
||||
private void HotKey_Redo(object sender, ExecutedRoutedEventArgs e)
|
||||
@@ -48,7 +49,7 @@ namespace Ink_Canvas
|
||||
{
|
||||
SymbolIconRedo_MouseUp(lastBorderMouseDownObject, null);
|
||||
}
|
||||
catch { }
|
||||
catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
|
||||
}
|
||||
|
||||
private void HotKey_Clear(object sender, ExecutedRoutedEventArgs e)
|
||||
|
||||
@@ -416,7 +416,7 @@ namespace Ink_Canvas
|
||||
{
|
||||
pptApplication.Presentations[i].Close();
|
||||
}
|
||||
catch { }
|
||||
catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -444,17 +444,17 @@ namespace Ink_Canvas
|
||||
{
|
||||
if (presentation != null)
|
||||
{
|
||||
try { if (Marshal.IsComObject(presentation)) Marshal.ReleaseComObject(presentation); } catch { }
|
||||
try { if (Marshal.IsComObject(presentation)) Marshal.ReleaseComObject(presentation); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
|
||||
presentation = null;
|
||||
}
|
||||
if (slides != null)
|
||||
{
|
||||
try { if (Marshal.IsComObject(slides)) Marshal.ReleaseComObject(slides); } catch { }
|
||||
try { if (Marshal.IsComObject(slides)) Marshal.ReleaseComObject(slides); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
|
||||
slides = null;
|
||||
}
|
||||
if (slide != null)
|
||||
{
|
||||
try { if (Marshal.IsComObject(slide)) Marshal.ReleaseComObject(slide); } catch { }
|
||||
try { if (Marshal.IsComObject(slide)) Marshal.ReleaseComObject(slide); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
|
||||
slide = null;
|
||||
}
|
||||
slidescount = 0;
|
||||
@@ -1030,7 +1030,7 @@ namespace Ink_Canvas
|
||||
currentPage = pres.SlideShowWindow.View.CurrentShowPosition;
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -977,7 +977,7 @@ namespace Ink_Canvas
|
||||
LogHelper.WriteLogToFile($"更新白板名言时出错: {ex.Message}", LogHelper.LogType.Warning);
|
||||
if (Settings.Appearance.ChickenSoupSource == 3 && BlackBoardWaterMark != null)
|
||||
{
|
||||
try { BlackBoardWaterMark.Text = "一言功能不可用"; } catch { }
|
||||
try { BlackBoardWaterMark.Text = "一言功能不可用"; } catch (Exception innerEx) { System.Diagnostics.Debug.WriteLine(innerEx); }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3344,7 +3344,7 @@ namespace Ink_Canvas
|
||||
|
||||
ToggleSwitchRunAtStartup.IsOn = false;
|
||||
}
|
||||
catch { }
|
||||
catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
|
||||
|
||||
ShowNotification("设置已重置为默认推荐设置~");
|
||||
}
|
||||
@@ -3363,7 +3363,7 @@ namespace Ink_Canvas
|
||||
LoadSettings(isStartup: false, skipAutoUpdateCheck: true);
|
||||
isLoaded = true;
|
||||
}
|
||||
catch { }
|
||||
catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -4423,7 +4423,7 @@ namespace Ink_Canvas
|
||||
var path = App.RootPath + settingsFileName;
|
||||
ProcessProtectionManager.WithWriteAccess(path, () => File.WriteAllText(path, text));
|
||||
}
|
||||
catch { }
|
||||
catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
|
||||
}
|
||||
|
||||
private void SCManipulationBoundaryFeedback(object sender, ManipulationBoundaryFeedbackEventArgs e)
|
||||
|
||||
@@ -623,7 +623,7 @@ namespace Ink_Canvas
|
||||
{
|
||||
inkCanvas.Strokes.Remove(lastTempStroke);
|
||||
}
|
||||
catch { }
|
||||
catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
|
||||
|
||||
lastTempStroke = stroke;
|
||||
inkCanvas.Strokes.Add(stroke);
|
||||
@@ -681,7 +681,7 @@ namespace Ink_Canvas
|
||||
{
|
||||
inkCanvas.Strokes.Remove(lastTempStroke);
|
||||
}
|
||||
catch { }
|
||||
catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
|
||||
|
||||
lastTempStroke = stroke;
|
||||
inkCanvas.Strokes.Add(stroke);
|
||||
@@ -870,7 +870,7 @@ namespace Ink_Canvas
|
||||
{
|
||||
inkCanvas.Strokes.Remove(lastTempStroke);
|
||||
}
|
||||
catch { }
|
||||
catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
|
||||
|
||||
lastTempStroke = stroke;
|
||||
inkCanvas.Strokes.Add(stroke);
|
||||
@@ -895,7 +895,7 @@ namespace Ink_Canvas
|
||||
{
|
||||
inkCanvas.Strokes.Remove(lastTempStroke);
|
||||
}
|
||||
catch { }
|
||||
catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
|
||||
|
||||
lastTempStroke = stroke;
|
||||
inkCanvas.Strokes.Add(stroke);
|
||||
@@ -912,7 +912,7 @@ namespace Ink_Canvas
|
||||
{
|
||||
inkCanvas.Strokes.Remove(lastTempStroke);
|
||||
}
|
||||
catch { }
|
||||
catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
|
||||
|
||||
lastTempStroke = stroke;
|
||||
inkCanvas.Strokes.Add(stroke);
|
||||
@@ -931,7 +931,7 @@ namespace Ink_Canvas
|
||||
{
|
||||
inkCanvas.Strokes.Remove(lastTempStroke);
|
||||
}
|
||||
catch { }
|
||||
catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
|
||||
|
||||
lastTempStroke = stroke;
|
||||
inkCanvas.Strokes.Add(stroke);
|
||||
@@ -957,7 +957,7 @@ namespace Ink_Canvas
|
||||
{
|
||||
inkCanvas.Strokes.Remove(lastTempStroke);
|
||||
}
|
||||
catch { }
|
||||
catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
|
||||
|
||||
lastTempStroke = stroke;
|
||||
inkCanvas.Strokes.Add(stroke);
|
||||
@@ -1019,7 +1019,7 @@ namespace Ink_Canvas
|
||||
{
|
||||
inkCanvas.Strokes.Remove(lastTempStrokeCollection);
|
||||
}
|
||||
catch { }
|
||||
catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
|
||||
|
||||
lastTempStrokeCollection = strokes;
|
||||
inkCanvas.Strokes.Add(strokes);
|
||||
@@ -1554,10 +1554,10 @@ namespace Ink_Canvas
|
||||
// 如果更新失败,确保清理状态
|
||||
if (lastTempStroke != null && inkCanvas.Strokes.Contains(lastTempStroke))
|
||||
{
|
||||
try { inkCanvas.Strokes.Remove(lastTempStroke); } catch { }
|
||||
try { inkCanvas.Strokes.Remove(lastTempStroke); } catch (Exception innerEx) { System.Diagnostics.Debug.WriteLine(innerEx); }
|
||||
}
|
||||
lastTempStroke = newStroke;
|
||||
try { inkCanvas.Strokes.Add(newStroke); } catch { }
|
||||
try { inkCanvas.Strokes.Add(newStroke); } catch (Exception innerEx) { System.Diagnostics.Debug.WriteLine(innerEx); }
|
||||
}
|
||||
}), DispatcherPriority.Render);
|
||||
}
|
||||
@@ -1612,11 +1612,11 @@ namespace Ink_Canvas
|
||||
{
|
||||
foreach (var stroke in lastTempStrokeCollection)
|
||||
{
|
||||
try { inkCanvas.Strokes.Remove(stroke); } catch { }
|
||||
try { inkCanvas.Strokes.Remove(stroke); } catch (Exception innerEx) { System.Diagnostics.Debug.WriteLine(innerEx); }
|
||||
}
|
||||
}
|
||||
lastTempStrokeCollection = newStrokeCollection;
|
||||
try { inkCanvas.Strokes.Add(newStrokeCollection); } catch { }
|
||||
try { inkCanvas.Strokes.Add(newStrokeCollection); } catch (Exception innerEx) { System.Diagnostics.Debug.WriteLine(innerEx); }
|
||||
}
|
||||
}), DispatcherPriority.Render);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Ink_Canvas.Helpers;
|
||||
using Ink_Canvas.Helpers;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
@@ -162,7 +162,7 @@ namespace Ink_Canvas
|
||||
|
||||
e.Stroke.StylusPoints = stylusPoints;
|
||||
}
|
||||
catch { }
|
||||
catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
|
||||
break;
|
||||
case 0:
|
||||
if (penType == 0)
|
||||
@@ -210,7 +210,7 @@ namespace Ink_Canvas
|
||||
|
||||
e.Stroke.StylusPoints = stylusPoints;
|
||||
}
|
||||
catch { }
|
||||
catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -603,7 +603,7 @@ namespace Ink_Canvas
|
||||
}
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
|
||||
}
|
||||
|
||||
InkToShapeProcess();
|
||||
@@ -630,7 +630,7 @@ namespace Ink_Canvas
|
||||
RandWindow.randSeed = (int)(_speed * 100000 * 1000);
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
|
||||
|
||||
switch (Settings.Canvas.InkStyle)
|
||||
{
|
||||
@@ -663,7 +663,7 @@ namespace Ink_Canvas
|
||||
|
||||
e.Stroke.StylusPoints = stylusPoints;
|
||||
}
|
||||
catch { }
|
||||
catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
|
||||
|
||||
break;
|
||||
case 0:
|
||||
@@ -712,12 +712,12 @@ namespace Ink_Canvas
|
||||
|
||||
e.Stroke.StylusPoints = stylusPoints;
|
||||
}
|
||||
catch { }
|
||||
catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
|
||||
|
||||
// 应用高级贝塞尔曲线平滑(仅在未进行直线拉直时)
|
||||
Debug.WriteLine($"墨迹平滑检查: UseAdvancedBezierSmoothing={Settings.Canvas.UseAdvancedBezierSmoothing}, wasStraightened={wasStraightened}");
|
||||
|
||||
@@ -453,7 +453,7 @@ namespace Ink_Canvas
|
||||
}
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
|
||||
}
|
||||
|
||||
|
||||
@@ -550,7 +550,7 @@ namespace Ink_Canvas
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
|
||||
}
|
||||
}
|
||||
else if (Settings.Automation.IsAutoFoldInEasiCamera && windowProcessName == "EasiCamera")
|
||||
@@ -617,7 +617,7 @@ namespace Ink_Canvas
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -699,7 +699,7 @@ namespace Ink_Canvas
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
|
||||
}
|
||||
}
|
||||
// 检查EasiCamera
|
||||
@@ -809,7 +809,7 @@ namespace Ink_Canvas
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -388,7 +388,7 @@ namespace Ink_Canvas
|
||||
TouchDownPointsList.Clear();
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
|
||||
|
||||
inkCanvas.ReleaseStylusCapture();
|
||||
ViewboxFloatingBar.IsHitTestVisible = true;
|
||||
@@ -415,7 +415,7 @@ namespace Ink_Canvas
|
||||
{
|
||||
if (e.StylusDevice.StylusButtons[1].StylusButtonState == StylusButtonState.Down) return;
|
||||
}
|
||||
catch { }
|
||||
catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
|
||||
|
||||
|
||||
var strokeVisual = GetStrokeVisual(e.StylusDevice.Id);
|
||||
@@ -424,7 +424,7 @@ namespace Ink_Canvas
|
||||
strokeVisual.Add(new StylusPoint(stylusPoint.X, stylusPoint.Y, stylusPoint.PressureFactor));
|
||||
strokeVisual.Redraw();
|
||||
}
|
||||
catch { }
|
||||
catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
|
||||
}
|
||||
|
||||
private StrokeVisual GetStrokeVisual(int id)
|
||||
@@ -729,7 +729,7 @@ namespace Ink_Canvas
|
||||
stroke.DrawingAttributes.Width *= md.Scale.X;
|
||||
stroke.DrawingAttributes.Height *= md.Scale.Y;
|
||||
}
|
||||
catch { }
|
||||
catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -744,7 +744,7 @@ namespace Ink_Canvas
|
||||
stroke.DrawingAttributes.Width *= md.Scale.X;
|
||||
stroke.DrawingAttributes.Height *= md.Scale.Y;
|
||||
}
|
||||
catch { }
|
||||
catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
|
||||
}
|
||||
|
||||
// 同时变换画布上的图片元素
|
||||
|
||||
@@ -95,7 +95,7 @@ namespace Ink_Canvas
|
||||
{
|
||||
LogHelper.WriteLogToFile($"视频展台摄像头错误: {e}", LogHelper.LogType.Error);
|
||||
}
|
||||
catch { }
|
||||
catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
|
||||
}
|
||||
|
||||
private void CameraService_FrameReceived(object sender, Bitmap frame)
|
||||
@@ -169,7 +169,7 @@ namespace Ink_Canvas
|
||||
img.Source = preview;
|
||||
img.Visibility = Visibility.Visible;
|
||||
}
|
||||
catch { }
|
||||
catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
|
||||
}
|
||||
|
||||
private const double VideoPresenterLiveFrameScreenRatio = 0.75;
|
||||
@@ -201,7 +201,7 @@ namespace Ink_Canvas
|
||||
InitializeElementTransform(img);
|
||||
BindElementEvents(img);
|
||||
}
|
||||
catch { }
|
||||
catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
|
||||
|
||||
_liveFrameImageByPage[page] = img;
|
||||
return img;
|
||||
@@ -323,7 +323,7 @@ namespace Ink_Canvas
|
||||
UpdateCurrentToolMode("select");
|
||||
HideSubPanels("select");
|
||||
}
|
||||
catch { }
|
||||
catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
|
||||
|
||||
// 立即用侧栏预览刷新一次
|
||||
if (VideoPresenterPreviewImage?.Source is BitmapImage bi)
|
||||
@@ -346,7 +346,7 @@ namespace Ink_Canvas
|
||||
inkCanvas.Children.Remove(img);
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -365,7 +365,7 @@ namespace Ink_Canvas
|
||||
|
||||
_liveFrameLayoutByPage[page] = (left, top, img.Width);
|
||||
}
|
||||
catch { }
|
||||
catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
|
||||
}
|
||||
|
||||
// 翻页后调用:根据该页状态恢复实时画面,并同步设备选择
|
||||
@@ -404,7 +404,7 @@ namespace Ink_Canvas
|
||||
_cameraService?.StartPreview(idx);
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
|
||||
}
|
||||
|
||||
private void BtnCapturePhoto_Click(object sender, RoutedEventArgs e)
|
||||
@@ -595,13 +595,13 @@ namespace Ink_Canvas
|
||||
}
|
||||
img.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
catch { }
|
||||
catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
|
||||
}
|
||||
}
|
||||
|
||||
try { _cameraService?.StopPreview(); } catch { }
|
||||
try { _cameraService?.StopPreview(); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
|
||||
}
|
||||
catch { }
|
||||
catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); }
|
||||
}
|
||||
|
||||
private static BitmapImage ConvertBitmapToBitmapImage(Bitmap bitmap)
|
||||
|
||||
Reference in New Issue
Block a user