protected override IAsyncResult BeginExecute(AsyncCodeActivityContext context, AsyncCallback callback, object state) { Window currWindow = ActiveWindow.Get(context); try { if (currWindow == null) { PropertyDescriptor property = context.DataContext.GetProperties()[WindowActive.OpenBrowsersPropertyTag]; if (property == null) { property = context.DataContext.GetProperties()[WindowAttach.OpenBrowsersPropertyTag]; } if (property != null) { currWindow = property.GetValue(context.DataContext) as Window; } } Win32Api.Rect rect = new Win32Api.Rect(); Win32Api.GetWindowRect((IntPtr)currWindow.getWindowHwnd(), out rect); int oldWidth = rect.Right - rect.Left; int oldHeight = rect.Bottom - rect.Top; int oldPosX = rect.Left; int oldPosY = rect.Top; int newPosX = PosX.Get(context); int newPosY = PosY.Get(context); int newWidth = Width.Get(context); int newHeight = Height.Get(context); int defPosX = newPosX == 0 ? oldPosX : newPosX; int defPosY = newPosY == 0 ? oldPosY : newPosY; int defWidth = newWidth == 0 ? oldWidth : newWidth; int defHeight = newHeight == 0 ? oldHeight : newHeight; Win32Api.MoveWindow(currWindow.getWindowHwnd(), defPosX, defPosY, defWidth, defHeight, true); } catch (Exception e) { SharedObject.Instance.Output(SharedObject.enOutputType.Error, "关闭窗口错误产生", e.Message); if (ContinueOnError.Get(context)) { } else { throw; } } m_Delegate = new runDelegate(Run); return(m_Delegate.BeginInvoke(callback, state)); }
protected override IAsyncResult BeginExecute(AsyncCodeActivityContext context, AsyncCallback callback, object state) { Window currWindow = ActiveWindow.Get(context); IntPtr _handle = handle.Get(context); if (currWindow == null) { currWindow = new Window(); currWindow.setWindowHwnd((int)_handle); } try { var selStr = Selector.Get(context); UiElement element = UiElement.FromSelector(selStr); if (currWindow != null) { Win32Api.SendMessage((IntPtr)currWindow.getWindowHwnd(), Win32Api.WM_CLOSE, IntPtr.Zero, IntPtr.Zero); } else if (element != null) { Win32Api.SendMessage(element.WindowHandle, Win32Api.WM_CLOSE, IntPtr.Zero, IntPtr.Zero); } else { PropertyDescriptor property = context.DataContext.GetProperties()[WindowActive.OpenBrowsersPropertyTag]; if (property == null) { property = context.DataContext.GetProperties()[WindowAttach.OpenBrowsersPropertyTag]; } if (property != null) { Window getBrowser = property.GetValue(context.DataContext) as Window; Win32Api.SendMessage((IntPtr)getBrowser.getWindowHwnd(), Win32Api.WM_CLOSE, IntPtr.Zero, IntPtr.Zero); } } } catch (Exception e) { SharedObject.Instance.Output(SharedObject.enOutputType.Error, "关闭窗口错误产生", e.Message); if (ContinueOnError.Get(context)) { } else { throw; } } m_Delegate = new runDelegate(Run); return(m_Delegate.BeginInvoke(callback, state)); }
protected override IAsyncResult BeginExecute(AsyncCodeActivityContext context, AsyncCallback callback, object state) { Window currWindow = ActiveWindow.Get(context); try { if (currWindow != null) { Win32Api.SendMessage((IntPtr)currWindow.getWindowHwnd(), Win32Api.WM_SYSCOMMAND, (IntPtr)Win32Api.SC_MINIMIZE, IntPtr.Zero); } else { PropertyDescriptor property = context.DataContext.GetProperties()[WindowActive.OpenBrowsersPropertyTag]; if (property == null) { property = context.DataContext.GetProperties()[WindowAttach.OpenBrowsersPropertyTag]; } if (property != null) { Window getBrowser = property.GetValue(context.DataContext) as Window; Win32Api.SendMessage((IntPtr)getBrowser.getWindowHwnd(), Win32Api.WM_SYSCOMMAND, (IntPtr)Win32Api.SC_MINIMIZE, IntPtr.Zero); } } } catch (Exception e) { SharedObject.Instance.Output(SharedObject.enOutputType.Error, "窗口最小化错误产生", e.Message); if (ContinueOnError.Get(context)) { } else { throw; } } m_Delegate = new runDelegate(Run); return(m_Delegate.BeginInvoke(callback, state)); }