Ejemplo n.º 1
0
        private void PropertiesViewModelHandler(object sender, PropertyChangedEventArgs e)
        {
            if (e.PropertyName != "SelectedLayerType")
            {
                return;
            }

            // Store the brush in case the user wants to reuse it
            var oldBrush = ProposedLayer.Properties.Brush;

            // Update the model
            if (ProposedLayer.LayerType.GetType() != SelectedLayerType.GetType())
            {
                ProposedLayer.LayerType = SelectedLayerType;
                ProposedLayer.SetupProperties();
            }

            // Let the layer type handle the viewmodel setup
            LayerPropertiesViewModel = ProposedLayer.LayerType.SetupViewModel(this, LayerPropertiesViewModel);

            if (oldBrush != null)
            {
                ProposedLayer.Properties.Brush = oldBrush;
            }

            NotifyOfPropertyChange(() => LayerPropertiesViewModel);
        }
Ejemplo n.º 2
0
        private void PropertiesViewModelHandler(object sender, PropertyChangedEventArgs e)
        {
            if (e.PropertyName != "LayerType")
            {
                return;
            }

            // Store the brush in case the user wants to reuse it
            var oldBrush = LayerPropertiesViewModel?.GetAppliedProperties().Brush;

            // Update the model
            if (ProposedLayer.LayerType != LayerType)
            {
                ProposedLayer.LayerType = LayerType;
                ProposedLayer.SetupProperties();
            }

            if (oldBrush != null)
            {
                ProposedLayer.Properties.Brush = oldBrush;
            }

            // Update the KeyboardPropertiesViewModel if it's being used
            var model = LayerPropertiesViewModel as KeyboardPropertiesViewModel;

            if (model != null)
            {
                model.IsGif = LayerType == LayerType.KeyboardGif;
            }

            // Apply the proper PropertiesViewModel
            if ((LayerType == LayerType.Keyboard || LayerType == LayerType.KeyboardGif) &&
                !(LayerPropertiesViewModel is KeyboardPropertiesViewModel))
            {
                LayerPropertiesViewModel = new KeyboardPropertiesViewModel(_dataModel, ProposedLayer.Properties)
                {
                    IsGif = LayerType == LayerType.KeyboardGif
                };
            }
            else if (LayerType == LayerType.Mouse && !(LayerPropertiesViewModel is MousePropertiesViewModel))
            {
                LayerPropertiesViewModel = new MousePropertiesViewModel(_dataModel, ProposedLayer.Properties);
            }
            else if (LayerType == LayerType.Headset && !(LayerPropertiesViewModel is HeadsetPropertiesViewModel))
            {
                LayerPropertiesViewModel = new HeadsetPropertiesViewModel(_dataModel, ProposedLayer.Properties);
            }
            else if (LayerType == LayerType.Folder && !(LayerPropertiesViewModel is FolderPropertiesViewModel))
            {
                LayerPropertiesViewModel = new FolderPropertiesViewModel(_dataModel, ProposedLayer.Properties);
            }

            NotifyOfPropertyChange(() => LayerPropertiesViewModel);
        }