Example #1
0
 private void Init()
 {
     if (ImbBus != null && ImbBus.Imb != null)
     {
         videoImbChannelOut = ImbBus.Imb.Publish(ChannelName());
         videoImbChannelIn = ImbBus.Imb.Subscribe(ChannelName());
         videoImbChannelIn.OnNormalEvent += videoImbChannelIn_OnNormalEvent;
         ImbBus.ClientAdded += ImbBus_ClientAdded;
         ImbBus.ClientRemoved += ImbBus_ClientRemoved;
         ImbBus.IncomingEventObject += ImbBus_IncomingEventObject;
     }
 }
Example #2
0
 void videoImbChannelIn_OnNormalEvent(TEventEntry aEvent, IMB3.ByteBuffers.TByteBuffer aPayload)
 {
     var cmdLine = aPayload.ReadString();
     var cmdParams = cmdLine.Split(new char[] {'|'}, StringSplitOptions.RemoveEmptyEntries);
     if (cmdParams.Length < 1) return;
     switch (cmdParams[0])
     {
         case "DisplayVideoCmd":
             var cmd = new DisplayVideoCmd(ref cmdParams);
             if (DisplayVideoEvent != null)
                 DisplayVideoEvent(new DisplayVideoCmdEventArgs(cmd));
             break;
     }
 }
Example #3
0
 internal void CopyHandlersFrom(TEventEntry aEventEntry) {
     OnChangeObject     = aEventEntry.OnChangeObject;
     OnFocus            = aEventEntry.OnFocus;
     OnNormalEvent      = aEventEntry.OnNormalEvent;
     OnBuffer           = aEventEntry.OnBuffer;
     OnStreamCreate     = aEventEntry.OnStreamCreate;
     OnStreamEnd        = aEventEntry.OnStreamEnd;
     OnChangeFederation = aEventEntry.OnChangeFederation;
     OnTimerTick        = aEventEntry.OnTimerTick;
     OnTimerCmd         = aEventEntry.OnTimerCmd;
     OnChangeObjectData = aEventEntry.OnChangeObjectData;
     OnOtherEvent       = aEventEntry.OnOtherEvent;
     OnSubAndPub        = aEventEntry.OnSubAndPub;
 }
Example #4
0
        public void ImbSubscribe()
        {
            ImbUnsubscribe();
            if (UsDomainPlugin.Connection.Connected)
            {
                if (UsDomainPlugin == null || UsDomainPlugin.CurrentSession == null || string.IsNullOrWhiteSpace(UsDomainPlugin.CurrentSession.eventName))
                {
                    Debug.WriteLine("Cannot determine current session from USDomain plugin");
                    return;
                }
                _effectsEvent = UsDomainPlugin.Connection.Subscribe(UsDomainPlugin.CurrentSession.eventName + ".Effects", false);
                _effectsEvent.OnNormalEvent += Effects_OnNormalEvent;

                Debug.WriteLine(string.Format("Subscribed to IMB event {0}: {1}", UsDomainPlugin.CurrentSession.eventName + ".Effects", _effectsEvent.ID));
            }
            else
            {
                Debug.WriteLine("USDomain plugin is not connected to IMB");
            }
        }
Example #5
0
 public void ImbUnsubscribe()
 {
     if (_effectsEvent != null)
     {
         _effectsEvent.OnNormalEvent -= Effects_OnNormalEvent;
     }
     _effectsEvent = null;
 }
Example #6
0
        public void Follow2D(long id)
        {
            var old = AppState.Imb.FindClient(Following);
            if (old != null)
            {
                old.IsFollowing = false;
                AppState.Imb.SendCommand(Following, FollowMapOffCommand);
                AppState.TriggerNotification("You stopped following the map of " + old.Name, pathData:MenuHelpers.MapIcon);
            }
            Following = id;
            if (AppState.Imb != null && AppState.Imb.IsConnected)
            {
                if (followMap != null)
                {
                    
                    followMap.ClearAllStreams();
                    followMap.OnNormalEvent -= followMap_OnNormalEvent;    
                    AppState.Imb.Imb.UnSubscribe(followMap.EventName);
                }
                if (id != 0)
                {
                    var c = AppState.Imb.FindClient(id);
                    if (c == null) return;
                    c.IsFollowing = true;
                    followMap = AppState.Imb.Imb.Subscribe(id + ".mapextent");
                    followMap.OnNormalEvent += followMap_OnNormalEvent;
                    AppState.Imb.SendCommand(id, FollowMapOnCommand);
                    AppState.TriggerNotification("You are now following the map of " + c.Name, pathData: MenuHelpers.MapIcon);
                }
                
            }

        }
