|
using System;
using System.ComponentModel.Composition;
using System.Runtime.InteropServices;
using System.Windows;
using System.Windows.Input;
using System.Windows.Interop;
using System.Windows.Media;
using MediaAssistant.Management;
using Application = System.Windows.Application;
using MouseEventArgs = System.Windows.Input.MouseEventArgs;
namespace MediaAssistant.Controls.TopPanel
{
[Export(typeof(ITopPanelView))]
public partial class TopPanelView:ITopPanelView
{
public TopPanelView()
{
InitializeComponent();
}
private void HandleToolButtonClocked(object sender, RoutedEventArgs e)
{
ToolMenu.PlacementTarget = (UIElement) sender;
ToolMenu.IsOpen = true;
}
public const int WM_NCLBUTTONDOWN = 0xA1;
public const int HT_CAPTION = 0x2;
[DllImport("user32.dll")]
public static extern int SendMessage(IntPtr hWnd, int Msg,
int wParam, int lParam);
[DllImportAttribute("user32.dll")]
public static extern bool ReleaseCapture();
public void move_window(object sender, MouseButtonEventArgs e)
{
if(Application.Current.MainWindow.WindowState==WindowState.Maximized)
return;
ReleaseCapture();
SendMessage(new WindowInteropHelper(Application.Current.MainWindow).Handle,
WM_NCLBUTTONDOWN, HT_CAPTION, 0);
}
private void EXIT(object sender, MouseButtonEventArgs e)
{
Application.Current.MainWindow.Close();
}
private void MINIMIZE(object sender, MouseButtonEventArgs e)
{
Application.Current.MainWindow.WindowState = WindowState.Minimized;
}
private void MAX_RESTORE(object sender, MouseButtonEventArgs e)
{
var mainWindow = Application.Current.MainWindow;
var windowState = mainWindow.WindowState == WindowState.Normal ? WindowState.Maximized : WindowState.Normal;
if(windowState==WindowState.Maximized)
{
var screen=WpfScreen.GetScreenFrom(mainWindow);
mainWindow.MaxHeight = screen.WorkingArea.Height;
mainWindow.MaxWidth = screen.WorkingArea.Width;
}
mainWindow.WindowState = windowState;
}
private void Activate_Title_Icons(object sender, MouseEventArgs e)
{
Close_btn.Fill = (ImageBrush)Resources["Close_act"];
Min_btn.Fill = (ImageBrush)Resources["Min_act"];
Max_btn.Fill = (ImageBrush)Resources["Max_act"];
Menu_btn.Opacity = 1;
}
private void Deactivate_Title_Icons(object sender, MouseEventArgs e)
{
Close_btn.Fill = (ImageBrush)Resources["Close_inact"];
Min_btn.Fill = (ImageBrush)Resources["Min_inact"];
Max_btn.Fill = (ImageBrush)Resources["Max_inact"];
Menu_btn.Opacity = 0.5;
}
private void Close_pressing(object sender, MouseButtonEventArgs e)
{
Close_btn.Fill = (ImageBrush)Resources["Close_pr"];
}
private void Min_pressing(object sender, MouseButtonEventArgs e)
{
Min_btn.Fill = (ImageBrush)Resources["Min_pr"];
}
private void Max_pressing(object sender, MouseButtonEventArgs e)
{
Max_btn.Fill = (ImageBrush)Resources["Max_pr"];
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.