protected override void OnPreRender(EventArgs e) { var item = new SelectionUtility(this, Page.GetEngine()).SelectedItem; isInvalid = item == null || item.ID == 0; base.OnPreRender(e); }
static void Show() { SelectionUtility.ShowInWindow(new Provider(), new ContentWindowParameters { ApplyInspectorStyling = false, AddScrollView = false, MinSize = new Vector2(500, 400) }); }
private static ContentItem GetSelectedItem(SelectionUtility selection, ProfileUser profile) { var selectedItem = selection.ParseSelectionFromRequest(); if (selectedItem == null && profile.Settings.ContainsKey("Selected")) { selectedItem = selection.ParseSelected((string)profile.Settings["Selected"]); } return(selectedItem ?? (selection.Traverse.StartPage)); }
protected override void Render(HtmlTextWriter writer) { var item = new SelectionUtility(this, Page.GetEngine()).SelectedItem; if (item == null || item.ID == 0) { cv.IsValid = false; cv.RenderControl(writer); } else base.Render(writer); }
private void NotifyViewing(IEngine engine, HttpContextWrapper context) { var selection = new SelectionUtility(context, engine); if (selection.SelectedItem != null) { engine.AddActivity(new ManagementActivity { Operation = "View", PerformedBy = context.User.Identity.Name, ID = selection.SelectedItem.ID, Path = selection.SelectedItem.Path }); } }
public object GetMessages(HttpContextBase context, SelectionUtility selection) { var messageContext = new Edit.Collaboration.CollaborationContext { SelectedItem = selection.ParseSelectionFromRequest(), User = context.User } .ParseLastDismissed(context.Request["lastDismissed"]); return(new { Messages = engine.Resolve <N2.Edit.Collaboration.ManagementMessageCollector>().GetMessages(messageContext).ToList() }); }
public IEnumerator ContentProvider_WhenGivenNullContent_Exits() { var content = new NullContent(); LogAssert.Expect(LogType.Error, "SelectionUtilityTests.NullContent: Releasing content named 'Null' because it returned null value."); SelectionUtility.ShowInWindow(content); for (var i = 0; i < 10; ++i) { yield return(null); } Assert.That(Resources.FindObjectsOfTypeAll <ContentWindow>().Any(), Is.False); }
private void DrawAddressData(Rect contentRect, PackerAssetData assetData) { EGUI.DrawAreaLine(contentRect, Color.black); Rect pingBtnRect = new Rect(contentRect.x + contentRect.width - contentRect.height * 2, contentRect.y, contentRect.height * 2, contentRect.height); if (GUI.Button(pingBtnRect, "Ping")) { SelectionUtility.PingObject(assetData.Path); } Rect ValueRect = new Rect(contentRect.x, contentRect.y, contentRect.width - contentRect.height * 2, contentRect.height); Rect drawRect = new Rect(ValueRect.x, ValueRect.y, ValueRect.width * 0.5f, ValueRect.height * 0.5f); EGUI.BeginLabelWidth(80); { EditorGUI.TextField(drawRect, "path", assetData.Path); } EGUI.EndLableWidth(); drawRect = new Rect(ValueRect.x, ValueRect.y + drawRect.height, ValueRect.width * 0.5f, ValueRect.height * 0.5f); EGUI.BeginLabelWidth(80); { EditorGUI.TextField(drawRect, "address", assetData.Address); } EGUI.EndLableWidth(); drawRect = new Rect(ValueRect.x + ValueRect.width * 0.5f, ValueRect.y, ValueRect.width * 0.5f, ValueRect.height * 0.5f); EGUI.BeginLabelWidth(80); { EditorGUI.TextField(drawRect, "labels", string.Join(",", assetData.Labels)); } EGUI.EndLableWidth(); drawRect = new Rect(ValueRect.x + ValueRect.width * 0.5f, ValueRect.y + drawRect.height, ValueRect.width * 0.5f, ValueRect.height * 0.5f); EGUI.BeginLabelWidth(80); { } EGUI.EndLableWidth(); //if (Window.IsAddressRepeated(assetData.Address, out List<PackerBundleData> datas)) //{ // if (GUI.Button(drawRect,addressRepeatContent)) // { // AssetAddressRepeatPopupContent content = new AssetAddressRepeatPopupContent() // { // RepeatAddressDatas = datas.ToArray(), // }; // PopupWindow.Show(drawRect, content); // } //} }
public IEnumerator ContentProvider_WhenContentThrows_Exits() { var content = new ExceptionContent(); LogAssert.Expect(LogType.Error, "SelectionUtilityTests.ExceptionContent: Releasing content named 'Exception' because it threw an exception."); LogAssert.Expect(LogType.Exception, "Exception: Why are you doing this?"); SelectionUtility.ShowInWindow(content); for (var i = 0; i < 10; ++i) { yield return(null); } Assert.That(Resources.FindObjectsOfTypeAll <ContentWindow>().Any(), Is.False); }
public static void ExtractAnCompressClipsFromFBX() { AnimationClip[] extractClips = ExtractClipsFromFBX(); if (extractClips != null && extractClips.Length > 0) { var clipInfos = (from clip in extractClips let clipAssetPath = AssetDatabase.GetAssetPath(clip) select AnimationClipCompress.CreateCompressedClip(clip, 4) ).ToArray(); SelectionUtility.ActiveObjects(clipInfos); } }
private void DrawSkeleton(Rect rect) { GUILayout.BeginArea(rect); { EditorGUILayout.BeginVertical(); { EGUILayout.DrawBoxHeader("Skeleton Data", EGUIStyles.BoxedHeaderCenterStyle, GUILayout.ExpandWidth(true)); if (currentCreatorData != null && skeletonCreatorDataDrawer != null) { skeletonCreatorDataDrawer.OnGUILayout(); AvatarSkeletonCreatorData skeletonCreatorData = currentCreatorData.skeletonData; string targetPrefabPath = skeletonCreatorData.GetSkeletonPrefabPath(); GameObject targetPrefab = null; if (!string.IsNullOrEmpty(targetPrefabPath)) { targetPrefab = AssetDatabase.LoadAssetAtPath <GameObject>(targetPrefabPath); } EditorGUILayout.Space(); EditorGUILayout.Space(); EditorGUILayout.ObjectField("Output", targetPrefab, typeof(GameObject), false); EditorGUILayout.Space(); GUILayout.FlexibleSpace(); if (GUILayout.Button("Create Skeleton")) { GameObject skeletonPrefab = AvatarCreatorUtil.CreateSkeleton(skeletonCreatorData); if (skeletonPrefab == null) { EditorUtility.DisplayDialog("Error", "Create Failed.\n Please view the details from the console!!!", "OK"); } else { SelectionUtility.PingObject(skeletonPrefab); } } if (GUILayout.Button("Preview Skeleton")) { PreviewSkeleton(); } } } EditorGUILayout.EndVertical(); } GUILayout.EndArea(); }
protected virtual InterfacePaths GetUrls(HttpContextBase context, SelectionUtility selection) { return(new InterfacePaths { Management = engine.ManagementPaths.GetManagementInterfaceUrl(), Delete = engine.Config.Sections.Management.Paths.DeleteItemUrl.ResolveUrlTokens(), Edit = engine.Config.Sections.Management.Paths.EditItemUrl.ResolveUrlTokens(), SelectedQueryKey = PathData.SelectedQueryKey, ItemQueryKey = PathData.ItemQueryKey, PageQueryKey = PathData.PageQueryKey, Create = engine.Config.Sections.Management.Paths.NewItemUrl.ResolveUrlTokens(), PreviewUrl = engine.GetContentAdapter <NodeAdapter>(selection.SelectedItem).GetPreviewUrl(selection.SelectedItem, allowDraft: true) }); }
protected override void Render(HtmlTextWriter writer) { var item = new SelectionUtility(this, Page.GetEngine()).SelectedItem; if (item == null || item.ID == 0) { cv.IsValid = false; cv.RenderControl(writer); } else { base.Render(writer); } }
public override void Process(CommandContext state) { if (state.Content.IsPage && state.Original.State != ContentState.New && state.Original.Name != state.Content.Name) { var url = new SelectionUtility(state.Content, null).SelectedUrl("{ManagementUrl}/Content/LinkTracker/UpdateReferences.aspx").ToUrl().AppendQuery("previousName", state.Original.Name); if (state.Content.Parent != null) { url = url.AppendQuery("previousParent", state.Content.Parent.Path); } state.RedirectUrl = url; } }
public static void CompressClip() { AnimationClip[] selectedClips = Selection.GetFiltered <AnimationClip>(SelectionMode.Assets); if (selectedClips == null || selectedClips.Length == 0) { return; } var clipInfos = (from clip in selectedClips let clipAssetPath = AssetDatabase.GetAssetPath(clip) select AnimationClipCompress.CreateCompressedClip(clip, 4) ).ToArray(); SelectionUtility.ActiveObjects(clipInfos); }
private bool CreatePart(AvatarPartCreatorData data) { var partData = AvatarCreatorUtil.CreatePart(currentCreatorData.skeletonPartData.outputFolder, data); if (partData == null) { EditorUtility.DisplayDialog("Error", "Create Failed.\n Please view the details from the console!!!", "OK"); return(false); } else { SelectionUtility.PingObject(partData); return(true); } }
public ContentItem GetAutosaveVersion() { var value = Page.Request[ClientID + "_autosaved_url"]; if (string.IsNullOrEmpty(value)) { return(null); } Url editUrl = value; var selection = new SelectionUtility(key => editUrl[key], Engine); var item = selection.ParseSelectionFromRequest(); return(item); }
public IEnumerator ShowingContent_InInspectorWindow_CanControlLifecycle() { Selection.activeObject = null; yield return(null); var content = new LifecycleContent(); content.Status = ContentStatus.ContentNotReady; SelectionUtility.ShowInInspector(content); for (var i = 0; i < 10; ++i) { yield return(null); } var editor = Resources.FindObjectsOfTypeAll <InspectorContentEditor>().FirstOrDefault(); Assert.That(editor && null != editor, Is.EqualTo(true)); var element = editor.Target.Root.Q <Element <LifecycleContent> >(); Assert.That(element, Is.Null); yield return(null); element = editor.Target.Root.Q <Element <LifecycleContent> >(); Assert.That(element, Is.Null); content.Status = ContentStatus.ContentReady; for (var i = 0; i < 10; ++i) { yield return(null); } element = editor.Target.Root.Q <Element <LifecycleContent> >(); Assert.That(element, Is.Not.Null); content.Status = ContentStatus.ContentNotReady; for (var i = 0; i < 10; ++i) { yield return(null); } element = editor.Target.Root.Q <Element <LifecycleContent> >(); Assert.That(element, Is.Null); content.Status = ContentStatus.ContentUnavailable; for (var i = 0; i < 10; ++i) { yield return(null); } Assert.That(editor && null != editor, Is.EqualTo(false)); }
public static void CreateGroupAsset() { string[] dirs = SelectionUtility.GetSelectionDirs(); if (dirs != null && dirs.Length > 0) { string filePath = $"{dirs[0]}/asset_address_group.asset"; filePath = AssetDatabase.GenerateUniqueAssetPath(filePath); var config = ScriptableObject.CreateInstance <AssetAddressGroup>(); AssetDatabase.CreateAsset(config, filePath); AssetDatabase.ImportAsset(filePath); } else { Debug.LogError("AssetAddressUtil::CreateGroupAsset->Dir not found"); } }
protected override void OnPreRender(EventArgs e) { base.OnPreRender(e); CssClass += " cancel command"; if (string.IsNullOrEmpty(NavigateUrl)) { var page = Page as EditPage; if (page != null) { Engine = page.Engine; Selection = page.Selection; } NavigateUrl = CancelUrl(); } }
private void NotifyEditing(IEngine engine, HttpContextWrapper context) { var selection = new SelectionUtility(context, engine); if (Convert.ToBoolean(context.Request["changes"])) { engine.AddActivity(new ManagementActivity { Operation = "Edit", PerformedBy = context.User.Identity.Name, ID = selection.SelectedItem.ID, Path = selection.SelectedItem.Path }); } var activities = ManagementActivity.GetActivity(engine, selection.SelectedItem); context.Response.ContentType = "application/json"; context.Response.Write(ManagementActivity.ToJson(activities)); }
protected override void Render(HtmlTextWriter writer) { if (RequiredPermission == Permission.None) RequiredPermission = Page.GetType().GetCustomAttributes(typeof(IPermittable), true).OfType<IPermittable>() .Select(p => PermissionMap.GetMaximumPermission(p.RequiredPermission)) .OrderByDescending(rp => rp) .FirstOrDefault(); var item = new SelectionUtility(this, Page.GetEngine()).SelectedItem; if (!Page.GetEngine().SecurityManager.IsAuthorized(Page.User, item, RequiredPermission)) { cv.IsValid = false; cv.RenderControl(writer); } else base.Render(writer); }
public static void DeleteSelection(CommandExecuteContext context) { var session = Application.AuthoringProject?.Session; var worldManager = session.GetManager <IWorldManager>(); var m_EntityManager = worldManager.EntityManager; var m_SceneManager = session.GetManager <IEditorSceneManagerInternal>(); var selection = SelectionUtility.GetEntityGuidSelection(); foreach (var group in selection.Select(worldManager.GetEntityFromGuid).GroupBy(e => m_EntityManager.GetSharedComponentData <SceneGuid>(e))) { var graph = m_SceneManager.GetGraphForScene(group.Key); foreach (var node in group.Select(graph.FindNode)) { graph.Delete(node); } } }
public static Vector2 CenterCamera(float tempX, float tempY) { if (SelectionUtility.HasMemberSelected()) { Vector2 centerOfScreen = new Vector2(1366 / 2 - SelectionUtility.primarySelectedCharacter.proximityIndicator.Width / 2, 768 / 2 - SelectionUtility.primarySelectedCharacter.proximityIndicator.Height / 2); int x = (int)(SelectionUtility.primarySelectedCharacter.position.X + SceneUtility.xAxis - centerOfScreen.X); int y = (int)(SelectionUtility.primarySelectedCharacter.position.Y + SceneUtility.yAxis - centerOfScreen.Y); SceneUtility.xAxis -= x; SceneUtility.yAxis -= y; tempX = SceneUtility.xAxis; tempY = SceneUtility.yAxis; return(new Vector2(tempX, tempY)); } return(new Vector2(tempX, tempY)); }
private void NotifyViewing(IEngine engine, HttpContextWrapper context) { var selection = new SelectionUtility(context, engine); if (selection.SelectedItem != null) { engine.AddActivity(new ManagementActivity { Operation = "View", PerformedBy = context.User.Identity.Name, ID = selection.SelectedItem.ID, Path = selection.SelectedItem.Path }); } context.Response.WriteJson(new { Messages = engine.Resolve <ManagementMessageCollector>() .GetMessages(CollaborationContext.Create(engine.Resolve <IProfileRepository>(), selection.SelectedItem, context)) .ToList() }); }
public void Handle(HttpContextBase context) { string tagName = context.Request["tagName"]; string term = context.Request["term"]; var selection = new SelectionUtility(context.Request, engine); var startPage = engine.Content.Traverse.ClosestStartPage(selection.SelectedItem); var allTags = engine.Resolve <CacheWrapper>() .GetOrCreate <IEnumerable <string> >("Tags" + startPage, () => tags.FindTags(startPage, tagName)); var json = allTags .Where(t => t.StartsWith(term, StringComparison.InvariantCultureIgnoreCase)) .Select(t => new { label = t }) .ToJson(); context.Response.ContentType = "application/json"; context.Response.Write(json); }
protected virtual Node <TreeNode> CreateContent(HttpContextBase context, SelectionUtility selection) { var filter = engine.EditManager.GetEditorFilter(context.User); var structure = new BranchHierarchyBuilder(selection.SelectedItem, selection.Traverse.RootPage, true) { UseMasterVersion = false } .Children((item) => { var q = new N2.Persistence.Sources.Query { Parent = item, OnlyPages = true, Interface = Interfaces.Managing, Filter = filter }; return(engine.GetContentAdapter <NodeAdapter>(item).GetChildren(q)); }) .Build(); return(CreateStructure(structure, filter)); }
public static AnimationClip[] ExtractClipsFromFBX() { GameObject[] gameObjects = Selection.GetFiltered <GameObject>(SelectionMode.Assets); if (gameObjects == null || gameObjects.Length == 0) { return(null); } var clips = (from go in gameObjects let assetPath = AssetDatabase.GetAssetPath(go) where Path.GetExtension(assetPath).ToLower() == ".fbx" let extractClips = AnimationClipExtract.ExtractClipFromFBX(assetPath, null) from clip in extractClips select clip).ToList(); SelectionUtility.ActiveObjects(clips.ToArray()); return(clips.ToArray()); }
protected override void OnDrawRowItem(Rect rect, GridViewData itemData) { AssetDependency adData = itemData.GetData <AssetDependency>(); if (adData == null) { EditorGUI.LabelField(rect, "The data is null"); return; } Rect iconRect = new Rect(rect.x, rect.y, rect.height, rect.height); UnityObject assetObj = adData.cachedUObject; if (assetObj == null) { assetObj = AssetDatabase.LoadAssetAtPath(adData.assetPath, typeof(UnityObject)); adData.cachedUObject = assetObj; } Texture2D previewIcon = adData.cachedPreview; if (previewIcon == null) { previewIcon = EGUIResources.GetAssetPreview(assetObj); adData.cachedPreview = previewIcon; } GUI.DrawTexture(iconRect, previewIcon, ScaleMode.ScaleAndCrop); if (Event.current.type == EventType.MouseUp && iconRect.Contains(Event.current.mousePosition)) { SelectionUtility.PingObject(assetObj); } Rect labelRect = new Rect(iconRect.x + iconRect.width, iconRect.y, rect.width - iconRect.width, iconRect.height); EditorGUI.LabelField(labelRect, adData.assetPath, EGUIStyles.MiddleLeftLabelStyle); if (assetObj is Texture) { Rect memorySizeRect = new Rect(rect.x + rect.width - 60, rect.y, 60, rect.height); long memorySize = AssetDatabaseUtility.GetTextureStorageSize(assetObj as Texture); EditorGUI.LabelField(memorySizeRect, EditorUtility.FormatBytes(memorySize)); } }
private void NotifyEditing(IEngine engine, HttpContextWrapper context) { var selection = new SelectionUtility(context, engine); if (Convert.ToBoolean(context.Request["changes"])) { engine.AddActivity(new ManagementActivity { Operation = "Edit", PerformedBy = context.User.Identity.Name, ID = selection.SelectedItem.ID, Path = selection.SelectedItem.Path }); } var activities = ManagementActivity.GetActivity(engine, selection.SelectedItem); var messages = engine.Resolve <N2.Edit.Collaboration.ManagementMessageCollector>() .GetMessages(CollaborationContext.Create(engine.Resolve <IProfileRepository>(), selection.SelectedItem, context)) .ToList(); context.Response.ContentType = "application/json"; context.Response.Write(ManagementActivity.ToJson(activities, messages)); }
protected override ListItem[] GetListItems() { ParameterCollection query = new ParameterCollection(); if (!ShowUnpublish) { query &= Parameter.Equal("State", ContentState.Published); } if (ListItemsBelowCurrentStartPageOnly) { var selection = new SelectionUtility(HttpContext.Current, Engine); ContentItem item = selection.SelectedItem; var startPage = Find.ClosestOf <IStartPage>(item); query &= Parameter.Below(startPage); } if (LinkedType != null && LinkedType != typeof(ContentItem)) { query &= Parameter.TypeEqual(LinkedType); } if (ExcludedType != null) { query &= Parameter.TypeNotIn(Engine.Definitions.GetDefinitions().Where(d => ExcludedType.IsAssignableFrom(d.ItemType)).Select(d => d.Discriminator).ToArray()); } if (!Is(EditableItemSelectionFilter.Pages)) { query &= Parameter.IsNotNull("ZoneName"); } if (!Is(EditableItemSelectionFilter.Parts)) { query &= Parameter.IsNull("ZoneName"); } var items = Engine.Content.Search.Repository.Select(query, "ID", "Title"); return(items.Select(row => new ListItem((string)row["Title"], row["ID"].ToString())) .ToArray()); }
public static void CreateGroupAsset() { string dirPath = SelectionUtility.GetSelectionDir(); if (!string.IsNullOrEmpty(dirPath)) { string filePath = $"{dirPath}/asset_group.asset"; filePath = AssetDatabase.GenerateUniqueAssetPath(filePath); var config = ScriptableObject.CreateInstance <AssetGroupCreater>(); config.RootFolder = dirPath; EditorUtility.SetDirty(config); AssetDatabase.CreateAsset(config, filePath); AssetDatabase.ImportAsset(filePath); } else { Debug.LogError("AssetMenuItems::CreateGroupAsset->The dir is not found"); } }
public object Notes(HttpContextBase context, int?skip, int?take) { var item = new SelectionUtility(context, engine).ParseSelectionFromRequest(); if (item != null) { return(new { Notes = item["CollaborationNote"] != null ? new[] { item["CollaborationNote"] } : new object[0] }); } else { var items = engine.Persister.Repository.Find(Parameter.IsNotNull("CollaborationNote").Detail().Skip(skip ?? 0).Take(take ?? 1000)); return(new { AnnotatedItems = items.Select(ci => new { ci.ID, ci.Title, ci.Url, ci.IconUrl, ci.IconClass, Notes = new [] { ci["CollaborationNote"] } }).ToList() }); } }
public override void ProcessRequest(HttpContext context) { string target = context.Request["target"] ?? Targets.Preview; var selection = new SelectionUtility(context.Request, N2.Context.Current); ContentItem selectedItem = selection.SelectedItem; context.Response.ContentType = "text/plain"; ItemFilter filter = Engine.EditManager.GetEditorFilter(context.User); IContentAdapterProvider adapters = Engine.Resolve<IContentAdapterProvider>(); var node = new TreeHierarchyBuilder(selectedItem, 2) .Children((item) => adapters.ResolveAdapter<NodeAdapter>(item).GetChildren(item, Interfaces.Managing)) .Build(); string selectableTypes = context.Request["selectableTypes"]; string selectableExtensions = context.Request["selectableExtensions"]; TreeUtility.Write(node, selectedItem, adapters, filter, selectableTypes, selectableExtensions, excludeRoot: true, target: target, writer: context.Response.Output); }
public override void ProcessRequest(HttpContext context) { string target = context.Request["target"] ?? Targets.Preview; var selection = new SelectionUtility(context.Request, N2.Context.Current); ContentItem selectedItem = selection.SelectedItem; context.Response.ContentType = "text/plain"; ItemFilter filter = Engine.EditManager.GetEditorFilter(context.User); IContentAdapterProvider adapters = Engine.Resolve <IContentAdapterProvider>(); var node = new TreeHierarchyBuilder(selectedItem, 2) .Children((item) => adapters.ResolveAdapter <NodeAdapter>(item).GetChildren(item, Interfaces.Managing)) .Build(); string selectableTypes = context.Request["selectableTypes"]; string selectableExtensions = context.Request["selectableExtensions"]; TreeUtility.Write(node, selectedItem, adapters, filter, selectableTypes, selectableExtensions, excludeRoot: true, target: target, writer: context.Response.Output); }
public override void ProcessRequest(HttpContext context) { string target = context.Request["target"] ?? Targets.Preview; var selection = new SelectionUtility(context.Request, N2.Context.Current); ContentItem selectedNode = selection.SelectedItem; context.Response.ContentType = "text/plain"; ItemFilter filter = Engine.EditManager.GetEditorFilter(context.User); IContentAdapterProvider adapters = Engine.Resolve<IContentAdapterProvider>(); var root = new TreeHierarchyBuilder(selectedNode, 2) .Children((item) => adapters.ResolveAdapter<NodeAdapter>(item).GetChildren(item, Interfaces.Managing)) .Build(); TreeNode tn = (TreeNode)new N2.Web.Tree(root) .LinkProvider(node => Web.UI.Controls.Tree.BuildLink(adapters.ResolveAdapter<NodeAdapter>(node), node, node.Path == selectedNode.Path, target)) .Filters(filter) .ToControl(); Web.UI.Controls.Tree.AppendExpanderNodeRecursive(tn, filter, target, adapters); RenderControls(tn.Controls, context.Response.Output); }