Example #7
0
        public void Init(GroupLayer gl, MapPoint start, MapPoint finish, ResourceDictionary rd)
        {
            remoteClient.ComputeFieldOfViewAsImageCompleted += ClientOnComputeFieldOfViewCompleted;
            localClient .ComputeFieldOfViewAsImageCompleted += ClientOnComputeFieldOfViewCompleted;

            StartPoint = new csPoint
            {
                Mp = start
            };
            FinishPoint = new csPoint
            {
                Mp = finish
            };
            MLayer = new GraphicsLayer
            {
                ID = Guid.NewGuid().ToString()
            };

            ImageLayer = new ElementLayer();
            Image = new System.Windows.Controls.Image
            {
                HorizontalAlignment = HorizontalAlignment.Stretch,
                VerticalAlignment = VerticalAlignment.Stretch,
                Stretch = Stretch.Fill,
                StretchDirection = StretchDirection.Both
            };
            ElementLayer.SetEnvelope(Image, AppState.ViewDef.MapControl.Extent);
            ImageLayer.Children.Add(Image);

            Start = new Graphic();
            Finish = new Graphic();
            Line = new Graphic();

            var ls = new LineSymbol
            {
                Color = Brushes.Black,
                Width = 4
            };
            Line.Symbol = ls;
            UpdateLine();

            MLayer.Graphics.Add(Line);

            Start.Geometry = start;
            Start.Symbol = rd["Start"] as Symbol;
            Start.Attributes["position"] = start;
            Start.Attributes["finish"] = Finish;
            Start.Attributes["start"] = Start;
            Start.Attributes["line"] = Line;
            Start.Attributes["state"] = "start";
            Start.Attributes["measure"] = this;
            Start.Attributes["menuenabled"] = true;
            MLayer.Graphics.Add(Start);

            Finish.Geometry = finish;
            Finish.Attributes["position"] = finish;
            Finish.Symbol = rd["Finish"] as Symbol;
            Finish.Attributes["finish"] = Finish;
            Finish.Attributes["start"] = Start;
            Finish.Attributes["line"] = Line;
            Finish.Attributes["measure"] = this;
            Finish.Attributes["state"] = "finish";
            Finish.Attributes["menuenabled"] = true;
            MLayer.Graphics.Add(Finish);
            Layer.ChildLayers.Add(ImageLayer);
            Layer.ChildLayers.Add(MLayer);
            MLayer.Initialize();

            AppStateSettings.Instance.ViewDef.MapManipulationDelta += ViewDef_MapManipulationDelta;

            if (AppState.Imb != null && AppState.Imb.Imb != null)
            {
                _3D = AppState.Imb.Imb.Publish(AppState.Imb.Imb.ClientHandle + ".3d");
                //AppState.Imb.Imb.Publish(_channel);
            }

            updateTimer.Interval = 50;
            updateTimer.Elapsed += UpdateTimerElapsed;
            updateTimer.Start();
        }
Example #8
0
 private void Media_OnNormalEvent(TEventEntry aEvent, TByteBuffer aPayload)
 {
     var pl = aPayload.ReadString();
     var m = Media.FromString(pl);
     if (m == null) return;
     if (MediaReceived == null) return;
     var s = FindClient(Convert.ToInt32(m.Sender));
     if (MediaReceived!=null) MediaReceived(this, new MediaReceivedEventArgs
     {
         Media = m,
         Sender = s
     });
 }
Example #9
0
        private void Media_OnBuffer(TEventEntry aEvent, int aTick, int aBufferID, TByteBuffer aBuffer) {
            Execute.OnUIThread(() => {
                using (var stream = new MemoryStream(aBuffer.Buffer)) {
                    var image = new BitmapImage();
                    image.BeginInit();
                    image.StreamSource = stream;
                    image.EndInit();

                    var m = new Media {Image = image};
                    TriggerMediaReceived(m);
                }
            });
        }
Example #10
0
        public void InitImbEvents()
        {
            mapState = AppState.Imb.Imb.Subscribe(AppState.Imb.Id + ".mapstate");

        }
