Esempio n. 1
0
        protected override void OnSourceInitialized(EventArgs e)
        {
            base.OnSourceInitialized(e);
            HwndSource hwndSource = PresentationSource.FromVisual(this) as HwndSource;

            if (hwndSource != null)
            {
                m_hwnd      = hwndSource.Handle;
                m_OldParent = MyWin32Interop.SetParent(m_hwnd, (IntPtr)MyWin32Interop.HWND_MESSAGE);
                m_OldTop    = Top;
                m_OldLeft   = Left;
                Left        = 10000;
                Top         = 10000;
            }
        }
Esempio n. 2
0
        protected override void OnSourceInitialized(EventArgs e)
        {
            IntPtr hWnd = (new WindowInteropHelper(this)).Handle;

            IntPtr style = MyWin32Interop.GetWindowLongPtr(hWnd, MyWin32Interop.GWL_EXSTYLE);

            style = (IntPtr)((int)style | MyWin32Interop.ExtendedWindowStyles.WS_EX_DLGMODALFRAME);
            MyWin32Interop.SetWindowLongPtr(hWnd, MyWin32Interop.GWL_EXSTYLE, style);

            if (m_DisableCloseButton)
            {
                style = MyWin32Interop.GetWindowLongPtr(hWnd, MyWin32Interop.GWL_STYLE);
                style = (IntPtr)((int)style & ~MyWin32Interop.WindowStyles.WS_SYSMENU);
                MyWin32Interop.SetWindowLongPtr(hWnd, MyWin32Interop.GWL_STYLE, style);
            }
        }
Esempio n. 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="CloseEvent"></param>
        /// <param name="OwnerWindow"></param>
        /// <param name="Prompt"></param>
        /// <param name="WndTitle"></param>
        /// <param name="ShowingPauseInMs">
        /// Через сколько милисекунд отобразиться окно. Нужно задавать значения кратные TimerIntervalInMs
        /// </param>
        private CWaitingWnd(int ID,
                            AutoResetEvent CloseEvent,
                            Window OwnerWindow,
                            string Prompt,
                            string WndTitle,
                            int ShowingPauseInMs = 0)
        {
            InitializeComponent();

            m_ID = ID;

            lblPleaseWait.Content = Properties.Resources.resPleaseWait; /* В xaml делать вывод этого текста (как обычно {Loc resPleaseWait}) нельзя,
                                                                         * т.к. в этом случае почему-то LocalizationManager привязывается к другому потоку и
                                                                         * больше не даёт менять свой язык */
            Title             = WndTitle;
            txtblkPrompt.Text = Prompt;

            m_CloseEvent  = CloseEvent;
            m_OwnerWindow = OwnerWindow;

            CTaskBarIconTuning.SetProgressState(enTaskbarStates.Indeterminate);

            DispatcherTimer tmrSearching = new DispatcherTimer()
            {
                Interval = new TimeSpan(0, 0, 0, 0, TimerIntervalInMs)
            };

            tmrSearching.Tick += (s, ev) =>
            {
                if (m_RemTimersCountForShow-- == 0)
                {
                    MyWin32Interop.SetParent(m_hwnd, m_OldParent);
                    Top  = m_OldTop;
                    Left = m_OldLeft;
                    Activate();
                }

                if (m_CloseEvent.WaitOne(0))
                {
                    tmrSearching.Stop();
                    m_AllowClose = true;
                    Close();

                    if (OwnerWindow != null && Application.Current != null && DBManagerApp.Current.Dispatcher != null)
                    {
                        ThreadManager.Instance.InvokeUI(new Action(() =>
                        {
                            // Этот try...catch обязателен, т.к. без него вылетим в ошибку при перезагрузке программы при смене конфигурации
                            try
                            {
                                if (OwnerWindow != DBManagerApp.MainWnd || !OwnerWindow.IsLoaded)
                                {
                                    if (!OwnerWindow.IsLoaded)
                                    {
                                        DBManagerApp.MainWnd.Activate();
                                    }
                                }
                                if (OwnerWindow.IsLoaded)
                                {
                                    OwnerWindow.Activate();
                                }
                            }
                            catch
                            { }
                        }));
                    }
                }
            };
            m_RemTimersCountForShow = ShowingPauseInMs / (int)Math.Max(1, tmrSearching.Interval.TotalMilliseconds);
            tmrSearching.Start();
        }