public override void Install(IDictionary stateSaver)
        {
            // this is only for debugging - it allows you to attach a debugger to the installer instance
            //System.Diagnostics.Debugger.Launch();

            // make sure to call the base class' Install() method
            base.Install(stateSaver);

            // this is where the user selected to install the files
            string installFolder = Context.Parameters["tempdir"];

            // this is the name of the subfolder used to contain all of your display's files
            string folderName = Context.Parameters["folderName"];

            // detect if/where growl is installed
            Growl.CoreLibrary.Detector detector = new Growl.CoreLibrary.Detector();
            if (detector.IsInstalled)
            {
                // growl was detected - read the Display folder location
                string displayFolder = Path.Combine(detector.DisplaysFolder, folderName);

                // save our display folder information for later (uninstallation)
                stateSaver.Add("DISPLAY_FOLDER", displayFolder);

                // make sure our subfolder exists
                if (!Directory.Exists(displayFolder))
                {
                    Directory.CreateDirectory(displayFolder);
                }

                // copy files from temp location to actual location.
                // (our files were originally installed in a Files subfolder of the path the user selected)
                string           sourceFolder = Path.Combine(installFolder, "Files");
                DirectoryInfo    d            = new DirectoryInfo(sourceFolder);
                FileInfo[]       files        = d.GetFiles();
                Queue <FileInfo> queue        = new Queue <FileInfo>(files);
                foreach (FileInfo file in queue)
                {
                    // move each file from the Files folder to our display folder
                    file.MoveTo(Path.Combine(displayFolder, file.Name));
                }

                // clean up the temporary Files folder
                Directory.Delete(sourceFolder);
            }
            else
            {
                // growl was not detected on this machine
                throw new InstallException("The Growl Display Installer requires that Growl for Windows already be installed on the system.");
            }
        }
        public override void Install(IDictionary stateSaver)
        {
            // this is only for debugging - it allows you to attach a debugger to the installer instance
            //System.Diagnostics.Debugger.Launch();

            // make sure to call the base class' Install() method
            base.Install(stateSaver);

            // this is where the user selected to install the files
            string installFolder = Context.Parameters["tempdir"];

            // this is the name of the subfolder used to contain all of your display's files
            string folderName = Context.Parameters["folderName"];

            // detect if/where growl is installed
            Growl.CoreLibrary.Detector detector = new Growl.CoreLibrary.Detector();
            if (detector.IsInstalled)
            {
                // growl was detected - read the Display folder location
                string displayFolder = Path.Combine(detector.DisplaysFolder, folderName);

                // save our display folder information for later (uninstallation)
                stateSaver.Add("DISPLAY_FOLDER", displayFolder);

                // make sure our subfolder exists
                if (!Directory.Exists(displayFolder))
                    Directory.CreateDirectory(displayFolder);

                // copy files from temp location to actual location.
                // (our files were originally installed in a Files subfolder of the path the user selected)
                string sourceFolder = Path.Combine(installFolder, "Files");
                DirectoryInfo d = new DirectoryInfo(sourceFolder);
                FileInfo[] files = d.GetFiles();
                Queue<FileInfo> queue = new Queue<FileInfo>(files);
                foreach (FileInfo file in queue)
                {
                    // move each file from the Files folder to our display folder
                    file.MoveTo(Path.Combine(displayFolder, file.Name));
                }

                // clean up the temporary Files folder
                Directory.Delete(sourceFolder);
            }
            else
            {
                // growl was not detected on this machine
                throw new InstallException("The Growl Display Installer requires that Growl for Windows already be installed on the system.");
            }
        }
