Playback Tab

Hello,

I have a task to create a Playback View with Cameras and a html page from the web server to display. User login credentials are stored in Options menu. Playback view is constructed using ViewItemUserControl.

Is it possible to access the Options from the Playback View and change Playback view as and when Options are modified?

Please let me know, how I can achieve this.

Thanks

Giridhar

In the Analytics Overlay plugin sample you can see how you can save a property in the Options menu and read it in another part of the plugin.

Hello,

I looked at the example code you mentioned but could not make out much out of that example.

Probably my explanation was vague. Let me try to explain in more details. I am constructing Playback View using ViewItemUserControl.cs. However this ViewItemUserControl is initialized at time of installing the plugin and after that never called. So, if I have to change an URL in that UserControl for a ViewItem, how do I achieve it. Please let me know.

Thanks

Giridhar

I guess your ViewItemUserControl has methods where it uses the URL, instead of hardcoding the URL you can read it from Options, which is what the sample show.

My ViewItemUserControl.Init() function does constructs the url, after that, if the user changes to user credentials from Options menu, how do I make the ViewItemUserControl to use it from Options menu is my question. Please let me know.

The sample “Property” is a better sample because it also shows an event handler so that you can pick up when a user change the options. You can pick up the options setting in ViewItemUserControl.Init()

If your ViewItemUserControl.Init() function does not constructs the url, what does? Without knowing how you use the ViewItemUserControl (or a different control/plugin?) to do the html page, I am unable to help. Please describe where and how the url is set in your code.

namespace XYZ.Client
{
    public partial class XYZViewItemUserControl : ViewItemUserControl
    {
        #region Component private class variables
 
        private CoremoteTacticsViewItemManager _viewItemManager;
        private object _themeChangedReceiver;
        //private object _selectedViewChanged;
        private ViewAndLayoutItem _currentView;
        private GroupBox groupBox2;
        public static Dictionary<String, String> properties5 = new Dictionary<string, string>();
 
        #endregion
 
        #region Component constructors + dispose
 
        public XYZViewItemUserControl(XYZViewItemManager viewItemManager)
        {
            _viewItemManager = viewItemManager;
            InitializeComponent();
        }
 
        private void OnCreateClick(object sender, EventArgs e)
        {
            List<Item> groups = ClientControl.Instance.GetViewGroupItems();
            if (groups.Count < 1)
                throw new MIPException("You do not have access to any groups?");
 
            // Use the first one (Private group)
            ConfigItem topGroupItem = (ConfigItem)groups[0];
 
            ConfigItem groupItem = (ConfigItem)FindName("XYZ", topGroupItem.GetChildren());
            if (groupItem == null)
            {
                // Make a group 
                groupItem = topGroupItem.AddChild("XYZ", Kind.View, FolderType.UserDefined);
            }
            // Figure out a name that does not exist
            for (int ix = 0; ix < groupItem.GetChildren().Count;ix++ )
            {
                groupItem.RemoveChild(groupItem.GetChildren()[ix]);
            }
           
            // Build a layout with one wide ViewItem at top and buttom, and 6 small once in the middle
            Rectangle[] rect = new Rectangle[6];
            rect[0] = new Rectangle(000, 000, 200, 200);
            rect[1] = new Rectangle(200, 000, 200, 200);
            rect[2] = new Rectangle(400, 000, 200, 200);
            rect[3] = new Rectangle(600, 000, 200, 200);
            rect[4] = new Rectangle(800, 000, 200, 200);
            rect[5] = new Rectangle(000, 200, 1000, 800);
            
            
            ViewAndLayoutItem viewAndLayoutItem =
                (ViewAndLayoutItem)groupItem.AddChild("XYZ-Playback", Kind.View, FolderType.No);
            viewAndLayoutItem.Layout = rect;
            viewAndLayoutItem.Properties["Created"] = DateTime.Now.ToLongDateString();
 
            Dictionary<String, String> properties6 = new Dictionary<string, string>();
            properties6.Add("URL", CoremoteTacticsWorkSpacePlugin.PRODUCT_LOGO);
            properties6.Add("Scaling", "0"); // fit in 640x480
            properties6.Add("Addscript", "true");
            properties6.Add("HideNavigationBar", "true");
            viewAndLayoutItem.InsertBuiltinViewItem(0, ViewAndLayoutItem.HTMLBuiltinId, properties6);
 
            Dictionary<String, String> properties1 = new Dictionary<string, string>();
            properties1.Add("CameraId", "");
            viewAndLayoutItem.InsertBuiltinViewItem(1, ViewAndLayoutItem.CameraBuiltinId, properties1);
 
            Dictionary<String, String> properties2 = new Dictionary<string, string>();
            properties2.Add("CameraId", "");
            viewAndLayoutItem.InsertBuiltinViewItem(2, ViewAndLayoutItem.CameraBuiltinId, properties2);
 
            Dictionary<String, String> properties3 = new Dictionary<string, string>();
            properties3.Add("CameraId", "");
            viewAndLayoutItem.InsertBuiltinViewItem(3, ViewAndLayoutItem.CameraBuiltinId, properties3);
 
            Dictionary<String, String> properties4 = new Dictionary<string, string>();
            properties4.Add("CameraId", "");
            viewAndLayoutItem.InsertBuiltinViewItem(4, ViewAndLayoutItem.CameraBuiltinId, properties4);
            
            // Insert a HTML ViewItem at top
            Dictionary<String, String> properties = new Dictionary<string, string>();
            if (XYZWorkSpacePlugin.URL != String.Empty)
            {
                properties5.Add("URL", XYZWorkSpacePlugin.URL);
            }
            else
            {
                properties5.Add("URL", XYZWorkSpacePlugin.DEPLOY_PATH + "\\" + "index.html");
            }
            properties.Add("HideNavigationbar", "true");
            properties.Add("Scaling", "5");					// fit in 800x600
            properties.Add("Addscript", "true");				// In case you need to add script
            viewAndLayoutItem.InsertBuiltinViewItem(5, ViewAndLayoutItem.HTMLBuiltinId, properties);
            viewAndLayoutItem.Save();
            topGroupItem.PropertiesModified();
        }
 
