示例#1
0
        private void frmSetting_Load(object sender, EventArgs e)
        {
            //Load config
            //Windows Bound (Position + Size)------------------------------------------------
            Rectangle rc = GlobalSetting.StringToRect(GlobalSetting.GetConfig($"{Name}.WindowsBound", "280,125,610,570"));

            if (!Helper.IsOnScreen(rc.Location))
            {
                rc.Location = new Point(280, 125);
            }
            Bounds = rc;

            //windows state--------------------------------------------------------------
            string s = GlobalSetting.GetConfig(Name + ".WindowsState", "Normal");

            if (s == "Normal")
            {
                WindowState = FormWindowState.Normal;
            }
            else if (s == "Maximized")
            {
                WindowState = FormWindowState.Maximized;
            }

            LoadTabGeneralConfig();
            InitLanguagePack();
        }
示例#2
0
        static void Main(string[] argv)
        {
            args = argv;

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new frmMain());


            //autoupdate----------------------------------------------------------------
            string s = GlobalSetting.GetConfig("AutoUpdate", DateTime.Now.ToString());

            if (s != "0")
            {
                DateTime lastUpdate = DateTime.Now;

                if (DateTime.TryParse(s, out lastUpdate))
                {
                    //Check for update every 7 days
                    if (DateTime.Now.Subtract(lastUpdate).TotalDays > 7)
                    {
                        Process.Start(char.ConvertFromUtf32(34) +
                                      Program.igPath + "igcmd.exe" +
                                      char.ConvertFromUtf32(34), "igautoupdate");
                    }
                }
            }
        }
示例#3
0
 private void lnkHelp_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
 {
     try
     {
         string version = GlobalSetting.GetConfig("igVersion", "1.0").Replace(".", "_");
         Process.Start("http://www.imageglass.org/support/user/create-theme?utm_source=app_" + version + "&utm_medium=app_click&utm_campaign=app_create_theme");
     }
     catch { }
 }
示例#4
0
 private void lnkDownloadTheme_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
 {
     try
     {
         string version = GlobalSetting.GetConfig("AppVersion", "1.0").Replace(".", "_");
         Process.Start("http://www.imageglass.org/download/themes?utm_source=app_" + version + "&utm_medium=app_click&utm_campaign=app_download_theme");
     }
     catch { }
 }
示例#5
0
        static void Main(string[] argv)
        {
            Guid guid = new Guid(appGuid);

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

            //auto update----------------------------------------------------------------
            string s = GlobalSetting.GetConfig("AutoUpdate", "1/1/2015 0:0:0");

            if (s != "0")
            {
                DateTime lastUpdate = DateTime.Now;

                if (DateTime.TryParse(s, out lastUpdate))
                {
                    //Check for update every 7 days
                    if (DateTime.Now.Subtract(lastUpdate).TotalDays > 7)
                    {
                        Process p = new Process();
                        p.StartInfo.FileName  = GlobalSetting.StartUpDir + "igcmd.exe";
                        p.StartInfo.Arguments = "igautoupdate";
                        p.Start();
                    }
                }
            }

            //get current config
            GlobalSetting.IsAllowMultiInstances = bool.Parse(GlobalSetting.GetConfig("IsAllowMultiInstances", "true"));

            //check if allows multi instances
            if (GlobalSetting.IsAllowMultiInstances)
            {
                Application.Run(formMain = new frmMain());
            }
            else
            {
                //single instance is required
                using (SingleInstance singleInstance = new SingleInstance(guid))
                {
                    if (singleInstance.IsFirstInstance)
                    {
                        singleInstance.ArgumentsReceived += SingleInstance_ArgumentsReceived;
                        singleInstance.ListenForArgumentsFromSuccessiveInstances();

                        Application.Run(formMain = new frmMain());
                    }
                    else
                    {
                        singleInstance.PassArgumentsToFirstInstance(Environment.GetCommandLineArgs());
                    }
                }
            } //end check multi instances
        }
 private void lnkUpdateReadMore_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
 {
     try
     {
         string version = GlobalSetting.GetConfig("AppVersion", "1.0").Replace(".", "_");
         Process.Start(up.Info.Decription + "?utm_source=app_" + version + "&utm_medium=app_click&utm_campaign=app_update_read_more");
     }
     catch
     {
         MessageBox.Show("Check your Internet connection!");
     }
 }
 private void btnDownload_Click(object sender, EventArgs e)
 {
     try
     {
         string version = GlobalSetting.GetConfig("AppVersion", "1.0").Replace(".", "_");
         Process.Start(up.Info.Link.ToString() + "?utm_source=app_" + version + "&utm_medium=app_click&utm_campaign=app_update_read_more");
     }
     catch
     {
         MessageBox.Show("Check your Internet connection!");
     }
 }
