Пример #1
0
        private void OnFireCommand(object sender, EventArgs e)
        {
            TaggedItem screenItem = (TaggedItem)comboBoxScreens.SelectedItem;
            TaggedItem windowItem = (TaggedItem)comboBoxWindows.SelectedItem;
            //if (screenItem == null || windowItem == null || _selectedView == null || listBox1.SelectedItem==null)
            //{
            //	MessageBox.Show("Please select Screen/Window in above dropdown boxes", "Error");
            //} else
            {
                MultiWindowCommandData data = new MultiWindowCommandData();
                data.Screen             = screenItem != null? screenItem.Item.FQID : null;
                data.Window             = windowItem != null? windowItem.Item.FQID : null;
                data.View               = _selectedView != null? _selectedView.FQID : null;
                data.X                  = 200;
                data.Y                  = 200;
                data.Height             = 400;
                data.Width              = 400;
                data.MultiWindowCommand = (string)listBox1.SelectedItem;
                data.PlaybackSupportedInFloatingWindow = checkBoxPlayback.Checked;

                if (data.MultiWindowCommand == MultiWindowCommand.SetNextViewInWindow ||
                    data.MultiWindowCommand == MultiWindowCommand.SetPreviousViewInWindow)
                {
                    data.MultiWindowCommand = MultiWindowCommand.SelectWindow;
                    EnvironmentManager.Instance.SendMessage(
                        new VideoOS.Platform.Messaging.Message(MessageId.SmartClient.MultiWindowCommand, data));
                    data.MultiWindowCommand = (string)listBox1.SelectedItem;
                }
                EnvironmentManager.Instance.SendMessage(
                    new VideoOS.Platform.Messaging.Message(MessageId.SmartClient.MultiWindowCommand, data),
                    null,
                    null);
            }
        }
