public override LayerPropertiesModel GetAppliedProperties() { var properties = GeneralHelpers.Clone(ProposedProperties); properties.Brush = Brush; return(properties); }
public override async void CanClose(Action <bool> callback) { // Create a fake layer and apply the properties to it var fakeLayer = GeneralHelpers.Clone(ProposedLayer); if (LayerPropertiesViewModel != null) { fakeLayer.Properties = LayerPropertiesViewModel.GetAppliedProperties(); } fakeLayer.Properties.Conditions.Clear(); foreach (var conditionViewModel in LayerConditionVms) { fakeLayer.Properties.Conditions.Add(conditionViewModel.LayerConditionModel); } var fake = GeneralHelpers.Serialize(fakeLayer); var real = GeneralHelpers.Serialize(Layer); if (fake.Equals(real)) { callback(true); return; } var close = await DialogService.ShowQuestionMessageBox("Unsaved changes", "Do you want to discard your changes?"); callback(close.Value); }
public async void DuplicateProfile() { if (SelectedProfile == null) { return; } var newProfile = GeneralHelpers.Clone(SelectedProfile); newProfile.Name = await DialogService.ShowInputDialog("Duplicate profile", "Please enter a unique profile name"); // Verify the name while (ProfileProvider.GetAll().Contains(newProfile)) { newProfile.Name = await DialogService.ShowInputDialog("Name already in use", "Please enter a unique profile name"); // Null when the user cancelled if (string.IsNullOrEmpty(SelectedProfile.Name)) { return; } } newProfile.IsDefault = false; ProfileProvider.AddOrUpdate(newProfile); LoadProfiles(); SelectedProfile = Profiles.FirstOrDefault(p => p.Name == newProfile.Name); }
public LayerEditorViewModel(LayerModel layer, ModuleDataModel dataModel, IEnumerable <ILayerType> types, IEnumerable <ILayerAnimation> layerAnimations) { Layer = layer; ProposedLayer = GeneralHelpers.Clone(layer); ProposedLayer.Children.Clear(); DataModel = DataModel; LayerTypes = new BindableCollection <ILayerType>(types.OrderBy(t => t.Name)); LayerAnimations = layerAnimations.OrderBy(l => l.Name).ToList(); DataModelProps = new BindableCollection <GeneralHelpers.PropertyCollection>(GeneralHelpers.GenerateTypeMap(dataModel)); if (Layer.Properties == null) { Layer.SetupProperties(); } // Setup existing conditions var conditions = ProposedLayer.Properties.Conditions.Select(c => new LayerConditionViewModel(this, c)); var keyBinds = ProposedLayer.Properties.LayerKeybindModels.Select(c => new LayerKeybindViewModel(this, c)); LayerConditionVms = new BindableCollection <LayerConditionViewModel>(conditions); LayerKeybindVms = new BindableCollection <LayerKeybindViewModel>(keyBinds); PropertyChanged += PropertiesViewModelHandler; // Setup existiing properties PreSelect(); }
public LayerDynamicPropertiesViewModel(string property, LayerEditorViewModel layerEditorViewModel) { _property = property; _layerEditorViewModel = layerEditorViewModel; // Look for the existing property model Proposed = new DynamicPropertiesModel(); var original = layerEditorViewModel .ProposedLayer .Properties .DynamicProperties .FirstOrDefault(lp => lp.LayerProperty == _property); if (original == null) { Proposed.LayerProperty = property; Proposed.LayerPropertyType = LayerPropertyType.PercentageOf; } else { Proposed = GeneralHelpers.Clone(original); } PropertyChanged += OnPropertyChanged; SetupControls(); }
/// <summary> /// Clones the given layer and adds it to the profile, after the original /// </summary> /// <param name="layer"></param> public void CloneLayer(LayerModel layer) { var clone = GeneralHelpers.Clone(layer); layer.InsertAfter(clone); UpdateLayerList(clone); }
public override async void CanClose(Action <bool> callback) { // Create a fake layer and apply the properties to it LayerPropertiesViewModel?.ApplyProperties(); // TODO: EventPropVM must have layer too if (EventPropertiesViewModel != null) { ProposedLayer.EventProperties = EventPropertiesViewModel.GetAppliedProperties(); } ProposedLayer.Properties.Conditions.Clear(); foreach (var conditionViewModel in LayerConditionVms) { ProposedLayer.Properties.Conditions.Add(conditionViewModel.ConditionModel); } ProposedLayer.Properties.LayerKeybindModels.Clear(); foreach (var layerKeybindViewModel in LayerKeybindVms) { ProposedLayer.Properties.LayerKeybindModels.Add(layerKeybindViewModel.LayerKeybindModel); } // Ignore this property as it isn't user input ProposedLayer.RenderAllowed = Layer.RenderAllowed; // If not a keyboard, ignore size and position if ((ProposedLayer.LayerType.DrawType != DrawType.Keyboard) || !ProposedLayer.LayerType.ShowInEdtor) { ProposedLayer.Properties.Width = Layer.Properties.Width; ProposedLayer.Properties.Height = Layer.Properties.Height; ProposedLayer.Properties.X = Layer.Properties.X; ProposedLayer.Properties.Y = Layer.Properties.Y; ProposedLayer.Properties.Contain = Layer.Properties.Contain; } // Ignore the children, can't just temporarily add them to the proposed layer because // that would upset the child layers' relations (sounds like Dr. Phil amirite?) var currentObj = GeneralHelpers.Clone(Layer); currentObj.Children.Clear(); // Apply the IsEvent boolean currentObj.SetupCondition(); ProposedLayer.SetupCondition(); var current = JsonConvert.SerializeObject(currentObj, Formatting.Indented); var proposed = JsonConvert.SerializeObject(ProposedLayer, Formatting.Indented); if (current.Equals(proposed)) { callback(true); return; } var close = await DialogService.ShowQuestionMessageBox("Unsaved changes", "Do you want to discard your changes?"); callback(close.Value); }
public override LayerPropertiesModel GetAppliedProperties() { HeightProperties.Apply(ProposedProperties); WidthProperties.Apply(ProposedProperties); OpacityProperties.Apply(ProposedProperties); var properties = GeneralHelpers.Clone(ProposedProperties); properties.Brush = Brush; return(properties); }
public KeyboardPropertiesViewModel(IDataModel dataModel, LayerPropertiesModel properties) : base(dataModel) { var keyboardProperties = (KeyboardPropertiesModel)properties; ProposedProperties = GeneralHelpers.Clone(keyboardProperties); Brush = ProposedProperties.Brush.CloneCurrentValue(); DataModelProps = new BindableCollection <GeneralHelpers.PropertyCollection>(); DataModelProps.AddRange(GeneralHelpers.GenerateTypeMap(dataModel)); HeightProperties = new LayerDynamicPropertiesViewModel("Height", DataModelProps, keyboardProperties); WidthProperties = new LayerDynamicPropertiesViewModel("Width", DataModelProps, keyboardProperties); OpacityProperties = new LayerDynamicPropertiesViewModel("Opacity", DataModelProps, keyboardProperties); }
public EventPropertiesViewModel(EventPropertiesModel eventPropertiesModel) { if (eventPropertiesModel == null) { ProposedProperties = new KeyboardEventPropertiesModel { ExpirationType = ExpirationType.Time, Length = new TimeSpan(0, 0, 1), TriggerDelay = new TimeSpan(0) } } ; else { ProposedProperties = GeneralHelpers.Clone(eventPropertiesModel); } }
/// <summary> /// Updates the inner layers when the settings have changed /// </summary> /// <param name="layerModel"></param> private void UpdateLayers(LayerModel layerModel) { var settings = (AudioPropertiesModel)layerModel.Properties; if (JsonConvert.SerializeObject(settings).Equals(JsonConvert.SerializeObject(_previousSettings))) { return; } _previousSettings = GeneralHelpers.Clone((AudioPropertiesModel)layerModel.Properties); _audioLayers.Clear(); if (settings.Direction == Direction.TopToBottom || settings.Direction == Direction.BottomToTop) { SetupVertical(settings); } else if (settings.Direction == Direction.LeftToRight || settings.Direction == Direction.RightToLeft) { SetupHorizontal(settings); } }
public LayerEditorViewModel(IDataModel dataModel, LayerModel layer) { _dataModel = dataModel; Layer = layer; ProposedLayer = GeneralHelpers.Clone(layer); if (Layer.Properties == null) { Layer.SetupProperties(); } DataModelProps = new BindableCollection <GeneralHelpers.PropertyCollection>(); DataModelProps.AddRange(GeneralHelpers.GenerateTypeMap(dataModel)); LayerConditionVms = new BindableCollection <LayerConditionViewModel>(layer.Properties.Conditions .Select(c => new LayerConditionViewModel(this, c, DataModelProps))); PropertyChanged += PropertiesViewModelHandler; PreSelect(); }
public async Task <ProfileModel> DuplicateProfile(ProfileModel selectedProfile) { var newProfile = GeneralHelpers.Clone(selectedProfile); var name = await GetValidProfileName("Duplicate profile", "Please enter a unique new profile name"); // User cancelled if (name == null) { return(null); } var doRename = await MakeProfileUnique(newProfile, name, newProfile.Name); if (!doRename) { return(null); } // Make sure it's not default, in case of copying a default profile newProfile.IsDefault = false; ProfileProvider.AddOrUpdate(newProfile); return(newProfile); }
public LayerDynamicPropertiesViewModel(string property, BindableCollection <GeneralHelpers.PropertyCollection> dataModelProps, KeyboardPropertiesModel keyboardProperties) { _property = property; // Look for the existing property model Proposed = new DynamicPropertiesModel(); var original = keyboardProperties.DynamicProperties.FirstOrDefault(lp => lp.LayerProperty == _property); if (original == null) { Proposed.LayerProperty = property; Proposed.LayerPropertyType = LayerPropertyType.PercentageOf; } else { Proposed = GeneralHelpers.Clone(original); } PropertyChanged += OnPropertyChanged; SetupControls(dataModelProps); }
public MousePropertiesViewModel(IDataModel dataModel, LayerPropertiesModel properties) : base(dataModel) { ProposedProperties = GeneralHelpers.Clone(properties); Brush = ProposedProperties.Brush.CloneCurrentValue(); }
public FolderPropertiesViewModel(IDataModel dataModel, LayerPropertiesModel properties) : base(dataModel) { ProposedProperties = GeneralHelpers.Clone(properties); }
public EventPropertiesModel GetAppliedProperties() { return(GeneralHelpers.Clone(ProposedProperties)); }
public override LayerPropertiesModel GetAppliedProperties() { return(GeneralHelpers.Clone(ProposedProperties)); }