Exemple #1
0
        public static void Error(Exception ex, string msg)
        {
            string message = Logging.Error(ex, msg);

            WPFDoEvents.InvokeInUIThread(() =>
            {
                MessageBox.Show(message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            });
        }
Exemple #2
0
        public static void Info(string msg, params object[] args)
        {
            string message = Logging.Info(msg, args);

            WPFDoEvents.InvokeInUIThread(() =>
            {
                MessageBox.Show(message, "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
            });
        }
Exemple #3
0
        public static void Error(string msg, params object[] args)
        {
            string message = Logging.Error(msg, args);

            WPFDoEvents.InvokeInUIThread(() =>
            {
                MessageBox.Show(message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            });
        }
Exemple #4
0
        public static void Warn(string msg, params object[] args)
        {
            string message = Logging.Warn(msg, args);

            WPFDoEvents.InvokeInUIThread(() =>
            {
                MessageBox.Show(message, "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            });
        }
Exemple #5
0
        public static bool AskErrorQuestion(string message, bool isError)
        {
            DialogResult dialog_result = DialogResult.Yes;

            WPFDoEvents.InvokeInUIThread(() =>
            {
                dialog_result = MessageBox.Show(message, isError ? "Problem" : "Question", MessageBoxButtons.YesNo,
                                                isError ? MessageBoxIcon.Error : MessageBoxIcon.Question);
            });
            return(dialog_result == DialogResult.Yes);
        }
Exemple #6
0
        public static bool AskErrorQuestion(string msg, bool isError, params object[] args)
        {
            string       message       = String.Format(msg, args);
            DialogResult dialog_result = DialogResult.Yes;

            WPFDoEvents.InvokeInUIThread(() =>
            {
                dialog_result = MessageBox.Show(message, isError ? "Problem" : "Question", MessageBoxButtons.YesNo,
                                                isError ? MessageBoxIcon.Error : MessageBoxIcon.Question);
            });
            return(dialog_result == DialogResult.Yes);
        }
Exemple #7
0
        public BackgroundFader(UserControl control, Color color_focussed, Color color_unfocussed)
        {
            WPFDoEvents.AssertThisCodeIsRunningInTheUIThread();

            this.control          = control;
            this.color_focussed   = color_focussed;
            this.color_unfocussed = color_unfocussed;

            this.control.Background = new SolidColorBrush(color_unfocussed);

            this.control.MouseEnter += DocumentNodeContentControl_MouseEnter;
            this.control.MouseLeave += DocumentNodeContentControl_MouseLeave;
        }
        private void BackgroundQueueRollAfterDrag(Point gamma)
        {
            current_scroll_gamma.X = gamma.X;
            current_scroll_gamma.Y = gamma.Y;

            // Utilities.LockPerfTimer l1_clk = Utilities.LockPerfChecker.Start();
            lock (thread_lock)
            {
                // l1_clk.LockPerfTimerStop();
                if (!is_someone_scrolling)
                {
                    is_someone_scrolling = true;
                    WPFDoEvents.InvokeAsyncInUIThread(() => RollAfterDrag(), DispatcherPriority.Background);
                }
            }
        }
Exemple #9
0
        internal /*virtual*/ void Dispose(bool disposing)    // sealed class doesn't allow 'virtual' + warning CS0628: 'WeakDependencyPropertyChangeNotifier.Dispose(bool)': new protected member declared in sealed class
        {
            Logging.Debug("WeakDependencyPropertyChangeNotifier::Dispose({0}) @{1}", disposing, dispose_count);

            WPFDoEvents.SafeExec(() =>
            {
                if (dispose_count == 0)
                {
                    BindingOperations.ClearBinding(this, ValueProperty);
                }
            }, must_exec_in_UI_thread: true);

            WPFDoEvents.SafeExec(() =>
            {
                _propertySource = null;
            });

            ++dispose_count;
        }
        public static void SafeExec(Action f, Dispatcher override_dispatcher = null, bool must_exec_in_UI_thread = false)
        {
            if ((!must_exec_in_UI_thread && override_dispatcher == null) || CurrentThreadIsUIThread())
            {
                // exec in same thread:
                try
                {
                    f();
                }
                catch (Exception ex)
                {
                    // NOTE: when you set a debugger breakpoint here, it should only be hit
                    // AFTER the Logging singleton instance has shut down:
                    // it's okay when we're *that far* into the application termination phase.
                    if (!Logging.HasShutDown)
                    {
                        Logging.Error(ex, "Failed safe-exec in same thread.");
                    }
                }
            }
            else
            {
                string trace = LogAssist.AppendStackTrace(null, "SafeExec");

                WPFDoEvents.InvokeInUIThread(() =>
                {
                    try
                    {
                        f();
                    }
                    catch (Exception ex)
                    {
                        if (!Logging.HasShutDown)
                        {
                            Logging.Error(ex, "Failed safe-exec in UI thread.\n  Invoker call trace:\n{0}", trace);
                        }
                    }
                }, override_dispatcher);
            }
        }
        protected virtual void Dispose(bool disposing)
        {
            Logging.Debug("AugmentedPopupAutoCloser::Dispose({0}) @{1}", disposing, dispose_count);

            WPFDoEvents.SafeExec(() =>
            {
                if (dispose_count == 0)
                {
                    // Get rid of managed resources
                    if (popup != null)
                    {
                        popup.IsOpen = false;
                    }
                }
            });

            WPFDoEvents.SafeExec(() =>
            {
                popup = null;
            });

            ++dispose_count;
        }
Exemple #12
0
        public WeakDependencyPropertyChangeNotifier(DependencyObject propertySource, PropertyPath property)
        {
            WPFDoEvents.AssertThisCodeIsRunningInTheUIThread();

            if (null == propertySource)
            {
                throw new ArgumentNullException("propertySource");
            }

            if (null == property)
            {
                throw new ArgumentNullException("property");
            }

            _propertySource = new WeakReference(propertySource);

            Binding binding = new Binding();

            binding.Path   = property;
            binding.Mode   = BindingMode.OneWay;
            binding.Source = propertySource;
            BindingOperations.SetBinding(this, ValueProperty, binding);
        }
        internal /*virtual*/ void Dispose(bool disposing)    // sealed class doesn't allow 'virtual' + warning CS0628: 'WeakDependencyPropertyChangeNotifier.Dispose(bool)': new protected member declared in sealed class
        {
            Logging.Debug("WeakDependencyPropertyChangeNotifier::Dispose({0}) @{1}", disposing, dispose_count);

            try
            {
                if (dispose_count == 0)
                {
                    WPFDoEvents.InvokeInUIThread(() =>
                    {
                        BindingOperations.ClearBinding(this, ValueProperty);
                    }, Dispatcher);
                }

                _propertySource = null;
            }
            catch (Exception ex)
            {
                Logging.Error(ex);
            }

            ++dispose_count;
        }
Exemple #14
0
        protected virtual void Dispose(bool disposing)
        {
            Logging.Debug("BackgroundFader::Dispose({0}) @{1}", disposing, dispose_count);

            WPFDoEvents.SafeExec(() =>
            {
                if (dispose_count == 0)
                {
                    // Get rid of managed resources / get rid of cyclic references:
                    if (null != control)
                    {
                        control.MouseEnter -= DocumentNodeContentControl_MouseEnter;
                        control.MouseLeave -= DocumentNodeContentControl_MouseLeave;
                    }
                }
            });

            WPFDoEvents.SafeExec(() =>
            {
                control = null;
            });

            ++dispose_count;
        }
Exemple #15
0
        public AugmentedPopupAutoCloser(Popup popup)
        {
            WPFDoEvents.AssertThisCodeIsRunningInTheUIThread();

            this.popup = popup;
        }