Beispiel #1
0
        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));
        }