コード例 #1
0
ファイル: App.xaml.cs プロジェクト: euphorbiacz/ClassicAssist
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            ExceptionlessClient.Default.Configuration.DefaultData.Add("Locale",
                                                                      Thread.CurrentThread.CurrentUICulture.Name);
            ExceptionlessClient.Default.Startup(Settings.Default.ExceptionlessKey);

            Parser.Default.ParseArguments <CommandLineOptions>(e.Args).WithParsed(o => CurrentOptions = o);

            if (string.IsNullOrEmpty(CurrentOptions.Path))
            {
                CurrentOptions.Path = Environment.CurrentDirectory;
            }

            UpdaterSettings = UpdaterSettings.Load(CurrentOptions.Path ?? Environment.CurrentDirectory);
            Exit           += (s, ea) =>
                              UpdaterSettings.Save(UpdaterSettings, CurrentOptions.Path ?? Environment.CurrentDirectory);

            if (CurrentOptions.CurrentVersion != null)
            {
                return;
            }

            string dllPath = IOPath.Combine(CurrentOptions.Path, "ClassicAssist.dll");

            try
            {
                CurrentOptions.CurrentVersion = VersionHelpers.GetProductVersion(dllPath).ToString();
            }
            catch (Exception)
            {
                CurrentOptions.Force = true;
            }
        }
コード例 #2
0
ファイル: SettingsManager.cs プロジェクト: rajeshwarn/Comet
 /// <summary>
 ///     Initializes a new instance of the <see cref="SettingsManager" /> class.
 /// </summary>
 public SettingsManager()
 {
     _filePath            = string.Empty;
     _applicationSettings = new ApplicationSettings {
         MaxRecentProjects = 7
     };
     _updaterSettings = new UpdaterSettings();
 }
