private async void OnPivotSelectionChanged(HtmlPageEditorControlPivotItem item) { ContentRenderer renderer = new ContentRenderer(); string content; switch (item) { case HtmlPageEditorControlPivotItem.Editor: break; case HtmlPageEditorControlPivotItem.Preview: content = await renderer.RenderContentAsync(ViewModel.Content, "markdown"); //Preview_WebView.NavigateToString(content); htmlPageViewerControl.ViewModel = new HtmlPageViewerControlViewModel { Page = ViewModel.Page }; break; case HtmlPageEditorControlPivotItem.Metadata: break; default: throw new ArgumentOutOfRangeException(nameof(item), item, null); } }
private void StartProcessingAnimationMode() { if (AnimationHelper.IsInAnimationMode) { return; } if (Application.isPlaying) { return; } var objects = new List <Component>(); // All observered objects foreach (var observedObject in CurrentSequence.ObservedObjects) { SaveObjectValueInAnimationMode(observedObject, ref objects); } USUndoManager.RegisterCompleteObjectUndo(this, "Play"); IsInAnimationMode = true; ContentRenderer.StoreBaseState(); }
private void SequenceSwitch(JSequencer nextSequence) { CurrentSequence = nextSequence; ContentRenderer.OnSequenceChange(CurrentSequence); //TryToFixPropertyTimelines(CurrentSequence); //TryToFixObserverTimelines(CurrentSequence); }
public PostRendered GetPostRenderedByID(Guid id, ClientAppType clientType) { var post = postRepo.GetPostsInclude().Where(p => p.ID == id).SingleOrDefault(); var postsRendered = ContentRenderer.BindPostsContent(new List <Post>() { post }, clientType); return(postsRendered.First()); }
private void SequenceSwitch(USSequencer nextSequence) { USUndoManager.RegisterCompleteObjectUndo(this, "Select new sequence"); CurrentSequence = nextSequence; USUndoManager.RegisterCompleteObjectUndo(ContentRenderer, "Select new sequence"); ContentRenderer.OnSequenceChange(CurrentSequence); TryToFixPropertyTimelines(CurrentSequence); TryToFixObserverTimelines(CurrentSequence); }
/// <summary> /// Basically the latest posts on the whole site/mobile /// </summary> public List <PostRendered> GetPostForEverywhere(PostType type, ClientAppType clientType) { var query = postRepo.GetPostsInclude().Where(p => p.IsPublic).OrderByDescending(c => c.LastActivityUtc).Take(ResultsPostCount); if (type != PostType.Unknown) { query = query.Where(p => p.TypeID == (int)type); } return(ContentRenderer.BindPostsContent(query.ToList(), clientType)); }
public async Task <StorageFile> ExportPage(MarkdownPage page) { var contentRenderer = new ContentRenderer(); var content = contentRenderer.RenderContentAsync(page.Content, ContentType.Markdown); var file = await ApplicationData.Current.TemporaryFolder.CreateFileAsync($"{page.Link.Replace(':', '_')}.html", CreationCollisionOption.ReplaceExisting); await FileIO.WriteTextAsync(file, await content); return(file); }
private void OnGUI() { if (!CurrentSequence) { ShowNotification(new GUIContent("Select a Sequence Or Create New One")); } if (CurrentSequence && CurrentSequence.TimelineContainerCount < 1) { ShowNotification(new GUIContent("Drag A Object To Sequence Or add a New Container")); } if (CurrentSequence && CurrentSequence.TimelineContainerCount >= 1 && EditorApplication.timeSinceStartup - showAnimationModeTime > 3000) { RemoveNotification(); } GUILayout.BeginVertical(); { DisplayTopBar(); DisplayBottomBar(); DisplayEdittableArea(); } GUILayout.EndVertical(); ProcessHotkeys(); if (UnityEngine.Event.current.type == EventType.DragUpdated) { DragAndDrop.visualMode = DragAndDropVisualMode.Link; UnityEngine.Event.current.Use(); } if (UnityEngine.Event.current.type == EventType.DragPerform) { foreach (UnityEngine.Object dragObject in DragAndDrop.objectReferences) { GameObject GO = dragObject as GameObject; if (CurrentSequence) { if (GO != CurrentSequence.gameObject) { DragAndDrop.AcceptDrag(); List <JTimelineBase> list = CurrentSequence.CreateContainers(GO.transform); foreach (var line in list) { ContentRenderer.AddNewTimeLineForRender(line); } } } } UnityEngine.Event.current.Use(); } }
private void OnSceneGUI() { if (!USPreferenceWindow.RenderHierarchyGizmos) { return; } if (ContentRenderer != null) { ContentRenderer.OnSceneGUI(); } }
public void ProcessShouldDoNothingIfRenderingIsNull() { // Arrange var contentRenderer = new ContentRenderer(); _args.Result = contentRenderer; // Act _controller.Process(_args); // Assert Assert.That(_args.Result, Is.EqualTo(contentRenderer), "Rendering should not be re-assigned"); }
private void StopProcessingAnimationMode() { if (CurrentSequence) { CurrentSequence.Stop(); } if (Application.isPlaying) { return; } ContentRenderer.RestoreBaseState(); }
public void FormatRenderMessage() { var data = new LoggingData(); data.Message = "TestMessage"; var render = new ContentRenderer(); render.LayoutData = data; var output = render.RenderMessage("123{message}456{message}"); Assert.AreEqual("123TestMessage456TestMessage", output); }
public void FormatRenderDate() { var data = new LoggingData(); data.CurrentDateTime = DateTime.Parse("7/15/2017 1:23 PM"); var render = new ContentRenderer(); render.LayoutData = data; var output = render.RenderDate("Testing {date:format=yyyy-MM-dd} or {date:format=MM/dd/yy HH:mm}.log"); Assert.AreEqual("Testing 2017-07-15 or 07/15/17 13:23.log", output); }
public void FormatRenderLevel() { var data = new LoggingData(); data.LogLevel = LogLevel.Fatal; var renderer = new ContentRenderer(); renderer.LayoutData = data; var output = renderer.Render("-->{level}<--"); var assert = "-->Fatal<--"; Assert.AreEqual(assert, output); }
private void StartProcessingAnimationMode() { if (Application.isPlaying) { return; } List <Component> objects = new List <Component>(); foreach (Transform observedObject in CurrentSequence.ObservedObjects) { SaveObjectValueInAnimationMode(observedObject, ref objects); } ContentRenderer.StoreBaseState(); }
/// <summary> /// Gets the type of the current renderer. /// </summary> /// <returns>RenderType.</returns> private RenderType GetCurrentRenderType() { if (this.EditMode) { return(RenderType.Edit); } if (!PageEditing.PageIsInEditMode || !this.Editable) { return(RenderType.Default); } ContentRenderer enclosingContentRenderer = this.GetEnclosingContentRenderer(); return(enclosingContentRenderer != null ? enclosingContentRenderer.RenderType : RenderType.OnPageEdit); }
public void FormatRender() { var data = new LoggingData(); data.CurrentDateTime = DateTime.Parse("7/15/2017 1:23:15 PM"); data.Message = "Test log entry"; data.LogLevel = LogLevel.Error; var renderer = new ContentRenderer(); renderer.LayoutData = data; var output = renderer.Render("{date:format=yyyy-MM-dd HH:mm:ss}\t{level}\t{message}"); var assert = "2017-07-15 13:23:15\tError\tTest log entry"; Assert.AreEqual(assert, output); }
private void OnPivotSelectionChanged(TextPageEditorControlPivotItem item) { ContentRenderer renderer = new ContentRenderer(); string content; switch (item) { case TextPageEditorControlPivotItem.Editor: break; case TextPageEditorControlPivotItem.Metadata: break; default: throw new ArgumentOutOfRangeException(nameof(item), item, null); } }
/// <summary> /// Gets the control responsible for rendering content and tries to cast it to <see cref="IBlockControl"/>. /// If the control does not implement this <see cref="IBlockControl"/> we create a wrapper that handles this for us. /// </summary> private static IBlockControl GetIBlockControl(ContentRenderer contentRenderer) { var blockControl = contentRenderer.CurrentControl as IBlockControl; if (blockControl != null) { return(blockControl); } var genericIBlockControlWrapper = new GenericIBlockControlWrapper(); genericIBlockControlWrapper.InnerControl = contentRenderer.CurrentControl; genericIBlockControlWrapper.CurrentData = contentRenderer.CurrentData; genericIBlockControlWrapper.ContentRenderer = contentRenderer; contentRenderer.CurrentControl = genericIBlockControlWrapper; return(genericIBlockControlWrapper); }
public ControllerTests() { Identity = Substitute.For <IIdentity>(); User = Substitute.For <IPrincipal>(); Repository = Substitute.For <IRepository>(); SettingsProvider = Substitute.For <ISettingsProvider>(); ContentRenderer = Substitute.For <IContentRenderer>(); ControllerContext = CreateControllerContext(); UrlHelper = CreateUrlHelper(); User.Identity.Returns(Identity); ControllerContext.HttpContext.User.Returns(User); SettingsProvider.GetSettings <FunnelWebSettings>().Returns(new FunnelWebSettings { EnablePublicHistory = true }); Html = CreateHelper(); ContentRenderer.RenderTrusted(Arg.Any <string>(), Arg.Any <string>(), Arg.Any <HtmlHelper>()).Returns(c => c.Args()[0]); ContentRenderer.RenderUntrusted(Arg.Any <string>(), Arg.Any <string>(), Arg.Any <HtmlHelper>()).Returns(c => c.Args()[0]); }
private void UndoRedoCallback() { // This hack ensures that we process and update our in progress Sequence when Undo / Redoing if (CurrentSequence) { var previousRunningTime = CurrentSequence.RunningTime; // if we undo we always revert to our base state. ContentRenderer.RestoreBaseState(); // if our running time is then > 0.0f, we process the timeline if (previousRunningTime > 0.0f) { CurrentSequence.RunningTime = previousRunningTime; } } Repaint(); }
private async void Export_Click(ContentDialog sender, ContentDialogButtonClickEventArgs args) { var backend = new SqLiteBackend(new SqLiteStorageOptions("test"), SystemClock.Instance); var folder = await FileSystemAccess.PickFolderAsync(); var pages = new List <GenericPage>(); if (ExportAllPages.IsChecked == true) { pages.AddRange(await backend.GetAllPagesAsync()); } else if (ExportSinglePage.IsChecked == true) { pages.Add(await backend.GetPageAsync(_id)); } var exportHtml = ExportHtml.IsChecked == true; var exportMarkdown = ExportMarkdown.IsChecked == true; foreach (var page in pages) { if (exportHtml) { var contentRenderer = new ContentRenderer(); var file = await folder.CreateFileAsync($"{page.Link.Replace(':', '_')}.html", CreationCollisionOption.ReplaceExisting); await FileIO.WriteTextAsync(file, await contentRenderer.RenderContentAsync(page.Content, ContentType.Markdown), UnicodeEncoding.Utf8); } if (exportMarkdown) { var file = await folder.CreateFileAsync($"{page.Link.Replace(':', '_')}.md", CreationCollisionOption.ReplaceExisting); await FileIO.WriteTextAsync(file, page.Content, UnicodeEncoding.Utf8); } } Hide(); }
/// <summary> /// Underlying helper /// </summary> /// <param name="places"></param> /// <param name="postType"></param> /// <param name="clientType"></param> /// <returns></returns> private List <PostRendered> GetPostsForPlaces(List <CfCacheIndexEntry> places, PostType postType, ClientAppType clientType) { if (places.Count == 0) { return(GetPostForEverywhere(postType, clientType)); } var feedPlaceIDs = places.Select(p => p.ID).Distinct().ToList(); IQueryable <Post> query = postRepo.GetPostsInclude() .Where(c => c.IsPublic && feedPlaceIDs.Contains(c.PlaceID)) .OrderByDescending(c => c.LastActivityUtc) .Take(ResultsPostCount); if (postType != PostType.Unknown) { query = query.Where(p => p.TypeID == (int)postType); } return(ContentRenderer.BindPostsContent(query.ToList(), clientType)); }
private void StopProcessingAnimationMode() { if (CurrentSequence) { CurrentSequence.Stop(); } if (!AnimationHelper.IsInAnimationMode) { return; } if (Application.isPlaying) { return; } USUndoManager.RegisterCompleteObjectUndo(this, "Play"); IsInAnimationMode = false; ContentRenderer.RestoreBaseState(); }
private void OnGUI() { AnimationCurveEditor.AutoTangentMode = AutoTangentMode; AnimationHelper.IsInAnimationMode = IsInAnimationMode; if (!CurrentSequence) { ShowNotification(new GUIContent(USEditorUtility.SelectSequence)); } if (CurrentSequence && CurrentSequence.TimelineContainerCount <= 1) { ShowNotification(new GUIContent(USEditorUtility.NoAnimatableObjects)); } if (CurrentSequence && CurrentSequence.TimelineContainerCount > 1 && EditorApplication.timeSinceStartup - showAnimationModeTime > 3000) { RemoveNotification(); } using (new Shared.GUIBeginVertical()) { DisplayTopBar(); DisplayEdittableArea(); DisplayBottomBar(); } ProcessHotkeys(); if (Event.current.type == EventType.DragUpdated) { if (!AnimationHelper.IsInAnimationMode) { DragAndDrop.visualMode = DragAndDropVisualMode.Link; Event.current.Use(); } else { showAnimationModeTime = EditorApplication.timeSinceStartup; ShowNotification(new GUIContent(USEditorUtility.AddingNewAffectedObjectWhilstInAnimationMode)); } } if (Event.current.type == EventType.DragPerform) { if (!AnimationHelper.IsInAnimationMode) { foreach (var dragObject in DragAndDrop.objectReferences) { var GO = dragObject as GameObject; if (GO != CurrentSequence.gameObject) { DragAndDrop.AcceptDrag(); //Do we already have a timeline for this object foreach (var timelineContainer in CurrentSequence.TimelineContainers) { if (timelineContainer.AffectedObject == GO.transform) { return; } } var newTimelineContainer = CurrentSequence.CreateNewTimelineContainer(GO.transform); USUndoManager.RegisterCreatedObjectUndo(newTimelineContainer.gameObject, "Add New Timeline Container"); ContentRenderer.AddNewTimelineContainer(newTimelineContainer); } } Event.current.Use(); } } }
private void OnSceneGUI() { ContentRenderer.OnSceneGUI(); }
private void DisplayBottomBar() { float space = 16.0f; GUILayout.Box("", EditorStyles.toolbar, GUILayout.ExpandWidth(true), GUILayout.Height(20.0f)); if (UnityEngine.Event.current.type == EventType.Repaint) { BottomBar = GUILayoutUtility.GetLastRect(); } if (CurrentSequence == null) { return; } GUILayout.BeginArea(BottomBar); { GUILayout.BeginHorizontal(); { string[] showAllOptions = { "Show All", "Show Only Animated" }; int selectedShowAll = 0; selectedShowAll = EditorGUILayout.Popup(selectedShowAll, showAllOptions, EditorStyles.toolbarPopup, GUILayout.MaxWidth(120.0f)); //开始检查是否有任何界面元素变化 EditorGUI.BeginChangeCheck(); string[] playBackOptions = { "Playback : Normal", "Playback : Looping", "Playback : PingPong" }; int selectedAnimationType = 0; if (CurrentSequence.IsLopping) { selectedAnimationType = 1; } else if (CurrentSequence.IsPingPonging) { selectedAnimationType = 2; } selectedAnimationType = EditorGUILayout.Popup(selectedAnimationType, playBackOptions, EditorStyles.toolbarPopup, GUILayout.MaxWidth(120.0f)); if (EditorGUI.EndChangeCheck()) { CurrentSequence.IsLopping = false; CurrentSequence.IsPingPonging = false; if (selectedAnimationType == 1) { CurrentSequence.IsLopping = true; CurrentSequence.IsPingPonging = false; } else if (selectedAnimationType == 2) { CurrentSequence.IsLopping = false; CurrentSequence.IsPingPonging = true; } } GUILayout.Space(space); GUILayout.Box("", USEditorUtility.SeperatorStyle, GUILayout.Height(18.0f)); GUILayout.Space(space); EditorGUILayout.LabelField("", "Running Time", GUILayout.MaxWidth(100.0f)); //开始检查是否有任何界面元素变化 EditorGUI.BeginChangeCheck(); float runningTime = EditorGUILayout.FloatField("", CurrentSequence.RunningTime, GUILayout.MaxWidth(50.0f)); if (EditorGUI.EndChangeCheck()) { SetRunningTime(runningTime); } GUILayout.Space(space); GUILayout.Box("", USEditorUtility.SeperatorStyle, GUILayout.Height(18.0f)); GUILayout.Space(space); EditorGUILayout.LabelField("", "Duration", GUILayout.MaxWidth(50.0f)); EditorGUI.BeginChangeCheck(); CurrentSequence.Duration = EditorGUILayout.FloatField("", CurrentSequence.Duration, GUILayout.MaxWidth(50.0f)); if (EditorGUI.EndChangeCheck()) { ContentRenderer.UpdateCachedMarkerInformation(); } GUILayout.Space(space); GUILayout.Box("", USEditorUtility.SeperatorStyle, GUILayout.Height(18.0f)); GUILayout.Space(space); EditorGUILayout.LabelField("", "PlaybackRate", GUILayout.MaxWidth(80.0f)); EditorGUI.BeginChangeCheck(); float playbackRate = EditorGUILayout.FloatField("", CurrentSequence.PlaybackRate, GUILayout.MaxWidth(50.0f)); if (EditorGUI.EndChangeCheck()) { CurrentSequence.PlaybackRate = playbackRate; ContentRenderer.UpdateCachedMarkerInformation(); } GUILayout.FlexibleSpace(); } GUILayout.EndHorizontal(); } GUILayout.EndArea(); }
private void DisplayBottomBar() { var space = 16.0f; GUILayout.Box("", EditorStyles.toolbar, GUILayout.ExpandWidth(true), GUILayout.Height(20.0f)); if (Event.current.type == EventType.Repaint) { BottomBar = GUILayoutUtility.GetLastRect(); } if (CurrentSequence == null) { return; } using (new Shared.GUIBeginArea(BottomBar)) { using (new Shared.GUIBeginHorizontal()) { USUndoManager.BeginChangeCheck(); string[] showAllOptions = { "Show All", "Show Only Animated" }; var selectedShowAll = 0; if (ShowOnlyAnimated) { selectedShowAll = 1; } selectedShowAll = EditorGUILayout.Popup(selectedShowAll, showAllOptions, EditorStyles.toolbarPopup, GUILayout.MaxWidth(120.0f)); if (USUndoManager.EndChangeCheck()) { USUndoManager.PropertyChange(this, "Show Animated"); if (selectedShowAll == 1) { ShowOnlyAnimated = true; } else { ShowOnlyAnimated = false; } } USUndoManager.BeginChangeCheck(); string[] playBackOptions = { "Playback : Normal", "Playback : Looping", "Playback : PingPong" }; var selectedAnimationType = 0; if (CurrentSequence.IsLopping) { selectedAnimationType = 1; } else if (CurrentSequence.IsPingPonging) { selectedAnimationType = 2; } selectedAnimationType = EditorGUILayout.Popup(selectedAnimationType, playBackOptions, EditorStyles.toolbarPopup, GUILayout.MaxWidth(120.0f)); if (USUndoManager.EndChangeCheck()) { USUndoManager.PropertyChange(CurrentSequence, "Playback State"); CurrentSequence.IsLopping = false; CurrentSequence.IsPingPonging = false; if (selectedAnimationType == 1) { CurrentSequence.IsLopping = true; CurrentSequence.IsPingPonging = false; } else if (selectedAnimationType == 2) { CurrentSequence.IsLopping = false; CurrentSequence.IsPingPonging = true; } } USUndoManager.BeginChangeCheck(); string[] curveAutoTangentModesNames = { "Tangent Mode : None", "Tangent Mode : Smooth", "Tangent Mode : Flatten", "Tangent Mode : RightLinear", "Tangent Mode : RightConstant", "Tangent Mode : LeftLinear", "Tangent Mode : LeftConstant", "Tangent Mode : BothLinear", "Tangent Mode : BothConstant", }; var newAutoTangentMode = EditorGUILayout.Popup((int)AutoTangentMode, curveAutoTangentModesNames, EditorStyles.toolbarPopup, GUILayout.MaxWidth(150.0f)); if (USUndoManager.EndChangeCheck()) { USUndoManager.PropertyChange(this, "AutoTangentMode"); AutoTangentMode = (CurveAutoTangentModes)newAutoTangentMode; AnimationCurveEditor.AutoTangentMode = AutoTangentMode; } GUILayout.Space(space); GUILayout.Box("", USEditorUtility.SeperatorStyle, GUILayout.Height(18.0f)); GUILayout.Space(space); EditorGUILayout.LabelField("", "Running Time", GUILayout.MaxWidth(100.0f)); USUndoManager.BeginChangeCheck(); var runningTime = EditorGUILayout.FloatField("", CurrentSequence.RunningTime, GUILayout.MaxWidth(50.0f)); if (USUndoManager.EndChangeCheck()) { USUndoManager.PropertyChange(CurrentSequence, "Running Time"); SetRunningTime(runningTime); } GUILayout.Space(space); GUILayout.Box("", USEditorUtility.SeperatorStyle, GUILayout.Height(18.0f)); GUILayout.Space(space); EditorGUILayout.LabelField("", "Duration", GUILayout.MaxWidth(50.0f)); USUndoManager.BeginChangeCheck(); var duration = EditorGUILayout.FloatField("", CurrentSequence.Duration, GUILayout.MaxWidth(50.0f)); if (USUndoManager.EndChangeCheck()) { USUndoManager.PropertyChange(CurrentSequence, "Duration"); CurrentSequence.Duration = duration; ContentRenderer.UpdateCachedMarkerInformation(); ContentRenderer.USHierarchy.ExternalModification(); } GUILayout.Space(space); GUILayout.Box("", USEditorUtility.SeperatorStyle, GUILayout.Height(18.0f)); GUILayout.Space(space); EditorGUILayout.LabelField("", "PlaybackRate", GUILayout.MaxWidth(80.0f)); USUndoManager.BeginChangeCheck(); var playbackRate = EditorGUILayout.FloatField("", CurrentSequence.PlaybackRate, GUILayout.MaxWidth(50.0f)); if (USUndoManager.EndChangeCheck()) { USUndoManager.PropertyChange(CurrentSequence, "PlaybackRate"); CurrentSequence.PlaybackRate = playbackRate; ContentRenderer.UpdateCachedMarkerInformation(); } GUILayout.FlexibleSpace(); } } }
/// <summary> /// Gets the control responsible for rendering content and tries to cast it to <see cref="IBlockControl"/>. /// If the control does not implement this <see cref="IBlockControl"/> we create a wrapper that handles this for us. /// </summary> private static IBlockControl GetIBlockControl(ContentRenderer contentRenderer) { var blockControl = contentRenderer.CurrentControl as IBlockControl; if (blockControl != null) { return blockControl; } var genericIBlockControlWrapper = new GenericIBlockControlWrapper(); genericIBlockControlWrapper.InnerControl = contentRenderer.CurrentControl; genericIBlockControlWrapper.CurrentData = contentRenderer.CurrentData; genericIBlockControlWrapper.ContentRenderer = contentRenderer; contentRenderer.CurrentControl = genericIBlockControlWrapper; return genericIBlockControlWrapper; }
/// <summary> /// Select feed post made by a single user /// </summary> /// <param name="locationID"></param> /// <param name="clientType"></param> /// <returns></returns> public List <PostRendered> GetPostForUser(Guid userID, ClientAppType clientType, int count) { var posts = postRepo.GetAll().Where(p => p.UserID == userID).OrderByDescending(p => p.Utc).Take(count).ToList(); return(ContentRenderer.BindPostsContent(posts, clientType)); }
public void ExternalModification() { ContentRenderer.ExternalModification(); }