Exemplo n.º 1
0
        private void TryFindRenderingDialog(object state)
        {
            var desktopHwnds = EnumerateOpenedWindows.GetDesktopWindows();

            foreach (var hwnd1 in desktopHwnds)
            {
                uint windowProcessId;
                EnumerateOpenedWindows.GetWindowThreadProcessId(hwnd1, out windowProcessId);
                if (this.workerProcess.Id != windowProcessId)
                {
                    continue;
                }

                var windowText = EnumerateOpenedWindows.GetWindowText(hwnd1);
                if (windowText.Contains("Rendering"))
                {
                    var handles = EnumerateOpenedWindows.GetAllChildrenWindowHandles(hwnd1, long.MaxValue);
                    foreach (var ctrlHwnd in handles)
                    {
                        // ReSharper disable once InconsistentNaming
                        const int GWL_ID    = -12;
                        var       controlId = EnumerateOpenedWindows.GetWindowLongPtr(ctrlHwnd, GWL_ID);
                        if (controlId.ToInt32() == 0x544) // 0x544 corresponds to progressText label near rendering progress
                        {
                            this.progressLabelHwnd = ctrlHwnd;
                            this.findRenderDialogTimer?.Dispose();
                            this.findRenderDialogTimer = null;

                            this.StartWatchProgressTimer();
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        private void TryGetRenderProgress(object state)
        {
            if (EnumerateOpenedWindows.IsWindowVisible(this.progressLabelHwnd))
            {
                string changedText = null;

                lock (this.sync)
                {
                    var text = EnumerateOpenedWindows.GetWindowText(this.progressLabelHwnd);
                    if (!string.Equals(this.progressText, text))
                    {
                        this.progressText = text;
                        changedText       = text;
                    }
                }

                if (changedText != null)
                {
                    ProgressChanged?.Invoke(this, changedText);
                }
            }
            else
            {
                this.getRenderProgressTimer?.Dispose();
                this.getRenderProgressTimer = null;

                StartWaitForRenderTimer();

                this.progressText = string.Empty;
                ProgressChanged?.Invoke(this, this.progressText);
            }
        }
Exemplo n.º 3
0
 public void BringToFront()
 {
     if (this.Process != null)
     {
         EnumerateOpenedWindows.SetForegroundWindow(this.Process.MainWindowHandle);
     }
 }
Exemplo n.º 4
0
        private void TryFindRenderingDialog(object state)
        {
            if (!this.findMutex.WaitOne(TimeSpan.FromMilliseconds(100)))
            {
                return;
            }

            try
            {
                var desktopHwnds = EnumerateOpenedWindows.GetDesktopWindows();

                foreach (var hwnd1 in desktopHwnds)
                {
                    uint windowProcessId;
                    EnumerateOpenedWindows.GetWindowThreadProcessId(hwnd1, out windowProcessId);
                    if (this.workerProcess.Id != windowProcessId)
                    {
                        continue;
                    }

                    var windowText = EnumerateOpenedWindows.GetWindowText(hwnd1);
                    if (windowText.Contains("Rendering"))
                    {
                        var handles = EnumerateOpenedWindows.GetAllChildrenWindowHandles(hwnd1, long.MaxValue);
                        foreach (var ctrlHwnd in handles)
                        {
                            // ReSharper disable once InconsistentNaming
                            const int GWL_ID    = -12;
                            var       controlId = EnumerateOpenedWindows.GetWindowLongPtr(ctrlHwnd, GWL_ID);
                            if (controlId.ToInt32() == 0x544)
                            // 0x544 corresponds to progressText label near rendering progress
                            {
                                this.progressLabelHwnd = ctrlHwnd;
                                this.findRenderDialogTimer?.Dispose();
                                this.findRenderDialogTimer = null;

                                this.StartWatchProgressTimer();
                            }
                        }
                    }
                }
            }
            catch (Exception exc)
            {
                Trace.TraceError(exc.Message);
            }
            finally
            {
                this.findMutex.ReleaseMutex();
            }
        }
Exemplo n.º 5
0
        private void TryGetRenderProgress(object state)
        {
            if (!this.vrayMutex.WaitOne(TimeSpan.FromMilliseconds(100)))
            {
                return;
            }

            try
            {
                if (EnumerateOpenedWindows.IsWindowVisible(this.progressLabelHwnd))
                {
                    string changedText = null;

                    lock (this.sync)
                    {
                        var text = EnumerateOpenedWindows.GetWindowText(this.progressLabelHwnd);
                        if (!string.Equals(this.progressText, text))
                        {
                            this.progressText = text;
                            changedText       = text;
                        }
                    }

                    if (changedText != null)
                    {
                        ProgressChanged?.Invoke(this, changedText);
                    }
                }
                else
                {
                    this.getRenderProgressTimer?.Dispose();
                    this.getRenderProgressTimer = null;

                    StartWaitForRenderTimer();

                    this.progressText = string.Empty;
                    ProgressChanged?.Invoke(this, this.progressText);
                }
            }
            catch (Exception exc)
            {
                Trace.TraceError(exc.Message);
            }
            finally
            {
                this.vrayMutex.ReleaseMutex();
            }
        }