private static void LogActiveTimeline <T>(ActiveTimeline <T> active, Guid timelineGuid, string message)
            where T : DependencyObject
        {
            var builder = new StringBuilder();

            builder.AppendLine();
            builder.AppendLine("---------- ACTIVE TIMELINE --------");
            builder.AppendLine($"Guid {timelineGuid} - {message} at {DateTimeOffset.Now.ToString("HH:mm:ss:fffff")}");
            builder.AppendLine("------------------------------------");

            Logger?.LogDebug(builder.ToString());
        }
예제 #2
0
        /// <summary>
        /// Load an Animation at selected path.
        /// </summary>
        /// <param name="AnimationPath">Path from which to open the Animation.</param>
        private void LoadAnimation(string AnimationPath)
        {
            string Name = AnimationPath.Substring(0, AnimationPath.Length - 4).Substring(19);

            this.Text = Name + " - Project Eternity Animation Editor";

            AnimationViewer.Preload();

            ActiveAnimation         = new AnimationClassEditor(Name);
            ActiveAnimation.Content = new ContentManager(AnimationViewer.Services);
            ActiveAnimation.Content.RootDirectory = "Content";
            AnimationViewer.ActiveAnimation       = ActiveAnimation;

            AnimationViewer.Services.AddService <GraphicsDevice>(AnimationViewer.GraphicsDevice);
            ActiveAnimation.Load();

            PropertiesDialog.txtScreenWidth.Value  = ActiveAnimation.ScreenWidth;
            PropertiesDialog.txtScreenHeight.Value = ActiveAnimation.ScreenHeight;

            PropertiesDialog.txtLoopStart.Value = ActiveAnimation.LoopStart;
            PropertiesDialog.txtLoopEnd.Value   = ActiveAnimation.LoopEnd;

            foreach (KeyValuePair <string, Timeline> ActiveTimeline in ActiveAnimation.DicTimeline)
            {
                if (ActiveTimeline.Value is AnimationOriginTimeline)
                {
                    continue;
                }

                if (ActiveTimeline.Value is VisibleTimeline)
                {
                    ActiveTimeline.Value.OnAnimationEditorLoad(ActiveAnimation);
                    ToolStripMenuItem tsmNewItem = new ToolStripMenuItem(ActiveTimeline.Value.TimelineEventType);
                    tsmNewItem.Tag    = ActiveTimeline.Value;
                    tsmNewItem.Click += AnimationViewer.tsmNewItem_Click;
                    AnimationViewer.spawnNewToolStripMenuItem.DropDownItems.Add(tsmNewItem);
                }
            }

            for (int L = 0; L < AnimationViewer.ActiveAnimation.ListAnimationLayer.BasicLayerCount; L++)
            {
                foreach (var ActiveTimelineFrame in AnimationViewer.ActiveAnimation.ListAnimationLayer[L].DicTimelineEvent.Values)
                {
                    foreach (var ActiveTimeline in ActiveTimelineFrame)
                    {
                        ActiveTimeline.OnAnimationEditorLoad(ActiveAnimation);
                    }
                }
            }

            panTimelineViewer.SetActiveAnimation(ActiveAnimation);
        }
        internal static void SetAnimationState <T>(this ActiveTimeline <T> active, Guid timelineGuid, AnimationState state)
            where T : DependencyObject
        {
            if (active != null)
            {
                active.State = state;
            }

            if (Animations.EnableActiveTimelinesLogging == LogLevel.Debug)
            {
                LogActiveTimeline(active, timelineGuid, $"Updated state to: {state}");
            }
        }
        internal static ActiveTimeline <T> Add <T>(
            this ConcurrentDictionary <Guid, ActiveTimeline <T> > actives,
            T timeline, AnimationSettings settings,
            FrameworkElement element,
            AnimationState state,
            IterationBehavior iterationBehavior,
            int iterationCount,
            bool isSequence,
            int sequenceOrder = 0)
            where T : DependencyObject
        {
            var elementGuid  = Animations.GetElementGuid(element);
            var timelineGuid = Guid.NewGuid();

            if (elementGuid.Equals(Guid.Empty))
            {
                elementGuid = Guid.NewGuid();
            }

            Animations.SetElementGuid(element, elementGuid);

            if (timeline != null)
            {
                Animations.SetElementGuid(timeline, elementGuid);
                Animations.SetTimelineGuid(timeline, timelineGuid);
            }

            var active = new ActiveTimeline <T>()
            {
                ElementGuid       = elementGuid,
                Timeline          = timeline,
                Settings          = settings,
                Element           = element,
                State             = state,
                IterationBehavior = iterationBehavior,
                IterationCount    = iterationCount,
                IsSequence        = isSequence,
                SequenceOrder     = sequenceOrder
            };

            if (actives.TryAdd(timelineGuid, active) && Animations.EnableActiveTimelinesLogging == LogLevel.Debug)
            {
                LogActiveTimelines(actives, "Active timeline added");
            }

            return(active);
        }
 private void SetActiveTimelineMentions()
 {
     _activeTimeline = ActiveTimeline.Mentions;
     RaisePropertyChanged("DisplayMentionsTimeline");
     RaisePropertyChanged("DisplayDirectMessages");
     RaisePropertyChanged("DisplayFriendsTimeline");
 }