Esempio n. 1
0
        protected virtual void Dispose(bool disposing)
        {
            Logging.Debug("BackgroundFader::Dispose({0}) @{1}", disposing, dispose_count);

            WPFDoEvents.InvokeInUIThread(() =>
            {
                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;
            });
        }
Esempio n. 2
0
        protected virtual void Dispose(bool disposing)
        {
            Logging.Debug("AugmentedPopupAutoCloser::Dispose({0}) @{1}", disposing, dispose_count);

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

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

                ++dispose_count;
            });
        }
Esempio n. 3
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);
            });
        }
Esempio n. 4
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);
            });
        }
Esempio n. 5
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);
            });
        }
Esempio n. 6
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);
            });
        }
Esempio n. 7
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);
        }
Esempio n. 8
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);
        }
Esempio n. 9
0
        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);
            }
        }
Esempio n. 10
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.InvokeInUIThread(() =>
            {
                WPFDoEvents.SafeExec(() =>
                {
                    if (dispose_count == 0)
                    {
                        BindingOperations.ClearBinding(this, ValueProperty);
                    }
                });

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

                ++dispose_count;
            });
        }