示例#1
0
        private static int CalcSelectedRowsHashcode()
        {
            var r = 0;

            if (CoreUserPreferences.Instance.InspectEasing)
            {
                r ^= FindMarkerBehind()?.GetHashCode() ?? 0;
            }
            if (Document.Current.Animation.IsCompound)
            {
                foreach (var track in GetSelectedAnimationTracksAndClips())
                {
                    r ^= track.GetHashCode();
                }
            }
            else if (Document.Current.InspectRootNode)
            {
                var rootNode = Document.Current.RootNode;
                r ^= rootNode.GetHashCode();
                foreach (var component in rootNode.Components)
                {
                    r ^= component.GetHashCode();
                }
            }
            else
            {
                foreach (var row in Document.Current.Rows)
                {
                    if (row.Selected)
                    {
                        r ^= row.GetHashCode();
                        var node = row.Components.Get <NodeRow>()?.Node;
                        if (node != null)
                        {
                            foreach (var component in node.Components)
                            {
                                if (ClassAttributes <NodeComponentDontSerializeAttribute> .Get(component.GetType()) != null)
                                {
                                    continue;
                                }
                                r ^= component.GetHashCode();
                            }
                        }
                    }
                }
            }
            return(r);
        }
示例#2
0
        public static Node Perform(Node container, FolderItemLocation location, Type nodeType)
        {
            if (!nodeType.IsSubclassOf(typeof(Node)))
            {
                throw new InvalidOperationException();
            }
            var ctr   = nodeType.GetConstructor(Type.EmptyTypes);
            var node  = (Node)ctr.Invoke(new object[] { });
            var attrs = ClassAttributes <TangerineNodeBuilderAttribute> .Get(nodeType);

            if (attrs?.MethodName != null)
            {
                var builder = nodeType.GetMethod(attrs.MethodName, BindingFlags.NonPublic | BindingFlags.Instance);
                builder.Invoke(node, new object[] { });
            }
            node.Id = GenerateNodeId(container, nodeType);
            InsertFolderItem.Perform(container, location, node);
            ClearRowSelection.Perform();
            SelectNode.Perform(node);
            Document.Current.Decorate(node);
            return(node);
        }