Esempio n. 1
0
        private void RefreshListView()
        {
            int temp  = VM.ReadingListSource.IndexOf(ReadingList.SelectedItem as ReadingListAdapter);
            int Index = -1;

            if (temp >= 0)
            {
                Index = VM.ReadingListSource[temp].Reading.Index;
            }
            ObservableCollection <ReadingListAdapter> newadapter = new ObservableCollection <ReadingListAdapter>();

            DataStorage.ListOfReadings.Sort();
            for (int x = 0; x < DataStorage.ListOfReadings.Count; x++)
            {
                if ((Convert.ToInt32(SettingsManagerInterface.GetString("Min", "-100")) == 0 && Convert.ToInt32(SettingsManagerInterface.GetString("Max", "100")) == 0) || (Convert.ToInt32(SettingsManagerInterface.GetString("Min", "-100")) == -100 && Convert.ToInt32(SettingsManagerInterface.GetString("Max", "100")) == 100))
                {
                    DataStorage.ListOfReadings[x].ColorEnabled = false;
                }
                else
                {
                    DataStorage.ListOfReadings[x].ColorEnabled = true;
                    var measurement = Convert.ToSingle(DataStorage.ListOfReadings[x].Measurement);
                    DataStorage.ListOfReadings[x].PassFail = measurement >= Convert.ToInt32(SettingsManagerInterface.GetString("Min", "-100")) && measurement <= Convert.ToInt32(SettingsManagerInterface.GetString("Max", "100"));
                }
                newadapter.Add(new ReadingListAdapter(DataStorage.ListOfReadings[x])
                {
                    Selected = DataStorage.ListOfReadings[x].Index == Index
                });
            }
            VM.ReadingListSource = newadapter;
            VM.RefreshListView();
        }
Esempio n. 2
0
 protected override void OnAppearing()
 {
     base.OnAppearing();
     DataStorage.DictionaryOfOptions.TryGetValue("Color Code", out string SelectedColorCode);
     if (SelectedColorCode == null)
     {
         SelectedColorCode = "None";
     }
     foreach (KeyValuePair <string, ColorCode> entry in DataStorage.DictionaryOfColorCodes)
     {
         VM.ColorCodePickerSource.Add(entry.Key);
     }
     ColorCodePicker.SelectedItem = SelectedColorCode;
     if (Convert.ToInt32(SettingsManagerInterface.GetString("Min", "-100")) != -100)
     {
         MinEntry.Text = SettingsManagerInterface.GetString("Min", "-100");
     }
     else
     {
         MinEntry.Text = "";
     }
     if (Convert.ToInt32(SettingsManagerInterface.GetString("Max", "100")) != 100)
     {
         MaxEntry.Text = SettingsManagerInterface.GetString("max", "100");
     }
     else
     {
         MaxEntry.Text = "";
     }
 }
Esempio n. 3
0
 protected override void OnDisappearing()
 {
     try
     {
         DataStorage.UpdateOption("Color Code", ColorCodePicker.SelectedItem as string);
         try
         {
             int minValue = -100;
             int maxValue = 100;
             if (MinEntry.Text != "")
             {
                 minValue = Convert.ToInt32(MinEntry.Text);
             }
             if (MaxEntry.Text != "")
             {
                 maxValue = Convert.ToInt32(MaxEntry.Text);
             }
             if (minValue < maxValue)
             {
                 SettingsManagerInterface.SetString(minValue.ToString(), "Min");
                 SettingsManagerInterface.SetString(maxValue.ToString(), "Max");
             }
             else
             {
                 throw new ArgumentException();
             }
         }
         catch (Exception)
         {
             ShowToast("Invalid Entry Into Min Max Feild");
         }
     }
     catch (Exception ex)
     {
     }
     base.OnDisappearing();
 }
