Example #1
0
        public AccountManager()
        {
            InitializeComponent();
            this.Title = CIV.strings.AccountManager_Title;
            this.DataContext = this;

            _settings = ProgramSettings.Load();

            RefreshInternetAccess();

            ClientList = new ObservableCollection<CIVAccount>();

            // Chargement de la liste des modèles de courriel
            MailTemplateList = new ObservableCollection<string>();

            MailFactory mailFactory = new MailFactory();
            for (int i = 0; i < mailFactory.MailTemplates.Count; i++)
                MailTemplateList.Add(mailFactory.MailTemplates[i].Name);

            foreach (CIVAccount account in _settings.Accounts)
                ClientList.Add(account);

            InitializeBinding(txtUsername, txtUsername.GetBindingExpression(TextBox.TextProperty).ParentBinding, "IsEnabled");
            InitializeBinding(txtQuotaQuantity, txtQuotaQuantity.GetBindingExpression(TextBox.TextProperty).ParentBinding, "IsEnabled");
            InitializeBinding(txtMailRecipients, txtMailRecipients.GetBindingExpression(TextBox.TextProperty).ParentBinding, "IsEnabled");

            chkSendMail.IsEnabled = _settings.EmailSMTP.Active;
        }
Example #2
0
        /// <summary>
        /// Recharge l'interface
        /// </summary>
        /// <param name="reload">Indique s'il faut recharger les options</param>
        public void RefreshAccount(bool reload)
        {
            bool minOneActive = false;

            if (reload)
            {
                ProgramSettings.Reload();
            }

            // Faire un backup de l'historique des messages
            Dictionary <Guid, object> history = new Dictionary <Guid, object>();

            // Si c'est le rectangle, on ne fait rien
            if (!((wpClients.Children.Count == 1) &&
                  (wpClients.Children[0] as ClientDashboard) == null))
            {
                foreach (ClientDashboard client in wpClients.Children)
                {
                    history.Add(client.Account.Id, client.Messages);
                    client.Dispose();
                }
            }

            wpClients.Children.Clear();

            ClientDashboard newClient;

            foreach (CIVAccount account in ProgramSettings.Instance.Accounts)
            {
                if (account.IsActive)
                {
                    minOneActive = true;

                    newClient = new ClientDashboard(account);
                    if (history.ContainsKey(newClient.Account.Id))
                    {
                        newClient.Messages = (ObservableCollection <ScreenMessage>)history[newClient.Account.Id];
                    }
                    newClient.UpdateEnd = ClientUpdateEnd;
                    wpClients.Children.Add(newClient);
                }
            }

            // Dans le cas où il n'y a pas de compte affiché, il faut mettre quelque chose dans le WrapPanel.
            // Sinon l'affichage est miniature.
            if (!minOneActive)
            {
                wpClients.Children.Add(new Rectangle()
                {
                    Width = 440, Height = 530
                });
            }

            RefreshSecondaryView(true);
        }
Example #3
0
        public static ProgramSettings Load()
        {
            ProgramSettings result;

            if (File.Exists(Filename))
            {
                try
                {
                    #if DEBUG
                    result = (ProgramSettings)XmlFactory.LoadFromFile(typeof(ProgramSettings), Filename, new XmlFactorySettings());
                    #else
                    result = (ProgramSettings)XmlFactory.LoadFromFile(typeof(ProgramSettings), Filename, new XmlFactorySettings()
                    {
                        Password = _key
                    });
#endif

                    if (result.Display.Count == 0)
                    {
                        result.ResetDisplay();
                    }

                    if (result.DisplaySystray.Count == 0)
                    {
                        result.ResetDisplaySystray();
                    }

                    return(result);
                }
                catch (Exception loadException)
                {
                    MessageBox.Show(loadException.ToString());
                }
            }

            result = new ProgramSettings();
            result.ResetDisplay();
            result.ResetDisplaySystray();

            try
            {
                // Si on arrive pas à sauvegarder, un met un Guid vide. Pour ne pas avoir plein de Guid unique inutile dans les logs
                if (!result.Save())
                {
                    result.Id = Guid.Empty;
                }
            }
            catch { }

            return(result);
        }
