Neuerstellung
This commit is contained in:
266
FSI.BT.Tools/FrmRadialMenu.xaml.cs
Normal file
266
FSI.BT.Tools/FrmRadialMenu.xaml.cs
Normal file
@@ -0,0 +1,266 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace FSI.BT.Tools
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for MainWindow.xaml
|
||||
/// </summary>
|
||||
public partial class FrmRadialMenu : Window, INotifyPropertyChanged
|
||||
{
|
||||
|
||||
public FrmRadialMenu()
|
||||
{
|
||||
InitializeComponent();
|
||||
DataContext = this;
|
||||
_isOpenHome = true;
|
||||
tbversion.Text = "v" + Assembly.GetExecutingAssembly().GetName().Version.Major + "." + Assembly.GetExecutingAssembly().GetName().Version.Minor;
|
||||
}
|
||||
|
||||
#region Home
|
||||
private bool _isOpenHome = true;
|
||||
public bool IsOpenHome
|
||||
{
|
||||
get
|
||||
{
|
||||
return _isOpenHome;
|
||||
}
|
||||
set
|
||||
{
|
||||
_isOpenHome = value;
|
||||
RaisePropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public ICommand CloseRadialMenuHome
|
||||
{
|
||||
get
|
||||
{
|
||||
return new RelayCommand(() => Visibility = Visibility.Hidden);
|
||||
}
|
||||
}
|
||||
|
||||
public ICommand OpenRadialMenuHome
|
||||
{
|
||||
get
|
||||
{
|
||||
return new RelayCommand(() =>
|
||||
{
|
||||
IsOpenHome = true;
|
||||
IsOpenEpl =
|
||||
IsOpenTools =
|
||||
IsOpenSie =
|
||||
IsOpenLinks = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Epl
|
||||
|
||||
private bool _isOpenEpl = false;
|
||||
public bool IsOpenEpl
|
||||
{
|
||||
get
|
||||
{
|
||||
return _isOpenEpl;
|
||||
}
|
||||
set
|
||||
{
|
||||
_isOpenEpl = value;
|
||||
RaisePropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public ICommand OpenRadialMenuEpl
|
||||
{
|
||||
get
|
||||
{
|
||||
return new RelayCommand(() =>
|
||||
{
|
||||
IsOpenEpl = true;
|
||||
IsOpenHome = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Tools
|
||||
|
||||
private bool _isOpenTools = false;
|
||||
public bool IsOpenTools
|
||||
{
|
||||
get
|
||||
{
|
||||
return _isOpenTools;
|
||||
}
|
||||
set
|
||||
{
|
||||
_isOpenTools = value;
|
||||
RaisePropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public ICommand OpenRadialMenuTools
|
||||
{
|
||||
get
|
||||
{
|
||||
return new RelayCommand(() =>
|
||||
{
|
||||
IsOpenTools = true;
|
||||
IsOpenHome = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Siemens
|
||||
|
||||
private bool _isOpenSie = false;
|
||||
public bool IsOpenSie
|
||||
{
|
||||
get
|
||||
{
|
||||
return _isOpenSie;
|
||||
}
|
||||
set
|
||||
{
|
||||
_isOpenSie = value;
|
||||
RaisePropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public ICommand OpenRadialMenuSie
|
||||
{
|
||||
get
|
||||
{
|
||||
return new RelayCommand(() =>
|
||||
{
|
||||
IsOpenSie = true;
|
||||
IsOpenHome = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Links
|
||||
|
||||
private bool _isOpenLinks = false;
|
||||
public bool IsOpenLinks
|
||||
{
|
||||
get
|
||||
{
|
||||
return _isOpenLinks;
|
||||
}
|
||||
set
|
||||
{
|
||||
_isOpenLinks = value;
|
||||
RaisePropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public ICommand OpenRadialMenuLinks
|
||||
{
|
||||
get
|
||||
{
|
||||
return new RelayCommand(() =>
|
||||
{
|
||||
IsOpenLinks = true;
|
||||
IsOpenPlantLinks =
|
||||
IsOpenHome = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Anlagen Links
|
||||
|
||||
private bool _isOpenPlantLinks = false;
|
||||
public bool IsOpenPlantLinks
|
||||
{
|
||||
get
|
||||
{
|
||||
return _isOpenPlantLinks;
|
||||
}
|
||||
set
|
||||
{
|
||||
_isOpenPlantLinks = value;
|
||||
RaisePropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public ICommand OpenRadialMenuPlantLinks
|
||||
{
|
||||
get
|
||||
{
|
||||
return new RelayCommand(() =>
|
||||
{
|
||||
IsOpenPlantLinks = true;
|
||||
IsOpenLinks = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
void RaisePropertyChanged([CallerMemberName] string? propertyName = null)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
|
||||
private void Window_Deactivated(object sender, EventArgs e)
|
||||
{
|
||||
Visibility = Visibility.Hidden;
|
||||
|
||||
IsOpenHome = true;
|
||||
IsOpenEpl =
|
||||
IsOpenTools =
|
||||
IsOpenSie =
|
||||
IsOpenLinks =
|
||||
IsOpenPlantLinks = false;
|
||||
}
|
||||
|
||||
|
||||
private void RadialMenuItem_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
int left = Convert.ToInt32(GetActualLeft() + this.ActualWidth / 2);
|
||||
int top = Convert.ToInt32(GetActuaTop() + this.ActualHeight / 2);
|
||||
System.Windows.Forms.Cursor.Position = new System.Drawing.Point(left, top);
|
||||
}
|
||||
|
||||
|
||||
private double GetActualLeft()
|
||||
{
|
||||
if (this.WindowState == WindowState.Maximized)
|
||||
{
|
||||
var leftField = typeof(Window).GetField("_actualLeft", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
|
||||
return (double)leftField.GetValue(this);
|
||||
}
|
||||
else
|
||||
return this.Left;
|
||||
}
|
||||
|
||||
private double GetActuaTop()
|
||||
{
|
||||
if (this.WindowState == WindowState.Maximized)
|
||||
{
|
||||
var topField = typeof(Window).GetField("_actualTop", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
|
||||
return (double)topField.GetValue(this);
|
||||
}
|
||||
else
|
||||
return this.Top;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user