mirror of
https://github.com/chylex/Backup-Essentials.git
synced 2025-08-18 20:24:55 +02:00
BackupEssentials
Backup
Controls
ButtonMainMenu.cs
ButtonTitleBar.cs
Data
Pages
Properties
Resources
Sys
Utils
App.xaml
App.xaml.cs
AppPageManager.cs
BackupEssentials.csproj
BackupReportWindow.xaml
BackupReportWindow.xaml.cs
BackupWindow.xaml
BackupWindow.xaml.cs
MainWindow.xaml
MainWindow.xaml.cs
Simple Styles.xaml
TestingWindow.xaml
TestingWindow.xaml.cs
.gitignore
BackupEssentials.sln
LICENSE
README.md
51 lines
1.8 KiB
C#
51 lines
1.8 KiB
C#
using System;
|
|
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Threading;
|
|
|
|
namespace BackupEssentials.Controls{
|
|
public class ButtonMainMenu:Button{
|
|
public static readonly DependencyProperty ClickPageProperty = DependencyProperty.Register("ClickPage",typeof(string),typeof(ButtonMainMenu));
|
|
|
|
public string ClickPage {
|
|
get { return (string)base.GetValue(ClickPageProperty); }
|
|
set { base.SetValue(ClickPageProperty,(string)value); }
|
|
}
|
|
|
|
private bool IsCheckedVar;
|
|
|
|
public bool IsChecked {
|
|
get { return IsCheckedVar; }
|
|
set { IsCheckedVar = value; VisualStateManager.GoToState(this,IsCheckedVar ? "Pressed" : "Normal",true); }
|
|
}
|
|
|
|
public ButtonMainMenu(){
|
|
SizeChanged += (sender, args) => {
|
|
if (IsChecked)VisualStateManager.GoToState(this,"Pressed",false);
|
|
};
|
|
}
|
|
|
|
public override void OnApplyTemplate(){
|
|
base.OnApplyTemplate();
|
|
|
|
foreach(VisualStateGroup group in VisualStateManager.GetVisualStateGroups((FrameworkElement)Template.FindName("MainMenuButtonGrid",this))){
|
|
group.CurrentStateChanging += (sender, args) => {
|
|
if (IsChecked && !args.NewState.Name.Equals("Pressed")){
|
|
DispatcherTimer timer = new DispatcherTimer();
|
|
timer.Interval = new TimeSpan(1);
|
|
|
|
timer.Tick += (sender2, args2) => {
|
|
if (IsChecked){
|
|
VisualStateManager.GoToState(this,"Pressed",false);
|
|
timer.Stop();
|
|
}
|
|
};
|
|
|
|
timer.Start();
|
|
}
|
|
};
|
|
}
|
|
}
|
|
}
|
|
}
|