Пример #2
0
        /// <summary>
        /// Handles messages from the Alarm List.
        /// Creates a new view and displays it in a floating window each time a message is sent from the Alarm List.
        /// </summary>
        /// <param name="message">The message contains a list of alarms.</param>
        /// <param name="destination">Ignored since we want all messages from the Alarm List.</param>
        /// <param name="source">Ignored since we want messages from any Alarm List.</param>
        /// <returns>null - since the Alarm List is indifferent of who listens to its messages.</returns>
        private Object CameraListReceiver(VideoOS.Platform.Messaging.Message message, FQID destination, FQID source)
        {
            List <Alarm> alarms = message.Data as List <Alarm>;

            if (alarms != null)
            {
                int viewNumber = _viewCounter + 1;
                // Make a new Temporary view group
                ConfigItem tempGroupItem = (ConfigItem)ClientControl.Instance.CreateTemporaryGroupItem("Temporary" + viewNumber);
                // Make a group
                ConfigItem groupItem = tempGroupItem.AddChild("DynamicViewGroup" + viewNumber, Kind.View, FolderType.UserDefined);
                // Build a layout with wide ViewItems at the top and buttom, and 5 small ones in the middle
                Rectangle[] rect = new Rectangle[7];
                rect[0] = new Rectangle(000, 000, 999, 399);
                rect[1] = new Rectangle(000, 399, 199, 199);
                rect[2] = new Rectangle(199, 399, 199, 199);
                rect[3] = new Rectangle(399, 399, 199, 199);
                rect[4] = new Rectangle(599, 399, 199, 199);
                rect[5] = new Rectangle(799, 399, 199, 199);
                rect[6] = new Rectangle(000, 599, 999, 399);
                int               capacity          = rect.Length;
                string            viewName          = "DynamicView" + viewNumber;
                ViewAndLayoutItem viewAndLayoutItem = groupItem.AddChild(viewName, Kind.View, FolderType.No) as ViewAndLayoutItem;
                viewAndLayoutItem.Layout = rect;

                // Insert cameras
                int index = 0;
                foreach (Alarm alarm in alarms)
                {
                    // Add camera from the triggering event
                    // Note: EventHeader.Source cannot be null because an alarm must have a source
                    if (index < capacity && alarm.EventHeader?.Source.FQID.Kind == Kind.Camera)
                    {
                        viewAndLayoutItem.InsertBuiltinViewItem(index++,
                                                                ViewAndLayoutItem.CameraBuiltinId,
                                                                new Dictionary <string, string>()
                        {
                            { "CameraId", alarm.EventHeader.Source.FQID.ObjectId.ToString() }
                        });
                    }

                    if (alarm.ReferenceList == null)
                    {
                        continue;
                    }

                    // Add related cameras from the alarm
                    foreach (Reference rel in alarm.ReferenceList)
                    {
                        if (index < capacity && rel.FQID.Kind == Kind.Camera)
                        {
                            viewAndLayoutItem.InsertBuiltinViewItem(index++,
                                                                    ViewAndLayoutItem.CameraBuiltinId,
                                                                    new Dictionary <string, string>()
                            {
                                { "CameraId", rel.FQID.ObjectId.ToString() }
                            });
                        }
                    }
                }

                if (index == 0)
                {
                    // Exit here, since no cameras were found in the alarm list
                    return(null);
                }

                viewAndLayoutItem.Save();
                tempGroupItem.PropertiesModified();

                Item screen = Configuration.Instance.GetItemsByKind(Kind.Screen).FirstOrDefault();
                Item window = Configuration.Instance.GetItemsByKind(Kind.Window).FirstOrDefault();
                Item view   = groupItem.GetChildren().FirstOrDefault(v => v.Name.Equals(viewName));
                if (screen == null || window == null || view == null)
                {
                    return(null);
                }

                // Create floating window
                MultiWindowCommandData data = new MultiWindowCommandData();
                data.Screen             = screen.FQID;
                data.Window             = window.FQID;
                data.View               = view.FQID;
                data.X                  = 200;
                data.Y                  = 200;
                data.Height             = 500;
                data.Width              = 500;
                data.MultiWindowCommand = "OpenFloatingWindow";
                data.PlaybackSupportedInFloatingWindow = true;
                EnvironmentManager.Instance.SendMessage(new VideoOS.Platform.Messaging.Message(MessageId.SmartClient.MultiWindowCommand, data), null, null);
                _viewCounter++;
            }
            return(null);
        }
        /// <summary>
        /// This method is called when the user selects a camera and inserts the selected camera in a floating hotspot window
        /// </summary>
        /// <param name="message"></param>
        /// <param name="dest"></param>
        /// <param name="sender"></param>
        /// <returns></returns>
        private object ViewItemSelected(Message message, FQID dest, FQID sender)
        {
            if (sender != null && _myWindowFQID2 != null && sender.ObjectId == _myWindowFQID2.ObjectId)       // Ignore my own setup messages
            {
                return(null);
            }
            if (_myMessageInProgress)
            {
                return(null);
            }

            if (message.MessageId == MessageId.SmartClient.SelectedCameraChangedIndication)
            {
                FQID cameraFQID = message.RelatedFQID;

                if (_myWindowFQID2 != null)
                {
                    _myMessageInProgress = true;
                    EnvironmentManager.Instance.SendMessage(new Message(MessageId.SmartClient.SetCameraInViewCommand,
                                                                        new SetCameraInViewCommandData()
                    {
                        Index = _top?0:1, CameraFQID = cameraFQID
                    }), _myWindowFQID2);
                    _myMessageInProgress = false;
                    _top = !_top;
                    return(null);
                }

                if (cameraFQID == null)
                {
                    return(null);
                }

                _viewCounter++;
                // Make a new Temporary view group
                ConfigItem tempGroupItem = (ConfigItem)ClientControl.Instance.CreateTemporaryGroupItem("Floating Hotspot");
                // Make a group
                ConfigItem groupItem = tempGroupItem.AddChild("SCHotSpotGroup" + _viewCounter, Kind.View, FolderType.UserDefined);
                // Build a layout with wide ViewItems at the top and buttom, and 5 small ones in the middle
                Rectangle[] rect = new Rectangle[2];
                rect[0] = new Rectangle(000, 000, 999, 499);
                rect[1] = new Rectangle(000, 499, 999, 500);
                string            viewName          = "SCHotSpot" + _viewCounter;
                ViewAndLayoutItem viewAndLayoutItem = (ViewAndLayoutItem)groupItem.AddChild(viewName, Kind.View, FolderType.No);
                viewAndLayoutItem.Layout = rect;
                // Insert cameras
                Dictionary <String, String> cameraViewItemProperties = new Dictionary <string, string>();
                cameraViewItemProperties.Add("CameraId", cameraFQID != null?cameraFQID.ObjectId.ToString():Guid.Empty.ToString());
                viewAndLayoutItem.InsertBuiltinViewItem(0, ViewAndLayoutItem.CameraBuiltinId, cameraViewItemProperties);
                viewAndLayoutItem.Save();
                tempGroupItem.PropertiesModified();
                // Create floating window
                MultiWindowCommandData data    = new MultiWindowCommandData();
                List <Item>            screens = Configuration.Instance.GetItemsByKind(Kind.Screen);
                FQID screenFQID = GetFirstOfKind(screens, Kind.Screen);
                if (screenFQID != null)
                {
                    data.Screen = screenFQID;
                    List <Item> windows    = Configuration.Instance.GetItemsByKind(Kind.Window);
                    FQID        windowFQID = GetFirstOfKind(windows, Kind.Window);
                    if (windowFQID != null)
                    {
                        data.Window = windowFQID;
                        foreach (Item view in groupItem.GetChildren())
                        {
                            if (view.Name.Equals(viewName))
                            {
                                data.View               = view.FQID;
                                data.X                  = 200;
                                data.Y                  = 200;
                                data.Height             = 400;
                                data.Width              = 200;
                                _myMessageInProgress    = true;
                                data.MultiWindowCommand = MultiWindowCommand.OpenFloatingWindow;
                                Collection <object> result = EnvironmentManager.Instance.SendMessage(new VideoOS.Platform.Messaging.Message(MessageId.SmartClient.MultiWindowCommand, data), null, null);
                                if (result != null && result.Count > 0)
                                {
                                    _myWindowFQID2 = result[0] as FQID;                                                 // Save the Window FQID for next updates
                                }
                                _myMessageInProgress = false;
                                return(null);
                            }
                        }
                    }
                }
            }
            return(null);
        }