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
}
}