Example #1
0
        public MainWindow()
        {
            InitializeComponent();

            string culture = CfgFile.Get("Lang");

            LocalizeDictionary.Instance.Culture   = CultureInfo.GetCultureInfo(culture);
            Thread.CurrentThread.CurrentUICulture = LocalizeDictionary.Instance.Culture;

            string path = String.Format(@"Themes/{0}/Theme.xaml", CfgFile.Get("Theme"));

            using (var fs = new FileStream(path, FileMode.Open))
            {
                var dic = (ResourceDictionary)XamlReader.Load(fs);
                Application.Current.MainWindow.Resources.MergedDictionaries.Clear();
                Application.Current.MainWindow.Resources.MergedDictionaries.Add(dic);
            }

            // Wiring up View and ViewModel
            var model = new MainWindowViewModel();

            DataContext = model;

            navigationButtonStyle              = (Style)FindResource("NavigationButton");
            navigationButtonSelectedStyle      = (Style)FindResource("NavigationButtonSelected");
            navigationButtonFirstStyle         = (Style)FindResource("NavigationButtonFirst");
            navigationButtonFirstSelectedStyle = (Style)FindResource("NavigationButtonFirstSelected");

            ProcessFirstRun();
        }
        public PanelPreferences2()
        {
            InitializeComponent();

            var lang = CfgFile.Get("Lang");

            if (!langIndex.ContainsKey(lang))
            {
                lang = "en-US";
            }

            LanguagesList.SelectedIndex = langIndex[lang];
            MinToTray.IsChecked         = CfgFile.Get("MinimizeToTray") == "1";
            object regValue = null;

            try
            {
                using (RegistryKey regKey = Registry.CurrentUser.OpenSubKey(registryKeyName))
                {
                    regValue = regKey.GetValue(registryAppName);
                }
            }
            catch
            {
            }
            StartUpAction.IsChecked    = regValue != null;
            driverDownloadsFolder.Text = Uri.UnescapeDataString(CfgFile.Get("DriverDownloadsFolder"));
            backupsFolder.Text         = Uri.UnescapeDataString(CfgFile.Get("BackupsFolder"));
        }
Example #3
0
        public string[] getSectionsList(string aircraftDirectory, string filename)
        {
            CfgFile availableSections = cfgTemplates.Find(x => x.Name == filename);
            CfgFile installedSections = cfgFileExists(filename) ? cfgAircraft.Find(x => x.Name == filename) : cfgAircraft.Find(x => x.Name == "aircraft.cfg");

            string[] sections = new string[100];

            if (availableSections != null)
            {
                int i = 0;
                foreach (var cockpitSection in availableSections.Sections)
                {
                    if (installedSections != null && installedSections.Sections.Find(x => x.Name == cockpitSection.Name) != null)
                    {
                        sections[i] = cockpitSection.Name + Environment.NewLine;
                    }
                    else
                    {
                        sections[i] = "-" + cockpitSection.Name.ToUpper() + Environment.NewLine;
                    }
                    i++;
                }
            }

            return(sections);
        }
Example #4
0
        public CfgFile setCfgSectionStatus(CfgFile cfgFile, string sectionname, bool active = true)
        {
            if (cfgFile != null)
            {
                CfgSection ligtsList = cfgFile.Sections.Find(x => x.Name == sectionname);
                if (ligtsList != null)
                {
                    if (DEBUG)
                    {
                        Console.WriteLine("setCfgValueStatus: " + cfgFile.Name + " / " + sectionname + " set to " + active);
                    }

                    ligtsList.Active = active;
                    foreach (CfgLine line in ligtsList.Lines)
                    {
                        line.Active = active;
                    }

                    return(cfgFile);
                }
            }

            if (DEBUG)
            {
                Console.WriteLine("setCfgValueStatus: " + cfgFile.Name + " / " + sectionname + " NOT FOUND");
            }
            return(cfgFile);
        }
