public SetCategories(PreferenceId pref, List <Categories> categoryDat, INavigation nav, int act)
 {
     InitializeComponent();
     Nav    = nav;
     action = act;
     this.BindingContext = new SetCategoriesViewModel(pref, categoryDat, action);
 }
Esempio n. 2
0
        private void GetPreferences(string keyVal)
        {
            string[]            indiv_prefs = keyVal.Split(';');
            List <PreferenceId> prefs_ids   = new List <PreferenceId>();

            foreach (string s in indiv_prefs)
            {
                string[] indiv_internal = s.Split(',');
                int      i = 0;

                PreferenceId pref_id = new PreferenceId();


                foreach (string t in indiv_internal)
                {
                    if (i == 0)
                    {
                        string t1   = t.Remove(0, 5);
                        string name = t1;
                        pref_id.Name = name;
                    }
                    else if (i == 1)
                    {
                        int    id = 0;
                        string t1 = t.Remove(0, 3);
                        int.TryParse(t1, out id);
                        pref_id.Id = id;
                    }
                    else
                    {
                        pref_id.PresetData += t;
                        if (i != indiv_internal.Length - 1)
                        {
                            pref_id.PresetData += ",";
                        }
                    }
                    i++;
                }

                prefs_ids.Add(pref_id);
            }
            SavedPreferences = new ObservableCollection <PreferenceId>(prefs_ids);
        }
Esempio n. 3
0
        public SetCategoriesViewModel(PreferenceId pref, List <Categories> categData, int action)
        {
            if (action == 0)
            {
                PreferenceId prefNew = new PreferenceId();
                prefNew.Name       = "New Name";
                prefNew.PresetData = "12,17,7,34,5,5,12,2,4,2";

                string default_key = "name=Default,id=0,12,17,7,17,5,5,12,2,4,2;name=Second,id=1,14,15,7,17,5,5,12,2,4,2";
                string keyVal      = Preferences.Get("pref_keys", default_key);

                int id = 0;
                foreach (string s in keyVal.Split(';'))
                {
                    foreach (string t in s.Split(','))
                    {
                        if (t.Contains("id="))
                        {
                            string u = t.Replace("id=", "");
                            int.TryParse(u, out id);
                        }
                    }
                }
                prefNew.Id     = id + 1;
                Preference     = prefNew;
                PreferenceName = Preference.Name;
            }
            else if (action == 1)
            {
                Preference     = pref;
                PreferenceName = Preference.Name;
                string oldKey = "name=" + Preference.Name + ",id=" + Preference.Id + "," + Preference.PresetData;
                OldKey = oldKey;
            }

            CategoryData = categData;
            SetChartValues(Preference.PresetData);
            CalculateTotal();
            Subscribe();
        }
Esempio n. 4
0
        public static void DeletePresetData(SelectPreferencesViewModel vm)
        {
            vm.IsLoading = true;

            PreferenceId pref = vm.SelectedPreference;

            string default_key = "name=Default,id=0,12,17,7,17,5,5,12,2,4,2;name=Second,id=1,14,15,7,17,5,5,12,2,4,2";
            string keyVal      = Preferences.Get("pref_keys", default_key);

            string keyToDelete = "name=" + pref.Name + ",id=" + pref.Id + "," + pref.PresetData;
            string finalKey    = "";

            foreach (string s in keyVal.Split(';'))
            {
                if (!s.Equals(keyToDelete))
                {
                    if (!string.IsNullOrEmpty(s))
                    {
                        if (finalKey.Equals(""))
                        {
                            finalKey += s;
                        }
                        else
                        {
                            finalKey += ";" + s;
                        }
                    }
                }
            }

            Preferences.Set("pref_keys", finalKey);
            vm.SetKeyValues();

            vm.SavedPreferences.Remove(pref);

            vm.IsLoading = false;
        }