コード例 #1
0
ファイル: StartUp.cs プロジェクト: rluiten/desktopPet
        /// <summary>
        /// Constructor. Called when application is started.
        /// </summary>
        /// <param name="processIcon">ProcessIcon class, to change icon when a new pet is selected.</param>
        public StartUp(ProcessIcon processIcon)
        {
            pi = processIcon;

            // Init XML class
            xml = new Xml();
            // Init Animations class
            animations = new Animations(xml);

            // If SHIFT key was pressed, open Debug window
            Keys ks = Control.ModifierKeys;

            if (ks == Keys.Shift)
            {
                debug = new FormDebug();
                debug.Show();
                AddDebugInfo(DEBUG_TYPE.info, "debug window started");
            }

            // Read XML file and start new sheep in 1 second
            if (!xml.readXML())
            {
                Properties.Settings.Default.xml = Properties.Resources.animations;
                Properties.Settings.Default.Save();
                xml.readXML();
            }

            // Set animation icon
            pi.SetIcon(xml.bitmapIcon,
                       xml.AnimationXML.Header.Petname,
                       xml.AnimationXML.Header.Author,
                       xml.AnimationXML.Header.Title,
                       xml.AnimationXML.Header.Version,
                       xml.AnimationXML.Header.Info
                       );

            // Wait 1 second, before starting first animation
            timer1.Tag      = "A";
            timer1.Tick    += new EventHandler(timer1_Tick);
            timer1.Interval = 1000;
            timer1.Enabled  = true;

            if (Program.ArgumentInstall == "yes")
            {
                Install install = new Install();
                install.ShowInstallation();
            }
        }
コード例 #2
0
        /// <summary>
        /// Creates this instance for the tray icon.
        /// </summary>
        /// <returns>ContextMenuStrip to add in the tray icon.</returns>
        public ContextMenuStrip Create()
        {
            // Add the default menu options.
            ContextMenuStrip   menu = new ContextMenuStrip();
            ToolStripMenuItem  item;
            ToolStripSeparator sep;

            // Create install class
            installForm = new Install();

            // Item: New Sheep.
            newSheepMenuItem        = new ToolStripMenuItem();
            newSheepMenuItem.Text   = "&Add new Sheep";
            newSheepMenuItem.Click += new EventHandler(AddNewSheep_Click);
            newSheepMenuItem.Image  = Resources.icon.ToBitmap();
            newSheepMenuItem.Font   = new Font(newSheepMenuItem.Font, newSheepMenuItem.Font.Style | FontStyle.Bold);
            menu.Items.Add(newSheepMenuItem);

            // Item: Options.
            item        = new ToolStripMenuItem();
            item.Text   = "&Options";
            item.Click += new EventHandler(Options_Click);
            item.Image  = Resources.option;
            menu.Items.Add(item);

            // Item: Separator.
            sep = new ToolStripSeparator();
            menu.Items.Add(sep);

            // Item: About.
            item = new ToolStripMenuItem();
            if (!installForm.IsApplicationInstalled())
            {
                item.Text = "&Install application...";
            }
            else
            {
                item.Text = "Repair/&Uninstall...";
            }
            item.Click += new EventHandler(InstallApplication);
            item.Image  = installForm.Icon.ToBitmap();
            menu.Items.Add(item);

            // Item: About.
            item        = new ToolStripMenuItem();
            item.Text   = "A&bout";
            item.Click += new EventHandler(About_Click);
            item.Image  = Resources.about;
            menu.Items.Add(item);

            // Item: Help.
            item        = new ToolStripMenuItem();
            item.Text   = "&Help";
            item.Click += new EventHandler(Help_Click);
            item.Image  = Resources.help;
            menu.Items.Add(item);

            // Item: Separator.
            sep = new ToolStripSeparator();
            menu.Items.Add(sep);

            // Item: Close application.
            closeSheepMenuItem        = new ToolStripMenuItem();
            closeSheepMenuItem.Text   = "&Remove Sheep and Close";
            closeSheepMenuItem.Click += new EventHandler(Exit_Click);
            closeSheepMenuItem.Image  = Resources.exit;
            menu.Items.Add(closeSheepMenuItem);

            return(menu);
        }