Example #5
0
        public CfgData Load()
        {
            var languageInfo = new LanguageInfo();
            // system.cfg
            var systemConfigFile = new CfgFile(GameConstants.GetSystemConfigPath(_currentGame.RootFolderPath));
            var systemConfigData = systemConfigFile.Read();

            LoadLanguageInfo(systemConfigData, languageInfo);
            // user.cfg
            var userConfigFile = new CfgFile(GameConstants.GetUserConfigPath(_currentGame.RootFolderPath));
            var userConfigData = userConfigFile.Read();

            if (userConfigData.TryGetValue(GameConstants.CurrentLanguageKey, out var value))
            {
                _userConfigLanguage = value;
            }
            else
            {
                _userConfigLanguage = null;
            }
            if (FixUserConfigLanguageInfo(userConfigData, languageInfo))
            {
                userConfigFile.Save(userConfigData);
            }
            LanguageInfo = languageInfo;
            return(userConfigData);
        }
Example #6
0
        public List <string> getSounds(string aircraftDirectory)
        {
            List <string> sounds   = new List <string>();
            var           cfgFiles = Directory.EnumerateFiles(aircraftDirectory, "sound.cfg", SearchOption.AllDirectories);

            foreach (string currentFile in cfgFiles)
            {
                if (Path.GetFileName(currentFile)[0] != '.')
                {
                    List <CfgLine> cfgLines = readCSV(File.ReadAllText(currentFile) + "\r\n[]");
                    //Console.WriteLine(cfgLines.First().Name);
                    CfgFile tempFile = parseCfg(currentFile.Replace(aircraftDirectory, "").TrimStart('\\'), cfgLines);

                    foreach (CfgSection section in tempFile.Sections)
                    {
                        if (section.Name.Length > 0)
                        {
                            sounds.Add((!section.Active ? "-" : "") + currentFile.Replace(aircraftDirectory, "") + "\\" + section.Name);
                        }
                    }
                }
            }

            return(sounds);
        }
 private void driverDownloadsFolder_TextChanged(object sender, TextChangedEventArgs e)
 {
     if (Directory.Exists(driverDownloadsFolder.Text))
     {
         CfgFile.Set("DriverDownloadsFolder", Uri.EscapeUriString(driverDownloadsFolder.Text));
     }
 }
Example #8
0
        public JsonCfgFile(CfgFile cfgFile)
        {
            Val1656.FromByte(cfgFile.Addr1656);
            Val1662.FromByte(cfgFile.Addr1662);
            Val166E.FromByte(cfgFile.Addr166E);
            Val167A.FromByte(cfgFile.Addr167A);
            Val1686.FromByte(cfgFile.Addr1686);
            Val190F.FromByte(cfgFile.Addr190F);

            AsmFile = cfgFile.AsmFile;
            ActLike = cfgFile.ActLike;
            Type    = cfgFile.Type;

            ExProp1 = cfgFile.ExProp1;
            ExProp2 = cfgFile.ExProp2;

            ByteCount   = cfgFile.ByteCount;
            ExByteCount = cfgFile.ExByteCount;

            Map16    = cfgFile.CustomMap16Data;
            Displays = new List <CFG.Map16.DisplaySprite>();
            foreach (var display in cfgFile.DisplayEntries)
            {
                var  newDisplay = (CFG.Map16.DisplaySprite)display.Clone();
                bool useText    = display.UseText;
                newDisplay.DisplayText = newDisplay.DisplayText.Replace("\n", @"\n");
                newDisplay.UseText     = useText;
                Displays.Add(newDisplay);
            }
            Collection = new List <CollectionSprite>(cfgFile.CollectionEntries);
        }
Example #9
0
        public bool setCfgValueStatus(string aircraftDirectory, string attrname, string filename, string sectionname = "", bool active = true)
        {
            if (!cfgFileExists(filename))
            {
                filename = "aircraft.cfg";
            }

            CfgFile cfgFile = cfgAircraft.Find(x => x.Name == filename);

            if (cfgFile != null)
            {
                CfgSection ligtsList = cfgFile.Sections.Find(x => x.Name == sectionname);
                if (ligtsList != null)
                {
                    CfgLine line = ligtsList.Lines.Find(x => x.Name == attrname);
                    if (line != null)
                    {
                        line.Active = active;

                        if (DEBUG)
                        {
                            Console.WriteLine("setCfgValueStatus: " + filename + " / " + (sectionname != "" ? sectionname : "ANY") + " / " + attrname + " set to " + active);
                        }
                        return(true);
                    }
                }
            }

            if (DEBUG)
            {
                Console.WriteLine("setCfgValueStatus: " + filename + " / " + (sectionname != "" ? sectionname : "ANY") + " / " + attrname + " NOT FOUND");
            }
            return(false);
        }