コード例 #3
0
        internal UpdaterSettings Load()
        {
            UpdaterSettings settings = null;
            try
            {
                string path =
                    Application.Settings.StartupPath +
                    Path.DirectorySeparatorChar +
                    "Updater" +
                    Path.DirectorySeparatorChar +
                    "UpdaterSettings.xml";

                if (File.Exists(path))
                {

                    XmlDocument doc = new System.Xml.XmlDocument();
                    doc.Load(path);

                    XmlNode details = doc.SelectSingleNode("Settings");
                    if (details != null && details.HasChildNodes)
                    {
                        settings = new UpdaterSettings();

                        XmlNode node = details.SelectSingleNode("UpdateUri");
                        if (node != null)
                        {
                            settings.UpdateUri = node.InnerText;
                        }

                        node = details.SelectSingleNode("AutoCheckForUpdates");
                        if (node != null)
                        {
                            settings.AutoCheckForUpdates = ConvertToBoolean(node.InnerText);
                        }

                        node = details.SelectSingleNode("AutoUpdateCheckInterval");
                        if (node != null)
                        {
                            settings.AutoUpdateCheckInterval = ConvertToInt(node.InnerText);
                        }

                        node = details.SelectSingleNode("AutoDownloadUpdate");
                        if (node != null)
                        {
                            settings.AutoDownloadUpdate = ConvertToBoolean(node.InnerText);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                //EventLogger.Instance.Add(ex.Message);
            }

            return settings;
        }
コード例 #4
0
ファイル: FormBrowser.cs プロジェクト: gomson/TweetDuck
        public FormBrowser(UpdaterSettings updaterSettings)
        {
            InitializeComponent();

            Text = Program.BrandName;

            this.plugins           = new PluginManager(Program.PluginPath, Program.PluginConfigFilePath);
            this.plugins.Reloaded += plugins_Reloaded;
            this.plugins.Executed += plugins_Executed;
            this.plugins.Reload();

            this.notification = new FormNotificationTweet(this, plugins);
            this.notification.Show();

            this.browser             = new TweetDeckBrowser(this, plugins, new TweetDeckBridge(this, notification));
            this.browser.PageLoaded += browser_PageLoaded;

            this.contextMenu = ContextMenuBrowser.CreateMenu(this);

            Controls.Add(new MenuStrip {
                Visible = false
            });                                             // fixes Alt freezing the program in Win 10 Anniversary Update

            Disposed += (sender, args) => {
                Config.MuteToggled         -= Config_MuteToggled;
                Config.TrayBehaviorChanged -= Config_TrayBehaviorChanged;

                browser.Dispose();
                contextMenu.Dispose();

                notificationScreenshotManager?.Dispose();
                soundNotification?.Dispose();
                videoPlayer?.Dispose();
                analytics?.Dispose();
            };

            Config.MuteToggled += Config_MuteToggled;

            this.trayIcon.ClickRestore += trayIcon_ClickRestore;
            this.trayIcon.ClickClose   += trayIcon_ClickClose;
            Config.TrayBehaviorChanged += Config_TrayBehaviorChanged;

            UpdateTrayIcon();

            this.updates = browser.CreateUpdateHandler(updaterSettings);
            this.updates.UpdateAccepted  += updates_UpdateAccepted;
            this.updates.UpdateDismissed += updates_UpdateDismissed;

            RestoreWindow();
        }
コード例 #5
0
ファイル: Options.cs プロジェクト: rajeshwarn/Comet
        /// <summary>
        ///     Updates the settings manager with the latest options.
        /// </summary>
        private void UpdateSettings()
        {
            ApplicationSettings _applicationSettings = new ApplicationSettings
            {
                MaxRecentProjects = Convert.ToInt32(NudMaximumRecentProjects.Value)
            };

            UpdaterSettings _updaterSettings = new UpdaterSettings
            {
                AutoUpdate                 = CbAutoUpdate.Checked,
                DisplayWelcomePage         = CbDisplayWelcomePage.Checked,
                NotifyUpdateReadyToInstall = CbNotifyBeforeInstallingUpdates.Checked
            };

            ControlPanel.SettingsManager.ApplicationSettings = _applicationSettings;
            ControlPanel.SettingsManager.UpdaterSettings     = _updaterSettings;
        }
コード例 #6
0
        public static bool SaveSettings(UpdaterSettings settings)
        {
            try
            {
                if (repo == null)
                {
                    repo = new Repository.ApplicationUpdater();
                }

                if (!settings.UpdateUri.Contains("http://"))
                {
                    settings.UpdateUri = "http://" + settings.UpdateUri;
                }

                return(repo.Save(settings));
            }
            catch (Exception ex)
            {
                //EventLogger.Instance.Add(ex.Message);
            }

            return(false);
        }
コード例 #7
0
        private static void CleanupAfterUpdate()
        {
            UpdaterSettings s = Settings.TheSettings.Updater;

            if (s.CleanupAfterUpdate)
            {
                Log.Info("Cleaning up old version files...");
                s.CleanupAfterUpdate = false;

                int count = 0;
                while (s.CleanupList.Count > 0)
                {
                    try
                    {
                        File.Delete(s.CleanupList[0]);
                        Log.Info($"Deleted {s.CleanupList[0]}");
                        count++;
                    }
                    catch (Exception e)
                    {
                        if (e is DirectoryNotFoundException ||
                            e is UnauthorizedAccessException)
                        {
                            Log.Exception(e);
                            continue;
                        }

                        throw;
                    }

                    s.CleanupList.RemoveAt(0);
                }

                Log.Info(string.Format("Cleaned up {0} file{1}.", count, count != 1 ? "s" : ""));
            }
        }
コード例 #8
0
        public override void LoadDefaults()
        {
            Locale = "en";

            PrivateMessageFormat  = "(From {0}): {1}";
            PrivateMessageFormat2 = "(To {0}): {1}";

            UnfreezeOnDeath = true;
            UnfreezeOnQuit  = true;

            AdminBypassWarpCooldown = true;
            PerWarpPermission       = true;
            WarpCooldown            = 5;

            EnableJoinLeaveMessage = true;
            EnableUnknownMessage   = true;
            EnableTextCommands     = true;
            EnableDeathMessages    = true;

            EnablePollRunningMessage   = true;
            PollRunningMessageCooldown = 20;
            ServerFrameRate            = -1;  // http://docs.unity3d.com/ScriptReference/Application-targetFrameRate.html

            AutoAnnouncer = new AutoAnnouncer();
            AutoAnnouncer.LoadDefaults();

            AutoCommands = new AutoCommands();
            AutoCommands.LoadDefaults();

            AntiSpam = new AntiSpamSettings {
                Enabled  = true,
                Interval = 3
            };

            Updater = new UpdaterSettings {
                CheckUpdates   = true,
                DownloadLatest = true,
                AlertOnJoin    = true
            };

            HomeCommand = new HomeCommandSettings {
                Cooldown       = 30, Delay = 5,
                CancelWhenMove = true
            };

            WebKits = new WebKitsSettings {
                Enabled = false, Url = ""
            };

            WebConfig = new WebConfigSettings {
                Enabled = false, Url = ""
            };

            Kit = new KitSettings {
                ShowCost   = true, ShowCostIfZero = false,
                CostFormat = "{0}({1}{2})", GlobalCooldown = 0,
                ResetGlobalCooldownWhenDie = false
            };

            Tpa = new TpaSettings {
                ExpireDelay = 10, TeleportDelay = 5
            };

            Economy = new EconomySettings {
                UseXp      = false, UconomyCurrency = "$",
                XpCurrency = "Xp"
            };

            GiveItemBlacklist = new List <ushort>();
            VehicleBlacklist  = new List <ushort>();
            DisabledCommands  = new List <string>();
            EnabledSystems    = new List <string> {
                "kits", "warps"
            };

            ItemSpawnLimit = 10;
        }
コード例 #9
0
ファイル: EssConfig.cs プロジェクト: nausofficial/uEssentials
        public override void LoadDefaults()
        {
            Locale = "en";

            BackDelay = 10;

            UnfreezeOnDeath = true;
            UnfreezeOnQuit  = true;

            EnableJoinLeaveMessage       = true;
            EnableTextCommands           = true;
            EnableDeathMessages          = true;
            ShowPermissionOnErrorMessage = true;
            SaveCommandCooldowns         = false;

            EnablePollRunningMessage   = true;
            PollRunningMessageCooldown = 20;
            ServerFrameRate            = -1; // http://docs.unity3d.com/ScriptReference/Application-targetFrameRate.html

            AutoAnnouncer = new AutoAnnouncer();
            AutoAnnouncer.LoadDefaults();

            AutoCommands = new AutoCommands();
            AutoCommands.LoadDefaults();

            PrivateMessage = new PrivateMessageSettings {
                FormatFrom         = "(From {0}): {1}",
                FormatTo           = "(To {0}): {1}",
                FormatSpy          = "<gray>Spy: {0} -> {1}: {2}",
                ConsoleDisplayName = "*console*"
            };

            AntiSpam = new AntiSpamSettings {
                Enabled  = true,
                Interval = 3
            };

            Updater = new UpdaterSettings {
                CheckUpdates   = true,
                DownloadLatest = true,
                AlertOnJoin    = true
            };

            Home = new HomeCommandSettings {
                TeleportDelay          = 5,
                CancelTeleportWhenMove = true
            };

            Warp = new WarpCommandSettings {
                TeleportDelay          = 5,
                PerWarpPermission      = true,
                CancelTeleportWhenMove = false
            };

            Kit = new KitSettings {
                ShowCost                   = true,
                ShowCostIfZero             = false,
                CostFormat                 = "{0}({1}{2})",
                GlobalCooldown             = 0,
                ResetGlobalCooldownWhenDie = false
            };

            Tpa = new TpaSettings {
                ExpireDelay            = 10,
                TeleportDelay          = 5,
                CancelTeleportWhenMove = true
            };

            Economy = new EconomySettings {
                UseXp           = false,
                UconomyCurrency = "$",
                XpCurrency      = "Xp"
            };

            VehicleFeatures = new VehicleFeaturesSettings {
                RefuelPercentage = 20,
                RepairPercentage = 70
            };

            ItemFeatures = new ItemFeaturesSettings {
                ReloadPercentage = 80,
                RepairPercentage = 80
            };

            GiveItemBlacklist  = new HashSet <ushort>();
            VehicleBlacklist   = new HashSet <ushort>();
            DisabledCommands   = new List <string>();
            CommandsToOverride = new HashSet <string>(StringComparer.InvariantCultureIgnoreCase);
            EnabledSystems     = new HashSet <string>(StringComparer.InvariantCultureIgnoreCase)
            {
                "kits", "warps"
            };

            ItemSpawnLimit = 10;
        }
コード例 #10
0
ファイル: FormBrowser.cs プロジェクト: PlumpMath/TweetDuck
        public FormBrowser(PluginManager pluginManager, UpdaterSettings updaterSettings)
        {
            InitializeComponent();

            Text = Program.BrandName;

            this.plugins                     = pluginManager;
            this.plugins.Reloaded           += plugins_Reloaded;
            this.plugins.PluginChangedState += plugins_PluginChangedState;

            this.contextMenu = ContextMenuBrowser.CreateMenu(this);

            this.notification = new FormNotificationTweet(this, plugins)
            {
                #if DEBUG
                CanMoveWindow = () => (ModifierKeys & Keys.Alt) == Keys.Alt
                #else
                CanMoveWindow = () => false
                #endif
            };

            this.notification.Show();

            this.browser = new ChromiumWebBrowser("https://tweetdeck.twitter.com/")
            {
                MenuHandler     = new ContextMenuBrowser(this),
                JsDialogHandler = new JavaScriptDialogHandler(),
                LifeSpanHandler = new LifeSpanHandler()
            };

            #if DEBUG
            this.browser.ConsoleMessage += BrowserUtils.HandleConsoleMessage;
            #endif

            this.browser.LoadingStateChanged += browser_LoadingStateChanged;
            this.browser.FrameLoadStart      += browser_FrameLoadStart;
            this.browser.FrameLoadEnd        += browser_FrameLoadEnd;
            this.browser.LoadError           += browser_LoadError;
            this.browser.RegisterAsyncJsObject("$TD", new TweetDeckBridge(this, notification));
            this.browser.RegisterAsyncJsObject("$TDP", plugins.Bridge);

            browser.BrowserSettings.BackgroundColor = (uint)BrowserUtils.BackgroundColor.ToArgb();
            browser.Dock     = DockStyle.None;
            browser.Location = ControlExtensions.InvisibleLocation;
            Controls.Add(browser);

            Controls.Add(new MenuStrip {
                Visible = false
            });                                             // fixes Alt freezing the program in Win 10 Anniversary Update

            Disposed += (sender, args) => {
                browser.Dispose();
                contextMenu.Dispose();

                if (notificationScreenshotManager != null)
                {
                    notificationScreenshotManager.Dispose();
                }

                if (soundNotification != null)
                {
                    soundNotification.Dispose();
                }
            };

            this.trayIcon.ClickRestore += trayIcon_ClickRestore;
            this.trayIcon.ClickClose   += trayIcon_ClickClose;
            Config.TrayBehaviorChanged += Config_TrayBehaviorChanged;

            UpdateTrayIcon();

            Config.MuteToggled += Config_MuteToggled;

            this.updates = new UpdateHandler(browser, this, updaterSettings);
            this.updates.UpdateAccepted  += updates_UpdateAccepted;
            this.updates.UpdateDismissed += updates_UpdateDismissed;

            RestoreWindow();
        }
コード例 #11
0
ファイル: Program.cs プロジェクト: gomson/TweetDuck
        private static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Cef.EnableHighDPISupport();

            WindowRestoreMessage = NativeMethods.RegisterWindowMessage("TweetDuckRestore");
            SubProcessMessage    = NativeMethods.RegisterWindowMessage("TweetDuckSubProcess");

            if (!WindowsUtils.CheckFolderWritePermission(StoragePath))
            {
                FormMessage.Warning("Permission Error", "TweetDuck does not have write permissions to the storage folder: " + StoragePath, FormMessage.OK);
                return;
            }

            if (Arguments.HasFlag(Arguments.ArgRestart))
            {
                LockManager.Result lockResult = LockManager.LockWait(10000);

                while (lockResult != LockManager.Result.Success)
                {
                    if (lockResult == LockManager.Result.Fail)
                    {
                        FormMessage.Error("TweetDuck Has Failed :(", "An unknown error occurred accessing the data folder. Please, make sure TweetDuck is not already running. If the problem persists, try restarting your system.", FormMessage.OK);
                        return;
                    }
                    else if (!FormMessage.Warning("TweetDuck Cannot Restart", "TweetDuck is taking too long to close.", FormMessage.Retry, FormMessage.Exit))
                    {
                        return;
                    }

                    lockResult = LockManager.LockWait(5000);
                }
            }
            else
            {
                LockManager.Result lockResult = LockManager.Lock();

                if (lockResult == LockManager.Result.HasProcess)
                {
                    if (!LockManager.RestoreLockingProcess(2000) && FormMessage.Error("TweetDuck is Already Running", "Another instance of TweetDuck is already running.\nDo you want to close it?", FormMessage.Yes, FormMessage.No))
                    {
                        if (!LockManager.CloseLockingProcess(10000, 5000))
                        {
                            FormMessage.Error("TweetDuck Has Failed :(", "Could not close the other process.", FormMessage.OK);
                            return;
                        }

                        lockResult = LockManager.Lock();
                    }
                    else
                    {
                        return;
                    }
                }

                if (lockResult != LockManager.Result.Success)
                {
                    FormMessage.Error("TweetDuck Has Failed :(", "An unknown error occurred accessing the data folder. Please, make sure TweetDuck is not already running. If the problem persists, try restarting your system.", FormMessage.OK);
                    return;
                }
            }

            UserConfig   = UserConfig.Load(UserConfigFilePath);
            SystemConfig = SystemConfig.Load(SystemConfigFilePath);

            if (Arguments.HasFlag(Arguments.ArgImportCookies))
            {
                ExportManager.ImportCookies();
            }
            else if (Arguments.HasFlag(Arguments.ArgDeleteCookies))
            {
                ExportManager.DeleteCookies();
            }

            if (Arguments.HasFlag(Arguments.ArgUpdated))
            {
                WindowsUtils.TryDeleteFolderWhenAble(InstallerPath, 8000);
            }

            CefSharpSettings.WcfEnabled = false;

            CefSettings settings = new CefSettings {
                AcceptLanguageList    = BrowserUtils.HeaderAcceptLanguage,
                UserAgent             = BrowserUtils.HeaderUserAgent,
                Locale                = Arguments.GetValue(Arguments.ArgLocale, string.Empty),
                BrowserSubprocessPath = BrandName + ".Browser.exe",
                CachePath             = StoragePath,
                LogFile               = ConsoleLogFilePath,
                #if !DEBUG
                LogSeverity = Arguments.HasFlag(Arguments.ArgLogging) ? LogSeverity.Info : LogSeverity.Disable
                #endif
            };

            CommandLineArgs.ReadCefArguments(UserConfig.CustomCefArgs).ToDictionary(settings.CefCommandLineArgs);
            BrowserUtils.SetupCefArgs(settings.CefCommandLineArgs);

            Cef.Initialize(settings, false, new BrowserProcessHandler());

            Application.ApplicationExit += (sender, args) => ExitCleanup();

            UpdaterSettings updaterSettings = new UpdaterSettings {
                AllowPreReleases        = Arguments.HasFlag(Arguments.ArgDebugUpdates),
                DismissedUpdate         = UserConfig.DismissedUpdate,
                InstallerDownloadFolder = InstallerPath
            };

            FormBrowser mainForm = new FormBrowser(updaterSettings);

            Application.Run(mainForm);

            if (mainForm.UpdateInstallerPath != null)
            {
                ExitCleanup();

                // ProgramPath has a trailing backslash
                string updaterArgs = "/SP- /SILENT /CLOSEAPPLICATIONS /UPDATEPATH=\"" + ProgramPath + "\" /RUNARGS=\"" + Arguments.GetCurrentForInstallerCmd() + "\"" + (IsPortable ? " /PORTABLE=1" : "");
                bool   runElevated = !IsPortable || !WindowsUtils.CheckFolderWritePermission(ProgramPath);

                if (WindowsUtils.OpenAssociatedProgram(mainForm.UpdateInstallerPath, updaterArgs, runElevated))
                {
                    Application.Exit();
                }
                else
                {
                    RestartWithArgsInternal(Arguments.GetCurrentClean());
                }
            }
        }
コード例 #12
0
        public FormBrowser(PluginManager pluginManager, UpdaterSettings updaterSettings)
        {
            InitializeComponent();

            Text = Program.BrandName;

            this.plugins                     = pluginManager;
            this.plugins.Reloaded           += plugins_Reloaded;
            this.plugins.PluginChangedState += plugins_PluginChangedState;

            this.notification = CreateNotificationForm(NotificationFlags.AutoHide | NotificationFlags.TopMost);
            #if DEBUG
            this.notification.CanMoveWindow = () => (ModifierKeys & Keys.Alt) == Keys.Alt;
            #else
            this.notification.CanMoveWindow = () => false;
            #endif
            this.notification.Show();

            this.browser = new ChromiumWebBrowser("https://tweetdeck.twitter.com/")
            {
                MenuHandler     = new ContextMenuBrowser(this),
                DialogHandler   = new FileDialogHandler(this),
                JsDialogHandler = new JavaScriptDialogHandler(),
                LifeSpanHandler = new LifeSpanHandler()
            };

            #if DEBUG
            this.browser.ConsoleMessage += BrowserUtils.HandleConsoleMessage;
            #endif

            this.browser.LoadingStateChanged += Browser_LoadingStateChanged;
            this.browser.FrameLoadEnd        += Browser_FrameLoadEnd;
            this.browser.RegisterAsyncJsObject("$TD", new TweetDeckBridge(this, notification));
            this.browser.RegisterAsyncJsObject("$TDP", plugins.Bridge);

            Controls.Add(browser);

            Disposed += (sender, args) => {
                browser.Dispose();

                if (notificationScreenshotManager != null)
                {
                    notificationScreenshotManager.Dispose();
                }

                if (notificationSound != null)
                {
                    notificationSound.Dispose();
                }
            };

            this.trayIcon.ClickRestore += trayIcon_ClickRestore;
            this.trayIcon.ClickClose   += trayIcon_ClickClose;
            Config.TrayBehaviorChanged += Config_TrayBehaviorChanged;

            UpdateTrayIcon();

            Config.MuteToggled += Config_MuteToggled;

            this.updates = new UpdateHandler(browser, this, updaterSettings);
            this.updates.UpdateAccepted  += updates_UpdateAccepted;
            this.updates.UpdateDismissed += updates_UpdateDismissed;
        }
コード例 #13
0
ファイル: SettingsManager.cs プロジェクト: rajeshwarn/Comet
 /// <summary>Initializes a new instance of the <see cref="SettingsManager" /> class. </summary>
 /// <param name="filePath">The settings file Path.</param>
 /// <param name="applicationSettings">The application settings.</param>
 /// <param name="updaterSettings">The updater settings.</param>
 public SettingsManager(string filePath, ApplicationSettings applicationSettings, UpdaterSettings updaterSettings) : this()
 {
     _filePath            = filePath;
     _applicationSettings = applicationSettings;
     _updaterSettings     = updaterSettings;
 }