mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-04 08:00:16 -04:00
Moved application code to the Application layer
Imported Win10 project Code cleanup WIP - Use common UWP services for Win8.1 and Win10
This commit is contained in:
20
ModernKeePass10/Controls/ListViewWithDisable.cs
Normal file
20
ModernKeePass10/Controls/ListViewWithDisable.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using ModernKeePass.Application.Common.Interfaces;
|
||||
using ModernKeePass.Domain.Interfaces;
|
||||
|
||||
namespace ModernKeePass.Controls
|
||||
{
|
||||
public class ListViewWithDisable: ListView
|
||||
{
|
||||
protected override void PrepareContainerForItemOverride(DependencyObject element, object item)
|
||||
{
|
||||
base.PrepareContainerForItemOverride(element, item);
|
||||
|
||||
var binaryItem = item as IIsEnabled;
|
||||
if (!(element is ListViewItem container) || binaryItem == null) return;
|
||||
container.IsEnabled = binaryItem.IsEnabled;
|
||||
container.IsHitTestVisible = binaryItem.IsEnabled;
|
||||
}
|
||||
}
|
||||
}
|
56
ModernKeePass10/Controls/TextBoxWithButton.cs
Normal file
56
ModernKeePass10/Controls/TextBoxWithButton.cs
Normal file
@@ -0,0 +1,56 @@
|
||||
using System;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
|
||||
namespace ModernKeePass.Controls
|
||||
{
|
||||
public class TextBoxWithButton : TextBox
|
||||
{
|
||||
public event EventHandler<RoutedEventArgs> ButtonClick;
|
||||
|
||||
public string ButtonSymbol
|
||||
{
|
||||
get => (string)GetValue(ButtonSymbolProperty);
|
||||
set => SetValue(ButtonSymbolProperty, value);
|
||||
}
|
||||
public static readonly DependencyProperty ButtonSymbolProperty =
|
||||
DependencyProperty.Register(
|
||||
"ButtonSymbol",
|
||||
typeof(string),
|
||||
typeof(TextBoxWithButton),
|
||||
new PropertyMetadata("", (o, args) => { }));
|
||||
|
||||
public string ButtonTooltip
|
||||
{
|
||||
get => (string)GetValue(ButtonTooltipProperty);
|
||||
set => SetValue(ButtonTooltipProperty, value);
|
||||
}
|
||||
public static readonly DependencyProperty ButtonTooltipProperty =
|
||||
DependencyProperty.Register(
|
||||
"ButtonTooltip",
|
||||
typeof(string),
|
||||
typeof(TextBoxWithButton),
|
||||
new PropertyMetadata(string.Empty, (o, args) => { }));
|
||||
|
||||
public bool IsButtonEnabled
|
||||
{
|
||||
get => (bool)GetValue(IsButtonEnabledProperty);
|
||||
set => SetValue(IsButtonEnabledProperty, value);
|
||||
}
|
||||
public static readonly DependencyProperty IsButtonEnabledProperty =
|
||||
DependencyProperty.Register(
|
||||
"IsButtonEnabled",
|
||||
typeof(bool),
|
||||
typeof(TextBoxWithButton),
|
||||
new PropertyMetadata(true, (o, args) => { }));
|
||||
|
||||
protected override void OnApplyTemplate()
|
||||
{
|
||||
base.OnApplyTemplate();
|
||||
if (GetTemplateChild("ActionButton") is Button actionButton)
|
||||
{
|
||||
actionButton.Click += (sender, e) => ButtonClick?.Invoke(sender, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user