Example #10
0
        static void Main()
        {
            GParams.Instance.ServerAdress = "127.0.0.1";
            GParams.Instance.PortAdress   = 1353;
            GParams.Instance.TimeOut      = int.MaxValue;



            if (System.IO.File.Exists(Program.LocalAppParamPath))
            {
                var _cfgFile = new CfgFile(Program.LocalAppParamPath);

                if (_cfgFile.Read())
                {
                    if (!string.IsNullOrEmpty(_cfgFile.GetValue("Comunication", "Adress", false)))
                    {
                        GParams.Instance.ServerAdress = _cfgFile.GetValue("Comunication", "Adress", false);
                    }

                    if (GParams.ToInt32(_cfgFile.GetValue("Comunication", "Port", false)).HasValue)
                    {
                        GParams.Instance.PortAdress = GParams.ToInt32(_cfgFile.GetValue("Comunication", "Port", false)) ?? 0;
                    }
                }
            }

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new MainForm());
        }
Example #11
0
 void MinimizeApp(object sender, RoutedEventArgs e)
 {
     WindowState = WindowState.Minimized;
     if (CfgFile.Get("MinimizeToTray") == "1")
     {
         Hide();
     }
 }
Example #12
0
        public void adjustEnginesPower(string aircraftDirectory, double multiplier)
        {
            CfgFile cfgFile = cfgFileExists("engines.cfg") ? cfgAircraft.Find(x => x.Name == "engines.cfg") :
                              cfgAircraft.Find(x => x.Name == "aircraft.cfg");

            if (cfgFile != null)
            {
                string attr = "";
                string sect = "";

                string engine_type = getCfgValue("engine_type", "engines.cfg", "[GENERALENGINEDATA]");
                if (engine_type.Contains('.'))
                {
                    engine_type = engine_type.Split('.')[0];
                }
                if (engine_type == "1" || engine_type == "5") // JET
                {
                    attr = "static_thrust";
                    sect = "[TURBINEENGINEDATA]";
                }
                else if (engine_type == "0") // PISTON
                {
                    attr = "power_scalar";
                    sect = "[PISTON_ENGINE]";
                }
                else if (engine_type == "5")   // TURBOPROP
                {
                    attr = "power_scalar";
                    sect = "[TURBOPROP_ENGINE]";
                }

                if (attr != "" && sect != "")
                {
                    string thrust = getCfgValue(attr, "engines.cfg", sect);
                    if (thrust != "")
                    {
                        double.TryParse(thrust.Replace(",", ".").Trim(), NumberStyles.Any, CultureInfo.InvariantCulture, out double num);
                        if (num > 0)
                        {
                            double newThrust = Math.Max((num * multiplier), 0.001);
                            if (attr == "power_scalar")
                            {
                                newThrust = Math.Min((num * multiplier), 1.9);
                            }
                            string           newThrustString  = newThrust.ToString("0.###");
                            MessageBoxResult messageBoxResult = MessageBox.Show("Old value: " + num + Environment.NewLine + "New value: " + newThrustString, "Engines power adjustment", System.Windows.MessageBoxButton.YesNo);
                            if (messageBoxResult == MessageBoxResult.Yes)
                            {
                                setCfgValue(aircraftDirectory, attr, newThrustString, "engines.cfg", sect);
                                saveCfgFiles(aircraftDirectory, new string[] { "engines.cfg" });
                            }
                        }
                    }
                }
            }
        }
