public void ShowTreeView() { if (_videoNode == null) { LogService.Error("获取到CCTV视频列表失败,请检查配置是否正确!"); MessageBox.Show("获取到CCTV视频列表失败,请检查配置是否正确!"); return; } if (!VTSCore.Common.WindowStateDetect.ShowWindow(_treeClient)) { _treeClient = new CCTVTreeCtrlClient(); System.Windows.Interop.HwndSource winformWindow = (System.Windows.Interop.HwndSource.FromDependencyObject(this) as System.Windows.Interop.HwndSource); if (winformWindow != null) { new System.Windows.Interop.WindowInteropHelper(_treeClient) { Owner = winformWindow.Handle } } ; _treeClient.VideoNode = _videoNode; _treeClient.Show(); _treeClient.OnPlayVadio += ShowCCTVWindow; } }
private void importFromData() { try { if (!VTSCore.Common.WindowStateDetect.ShowWindow(_importAreaByStringClient)) { _importAreaByStringClient = new ImportAreaByStringClient(); _importAreaByStringClient.Show(); System.Windows.Interop.HwndSource winformWindow = (System.Windows.Interop.HwndSource.FromDependencyObject(this) as System.Windows.Interop.HwndSource); if (winformWindow != null) { new System.Windows.Interop.WindowInteropHelper(_importAreaByStringClient) { Owner = winformWindow.Handle } } ; _importAreaByStringClient.OnSaving += OnSavingByString; } } catch (Exception ex) { MessageBox.Show("请输入需要导入的数据,并用','号隔开!!(区域名称,经度,纬度,经度,纬度,…)" + Environment.NewLine + ex.Message); } }
/// <summary> /// This is the method that responds to the TextInput event. /// </summary> /// <param name="e">Event arguments</param> protected override void OnTextInput(TextCompositionEventArgs e) { base.OnTextInput(e); if (e.Handled) { return; } // We don't use win32 menu's, so we need to emulate the win32 // behavior for hitting Space while in menu mode. Alt+Space // will be handled as a SysKey by the DefaultWindowProc, but // Alt, then Space needs to be special cased here because we prevent win32. // from entering menu mode. In WPF the equiv. of win32 menu mode is having // a main menu with focus and no menu items opened. if (e.UserInitiated && e.Text == " " && IsMainMenu && (CurrentSelection == null || !CurrentSelection.IsSubmenuOpen)) { // We need to exit menu mode because it holds capture and prevents // the system menu from showing. IsMenuMode = false; System.Windows.Interop.HwndSource source = PresentationSource.CriticalFromVisual(this) as System.Windows.Interop.HwndSource; if (source != null) { source.ShowSystemMenu(); e.Handled = true; } } }
/// <inheritdoc /> protected override void OnSourceInitialized(EventArgs e) { base.OnSourceInitialized(e); _windowSource = System.Windows.Interop.HwndSource.FromDependencyObject(this) as System.Windows.Interop.HwndSource; Visibility = System.Windows.Visibility.Hidden; _windowSource.AddHook(INTV.Shared.Interop.DeviceManagement.DeviceChange.Handler); }
public void MakeMenu(Window mainWindow) { if (Directory.Exists("Themes")) { FileInfo[] localthemes = new DirectoryInfo("Themes").GetFiles(); foreach (var item in localthemes) { this.VisualThemesList.Add(new VisualTheme { ShortName = item.Name, FullName = item.FullName }); } } // Create a new submenu structure IntPtr hMenu = TMP.Shared.SystemMenu.AddSysMenuSubMenu(); if (hMenu != IntPtr.Zero) { // Build submenu items of hMenu uint index = 0; for (int i = 0; i < this.VisualThemesList.Count; i++) { TMP.Shared.SystemMenu.AddSysMenuSubItem(this.VisualThemesList[i].ShortName, index, VISUAL_THEME_BASE_ID + index, hMenu); index++; } // Now add to main system menu (position 6) TMP.Shared.SystemMenu.AddSysMenuItem("Визуальная тема", 0, 6, hMenu); TMP.Shared.SystemMenu.AddSysMenuItem("-", 0, 7, IntPtr.Zero); } // Attach our WndProc handler to this Window System.Windows.Interop.HwndSource source = System.Windows.Interop.HwndSource.FromHwnd(new System.Windows.Interop.WindowInteropHelper(mainWindow).Handle); source.AddHook(new System.Windows.Interop.HwndSourceHook(this.WndProc)); }
private void mainWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e) { IntPtr windowHandle = (new System.Windows.Interop.WindowInteropHelper(this)).Handle; System.Windows.Interop.HwndSource src = System.Windows.Interop.HwndSource.FromHwnd(windowHandle); src.RemoveHook(new System.Windows.Interop.HwndSourceHook(this.WndProc)); }
public static string BrowseFolder(string description, string selectedPath, System.Windows.Interop.HwndSource source) { string folderPath = string.Empty; try { Environment.SpecialFolder rootFolder = Environment.SpecialFolder.Desktop; System.Windows.Forms.FolderBrowserDialog folderBrowser = new System.Windows.Forms.FolderBrowserDialog(); folderBrowser.Description = description; folderBrowser.RootFolder = rootFolder; folderBrowser.SelectedPath = selectedPath; System.Windows.Forms.IWin32Window iWin32Window = new ShellWin32Window(source); System.Windows.Forms.DialogResult result = folderBrowser.ShowDialog(iWin32Window); if (result == System.Windows.Forms.DialogResult.OK) { folderPath = folderBrowser.SelectedPath; } } catch (System.Exception ex) { folderPath = null; LogHelper.UILogger.Debug("BrowseFolder Failed,", ex); } finally { } return(folderPath); }
bool IMessageFilter.PreFilterMessage(ref Message m) { if (Form.tcMain.SelectedTabPage == Form.tpLibrary && m.Msg == MSG.WM_MOUSEWHEEL) { System.Windows.Rect rect = new System.Windows.Rect(0, 0, Form.LibraryControl.PicturePreview.ActualWidth, Form.LibraryControl.PicturePreview.ActualHeight); System.Windows.Point pt = System.Windows.Input.Mouse.GetPosition(Form.LibraryControl.PicturePreview); if (rect.Contains(pt)) { System.Windows.Interop.HwndSource hwndSource = (System.Windows.Interop.HwndSource)System.Windows.Interop.HwndSource.FromVisual(Form.LibraryControl.PicturePreview); NativeMethods.SendMessage(hwndSource.Handle, m.Msg, m.WParam, m.LParam); return(true); } } if (m.Msg == MSG.WM_KEYDOWN || m.Msg == MSG.WM_SYSKEYDOWN || m.Msg == MSG.WM_SYSKEYUP || m.Msg == MSG.WM_KEYUP) { if (Form.tcMain.SelectedTabPage == Form.tpLibrary) { if (Form.LibraryControl.filterTree.ClientRectangle.Contains(Form.LibraryControl.filterTree.PointToClient(Control.MousePosition))) { Form.LibraryControl.TemporaryUpdateFilterOperation(true); } } //else if(Form.tcMain.SelectedTabPage == Form.tpViewer) { // Form.ViewerControl.ProcessKeyDown((Keys)m.WParam.ToInt32()); //} } return(false); }
public void DeregisterFromPnpEvents() { System.Windows.Interop.HwndSource hwndSource = System.Windows.Interop.HwndSource.FromHwnd(new System.Windows.Interop.WindowInteropHelper(this).Handle); hwndSource.RemoveHook(new System.Windows.Interop.HwndSourceHook(WndProc)); Win32Api.UnregisterDeviceNotification(hwndSource.Handle); }
private ConfigCCTV ReadSetting(ConfigCCTV config) { if (config == null) { config = new ConfigCCTV(); } form = new VTSCore.Layers.Tracks.CCTV.CCTVConfigForm(config.Clone()); System.Windows.Interop.HwndSource winformWindow = (System.Windows.Interop.HwndSource.FromDependencyObject(this) as System.Windows.Interop.HwndSource); if (winformWindow != null) { new System.Windows.Interop.WindowInteropHelper(form) { Owner = winformWindow.Handle } } ; if (form.ShowDialog().Value) { return(form.Config); } else { return(null); } }
protected override async void OnInitialized(EventArgs e) { base.OnInitialized(e); if (WindowUtil.IsDesingMode()) { return; } await System.Threading.Tasks.Task.Yield(); await _mapNotification.InitCompletion; _locator = LocatorAndBorder.Instance; _radars = new RadarsCanvas(_locator); this.AddChild(_radars); _locator.OnMapRefreshed += _locator_OnMapRefreshed; _mouseEventSource.MouseDown.Subscribe(onMouseDown); activatingStatus = ActivatingStatus.Instance; _menuBarInfo = MenuBarsBaseInfo.Instance; _menuBarInfo.PropertyChanged += _menuBarInfo_PropertyChanged; _winformWindow = (System.Windows.Interop.HwndSource.FromDependencyObject(this) as System.Windows.Interop.HwndSource); _radars.InitHwndSourse(_winformWindow); _locator_OnMapRefreshed(); }
public void MainWindow_SourceInitialized(IntPtr windowHandle) { System.Windows.Interop.HwndSource src = System.Windows.Interop.HwndSource.FromHwnd(windowHandle); src.AddHook(new System.Windows.Interop.HwndSourceHook(WndProc)); MainWindowHandleForAvantesCallback = windowHandle; }
public ShellWin32Window(System.Windows.Interop.HwndSource source = null) { if (!source.IsNull()) { _handle = source.Handle; } }
protected override void OnSourceInitialized(EventArgs e) { base.OnSourceInitialized(e); _hwndSoure = System.Windows.Interop.HwndSource.FromHwnd(new System.Windows.Interop.WindowInteropHelper(this).Handle); _hwndSoure?.AddHook(HwndHook); }
public EdgeBarPage AddWpfEdgeBarPage <TControl>(EdgeBarPageConfiguration config, SolidEdgeFramework.SolidEdgeDocument document) where TControl : System.Windows.Controls.Page, new() { uint WS_VISIBLE = 0x10000000; uint WS_CHILD = 0x40000000; uint WS_MAXIMIZE = 0x01000000; TControl control = Activator.CreateInstance <TControl>(); var edgeBarPage = AddEdgeBarPage( config: config, controlHandle: IntPtr.Zero, document: document); var hwndSource = new System.Windows.Interop.HwndSource(new System.Windows.Interop.HwndSourceParameters { PositionX = 0, PositionY = 0, Height = 0, Width = 0, ParentWindow = edgeBarPage.Handle, WindowStyle = (int)(WS_VISIBLE | WS_CHILD | WS_MAXIMIZE) }) { RootVisual = control }; edgeBarPage.ChildObject = hwndSource; return(edgeBarPage); }
private void showRadarAreaClient() { if (!VTSCore.Common.WindowStateDetect.ShowWindow(_radarAreaClient)) { _radarAreaClient = new RadarAreaClient(); System.Windows.Interop.HwndSource winformWindow = (System.Windows.Interop.HwndSource.FromDependencyObject(this) as System.Windows.Interop.HwndSource); if (winformWindow != null) { new System.Windows.Interop.WindowInteropHelper(_radarAreaClient) { Owner = winformWindow.Handle } } ; _radarAreaClient.Show(); } else { _radarAreaClient.WindowState = WindowState.Normal; } } #region 海图分析 FeatureSelectUI _featureSelectUI;
/// <summary> /// 返回打开的目录路径 /// </summary> private string OpenFolder() { System.Windows.Forms.FolderBrowserDialog dlg = new System.Windows.Forms.FolderBrowserDialog(); System.Windows.Interop.HwndSource source = PresentationSource.FromVisual(this) as System.Windows.Interop.HwndSource; System.Windows.Forms.IWin32Window win = new OpenFolderDialog(source.Handle); System.Windows.Forms.DialogResult result = dlg.ShowDialog(win); return(dlg.SelectedPath); }
private void RemoveHook() { if (_HwndSource != null) { _HwndSource.RemoveHook(TaskDialogHelpers.CloseButtonHook); _HwndSource = null; } }
// We should clean up our hotkeys to avoid having orphaned events in Windows protected override void OnClosed(EventArgs e) { _source.RemoveHook(HwndHook); _source = null; // Ensure that all events are deregistered properly hotKeyManager.Clear(); base.OnClosed(e); }
/// <summary>Wraps an Exsisting instance of an object</summary> /// <param name="o">Instance of the object to wrap</param> public static Microsoft.Test.Security.Wrappers.HwndSourceSW Wrap(System.Windows.Interop.HwndSource o) { if (o == null) { return(null); } return(new Microsoft.Test.Security.Wrappers.HwndSourceSW(o)); }
private void btnLogPathBrower_Click(object sender, RoutedEventArgs e) { System.Windows.Forms.FolderBrowserDialog dlg = new System.Windows.Forms.FolderBrowserDialog(); System.Windows.Interop.HwndSource source = PresentationSource.FromVisual(this) as System.Windows.Interop.HwndSource; System.Windows.Forms.IWin32Window win = new OldWindow(source.Handle); System.Windows.Forms.DialogResult result = dlg.ShowDialog(win); txtLOGLocation.Text = dlg.SelectedPath; }
/// <summary> /// /// </summary> public void folderBrowser() { System.Windows.Forms.FolderBrowserDialog dlg = new System.Windows.Forms.FolderBrowserDialog(); System.Windows.Interop.HwndSource source = PresentationSource.FromVisual(this) as System.Windows.Interop.HwndSource; System.Windows.Forms.IWin32Window win = new OldWindow(source.Handle); System.Windows.Forms.DialogResult result = dlg.ShowDialog(win); tbFilePath.Text = dlg.SelectedPath; }
private void AddHook() { _HwndSource = PresentationSource.FromVisual(this) as System.Windows.Interop.HwndSource; if (_HwndSource != null) { _HwndSource.AddHook(TaskDialogHelpers.CloseButtonHook); } }
private void updateCCTVFormOwner() { System.Windows.Interop.HwndSource winformWindow = (System.Windows.Interop.HwndSource.FromDependencyObject(this) as System.Windows.Interop.HwndSource); if (winformWindow != null) { WindowOwnerBinding.SetOwner(_trackVideoForm.Handle, winformWindow.Handle); } }
private void WindowLoadedHandler(object sender, RoutedEventArgs e) { _queryCancelAutoPlayMessageId = NativeMethods.RegisterWindowMessage("QueryCancelAutoPlay"); System.Windows.Interop.HwndSource source = System.Windows.Interop.HwndSource.FromHwnd(new System.Windows.Interop.WindowInteropHelper(this).Handle); source.AddHook(WndProc); }
private void TextBox_MouseDoubleClick(object sender, MouseButtonEventArgs e) { System.Windows.Interop.HwndSource source = PresentationSource.FromVisual(this) as System.Windows.Interop.HwndSource; System.Windows.Forms.IWin32Window win = new OldWindow(source.Handle); if (fs.ShowDialog(win) == System.Windows.Forms.DialogResult.OK) { VM_MA.SavePath = fs.DirectoryPath; } }
protected override void OnSourceInitialized(EventArgs e) { base.OnSourceInitialized(e); System.Windows.Interop.HwndSource hwndSource = PresentationSource.FromVisual(this) as System.Windows.Interop.HwndSource; if (hwndSource != null) { hwndSource.AddHook(new System.Windows.Interop.HwndSourceHook(Hook)); } }
void SourceInitializedHandler(object sender, EventArgs e) { IntPtr handle = (new System.Windows.Interop.WindowInteropHelper(this)).Handle; System.Windows.Interop.HwndSource hwndSource = System.Windows.Interop.HwndSource.FromHwnd(handle); if (hwndSource != null) { hwndSource.AddHook(WindowProc); } }
protected override void OnActivated(EventArgs e) { base.OnActivated(e); hwnd = new System.Windows.Interop.WindowInteropHelper(this); if (hwnd.Handle != null && hwnd.Handle != IntPtr.Zero) { nativeSource = System.Windows.Interop.HwndSource.FromHwnd(hwnd.Handle); nativeSource.AddHook(OnWindowMessage); } }
/// <summary> /// 获取窗体句柄 /// </summary> /// <param name="window">窗体</param> public static IntPtr GetWindowHwndSource(DependencyObject window, bool isHwnd = true) { var formDependency = System.Windows.Interop.HwndSource.FromDependencyObject(window); System.Windows.Interop.HwndSource winformWindow = (formDependency as System.Windows.Interop.HwndSource); if (isHwnd) { Hwnd = winformWindow; } return(winformWindow.Handle); }
protected override void OnActivated(EventArgs e) { base.OnActivated(e); hwnd = new System.Windows.Interop.WindowInteropHelper(this); if (hwnd.Handle!=null && hwnd.Handle!=IntPtr.Zero) { nativeSource = System.Windows.Interop.HwndSource.FromHwnd(hwnd.Handle); nativeSource.AddHook(OnWindowMessage); } }
public MainWindow() { SourceInitialized += (s, e) => { hwndSource = (System.Windows.Interop.HwndSource)PresentationSource.FromVisual(this); }; InitializeComponent(); listBox.SelectionChanged += (s, e) => { listBox.SelectedItem = null; }; ((CMWebServiceData)Resources["serviceData"]).PropertyChanged += (s, e) => { if (e.PropertyName == "IsError") { App.Current.Dispatcher.Invoke(() => { TaskbarItemInfo.Overlay = ((CMWebServiceData)Resources["serviceData"]).IsError ? (ImageSource)Resources["overlayImage"] : null; }); } }; }
public override void OnCreateParent(IntPtr hwndParent) { var parameters = new System.Windows.Interop.HwndSourceParameters("CS_Options"); parameters.PositionX = 0; parameters.PositionY = 0; parameters.Height = (int)m_page.Height; parameters.Width = (int)m_page.Width; parameters.ParentWindow = hwndParent; const int WS_CHILD = 0x40000000; const int WS_VISIBLE = 0x10000000; parameters.WindowStyle = WS_VISIBLE | WS_CHILD; m_source = new System.Windows.Interop.HwndSource(parameters); m_source.SizeToContent = System.Windows.SizeToContent.WidthAndHeight; m_source.AddHook(new System.Windows.Interop.HwndSourceHook(ChildHwndSourceHook)); m_source.CompositionTarget.BackgroundColor = System.Windows.SystemColors.WindowBrush.Color; m_source.RootVisual = m_page; }
private void RemoveHook() { if (_HwndSource != null) { _HwndSource.RemoveHook(TaskDialogHelpers.CloseButtonHook); _HwndSource = null; } }
void Overlay_Loaded(object sender, System.Windows.RoutedEventArgs e) { _overlaySource = (System.Windows.Interop.HwndSource)System.Windows.PresentationSource.FromVisual(_overlay); int exStyle = (int)GetWindowLong(_overlaySource.Handle, GWL_EXSTYLE); exStyle |= WS_EX_TOOLWINDOW; SetWindowLong(_overlaySource.Handle, GWL_EXSTYLE, (IntPtr)exStyle); SetWindowPos(_overlaySource.Handle, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); SetWindowPos(Handle, _overlaySource.Handle, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); var m = _overlaySource.CompositionTarget.TransformFromDevice; _wpfScale.X = m.M11; _wpfScale.Y = m.M22; _overlay.Left = (Left + _chromeTopLeft.Width) * _wpfScale.X; _overlay.Top = (Top + _chromeTopLeft.Height) * _wpfScale.Y; _overlay.Width = ClientSize.Width * _wpfScale.X; _overlay.Height = ClientSize.Height * _wpfScale.Y; _overlaySource.AddHook(Overlay_WndProc); }
private void AddHook() { _HwndSource = PresentationSource.FromVisual(this) as System.Windows.Interop.HwndSource; if (_HwndSource != null) { _HwndSource.AddHook(TaskDialogHelpers.CloseButtonHook); } }