Example #1
0
 private void CopyValue(RandomTableRowViewModel rowView)
 {
     if (rowView != null && !String.IsNullOrWhiteSpace(rowView.Value))
     {
         Clipboard.SetText(rowView.Value);
     }
 }
Example #2
0
        /// <summary>
        /// Creates a new instance of <see cref="RandomTableEditViewModel"/>
        /// </summary>
        public RandomTableEditViewModel(RandomTableModel randomTableModel)
        {
            _randomTableModel = new RandomTableModel(randomTableModel);

            foreach (RandomTableRowModel rowModel in _randomTableModel.Rows)
            {
                RandomTableRowViewModel randomTableRowViewModel = new RandomTableRowViewModel(rowModel);
                randomTableRowViewModel.PropertyChanged += Row_PropertyChanged;
                _rows.Add(randomTableRowViewModel);
            }

            _dieOptions.AddRange(_statService.Dice);

            _name = _randomTableModel.Name;

            if (_randomTableModel.Tags.Any())
            {
                _tags = String.Join(", ", _randomTableModel.Tags);
            }

            _die    = !String.IsNullOrWhiteSpace(_randomTableModel.Die) ? _randomTableModel.Die : _dieOptions[0];
            _header = _randomTableModel.Header;

            _addRowCommand    = new RelayCommand(obj => true, obj => AddRow());
            _deleteRowCommand = new RelayCommand(obj => true, obj => DeleteRow(obj as RandomTableRowViewModel));

            SetRowDieMaximums();
        }
Example #3
0
        private void AddRow()
        {
            RandomTableRowModel rowModel = new RandomTableRowModel();

            _randomTableModel.Rows.Add(rowModel);

            RandomTableRowViewModel randomTableRowViewModel = new RandomTableRowViewModel(rowModel);

            if (Int32.TryParse(_die.Replace("d", String.Empty), out int die))
            {
                randomTableRowViewModel.DieMax = die;
            }

            if (_rows.Any())
            {
                randomTableRowViewModel.Min = _rows.Last().Max + 1;
                randomTableRowViewModel.Max = randomTableRowViewModel.Min;
            }
            else
            {
                randomTableRowViewModel.Min = 1;
                randomTableRowViewModel.Max = 1;
            }

            randomTableRowViewModel.PropertyChanged += Row_PropertyChanged;

            _rows.Add(randomTableRowViewModel);

            OnPropertyChanged(nameof(Rows));
        }
Example #4
0
        private void DeleteRow(RandomTableRowViewModel randomTableRowViewModel)
        {
            if (_dialogService.ShowConfirmationDialog("Delete Row", "Are you sure you want to delete the row?", "Yes", "No", null) == true)
            {
                randomTableRowViewModel.PropertyChanged -= Row_PropertyChanged;

                _randomTableModel.Rows.Remove(randomTableRowViewModel.RowModel);
                _rows.Remove(randomTableRowViewModel);

                OnPropertyChanged(nameof(Rows));
            }
        }