private static void Register(UTinyEntityView view)
 {
     if (ActiveViews.Add(view) && ActiveViews.Count == 1)
     {
         Undo.postprocessModifications += HandlePostProcessModification;
     }
 }
Example #2
0
        private void ActiveViews_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            switch (e.Action)
            {
            case NotifyCollectionChangedAction.Add:
                ActiveViews.Add(e.NewItems[0].ToString());
                break;

            case NotifyCollectionChangedAction.Remove:
                ActiveViews.Remove(e.OldItems[0].ToString());
                break;

            case NotifyCollectionChangedAction.Replace:
                break;

            case NotifyCollectionChangedAction.Move:
                break;

            case NotifyCollectionChangedAction.Reset:
                ActiveViews.Clear();
                foreach (var view in region.ActiveViews)
                {
                    ActiveViews.Add(view.ToString());
                }
                break;

            default:
                break;
            }

            RemoveActiveViewCommand.RaiseCanExecuteChanged();

            SelectedViewName = ActiveViews.FirstOrDefault();
        }
Example #3
0
 public void RemoveAllViews()
 {
     foreach (IView view in Views)
     {
         Deactivate(view);
         ActiveViews.Remove(view);
         Views.Remove(view);
     }
 }
Example #4
0
        /// <summary>
        /// Marks the specified view as active.
        /// </summary>
        /// <param name="view">The view to activate.</param>
        /// <remarks>If there is an active view before calling this method,
        /// that view will be deactivated automatically.</remarks>
        public override void Activate(object view)
        {
            object currentActiveView = ActiveViews.FirstOrDefault();

            if (currentActiveView != null && currentActiveView != view && this.Views.Contains(currentActiveView))
            {
                base.Deactivate(currentActiveView);
            }
            base.Activate(view);
        }
Example #5
0
        /// <summary>
        /// Marks the specified view as active.
        /// </summary>
        /// <param name="view">The view to activate.</param>
        /// <remarks>If there is an active view before calling this method,
        /// that view will be deactivated automatically.</remarks>
        public override void Activate(VisualElement view)
        {
            var currentActiveView = ActiveViews.FirstOrDefault();

            if (currentActiveView != null && currentActiveView != view && Views.Contains(currentActiveView))
            {
                base.Deactivate(currentActiveView);
            }

            base.Activate(view);
        }
Example #6
0
        /// <summary>
        /// Marks the specified view as inactive.
        /// </summary>
        /// <param name="view">The view to deactivate.</param>
        public virtual void Deactivate(IView view)
        {
            if (view == null)
            {
                throw new ArgumentNullException(Resources.ViewShouldNotBeNull);
            }

            if (GetView(view.Name) == null)
            {
                throw new ArgumentException(Resources.ViewNotInRegionException);
            }

            ActiveViews.Remove(view);
        }
        private static void Unregister(UTinyEntityView view)
        {
            if (!ActiveViews.Remove(view))
            {
                return;
            }

            if (ActiveViews.Count == 0)
            {
                Undo.postprocessModifications -= HandlePostProcessModification;
            }

            // From this point, we know that the entity view is being destroyed. What we do not know is if the view is
            // being destroyed because we are unloading the scene or if the user deleted the entity through the hierarchy
            // or the scene view.
            var entity = view.EntityRef.Dereference(Registry);

            if (entity?.EntityGroup == null)
            {
                return;
            }

            var entityGroupRef = (UTinyEntityGroup.Reference)entity.EntityGroup;

            if (UnloadingEntityGroups.Contains(entityGroupRef))
            {
                return;
            }

            entity.View = null;

            var graph = EntityGroupManager.GetSceneGraph(entityGroupRef);

            if (null == graph)
            {
                return;
            }

            graph.Delete(graph.FindNode(view.EntityRef));
            UTinyHierarchyWindow.InvalidateSceneGraph();
        }
Example #8
0
 /// <summary>
 /// Removes the specified view from the region.
 /// </summary>
 /// <param name="view">The view to remove.</param>
 public virtual void Remove(IView view)
 {
     this.ItemMetadataCollection.Remove(view);
     ActiveViews.Remove(view);
     Views.Remove(view);
 }
Example #9
0
 public static void AddActiveView(IHotReloadableView view) => ActiveViews.Add(view);