Пример #1
0
 /// <summary>
 /// Static constructor
 /// </summary>
 static Settings()
 {
     UI = new UISettings();
     G15 = new G15Settings();
     IGB = new IGBSettings();
     Proxy = new ProxySettings(); 
     Updates = new UpdateSettings();
     Calendar = new CalendarSettings();
     Exportation = new ExportationSettings();
     Notifications = new NotificationSettings();
 }
Пример #2
0
        /// <summary>
        /// Static constructor.
        /// </summary>
        static Settings()
        {
            UI = new UISettings();
            G15 = new G15Settings();
            IGB = new IgbSettings();
            Proxy = new ProxySettings();
            Updates = new UpdateSettings();
            Calendar = new CalendarSettings();
            Exportation = new ExportationSettings();
            MarketPricer = new MarketPricerSettings();
            Notifications = new NotificationSettings();
            LoadoutsProvider = new LoadoutsProviderSettings();
            PortableEveInstallations = new PortableEveInstallationsSettings();
            CloudStorageServiceProvider = new CloudStorageServiceProviderSettings();

            EveMonClient.TimerTick += EveMonClient_TimerTick;
        }
Пример #3
0
        public SerializableSettings()
        {
            Plans = new List<SerializablePlan>();
            Accounts = new List<SerializableAccount>();
            Characters = new List<SerializableSettingsCharacter>();
            MonitoredCharacters = new List<MonitoredCharacterSettings>();

            APIProviders = new SerializableAPIProviders();
            Notifications = new NotificationSettings();
            Exportation = new ExportationSettings();
            Scheduler = new SerializableScheduler();
            Calendar = new CalendarSettings();
            Updates = new UpdateSettings();
            Proxy = new ProxySettings();
            IGB = new IGBSettings();
            G15 = new G15Settings();
            UI = new UISettings();
        }
Пример #4
0
 public SerializableSettings()
 {
     m_plans = new Collection<SerializablePlan>();
     m_apiKeys = new Collection<SerializableAPIKey>();
     m_characters = new Collection<SerializableSettingsCharacter>();
     m_monitoredCharacters = new Collection<MonitoredCharacterSettings>();
     CloudStorageServiceProvider = new CloudStorageServiceProviderSettings();
     PortableEveInstallations = new PortableEveInstallationsSettings();
     Notifications = new NotificationSettings();
     APIProviders = new APIProvidersSettings();
     LoadoutsProvider = new LoadoutsProviderSettings();
     MarketPricer = new MarketPricerSettings();
     Exportation = new ExportationSettings();
     Scheduler = new SchedulerSettings();
     Calendar = new CalendarSettings();
     Updates = new UpdateSettings();
     Proxy = new ProxySettings();
     IGB = new IgbSettings();
     G15 = new G15Settings();
     UI = new UISettings();
 }
Пример #5
0
        /// <summary>
        /// Performs the sending of the mail
        /// </summary>
        /// <param name="settings">Settings object to use when sending</param>
        /// <param name="subject">Subject of the message</param>
        /// <param name="body">Body of the message</param>
        /// <returns>True if no exceptions thrown, otherwise false</returns>
        /// <remarks>
        /// NotificationSettings object is required to support
        /// alternative settings from Tools -> Options. Use
        /// Settings.Notifications unless using an alternative
        /// configuration.
        /// </remarks>
        private static void SendMail(NotificationSettings settings, string subject, string body)
        {
            // Trace something to the logs so we can identify the time the message was sent
            EveMonClient.Trace($"(Subject - {subject}; Server - {settings.EmailSmtpServerAddress}:{settings.EmailPortNumber})");

            string sender = String.IsNullOrEmpty(settings.EmailFromAddress)
                ? "*****@*****.**"
                : settings.EmailFromAddress;

            List<string> toAddresses = settings.EmailToAddress.Split(
                new[] { ';', ',' }, StringSplitOptions.RemoveEmptyEntries).ToList();

            try
            {
                // Set up message
                s_mailMessage = new MailMessage();
                toAddresses.ForEach(address => s_mailMessage.To.Add(address.Trim()));
                s_mailMessage.From = new MailAddress(sender);
                s_mailMessage.Subject = subject;
                s_mailMessage.Body = body;

                // Set up client
                s_smtpClient = GetClient(settings);

                // Send message
                s_smtpClient.SendAsync(s_mailMessage, null);
            }
            catch (Exception e)
            {
                ExceptionHandler.LogException(e, true);
                MessageBox.Show(@"The message failed to send.", @"EVEMon Emailer Failure", MessageBoxButtons.OK,
                    MessageBoxIcon.Warning);
            }
        }
