private void LoadSettings() { using (Settings xmlreader = new MPSettings()) { _serveradress = xmlreader.GetValueAsString("MPDomoticz", "ServerAdress", "localhost"); _serverport = xmlreader.GetValueAsString("MPDomoticz", "ServerPort", "8080"); _username= xmlreader.GetValueAsString("MPDomoticz", "Username", ""); _password = xmlreader.GetValueAsString("MPDomoticz", "Password", ""); RefreshInterval = xmlreader.GetValueAsInt("MPDomoticz", "RefreshInterval", 30); string strTmp = xmlreader.GetValueAsString("MPDomoticz", "FilterBy", "All"); if (!Enum.TryParse<DeviceFilter.DeviceFilterBy>(strTmp, out CurrentFilterBy)) { CurrentFilterBy = DeviceFilter.DeviceFilterBy.All; } //CurrentSortBy = (DeviceSort.SortMethod)xmlreader.GetValueAsInt("MPDomoticz", "SortBy", (int)DeviceSort.SortMethod.Name); strTmp = xmlreader.GetValueAsString("MPDomoticz", "SortBy", "Name"); if (!Enum.TryParse<DeviceSort.SortMethod>(strTmp, out CurrentSortBy)) { CurrentSortBy = DeviceSort.SortMethod.Name; } int tmp = xmlreader.GetValueAsInt("MPDomoticz", "SortByAsc", 1); CurrentSortAsc = true; if (tmp == 0) { CurrentSortAsc = false; } } }
/* * Filter */ protected void OnShowFilter() { Log.Info("MP-Domoticz: OnShowFilter"); GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU); if (dlg == null) { return; } dlg.Reset(); dlg.SetHeading(97); // Common sorts - group 1 dlg.Add(Translation.Favourites); dlg.Add(Translation.Switches); dlg.Add(Translation.Scenes); dlg.Add(Translation.Temperature); dlg.Add(Translation.Weather); dlg.Add(Translation.Utility); dlg.Add(Translation.All); // show dialog and wait for result dlg.DoModal(GetID); if (dlg.SelectedId == -1) { return; } switch (dlg.SelectedId) { case 1: CurrentFilterBy = DeviceFilter.DeviceFilterBy.Favorites; break; case 2: CurrentFilterBy = DeviceFilter.DeviceFilterBy.Switches; break; case 3: CurrentFilterBy = DeviceFilter.DeviceFilterBy.Scenes; break; case 4: CurrentFilterBy = DeviceFilter.DeviceFilterBy.Temperature; break; case 5: CurrentFilterBy = DeviceFilter.DeviceFilterBy.Weather; break; case 6: CurrentFilterBy = DeviceFilter.DeviceFilterBy.Utility; break; case 7: CurrentFilterBy = DeviceFilter.DeviceFilterBy.All; break; default: CurrentFilterBy = DeviceFilter.DeviceFilterBy.Favorites; break; } OnFilter(); UpdateButtons(); GUIControl.FocusControl(GetID, btnFilterBy.GetID); SaveSettings(); }