Write() public method

public Write ( string message ) : void
message string
return void
コード例 #1
0
 public override void Write(string message)
 {
     if (!enabled)
     {
         return;
     }
     tw.Write(message);
 }
コード例 #2
0
ファイル: App.xaml.cs プロジェクト: beavis28/power8
        /// <summary>
        /// Application initializer. Performs compatibility check, 
        /// starts diagnostics if required, works settings around,
        /// and initializes the process of generating of internal data structures.
        /// </summary>
        public App()
        {
            if(Util.OsIs.VistaExact) //If run on shit
            {
                MessageBox.Show(
                    Power8.Properties.Resources.Err_VistaDetected,
                    Power8.Properties.NoLoc.Stg_AppShortName, MessageBoxButton.OK, MessageBoxImage.Error);
                Environment.Exit(2); //means: OS not found
            }
            //Global error mode setter - in 1st place to fix nasty startup error on Win10x86
            API.SetErrorMode(API.ErrMode.FailCriticalErrors);
            
            //Power8s in our session but with different pid
            foreach (var p in Process.GetProcessesByName("Power8")
                                     .Where(p => p.SessionId == Proc.SessionId && p.Id != Proc.Id))
            {
                p.Kill();
            }

            Util.MainDisp = Dispatcher; //store main thread dispatcher. Widely used in Application.

#if DEBUG
            //System.Threading.Thread.CurrentThread.CurrentUICulture = System.Globalization.CultureInfo.GetCultureInfo("ru");

            //Error handling and detection
            var l = new TextWriterTraceListener(Environment.ExpandEnvironmentVariables(@"%temp%\p8log.txt"));
            l.Write("\r\n\r\nPower8 Log opened at " + DateTime.Now + "\r\n\r\n");
            Debug.AutoFlush = true;
            Debug.Listeners.Add(l);
#endif
            
            DispatcherUnhandledException += (sender, e) => Util.DispatchUnhandledException(e.Exception);
            AppDomain.CurrentDomain.UnhandledException += HandleUnhandled;

            var dbRoot = Util.GetSettingsIndependentDbRoot();
            try
            {
                var ids = Directory.GetFiles(dbRoot, "*" + ClientIDExtension);
                string clientId;
                if (ids.Length == 0)
                {
                    clientId = Guid.NewGuid().ToString();
                    File.Create(dbRoot + "\\" + clientId + ClientIDExtension);
                }
                else
                {
                    clientId = Path.GetFileNameWithoutExtension(ids[0]);
                }
                Analytics.Init(TrackID, clientId, Power8.Properties.NoLoc.Stg_AppShortName,
                    Util.GetAppVersion().ToString());
            }
            catch (Exception ex)
            {
                Log.Raw("Unable to read client ID to init analytics: " + ex);
            }

            //Move settings from previous ver
            var std = Power8.Properties.Settings.Default;
            if (!std.FirstRunDone)
            {
                try
                {
                    std.Upgrade();
                }
                catch (Exception ex)
                {
                    Log.Raw("Unable to upgrade settings: " + ex);
                }
                std.Save();//FirstRunDone is updated later in Main Window code
                Analytics.PostEvent(Analytics.Category.Deploy, std.FirstRunDone ? "Update" : "Fresh", null, 1);
            }

            //Initialize standard folder icon
            ImageManager.GetImageContainerSync(new PowerItem { Argument = dbRoot, IsFolder = true }, API.Shgfi.SMALLICON);
            
            //Build tree
            Util.ForkPool(PowerItemTree.InitTree, "InitTree");

            //react on DwmCompositionChanged event
            ComponentDispatcher.ThreadFilterMessage += WndProc;
        }