Exemplo n.º 1
0
        /// <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();
            }
        }
Exemplo n.º 2
0
        static void Main()
        {
            int iMutexIndex = 0;

            Application.EnableVisualStyles();
            // if you like to wait a few seconds in case that the instance is just
            // shutting down
            try
            {
                if (!mutex.WaitOne(TimeSpan.FromSeconds(1), false))
                {
                    iMutexIndex = 1;
                    if (!mutex2.WaitOne(TimeSpan.FromSeconds(1), false))
                    {
                        MessageBox.Show("Application is already running! Only 2 instances are allowed.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Can't execute application: " + ex.Message);
                return;
            }

            Application.SetCompatibleTextRenderingDefault(false);

            // Show the system tray icon.
            using (ProcessIcon pi = new ProcessIcon())
            {
                pi.Display();

                Mainthread = new StartUp(pi);

                // Make sure the application runs!
                Application.Run();
            }

            if (iMutexIndex == 0)
            {
                mutex.ReleaseMutex();
            }
            else if (iMutexIndex == 1)
            {
                mutex2.ReleaseMutex();
            }
        }
Exemplo n.º 3
0
        /// <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())
            {
                Program.MyData.SetXml(Properties.Resources.animations, "esheep64");
                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;

            Program.MyData.ListenOnXMLChanged(XmlFileChanged);
            Program.MyData.ListenOnOptionsChanged(OptionFileChanged);
        }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            //string resource1 = "DesktopPet.dll.NAudio.dll";
            //EmbeddedAssembly.Load(resource1, "NAudio.dll");

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);

            MyData = new LocalData.LocalData(Windows.Storage.ApplicationData.Current.LocalFolder.Path, Application.ExecutablePath);

            // Show the system tray icon.
            using (ProcessIcon pi = new ProcessIcon())
            {
                pi.Display();

                Mainthread = new StartUp(pi);

                // Make sure the application runs!
                Application.Run();
            }
        }
Exemplo n.º 5
0
        static void Main(string[] args)
        {
            int iMutexIndex = 0;

            string resource1 = "DesktopPet.Portable.NAudio.dll";

            EmbeddedAssembly.Load(resource1, "NAudio.dll");

            AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);

            Application.EnableVisualStyles();
            // if you like to wait a few seconds in case that the instance is just
            // shutting down
            try
            {
                if (!mutex.WaitOne(TimeSpan.FromSeconds(1), false))
                {
                    iMutexIndex = 1;
                    try
                    {
                        if (!mutex2.WaitOne(TimeSpan.FromSeconds(1), false))
                        {
                            MessageBox.Show("Application is already running! Only 2 instances are allowed.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return;
                        }
                    }
                    catch (Exception)
                    {
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Can't execute application: " + ex.Message);
                return;
            }

            // Check and parse the arguments
            string SearchStringLocalXml = "localxml=";
            string SearchStringWebXml   = "webxml=";
            string SearchStringInstall  = "install=";

            foreach (string s in args)
            {
                if (s.IndexOf(SearchStringLocalXml) >= 0)
                {
                    ArgumentLocalXML = s.Substring(s.IndexOf(SearchStringLocalXml) + SearchStringLocalXml.Length);
                    if (ArgumentLocalXML.IndexOf(" ") >= 0)
                    {
                        ArgumentLocalXML = ArgumentLocalXML.Substring(0, ArgumentLocalXML.IndexOf(" "));
                    }
                }
                else if (s.IndexOf(SearchStringWebXml) >= 0)
                {
                    ArgumentWebXML = s.Substring(s.IndexOf(SearchStringWebXml) + SearchStringWebXml.Length);
                    if (ArgumentWebXML.IndexOf(" ") >= 0)
                    {
                        ArgumentWebXML = ArgumentWebXML.Substring(0, ArgumentWebXML.IndexOf(" "));
                    }
                }
                else if (s.IndexOf(SearchStringInstall) >= 0)
                {
                    ArgumentInstall = s.Substring(s.IndexOf(SearchStringInstall) + SearchStringInstall.Length);
                    if (ArgumentInstall.IndexOf(" ") >= 0)
                    {
                        ArgumentInstall = ArgumentInstall.Substring(0, ArgumentInstall.IndexOf(" "));
                    }
                }
            }

            Application.SetCompatibleTextRenderingDefault(false);

            // Show the system tray icon.
            using (ProcessIcon pi = new ProcessIcon())
            {
                pi.Display();

                Mainthread = new StartUp(pi);

                // Make sure the application runs!
                Application.Run();
            }

            if (iMutexIndex == 0)
            {
                mutex.ReleaseMutex();
            }
            else if (iMutexIndex == 1)
            {
                mutex2.ReleaseMutex();
            }
        }