protected ControlPointViewModelBase([NotNull] CurveViewModelBase curve) : base(curve.SafeArgument(nameof(curve)).ServiceProvider) { Curve = curve; DependentProperties.Add(nameof(Point), new[] { nameof(ActualKey), nameof(ActualPoint), nameof(ActualValue) }); }
protected CombinedObservableNode(ObservableViewModel ownerViewModel, string name, IEnumerable <SingleObservableNode> combinedNodes, Index index) : base(ownerViewModel, index) { // ReSharper disable once DoNotCallOverridableMethodsInConstructor DependentProperties.Add(nameof(Value), new[] { nameof(HasMultipleValues), nameof(IsPrimitive), nameof(HasList), nameof(HasDictionary) }); this.combinedNodes = new List <SingleObservableNode>(combinedNodes); Name = name; DisplayName = this.combinedNodes.First().DisplayName; combinedNodeInitialValues = new List <object>(); distinctCombinedNodeInitialValues = new HashSet <object>(); bool isReadOnly = false; bool isVisible = false; bool nullOrder = false; foreach (var node in this.combinedNodes) { if (node.IsDisposed) { throw new InvalidOperationException("One of the combined node is already disposed."); } if (node.IsReadOnly) { isReadOnly = true; } if (node.IsVisible) { isVisible = true; } if (node.Order == null) { nullOrder = true; } if (order == node.Order || (!nullOrder && order == null)) { order = node.Order; } combinedNodeInitialValues.Add(node.Value); distinctCombinedNodeInitialValues.Add(node.Value); } IsReadOnly = isReadOnly; IsVisible = isVisible; ResetInitialValues = new AnonymousCommand(ServiceProvider, () => { using (Owner.BeginCombinedAction(Owner.FormatCombinedUpdateMessage(this, null), Path)) { CombinedNodes.Zip(combinedNodeInitialValues).ForEach(x => x.Item1.Value = x.Item2); Refresh(); } }); }
protected DirectoryBaseViewModel(SessionViewModel session) : base(session) { SubDirectories = new ReadOnlyObservableCollection <DirectoryViewModel>(subDirectories); // ReSharper disable DoNotCallOverridableMethodsInConstructor - looks like an issue in resharper DependentProperties.Add(nameof(Parent), new[] { nameof(Path), nameof(Package), nameof(Root) }); // ReSharper restore DoNotCallOverridableMethodsInConstructor RegisterMemberCollectionForActionStack(nameof(Assets), Assets); }
protected NodeViewModel(GraphViewModel ownerViewModel, Index index) : base(ownerViewModel.ServiceProvider) { DependentProperties.Add(nameof(Path), new[] { nameof(DisplayPath) }); Owner = ownerViewModel; Index = index; Guid = Guid.NewGuid(); IsVisible = true; IsReadOnly = false; }
/// <summary> /// Initializes a new instance of the <see cref="SolutionPlatformViewModel"/> class. /// </summary> /// <param name="serviceProvider">The service provider for this view model.</param> /// <param name="solutionPlatform">The solution platform represented by the view model.</param> /// <param name="isAlreadyInstalled">Indicates whether this plaform is already installed in the related package.</param> /// <param name="initiallySelected">Indicates whether this plaform should be initially selected.</param> public SolutionPlatformViewModel(IViewModelServiceProvider serviceProvider, SolutionPlatform solutionPlatform, bool isAlreadyInstalled, bool initiallySelected) : base(serviceProvider) { SolutionPlatform = solutionPlatform; IsAvailableOnMachine = solutionPlatform.IsAvailable; IsSelected = initiallySelected; IsAlreadyInstalled = isAlreadyInstalled; DependentProperties.Add(nameof(IsSelected), new[] { nameof(MarkedToRemove) }); SelectedTemplate = AvailableTemplates.FirstOrDefault(); }
protected EntityHierarchyElementViewModel([NotNull] EntityHierarchyEditorViewModel editor, [NotNull] EntityHierarchyViewModel asset, [NotNull] IEnumerable <EntityDesign> childEntities, object assetSideInstance) : base(editor, asset, childEntities) { this.assetSideInstance = assetSideInstance; LoadCommand = new AnonymousTaskCommand <bool>(ServiceProvider, recursive => RequestLoading(!IsLoaded, recursive)); LockCommand = new AnonymousTaskCommand <bool>(ServiceProvider, recursive => RequestLocking(!IsLocked, recursive)); DependentProperties.Add(nameof(IsLoaded), new[] { nameof(IsSelectable) }); DependentProperties.Add(nameof(IsLocked), new[] { nameof(IsSelectable) }); }
public TemplateDescriptionGroupViewModel(IViewModelServiceProvider serviceProvider, string name) : base(serviceProvider) { if (name == null) { throw new ArgumentNullException(nameof(name)); } Name = name; Templates = new ObservableList <ITemplateDescriptionViewModel>(); DependentProperties.Add(nameof(Parent), new[] { nameof(Path) }); }
/// <summary> /// Initializes a new instance of the <see cref="ViewportViewModel"/> class. /// </summary> /// <param name="serviceProvider">The service provider to use with this view model.</param> public ViewportViewModel(IViewModelServiceProvider serviceProvider) : base(serviceProvider) { DependentProperties.Add(nameof(ContentWidth), new[] { nameof(ActualContentWidth) }); DependentProperties.Add(nameof(ContentHeight), new[] { nameof(ActualContentHeight) }); DependentProperties.Add(nameof(ScaleFactor), new[] { nameof(ActualContentWidth), nameof(ActualContentHeight) }); FitOnScreenCommand = new AnonymousCommand(ServiceProvider, FitOnScreen); ScaleToRealSizeCommand = new AnonymousCommand(ServiceProvider, ScaleToRealSize); ZoomInCommand = new AnonymousCommand(ServiceProvider, () => ZoomIn(ViewportWidth * 0.5, ViewportHeight * 0.5)); ZoomOutCommand = new AnonymousCommand(ServiceProvider, () => ZoomOut(ViewportWidth * 0.5, ViewportHeight * 0.5)); }
public SpriteBordersViewModel(SpriteInfoViewModel sprite, IObjectNode spriteNode) : base(sprite) { textureRegionNode = spriteNode[nameof(SpriteInfo.TextureRegion)]; textureRegionNode.ValueChanged += OnTextureRegionValueChanged; var spriteBordersNode = spriteNode[nameof(SpriteInfo.Borders)]; borderBinding = new MemberGraphNodeBinding <Vector4>(spriteBordersNode, nameof(Borders), OnPropertyChanging, OnPropertyChanged, UndoRedoService); DependentProperties.Add(nameof(Borders), new[] { nameof(ActualBorders) }); DependentProperties.Add(nameof(ScaleFactor), new[] { nameof(ActualBorders) }); }
public SpriteSheetPreviewViewModel(SessionViewModel session) : base(session) { PreviewPreviousFrameCommand = new AnonymousCommand(ServiceProvider, () => { if (PreviewFrameCount > 0) { PreviewCurrentFrame = 1 + (PreviewCurrentFrame + PreviewFrameCount - 2) % PreviewFrameCount; } }); PreviewNextFrameCommand = new AnonymousCommand(ServiceProvider, () => { if (PreviewFrameCount > 0) { PreviewCurrentFrame = 1 + (PreviewCurrentFrame + PreviewFrameCount) % PreviewFrameCount; } }); DependentProperties.Add(nameof(DisplayMode), new[] { nameof(PreviewCurrentFrame), nameof(PreviewFrameCount) }); }
public TextureRegionViewModel(SpriteInfoViewModel sprite, IMemberNode textureRegionNode) : base(sprite) { if (sprite.Editor.Cache != null) { RefreshImageSize(); } else { sprite.Editor.Initialized += EditorInitialized; } textureRegionBinding = new MemberGraphNodeBinding <RectangleF, Rectangle>(textureRegionNode, nameof(Region), OnPropertyChanging, OnPropertyChanged, x => (Rectangle)x, UndoRedoService); DependentProperties.Add(nameof(Region), new[] { nameof(ActualLeft), nameof(ActualTop), nameof(ActualWidth), nameof(ActualHeight), nameof(ActualRightOffset), nameof(ActualBottomOffset) }); DependentProperties.Add(nameof(ScaleFactor), new[] { nameof(ActualLeft), nameof(ActualTop), nameof(ActualWidth), nameof(ActualHeight), nameof(ActualRightOffset), nameof(ActualBottomOffset) }); DependentProperties.Add(nameof(ImageWidth), new[] { nameof(ActualRightOffset), nameof(ActualBottomOffset) }); DependentProperties.Add(nameof(ImageHeight), new[] { nameof(ActualRightOffset), nameof(ActualBottomOffset) }); }
public SpriteCenterViewModel(SpriteInfoViewModel sprite, IObjectNode spriteNode) : base(sprite) { var spriteCenterNode = spriteNode[nameof(SpriteInfo.Center)]; spriteCenterNodeBinding = new MemberGraphNodeBinding <Vector2>(spriteCenterNode, nameof(Center), OnPropertyChanging, OnPropertyChanged, UndoRedoService); var centerFromMiddleNode = spriteNode[nameof(SpriteInfo.CenterFromMiddle)]; centerFromMiddleBinding = new MemberGraphNodeBinding <bool>(centerFromMiddleNode, nameof(CenterFromMiddle), OnPropertyChanging, OnPropertyChanged, UndoRedoService); var textureRegionNode = spriteNode[nameof(SpriteInfo.TextureRegion)]; textureRegionBinding = new MemberGraphNodeBinding <Rectangle>(textureRegionNode, nameof(ActualCenter), OnPropertyChanging, OnPropertyChanged, UndoRedoService); DependentProperties.Add(nameof(Center), new[] { nameof(ActualCenter) }); DependentProperties.Add(nameof(CenterFromMiddle), new[] { nameof(ActualCenter) }); DependentProperties.Add(nameof(ScaleFactor), new[] { nameof(ActualCenter) }); }
public PackageViewModel(SessionViewModel session, PackageContainer packageContainer, bool packageAlreadyInSession) : base(session) { PackageContainer = packageContainer; Package = PackageContainer.Package; HasBeenUpgraded = Package.IsDirty; DependentProperties.Add(nameof(PackagePath), new[] { nameof(Name), nameof(RootDirectory) }); Dependencies = new DependencyCategoryViewModel(nameof(Dependencies), this, session, Package.RootAssets); AssetMountPoint = new AssetMountPointViewModel(this); content.Add(AssetMountPoint); content.Add(Dependencies); RenameCommand = new AnonymousCommand(ServiceProvider, () => IsEditing = true); IsLoaded = Package.State >= PackageState.AssetsReady; // IsDeleted will make the package added to Session.LocalPackages, so let's do it last InitialUndelete(!packageAlreadyInSession); DeletedAssets.CollectionChanged += DeletedAssetsChanged; }
public SpriteSheetEditorViewModel([NotNull] SpriteSheetViewModel spriteSheet) : base(spriteSheet) { Viewport = new ViewportViewModel(ServiceProvider); // Commands DisplaySpriteSheetPropertiesCommand = new AnonymousCommand(ServiceProvider, DisplaySpriteSheetProperties); RemoveImageCommand = new AnonymousCommand(ServiceProvider, RemoveSelectedImages); SelectNextSpriteCommand = new AnonymousCommand <int>(ServiceProvider, SelectNextSprite); MoveImageCommand = new AnonymousCommand <int>(ServiceProvider, MoveImage); AddNewImageCommand = new AnonymousCommand(ServiceProvider, AddNewImage); UseWholeImageCommand = new AnonymousCommand(ServiceProvider, UseWholeImage); FocusOnRegionCommand = new AnonymousCommand(ServiceProvider, FocusOnRegion); DuplicateSelectedImagesCommand = new AnonymousCommand(ServiceProvider, DuplicateSelectedImages); CopyImageCommand = new AnonymousCommand(ServiceProvider, CopyImages, CanCopyImages); PasteImageCommand = new AnonymousCommand(ServiceProvider, PasteImages, () => pasteMonitor.Get(CanPasteImages)); FindSpriteRegionCommand = new AnonymousCommand <WindowsPoint>(ServiceProvider, FindSpriteRegion); ToggleSelectionHighlightCommand = new AnonymousCommand(ServiceProvider, () => SelectionHighlightEnabled = !SelectionHighlightEnabled); ToggleToolModeCommand = new AnonymousCommand <SpriteSheetEditorToolMode>(ServiceProvider, ToggleToolMode); ToggleUseMagicWandCommand = new AnonymousCommand(ServiceProvider, () => ToggleToolMode(SpriteSheetEditorToolMode.MagicWand)); SelectedSprites = new ObservableList <object>(); SelectedSprites.CollectionChanged += SelectedImagesCollectionChanged; ServiceProvider.Get <SelectionService>().RegisterSelectionScope(id => Sprites.FirstOrDefault(x => x.Id == id), obj => (obj as SpriteInfoViewModel)?.Id, SelectedSprites); sprites = new ObservableList <SpriteInfoViewModel>(Asset.Asset.Sprites.Select((x, i) => new SpriteInfoViewModel(this, x) { Index = i })); Sprites.CollectionChanged += ImageCollectionChanged; DependentProperties.Add(nameof(ToolMode), new[] { nameof(UsingPixelTool) }); magicWandUseTransparency = !Asset.Asset.ColorKeyEnabled; var rootNode = Session.AssetNodeContainer.GetNode(spriteSheet.Asset); spritesNode = rootNode[nameof(SpriteSheetAsset.Sprites)].Target; colorKeyNodeBinding = new MemberGraphNodeBinding <Color>(rootNode[nameof(SpriteSheetAsset.ColorKeyColor)], nameof(ColorKey), OnPropertyChanging, OnPropertyChanged, UndoRedoService); colorKeyEnabledNodeBinding = new MemberGraphNodeBinding <bool>(rootNode[nameof(SpriteSheetAsset.ColorKeyEnabled)], nameof(ColorKeyEnabled), OnPropertyChanging, OnPropertyChanged, UndoRedoService); typeNodeBinding = new MemberGraphNodeBinding <SpriteSheetType>(rootNode[nameof(SpriteSheetAsset.Type)], nameof(Type), OnPropertyChanging, OnPropertyChanged, UndoRedoService); // TODO: dispose this spritesNode.ItemChanged += SpritesContentChanged; }
internal LauncherViewModel(IViewModelServiceProvider serviceProvider, NugetStore store) : base(serviceProvider) { if (store == null) { throw new ArgumentNullException(nameof(store)); } DependentProperties.Add("ActiveVersion", new[] { "ActiveDocumentationPages" }); this.store = store; store.Logger = this; DisplayReleaseAnnouncement(); VsixPackage = new VsixVersionViewModel(this, store); // Commands InstallLatestVersionCommand = new AnonymousTaskCommand(ServiceProvider, InstallLatestVersion) { IsEnabled = false }; OpenUrlCommand = new AnonymousTaskCommand <string>(ServiceProvider, OpenUrl); ReconnectCommand = new AnonymousTaskCommand(ServiceProvider, async() => { // We are back online (or so we think) IsOffline = false; await FetchOnlineData(); }); StartStudioCommand = new AnonymousTaskCommand(ServiceProvider, StartStudio) { IsEnabled = false }; foreach (var devVersion in LauncherSettings.DeveloperVersions) { var version = new XenkoDevVersionViewModel(this, store, null, devVersion, false); xenkoVersions.Add(version); } FetchOnlineData().Forget(); LoadRecentProjects(); uninstallHelper = new UninstallHelper(serviceProvider, store); GameStudioSettings.RecentProjectsUpdated += (sender, e) => Dispatcher.InvokeAsync(LoadRecentProjects).Forget(); }
private DragContainer() { DependentProperties.Add(nameof(IsAccepted), new[] { nameof(IsRejected) }); }
protected CombinedNodeViewModel(GraphViewModel ownerViewModel, string name, IEnumerable <SingleNodeViewModel> combinedNodes, Index index) : base(ownerViewModel, index) { // ReSharper disable once DoNotCallOverridableMethodsInConstructor DependentProperties.Add(nameof(Value), new[] { nameof(HasMultipleValues), nameof(IsPrimitive), nameof(HasCollection), nameof(HasDictionary) }); this.combinedNodes = new List <SingleNodeViewModel>(combinedNodes); Name = name; DisplayName = this.combinedNodes.First().DisplayName; combinedNodeInitialValues = new List <object>(); distinctCombinedNodeInitialValues = new HashSet <object>(); bool isReadOnly = false; bool isVisible = false; bool nullOrder = false; foreach (var node in this.combinedNodes) { if (node.IsDestroyed) { throw new InvalidOperationException("One of the combined node is already disposed."); } if (node.IsReadOnly) { isReadOnly = true; } if (node.IsVisible) { isVisible = true; } if (node.Order == null) { nullOrder = true; } if (order == node.Order || (!nullOrder && order == null)) { order = node.Order; } // Note: sometimes member info could be different for the same member if we select objects of types that inherit from another // This will just affect the view order, so it shouldn't be a problem. if (memberInfo == null) { memberInfo = node.MemberInfo; } combinedNodeInitialValues.Add(node.Value); distinctCombinedNodeInitialValues.Add(node.Value); } IsReadOnly = isReadOnly; IsVisible = isVisible; ResetInitialValues = new AnonymousCommand(ServiceProvider, () => { using (Owner.BeginCombinedAction(Owner.FormatCombinedUpdateMessage(this, null), Path)) { CombinedNodes.Zip(combinedNodeInitialValues).ForEach(x => x.Item1.Value = x.Item2); Refresh(); } }); }