Example #11
0
        public void Init(GroupLayer gl, MapPoint start, MapPoint finish, ResourceDictionary rd)
        {
            startPoint = new csPoint
            {
                Mp = start
            };
            finishPoint = new csPoint
            {
                Mp = finish
            };
            MLayer = new GraphicsLayer
            {
                ID = Guid.NewGuid().ToString()
            };
            _start = new Graphic();
            _finish = new Graphic();
            Line = new Graphic();

            var ls = new LineSymbol
            {
                Color = Brushes.Black,
                Width = 4
            };
            Line.Symbol = ls;
            UpdateLine();

            MLayer.Graphics.Add(Line);

            _start.Geometry = start;
            _start.Symbol = rd["Start"] as Symbol;
            _start.Attributes["position"] = start;
            _start.Attributes["finish"] = _finish;
            _start.Attributes["start"] = _start;
            _start.Attributes["line"] = Line;
            _start.Attributes["state"] = "start";
            _start.Attributes["measure"] = this;
            _start.Attributes["menuenabled"] = true;
            MLayer.Graphics.Add(_start);

            _finish.Geometry = finish;
            _finish.Attributes["position"] = finish;
            _finish.Symbol = rd["Finish"] as Symbol;
            _finish.Attributes["finish"] = _finish;
            _finish.Attributes["start"] = _start;
            _finish.Attributes["line"] = Line;
            _finish.Attributes["measure"] = this;
            _finish.Attributes["state"] = "finish";
            _finish.Attributes["menuenabled"] = true;
            MLayer.Graphics.Add(_finish);

            Layer.ChildLayers.Add(MLayer);
            MLayer.Initialize();

            AppStateSettings.Instance.ViewDef.MapManipulationDelta += ViewDef_MapManipulationDelta;

            if (AppState.Imb != null && AppState.Imb.Imb != null)
            {
                _3d = AppState.Imb.Imb.Publish(AppState.Imb.Imb.ClientHandle + ".3d");
                //AppState.Imb.Imb.Publish(_channel);
            }

            _updateTimer.Interval = 50;
            _updateTimer.Elapsed += UpdateTimerElapsed;
            _updateTimer.Start();
        }
Example #12
0
        public void StopImb()
        {
            Debug.Assert(commandChannel != null, "Already deinitialized" );

            foreach (var l in Layers)
            {
                var s = (PoiService)AppState.DataServer.Services.FirstOrDefault(k => k.Id == l);
                if (s != null && s.Layer != null) s.Layer.Stop();
            }

            AppState.ViewDef.MapControl.ExtentChanged             -= MapControl_ExtentChanged;
            AppState.ViewDef.MapControl.PreviewMouseRightButtonUp -= MapControl_PreviewMouseRightButtonUp;
            if (commandChannel != null)
            {
                commandChannel.OnNormalEvent -= CommandChannelOnNormalEvent;
                commandChannel.UnSubscribe();
                commandChannel = null;
            }
            Clients.Remove(AppState.Imb.Imb.ClientHandle);
            UpdateGroup();  
            
        }
Example #13
0
        void CommandChannelOnNormalEvent(TEventEntry aEvent, IMB3.ByteBuffers.TByteBuffer aPayload)
        {
            var l  = aPayload.ReadString();
            var ss = l.Split('|');
            switch (ss[0])
            {
                case "point":
                    Execute.OnUIThread(() =>
                    {
                        var xp = Convert.ToDouble(ss[1], CultureInfo.InvariantCulture);
                        var yp = Convert.ToDouble(ss[2], CultureInfo.InvariantCulture);
                        var c = AppState.Imb.FindClient(long.Parse(ss[3]));
                        if (c != null)
                        {
                            var nea = new NotificationEventArgs()
                            {
                                Duration   = TimeSpan.FromSeconds(5),
                                Options    = new List<string> { "Zoom to" },
                                PathData   = MenuHelpers.PointerIcon,
                                Header     = "Pointer triggered by " + c.Name,
                                Background = AppState.AccentBrush,
                                Foreground = System.Windows.Media.Brushes.Black,

                            };

                            nea.OptionClicked += (e, f) => AppState.ViewDef.ZoomAndPoint(new Point(yp, xp), false);

                            AppState.TriggerNotification(nea);
                        }

                        AppState.ViewDef.AddGeoPointer(new GeoPointerArgs() { Position = new MapPoint(yp, xp), Duration = TimeSpan.FromSeconds(2) });
                    });
                    break;
                case "map":
                    if (!string.Equals(l, lastMapEvent) && FollowMap)
                    {
                        lastMapEvent = l;

                        var x = Convert.ToDouble(ss[1], CultureInfo.InvariantCulture);
                        var y = Convert.ToDouble(ss[2], CultureInfo.InvariantCulture);
                        var r = Convert.ToDouble(ss[3], CultureInfo.InvariantCulture);

                        Execute.OnUIThread(delegate
                        {
                            var w = (AppState.ViewDef.MapControl.ActualWidth / 2) * r;
                            var h = (AppState.ViewDef.MapControl.ActualHeight / 2) * r;
                            var env = new Envelope(x - w, y - h, x + w, y + h);
                            AppState.ViewDef.MapControl.Extent = env;
                        });
                        skipNext = true;
                    }
                    break;
            }
        }
