public RanetCheckedListBox() { InitializeComponent(); this.ListBox.SelectionMode = System.Windows.Controls.SelectionMode.Multiple; this.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch; this.ListBox.ItemContainerStyle = Resources["CheckedItemStyle"] as Style; m_DataSource = new ObservableObjectCollection(); }
public RanetCheckedListBox() { DefaultStyleKey = typeof(RanetListBox); this.SelectionMode = System.Windows.Controls.SelectionMode.Multiple; this.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch; ResourceDictionary dic = new ResourceDictionary(); dic.Source = new Uri(ResourceUri,UriKind.Relative); this.ItemContainerStyle = dic["CheckedItemStyle"] as Style; m_DataSource = new ObservableObjectCollection(); }
public RanetCheckedListBox() { DefaultStyleKey = typeof(RanetListBox); this.SelectionMode = System.Windows.Controls.SelectionMode.Multiple; this.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch; ResourceDictionary dic = new ResourceDictionary(); dic.Source = new Uri(ResourceUri, UriKind.Relative); this.ItemContainerStyle = dic["CheckedItemStyle"] as Style; m_DataSource = new ObservableObjectCollection(); }
private async Task UpdateFileList(ObservableObjectCollection <File> filelist) { _filelistUpdatInProcess = true; _FileList.Clear(); // переносим из временного списка в список файлов отображаемый пользователю только элементы с типом File и Directory foreach (File file in filelist) { if (file.Nature != FileNature.Playlist) { _FileList.Add(file); } } // Сортируем элементы списка по типу так чтобы каталоги оказались в начале _FileList.Sort(new GenericComparer <File>("Nature", SortOrder.Desc)); // Добавляем картинки каталогов if (DisplayFolderPictures) { string currentfolder = string.Empty; if (CurrentFolder.Length != 0) { currentfolder = CurrentFolder + "\\"; } foreach (File file in _FileList) { if (_filelistCancelUpdate) { break; } if (file.Nature == FileNature.Directory) { IRandomAccessStream fileStream = await Utilities.GetFolderImageStream(MusicCollectionFolder, currentfolder + file.Name, AlbumCoverFileNames); if (fileStream != null) { await _mainPage.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async delegate { BitmapImage bmi = new BitmapImage(); await bmi.SetSourceAsync(fileStream); file.ImageSource = bmi; }); } } } } _filelistUpdatInProcess = false; }
public Server(MainPage mainPage) { _mainPage = mainPage; _Statistics = new Statistic(_mainPage); _Status = new Status(_mainPage); _CurrentSong = new CurrentSong(_mainPage); _Playlist = new ObservableObjectCollection <Track>(_mainPage); _FileList = new ObservableObjectCollection <File>(_mainPage); _SavedPlaylists = new ObservableObjectCollection <File>(_mainPage); _Outputs = new ObservableObjectCollection <Output>(_mainPage); _Artists = new ObservableObjectCollection <CommonGridItem>(_mainPage); _Genres = new ObservableObjectCollection <CommonGridItem>(_mainPage); _Albums = new ObservableObjectCollection <CommonGridItem>(_mainPage); _Tracks = new ObservableObjectCollection <Track>(_mainPage); _Connection.PropertyChanged += Connection_PropertyChanged; }
/// <summary> /// Read server responces and convert them into data objects /// </summary> private async Task HandleResponse(MpdResponseCollection response) { //bool handleResponseCriticalError = false; string errorMessage = string.Empty; try { switch (response.Command.Op) { case "update": // в ответ на команду сервер возвращает" "updating_db: 1\n" (Реализовано) case "stats": _Statistics.Update(response); break; case "status": _Status.Update(response); break; // Реализовано case "currentsong": _CurrentSong.Update(response); break; case "lsinfo": if (response.Count > 0) { // Каталог не пустой string currentfolder = string.Empty; if (CurrentFolder.Length != 0) { currentfolder = CurrentFolder + "\\"; } // Создаём временный список файлов и заполняем его данными из ответв сервера ObservableObjectCollection <File> filelist = new ObservableObjectCollection <File>(_mainPage); filelist.Update(response); if (_filelistUpdatInProcess) { _filelistCancelUpdate = true; while (_filelistUpdatInProcess) { await Task.Delay(TimeSpan.FromMilliseconds(100)); } // while (_filelistUpdatInProcess); _filelistCancelUpdate = false; } await UpdateFileList(filelist); } else { // Каталог не содержит файлов _FileList.ClearAndNotify(); } break; case "list": switch (response.Command.Argument1) { case "genre": _Genres.Update(response); break; case "artist": _Artists.Update(response); break; case "album": _Albums.Update(response); break; case "title": _Tracks.Update(response); break; } break; case "search": _Tracks.Update(response); break; case "playlistinfo": _Playlist.Update(response); break; case "listplaylists": _SavedPlaylists.Update(response); break; case "outputs": if (response.Count > 0) { _Outputs.Update(response); } break; case "config": break; default: break; } if (response.Command.Op != "status") { NotifyCommandCompletion(response.Command.Op, "OK", response.Error); } } catch (BalboaNullValueException be) { _Terminating = true; errorMessage = string.Format(_resldr.GetString("NullValueExceptionMsg"), be.VariableName, be.MethodName, be.FileName, be.LineNumber); } catch (BalboaException be) { _Terminating = true; errorMessage = string.Format(_resldr.GetString("BalboaExceptionMsg"), be.MethodName, be.FileName, be.LineNumber, be.Message); } catch (Exception e) { _Terminating = true; string exceptionMessage = e.Message.Contains("\r\n") ? e.Message.Substring(0, e.Message.IndexOf("\r\n")) : e.Message; errorMessage = string.Format(_resldr.GetString("UnexpectedServerError"), exceptionMessage); } finally { if (_Terminating) { //await Halt(); NotifyCriticalError(errorMessage); } } }