Example #13
0
        /// <summary>
        /// Asserts that fields that were added in Version 1.2 or later remained clear on older loadings.
        /// Entries are suppose to be empty and not null
        /// </summary>
        /// <param name="data"></param>
        public void AssertVersion_1_2(CfgFile data)
        {
            Assert.IsNotNull(data.CustomMap16Data, nameof(CfgFile.CustomMap16Data));
            Assert.IsNotNull(data.DisplayEntries, nameof(CfgFile.CustomMap16Data));
            Assert.IsNotNull(data.CollectionEntries, nameof(CfgFile.CollectionEntries));

            Assert.AreEqual(0, data.CustomMap16Data.Length, nameof(CfgFile.CustomMap16Data));
            Assert.AreEqual(0, data.DisplayEntries.Count, nameof(CfgFile.CustomMap16Data));
            Assert.AreEqual(0, data.CollectionEntries.Count, nameof(CfgFile.CollectionEntries));
        }
Example #14
0
        public bool SaveConfig(CfgData config)
        {
            var userConfigFile = new CfgFile(GameConstants.GetUserConfigPath(_currentGame.RootFolderPath));

            if (_userConfigLanguage != null)
            {
                config.AddOrUpdateRow(GameConstants.CurrentLanguageKey, _userConfigLanguage);
            }
            return(userConfigFile.Save(config));
        }
Example #15
0
        public void saveCfgFile(string aircraftDirectory, CfgFile cfgFile)
        {
            string path = aircraftDirectory + "\\" + cfgFile.Name;

            Console.WriteLine("Saving config file " + cfgFile.Name + " into " + path);
            lastChangeTimestamp = DateTime.UtcNow.Ticks;

            if (File.Exists(path))
            {
                try { File.Delete(path); }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    MessageBox.Show("Can't update file " + path);
                    return;
                }
            }


            if (!File.Exists(path))
            {
                using (FileStream fs = File.Create(path))
                {
                    byte[] text = new UTF8Encoding(true).GetBytes("");// new UTF8Encoding(true).GetBytes("[VERSION]" + System.Environment.NewLine + "major = 1" + System.Environment.NewLine + "minor = 0" + System.Environment.NewLine);
                    fs.Write(text, 0, text.Length);
                }
            }

            using (FileStream fs = File.Open(path, FileMode.Append, FileAccess.Write, FileShare.Write))
            {
                foreach (CfgSection cfgSection in cfgFile.Sections)
                {
                    byte[] text = new UTF8Encoding(true).GetBytes(System.Environment.NewLine + (!cfgSection.Active ? ";-" : "") + cfgSection.Name + System.Environment.NewLine + System.Environment.NewLine);
                    fs.Write(text, 0, text.Length);


                    foreach (CfgLine cfgLine in cfgSection.Lines)
                    {
                        if (!String.IsNullOrEmpty(cfgLine.Name) || !String.IsNullOrEmpty(cfgLine.Value) || !String.IsNullOrEmpty(cfgLine.Comment))
                        {
                            if (String.IsNullOrEmpty(cfgLine.Name) && String.IsNullOrEmpty(cfgLine.Value))
                            {
                                text = new UTF8Encoding(true).GetBytes("; " + cfgLine.Comment + System.Environment.NewLine);
                            }
                            else
                            {
                                text = new UTF8Encoding(true).GetBytes((!cfgLine.Active ? ";-" : "") + cfgLine.Name + " = " + cfgLine.Value + " ; " + cfgLine.Comment + System.Environment.NewLine);
                            }
                            fs.Write(text, 0, text.Length);
                        }
                    }
                }
            }
        }
Example #16
0
        private void m_saveSettingsBtn_Click(object sender, EventArgs e)
        {
            var _cfgFile = new CfgFile(Program.LocalAppParamPath);

            _cfgFile.Read();

            _cfgFile.SetValue("Comunication", "Adress", this.m_serverIpTb.Text, false);
            _cfgFile.SetValue("Comunication", "Port", this.m_serverPortTb.Text, false);

            _cfgFile.Save();
        }