Example #14
0
        public void InitImb()
        {
            Debug.Assert(commandChannel == null, "Already initialized");
            commandChannel = AppState.Imb.Imb.Subscribe(CommandsChannelName, true);

            commandChannel.OnNormalEvent                          += CommandChannelOnNormalEvent;
            AppState.ViewDef.MapControl.ExtentChanged             += MapControl_ExtentChanged;
            AppState.ViewDef.MapControl.PreviewTouchDown          += MapControl_PreviewTouchDown;
            AppState.ViewDef.MapControl.PreviewMouseRightButtonUp += MapControl_PreviewMouseRightButtonUp;

            Clients.Add(AppState.Imb.Imb.ClientHandle);
            UpdateGroup();

        }
Example #15
0
 /// <summary>
 ///  Initialize imb connection
 /// </summary>
 private void InitImb() {
     id = client.Id;
     foreach (var v in client.Variables)
     {
         ProcessReceivedImbBusVariable(v.Key, v.Value);
     }
     client.Imb.OnVariable += Imb_OnVariable;
     privateChannel = client.Imb.Subscribe(client.Id + ServiceChannelExtentions);
     privateChannel.OnBuffer += ReceivedPrivateMessage;
 }
Example #16
0
 private void _cameraStream_OnBuffer(TEventEntry aEvent, int aTick, int aBufferId, TByteBuffer aBuffer)
 {
     rsv.Dispatcher.Invoke(delegate
     {
         //string fotoStr = aPayload.ReadString();
         byte[] fotoBa = aBuffer.Buffer;
         BitmapImage bmp = GetBitmapImage(fotoBa);
         wb = new WriteableBitmap(bmp);
         rsv.bs.Source = wb;
         rsv.bs.InvalidateVisual();
         rsv.inkStrokes.Width = wb.Width;
         rsv.inkStrokes.Height = wb.Height;
     });
 }
