1

Axiom Tab Auto Navigate

Good Day All,

I have an Axiom application with multiple tabs.  Is there any way for a script to run that cycles through displaying each tab at a constant rate? Display tab1, wait 20 seconds, display tab2, wait 20 seconds, and so on.  It would just repeat this continuously.  I have a static display that is not interactive but want to showcase multiple tabs.  Any help would be much appreciated. 

Cheers,

Tim

2 replies

null
    • Digital Marketing Coordinator
    • garrett
    • 2 mths ago
    • Reported - view

    Hey Timothy, 

    I'm guessing by tab you mean Screen? If so I have a solution. 

    To have this work correctly, the script will need to be applied on every tab. 

    using AxiomCore2.Client;
    using AxiomCore2.ControlProperties;
    using AxiomCore2.Controls;
    using AxiomCore2.Data;
    using AxiomCore2.Events;
    using AxiomCore2.Legacy;
    using AxiomCore2.Log;
    using AxiomCore2.Managers;
    using System;
    using System.Collections.Generic;
    using System.IO;
    using System.Linq;
    using System.Collections;
    using System.Drawing;
    
    namespace AxiomScript
    {
      public partial class ScreenScript : IDisposable
      {
        private EventTimer _timer = null;
        private int _initialTime = Convert.ToInt32(TimeSpan.FromSeconds(19).TotalMilliseconds); // Time to wait before first trigger (1 second)
        private int _interval = Convert.ToInt32(TimeSpan.FromSeconds(1).TotalMilliseconds); // Interval for repeating action (5 seconds)
    
        // Axiom references
        public ControlApplication Application { get; } = ControlApplication.Instance;
        public ControlFactoryManager ControlFactory { get; } = ControlFactoryManager.Instance;
        public IDataProvider DataProvider { get; } = DataProviderManager.CreateInstance();
        public ILog Log { get; } = ClientLog.UserScript;
        public NavigationManager Navigation { get; } = NavigationManager.Instance;
        public ControlScreen Screen => _screen;
    
        public void OnScreenVisible()
        {
          if (_timer == null)
          {
            // Initialize the timer to switch screens after an initial delay and every interval
            _timer = new EventTimer(
              callback: TimerCallback,
              dueTime: _initialTime,
              period: _interval);
          }
          else
          {
            // Reset the timer if it already exists
            _timer.Change(dueTime: _initialTime, period: _interval);
          }
        }
    
        public void OnScreenInvisible()
        {
          if (_timer != null)
          {
            // Pause the timer when the screen is invisible
            _timer.Change(dueTime: EventTimer.Infinite, period: EventTimer.Infinite);
          }
        }
    
        public void Dispose()
        {
          // Dispose of the timer if needed
          _timer?.Dispose();
        }
    
        private void TimerCallback(EventTimer timer, object userData)
        {
          // Switch screens every interval
          SwitchToNextScreen();
        }
    
        public void SwitchToNextScreen()
        {
          int currentScreenIndex = Application.Screens.IndexOf(Application.CurrentScreen);
          int nextScreenIndex = currentScreenIndex + 1;
    
          if (nextScreenIndex >= Application.Screens.Count())
            nextScreenIndex = 0;
    
          ControlScreen nextScreen = Application.Screens[nextScreenIndex] as ControlScreen;
          Application.CurrentScreen = nextScreen;
        }
      }
    }
    

    Let me know if this works !

      • timothy_vertin
      • 2 wk ago
      • Reported - view

       Hey Garrett,

      Thank you for the reply bud.  Worked out great, my application is now cycling through the screens as intended.  Really appreciate it.

      Tim

Content aside

print this pagePrint this page
  • 1 Likes
  • 2 wk agoLast active
  • 2Replies
  • 28Views
  • 2 Following