Ejemplo n.º 1
0
        public void ShowWindow(IRemoteControl window)
        {
            if (window == null)
            {
                throw new ArgumentException("Window argument cannot be null");
            }

            bool   IsContract           = false;
            bool   IsAirspaceDecoration = false;
            object Control = null;

            try {
                Control = window.GetControl();
            } catch (SerializationException) {
                INativeHandleContract contract = window.GetControl(true) as INativeHandleContract;
                if (contract != null)
                {
                    Control              = FrameworkElementAdapters.ContractToViewAdapter(contract);
                    IsContract           = true;
                    IsAirspaceDecoration = window.EnableAirspaceFix;
                }
            }
            if (Control != null)
            {
                if (CurrentWindow != null)
                {
                    WindowStack.Push(CurrentWindow);
                }

                if (IsContract && IsAirspaceDecoration)
                {
                    Control = new AirspaceDecorator()
                    {
                        AirspaceMode = AirspaceMode.Redirect,
                        IsInputRedirectionEnabled  = true,
                        IsOutputRedirectionEnabled = true,
                        Background = Brushes.White,
                        Content    = Control
                    };
                }

                CurrentWindow = window;
                CurrentWindow.OnShow();
                UpdateTransition(Control, ((IsContract && !IsAirspaceDecoration) || (this.IsContract && !this.IsAirspaceDecoration))
                    ? TransitionType.Normal
                    : DefaultTransition);
                this.IsContract           = IsContract;
                this.IsAirspaceDecoration = IsAirspaceDecoration;
            }
        }
Ejemplo n.º 2
0
        // Bring to the front of the windows in the specified state.
        public void BringToFront(MdiWindow window, WindowState windowState)
        {
            int oldIndex = IndexOf(window);
            int newIndex = Count - 1;

            if (windowState == WindowState.Minimized)
            {
                bool foundSelf = false;

                for (newIndex = 0; newIndex < (Count - 1); newIndex++)
                {
                    if (Items[newIndex] == window)
                    {
                        foundSelf = true;
                    }

                    if (MdiPanel.GetWindowState(Items[newIndex]) != WindowState.Minimized)
                    {
                        break;
                    }
                }

                if (foundSelf)
                {
                    newIndex--;
                }
            }

            Move(oldIndex, newIndex);

            // HACK: how to coordinate Win32 ZOrder with WPF ZOrder?  This works, but assumes to many implementation details.
            if (VisualTreeHelper.GetChildrenCount(window) > 0)
            {
                AirspaceDecorator hwndClipper = VisualTreeHelper.GetChild(window, 0) as AirspaceDecorator;
                if (hwndClipper != null)
                {
                    if (VisualTreeHelper.GetChildrenCount(hwndClipper) > 0)
                    {
                        HwndSourceHost hwndSourceHost = VisualTreeHelper.GetChild(hwndClipper, 0) as HwndSourceHost;
                        if (hwndSourceHost != null)
                        {
                            HWND hwnd = new HWND(hwndSourceHost.Handle);
                            NativeMethods.SetWindowPos(hwnd, HWND.TOP, 0, 0, 0, 0, SWP.NOMOVE | SWP.NOSIZE);
                        }
                    }
                }
            }
        }