public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
 {
     if (value == null)
     {
         return(Visibility.Visible);
     }
     return((ExtMethods.PathIsEftServerBase((PEOptions)value) && ExtMethods.ServerHaveProfiles((PEOptions)value)) ? Visibility.Hidden : Visibility.Visible);
 }
 public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
 {
     if (value == null)
     {
         return(Visibility.Visible);
     }
     return(ExtMethods.PathIsEftServerBase((PEOptions)value) ? Visibility.Collapsed : Visibility.Visible);
 }
Ejemplo n.º 3
0
 public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
 {
     if (value == null)
     {
         return(false);
     }
     return(ExtMethods.PathIsEftServerBase(value.ToString()) && ExtMethods.ServerHaveProfiles(value.ToString()));
 }
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value == null)
            {
                return(Visibility.Visible);
            }
            if (!ExtMethods.ServerHaveProfiles((PEOptions)value))
            {
                return(Visibility.Visible);
            }

            return(Visibility.Collapsed);
        }
Ejemplo n.º 5
0
        private async void LoadDataWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            await progressDialog.CloseAsync();

            if (e.Error != null)
            {
                await DialogManager.ShowMessageAsync(Application.Current.MainWindow as MetroWindow, ErrorTitle, e.Error.Message, MessageDialogStyle.Affirmative, new MetroDialogSettings { AffirmativeButtonText = ErrorConfirm, AnimateShow = true, AnimateHide = true });

                ExtMethods.Log($"LoadDataWorker | {e.Error.Message}");
            }
            else
            {
                while (workerNotifications.Count > 0)
                {
                    await DialogManager.ShowMessageAsync(Application.Current.MainWindow as MetroWindow, workerNotifications[0].NotificationTitle, workerNotifications[0].NotificationDescription, MessageDialogStyle.Affirmative, new MetroDialogSettings { AffirmativeButtonText = ErrorConfirm, AnimateShow = true, AnimateHide = true });

                    workerNotifications.RemoveAt(0);
                }
            }
        }
