internal static void RemoveLastItemFromOrderListByName(string itemName) { var orderWindow = WindowsManagement.GetOrderWindowInstance(); Order item = orderWindow.orderList.Where(x => x.Product.Name.Equals(itemName)).ToList().LastOrDefault(); orderWindow.orderList.Remove(item); }
private void OnRightClick(object sender, int id) { if (id == data.uID && contextMenu != null) { Point pt = Control.MousePosition; GDI.POINT point = new GDI.POINT(); point.x = pt.X; point.y = pt.Y; // this ensures that if we show the menu and then click on another window the menu will close WindowsManagement.SetForegroundWindow(messageSink.Handle); if (BeforeShowMenu != null) { BeforeShowMenu(this, EventArgs.Empty); } // call non public member of ContextMenu contextMenu.GetType().InvokeMember("OnPopup", BindingFlags.NonPublic | BindingFlags.InvokeMethod | BindingFlags.Instance, null, contextMenu, new Object[] { System.EventArgs.Empty }); WindowsManagement.TrackPopupMenuEx(contextMenu.Handle, 64, point.x, point.y, messageSink.Handle, IntPtr.Zero); if (AfterShowMenu != null) { AfterShowMenu(this, EventArgs.Empty); } } }
public void Move(GDI.RECT rcDest) { if (_clientRect == null) { GDI.RECT rect; WindowsManagement.GetClientRect(_hMediaWindow, out rect); _clientRect = rect; } if (_windowRect == null) { GDI.RECT rect; WindowsManagement.GetWindowRect(_hMediaWindow, out rect); _windowRect = rect; } if ((_clientRect.Value.right - _clientRect.Value.left) != (rcDest.right - rcDest.left) || (_clientRect.Value.bottom - _clientRect.Value.top) != (rcDest.bottom - rcDest.top)) { GDI.RECT rect; rect.left = rect.top = 0; rect.right = (rcDest.right - rcDest.left) + ((_windowRect.Value.right - _windowRect.Value.left) - (_clientRect.Value.right - _clientRect.Value.left)); rect.bottom = (rcDest.bottom - rcDest.top) + ((_windowRect.Value.bottom - _windowRect.Value.top) - (_clientRect.Value.bottom - _clientRect.Value.top)); if (WindowsManagement.MoveWindow(_hMediaWindow, rect.left, rect.top, rect.right, rect.bottom, false) != 0) { _windowRect = rect; _clientRect = rcDest; } } }
public void Move(GDI.RECT rcDest) { if (_hwnd != null) { WindowsManagement.MoveWindow(_hwnd, rcDest.left, rcDest.top, rcDest.right - rcDest.left, rcDest.bottom - rcDest.top, true); } }
public void ShowCursor() { if (_previousCursor != IntPtr.Zero) { WindowsManagement.SetCursor(_previousCursor); } }
private void OnIdle(object sender, EventArgs e) { bool CapsLock = (((ushort)WindowsManagement.GetKeyState(0x14 /*VK_CAPITAL*/)) & 0xffff) != 0; bool NumLock = (((ushort)WindowsManagement.GetKeyState(0x90 /*VK_NUMLOCK*/)) & 0xffff) != 0; bool Insert = (((ushort)WindowsManagement.GetKeyState(0x2D /*VK_INSERT*/)) & 0xffff) != 0; if (CapsLock && CapsPanel.Text.Length == 0) { CapsPanel.Text = "CAP"; } else if (!CapsLock && CapsPanel.Text.Length != 0) { CapsPanel.Text = ""; } if (NumLock && NumPanel.Text.Length == 0) { NumPanel.Text = "NUM"; } else if (!NumLock && NumPanel.Text.Length != 0) { NumPanel.Text = ""; } if (Insert && InsPanel.Text == "OVR") { InsPanel.Text = "INS"; } else if (!Insert && InsPanel.Text == "INS") { InsPanel.Text = "OVR"; } }
// [System.Security.Permissions.PermissionSet(System.Security.Permissions.SecurityAction.Demand, Name="FullTrust")] protected override void WndProc(ref Message m) { if (m.Msg == (int)WindowsMessages.WM_SIZE && nicon.icon != null) { WindowsManagement.GetWindowPlacement(Handle, ref wndpl); if (wndpl.showCmd == (uint)WindowsManagement.SW_SHOWMINIMIZED) { bParentMaximized = wndpl.flags != 0; if (nicon.nSysTray != 0) { nicon.Visible = true; parent.Visible = false; } bBeenMinimized = true; } else { if (!parent.Visible) { parent.Visible = true; } if (!nicon.bShowTrayAlways && nicon.nSysTray == 1) { nicon.Visible = false; } bBeenMinimized = false; } } base.WndProc(ref m); }
private void ShopCart_VisibleChanged(object sender, EventArgs e) { //TODO fix problem with showing data in grid view ShopCartGridView.DataSource = null; var orderWindow = WindowsManagement.GetOrderWindowInstance(); ShopCartGridView.DataSource = orderWindow.orderList; }
private SingleInstance(string guid) { string strAsm = Assembly.GetExecutingAssembly().GetName().Name; mutex = new Mutex(true, strAsm + guid, out bOwned); UWM_ARE_YOU_ME = WindowsManagement.RegisterWindowMessage("AreYouMe" + guid); if (!bOwned) WindowsManagement.EnumWindows(new WindowsManagement.EnumWindowsProc(searcher), IntPtr.Zero); }
private void OnWindowLoad(object sender, RoutedEventArgs e) { InnerFrame.NavigationUIVisibility = NavigationUIVisibility.Hidden; InnerFrame.Content = WindowsManagement.GetDashboardControlInstance(); DashboardButton.Background = activeButtonColor; DashboardButton.Focus(); }
public void HideCursor() { var previousCursor = WindowsManagement.SetCursor(IntPtr.Zero); if (previousCursor != IntPtr.Zero) { _previousCursor = previousCursor; } }
protected override void DestroyWindowCore(HandleRef hwnd) { if (_mediaWindow != null) { _mediaWindow.Dispose(); } WindowsManagement.DestroyWindow(hwnd.Handle); }
public void BringToFront() { if (hWndOther != IntPtr.Zero) { if (WindowsManagement.IsIconic(hWndOther) != 0) WindowsManagement.ShowWindowAsync(hWndOther, WindowsManagement.SW_RESTORE); WindowsManagement.SetForegroundWindow(hWndOther); } }
public void Invalidate() { if (_hwnd != IntPtr.Zero) { GDI.RECT rcClient; WindowsManagement.GetClientRect(_hwnd, out rcClient); WindowsManagement.InvalidateRect(_hwnd, ref rcClient, false); } }
private static IntPtr WndProc(IntPtr hWnd, uint msg, IntPtr wParam, IntPtr lParam) { WindowsManagement.WndProc proc; if (_procs.TryGetValue(hWnd, out proc)) { return(proc(hWnd, msg, wParam, lParam)); } else { return(WindowsManagement.DefWindowProc(hWnd, msg, wParam, lParam)); } }
private void Dispose(bool disposing) { // no matter what, destroy the handle if (_hwnd != IntPtr.Zero) { System.Diagnostics.Debug.Assert(_procs.ContainsKey(_hwnd), "Handle wasn't found in the inernal collection."); _procs.Remove(_hwnd); System.Diagnostics.Debug.Assert(!_procs.ContainsKey(_hwnd), "Handle wasn't removed from the inernal collection."); WindowsManagement.DestroyWindow(_hwnd); _hwnd = IntPtr.Zero; } }
private IntPtr CreateWindow(IntPtr hwndParent) { return(WindowsManagement.CreateWindowEx(0, WINDOW_CLASS_NAME, null, WindowsManagement.WS_VISIBLE | WindowsManagement.WS_CHILD | WindowsManagement.WS_CLIPSIBLINGS, 0, 0, 0, 0, hwndParent, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero)); }
public void SendCommandLineArgs() { string[] args = Environment.GetCommandLineArgs(); if (hWndOther != IntPtr.Zero) { IntPtr buffer = IntPtr.Zero; IntPtr pcds = IntPtr.Zero; MemoryStream stream = null; try { ArgsPacket packet = new ArgsPacket(); packet.guid = guid; packet.args = args; stream = new MemoryStream(); BinaryFormatter formatter = new BinaryFormatter(); formatter.Serialize(stream, packet); byte[] abyte = stream.ToArray(); buffer = Marshal.AllocCoTaskMem(abyte.Length); Marshal.Copy(abyte, 0, buffer, abyte.Length); WindowsManagement.COPYDATASTRUCT cds = new WindowsManagement.COPYDATASTRUCT(); cds.dwData = COPYDATA_TYPE_FILENAME; cds.cbData = abyte.Length; cds.lpData = buffer; pcds = Marshal.AllocCoTaskMem(Marshal.SizeOf(cds)); Marshal.StructureToPtr(cds, pcds, true); WindowsManagement.SendMessage(hWndOther, (int) WindowsMessages.WM_COPYDATA, IntPtr.Zero, pcds); } catch { } finally { if (buffer != IntPtr.Zero) Marshal.FreeCoTaskMem(buffer); if (pcds != IntPtr.Zero) Marshal.FreeCoTaskMem(pcds); if (stream != null) stream.Close(); } } }
protected override HandleRef BuildWindowCore(HandleRef hwndParent) { var hostHandle = WindowsManagement.CreateWindowEx(0, "static", "", WindowsManagement.WS_VISIBLE | WindowsManagement.WS_CHILD | WindowsManagement.WS_CLIPSIBLINGS, 0, 0, 0, 0, hwndParent.Handle, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero); return(new HandleRef(this, hostHandle)); }
private int searcher(IntPtr hWnd, IntPtr lParam) { int result; int ok = WindowsManagement.SendMessageTimeout(hWnd, (int)UWM_ARE_YOU_ME, IntPtr.Zero, IntPtr.Zero, WindowsManagement.SMTO_BLOCK | WindowsManagement.SMTO_ABORTIFHUNG, 100, out result); if (ok == 0) return 1; // ignore this and continue if (result == (int)UWM_ARE_YOU_ME) { // found it hWndOther = hWnd; return 0; // stop search } return 1; // continue }
private void ConfirmButton_Click(object sender, EventArgs e) { decimal currentPrice = decimal.Parse(CostBox.Text); if (currentPrice.Equals(0)) { MessageBox.Show(UserMessages.NoOrder, WindowsTypes.Information, MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (decimal.Parse(CostBox.Text) <= 150m) { Hide(); WindowsManagement.GetOrderConfirmInstance().Show(); } else { MessageBox.Show(UserMessages.HugeOrder, WindowsTypes.Information, MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private static WindowsManagement.WndProc _global_wnd_proc = WndProc; // prevent garbage collection of the delegate static DefaultMediaWindow() { WindowsManagement.WNDCLASSEX wcex = new WindowsManagement.WNDCLASSEX(); wcex.cbSize = (uint)Marshal.SizeOf(wcex); wcex.style = (uint)(WindowsManagement.ClassStyles.CS_HREDRAW | WindowsManagement.ClassStyles.CS_VREDRAW | WindowsManagement.ClassStyles.CS_DBLCLKS); wcex.lpfnWndProc += _global_wnd_proc; wcex.cbClsExtra = 0; wcex.cbWndExtra = 0; wcex.hInstance = IntPtr.Zero; wcex.hIcon = IntPtr.Zero; wcex.hCursor = WindowsManagement.LoadCursor(IntPtr.Zero, WindowsManagement.IDC_ARROW); wcex.hbrBackground = IntPtr.Zero; wcex.lpszMenuName = null; wcex.lpszClassName = WINDOW_CLASS_NAME; wcex.hIconSm = IntPtr.Zero; WindowsManagement.RegisterClassEx(ref wcex); }
private static void OnShowIconChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { var win = d as Window; if (win == null) { return; } var helper = new WindowInteropHelper(win); var hwnd = helper.EnsureHandle(); int extendedStyle = WindowsManagement.GetWindowLong(hwnd, WindowsManagement.GWL_EXSTYLE); WindowsManagement.SetWindowLong(hwnd, WindowsManagement.GWL_EXSTYLE, extendedStyle ^ WindowsManagement.WS_EX_DLGMODALFRAME); // Update the window's non-client area to reflect the changes WindowsManagement.SetWindowPos(hwnd, IntPtr.Zero, 0, 0, 0, 0, WindowsManagement.SWP_NOMOVE | WindowsManagement.SWP_NOSIZE | WindowsManagement.SWP_NOZORDER | WindowsManagement.SWP_FRAMECHANGED); }
public static void MoveWindow(this Window window, double left, double top, double width, double height) { int pxLeft = 0, pxTop = 0; if (left != 0 || top != 0) { window.TransformToPixels(left, top, out pxLeft, out pxTop); } int pxWidth, pxHeight; window.TransformToPixels(width, height, out pxWidth, out pxHeight); var helper = new WindowInteropHelper(window); WindowsManagement.MoveWindow(helper.Handle, pxLeft, pxTop, pxWidth, pxHeight, true); }
protected DialogResult ShowMyDialog(Form dlg) { if (bShowingFileDialog) { return(DialogResult.Cancel); } if (!bShowingDialog) { bShowingDialog = true; CurrentDialog = dlg; DialogResult result = dlg.ShowDialog(this); bShowingDialog = false; CurrentDialog = null; return(result); } else { WindowsManagement.SetForegroundWindow(CurrentDialog.Handle); return(DialogResult.Cancel); } }
private void AddExtrasProductToOrderList() { OrderWindow orderWindow = WindowsManagement.GetOrderWindowInstance(); TextBox foodTextBox = orderWindow.choosedCountBox; List <CheckBox> checkBoxes = new List <CheckBox>() { DoubleCheeseCheckbox, HamCheckbox, MushroomsCheckbox, SalamiCheckbox }; string foodName = foodTextBox.Name.Replace("CountBox", string.Empty); ProductsConfiguration.ExtrasProduct.TryGetValue(foodName, out Product value); var order = new Order(new Product(value.Name, value.Price, value.Extras)); List <string> extras = new List <string>(); foreach (CheckBox checkBox in checkBoxes) { if (checkBox.Checked) { checkBox.Checked = false; extras.Add(checkBox.Text); order.Product.Price += 2; } } if (extras.Any()) { order.Product.Extras.Add(extras.Aggregate((i, j) => string.Format("{0}, {1}", i, j))); } orderWindow.orderList.Add(order); UserActionHelpers.AddValueToCountBox(foodTextBox); Hide(); orderWindow.Show(); }
private void Confirm_Click(object sender, EventArgs e) { List <(bool, string)> validators = new List <(bool, string)>() { DataValidationManager.CheckEmail(EmailTextBox.Text), DataValidationManager.CheckFirstName(FirstNameTextBox.Text), DataValidationManager.CheckLastName(LastNameTextBox.Text), DataValidationManager.CheckAddress(AddressTextBox.Text), }; foreach (var validator in validators) { if (!string.IsNullOrEmpty(validator.Item2)) { MessageBox.Show(validator.Item2, WindowsTypes.Information, MessageBoxButtons.OK, MessageBoxIcon.Information); break; } } if (validators.TrueForAll(x => x.Item1)) { var emailBody = string.Format(emailBodyFormat, AddressTextBox.Text, FirstNameTextBox.Text, LastNameTextBox.Text, NotesTextBox.Text); EmailSendStatus emailSendStatus = new EmailManager().SendEmail(EmailTextBox.Text, "Pizza Application Order", emailBody); if (emailSendStatus.SendSuccessfully) { MessageBox.Show(UserMessages.EmailSended, WindowsTypes.Information, MessageBoxButtons.OK, MessageBoxIcon.Information); AddHistoryRecordToDatabase(); UserActionHelpers.ClearAllTextBoxData(); Hide(); WindowsManagement.GetMainWindowInstance().Show(); } else { MessageBox.Show(UserMessages.EmailFailedToSend, WindowsTypes.Information, MessageBoxButtons.OK, MessageBoxIcon.Information); } } }
private void AcceptButton_Click(object sender, RoutedEventArgs e) { if (UserTypesComboBox.SelectedItem == null) { MessageBox.Show(HotelManagmentLogic.Configuration.OutputMessages.MissingArgumentsMessage); return; } try { if (Enum.TryParse <UserType>(UserTypesComboBox.SelectedValue.ToString(), out UserType parsedUserType)) { AddToDatabaseResult result = UserDatabaseOperations.ChangeUserPermissions(selectedUser, parsedUserType); MessageBox.Show(result.Message); WindowsManagement.GetAdministrationControlInstance().RefreshRegisteredUserList(); this.Close(); } } catch (Exception ex) { ErrorLogger.AddLog(new ErrorLogger.Error(ex)); } }
protected virtual void OnFileOpen(object sender, EventArgs e) { if (!bShowingFileDialog && !bShowingDialog) { bShowingFileDialog = true; OpenFileDialog dlg = new OpenFileDialog(); dlg.Filter = "Video Files (*.avi;*.divx;*.mpg;*.mpeg;*.asf;*.wmv;*.mov;*.qt;*.vob;*.dat;*.mkv;*.flv;*.mp4;*.3gp;*.3g2;*.m1v;*.m2v)|" + "*.avi;*.divx;*.mpg;*.mpeg;*.asf;*.wmv;*.mov;*.qt;*.vob;*.dat;*.mkv;*.flv;*.mp4;*.3gp;*.3g2;*.m1v;*.m2v|All Files (*.*)|*.*"; if (dlg.ShowDialog(this) == DialogResult.OK) { strFileName = dlg.FileName; whatToPlay = Pvp.Core.MediaEngine.MediaSourceType.File; bPlayPending = true; } bShowingFileDialog = false; } else if (bShowingDialog) { WindowsManagement.SetForegroundWindow(CurrentDialog.Handle); } }
protected virtual IntPtr OnWndProc(IntPtr hWnd, uint msg, IntPtr wParam, IntPtr lParam) { MessageReceivedEventArgs args = new MessageReceivedEventArgs(hWnd, msg, wParam, lParam); OnMessageReceived(args); if (!args.ReturnValue.HasValue) { switch (msg) { case (int)WindowsMessages.WM_PAINT: var processed = Paint(); if (processed) { args.ReturnValue = IntPtr.Zero; } break; case (int)WindowsMessages.WM_ERASEBKGND: args.ReturnValue = new IntPtr(1); // return non-zero to indicate no further erasing is required break; case (int)WindowsMessages.WM_DISPLAYCHANGE: if (_VMRWindowlessControl != null) { _VMRWindowlessControl.DisplayModeChanged(); } else if (_VMRWindowlessControl9 != null) { _VMRWindowlessControl9.DisplayModeChanged(); } break; } } return(args.ReturnValue ?? WindowsManagement.DefWindowProc(hWnd, msg, wParam, lParam)); }