示例#8
0
 /// <summary>
 /// Set file associations
 /// </summary>
 /// <param name="igPath">ImageGlass.exe path</param>
 public static void SetAssociations(string igPath)
 {
     try
     {
         string supportedExts = "*.jpg;*.jpe;*.jfif;*.jpeg;*.png;" +
                                "*.gif;*.ico;*.bmp;*.dib;*.tif;*.tiff;" +
                                "*.exif;*.wmf;*.emf;";
         supportedExts = GlobalSetting.GetConfig("SupportedExtensions", supportedExts);
         Functions.RegisterAssociation(supportedExts, igPath);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
示例#9
0
        /// <summary>
        /// Load theme list
        /// </summary>
        private void LoadThemeList()
        {
            //add default theme
            var defaultTheme = new Theme(GlobalSetting.StartUpDir(@"DefaultTheme\config.xml"));

            _themeList.Add(defaultTheme);
            cmbTheme.Items.Clear();
            cmbTheme.Items.Add(defaultTheme.Name);
            cmbTheme.SelectedIndex = 0;


            string themeFolder = GlobalSetting.ConfigDir(Dir.Themes);

            //get the current theme
            var currentTheme = GlobalSetting.GetConfig("Theme", "default");


            if (Directory.Exists(themeFolder))
            {
                foreach (string d in Directory.GetDirectories(themeFolder))
                {
                    string configFile = Path.Combine(d, "config.xml");

                    if (File.Exists(configFile))
                    {
                        Theme th = new Theme(d);

                        //invalid theme
                        if (!th.IsThemeValid)
                        {
                            continue;
                        }

                        _themeList.Add(th);
                        cmbTheme.Items.Add(th.Name);

                        if (currentTheme.ToLower().CompareTo(th.ThemeFolderName.ToLower()) == 0)
                        {
                            cmbTheme.SelectedIndex = cmbTheme.Items.Count - 1;
                        }
                    }
                }
            }
            else
            {
                Directory.CreateDirectory(themeFolder);
            }
        }
示例#10
0
        /// <summary>
        /// Load theme list
        /// </summary>
        private void LoadThemeList()
        {
            //add default theme
            var defaultTheme = new Theme(Path.Combine(GlobalSetting.StartUpDir, @"DefaultTheme\config.xml"));

            _themeList.Add(defaultTheme);
            cmbTheme.Items.Clear();
            cmbTheme.Items.Add(defaultTheme.Name);
            cmbTheme.SelectedIndex = 0;


            string dir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), @"ImageGlass\Themes\");

            //get the current theme
            var currentTheme = GlobalSetting.GetConfig("Theme", "Default");


            if (Directory.Exists(dir))
            {
                foreach (string d in Directory.GetDirectories(dir))
                {
                    string configFile = Path.Combine(d, "config.xml");

                    if (File.Exists(configFile))
                    {
                        Theme th = new Theme();

                        //invalid theme
                        if (!th.LoadTheme(configFile))
                        {
                            continue;
                        }

                        _themeList.Add(th);
                        cmbTheme.Items.Add(th.Name);

                        if (currentTheme.ToLower().CompareTo(th.ThemeConfigFilePath.ToLower()) == 0)
                        {
                            cmbTheme.SelectedIndex = cmbTheme.Items.Count - 1;
                        }
                    }
                }
            }
            else
            {
                Directory.CreateDirectory(dir);
            }
        }
示例#11
0
        private void frmExtension_Load(object sender, EventArgs e)
        {
            //Load config
            //Windows Bound (Position + Size)--------------------------------------------
            Rectangle rc = GlobalSetting.StringToRect(GlobalSetting.GetConfig(this.Name + ".WindowsBound",
                                                                              "280,125,840,500"));

            this.Bounds = rc;

            //windows state--------------------------------------------------------------
            string s = GlobalSetting.GetConfig(this.Name + ".WindowsState", "Normal");

            if (s == "Normal")
            {
                this.WindowState = FormWindowState.Normal;
            }
            else if (s == "Maximized")
            {
                this.WindowState = FormWindowState.Maximized;
            }

            //Apply Windows theme
            RenderTheme r = new RenderTheme();

            r.ApplyTheme(tvExtension);

            if (!System.IO.Directory.Exists(Application.StartupPath + @"\Plugins"))
            {
                System.IO.Directory.CreateDirectory(Application.StartupPath + @"\Plugins");
            }
            else
            {
                Global.Plugins.FindPlugins(Application.StartupPath + @"\Plugins");

                foreach (ImageGlass.Plugins.Types.AvailablePlugin p in Global.Plugins.AvailablePlugins)
                {
                    TreeNode n = new TreeNode(p.Instance.Name);
                    tvExtension.Nodes.Add(n);
                    n = null;
                }
            }

            //Load language:
            this.Text                 = GlobalSetting.LangPack.Items["frmExtension._Text"];
            lnkGetMoreExt.Text        = GlobalSetting.LangPack.Items["frmExtension.lnkGetMoreExt"];
            tvExtension.Nodes[0].Text = GlobalSetting.LangPack.Items["frmExtension.Node0"];
            btnClose.Text             = GlobalSetting.LangPack.Items["frmExtension.btnClose"];
        }
示例#12
0
        /// <summary>
        /// Thêm menu 'Open with ImageGlass' vào menu ngữ cảnh
        /// </summary>
        /// <param name="igPath">Đường dẫn của tập tin ImageGlass.exe</param>
        public static void AddImageGlassToContextMenu(string igPath)
        {
            try
            {
                string supportedExts = "*.jpg;*.jpe;*.jfif;*.jpeg;*.png;" +
                                       "*.gif;*.ico;*.bmp;*.dib;*.tif;*.tiff;" +
                                       "*.exif;*.wmf;*.emf;";
                supportedExts = GlobalSetting.GetConfig("SupportedExtensions", supportedExts);

                AddImageGlassToContextMenu(igPath, supportedExts);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#13
0
        /// <summary>
        /// Load language list
        /// </summary>
        private void LoadLanguageList()
        {
            cmbLanguage.Items.Clear();
            cmbLanguage.Items.Add("English");


            _langList = new List <Language>
            {
                new Language()
            };

            string langPath = Path.Combine(GlobalSetting.StartUpDir, "Languages");

            if (!Directory.Exists(langPath))
            {
                Directory.CreateDirectory(langPath);
            }
            else
            {
                foreach (string f in Directory.GetFiles(langPath))
                {
                    if (Path.GetExtension(f).ToLower() == ".iglang")
                    {
                        Language l = new Language(f);
                        _langList.Add(l);

                        int    iLang   = cmbLanguage.Items.Add(l.LangName);
                        string curLang = GlobalSetting.GetConfig("Language", "English");

                        //using current language pack
                        if (f.CompareTo(curLang) == 0)
                        {
                            cmbLanguage.SelectedIndex = iLang;
                        }
                    }
                }
            }

            if (cmbLanguage.SelectedIndex == -1)
            {
                cmbLanguage.SelectedIndex = 0;
            }
        }
示例#14
0
        /// <summary>
        /// Get and load value of General tab
        /// </summary>
        private void LoadTabGeneralConfig()
        {
            //Get value of chkWelcomePicture ----------------------------------------------------
            chkWelcomePicture.Checked = GlobalSetting.IsShowWelcome;

            //Get value of chkShowToolBar
            chkShowToolBar.Checked = GlobalSetting.IsShowToolBar;

            //Get Portable mode value -----------------------------------------------------------
            chkPortableMode.Checked = GlobalSetting.IsPortableMode;
            if (!GlobalSetting.CheckStartUpDirWritable())
            {
                chkPortableMode.Enabled = false;
            }

            //Get value of cmbAutoUpdate --------------------------------------------------------
            string configValue = GlobalSetting.GetConfig("AutoUpdate", DateTime.Now.ToString());

            if (configValue != "0")
            {
                chkAutoUpdate.Checked = true;
            }
            else
            {
                chkAutoUpdate.Checked = false;
            }

            //Get value of IsAllowMultiInstances
            chkAllowMultiInstances.Checked = GlobalSetting.IsAllowMultiInstances;

            //Get value of IsPressESCToQuit
            chkESCToQuit.Checked = GlobalSetting.IsPressESCToQuit;

            //Get value of IsConfirmationDelete
            chkConfirmationDelete.Checked = GlobalSetting.IsConfirmationDelete;

            //Get value of IsScrollbarsVisible
            chkShowScrollbar.Checked = GlobalSetting.IsScrollbarsVisible;

            //Get background color
            picBackgroundColor.BackColor = GlobalSetting.BackgroundColor;
        }
示例#15
0
        private void frmExtension_Load(object sender, EventArgs e)
        {
            //Load config
            //Windows Bound (Position + Size)--------------------------------------------
            Rectangle rc = GlobalSetting.StringToRect(GlobalSetting.GetConfig($"{Name}.WindowsBound", "280,125,850,550"));

            if (!Helper.IsOnScreen(rc.Location))
            {
                rc.Location = new Point(280, 125);
            }
            Bounds = rc;

            //windows state--------------------------------------------------------------
            string s = GlobalSetting.GetConfig($"{Name}.WindowsState", "Normal");

            if (s == "Normal")
            {
                WindowState = FormWindowState.Normal;
            }
            else if (s == "Maximized")
            {
                WindowState = FormWindowState.Maximized;
            }

            //Apply Windows theme
            RenderTheme r = new RenderTheme();

            r.ApplyTheme(tvExtension);

            //load extensions
            LoadExtensions();

            //Load language:
            Text = GlobalSetting.LangPack.Items["frmExtension._Text"];
            btnRefreshAllExt.Text = GlobalSetting.LangPack.Items["frmExtension.btnRefreshAllExt"];
            btnGetMoreExt.Text    = GlobalSetting.LangPack.Items["frmExtension.btnGetMoreExt"];
            btnInstallExt.Text    = GlobalSetting.LangPack.Items["frmExtension.btnInstallExt"];
            btnClose.Text         = GlobalSetting.LangPack.Items["frmExtension.btnClose"];

            RightToLeft = GlobalSetting.LangPack.IsRightToLeftLayout;
        }
示例#16
0
        private void frmSetting_Load(object sender, EventArgs e)
        {
            //Remove tabs header
            tab1.Appearance = TabAppearance.FlatButtons;
            tab1.ItemSize   = new Size(0, 1);
            tab1.SizeMode   = TabSizeMode.Fixed;

            //Load config
            //Windows Bound (Position + Size)-------------------------------------------
            Rectangle rc = GlobalSetting.StringToRect(GlobalSetting.GetConfig($"{Name}.WindowsBound", "280,125,610,570"));

            if (!Helper.IsOnScreen(rc.Location))
            {
                rc.Location = new Point(280, 125);
            }
            Bounds = rc;

            //windows state--------------------------------------------------------------
            string s = GlobalSetting.GetConfig(Name + ".WindowsState", "Normal");

            if (s == "Normal")
            {
                WindowState = FormWindowState.Normal;
            }
            else if (s == "Maximized")
            {
                WindowState = FormWindowState.Maximized;
            }

            //Get the last view of tab --------------------------------------------------
            tab1.SelectedIndex = GlobalSetting.SettingsTabLastView;
            tab1_SelectedIndexChanged(tab1, null); //Load tab's configs

            //Load configs
            LoadTabGeneralConfig();
            LoadTabImageConfig();
            lnkRefresh_LinkClicked(null, null);


            InitLanguagePack();
        }
        private void frmColorPicker_Load(object sender, EventArgs e)
        {
            UpdateUI();

            //Windows Bound (Position + Size)-------------------------------------------
            Rectangle rc = GlobalSetting.StringToRect(GlobalSetting.GetConfig($"{Name}.WindowsBound", $"0,0,300,160"));

            if (rc.X == 0 && rc.Y == 0)
            {
                _locationOffset = DefaultLocationOffset;
                parentOffset    = _locationOffset;

                _SetLocationBasedOnParent();
            }
            else
            {
                this.Location = rc.Location;
            }

            _ResetColor();


            lblRGB.Text = "RGB:";
            lblHEX.Text = "HEX:";
            lblHSL.Text = "HSL:";

            if (GlobalSetting.IsColorPickerRGBA)
            {
                lblRGB.Text = "RGBA:";
            }
            if (GlobalSetting.IsColorPickerHEXA)
            {
                lblHEX.Text = "HEXA:";
            }
            if (GlobalSetting.IsColorPickerHSLA)
            {
                lblHSL.Text = "HSLA:";
            }
        }
示例#18
0
        private void frmSetting_Load(object sender, EventArgs e)
        {
            //Load config
            //Windows Bound (Position + Size)--------------------------------------------
            Rectangle rc = GlobalSetting.StringToRect(GlobalSetting.GetConfig(this.Name + ".WindowsBound", "280,125,610, 570"));

            this.Bounds = rc;

            //windows state--------------------------------------------------------------
            string s = GlobalSetting.GetConfig(this.Name + ".WindowsState", "Normal");

            if (s == "Normal")
            {
                this.WindowState = FormWindowState.Normal;
            }
            else if (s == "Maximized")
            {
                this.WindowState = FormWindowState.Maximized;
            }

            LoadTabGeneralConfig();
            InitLanguagePack();
        }
示例#19
0
        /// <summary>
        /// Xoá tất cả menu 'Open with ImageGlass'
        /// </summary>
        public static void RemoveImageGlassToContextMenu()
        {
            try
            {
                string supportedExts = "*.jpg;*.jpe;*.jfif;*.jpeg;*.png;" +
                                       "*.gif;*.ico;*.bmp;*.dib;*.tif;*.tiff;" +
                                       "*.exif;*.wmf;*.emf;";
                supportedExts = GlobalSetting.GetConfig("SupportedExtensions", supportedExts);

                string[] exts = supportedExts.Replace("*", "").Split(new char[] { ';' },
                                                                     StringSplitOptions.RemoveEmptyEntries);

                foreach (string ext in exts)
                {
                    RemoveContextMenuItem(ext, "Open with ImageGlass");
                }

                GlobalSetting.SetConfig("ContextMenuExtensions", "");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#20
0
        private void frmExtension_Load(object sender, EventArgs e)
        {
            //Load config
            //Windows Bound (Position + Size)--------------------------------------------
            Rectangle rc = GlobalSetting.StringToRect(GlobalSetting.GetConfig(this.Name + ".WindowsBound",
                                                                              "280,125,840,500"));

            this.Bounds = rc;

            //windows state--------------------------------------------------------------
            string s = GlobalSetting.GetConfig(this.Name + ".WindowsState", "Normal");

            if (s == "Normal")
            {
                this.WindowState = FormWindowState.Normal;
            }
            else if (s == "Maximized")
            {
                this.WindowState = FormWindowState.Maximized;
            }

            //Apply Windows theme
            RenderTheme r = new RenderTheme();

            r.ApplyTheme(tvExtension);

            //load extensions
            LoadExtensions();

            //Load language:
            this.Text             = GlobalSetting.LangPack.Items["frmExtension._Text"];
            btnRefreshAllExt.Text = GlobalSetting.LangPack.Items["frmExtension.btnRefreshAllExt"];
            btnGetMoreExt.Text    = GlobalSetting.LangPack.Items["frmExtension.btnGetMoreExt"];
            btnInstallExt.Text    = GlobalSetting.LangPack.Items["frmExtension.btnInstallExt"];
            btnClose.Text         = GlobalSetting.LangPack.Items["frmExtension.btnClose"];
        }
示例#21
0
        static void Main(string[] argv)
        {
            // Windows Vista or later
            if (Environment.OSVersion.Version.Major >= 6)
            {
                SetProcessDPIAware();
            }

            Guid guid = new Guid(appGuid);

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

            // Check if the start up directory writable
            GlobalSetting.IsStartUpDirWritable = GlobalSetting.CheckStartUpDirWritable();


            //check if user enable TEMPORARY portable mode ------------------------------
            GlobalSetting.IsPortableMode = false;

            if (argv.ToList().IndexOf("--portable") != -1)
            {
                GlobalSetting.IsPortableMode = true;
            }
            else
            {
                string configValue = GlobalSetting.GetConfig("IsPortableMode", "False", true);
                GlobalSetting.IsPortableMode = bool.Parse(configValue);
            }

            //auto update----------------------------------------------------------------
            string lastUpdateConfig = GlobalSetting.GetConfig("AutoUpdate", "7/26/1991 12:13:08 AM");

            if (lastUpdateConfig != "0")
            {
                DateTime lastUpdate = DateTime.Now;

                if (DateTime.TryParse(lastUpdateConfig, out lastUpdate))
                {
                    //Check for update every 7 days
                    if (DateTime.Now.Subtract(lastUpdate).TotalDays > 7)
                    {
                        Process p = new Process();
                        p.StartInfo.FileName  = GlobalSetting.StartUpDir + "igcmd.exe";
                        p.StartInfo.Arguments = "igautoupdate";
                        p.Start();
                    }
                }
            }

            //save last update
            GlobalSetting.SetConfig("AutoUpdate", DateTime.Now.ToString("MM/dd/yyyy HH:mm:ss"));

            //get current config
            GlobalSetting.IsAllowMultiInstances = bool.Parse(GlobalSetting.GetConfig("IsAllowMultiInstances", "true"));

            //check if allows multi instances
            if (GlobalSetting.IsAllowMultiInstances)
            {
                Application.Run(formMain = new frmMain());
            }
            else
            {
                //single instance is required
                using (SingleInstance singleInstance = new SingleInstance(guid))
                {
                    if (singleInstance.IsFirstInstance)
                    {
                        singleInstance.ArgumentsReceived += SingleInstance_ArgumentsReceived;
                        singleInstance.ListenForArgumentsFromSuccessiveInstances();

                        Application.Run(formMain = new frmMain());
                    }
                    else
                    {
                        singleInstance.PassArgumentsToFirstInstance(Environment.GetCommandLineArgs());
                    }
                }
            } //end check multi instances
        }
示例#22
0
        static void Main(string[] argv)
        {
            // Check if the start up directory writable
            GlobalSetting.IsStartUpDirWritable = GlobalSetting.CheckStartUpDirWritable();


            // Set up Startup Profile to improve launch performance
            // https://blogs.msdn.microsoft.com/dotnet/2012/10/18/an-easy-solution-for-improving-app-launch-performance/
            ProfileOptimization.SetProfileRoot(GlobalSetting.ConfigDir());
            ProfileOptimization.StartProfile("igstartup.profile");

            // Issue #360: IG periodically searching for dismounted device
            SetErrorMode(ErrorModes.SEM_FAILCRITICALERRORS);

            // Windows Vista or later
            if (Environment.OSVersion.Version.Major >= 6)
            {
                SetProcessDPIAware();
            }

            Guid guid = new Guid(appGuid);

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


            // Save App version
            GlobalSetting.SetConfig("AppVersion", Application.ProductVersion.ToString());


            #region Check First-launch Configs
            var firstLaunchVersion = 0;

            int.TryParse(GlobalSetting.GetConfig("FirstLaunchVersion", "0"), out firstLaunchVersion);

            if (firstLaunchVersion < GlobalSetting.FIRST_LAUNCH_VERSION)
            {
                Process p = new Process();
                p.StartInfo.FileName  = GlobalSetting.StartUpDir("igcmd.exe");
                p.StartInfo.Arguments = "firstlaunch";

                try
                {
                    p.Start();
                }
                catch { }

                Application.Exit();
                return;
            }
            #endregion


            #region Auto update
            string lastUpdateConfig = GlobalSetting.GetConfig("AutoUpdate", "7/26/1991 12:13:08 AM");

            if (lastUpdateConfig != "0")
            {
                DateTime lastUpdate = DateTime.Now;

                if (DateTime.TryParseExact(lastUpdateConfig, "M/d/yyyy HH:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.None, out lastUpdate))
                {
                    //Check for update every 3 days
                    if (DateTime.Now.Subtract(lastUpdate).TotalDays > 3)
                    {
                        RunCheckForUpdate();
                    }
                }
                else
                {
                    RunCheckForUpdate();
                }
            }


            void RunCheckForUpdate()
            {
                Process p = new Process();

                p.StartInfo.FileName  = GlobalSetting.StartUpDir("igcmd.exe");
                p.StartInfo.Arguments = "igautoupdate";
                p.Start();

                //save last update
                GlobalSetting.SetConfig("AutoUpdate", DateTime.Now.ToString("M/d/yyyy HH:mm:ss"));
            }

            #endregion


            #region Multi instances
            //get current config
            GlobalSetting.IsAllowMultiInstances = bool.Parse(GlobalSetting.GetConfig("IsAllowMultiInstances", "true"));

            //check if allows multi instances
            if (GlobalSetting.IsAllowMultiInstances)
            {
                Application.Run(formMain = new frmMain());
            }
            else
            {
                //single instance is required
                using (SingleInstance singleInstance = new SingleInstance(guid))
                {
                    if (singleInstance.IsFirstInstance)
                    {
                        singleInstance.ArgumentsReceived += SingleInstance_ArgumentsReceived;
                        singleInstance.ListenForArgumentsFromSuccessiveInstances();

                        Application.Run(formMain = new frmMain());
                    }
                    else
                    {
                        singleInstance.PassArgumentsToFirstInstance(Environment.GetCommandLineArgs());
                    }
                }
            } //end check multi instances
            #endregion
        }
示例#23
0
        /// <summary>
        /// Get and load value of General tab
        /// </summary>
        private void LoadTabGeneralConfig()
        {
            //Get value of chkFindChildFolder
            chkFindChildFolder.Checked = bool.Parse(GlobalSetting.GetConfig("Recursive", "false"));

            //Get value of cmbAutoUpdate
            string s = GlobalSetting.GetConfig("AutoUpdate", DateTime.Now.ToString());

            if (s != "0")
            {
                chkAutoUpdate.Checked = true;
            }
            else
            {
                chkAutoUpdate.Checked = false;
            }

            //Get value of chkWelcomePicture
            chkWelcomePicture.Checked = bool.Parse(GlobalSetting.GetConfig("Welcome", "true"));

            //Get value of chkHideToolBar
            chkHideToolBar.Checked = bool.Parse(GlobalSetting.GetConfig("IsHideToolbar", "false"));

            //Get value of chkLoopSlideshow
            chkLoopSlideshow.Checked = bool.Parse(GlobalSetting.GetConfig("IsLoopBackSlideShow", "true"));

            //Get value of chkImageBoosterBack
            chkImageBoosterBack.Checked = bool.Parse(GlobalSetting.GetConfig("IsImageBoosterBack", "false"));

            //Get value of IsPressESCToQuit
            chkESCToQuit.Checked = bool.Parse(GlobalSetting.GetConfig("IsPressESCToQuit", "true"));

            //Get value of IsPressESCToQuit
            chkAllowMultiInstances.Checked = bool.Parse(GlobalSetting.GetConfig("IsAllowMultiInstances", "true"));

            //Get value of barInterval
            int i = int.Parse(GlobalSetting.GetConfig("Interval", "5"));

            if (0 < i && i < 61)
            {
                barInterval.Value = i;
            }
            else
            {
                barInterval.Value = 5;
            }

            lblSlideshowInterval.Text = string.Format(GlobalSetting.LangPack.Items["frmSetting.lblSlideshowInterval"],
                                                      barInterval.Value);

            //load thumbnail dimension
            i = int.Parse(GlobalSetting.GetConfig("ThumbnailDimension", "48"));
            GlobalSetting.ThumbnailDimension   = i;
            cmbThumbnailDimension.SelectedItem = i.ToString();

            //Load items of cmbImageOrder
            cmbImageOrder.Items.Clear();
            cmbImageOrder.Items.Add(GlobalSetting.LangPack.Items["frmSetting.cmbImageOrder._Name"]);
            cmbImageOrder.Items.Add(GlobalSetting.LangPack.Items["frmSetting.cmbImageOrder._Length"]);
            cmbImageOrder.Items.Add(GlobalSetting.LangPack.Items["frmSetting.cmbImageOrder._CreationTime"]);
            cmbImageOrder.Items.Add(GlobalSetting.LangPack.Items["frmSetting.cmbImageOrder._LastAccessTime"]);
            cmbImageOrder.Items.Add(GlobalSetting.LangPack.Items["frmSetting.cmbImageOrder._LastWriteTime"]);
            cmbImageOrder.Items.Add(GlobalSetting.LangPack.Items["frmSetting.cmbImageOrder._Extension"]);
            cmbImageOrder.Items.Add(GlobalSetting.LangPack.Items["frmSetting.cmbImageOrder._Random"]);

            //Get value of cmbImageOrder
            s = GlobalSetting.GetConfig("ImageLoadingOrder", "0");
            i = 0;
            if (int.TryParse(s, out i))
            {
                if (-1 < i && i < cmbImageOrder.Items.Count)
                {
                }
                else
                {
                    i = 0;
                }
            }
            cmbImageOrder.SelectedIndex = i;

            //Get background color
            picBackgroundColor.BackColor = GlobalSetting.BackgroundColor;
        }
        static void Main(string[] argv)
        {
            // Windows Vista or later
            if (Environment.OSVersion.Version.Major >= 6)
            {
                SetProcessDPIAware();
            }

            Guid guid = new Guid(appGuid);

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

            // Check if the start up directory writable
            GlobalSetting.IsStartUpDirWritable = GlobalSetting.CheckStartUpDirWritable();

            // Enable Portable mode as default if possible
            GlobalSetting.IsPortableMode = GlobalSetting.IsStartUpDirWritable;

            // Save App version
            GlobalSetting.SetConfig("AppVersion", Application.ProductVersion.ToString());

            #region Check First-launch Configs
            var firstLaunchVersion = 0;

            int.TryParse(GlobalSetting.GetConfig("FirstLaunchVersion", "0"), out firstLaunchVersion);

            if (firstLaunchVersion < GlobalSetting.FIRST_LAUNCH_VERSION)
            {
                Process p = new Process();
                p.StartInfo.FileName  = Path.Combine(GlobalSetting.StartUpDir, "igcmd.exe");
                p.StartInfo.Arguments = "firstlaunch";

                try
                {
                    p.Start();
                }
                catch { }

                Application.Exit();
                return;
            }
            #endregion


            #region Auto update
            string lastUpdateConfig = GlobalSetting.GetConfig("AutoUpdate", "7/26/1991 12:13:08 AM");

            if (lastUpdateConfig != "0")
            {
                DateTime lastUpdate = DateTime.Now;

                if (DateTime.TryParseExact(lastUpdateConfig, "M/d/yyyy HH:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.None, out lastUpdate))
                {
                    //Check for update every 3 days
                    if (DateTime.Now.Subtract(lastUpdate).TotalDays > 3)
                    {
                        RunCheckForUpdate();
                    }
                }
                else
                {
                    RunCheckForUpdate();
                }
            }


            void RunCheckForUpdate()
            {
                Process p = new Process();

                p.StartInfo.FileName  = GlobalSetting.StartUpDir + "igcmd.exe";
                p.StartInfo.Arguments = "igautoupdate";
                p.Start();

                //save last update
                GlobalSetting.SetConfig("AutoUpdate", DateTime.Now.ToString("M/d/yyyy HH:mm:ss"));
            }

            #endregion


            #region Multi instances
            //get current config
            GlobalSetting.IsAllowMultiInstances = bool.Parse(GlobalSetting.GetConfig("IsAllowMultiInstances", "true"));

            //check if allows multi instances
            if (GlobalSetting.IsAllowMultiInstances)
            {
                Application.Run(formMain = new frmMain());
            }
            else
            {
                //single instance is required
                using (SingleInstance singleInstance = new SingleInstance(guid))
                {
                    if (singleInstance.IsFirstInstance)
                    {
                        singleInstance.ArgumentsReceived += SingleInstance_ArgumentsReceived;
                        singleInstance.ListenForArgumentsFromSuccessiveInstances();

                        Application.Run(formMain = new frmMain());
                    }
                    else
                    {
                        singleInstance.PassArgumentsToFirstInstance(Environment.GetCommandLineArgs());
                    }
                }
            } //end check multi instances
            #endregion
        }
示例#25
0
        /// <summary>
        /// Get and load value of General tab
        /// </summary>
        private void LoadTabGeneralConfig()
        {
            //Get value of chkFindChildFolder
            chkFindChildFolder.Checked = bool.Parse(GlobalSetting.GetConfig("Recursive", "false"));

            //Get value of cmbAutoUpdate
            string s = GlobalSetting.GetConfig("AutoUpdate", DateTime.Now.ToString());

            if (s != "0")
            {
                chkAutoUpdate.Checked = true;
            }
            else
            {
                chkAutoUpdate.Checked = false;
            }

            //Get value of chkWelcomePicture
            chkWelcomePicture.Checked = bool.Parse(GlobalSetting.GetConfig("Welcome", "true"));

            //Get value of chkHideToolBar
            chkHideToolBar.Checked = bool.Parse(GlobalSetting.GetConfig("IsHideToolbar", "false"));

            //Get value of chkLoopSlideshow
            chkLoopSlideshow.Checked = bool.Parse(GlobalSetting.GetConfig("IsLoopBackSlideShow", "true"));

            //Load items of cmbZoomOptimization
            cmbZoomOptimization.Items.Clear();
            cmbZoomOptimization.Items.Add(GlobalSetting.LangPack.Items["frmSetting.cmbZoomOptimization._Auto"]);
            cmbZoomOptimization.Items.Add(GlobalSetting.LangPack.Items["frmSetting.cmbZoomOptimization._SmoothPixels"]);
            cmbZoomOptimization.Items.Add(GlobalSetting.LangPack.Items["frmSetting.cmbZoomOptimization._ClearPixels"]);

            //Get value of cmbZoomOptimization
            s = GlobalSetting.GetConfig("ZoomOptimize", "0");
            int i = 0;

            if (int.TryParse(s, out i))
            {
                if (-1 < i && i < cmbZoomOptimization.Items.Count)
                {
                }
                else
                {
                    i = 0;
                }
            }
            cmbZoomOptimization.SelectedIndex = i;

            //Get value of barInterval
            i = int.Parse(GlobalSetting.GetConfig("Interval", "5"));
            if (0 < i && i < 61)
            {
                barInterval.Value = i;
            }
            else
            {
                barInterval.Value = 5;
            }

            lblSlideshowInterval.Text = string.Format(GlobalSetting.LangPack.Items["frmSetting.lblSlideshowInterval"],
                                                      barInterval.Value);

            //Load items of cmbImageOrder
            cmbImageOrder.Items.Clear();
            cmbImageOrder.Items.Add(GlobalSetting.LangPack.Items["frmSetting.cmbImageOrder._Name"]);
            cmbImageOrder.Items.Add(GlobalSetting.LangPack.Items["frmSetting.cmbImageOrder._Length"]);
            cmbImageOrder.Items.Add(GlobalSetting.LangPack.Items["frmSetting.cmbImageOrder._CreationTime"]);
            cmbImageOrder.Items.Add(GlobalSetting.LangPack.Items["frmSetting.cmbImageOrder._LastAccessTime"]);
            cmbImageOrder.Items.Add(GlobalSetting.LangPack.Items["frmSetting.cmbImageOrder._LastWriteTime"]);
            cmbImageOrder.Items.Add(GlobalSetting.LangPack.Items["frmSetting.cmbImageOrder._Extension"]);
            cmbImageOrder.Items.Add(GlobalSetting.LangPack.Items["frmSetting.cmbImageOrder._Random"]);

            //Get value of cmbImageOrder
            s = GlobalSetting.GetConfig("ImageLoadingOrder", "0");
            i = 0;
            if (int.TryParse(s, out i))
            {
                if (-1 < i && i < cmbImageOrder.Items.Count)
                {
                }
                else
                {
                    i = 0;
                }
            }
            cmbImageOrder.SelectedIndex = i;

            //Get background color
            picBackgroundColor.BackColor = GlobalSetting.BackgroundColor;
        }