Example #17
0
        //        public void AddLocalDataServiceTemplate(string folder, string file) {
        //            var idName = Path.GetFileNameWithoutExtension(file); 
        //            var guid = Guid.NewGuid();
        //            if (string.IsNullOrEmpty(idName)) return;
        //            var ps = new PoiService {
        //                IsLocal = true,
        //                Folder = folder,
        //                Id = guid,
        //                Name = idName,
        //                IsTemplate = true,
        //                StaticService = false,
        //                RelativeFolder = folder.Replace(baseFolder, string.Empty)
        //            };
        //            ps.InitPoiService();
        //            Templates.Add(ps);
        //            //CheckSettings(ps);
        //        }
        //
        //        public PoiService AddLocalDataServiceFromCsv(string folder, Mode _mode, string file, string originFolder = "",
        //            bool autoStart = false)
        //        {
        //            PoiServiceImporterFromFileList poiServiceImporterFromFileList = PoiServiceImporterFromFileList.Instance;
        //            IImporter<FileLocation, PoiService> suitableImporter = poiServiceImporterFromFileList.FirstOrDefault(importer => importer.DataFormatExtension.Equals("csv"));
        //
        //            if (suitableImporter == null)
        //            {
        //                throw new NotImplementedException("Cannot find an importer for CSV files in the assembly.");
        //            }
        //
        //            IOResult<PoiService> ioResult = suitableImporter.ImportData(new FileLocation(Path.Combine(folder, file)));
        //            if (ioResult.Successful)
        //            {
        //                return ioResult.Result;
        //            }
        //            else
        //            {
        //                throw ioResult.Exception;
        //            }
        //        }

        //private static void CheckSettings(Service ps) {
        //    if (ps.SettingsList != null) return;
        //    ps.SettingsList = ps.CreateContentList("settings", typeof(ServiceSettings));
        //    ps.SettingsList.Add(new ServiceSettings());
        //    ps.AllContent.Remove(ps.AllContent.FirstOrDefault(c => string.Equals(ps.SettingsList.Id, c.Id, StringComparison.InvariantCultureIgnoreCase)));
        //    ps.AllContent.Add(ps.SettingsList);
        //}

        /// <summary>
        ///     received message on private channel
        /// </summary>
        private void ReceivedPrivateMessage(TEventEntry aEvent, int aTick, int aBufferId, TByteBuffer aBuffer){ // REVIEW TODO fix: removed async
            var pm = PrivateMessage.ConvertByteArrayToMessage(aBuffer.Buffer);
            if (pm == null)
            {
                LogCs.LogWarning(String.Format("Received IMB message: Corrupt message! ", pm.Id, pm.Action));
                return;
            }
            var s = Services.FirstOrDefault(k => k.Id == pm.Id);
            if (s == null)
            {
                LogCs.LogWarning(String.Format("Received IMB message: Service with GUID '{0}' is not found in servicelist (msg action is {1}). Ignore message. ",
                        pm.Id, pm.Action));
                return;
            }
            var reqClient = AppState.Imb.FindClient(pm.Sender);
            switch (pm.Action) {
                case PrivateMessageActions.RequestData:
                    SendData(pm.Sender, s, pm.ContentId, pm.OwnerId, pm.Channel);
                    break;
                case PrivateMessageActions.ResponseData:
                    if ((s.store.SaveBytes(s.Folder, pm.ContentId, pm.Content, false))) // REVIEW TODO fix: removed await
                        s.DataReceived(pm.ContentId, pm.Content);
                    break;
                case PrivateMessageActions.SubscribeRequest:
                    // TODO EV Why do you set server initialization to false? When adding a task, it is not synchronized anymore (RegisterContent is cancelled).
                    //s.IsInitialized = false;
                    if (!s.Subscribers.Contains(pm.Sender)) s.Subscribers.Add(pm.Sender);
                    LogImbService.LogMessage(String.Format("Received IMB message: IMB client with handle {0} ({1}) requested to subscribe (join) service '{2}' ({3}) (add to service).",
                          pm.Sender, (reqClient != null) ? reqClient.Name : "-", s.Name, pm.Id));
                    SendToImbBusSubscriptedToService(s.Id, pm.Sender);
                    LogImbService.LogMessage(String.Format("IMB handles subscribed (joined) to service {0}: {1}", s.Name, s.SubscribedImbClientHandles));

                    if (reqClient != null && (AppState.Imb.ActiveGroup == null || !AppState.Imb.ActiveGroup.Clients.Contains(reqClient.Id)))
                        Execute.OnUIThread(
                            () => AppState.TriggerNotification(reqClient.Name + " has joined " + s.Name, image: reqClient.Image));
                    break;
                case PrivateMessageActions.UnsubscribeRequest:
                    //s.IsInitialized = false;
                    if (s.Subscribers.Contains(pm.Sender)) s.Subscribers.Remove(pm.Sender);
                    SendPrivateMessage(pm.Sender, PrivateMessageActions.Unsubscribe, s.Id);
                    var unsubClient = AppState.Imb.FindClient(pm.Sender);
                    if (unsubClient != null) Execute.OnUIThread(() => AppState.TriggerNotification(unsubClient.Name + " has left " + s.Name, image: unsubClient.Image));
                    LogImbService.LogMessage(String.Format("Received IMB message: IMB client {0} requested to unsubscribe (unjoin) to service '{1}'({2}) (joined service).",
                       AppState.Imb.ImbClientHandleToName(pm.Sender), s.Name, pm.Id));
                    LogImbService.LogMessage(String.Format("IMB handles subscribed (joined) to service '{0}'({1}): {2}", s.Name, s.Id, s.SubscribedImbClientHandles));
                    break;
                case PrivateMessageActions.ServiceReset: // requested for service reset
                    int priority = 2;
                    int.TryParse(pm.Channel, out priority);
                    SendServiceReset(pm.Sender, s.Id, priority);
                    //var resx = s.ToXml().ToString();
                    //SendPrivateMessage(pm.Sender,PrivateMessageActions.ResponseXml,s.Id,resx,Guid.Empty);
                    break;
                case PrivateMessageActions.RequestXml:
                    var res = s.ToXml().ToString();
                    SendPrivateMessage(pm.Sender, PrivateMessageActions.ResponseXml, s.Id, res, Guid.Empty);
                    break;
                case PrivateMessageActions.ResponseXml:
                    LogImbService.LogMessage(String.Format("Received IMB message: Recieved service XML definition for service {0} ({1}), Load XML into service.",
                         s.Name, s.Id));
                    LogImbService.ToFile(String.Format("./logging/ReceivedServiceDefinition_{0}_{1}_{2}", s.Name, s.Id, DateTime.Now.Ticks), pm.ContentId);
                    s.FromXml(pm.ContentId, s.Folder);
                    s.TriggerInitialized();
                    break;
                case PrivateMessageActions.Subscribe:
                    LogImbService.LogMessage(String.Format("Received IMB message: Subscribe request to subscribe to (join) service '{0}'({1}) acknowledged (mode={2})", s.Name, s.Id, mode));
                    s.Subscribe(mode);
                    s.SubscribeServiceChannel();
                    //Subscribe(s);
                    if (Subscribed != null) Subscribed(this, new ServiceSubscribeEventArgs { Service = s });
                    var npm = new PrivateMessage {
                        Action = PrivateMessageActions.ServiceReset,
                        Id = s.Id,
                        Sender = client.Id,
                        Channel = SyncPriority.ToString()
                    };
                    SendPrivateMessage(pm.Sender, npm);
                    break;
                case PrivateMessageActions.Unsubscribe:
                    s.Unsubscribe();
                    s.UnSubscribeServiceChannel();
                    if (UnSubscribed != null) UnSubscribed(this, new ServiceSubscribeEventArgs { Service = s });
                    break;
                case PrivateMessageActions.ListReset: // receiving lists from server
                    ListReset(s.Id, pm.Content, pm.Channel);
                    if (pm.ContentId == "First")
                    {
                        count = 0;
                    }
                    count += pm.Content.Length;
                    if (pm.ContentId == "Last")
                    {
                        var l = count;
                        LogImbService.LogMessage(String.Format("Received last content for Service {0}", s.Id));
                        s.TriggerInitialized();
                    }
                    LogImbService.LogMessage(String.Format("Received the content #{4} of service '{0}'({1}) from IMB client {2} (channel='{3}') (ListReset action).",
                        s.Name, s.Id, AppState.Imb.ImbClientHandleToName(pm.Sender), pm.Channel, count));
                    break;
                case PrivateMessageActions.SendData:
                    
                    var f = s.Folder + @"\_Media\" + pm.ContentId;
                    LogImbService.LogMessage(String.Format("IMB Message SendData received; store {0} bytes to location '{1}'", pm.Content.Length, f));
                    s.store.SaveBytes(f, pm.Content);
                    break;
            }
        }