Ejemplo n.º 6
0
        public static MainData Load()
        {
            if (!Directory.Exists(LangPath))
            {
                Directory.CreateDirectory(LangPath);
            }
            if (!File.Exists(Path.Combine(LangPath, "en.json")))
            {
                File.WriteAllText(Path.Combine(LangPath, "en.json"), JsonConvert.SerializeObject(EN, Formatting.Indented));
            }
            if (!File.Exists(Path.Combine(LangPath, "ru.json")))
            {
                File.WriteAllText(Path.Combine(LangPath, "ru.json"), JsonConvert.SerializeObject(RU, Formatting.Indented));
            }
            if (!File.Exists(Path.Combine(LangPath, "fr.json")))
            {
                File.WriteAllText(Path.Combine(LangPath, "fr.json"), JsonConvert.SerializeObject(FR, Formatting.Indented));
            }
            if (!File.Exists(Path.Combine(LangPath, "ge.json")))
            {
                File.WriteAllText(Path.Combine(LangPath, "ge.json"), JsonConvert.SerializeObject(GE, Formatting.Indented));
            }
            PEOptions eOptions = CreateOptions();

            if (string.IsNullOrEmpty(eOptions.Language))
            {
                eOptions.Language = ExtMethods.GetWindowsCulture();
            }
            Dictionary <string, string> Locale = JsonConvert.DeserializeObject <Dictionary <string, string> >(File.ReadAllText(Path.Combine(LangPath, eOptions.Language + ".json")));
            Dictionary <string, string> Eth    = new Dictionary <string, string>();

            switch (eOptions.Language)
            {
            case "en":
                Eth = EN;
                break;

            case "ge":
                Eth = GE;
                break;

            case "ru":
                Eth = RU;
                break;

            case "fr":
                Eth = FR;
                break;
            }
            bool needReSave = false;

            foreach (var lc in Eth)
            {
                if (!Locale.ContainsKey(lc.Key))
                {
                    Locale.Add(lc.Key, lc.Value);
                    needReSave = true;
                }
            }
            if (needReSave)
            {
                File.WriteAllText(Path.Combine(LangPath, $"{eOptions.Language}.json"), JsonConvert.SerializeObject(Locale, Formatting.Indented));
            }
            MainData lang = new MainData {
                locale = Locale, options = eOptions, characterInventory = new CharacterInventory {
                    Rubles = 0, Euros = 0, Dollars = 0
                }
            };

            try
            {
                if (!string.IsNullOrEmpty(eOptions.EftServerPath) && !ExtMethods.PathIsEftServerBase(eOptions))
                {
                    eOptions.EftServerPath = null;
                }
                if (!string.IsNullOrEmpty(eOptions.DefaultProfile) && !string.IsNullOrEmpty(eOptions.EftServerPath) && !File.Exists(Path.Combine(eOptions.EftServerPath, eOptions.DirsList["dir_profiles"], eOptions.DefaultProfile + ".json")))
                {
                    eOptions.DefaultProfile = null;
                }
                if (!string.IsNullOrEmpty(eOptions.EftServerPath) && ExtMethods.ServerHaveProfiles(eOptions))
                {
                    lang.Profiles = Directory.GetFiles(Path.Combine(eOptions.EftServerPath, eOptions.DirsList["dir_profiles"])).Select(x => Path.GetFileNameWithoutExtension(x)).ToList();
                    if (lang.Profiles.Count > 0 && (string.IsNullOrEmpty(eOptions.DefaultProfile) || !lang.Profiles.Contains(eOptions.DefaultProfile)))
                    {
                        eOptions.DefaultProfile = lang.Profiles.FirstOrDefault();
                    }
                }
                if (!string.IsNullOrEmpty(eOptions.EftServerPath) && !string.IsNullOrEmpty(eOptions.DefaultProfile))
                {
                    var Pr = JsonConvert.DeserializeObject <Profile>(File.ReadAllText(Path.Combine(eOptions.EftServerPath, eOptions.DirsList["dir_profiles"], eOptions.DefaultProfile + ".json")));
                    lang.Character = Pr.characters?.pmc;
                    if (lang.Character == null)
                    {
                        lang.Character = new Character();
                    }
                    lang.Character.Suits         = Pr.suits?.ToList();
                    lang.Character.WeaponPresets = Pr.weaponbuilds;
                }
                if (lang.Character != null && lang.Character.Info != null && lang.Character.Inventory != null && lang.Character.TraderStandings != null && lang.Character.Skills != null)
                {
                    lang.ProfileHash = JsonConvert.SerializeObject(lang.Character).ToString().GetHashCode();
                }
            }
            catch (Exception ex)
            {
                DialogManager.ShowMessageAsync(Application.Current.MainWindow as MetroWindow, lang.locale["invalid_server_location_caption"], $"{ex.GetType().Name}: {ex.Message}", MessageDialogStyle.Affirmative, new MetroDialogSettings {
                    AffirmativeButtonText = lang.locale["saveprofiledialog_ok"], AnimateShow = true, AnimateHide = true
                });
                ExtMethods.Log($"Error loading profile: {ex.GetType().Name}: {ex.Message}{Environment.NewLine}{ex.StackTrace}");
            }
            return(lang);
        }