Example #4
0
        //ListBox dragSource = null;

        public GeneralSettings()
        {
            InitializeComponent();
            this.Title = CIV.strings.GeneralSettings_Title;

            _settings = ProgramSettings.Load();

            defaultLanguage = _settings.UserLanguage;

            DisplayInfoList                  = new ObservableCollection <DisplayInfoTypes>();
            DisplayInfoListSystray           = new ObservableCollection <DisplayInfoTypes>();
            lbDisplayList.DataContext        = DisplayInfoList;
            lbDisplayListSystray.DataContext = DisplayInfoListSystray;

            GenerateDisplayList();
            GenerateDisplaySystrayList();

            try
            {
                RegistryKey rkAutorun = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run");

                if (rkAutorun != null)
                {
                    _settings.LaunchAtStartup = rkAutorun.GetValueNames().Contains("CIV");
                    rkAutorun.Close();
                }
                else
                {
                    _settings.LaunchAtStartup = false;
                }
            }
            catch (Exception e)
            {
                LogFactory.LogEngine.Instance.Add(e);
            }

            _launchAtStartup = _settings.LaunchAtStartup;

            this.DataContext = _settings;

            // Windows XP et moins
            if (Environment.OSVersion.Version.Major < 6)
            {
                tabSystray.Visibility = System.Windows.Visibility.Collapsed;
            }
        }
Example #5
0
        private void miGeneralSettings_Click(object sender, RoutedEventArgs e)
        {
            GeneralSettings winGeneralSettings = new GeneralSettings();

            winGeneralSettings.Owner = this;
            Nullable <bool> dialogResult = winGeneralSettings.ShowDialog();

            if (dialogResult != null && dialogResult == true)
            {
                ProgramSettings.Reload();

                CreateSystrayIcon();

                RefreshAccount(false);

                SetTimers();
            }
        }
Example #6
0
        //ListBox dragSource = null;
        public GeneralSettings()
        {
            InitializeComponent();
            this.Title = CIV.strings.GeneralSettings_Title;

            _settings = ProgramSettings.Load();

            defaultLanguage = _settings.UserLanguage;

            DisplayInfoList = new ObservableCollection<DisplayInfoTypes>();
            DisplayInfoListSystray = new ObservableCollection<DisplayInfoTypes>();
            lbDisplayList.DataContext = DisplayInfoList;
            lbDisplayListSystray.DataContext = DisplayInfoListSystray;

            GenerateDisplayList();
            GenerateDisplaySystrayList();

            try
            {
                RegistryKey rkAutorun = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run");

                if (rkAutorun != null)
                {
                    _settings.LaunchAtStartup = rkAutorun.GetValueNames().Contains("CIV");
                    rkAutorun.Close();
                }
                else
                    _settings.LaunchAtStartup = false;
            }
            catch (Exception e)
            {
                LogFactory.LogEngine.Instance.Add(e);
            }

            _launchAtStartup = _settings.LaunchAtStartup;

            this.DataContext = _settings;

            // Windows XP et moins
            if (Environment.OSVersion.Version.Major < 6)
                tabSystray.Visibility = System.Windows.Visibility.Collapsed;
        }
Example #7
0
 public static void Reload()
 {
     _instance = Load();
 }
Example #8
0
 public static void Reload()
 {
     _instance = Load();
 }
Example #9
0
        public static ProgramSettings Load()
        {
            ProgramSettings result;

            if (File.Exists(Filename))
            {
                try
                {
                    #if DEBUG
                    result = (ProgramSettings)XmlFactory.LoadFromFile(typeof(ProgramSettings), Filename, new XmlFactorySettings());
                    #else
                    result = (ProgramSettings)XmlFactory.LoadFromFile(typeof(ProgramSettings), Filename, new XmlFactorySettings() { Password = _key });
            #endif

                    if (result.Display.Count == 0)
                        result.ResetDisplay();

                    if (result.DisplaySystray.Count == 0)
                        result.ResetDisplaySystray();

                    return result;
                }
                catch (Exception loadException)
                {
                    MessageBox.Show(loadException.ToString());
                }
            }

            result = new ProgramSettings();
            result.ResetDisplay();
            result.ResetDisplaySystray();

            try
            {
                // Si on arrive pas à sauvegarder, un met un Guid vide. Pour ne pas avoir plein de Guid unique inutile dans les logs
                if (!result.Save())
                    result.Id = Guid.Empty;
            }
            catch { }

            return result;
        }