1
0
mirror of https://github.com/chylex/Backup-Essentials.git synced 2025-08-25 23:35:11 +02:00
Files
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
TestingWindow.xaml
TestingWindow.xaml.cs
.gitignore
BackupEssentials.sln
LICENSE
README.md
Backup-Essentials/BackupEssentials/Controls/ButtonMainMenu.cs

55 lines
2.0 KiB
C#

using BackupEssentials.Utils;
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
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(){
if (!WindowsVersion.IsFullySupported())((Label)Template.FindName("label",this)).Effect = null;
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();
}
};
}
}
}
}