Example #18
0
 private void _screenshot_OnBuffer(TEventEntry aEvent, int aTick, int aBufferId, TByteBuffer aBuffer)
 {
     rsv.Dispatcher.Invoke(
         delegate
         {
             //rsv.bs.Source = GetBitmapImage(aBuffer.Buffer);
             //Console.WriteLine(rsv.bs.Source.ToString());
             var bsSrc =  GetImageFromJpegByteArray(aBuffer.Buffer);
             if(bsSrc != null)
                 rsv.bs.Source = bsSrc;
             //rsv.bs.Source = GetImageFromByteArray(aBuffer.Buffer, Client.ResolutionY / Client.Quality,Client.ResolutionX / Client.Quality);
         });
 }
Example #19
0
 private void Positions_OnNormalEvent(TEventEntry aEvent, TByteBuffer aPayload)
 {
     var d = aPayload.ReadString();
     var s = aEvent.EventName.Split('.');
     if (s.Length != 3) return;
     var cl = Clients.FirstOrDefault(k => k.Key == Int32.Parse(s[1]));
     cl.Value.UpdatePosition(d);
 }
Example #20
0
        public void Unsubscribe()
        {
  
            if (_screenshot != null)
            {
                AppState.Imb.Imb.UnSubscribe(Client.Id + ".Screenshot");
                _screenshot = null;
            }

            if (_cameraStream != null)
            {
                AppState.Imb.Imb.UnSubscribe(Client.Id + ".CameraStream");
                _cameraStream = null;
            }
        }
Example #21
0
 private void Commands_OnNormalEvent(TEventEntry aEvent, TByteBuffer aPayload)
 {
     var c = Command.FromString(aPayload.ReadString());
     if (CommandReceived != null) CommandReceived(this, c);
 }
