theme improvements

This commit is contained in:
2021-04-14 15:28:30 +03:00
parent 4faf7fecc1
commit 55e354b980
12 changed files with 221 additions and 318 deletions

View File

@@ -1,29 +1,31 @@
using System;
using Microsoft.Xaml.Behaviors;
using System;
using System.Collections;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Interactivity;
using System.Windows.Threading;
namespace BrightSharp.Behaviors
{
public class FilterDefaultViewTextBoxBehavior : Behavior<TextBox>
{
DispatcherTimer timer = new DispatcherTimer();
readonly DispatcherTimer _timer = new DispatcherTimer();
public FilterDefaultViewTextBoxBehavior()
{
timer.Tick += Timer_Tick;
_timer.Tick += Timer_Tick;
FilterDelay = TimeSpan.FromSeconds(1);
IgnoreCase = null; //Case sensitive if any char upper case
FilterStringPropertyName = "FilterString";
}
private void Timer_Tick(object sender, EventArgs e)
{
timer.Stop();
_timer.Stop();
if (ItemsSource != null)
{
var view = CollectionViewSource.GetDefaultView(ItemsSource);
@@ -90,7 +92,7 @@ namespace BrightSharp.Behaviors
public Predicate<object> CustomFilter { get; set; }
public TimeSpan FilterDelay { get { return timer.Interval; } set { timer.Interval = value; } }
public TimeSpan FilterDelay { get { return _timer.Interval; } set { _timer.Interval = value; } }
protected override void OnAttached()
{
@@ -101,14 +103,14 @@ namespace BrightSharp.Behaviors
private void AssociatedObject_TextChanged(object sender, TextChangedEventArgs e)
{
timer.Stop(); timer.Start();
_timer.Stop(); _timer.Start();
HasFilterText = !string.IsNullOrEmpty(AssociatedObject.Text);
}
protected override void OnDetaching()
{
AssociatedObject.TextChanged -= AssociatedObject_TextChanged;
timer.Tick -= Timer_Tick;
_timer.Tick -= Timer_Tick;
base.OnDetaching();
}
}

View File

@@ -2,6 +2,7 @@
using BrightSharp.Interop.Constants;
using BrightSharp.Interop.Structures;
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Windows;
using System.Windows.Interop;
@@ -38,6 +39,7 @@ namespace BrightSharp.Behaviors
}
}
[DebuggerStepThrough]
private IntPtr WindowProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
{
switch (msg)

View File

@@ -1,6 +1,6 @@
using System.Windows.Controls.Primitives;
using Microsoft.Xaml.Behaviors;
using System.Windows.Controls.Primitives;
using System.Windows.Input;
using System.Windows.Interactivity;
namespace BrightSharp.Behaviors
{

View File

@@ -1,23 +1,22 @@
using System.Windows;
using System.Windows.Interactivity;
using System.Windows.Interop;
using Microsoft.Xaml.Behaviors;
using System.Windows;
namespace BrightSharp.Behaviors
{
public class WindowMinMaxSizeBehavior : Behavior<Window>
{
private MinMaxSize_Logic logic;
private MinMaxSize_Logic _logic;
protected override void OnAttached()
{
base.OnAttached();
logic = new MinMaxSize_Logic(AssociatedObject);
logic.OnAttached();
_logic = new MinMaxSize_Logic(AssociatedObject);
_logic.OnAttached();
}
protected override void OnDetaching()
{
logic.OnDetaching();
_logic.OnDetaching();
base.OnDetaching();
}
}