Example #17
0
        public bool RemoveCurrentLanguage()
        {
            var userConfigFile = new CfgFile(GameConstants.GetUserConfigPath(_currentGame.RootFolderPath));
            var userConfigData = userConfigFile.Read();

            if (userConfigData.RemoveRow(GameConstants.CurrentLanguageKey) != null &&
                userConfigFile.Save(userConfigData))
            {
                LanguageInfo.Current = null;
                return(true);
            }
            return(false);
        }
        void SetDaysFromLastScanProgressBarValue(int daysFromLastScan)
        {
            int daysFromLastScanProgress = daysFromLastScan * 360 / MainWindowViewModel.DaysFromLastScanMax;

            if (daysFromLastScan == 0)
            {
                DaysFromLastScan.FontSize           = 30;
                DaysFromLastScan.Margin             = new Thickness(2, 56, 0, 0);
                LocalizeDictionary.Instance.Culture = CultureInfo.GetCultureInfo(CfgFile.Get("Lang"));
                DaysFromLastScan.Text  = WPFLocalizeExtensionHelpers.GetUIString("Today");
                DaysAgoText.Visibility = System.Windows.Visibility.Hidden;
                Gradient.Visibility    = Visibility.Collapsed;
                MoreThan.Visibility    = Visibility.Collapsed;
                return;
            }


            DaysFromLastScan.Text = daysFromLastScan.ToString(CultureInfo.InvariantCulture);
            if ((daysFromLastScanProgress < 359 && daysFromLastScanProgress > 0) || (daysFromLastScan <= MainWindowViewModel.DaysFromLastScanMax && daysFromLastScan > 0))
            {
                Gradient.Visibility = Visibility.Visible;
                DaysFromLastScanProgressBar.Visibility = Visibility.Visible;
                MoreThan.Visibility = Visibility.Collapsed;
                DaysFromLastScanProgressBar.RotationAngle = daysFromLastScanProgress;
                DaysFromLastScanProgressBar.WedgeAngle    = 360 - daysFromLastScanProgress;
                DaysFromLastScanProgressBar.Visibility    = Visibility.Visible;
            }
            else
            {
                if (daysFromLastScan > 0)
                {
                    MoreThan.Visibility   = Visibility.Visible;
                    DaysFromLastScan.Text = MainWindowViewModel.DaysFromLastScanMax.ToString(CultureInfo.InvariantCulture);
                    DaysFromLastScanProgressBar.RotationAngle = 0;
                    DaysFromLastScanProgressBar.WedgeAngle    = 0;
                    DaysFromLastScanProgressBar.Visibility    = Visibility.Collapsed;
                }
                else
                {
                    if (daysFromLastScan == 0)
                    {
                        Gradient.Visibility = Visibility.Collapsed;
                    }
                }
            }
            if (daysFromLastScan == MainWindowViewModel.DaysFromLastScanMax)
            {
                DaysFromLastScanProgressBar.Visibility = Visibility.Collapsed;
            }
        }
Example #19
0
 /// <summary>
 /// 
 /// </summary>
 /// <returns></returns>
 private string GetID()
 {
     string path = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase);
     CfgFile cfg = new CfgFile(path + "\\confini.ci");
     string id = cfg.getValue("DATA", "uniqueid", true);
     if (id == "")
     {
         SecurityProvider sp = new SecurityProvider();
         id = sp.GetUniqueIDWithTimestamp(32);
         cfg.setValue("DATA", "uniqueid", id, true);
         cfg.Save();
     }
     return id;
 }
Example #20
0
        private void AssertTweakBytes(CfgFile data, byte[] reference)
        {
            Assert.AreEqual <byte>(reference[0], data.Type, nameof(CfgFile.Type));
            Assert.AreEqual <byte>(reference[1], data.ActLike, nameof(CfgFile.ActLike));

            Assert.AreEqual <byte>(reference[2], data.Addr1656, nameof(CfgFile.Addr1656));
            Assert.AreEqual <byte>(reference[3], data.Addr1662, nameof(CfgFile.Addr1662));
            Assert.AreEqual <byte>(reference[4], data.Addr166E, nameof(CfgFile.Addr166E));
            Assert.AreEqual <byte>(reference[5], data.Addr167A, nameof(CfgFile.Addr167A));
            Assert.AreEqual <byte>(reference[6], data.Addr1686, nameof(CfgFile.Addr1686));
            Assert.AreEqual <byte>(reference[7], data.Addr190F, nameof(CfgFile.Addr190F));

            Assert.AreEqual <byte>(reference[8], data.ExProp1, nameof(CfgFile.ExProp1));
            Assert.AreEqual <byte>(reference[9], data.ExProp2, nameof(CfgFile.ExProp2));
        }
