コード例 #1
0
ファイル: Core.cs プロジェクト: guidoquadrini/Chronos
 /// <summary>
 /// Play a wave file (called when the planetary hour has changed if the user has configured it)
 /// </summary>
 public void PlaySoundFile(string name)
 {
     PInvoke.PlaySound(name, 0, PInvoke.SND_ASYNC | PInvoke.SND_NOWAIT | PInvoke.SND_FILENAME);
 }
コード例 #2
0
ファイル: Core.cs プロジェクト: guidoquadrini/Chronos
        public ChronosXPCore(System.Windows.Application entry)
        {
            Entry = entry;

            Application.ApplicationExit += new System.EventHandler(appExit);
            Application.Idle            += new System.EventHandler(appIdle);

            conf = new Config(this);
            if (!conf.LoadOK)
            {
                Shutdown();
                return;
            }

            string[] args = Environment.GetCommandLineArgs();

            bool showproperties = false;

            // The command-line arguments should only be used for testing, or internally
            foreach (string arg in args)
            {
                switch (arg.ToLower())
                {
                case "/english":
                    conf.Language = Config.CultureEN;
                    break;

                case "/nederlands":
                case "/dutch":
                    conf.Language = Config.CultureNL;
                    break;

                case "/español":
                case "/espanol":
                case "/spanish":
                    conf.Language = Config.CultureES;
                    break;

                case "/italiano":
                case "/italian":
                    conf.Language = Config.CultureIT;
                    break;

                case "/français":
                case "/francais":
                case "/french":
                    conf.Language = Config.CultureFR;
                    break;

                case "/português":
                case "/portugues":
                case "/portuguese":
                    conf.Language = Config.CulturePT;
                    break;

                case "/hungarian":
                case "/magyar":
                    conf.Language = Config.CultureHU;
                    break;

                case "/greek":
                    conf.Language = Config.CultureGR;
                    break;

                case "/hebrew":
                    conf.Language = Config.CultureHE;
                    break;

                case "/standalone":
                    conf.RunFromTrayNow = false;
                    break;

                case "/tray":
                    conf.RunFromTrayNow = true;
                    break;

                case "/properties":
                    showproperties = true;
                    break;

                case "/nogradient":
                    conf.UseGradient = false;
                    break;

                case "/gradient":
                    conf.UseGradient = true;
                    break;

                case "/nocheckupdate":
                    checkUpdate = false;
                    break;

                case "/fastcheckupdate":
                    fastCheckUpdate = true;
                    break;

                                #if BETA
                case "/debugnotify":
                    debugnotify = true;
                    break;

                // This is to create screen-shots (for the web page) of a BETA, but make it look like a release.  Use with
                // /currentculture=(culture), to set Thread.CurrentCulture (which prints the VisualMonthCalendar in that language)
                // /photogenic implies /debugnotify
                case "/photogenic":
                    Photogenic  = true;
                    debugnotify = true;
                    break;
                                #endif
                default:
                    if (arg.ToLower().StartsWith("/zenith="))
                    {
                        string[] zz = arg.Split(new char[] { '=' }, 2);
                        try
                        {
                            conf.ZenithDistance = double.Parse(zz[1]);
                        }
                        catch
                        {
                            MessageBox.Show(conf.GetString("Core.InvalidArgument") + ": " + arg, "ChronosXP",
                                            MessageBoxButtons.OK, MessageBoxIcon.Error);
                            Shutdown();
                            return;
                        }
                    }
                    else if (arg.ToLower().StartsWith("/iconset="))
                    {
                        string[] zz = arg.Split(new char[] { '=' }, 2);
                        if (zz[1].ToLower().Equals("silver") || zz[1].ToLower().Equals("black") || zz[1].ToLower().Equals("multi"))
                        {
                            conf.Fx.IconSet = zz[1];
                        }
                        else
                        {
                            MessageBox.Show(conf.GetString("Core.InvalidArgument") + ": " + arg, "ChronosXP",
                                            MessageBoxButtons.OK, MessageBoxIcon.Error);
                            Shutdown();
                            return;
                        }
                    }
                    else if (arg.ToLower().StartsWith("/currentculture="))
                    {
                        string[] zz = arg.Split(new char[] { '=' }, 2);
                        try
                        {
                            conf.CurrentCulture                   = new CultureInfo(zz[1]);
                            Application.CurrentCulture            = conf.CurrentCulture;
                            Thread.CurrentThread.CurrentUICulture = conf.CurrentCulture;
                        }
                        catch
                        {
                            MessageBox.Show("Unsupported culture: " + zz[1], "ChronosXP",
                                            MessageBoxButtons.OK, MessageBoxIcon.Error);
                            Shutdown();
                            return;
                        }
                    }
                    else
                    {
                        continue;
                        //MessageBox.Show (conf.GetString ("Core.InvalidArgument") + ": " + arg, "ChronosXP",
                        //    MessageBoxButtons.OK, MessageBoxIcon.Error);
                        //Application.Exit();
                        //return;
                    }
                    break;
                }
            }

            // tray mode?  initialize the NotifyIcon, ContextMenu and Timer, and calculate planetary hours.
            if (conf.RunFromTrayNow)
            {
                initTray();

                pHours      = new PlanetaryHours(conf);
                currentHour = pHours.CurrentHour();
                updateTray();

                if (conf.Caption == Config.CaptionType.LunarPhase)
                {
                    localPhases  = new LunarPhase(DateTime.UtcNow);
                    currentPhase = localPhases.CurrentPhase(DateTime.UtcNow);
                }

                // This timer checks to see if the planetary hour has changed; if so, notify the user (if applicable) and change the NotifyIcon
                // and it's ToolTip text.
                phClock          = new System.Windows.Forms.Timer();
                phClock.Interval = conf.Interval();
                phClock.Tick    += new System.EventHandler(phTick);
                phClock.Start();

                // This timer periodically updates the system tray icon;  this is to ensure that the ChronosXP is not hidden with the
                // inactive icons, and also because of a bug that makes the icon distorted after doing a <Windows key>+L
                trayClock          = new System.Windows.Forms.Timer();
                trayClock.Interval = 55555;
                trayClock.Tick    += new System.EventHandler(trayTick);
                trayClock.Start();

                // When in tray mode, bind Alt+F11 to open the Planetary Hours Calendar (see this.WndProc)
                PInvoke.RegisterHotKey(Handle, 101, PInvoke.MOD_ALT, PInvoke.VK_F11);
            }

                        #if WINDOWS
            if (conf.Run == 1)                     // First time ChronosXP is run?  Prompt user to configure locality
            {
                DialogResult res = MessageBox.Show(conf.GetString("Core.WelcomeText"), conf.GetString("Core.WelcomeTitle"),
                                                   MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (res == DialogResult.Yes)
                {
                    ShowProperties();
                }
                else
                {
                    MessageBox.Show(conf.GetString("Core.NoConfigText"), conf.GetString("Core.NoConfigTitle"),
                                    MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
                        #endif

                        #if BETA
            if (conf.BetaExpiry.CompareTo(DateTime.Now) <= 0)              // Beta expired?  Prompt user to upgrade
            {
                auxThread = new Thread(new ThreadStart(threadBetaExpired));
                auxThread.Start();

                if (conf.RunFromTrayNow)
                {
                    betaClock          = new System.Windows.Forms.Timer();
                    betaClock.Interval = 2255555;
                    betaClock.Tick    += new System.EventHandler(betaWarnTick);
                    betaClock.Start();
                }
            }
            else
                        #endif // BETA

                        #if WINDOWS
            // First, second or third time ChronosXP is run?  Notify user that its running in the background with a balloon window
            if (conf.Run < 3 && conf.RunFromTrayNow)
            {
                auxThread = new Thread(new ThreadStart(threadBgRunning));
                auxThread.Start();
            }
                        #endif // WINDOWS

            //if !DEBUG
            CheckUpdates();
            //endif / DEBUG

            // standalone mode?  display the Planetary Hours Calendar
            if (!conf.RunFromTrayNow)
            {
                ShowCalendar();
            }

            // run with /properties argument?  Show the Properties form.
            if (showproperties)
            {
                ShowProperties();
            }
        }
コード例 #3
0
ファイル: Core.cs プロジェクト: guidoquadrini/Chronos
 /// <summary>
 /// Play a sound alias, such as "Windows Logon"; called when the planetary hour has changed if the user has configured it
 /// </summary>
 public void PlaySoundAlias(string name)
 {
     PInvoke.PlaySound(name, 0, PInvoke.SND_ASYNC | PInvoke.SND_NOWAIT | PInvoke.SND_ALIAS);
 }