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; } } }
/// <summary> /// Show Sort dialog /// </summary> protected void OnShowSort() { GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU); if (dlg == null) { return; } dlg.Reset(); dlg.SetHeading(495); // Sort options int maxCommonSortIndex = -1; // Inrease by 1 when adding new common sort label(sort valid in share and db views)) // Common sorts - group 1 dlg.AddLocalizedString(365); // 0 name maxCommonSortIndex++; dlg.AddLocalizedString(104); // 2 date created (date) maxCommonSortIndex++; // show dialog and wait for result dlg.DoModal(GetID); if (dlg.SelectedId == -1) { return; } CurrentSortAsc = true; switch (dlg.SelectedId) { case 365: CurrentSortBy = DeviceSort.SortMethod.Name; break; case 104: CurrentSortBy = DeviceSort.SortMethod.LastSeen; CurrentSortAsc = false; break; default: CurrentSortBy = DeviceSort.SortMethod.Name; break; } OnSort(); UpdateButtons(); GUIControl.FocusControl(GetID, btnSortBy.GetID); SaveSettings(); }