protected override double GetNativeHeight(SceneElement element) { MediaSceneElement mediaSceneElement = element as MediaSceneElement; if (mediaSceneElement != null && mediaSceneElement.IsViewObjectValid) { return(mediaSceneElement.Height); } return(base.GetNativeWidth(element)); }
protected override IList <SceneElement> AddToDocumentInternal(string importedFilePath, SceneElement element, ISceneInsertionPoint insertionPoint, SceneViewModel sceneViewModel, SceneEditTransaction editTransaction) { MediaSceneElement mediaSceneElement = element as MediaSceneElement; IList <SceneElement> list = (IList <SceneElement>) new List <SceneElement>(); if (mediaSceneElement != null) { double num = (double)mediaSceneElement.GetLocalOrDefaultValueAsWpf(DesignTimeProperties.DesignTimeNaturalDurationProperty); mediaSceneElement.ClearLocalValue(DesignTimeProperties.DesignTimeNaturalDurationProperty); if (insertionPoint.CanInsert((ITypeId)mediaSceneElement.Type)) { if (!JoltHelper.TypeSupported((ITypeResolver)element.ProjectContext, PlatformTypes.MediaTimeline)) { Uri uri = new Uri(importedFilePath, UriKind.RelativeOrAbsolute); mediaSceneElement.SetLocalValueAsWpf(MediaSceneElement.SourceProperty, (object)uri); } else { IStoryboardContainer mediaStoryboardContainer = insertionPoint.SceneNode.StoryboardContainer; StoryboardTimelineSceneNode targetStoryboard = (StoryboardTimelineSceneNode)null; sceneViewModel.EditContextManager.SingleViewModelEditContextWalker.Walk(false, (SingleHistoryCallback)((context, isGhosted) => { if (context.StoryboardContainer != mediaStoryboardContainer) { return(false); } targetStoryboard = context.Timeline; return(true); })); if (targetStoryboard == null) { foreach (TriggerBaseNode triggerBaseNode in (IEnumerable <TriggerBaseNode>)mediaStoryboardContainer.VisualTriggers) { EventTriggerNode eventTriggerNode = triggerBaseNode as EventTriggerNode; if (eventTriggerNode != null && eventTriggerNode.RoutedEvent == FrameworkElement.LoadedEvent) { foreach (SceneNode sceneNode in (IEnumerable <SceneNode>)eventTriggerNode.Actions) { TimelineActionNode timelineActionNode = sceneNode as TimelineActionNode; if (timelineActionNode != null && timelineActionNode.TimelineOperation == TimelineOperation.Begin) { targetStoryboard = timelineActionNode.TargetTimeline; if (!TimelinePane.ShouldExposeStoryboardToUser((SceneNode)targetStoryboard)) { targetStoryboard = (StoryboardTimelineSceneNode)null; } else { break; } } } } if (targetStoryboard != null) { break; } } if (targetStoryboard != null) { sceneViewModel.SetActiveStoryboardTimeline(mediaStoryboardContainer, targetStoryboard, (TriggerBaseNode)null); } } if (targetStoryboard == null) { targetStoryboard = sceneViewModel.AnimationEditor.CreateNewTimeline(sceneViewModel.ActiveStoryboardContainer, element.Name, TriggerCreateBehavior.Default, true); sceneViewModel.AnimationEditor.IsRecording = false; } IType type = this.DesignerContext.ActiveDocument.ProjectContext.ResolveType(PlatformTypes.MediaTimeline); MediaTimelineSceneNode timelineSceneNode = (MediaTimelineSceneNode)sceneViewModel.CreateSceneNode(type.RuntimeType); timelineSceneNode.SetLocalValue(DesignTimeProperties.DesignTimeNaturalDurationProperty, (object)num); Uri uri = new Uri(importedFilePath, UriKind.RelativeOrAbsolute); timelineSceneNode.Source = uri; timelineSceneNode.TargetName = element.Name; double animationTime = sceneViewModel.AnimationEditor.AnimationTime; timelineSceneNode.Begin = animationTime; targetStoryboard.Children.Add((TimelineSceneNode)timelineSceneNode); editTransaction.Update(); } list.Add(element); insertionPoint.Insert((SceneNode)mediaSceneElement); } } return(list); }