コード例 #1
0
ファイル: MainWindow.xaml.cs プロジェクト: skyclub66/SQLPad
        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();
        }
コード例 #2
0
ファイル: TraceLog.cs プロジェクト: xiaowuwang/SQLPad
        public static void WriteLine(string message)
        {
            var messageWithTimestamp = $"{DateTime.Now:yyyy-MM-dd HH:mm:ss.fff} - {message}";

            Trace.WriteLine(messageWithTimestamp);

            WindowTraceLog.WriteLine(messageWithTimestamp);
        }
コード例 #3
0
        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);
        }