Esempio n. 4
0
        private void ThemeChanged(object sender, EventArgs e)
        {
            SettingsManagerInterface.SetString((ThemePicker.SelectedItem as string), "SelectedString");
            switch ((ThemePicker.SelectedItem as string))
            {
            case "Blue":
                Application.Current.Resources["TraceColor"]        = (Color)Application.Current.Resources["LightBlue"];
                Application.Current.Resources["NavigationPrimary"] = (Color)Application.Current.Resources["Blue"];
                break;

            case "Orange":
                Application.Current.Resources["TraceColor"]        = (Color)Application.Current.Resources["Orange"];
                Application.Current.Resources["NavigationPrimary"] = (Color)Application.Current.Resources["DarkOrange"];
                break;

            case "GrayScale":
                Application.Current.Resources["TraceColor"]        = (Color)Application.Current.Resources["Black"];
                Application.Current.Resources["NavigationPrimary"] = (Color)Application.Current.Resources["Black"];
                break;

            case "Neon":
                Application.Current.Resources["TraceColor"]        = (Color)Application.Current.Resources["Pink"];
                Application.Current.Resources["NavigationPrimary"] = (Color)Application.Current.Resources["DarkPink"];
                break;

            case "Green":
                Application.Current.Resources["TraceColor"]        = (Color)Application.Current.Resources["Green"];
                Application.Current.Resources["NavigationPrimary"] = (Color)Application.Current.Resources["DarkGreen"];
                break;

            case "Red":
                Application.Current.Resources["TraceColor"]        = (Color)Application.Current.Resources["Red"];
                Application.Current.Resources["NavigationPrimary"] = (Color)Application.Current.Resources["DarkRed"];
                break;
            }
        }
Esempio n. 5
0
        private void SaveReading(int index, bool overwriteExisting)
        {
            //Convert our strings into a "Reading" and add it to the list
            SelectedColorCode.Index = index;
            var  readingDouble = Convert.ToDouble(PowerMeter.CurrentMeasurement);
            bool PassOrFail;
            bool colorEnabled;

            if (Convert.ToInt32(SettingsManagerInterface.GetString("Min", "-100")) == -100 || Convert.ToInt32(SettingsManagerInterface.GetString("Max", "100")) == 100)
            {
                PassOrFail   = false;
                colorEnabled = false;
            }
            else if (readingDouble >= Convert.ToInt32(SettingsManagerInterface.GetString("Min", "-100")) && readingDouble <= Convert.ToInt32(SettingsManagerInterface.GetString("Max", "100")))
            {
                PassOrFail   = true;
                colorEnabled = true;
            }
            else
            {
                PassOrFail   = false;
                colorEnabled = true;
            }
            //create reading and add 1 to its index (since it is a new one)
            Reading reading;

            if (SelectedColorCode.Index < SelectedColorCode.Count - 1)
            {
                reading = new Reading(PowerMeter.CurrentMeasurement, PassOrFail, PowerMeter.CurrentMode, PowerMeter.CurrentWavelength, SelectedColorCode.CurrentSector + "_" + SelectedColorCode.CurrentGroupingColor + "_" + SelectedColorCode.CurrentIndividualColor + "_" + SelectedColorCode.CurrentCore, DateTime.Now, index, PowerMeter.CurrentReference, PowerMeter.CurrentTone)
                {
                    ColorEnabled = colorEnabled
                };
                if (overwriteExisting)
                {
                    for (int x = 0; x < DataStorage.ListOfReadings.Count; x++)
                    {
                        if (DataStorage.ListOfReadings[x].Index == index)
                        {
                            DataStorage.ListOfReadings.RemoveAt(x);
                            x--;
                        }
                    }
                }
                DataStorage.ListOfReadings.Add(reading);
            }
            else
            {
                reading = new Reading(PowerMeter.CurrentMeasurement, PassOrFail, PowerMeter.CurrentMode, PowerMeter.CurrentWavelength, (index + 1).ToString(), DateTime.Now, index, PowerMeter.CurrentReference, PowerMeter.CurrentTone)
                {
                    ColorEnabled = colorEnabled
                };
                if (overwriteExisting)
                {
                    for (int x = 0; x < DataStorage.ListOfReadings.Count; x++)
                    {
                        if (DataStorage.ListOfReadings[x].Index == index)
                        {
                            DataStorage.ListOfReadings.RemoveAt(x);
                            x--;
                        }
                    }
                }
                DataStorage.ListOfReadings.Add(reading);
            }
            RefreshListView();
            DataStorage.Update();
        }