Exemple #1
0
        public MainWindow()
        {
            WindowTraceLog.Initialize();

            if (!EnsureValidConfiguration())
            {
                Application.Current.Shutdown(Int32.MinValue);
                return;
            }

            InitializeComponent();

            var applicationTitle = App.Title;

            if (IsRunningAsAdministrator)
            {
                applicationTitle = $"{applicationTitle} (Administrator)";
            }

            Title = applicationTitle;

            RecentFileMenu.PlacementTarget = this;

            _findReplaceManager             = (FindReplaceManager)Application.Current.Resources["FindReplaceManager"];
            _findReplaceManager.OwnerWindow = this;
            _findReplaceManager.Editors     = _editorAdapters;

            _timerWorkingDocumentSave = new DispatcherTimer(TimeSpan.FromMinutes(3), DispatcherPriority.Normal, delegate { SaveWorkingDocuments(); }, Dispatcher);

            Loaded  += WindowLoadedHandler;
            Closing += WindowClosingHandler;
            Closed  += WindowClosedHandler;

            _windowDatabaseMonitor = new WindowDatabaseMonitor();
        }
Exemple #2
0
        public static void WriteLine(string message)
        {
            var messageWithTimestamp = $"{DateTime.Now:yyyy-MM-dd HH:mm:ss.fff} - {message}";

            Trace.WriteLine(messageWithTimestamp);

            WindowTraceLog.WriteLine(messageWithTimestamp);
        }
        public static void Initialize()
        {
            if (Instance != null)
            {
                throw new InvalidOperationException("Trace log window has been already initialized. ");
            }

            var contentBuilder = new StringBuilder();

            foreach (var message in _messages.OrderBy(m => m))
            {
                contentBuilder.AppendLine(message);
            }

            Instance = new WindowTraceLog {
                TraceLog = contentBuilder.ToString()
            };
            _messages = new ConcurrentBag <string>();
            WorkDocumentCollection.RestoreWindowProperties(Instance);
        }