Ejemplo n.º 1
0
        /// <summary>
        /// Moves a card from the old set to this one
        /// and notifies of property changes.
        /// </summary>
        /// <param name="old"></param>
        public void TransferCard(CardModelView card)
        {
            if (card == null)
            {
                return;
            }
            CardSetModelView old = card.Parent as CardSetModelView;

            if (old == null)
            {
                return;
            }
            if (old == this)
            {
                //MessageBox.Show("Whoa!");
                return;
            }

            _Cards.Add(card);
            old._Cards.Remove(card);
            card.TransferOwnership(this);

            NotifyPropertyChanged("Cards");
            NotifyPropertyChanged("Children");
            old.NotifyPropertyChanged("Cards");
            old.NotifyPropertyChanged("Children");
        }
Ejemplo n.º 2
0
 /// <summary>
 ///
 /// </summary>
 public MainWindow()
 {
     CardSets = new List <CardSetModelView>();
     CardSets.Add(new CardSetModelView());
     ActiveCard = new CardModelView(CardSets[0]);
     CardSets[0].Cards.Add(ActiveCard);
     InitializeComponent();
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Returns the model to default state of a single card set with a single card within it.
        /// </summary>
        public void ResetToDefaultSet()
        {
            _Cards.Clear();

            PrintStatus = false;
            _Cards      = new List <ITreeViewItemViewModel>();
            CardModelView defaultCard = new CardModelView(this);

            _Cards.Add(defaultCard);
        }
Ejemplo n.º 4
0
        public void ImportCard(string fileName)
        {
            if (fileName != null && fileName.Length > 0)
            {
                //imply selection
                ITreeViewItemViewModel selectedItem = this.treeviewCardSets.SelectedValue as ITreeViewItemViewModel;

                if (selectedItem != null)
                {
                    CardSetModelView cardSet;
                    if (selectedItem.IsLeaf)
                    {
                        cardSet = selectedItem.Parent as CardSetModelView;
                    }
                    else
                    {
                        cardSet = selectedItem as CardSetModelView;
                    }

                    //serialize that card
                    IFormatter    formatter = new BinaryFormatter();
                    Stream        stream    = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read);
                    CardModelView card      = (CardModelView)formatter.Deserialize(stream);
                    stream.Close();

                    if (card == null)
                    {
                        MessageBox.Show("The card did not load properly. " + fileName);
                        return;
                    }
                    cardSet.AddCardToSet(card);
                    NotifyPropertyChanged("CardSets");
                    NotifyPropertyChanged("ObservableCardSets");
                    cardSet.IsExpanded = true;
                    ActiveCard         = card;
                }
                else
                {
                    MessageBox.Show("There was an error loading the card. " + fileName);
                }
            }
        }
Ejemplo n.º 5
0
 public void AddCardToSet(CardModelView card)
 {
     card.SetOwner(this);
     Cards.Add(card);
 }