Example #22
0
        public void Subscribe()
        {
          

            _screenshot = AppState.Imb.Imb.Subscribe(Client.Id + ".Screenshot");
            _screenshot.OnBuffer += _screenshot_OnBuffer;

            if (Client.Type == "Phone")
            {
                _cameraStream = AppState.Imb.Imb.Subscribe(Client.Id + ".CameraStream");
                _cameraStream.OnBuffer += _cameraStream_OnBuffer;
                _strokeStream = AppState.Imb.Imb.Subscribe(Client.Id + ".StrokeStream");
                _strokeStream.OnNormalEvent += _strokeStream_OnNormalEvent;
                _cameraStream.OnStreamCreate += _cameraStream_OnStreamCreate;
                _cameraStream.OnStreamEnd += _cameraStream_OnStreamEnd;
            }
        }
Example #23
0
        public void Init()
        {
            AppState.ShareContracts.Add(new SendToContract());

            if (AppState.Imb.Enabled)
            {
                AppState.Imb.ClientAdded += ImbClientAdded;
                AppState.Imb.ClientRemoved += ImbClientRemoved;
                AppState.Imb.AllClients.CollectionChanged -= AllClients_CollectionChanged;
                AppState.Imb.AllClients.CollectionChanged += AllClients_CollectionChanged;
                AppState.Imb.Imb.OnVariable += Imb_OnVariable;
                AppState.Imb.CommandReceived += Imb_CommandReceived;
                fastMapChangeChannel = AppState.Imb.Imb.Publish(AppState.Imb.Id + ".fastmapextent");
                fastMapInterval = AppState.Config.GetInt("Map.FastMapUpdateInterval", 200);
                AppState.Imb.Status.AddCapability("receivescreenshot");

                AppState.ViewDef.VisibleChanged += ViewDefVisibleChanged;
                AppState.ViewDef.MapManipulationDelta += ViewDefMapManipulationDelta;


                foreach (var c in AppState.Imb.Clients) AddClient(c.Value);
                if (AppState.ViewDef.MapControl != null)
                {
                    AppState.ViewDef.MapControl.ExtentChanged += MapControlExtentChanged;
                    AppState.ViewDef.MapControl.ExtentChanging += MapControlExtentChanging;
                }

                var viewModel = new ContactsViewModel() {Plugin = this};

                spti = new StartPanelTabItem
                {
                    ModelInstance = viewModel,
                    Position = StartPanelPosition.left,
                    HeaderStyle = TabHeaderStyle.Image,
                    Name = "Contacts",
                    
                    Image = new BitmapImage(new Uri(@"pack://application:,,,/csCommon;component/Resources/Icons/person.png", UriKind.RelativeOrAbsolute))
                };

                //AppState.ConfigTabs.Add(new EsriMapSettingsViewModel() { DisplayName = "Map" });

            }

        }
Example #24
0
 void _cameraStream_OnStreamEnd(TEventEntry aEvent, ref Stream aStream, string aStreamName)
 {
     // Create image from stream
     long strLen = aStream.Length;
 }
Example #25
0
 void followMap_OnNormalEvent(TEventEntry aEvent, IMB3.ByteBuffers.TByteBuffer aPayload)
 {
     var s = aPayload.ReadString();
     var ss = s.Split('|');
     double xmin = Convert.ToDouble(ss[0], CultureInfo.InvariantCulture);
     double ymin = Convert.ToDouble(ss[1], CultureInfo.InvariantCulture);
     double xmax = Convert.ToDouble(ss[2], CultureInfo.InvariantCulture);
     double ymax = Convert.ToDouble(ss[3], CultureInfo.InvariantCulture);
     Execute.OnUIThread(delegate
                            {
                                AppState.ViewDef.MapControl.Extent = new Envelope(xmin, ymin, xmax, ymax);    
                            });
     
 
     
 }  
Example #26
0
 Stream _cameraStream_OnStreamCreate(TEventEntry aEvent, string aStreamName)
 {
     //throw new NotImplementedException();
     strm = new MemoryStream();
     return strm;
 }