Пример #6
0
        /// <summary>
        /// Gets the client.
        /// </summary>
        /// <param name="settings">The settings.</param>
        /// <returns></returns>
        private static SmtpClient GetClient(NotificationSettings settings)
        {
            SmtpClient client = new SmtpClient
            {
                DeliveryMethod = SmtpDeliveryMethod.Network,
                Timeout = (int)TimeSpan.FromSeconds(Settings.Updates.HttpTimeout).TotalMilliseconds,

                // Host and port
                Host = settings.EmailSmtpServerAddress,
                Port = settings.EmailPortNumber,

                // SSL
                EnableSsl = settings.EmailServerRequiresSsl
            };

            ServicePointManager.ServerCertificateValidationCallback = (s, certificate, chain, sslPolicyErrors) => true;

            client.SendCompleted += SendCompleted;

            if (!settings.EmailAuthenticationRequired)
                return client;

            // Credentials
            client.UseDefaultCredentials = false;
            client.Credentials = new NetworkCredential(settings.EmailAuthenticationUserName,
                Util.Decrypt(settings.EmailAuthenticationPassword,
                    settings.EmailAuthenticationUserName));

            return client;
        }
Пример #7
0
 /// <summary>
 /// Sends a test mail
 /// </summary>
 /// <param name="settings">NotificationSettings object</param>
 /// <remarks>
 /// A notification settings object is required, as this function
 /// is called from the Settings Window, and assumibly the user
 /// is changing settings.
 /// </remarks>
 /// <returns>False if an exception was thrown, otherwise True.</returns>
 public static void SendTestMail(NotificationSettings settings)
 {
     s_isTestMail = true;
     SendMail(settings, "EVEMon Test Mail", "This is a test email sent by EVEMon");
 }
Пример #8
0
        /// <summary>
        /// Populates the notifications from controls.
        /// </summary>
        /// <param name="notificationSettings">The notification settings.</param>
        private void PopulateNotificationsFromControls(out NotificationSettings notificationSettings)
        {
            notificationSettings = notificationsControl.Settings;
            notificationSettings.PlaySoundOnSkillCompletion = cbPlaySoundOnSkillComplete.Checked;

            notificationSettings.EmailToAddress = tbToAddress.Text;
            notificationSettings.EmailFromAddress = tbFromAddress.Text;
            notificationSettings.EmailSmtpServer = tbMailServer.Text;

            // Try and get a usable number out of the text box
            int emailPortNumber = notificationSettings.EmailPortNumber;
            if (Int32.TryParse(emailPortTextBox.Text, out emailPortNumber))
            {
                notificationSettings.EmailPortNumber = emailPortNumber;
            }
            // Failing that just set to the IANA assigned port for SMTP
            else
            {
                notificationSettings.EmailPortNumber = 25;
            }

            notificationSettings.EmailServerRequiresSSL = cbEmailServerRequireSsl.Checked;
            notificationSettings.EmailAuthenticationRequired = cbEmailAuthRequired.Checked;
            notificationSettings.EmailAuthenticationUserName = tbEmailUsername.Text;
            notificationSettings.EmailAuthenticationPassword = tbEmailPassword.Text;
            notificationSettings.UseEmailShortFormat = cbEmailUseShortFormat.Checked;
            notificationSettings.SendMailAlert = mailNotificationCheckBox.Checked;
        }