        private Item FindName(String name, List<Item> items)
        {
            foreach (Item item in items)
                if (item.Name == name)
                    return item;
            return null;
        }
        private void SetUpApplicationEventListeners()
        {
            //set up ViewItem event listeners
            _viewItemManager.PropertyChangedEvent += new EventHandler(ViewItemManagerPropertyChangedEvent);
 
        }
 
        private void RemoveApplicationEventListeners()
        {
            //remove ViewItem event listeners
            _viewItemManager.PropertyChangedEvent -= new EventHandler(ViewItemManagerPropertyChangedEvent);
 
            EnvironmentManager.Instance.UnRegisterReceiver(_themeChangedReceiver);
            _themeChangedReceiver = null;
 
            //EnvironmentManager.Instance.UnRegisterReceiver(_selectedViewChanged);
        }
        private object ViewChangedHandler(Message message, FQID s, FQID r)
        {
            _currentView = message.Data as ViewAndLayoutItem;
 
            return null;
        }
        
        public override void Init()
        {
            SetUpApplicationEventListeners();
        }
 
        
        public override void Close()
        {
            RemoveApplicationEventListeners();
        }
 
        #endregion
 
        #region Print method
       
        public override void Print()
        {
            Print("Name of this item", "Some extra information");
        }
 
        #endregion
 
 
        #region Component events
 
        private void ViewItemUserControlMouseClick(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                FireClickEvent();
            }
            else if (e.Button == MouseButtons.Right)
            {
                FireRightClickEvent(e);
            }
        }
 
        private void ViewItemUserControlMouseDoubleClick(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                FireDoubleClickEvent();
            }
        }
 
 
        
        public event EventHandler RightClickEvent;
 
        
        protected virtual void FireRightClickEvent(EventArgs e)
        {
            if (RightClickEvent != null)
            {
                RightClickEvent(this, e);
            }
        }
 
        void ViewItemManagerPropertyChangedEvent(object sender, EventArgs e)
        {
            
        }
 
        private object ThemeChangedIndicationHandler(VideoOS.Platform.Messaging.Message message, FQID destination, FQID source)
        {
            this.Selected = _selected;
            return null;
        }
 
 
        #endregion
 
        #region Component properties
 
        
        public override bool Maximizable
        {
            get { return true; }
        }
 
        
        public override bool Selectable
        {
            get { return true; }
        }
 
        
        public override bool Selected
        {
            get
            {
                return base.Selected;
            }
            set
            {
                base.Selected = value;
                if (value)
                {
                   
                }
                else
                {
                   
                }
            }
        }
 
        #endregion
    }
}

I have pasted the code for ViewItemUserControl. Let me know.

Thanks

Giridhar

The build-in HTML viewitem does not have any refresh method. It is possible you could create your own viewitem and use .NET control.