Example #27
0
        private void Effects_OnNormalEvent(TEventEntry aevent, TByteBuffer apayload)
        {
            Execute.OnUIThread(() =>
            {
                int command = -1;
                string strJson = "";

                apayload.Read(out command);
                apayload.Read(out strJson);

                //                Debug.WriteLine("NormalEvent received from IMB: [id:{0}, command:{1}]:\n{2}", aevent.ID, command, strJson);
                Debug.WriteLine("NormalEvent received from IMB: [id:{0}, command:{1}]:\n{2} bytes", this.GetHashCode(), command, strJson.Length);
                if (!string.IsNullOrWhiteSpace(strJson))
                {
                    //todo: fixed in new effects binary, this replace WILL produce problems and MUST be removed:
                    strJson = strJson.Replace("NAN", "NaN");
                    var body = JObject.Parse(strJson);
                    Guid id;

                    switch (command)
                    {
                        case 1102:
                            Debug.WriteLine("ImbEvent hash: {0}", this.GetHashCode());
                            SetModelData(body["Models"] as JArray);
                            break;
                        case 1104:
                            var reply = body["ParametersReply"];
                            id = (Guid)reply["ID"];
                            SetModelPropertyData(id, reply["Parameters"] as JArray);
                            break;
                        case 1106:
                            var result = body["Result"];
                            id = (Guid)result["ID"];
                            SetCalculatedData(id, result["Parameters"] as JArray);
                            break;
                        case 1108:
                            //SetUnitsData
                            break;
                        case 1110:
                            SetChemicalsData(body["ChemicalNames"] as JArray);
                            break;
                    }
                }
            });
        }
Example #28
0
        void _strokeStream_OnNormalEvent(TEventEntry aEvent, TByteBuffer aPayload)
        {
            rsv.Dispatcher.Invoke(
                delegate
                {   
                    string strokesStr = aPayload.ReadString();
                    if (String.IsNullOrEmpty(strokesStr))
                        return;
                    if (strokesStr == "clear")
                    {
                        _strokes = new Dictionary<string, Stroke>();
                        rsv.inkStrokes.Strokes.Clear();
                        rsv.inkStrokes.InvalidateVisual();
                        rsv.gMain.InvalidateVisual();
                        return;
                    }
                    string[] strokesArr = strokesStr.Split(';');
                    _strokes = new Dictionary<string, Stroke>();
                    rsv.inkStrokes.Strokes.Clear();
                    foreach (string strokeStr in strokesArr)
                    {
                        string[] strokeDef = strokeStr.Split('/');
                        if (strokeDef.Length != 2)
                            break;
                        string guid = strokeDef[0];
                        if (_strokes.ContainsKey(guid))
                            continue;
                            
                        string[] pointsArr = strokeDef[1].Split('|');
                        StylusPointCollection points = new StylusPointCollection();
                        try
                        {
                            foreach (string pointStr in pointsArr)
                            {

                                string[] pointParts = pointStr.Split(',');

                                if (pointParts.Length == 2 && wb != null)
                                {
                                    StylusPoint point = new StylusPoint(wb.Width / 640d * double.Parse(pointParts[1]), wb.Height - (wb.Height / 480d * double.Parse(pointParts[0])));
                                    //StylusPoint point = new StylusPoint(double.Parse(pointParts[1]), wb.Height - double.Parse(pointParts[0]));
                                    points.Add(point);
                                }
                            }
                        }
                        catch (Exception err)
                        {
                            string errMsg = err.Message;
                        }
                        try
                        {
                            Stroke stroke = new Stroke(points);
                            stroke.DrawingAttributes.Color = Colors.Red;
                            stroke.DrawingAttributes.Height = 3;
                            stroke.DrawingAttributes.Width = 3;
                            //rsv.inkStrokes.Width = rsv.bs.ActualWidth;
                            rsv.inkStrokes.Strokes.Add(stroke);
                                
                            _strokes.Add(guid, stroke);
                               
                        }
                        catch { }
                    }
                    rsv.inkStrokes.InvalidateVisual();
                    rsv.gMain.InvalidateVisual();
                });
        }
Example #29
0
 public bool InitChannel()
 {
     if (Screenshot == null)
     {
         if (Imb != null && Imb.IsConnected)
         {
             Screenshot = Imb.Imb.Publish(Imb.Imb.ClientHandle + ".Screenshot");
         }
         else return false;
     }
     return true;
 }
Example #30
0
            //public string EventName[Int32 aEventID]

            public TEventEntry AddEvent(TConnection aConnection, string aEventName) {
                FCount++;
                while (FCount > FEvents.Length) {
                    if (FEvents.Length == 0)
                        Array.Resize(ref FEvents, FInitialSize);
                    else
                        Array.Resize(ref FEvents, FEvents.Length*2);
                }
                FEvents[FCount - 1] = new TEventEntry(aConnection, FCount - 1, aEventName);

                return FEvents[FCount - 1];
            }