public SimpleInfoOverlayModel(
            ViewerSdk.IVRViewerSdk viewerSdk,
            CoreSdk.ModelManager modelManager)
            : base(modelManager)
        {
            this.runningSince = DateTime.UtcNow;
            this.viewerSdk    = viewerSdk;

            // We will use monospaced font, 32 pixels high.
            this.fontFace = new CoreSdk.FontFace("Courier New", height: 32);

            // Tell Core SDK in which pass and stage we want to render.
            this.Subscribe(
                CoreSdk.PassSubscription.Overlay,
                CoreSdk.StageSubscription.Text);

            var currentProject = viewerSdk.ProjectManager.CurrentProject;

            // As rendering happens in a separate thread and viewer is not thread-safe,
            // it is recommended to cache any viewer SDK variable locally for later use in the Render method.
            this.ProjectName     = currentProject.Name;
            this.ProjectFileName = currentProject.FileName;

            // Register our model for rendering.
            this.Setup();
        }
Exemple #2
0
        public CountdownModel(
            CoreSdk.ModelManager modelManager,
            int startingNumber,
            string finalMessage)
            : base(modelManager)
        {
            const double messageOverlapDurationInSeconds = 1.3;
            const double numberMessageDurationInSeconds  = 1 + messageOverlapDurationInSeconds;

            this.messages = new MessageInfo[startingNumber + 1];

            for (int n = startingNumber, i = 0; n > 0; --n, ++i)
            {
                var m = new MessageInfo
                {
                    Text      = n.ToString(),
                    StartTime = TimeSpan.FromSeconds(
                        i * (numberMessageDurationInSeconds - messageOverlapDurationInSeconds)),
                    Duration = TimeSpan.FromSeconds(numberMessageDurationInSeconds),
                    Color    = Color.Crimson,
                };

                this.messages[i] = m;
            }
            var finalMessageInfo = new MessageInfo
            {
                Text      = finalMessage,
                StartTime = TimeSpan.FromSeconds(
                    startingNumber * (numberMessageDurationInSeconds - messageOverlapDurationInSeconds)),
                Duration = TimeSpan.FromSeconds(3),
                Color    = Color.Lime,
            };

            this.messages[this.messages.Length - 1] = finalMessageInfo;

            this.animDuration
                = this.messages.Max(m => m.EndTime)
                  - this.messages.Min(m => m.StartTime)
                  + TimeSpan.FromSeconds(3); // 3 silent seconds in the end.

            // We will use proportional font, 512 pixels high - big enough to
            // look good even in full-screen.
            this.fontFace = new CoreSdk.FontFace("Times New Roman", height: 512);

            this.Subscribe(
                CoreSdk.PassSubscription.Overlay,
                CoreSdk.StageSubscription.Text);
            this.Setup();
        }