Example #21
0
        public MainWindow()
        {
            InitializeComponent();

            string culture = CfgFile.Get("Lang");

            LocalizeDictionary.Instance.Culture   = CultureInfo.GetCultureInfo(culture);
            Thread.CurrentThread.CurrentUICulture = LocalizeDictionary.Instance.Culture;

            using (var fs = new FileStream("Theme.xaml", FileMode.Open))
            {
                var dic = (ResourceDictionary)XamlReader.Load(fs);
                Application.Current.MainWindow.Resources.MergedDictionaries.Clear();
                Application.Current.MainWindow.Resources.MergedDictionaries.Add(dic);
            }
        }
Example #22
0
 void ProcessFirstRun()
 {
     if (CfgFile.Get("FirstRun") == "1")
     {
         string appPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "Freemium Driver Utilities");
         Directory.CreateDirectory(appPath);
         string downloadsPath = Path.Combine(appPath, "Downloads");
         string backupsPath   = Path.Combine(appPath, "Backups");
         Directory.CreateDirectory(downloadsPath);
         Directory.CreateDirectory(backupsPath);
         var panelPreferences = (PanelPreferences)Application.Current.MainWindow.FindName("PanelPreferences");
         panelPreferences.driverDownloadsFolder.Text = downloadsPath;
         CfgFile.Set("DriverDownloadsFolder", Uri.EscapeUriString(downloadsPath));
         panelPreferences.backupsFolder.Text = backupsPath;
         CfgFile.Set("BackupsFolder", Uri.EscapeUriString(backupsPath));
         CfgFile.Set("FirstRun", "0");
     }
 }
Example #23
0
        private void AssertVersion(CfgFile data, int major = 1, int minor = 0)
        {
            //don't check on the given version if fields are clear but on the next one.
            minor++;

            Version v = data.GetType().Assembly.GetName().Version;

            for (; major <= v.Major; major++)
            {
                for (; minor <= v.Minor; minor++)
                {
                    string methodName = $"AssertVersion_{major}_{minor}";
                    var    methodInfo = GetType().GetMethod(methodName, new[] { data.GetType() });
                    Assert.IsNotNull(methodInfo, $"Version guard method: \"{methodName}\" not found");
                    methodInfo.Invoke(this, new[] { data });
                }
            }
        }
Example #24
0
        public void Load()
        {
            var languageInfo = new LanguageInfo();
            // system.cfg
            var systemConfigFile = new CfgFile(GameConstants.GetSystemConfigPath(_currentGame.RootFolder.FullName));
            var systemConfigData = systemConfigFile.Read();

            LoadLanguageInfo(systemConfigData, languageInfo);
            // user.cfg
            var userConfigFile = new CfgFile(GameConstants.GetUserConfigPath(_currentGame.RootFolder.FullName));
            var userConfigData = userConfigFile.Read();

            if (FixUserConfigLanguageInfo(userConfigData, languageInfo))
            {
                userConfigFile.Save(userConfigData);
            }
            LanguageInfo = languageInfo;
        }
Example #25
0
 public bool CreateProfile(string profileName, CfgData profileData)
 {
     _logger.Info($"Create profile: {profileName}");
     if (_profiles.ContainsKey(profileName))
     {
         _logger.Warn($"New profile name: {profileName} already exist");
         return(false);
     }
     if (CreateProfilesDirectory())
     {
         var profileFile = new CfgFile(GetProfilePath(profileName));
         if (profileFile.Save(profileData))
         {
             _profiles.Add(profileName, profileData);
             return(true);
         }
     }
     return(false);
 }