Ejemplo n.º 7
0
        public static MainData Load()
        {
            if (!Directory.Exists(LangPath))
            {
                Directory.CreateDirectory(LangPath);
            }
            if (!File.Exists(Path.Combine(LangPath, "en.json")))
            {
                File.WriteAllText(Path.Combine(LangPath, "en.json"), JsonConvert.SerializeObject(EN, Formatting.Indented));
            }
            if (!File.Exists(Path.Combine(LangPath, "ru.json")))
            {
                File.WriteAllText(Path.Combine(LangPath, "ru.json"), JsonConvert.SerializeObject(RU, Formatting.Indented));
            }
            if (!File.Exists(Path.Combine(LangPath, "fr.json")))
            {
                File.WriteAllText(Path.Combine(LangPath, "fr.json"), JsonConvert.SerializeObject(FR, Formatting.Indented));
            }
            if (!File.Exists(Path.Combine(LangPath, "ge.json")))
            {
                File.WriteAllText(Path.Combine(LangPath, "ge.json"), JsonConvert.SerializeObject(GE, Formatting.Indented));
            }
            PEOptions eOptions = CreateOptions();

            if (string.IsNullOrEmpty(eOptions.Language))
            {
                eOptions.Language = "en";
            }
            Dictionary <string, string> Locale = JsonConvert.DeserializeObject <Dictionary <string, string> >(File.ReadAllText(Path.Combine(LangPath, eOptions.Language + ".json")));
            Dictionary <string, string> Eth    = new Dictionary <string, string>();

            switch (eOptions.Language)
            {
            case "en":
                Eth = EN;
                break;

            case "ge":
                Eth = GE;
                break;

            case "ru":
                Eth = RU;
                break;

            case "fr":
                Eth = FR;
                break;
            }
            bool needReSave = false;

            foreach (var lc in Eth)
            {
                if (!Locale.ContainsKey(lc.Key))
                {
                    Locale.Add(lc.Key, lc.Value);
                    needReSave = true;
                }
            }
            if (needReSave)
            {
                File.WriteAllText(Path.Combine(LangPath, $"{eOptions.Language}.json"), JsonConvert.SerializeObject(Locale, Formatting.Indented));
            }
            MainData lang = new MainData {
                locale = Locale, options = eOptions, characterInventory = new CharacterInventory {
                    Rubles = 0, Euros = 0, Dollars = 0
                }
            };

            if (!string.IsNullOrEmpty(eOptions.EftServerPath) && !ExtMethods.PathIsEftServerBase(eOptions.EftServerPath))
            {
                eOptions.EftServerPath = null;
            }
            if (!string.IsNullOrEmpty(eOptions.DefaultProfile) && !string.IsNullOrEmpty(eOptions.EftServerPath) && !File.Exists(Path.Combine(eOptions.EftServerPath, "user\\profiles", eOptions.DefaultProfile + ".json")))
            {
                eOptions.DefaultProfile = null;
            }
            if (!string.IsNullOrEmpty(eOptions.EftServerPath) && ExtMethods.ServerHaveProfiles(eOptions.EftServerPath))
            {
                lang.Profiles = Directory.GetFiles(eOptions.EftServerPath + "\\user\\profiles").Select(x => Path.GetFileNameWithoutExtension(x)).ToList();
                if (lang.Profiles.Count > 0 && (string.IsNullOrEmpty(eOptions.DefaultProfile) || !lang.Profiles.Contains(eOptions.DefaultProfile)))
                {
                    eOptions.DefaultProfile = lang.Profiles.FirstOrDefault();
                }
            }
            if (!string.IsNullOrEmpty(eOptions.EftServerPath) && !string.IsNullOrEmpty(eOptions.DefaultProfile))
            {
                var Pr = JsonConvert.DeserializeObject <Profile>(File.ReadAllText(Path.Combine(eOptions.EftServerPath, "user\\profiles", eOptions.DefaultProfile + ".json")));
                lang.Character = Pr.characters.pmc;
                if (Pr.suits != null && Pr.suits.Count() > 0)
                {
                    lang.Character.Suits = Pr.suits.ToList();
                }
            }
            if (lang.Character != null && lang.Character.Info != null && lang.Character.Inventory != null && lang.Character.TraderStandings != null && lang.Character.Skills != null)
            {
                lang.ProfileHash = JsonConvert.SerializeObject(lang.Character).ToString().GetHashCode();
            }
            return(lang);
        }