Пример #1
0
 private void InitializeComponent()
 {
     AvaloniaXamlLoader.Load(this);
     DataContext = new ColorDialogViewModel()
     {
         Close = this.Close
     };
 }
Пример #2
0
        public CellViewModel(TableViewModel tableViewModel)
        {
            _tableViewModel = tableViewModel;

            UpKeyCommand = new RelayCommand(o =>
            {
                _tableViewModel.SelectCell(Column, Row - 2);
            });

            DownKeyCommand = new RelayCommand(o =>
            {
                _tableViewModel.SelectCell(Column, Row + 2);
            });

            RightKeyCommand = new RelayCommand(o =>
            {
                _tableViewModel.SelectCell(Column + 2, Row);
            });

            LeftKeyCommand = new RelayCommand(o =>
            {
                _tableViewModel.SelectCell(Column - 2, Row);
            });

            SelectCellCommand = new RelayCommand(o =>
            {
                _tableViewModel.SelectCell(Column, Row);
            });

            SelectNonAdjacentCellsCommand = new RelayCommand(o =>
            {
                _tableViewModel.SelectCell(Column, Row, true);
            });

            SelectRectangularBlockOfCellsCommand = new RelayCommand(o =>
            {
                _tableViewModel.SelectRectangularBlockOfCells(Column, Row);
            });

            Actions.Add(new ContextActionViewModel
            {
                Name   = "Background...",
                Action = new RelayCommand(o =>
                {
                    var viewModel   = new ColorDialogViewModel();
                    var colorDialog = new ColorDialog.ColorDialog
                    {
                        DataContext = viewModel
                    };

                    colorDialog.ShowDialog();
                    if (viewModel.SelectedColor != null)
                    {
                        Background = viewModel.SelectedColor.Name;
                    }
                })
            });

            Actions.Add(new ContextActionViewModel
            {
                Name   = "Copy",
                Action = new RelayCommand(o =>
                {
                    Clipboard.SetDataObject(Text);
                })
            });
        }