Example #26
0
 public bool SaveProfile(string profileName, CfgData profileData)
 {
     _logger.Info($"Save profile: {profileName}");
     if (!_profiles.ContainsKey(profileName))
     {
         _logger.Error($"Save profile: {profileName} not found");
         return(false);
     }
     if (CreateProfilesDirectory())
     {
         var profileFile = new CfgFile(GetProfilePath(profileName));
         if (profileFile.Save(profileData))
         {
             _profiles[profileName] = profileData;
             return(true);
         }
     }
     return(false);
 }
Example #27
0
 public void Load()
 {
     _profiles.Clear();
     if (Directory.Exists(_profilesPath))
     {
         _logger.Info($"Load profiles at path: {_profilesPath}");
         var profileFiles = Directory.EnumerateFiles(_profilesPath, $"*{ProfileExtension}");
         foreach (var profilePath in profileFiles)
         {
             _logger.Info($"Load profile: {profilePath}");
             var profileFile = new CfgFile(profilePath);
             var profileData = profileFile.Read();
             if (profileData != null)
             {
                 _profiles.Add(GetProfileName(profilePath), profileData);
             }
         }
     }
 }
Example #28
0
 void CloseApp(object sender, RoutedEventArgs e)
 {
     if (CfgFile.Get("MinimizeToTray") == "1")
     {
         Hide();
     }
     else
     {
         //CfgFile.Set("MainWindowLeft", AppMainWindow.Left.ToString());
         //CfgFile.Set("MainWindowTop", AppMainWindow.Top.ToString());
         try
         {
             Application.Current.Shutdown();
             Environment.Exit(0);
         }
         catch (Exception)
         {
         }
     }
 }
        public PanelScan()
        {
            InitializeComponent();
            int duration = 0;

            try
            {
                string   lastscandate = CfgFile.Get("LastScanDate");
                DateTime LastScanDate = DateTime.ParseExact(lastscandate, "dd/MM/yyyy", CultureInfo.InvariantCulture);
                if (LastScanDate < DateTime.Now.Date)
                {
                    duration = (DateTime.Now - DateTime.ParseExact(lastscandate, "dd/MM/yyyy", CultureInfo.InvariantCulture)).Duration().Days;
                }
            }
            catch
            {
            }
            SetDaysFromLastScanProgressBarValue(duration);
            LoadTaskParams();
        }
Example #30
0
 public bool SaveCurrentLanguage(string languageName)
 {
     if (!string.IsNullOrEmpty(languageName))
     {
         if (string.Compare(LanguageInfo.Current, languageName, StringComparison.OrdinalIgnoreCase) == 0)
         {
             return(true);
         }
         var userConfigFile = new CfgFile(GameConstants.GetUserConfigPath(_currentGame.RootFolderPath));
         var userConfigData = userConfigFile.Read();
         userConfigData.AddOrUpdateRow(GameConstants.CurrentLanguageKey, languageName);
         if (userConfigFile.Save(userConfigData))
         {
             LanguageInfo.Current = languageName;
             return(true);
         }
         return(false);
     }
     return(false);
 }
        private void LanguageChanged(object sender, SelectionChangedEventArgs e)
        {
            if (LanguagesList.SelectedIndex == 0)
            {
                LocalizeDictionary.Instance.Culture = CultureInfo.GetCultureInfo("en-US");
                CfgFile.Set("Lang", "en-US");
            }
            if (LanguagesList.SelectedIndex == 1)
            {
                LocalizeDictionary.Instance.Culture = CultureInfo.GetCultureInfo("de-DE");
                CfgFile.Set("Lang", "de-DE");
            }

            var mainViewModel = (MainWindowViewModel)Application.Current.MainWindow.DataContext;

            if (mainViewModel != null)
            {
                mainViewModel.SetBackupTypes();
                mainViewModel.SetSocialButtonsMargin();
                mainViewModel.SetLabels();
            }
        }
Example #32
0
 public Settings(String filename)
 {
     configFile = new CfgFile(filename);
     Load();
 }