Improved Performance
- Removed redundant calls by disabling event handling when an operation is created or moved, as well as before the end of construction - Also removed unused and ordered namespaces
This commit is contained in:
parent
4b50f44985
commit
b7f6158300
|
@ -17,6 +17,7 @@ namespace BFR
|
|||
public partial class MainWindow : Window
|
||||
{
|
||||
public readonly AvaloniaProperty[] HandledProperties = new AvaloniaProperty[] { TextBox.TextProperty, ComboBox.SelectedItemProperty, NumericUpDown.ValueProperty, CheckBox.IsCheckedProperty };
|
||||
private bool HandleEvents = false;
|
||||
|
||||
public async Task OpenDirectoryButtonClick() => OpenDirectory(await new OpenFolderDialog() { Directory = WorkingDirectory }.ShowAsync(this));
|
||||
public void OpenDirectory(string directory)
|
||||
|
@ -28,7 +29,7 @@ namespace BFR
|
|||
|
||||
public void FilterChanged(object sender, AvaloniaPropertyChangedEventArgs e)
|
||||
{
|
||||
if(HandledProperties.Contains(e.Property))
|
||||
if(HandledProperties.Contains(e.Property) && HandleEvents)
|
||||
Filter(); // Bind to PropertyChanged
|
||||
}
|
||||
public void Filter()
|
||||
|
@ -43,7 +44,7 @@ namespace BFR
|
|||
|
||||
public void PreviewChanged(object sender, AvaloniaPropertyChangedEventArgs e)
|
||||
{
|
||||
if (HandledProperties.Contains(e.Property))
|
||||
if (HandledProperties.Contains(e.Property) && HandleEvents)
|
||||
Preview(); // Bind to PropertyChanged
|
||||
}
|
||||
public void Preview()
|
||||
|
@ -69,11 +70,13 @@ namespace BFR
|
|||
|
||||
public void AddOperation()
|
||||
{
|
||||
HandleEvents = false;
|
||||
if (Operations.Count >= 1)
|
||||
Operations.Insert(
|
||||
SelectedOperation >= 0 ? SelectedOperation + 1 : Operations.Count,
|
||||
OperationTypes[SelectedOperationType].Create());
|
||||
else Operations.Add(OperationTypes[SelectedOperationType].Create());
|
||||
HandleEvents = true;
|
||||
Preview();
|
||||
}
|
||||
|
||||
|
@ -87,11 +90,13 @@ namespace BFR
|
|||
|
||||
public void MoveOperation(object sender, SpinEventArgs e)
|
||||
{
|
||||
HandleEvents = false;
|
||||
if (Operations.Count > 1)
|
||||
if (e.Direction == SpinDirection.Increase && SelectedOperation > 0)
|
||||
Operations.Move(SelectedOperation, SelectedOperation - 1);
|
||||
else if (e.Direction == SpinDirection.Decrease && SelectedOperation < Operations.Count - 1)
|
||||
Operations.Move(SelectedOperation, SelectedOperation + 1);
|
||||
HandleEvents = true;
|
||||
Preview();
|
||||
}
|
||||
|
||||
|
@ -122,6 +127,7 @@ namespace BFR
|
|||
AvaloniaXamlLoader.Load(this);
|
||||
DataContext = this;
|
||||
OpenDirectory(Environment.OSVersion.Platform == PlatformID.Win32NT ? @"C:\Users" : @"\home");
|
||||
HandleEvents = true;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,5 +1,4 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.Xml.Serialization;
|
||||
using System.Linq;
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System.Linq;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Xml.Serialization;
|
||||
using System.Collections.Generic;
|
||||
|
||||
|
@ -6,7 +7,6 @@ using Avalonia;
|
|||
|
||||
using BFR.Helpers;
|
||||
using BFR.DataModels;
|
||||
using System;
|
||||
|
||||
namespace BFR.Operations
|
||||
{
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using System.Xml.Serialization;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using Avalonia;
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Globalization;
|
||||
using System.Collections.Generic;
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user