Exemple #3
0
        public void Run()
        {
            if (!this.running)
            {
                this.running = true;

                InitializeComponent();

                // SUPER IMPORTANT - since we are using the contextMenu as the synchronizing object, its .Handle must be created first
                // this will force creation of the handle without showing the menu
                Utility.WriteDebugInfo("ContextMenu Handle: {0}", this.contextMenu.Handle);

                // scaling factor
                float currentDPI = 0;
                using (Graphics g = this.contextMenu.CreateGraphics())
                {
                    currentDPI = g.DpiX;
                }
                ApplicationMain.ScalingFactor = currentDPI / 96;

                // configure the controller
                this.controller = Controller.GetController();
                this.controller.FailedToStart          += new EventHandler <PortConflictEventArgs>(controller_FailedToStart);
                this.controller.FailedToStartUDPLegacy += new EventHandler <PortConflictEventArgs>(controller_FailedToStartUDPLegacy);
                this.controller.Initialize(Application.ExecutablePath, this.contextMenu);

                this.wpr = new WndProcReader(WndProc);

                StartGrowl();

                OnProgramRunning(this, EventArgs.Empty);

                HandleSystemNotifications();

                // signal the ProgramLoadedResetEvent so anybody that was waiting on it can start their work
                ProgramLoadedResetEvent.Set();

                // Normally we shouldnt ever explicitly call GC.Collect(), but since many of the prefs
                // are read from files on disk, they usually end up on the Large Object Heap. LOH objects
                // only get collected in Gen2 collections, so we want to do this here before the app
                // really gets going to clean up our initialization process.
                Utility.WriteDebugInfo("Program loaded. Force GC to clean up LOH");
                ApplicationMain.ForceGC();

                // auto updater
                this.updater = new Updater(Application.StartupPath);
                this.updater.CheckForUpdateComplete += new CheckForUpdateCompleteEventHandler(updater_CheckForUpdateComplete);
                this.autoUpdateTimer.Interval        = 20 * 1000;
                this.autoUpdateTimer.Tick           += new EventHandler(autoUpdateTimer_Tick);
                this.autoUpdateTimer.Start();

                // while it may seem strange to call the Detector to see if we are installed, it is the best way
                // to ensure that plugins/displays see the same values that we do
                Growl.CoreLibrary.Detector detector = new Growl.CoreLibrary.Detector();
                if (!detector.IsInstalled)
                {
                    // something is not right with the registry setting, so lets fix it now
                    Microsoft.Win32.RegistryKey key = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(Growl.CoreLibrary.Detector.REGISTRY_KEY, true);
                    if (key == null)
                    {
                        key = Microsoft.Win32.Registry.CurrentUser.CreateSubKey(Growl.CoreLibrary.Detector.REGISTRY_KEY);
                    }
                    using (key)
                    {
                        key.SetValue(null, Application.ExecutablePath);
                    }
                }
            }
        }
Exemple #4
0
        public void Run()
        {
            if (!this.running)
            {
                this.running = true;

                InitializeComponent();

                // SUPER IMPORTANT - since we are using the contextMenu as the synchronizing object, its .Handle must be created first
                // this will force creation of the handle without showing the menu
                Utility.WriteDebugInfo("ContextMenu Handle: {0}", this.contextMenu.Handle);

                // scaling factor
                float currentDPI = 0;
                using (Graphics g = this.contextMenu.CreateGraphics())
                {
                    currentDPI = g.DpiX;
                }
                ApplicationMain.ScalingFactor = currentDPI / 96;

                // configure the controller
                this.controller = Controller.GetController();
                this.controller.FailedToStart += new EventHandler<PortConflictEventArgs>(controller_FailedToStart);
                this.controller.FailedToStartUDPLegacy += new EventHandler<PortConflictEventArgs>(controller_FailedToStartUDPLegacy);
                this.controller.Initialize(Application.ExecutablePath, this.contextMenu);

                this.wpr = new WndProcReader(WndProc);

                StartGrowl();

                OnProgramRunning(this, EventArgs.Empty);

                HandleSystemNotifications();

                // signal the ProgramLoadedResetEvent so anybody that was waiting on it can start their work
                ProgramLoadedResetEvent.Set();

                // Normally we shouldnt ever explicitly call GC.Collect(), but since many of the prefs
                // are read from files on disk, they usually end up on the Large Object Heap. LOH objects
                // only get collected in Gen2 collections, so we want to do this here before the app
                // really gets going to clean up our initialization process.
                Utility.WriteDebugInfo("Program loaded. Force GC to clean up LOH");
                ApplicationMain.ForceGC();

                // auto updater
                this.updater = new Updater(Application.StartupPath);
                this.updater.CheckForUpdateComplete += new CheckForUpdateCompleteEventHandler(updater_CheckForUpdateComplete);
                this.autoUpdateTimer.Interval = 20 * 1000;
                this.autoUpdateTimer.Tick += new EventHandler(autoUpdateTimer_Tick);
                this.autoUpdateTimer.Start();

                // while it may seem strange to call the Detector to see if we are installed, it is the best way
                // to ensure that plugins/displays see the same values that we do
                Growl.CoreLibrary.Detector detector = new Growl.CoreLibrary.Detector();
                if (!detector.IsInstalled)
                {
                    // something is not right with the registry setting, so lets fix it now
                    Microsoft.Win32.RegistryKey key = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(Growl.CoreLibrary.Detector.REGISTRY_KEY, true);
                    if (key == null)
                        key = Microsoft.Win32.Registry.CurrentUser.CreateSubKey(Growl.CoreLibrary.Detector.REGISTRY_KEY);
                    using (key)
                    {
                        key.SetValue(null, Application.ExecutablePath);
                    }
                }
            }
        }