summaryrefslogtreecommitdiff
path: root/Codemerx/Gestor.Application/Views/Generic
diff options
context:
space:
mode:
Diffstat (limited to 'Codemerx/Gestor.Application/Views/Generic')
-rw-r--r--Codemerx/Gestor.Application/Views/Generic/BaseUserControl.cs104
-rw-r--r--Codemerx/Gestor.Application/Views/Generic/DragOverPopup.cs57
-rw-r--r--Codemerx/Gestor.Application/Views/Generic/ErrorWindow.cs101
-rw-r--r--Codemerx/Gestor.Application/Views/Generic/HosterWindow.cs460
4 files changed, 722 insertions, 0 deletions
diff --git a/Codemerx/Gestor.Application/Views/Generic/BaseUserControl.cs b/Codemerx/Gestor.Application/Views/Generic/BaseUserControl.cs
new file mode 100644
index 0000000..a389f17
--- /dev/null
+++ b/Codemerx/Gestor.Application/Views/Generic/BaseUserControl.cs
@@ -0,0 +1,104 @@
+using Gestor.Application.Helpers;
+using Gestor.Common.Validation;
+using Gestor.Model.Common;
+using System;
+using System.Runtime.CompilerServices;
+using System.Text.RegularExpressions;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Input;
+
+namespace Gestor.Application.Views.Generic
+{
+ public class BaseUserControl : UserControl
+ {
+ public virtual TipoTela Tela
+ {
+ get;
+ set;
+ }
+
+ public BaseUserControl()
+ {
+ }
+
+ public void DataAtual_OnDoubleClick(object sender, RoutedEventArgs e)
+ {
+ ((DatePicker)sender).SelectedDate = new DateTime?(Funcoes.GetNetworkTime().Date);
+ }
+
+ public void DatePicker_OnLostKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e)
+ {
+ DatePicker today = (DatePicker)sender;
+ today.Text = ValidationHelper.FormatDate(today.Text);
+ if (string.IsNullOrEmpty(today.Text))
+ {
+ today.DisplayDate = DateTime.Today;
+ }
+ }
+
+ public void DatePicker_PreviewKeyDown(object sender, KeyEventArgs e)
+ {
+ if (e.Key != Key.Return)
+ {
+ return;
+ }
+ DatePicker str = (DatePicker)sender;
+ DateTime date = Funcoes.GetNetworkTime().Date;
+ str.Text = date.ToString("dd/MM/yyyy");
+ }
+
+ public virtual void FormatarDocumento(object sender, RoutedEventArgs e)
+ {
+ TextBox textBox = (TextBox)sender;
+ textBox.Text = ValidationHelper.FormatDocument(textBox.Text);
+ }
+
+ public virtual void FormatarTelefone(object sender, RoutedEventArgs e)
+ {
+ TextBox textBox = (TextBox)sender;
+ if (string.IsNullOrWhiteSpace(textBox.Text))
+ {
+ return;
+ }
+ textBox.Text = ValidationHelper.FormatarTelefone(textBox.Text);
+ }
+
+ public virtual void LetrasHabilitacao(object sender, TextCompositionEventArgs e)
+ {
+ Regex regex = new Regex("[^a-eA-E]+");
+ e.Handled = regex.IsMatch(e.Text);
+ }
+
+ public virtual void Placa(object sender, TextCompositionEventArgs e)
+ {
+ Regex regex = new Regex("[^a-zA-Z0-9]+");
+ e.Handled = regex.IsMatch(e.Text);
+ }
+
+ public void ScrollViewer_PreviewMouseWheel(object sender, MouseWheelEventArgs e)
+ {
+ ScrollViewer scrollViewer = (ScrollViewer)sender;
+ scrollViewer.ScrollToVerticalOffset(scrollViewer.VerticalOffset - (double)e.Delta);
+ e.Handled = true;
+ }
+
+ public void SomenteCaracteres(object sender, TextCompositionEventArgs e)
+ {
+ Regex regex = new Regex("[^a-zA-Z]+$");
+ e.Handled = regex.IsMatch(e.Text);
+ }
+
+ public void SomenteData(object sender, TextCompositionEventArgs e)
+ {
+ Regex regex = new Regex("[^0-9/-]+");
+ e.Handled = regex.IsMatch(e.Text);
+ }
+
+ public virtual void SomenteNumeros(object sender, TextCompositionEventArgs e)
+ {
+ Regex regex = new Regex("[^0-9]+");
+ e.Handled = regex.IsMatch(e.Text);
+ }
+ }
+} \ No newline at end of file
diff --git a/Codemerx/Gestor.Application/Views/Generic/DragOverPopup.cs b/Codemerx/Gestor.Application/Views/Generic/DragOverPopup.cs
new file mode 100644
index 0000000..234ab52
--- /dev/null
+++ b/Codemerx/Gestor.Application/Views/Generic/DragOverPopup.cs
@@ -0,0 +1,57 @@
+using Gestor.Model.Domain.Ferramentas;
+using System;
+using System.CodeDom.Compiler;
+using System.ComponentModel;
+using System.Diagnostics;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Markup;
+
+namespace Gestor.Application.Views.Generic
+{
+ public class DragOverPopup : UserControl, IComponentConnector
+ {
+ internal TextBlock Titulo;
+
+ internal TextBlock Descricao;
+
+ private bool _contentLoaded;
+
+ public DragOverPopup(Tarefa tarefa)
+ {
+ this.InitializeComponent();
+ this.Titulo.Text = tarefa.get_Titulo();
+ this.Descricao.Text = tarefa.get_Descricao();
+ }
+
+ [DebuggerNonUserCode]
+ [GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
+ public void InitializeComponent()
+ {
+ if (this._contentLoaded)
+ {
+ return;
+ }
+ this._contentLoaded = true;
+ System.Windows.Application.LoadComponent(this, new Uri("/Gestor.Application;component/views/generic/dragoverpopup.xaml", UriKind.Relative));
+ }
+
+ [DebuggerNonUserCode]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ [GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
+ void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
+ {
+ if (connectionId == 1)
+ {
+ this.Titulo = (TextBlock)target;
+ return;
+ }
+ if (connectionId != 2)
+ {
+ this._contentLoaded = true;
+ return;
+ }
+ this.Descricao = (TextBlock)target;
+ }
+ }
+} \ No newline at end of file
diff --git a/Codemerx/Gestor.Application/Views/Generic/ErrorWindow.cs b/Codemerx/Gestor.Application/Views/Generic/ErrorWindow.cs
new file mode 100644
index 0000000..e1b7df0
--- /dev/null
+++ b/Codemerx/Gestor.Application/Views/Generic/ErrorWindow.cs
@@ -0,0 +1,101 @@
+using Gestor.Application.Helpers;
+using Gestor.Common.Validation;
+using Gestor.Model.API;
+using System;
+using System.CodeDom.Compiler;
+using System.ComponentModel;
+using System.Diagnostics;
+using System.Reflection;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Controls.Primitives;
+using System.Windows.Markup;
+
+namespace Gestor.Application.Views.Generic
+{
+ public class ErrorWindow : Window, IComponentConnector
+ {
+ internal TextBlock DescricaoErro;
+
+ internal RepeatButton ContinuarButton;
+
+ private bool _contentLoaded;
+
+ public ErrorWindow(TipoErro tipo, bool fecharSistema = false)
+ {
+ this.InitializeComponent();
+ this.HanddleErro(tipo);
+ if (fecharSistema)
+ {
+ this.ContinuarButton.Visibility = System.Windows.Visibility.Collapsed;
+ }
+ }
+
+ private void ContinuarButton_OnClick(object sender, RoutedEventArgs e)
+ {
+ base.Close();
+ }
+
+ private void HanddleErro(TipoErro tipo)
+ {
+ this.DescricaoErro.Text = ValidationHelper.GetCategory(tipo);
+ if (tipo != 3)
+ {
+ this.ContinuarButton.Visibility = System.Windows.Visibility.Visible;
+ return;
+ }
+ this.ContinuarButton.Visibility = System.Windows.Visibility.Collapsed;
+ }
+
+ [DebuggerNonUserCode]
+ [GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
+ public void InitializeComponent()
+ {
+ if (this._contentLoaded)
+ {
+ return;
+ }
+ this._contentLoaded = true;
+ System.Windows.Application.LoadComponent(this, new Uri("/Gestor.Application;component/views/generic/errorwindow.xaml", UriKind.Relative));
+ }
+
+ private void Reiniciar_OnClick(object sender, RoutedEventArgs e)
+ {
+ this.Shutdown();
+ }
+
+ private void Shutdown()
+ {
+ Instancia.ExcluirCfg();
+ Process.Start(System.Windows.Application.ResourceAssembly.Location, (ApplicationHelper.Conectado ? "INICIAR CONECTADO" : "INICIAR"));
+ System.Windows.Application.Current.Shutdown();
+ }
+
+ [DebuggerNonUserCode]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ [GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
+ void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
+ {
+ switch (connectionId)
+ {
+ case 1:
+ {
+ this.DescricaoErro = (TextBlock)target;
+ return;
+ }
+ case 2:
+ {
+ this.ContinuarButton = (RepeatButton)target;
+ this.ContinuarButton.Click += new RoutedEventHandler(this.ContinuarButton_OnClick);
+ return;
+ }
+ case 3:
+ {
+ ((RepeatButton)target).Click += new RoutedEventHandler(this.Reiniciar_OnClick);
+ return;
+ }
+ }
+ this._contentLoaded = true;
+ }
+ }
+} \ No newline at end of file
diff --git a/Codemerx/Gestor.Application/Views/Generic/HosterWindow.cs b/Codemerx/Gestor.Application/Views/Generic/HosterWindow.cs
new file mode 100644
index 0000000..01fa146
--- /dev/null
+++ b/Codemerx/Gestor.Application/Views/Generic/HosterWindow.cs
@@ -0,0 +1,460 @@
+using Gestor.Application.Actions;
+using MaterialDesignThemes.Wpf;
+using System;
+using System.CodeDom.Compiler;
+using System.ComponentModel;
+using System.Diagnostics;
+using System.Drawing;
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Threading;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Forms;
+using System.Windows.Input;
+using System.Windows.Interop;
+using System.Windows.Markup;
+using System.Windows.Media;
+using System.Windows.Shapes;
+using System.Windows.Shell;
+using System.Windows.Threading;
+
+namespace Gestor.Application.Views.Generic
+{
+ public class HosterWindow : Window, IComponentConnector
+ {
+ private bool _buttonClickable;
+
+ internal System.Windows.Shell.WindowChrome WindowChrome;
+
+ internal Grid Menu;
+
+ internal Grid MinimizeButton;
+
+ internal Path MinimizeButtonPath;
+
+ internal Grid MaximizeButton;
+
+ internal Path MaximizeButtonPath;
+
+ internal Grid CloseButton;
+
+ internal System.Windows.Controls.ContentControl ContentControl;
+
+ internal DialogHost HosterDialog;
+
+ internal MaterialDesignThemes.Wpf.DrawerHost DrawerHost;
+
+ internal MaterialDesignThemes.Wpf.Snackbar Snackbar;
+
+ private bool _contentLoaded;
+
+ public string Tela
+ {
+ get;
+ set;
+ }
+
+ public HosterWindow(System.Windows.Controls.ContentControl control, string titulo, double? x = null, double? y = null, bool canMaximize = false)
+ {
+ this.InitializeComponent();
+ Gestor.Application.Actions.Actions.EnableMainMenu = (Action<bool>)Delegate.Combine(Gestor.Application.Actions.Actions.EnableMainMenu, new Action<bool>(this.HabilitarMenu));
+ Gestor.Application.Actions.Actions.CloseHoster = (Action)Delegate.Combine(Gestor.Application.Actions.Actions.CloseHoster, new Action(this.Close));
+ this.MinimizeButton.MouseEnter += new System.Windows.Input.MouseEventHandler(HosterWindow.TopControls_OnMouseEnter);
+ this.MinimizeButton.MouseLeave += new System.Windows.Input.MouseEventHandler(this.TopControls_OnMouseLeave);
+ this.MaximizeButton.MouseEnter += new System.Windows.Input.MouseEventHandler(HosterWindow.TopControls_OnMouseEnter);
+ this.MaximizeButton.MouseLeave += new System.Windows.Input.MouseEventHandler(this.TopControls_OnMouseLeave);
+ this.CloseButton.MouseEnter += new System.Windows.Input.MouseEventHandler(HosterWindow.TopControls_OnMouseEnter);
+ this.CloseButton.MouseLeave += new System.Windows.Input.MouseEventHandler(this.TopControls_OnMouseLeave);
+ this.ContentControl.Content = control.Content;
+ this.ContentControl.DataContext = control.DataContext;
+ this.ContentControl.Tag = titulo;
+ this.MaximizeButtonPath.Data = Geometry.Parse((string)System.Windows.Application.Current.Resources["Restore"]);
+ if ((x.HasValue || y.HasValue) && !canMaximize)
+ {
+ base.WindowState = System.Windows.WindowState.Normal;
+ base.BorderThickness = new Thickness(1);
+ this.WindowChrome.ResizeBorderThickness = new Thickness(4);
+ this.WindowChrome.CaptionHeight = 30;
+ this.MaximizeButtonPath.Data = Geometry.Parse((string)System.Windows.Application.Current.Resources["Maximize"]);
+ }
+ if (x.HasValue)
+ {
+ if (x.Value >= base.Width)
+ {
+ if (!canMaximize)
+ {
+ base.MaxWidth = x.Value;
+ base.Width = x.Value;
+ }
+ base.MinWidth = x.Value;
+ }
+ else
+ {
+ base.MinWidth = x.Value;
+ if (!canMaximize)
+ {
+ base.Width = x.Value;
+ base.MaxWidth = x.Value;
+ }
+ }
+ }
+ if (y.HasValue)
+ {
+ if (y.Value >= base.Height)
+ {
+ if (!canMaximize)
+ {
+ base.MaxHeight = y.Value;
+ base.Height = y.Value;
+ }
+ base.MinHeight = y.Value;
+ }
+ else
+ {
+ base.MinHeight = y.Value;
+ if (!canMaximize)
+ {
+ base.Height = y.Value;
+ base.MaxHeight = y.Value;
+ }
+ }
+ }
+ if (!x.HasValue || !y.HasValue || canMaximize)
+ {
+ base.ResizeMode = System.Windows.ResizeMode.CanResize;
+ }
+ else
+ {
+ this.MaximizeButton.IsEnabled = false;
+ this.MinimizeButton.IsEnabled = false;
+ this.MaximizeButtonPath.Stroke = new SolidColorBrush(Colors.Gray);
+ this.MinimizeButtonPath.Stroke = new SolidColorBrush(Colors.Gray);
+ }
+ base.Title = titulo;
+ this.Tela = control.GetType().Name;
+ this.HosterDialog.set_Identifier(string.Format("Dialog{0}{1}", this.Tela, Guid.NewGuid()));
+ }
+
+ public void CloseButton_Click()
+ {
+ base.Close();
+ }
+
+ [DllImport("user32.dll", CharSet=CharSet.None, ExactSpelling=false)]
+ private static extern bool GetCursorPos(out HosterWindow.Point lpPoint);
+
+ [DllImport("user32.dll", CharSet=CharSet.None, ExactSpelling=false)]
+ private static extern bool GetMonitorInfo(IntPtr hMonitor, HosterWindow.Monitorinfo lpmi);
+
+ private void HabilitarMenu(bool enable)
+ {
+ this.Menu.IsEnabled = enable;
+ }
+
+ private void HosterWindow_OnLoaded(object sender, RoutedEventArgs e)
+ {
+ Task.Run(() => {
+ Thread.Sleep(500);
+ System.Windows.Application.Current.Dispatcher.Invoke(() => base.Topmost = false);
+ });
+ }
+
+ [DebuggerNonUserCode]
+ [GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
+ public void InitializeComponent()
+ {
+ if (this._contentLoaded)
+ {
+ return;
+ }
+ this._contentLoaded = true;
+ System.Windows.Application.LoadComponent(this, new Uri("/Gestor.Application;component/views/generic/hosterwindow.xaml", UriKind.Relative));
+ }
+
+ public void MaximizeButton_Click()
+ {
+ base.WindowState = (base.WindowState == System.Windows.WindowState.Normal ? System.Windows.WindowState.Maximized : System.Windows.WindowState.Normal);
+ }
+
+ public void MinimizeButton_Click()
+ {
+ base.WindowState = System.Windows.WindowState.Minimized;
+ }
+
+ [DllImport("user32.dll", CharSet=CharSet.None, ExactSpelling=false, SetLastError=true)]
+ private static extern IntPtr MonitorFromPoint(HosterWindow.Point pt, HosterWindow.MonitorOptions dwFlags);
+
+ protected sealed override void OnStateChanged(EventArgs e)
+ {
+ object obj;
+ base.BorderThickness = new Thickness((double)(base.WindowState != System.Windows.WindowState.Maximized));
+ System.Windows.Shell.WindowChrome windowChrome = this.WindowChrome;
+ if (base.WindowState == System.Windows.WindowState.Maximized)
+ {
+ obj = null;
+ }
+ else
+ {
+ obj = 4;
+ }
+ windowChrome.ResizeBorderThickness = new Thickness((double)obj);
+ this.WindowChrome.CaptionHeight = (double)((base.WindowState == System.Windows.WindowState.Maximized ? 32 : 29));
+ this.MaximizeButtonPath.Data = (base.WindowState == System.Windows.WindowState.Maximized ? Geometry.Parse((string)System.Windows.Application.Current.Resources["Restore"]) : Geometry.Parse((string)System.Windows.Application.Current.Resources["Maximize"]));
+ base.OnStateChanged(e);
+ }
+
+ private void SnackbarMessage_ActionClick(object sender, RoutedEventArgs e)
+ {
+ this.Snackbar.set_IsActive(false);
+ }
+
+ [DebuggerNonUserCode]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ [GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
+ void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
+ {
+ switch (connectionId)
+ {
+ case 1:
+ {
+ ((HosterWindow)target).Initialized += new EventHandler(this.Window_OnInitialized);
+ ((HosterWindow)target).Loaded += new RoutedEventHandler(this.HosterWindow_OnLoaded);
+ return;
+ }
+ case 2:
+ {
+ this.WindowChrome = (System.Windows.Shell.WindowChrome)target;
+ return;
+ }
+ case 3:
+ {
+ this.Menu = (Grid)target;
+ return;
+ }
+ case 4:
+ {
+ this.MinimizeButton = (Grid)target;
+ this.MinimizeButton.MouseLeftButtonDown += new MouseButtonEventHandler(this.TopControls_OnMouseLeftButtonDown);
+ this.MinimizeButton.MouseLeftButtonUp += new MouseButtonEventHandler(this.TopControls_OnMouseLeftButtonUp);
+ return;
+ }
+ case 5:
+ {
+ this.MinimizeButtonPath = (Path)target;
+ return;
+ }
+ case 6:
+ {
+ this.MaximizeButton = (Grid)target;
+ this.MaximizeButton.MouseLeftButtonDown += new MouseButtonEventHandler(this.TopControls_OnMouseLeftButtonDown);
+ this.MaximizeButton.MouseLeftButtonUp += new MouseButtonEventHandler(this.TopControls_OnMouseLeftButtonUp);
+ return;
+ }
+ case 7:
+ {
+ this.MaximizeButtonPath = (Path)target;
+ return;
+ }
+ case 8:
+ {
+ this.CloseButton = (Grid)target;
+ this.CloseButton.MouseLeftButtonDown += new MouseButtonEventHandler(this.TopControls_OnMouseLeftButtonDown);
+ this.CloseButton.MouseLeftButtonUp += new MouseButtonEventHandler(this.TopControls_OnMouseLeftButtonUp);
+ return;
+ }
+ case 9:
+ {
+ this.ContentControl = (System.Windows.Controls.ContentControl)target;
+ return;
+ }
+ case 10:
+ {
+ this.HosterDialog = (DialogHost)target;
+ return;
+ }
+ case 11:
+ {
+ this.DrawerHost = (MaterialDesignThemes.Wpf.DrawerHost)target;
+ return;
+ }
+ case 12:
+ {
+ this.Snackbar = (MaterialDesignThemes.Wpf.Snackbar)target;
+ return;
+ }
+ case 13:
+ {
+ ((SnackbarMessage)target).add_ActionClick(new RoutedEventHandler(this.SnackbarMessage_ActionClick));
+ return;
+ }
+ }
+ this._contentLoaded = true;
+ }
+
+ private static void TopControls_OnMouseEnter(object sender, System.Windows.Input.MouseEventArgs e)
+ {
+ ((Grid)sender).Background = (((Grid)sender).Name == "CloseButton" ? new SolidColorBrush(Colors.IndianRed) : new SolidColorBrush(Colors.Gray));
+ Path child = VisualTreeHelper.GetChild((Grid)sender, 0) as Path;
+ if (child != null)
+ {
+ child.Stroke = new SolidColorBrush(Colors.White);
+ }
+ }
+
+ private void TopControls_OnMouseLeave(object sender, System.Windows.Input.MouseEventArgs e)
+ {
+ this._buttonClickable = false;
+ ((Grid)sender).Background = new SolidColorBrush(Colors.Transparent);
+ Path child = VisualTreeHelper.GetChild((Grid)sender, 0) as Path;
+ if (child != null)
+ {
+ child.Stroke = new SolidColorBrush(Colors.White);
+ }
+ }
+
+ private void TopControls_OnMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
+ {
+ this._buttonClickable = true;
+ if (((Grid)sender).Name != "CloseButton")
+ {
+ ((Grid)sender).Background = new SolidColorBrush(Colors.DimGray);
+ }
+ else
+ {
+ ((Grid)sender).Background = new SolidColorBrush(Colors.Red);
+ Path child = VisualTreeHelper.GetChild((Grid)sender, 0) as Path;
+ if (child != null)
+ {
+ child.Stroke = new SolidColorBrush(Colors.Black);
+ return;
+ }
+ }
+ }
+
+ private void TopControls_OnMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
+ {
+ if (this._buttonClickable)
+ {
+ MethodInfo method = base.GetType().GetMethod(string.Concat(((Grid)sender).Name, "_Click"));
+ if (method == null)
+ {
+ return;
+ }
+ method.Invoke(this, null);
+ }
+ }
+
+ private void Window_OnInitialized(object sender, EventArgs e)
+ {
+ WindowInteropHelper windowInteropHelper = new WindowInteropHelper(this);
+ windowInteropHelper.EnsureHandle();
+ HwndSource hwndSource = HwndSource.FromHwnd(windowInteropHelper.Handle);
+ if (hwndSource == null)
+ {
+ return;
+ }
+ hwndSource.AddHook(new HwndSourceHook(this.WindowProc));
+ }
+
+ private IntPtr WindowProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
+ {
+ if (msg == 36)
+ {
+ this.WmGetMinMaxInfo(lParam);
+ }
+ return IntPtr.Zero;
+ }
+
+ private void WmGetMinMaxInfo(IntPtr lParam)
+ {
+ HosterWindow.Point point;
+ System.Drawing.Rectangle workingArea = Screen.FromHandle((new WindowInteropHelper(this)).Handle).WorkingArea;
+ base.MaxHeight = (double)workingArea.Height;
+ HosterWindow.GetCursorPos(out point);
+ IntPtr intPtr = HosterWindow.MonitorFromPoint(new HosterWindow.Point(0, 0), HosterWindow.MonitorOptions.MonitorDefaulttoprimary);
+ HosterWindow.Monitorinfo monitorinfo = new HosterWindow.Monitorinfo();
+ if (!HosterWindow.GetMonitorInfo(intPtr, monitorinfo))
+ {
+ return;
+ }
+ IntPtr intPtr1 = HosterWindow.MonitorFromPoint(point, HosterWindow.MonitorOptions.MonitorDefaulttonearest);
+ HosterWindow.Minmaxinfo structure = (HosterWindow.Minmaxinfo)Marshal.PtrToStructure(lParam, typeof(HosterWindow.Minmaxinfo));
+ if (!intPtr.Equals(intPtr1))
+ {
+ structure.ptMaxPosition.X = monitorinfo.rcMonitor.Left;
+ structure.ptMaxPosition.Y = monitorinfo.rcMonitor.Top;
+ structure.ptMaxSize.X = monitorinfo.rcMonitor.Right - monitorinfo.rcMonitor.Left;
+ structure.ptMaxSize.Y = monitorinfo.rcMonitor.Bottom - monitorinfo.rcMonitor.Top;
+ }
+ else
+ {
+ structure.ptMaxPosition.X = monitorinfo.rcWork.Left;
+ structure.ptMaxPosition.Y = monitorinfo.rcWork.Top;
+ structure.ptMaxSize.X = monitorinfo.rcWork.Right - monitorinfo.rcWork.Left;
+ structure.ptMaxSize.Y = monitorinfo.rcWork.Bottom - monitorinfo.rcWork.Top;
+ }
+ Marshal.StructureToPtr<HosterWindow.Minmaxinfo>(structure, lParam, true);
+ }
+
+ private struct Minmaxinfo
+ {
+ private readonly HosterWindow.Point ptReserved;
+
+ public HosterWindow.Point ptMaxSize;
+
+ public HosterWindow.Point ptMaxPosition;
+
+ private readonly HosterWindow.Point ptMinTrackSize;
+
+ private readonly HosterWindow.Point ptMaxTrackSize;
+ }
+
+ private class Monitorinfo
+ {
+ private readonly int cbSize;
+
+ public readonly HosterWindow.Rect rcMonitor;
+
+ public readonly HosterWindow.Rect rcWork;
+
+ private readonly int dwFlags;
+
+ public Monitorinfo()
+ {
+ }
+ }
+
+ private enum MonitorOptions : uint
+ {
+ MonitorDefaulttoprimary = 1,
+ MonitorDefaulttonearest = 2
+ }
+
+ public struct Point
+ {
+ public int X;
+
+ public int Y;
+
+ public Point(int x, int y)
+ {
+ this.X = x;
+ this.Y = y;
+ }
+ }
+
+ public struct Rect
+ {
+ public int Left;
+
+ public int Top;
+
+ public int Right;
+
+ public int Bottom;
+ }
+ }
+} \ No newline at end of file