Пример #9
0
        /// <summary>
        /// Alerts > Email alerts > Send test email button.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void emailTestButton_Click(object sender, EventArgs e)
        {
            NotificationSettings configuredValues = new NotificationSettings();
            PopulateNotificationsFromControls(out configuredValues);

            if (!Emailer.SendTestMail(configuredValues))
            {
                MessageBox.Show("The message failed to send.", "Mail Failure", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                MessageBox.Show("The message sent successfully. Please verify that the message was received.",
                                "Mail Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Пример #10
0
        /// <summary>
        /// Fetches the controls' values to <see cref="m_settings"/>.
        /// </summary>
        private bool ApplyToSettings()
        {
            // General - Compatibility
            m_settings.Compatibility = (CompatibilityMode)Math.Max(0, compatibilityCombo.SelectedIndex);
            m_settings.UI.SafeForWork = cbWorksafeMode.Checked;

            // Skill Planner
            m_settings.UI.PlanWindow.HighlightPrerequisites = cbHighlightPrerequisites.Checked;
            m_settings.UI.PlanWindow.HighlightPlannedSkills = cbHighlightPlannedSkills.Checked;
            m_settings.UI.PlanWindow.HighlightConflicts = cbHighlightConflicts.Checked;
            m_settings.UI.PlanWindow.HighlightPartialSkills = cbHighlightPartialSkills.Checked;
            m_settings.UI.PlanWindow.HighlightQueuedSkills = cbHighlightQueuedSiklls.Checked;
            m_settings.UI.PlanWindow.OnlyShowSelectionSummaryOnMultiSelect = cbSummaryOnMultiSelectOnly.Checked;
            m_settings.UI.PlanWindow.UseAdvanceEntryAddition = cbAdvanceEntryAdd.Checked;

            if (alwaysAskRadioButton.Checked)
            {
                m_settings.UI.PlanWindow.ObsoleteEntryRemovalBehaviour = ObsoleteEntryRemovalBehaviour.AlwaysAsk;
            }
            else if (removeAllRadioButton.Checked)
            {
                m_settings.UI.PlanWindow.ObsoleteEntryRemovalBehaviour = ObsoleteEntryRemovalBehaviour.RemoveAll;
            }
            else
            {
                m_settings.UI.PlanWindow.ObsoleteEntryRemovalBehaviour = ObsoleteEntryRemovalBehaviour.RemoveConfirmed;
            }

            // Skill Browser icon sets
            m_settings.UI.SkillBrowser.IconsGroupIndex = cbSkillIconSet.SelectedIndex + 1;

            // Main window skills filter
            m_settings.UI.MainWindow.ShowAllPublicSkills = cbShowAllPublicSkills.Checked;
            m_settings.UI.MainWindow.ShowNonPublicSkills = cbShowNonPublicSkills.Checked;
            m_settings.UI.MainWindow.ShowPrereqMetSkills = cbShowPrereqMetSkills.Checked;

            // System tray icon behaviour
            if (rbSystemTrayOptionsNever.Checked)
            {
                m_settings.UI.SystemTrayIcon = SystemTrayBehaviour.Disabled;
            }
            else if (rbSystemTrayOptionsMinimized.Checked)
            {
                m_settings.UI.SystemTrayIcon = SystemTrayBehaviour.ShowWhenMinimized;
            }
            else if (rbSystemTrayOptionsAlways.Checked)
            {
                m_settings.UI.SystemTrayIcon = SystemTrayBehaviour.AlwaysVisible;
            }

            // Main window close behaviour
            if (rbMinToTaskBar.Checked)
            {
                m_settings.UI.MainWindowCloseBehaviour = CloseBehaviour.MinimizeToTaskbar;
            }
            else if (rbMinToTray.Checked)
            {
                m_settings.UI.MainWindowCloseBehaviour = CloseBehaviour.MinimizeToTray;
            }
            else
            {
                m_settings.UI.MainWindowCloseBehaviour = CloseBehaviour.Exit;
            }

            // Main window
            m_settings.UI.MainWindow.ShowCharacterInfoInTitleBar = cbTitleToTime.Checked;
            m_settings.UI.MainWindow.TitleFormat = (MainWindowTitleFormat)cbWindowsTitleList.SelectedIndex + 1;
            m_settings.UI.MainWindow.ShowSkillNameInWindowTitle = cbSkillInTitle.Checked;
            m_settings.UI.MainWindow.HighlightPartialSkills = cbColorPartialSkills.Checked;
            m_settings.UI.MainWindow.HighlightQueuedSkills = cbColorQueuedSkills.Checked;
            m_settings.UI.MainWindow.AlwaysShowSkillQueueTime = cbAlwaysShowSkillQueueTime.Checked;

            // G15
            m_settings.G15.Enabled = g15CheckBox.Checked;
            m_settings.G15.UseCharactersCycle = cbG15ACycle.Checked;
            m_settings.G15.CharactersCycleInterval = (int)ACycleInterval.Value;
            m_settings.G15.UseTimeFormatsCycle = cbG15CycleTimes.Checked;
            m_settings.G15.TimeFormatsCycleInterval = (int)ACycleTimesInterval.Value;
            m_settings.G15.ShowSystemTime = cbG15ShowTime.Checked;
            m_settings.G15.ShowEVETime = cbG15ShowEVETime.Checked;

            // Notifications
            NotificationSettings notificationSettings = new NotificationSettings();
            PopulateNotificationsFromControls(out notificationSettings);
            m_settings.Notifications = notificationSettings;

            // IGB
            m_settings.IGB.IGBServerEnabled = igbCheckBox.Checked;
            m_settings.IGB.IGBServerPublic = cbIGBPublic.Checked;
            int igbServerPort = m_settings.IGB.IGBServerPort;
            Int32.TryParse(igbPortTextBox.Text, out igbServerPort);
            m_settings.IGB.IGBServerPort = igbServerPort;

            // Main window - Overview
            m_settings.UI.MainWindow.ShowOverview = cbShowOverViewTab.Checked;
            m_settings.UI.MainWindow.UseIncreasedContrastOnOverview = cbUseIncreasedContrastOnOverview.Checked;
            m_settings.UI.MainWindow.ShowOverviewWallet = overviewShowWalletCheckBox.Checked;
            m_settings.UI.MainWindow.ShowOverviewPortrait = overviewShowPortraitCheckBox.Checked;
            m_settings.UI.MainWindow.PutTrainingSkillsFirstOnOverview = overviewGroupCharactersInTrainingCheckBox.Checked;
            m_settings.UI.MainWindow.ShowOverviewSkillQueueTrainingTime = overviewShowSkillQueueTrainingTimeCheckBox.Checked;
            m_settings.UI.MainWindow.OverviewItemSize = (PortraitSizes)overviewPortraitSizeComboBox.SelectedIndex;

            // Tray icon window style
            if (trayPopupRadio.Checked)
            {
                m_settings.UI.SystemTrayPopup.Style = TrayPopupStyles.PopupForm;
            }
            else if (trayTooltipRadio.Checked)
            {
                m_settings.UI.SystemTrayPopup.Style = TrayPopupStyles.WindowsTooltip;
            }
            else
            {
                m_settings.UI.SystemTrayPopup.Style = TrayPopupStyles.Disabled;
            }

            // Proxy
            m_settings.Proxy.Enabled = customProxyCheckBox.Checked;
            int proxyPort = m_settings.Proxy.Port;
            Int32.TryParse(proxyPortTextBox.Text, out proxyPort);
            m_settings.Proxy.Port = proxyPort;
            m_settings.Proxy.Host = proxyHttpHostTextBox.Text;

            // Updates
            m_settings.Updates.CheckEVEMonVersion = cbCheckForUpdates.Checked;
            m_settings.Updates.CheckTimeOnStartup = cbCheckTimeOnStartup.Checked;

            // Scheduler colors
            m_settings.UI.Scheduler.BlockingColor = (SerializableColor)panelColorBlocking.BackColor;
            m_settings.UI.Scheduler.RecurringEventGradientStart = (SerializableColor)panelColorRecurring1.BackColor;
            m_settings.UI.Scheduler.RecurringEventGradientEnd = (SerializableColor)panelColorRecurring2.BackColor;
            m_settings.UI.Scheduler.SimpleEventGradientStart = (SerializableColor)panelColorSingle1.BackColor;
            m_settings.UI.Scheduler.SimpleEventGradientEnd = (SerializableColor)panelColorSingle2.BackColor;
            m_settings.UI.Scheduler.TextColor = (SerializableColor)panelColorText.BackColor;

            // External calendar settings
            m_settings.Calendar.Enabled = externalCalendarCheckbox.Checked;
            if (rbMSOutlook.Checked)
            {
                m_settings.Calendar.Provider = CalendarProvider.Outlook;
            }
            else
            {
                m_settings.Calendar.Provider = CalendarProvider.Google;
            }
            m_settings.Calendar.GoogleEmail = tbGoogleEmail.Text;
            m_settings.Calendar.GooglePassword = tbGooglePassword.Text;
            m_settings.Calendar.GoogleURL = tbGoogleURI.Text;
            m_settings.Calendar.GoogleReminder = cbGoogleReminder.SelectedIndex != -1 ? (GoogleCalendarReminder)cbGoogleReminder.SelectedIndex : GoogleCalendarReminder.None;
            m_settings.Calendar.UseReminding = cbSetReminder.Checked;
            m_settings.Calendar.RemindingInterval = Int32.Parse(tbReminder.Text);
            m_settings.Calendar.UseRemindingRange = cbUseAlterateReminder.Checked;
            m_settings.Calendar.EarlyReminding = dtpEarlyReminder.Value;
            m_settings.Calendar.LateReminding = dtpLateReminder.Value;

            // Updates API provider choices
            m_settings.APIProviders.CurrentProviderName = (string)cbAPIServer.SelectedItem;

            // Run at startup
            if (runAtStartupComboBox.Enabled)
            {
                RegistryKey rk = Registry.CurrentUser.OpenSubKey(StartupRegistryKey, true);
                if (runAtStartupComboBox.Checked)
                {
                    rk.SetValue("EVEMon", String.Format(CultureConstants.DefaultCulture, "\"{0}\" {1}", Application.ExecutablePath.ToString(), "-startMinimized"));
                }
                else
                {
                    rk.DeleteValue("EVEMon", false);
                }
            }

            // Success
            return true;
        }
Пример #11
0
        /// <summary>
        /// Sends a test mail
        /// </summary>
        /// <param name="settings">NotificationSettings object</param>
        /// <remarks>
        /// A notification settings object is required, as this function
        /// is called from the Settings Window, and assumibly the user
        /// is changing settings.
        /// </remarks>
        /// <returns>False if an exception was thrown, otherwise True.</returns>
		public static bool SendTestMail(NotificationSettings settings)
		{
            return SendMail(settings, "EVEMon Test Mail", "This is a test email sent by EVEMon");
		}
Пример #12
0
        /// <summary>
        /// Performs the sending of the mail
        /// </summary>
        /// <param name="settings">Settings object to use when sending</param>
        /// <param name="subject">Subject of the message</param>
        /// <param name="body">Body of the message</param>
        /// <returns>True if no exceptions thrown, otherwise false</returns>
        /// <remarks>
        /// NotificationSettings object is required to support
        /// alternative settings from Tols -> Options. Use
        /// Settings.Notifications unless using an alternative
        /// configuration.
        /// </remarks>
		private static bool SendMail(NotificationSettings settings, string subject, string body)
		{
            // trace something to the logs so we can identify the time the message was sent.
            EveClient.Trace("Emailer.SendMail: Subject - {0}; Server - {1}:{2}",
                subject,
                settings.EmailSmtpServer,
                settings.EmailPortNumber
                );

			try
			{
                // Set up message
                MailMessage msg = new MailMessage(settings.EmailFromAddress, settings.EmailToAddress, subject, body);

                // Set up client
                SmtpClient client = new SmtpClient(settings.EmailSmtpServer);
                client.SendCompleted += new SendCompletedEventHandler(SendCompleted); 
                if (settings.EmailPortNumber > 0)
				{
                    client.Port = settings.EmailPortNumber;
				}

                // Enter crendtials
                if (settings.EmailAuthenticationRequired)
				{
                    client.UseDefaultCredentials = false;
                    client.Credentials = new NetworkCredential(
                        settings.EmailAuthenticationUserName,
                        settings.EmailAuthenticationPassword);
				}

                // SSL
                client.EnableSsl = settings.EmailServerRequiresSSL;
                
                // Send message
				client.SendAsync(msg, null);
				return true;
			}
			catch (Exception e)
			{
				ExceptionHandler.LogException(e, true);
				return false;
			}
		}