Exemplo n.º 1
0
 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;
 }
Exemplo n.º 2
0
 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);
 }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
 public StateItemViewModel GetLastState()
 {
     LastState = States.LastOrDefault(p => p.Value.IsDone).Value;
     return(LastState);
 }
Exemplo n.º 5
0
 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);
 }
Exemplo n.º 6
0
 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);
 }