public StateItemsViewModel(Dictionary <StateEnum, string> dict) { foreach (var state in dict) { StateItemViewModel newstate = new StateItemViewModel(state.Key, state.Value, null, false); AddState(newstate); } Items[StateEnum.Created].SetDone(true); IsChanged = false; }
public BookViewModel() { foreach (var state in StatesDict) { StateItemViewModel newstate = new StateItemViewModel(state.Key, state.Value, null, false); AddState(newstate); } States[StateEnum.Created].SetDone(true); //GetLastState(); CopyInfoCommand = new RelayCommand <string>( (o) => { if (o is string) { System.Windows.Clipboard.SetDataObject(o as string); } }, "К"); Rating.PropertyChanged += (o, ea) => PropertyChanged?.Invoke(this, ea); }
public BookViewModel(Book book) { ID = book.ID; OTitle = book.OTitle; RTitle = book.RTitle; OAuthorName = book.OAuthorName; RAuthorName = book.RAuthorName; Year = book.Year; Note = book.Note; Description = book.Description; Rating.Value = book.Rating; foreach (var state in StatesDict) { StateItemViewModel newstate = new StateItemViewModel(state.Key, state.Value, null); var st = book.States.FirstOrDefault(p => p.Name == state.Key); if (st != null) { newstate.IsDone = true; newstate.Date = st.Date; } AddState(newstate); } GetLastState(); CopyInfoCommand = new RelayCommand <string>( (o) => { if (o is string) { System.Windows.Clipboard.SetDataObject(o as string); } }, "К"); Rating.PropertyChanged += (o, ea) => PropertyChanged?.Invoke(this, ea); }
public StateItemViewModel GetLastState() { LastState = States.LastOrDefault(p => p.Value.IsDone).Value; return(LastState); }
private void AddState(StateItemViewModel state) { state.PropertyChanged += (o, ea) => PropertyChanged?.Invoke(this, ea); state.StateChanged += (o, ea) => LastState = States.LastOrDefault(p => p.Value.IsDone).Value; States.Add(state.Name, state); }
private void AddState(StateItemViewModel state) { state.Changed += (o, ea) => IsChanged = true; state.StateChanged += (o, ea) => LastState = Items.LastOrDefault(p => p.Value.IsDone).Value; Items.Add(state.Name, state); }