Inheritance: Caliburn.Micro.PropertyChangedBase
Exemplo n.º 1
0
 private void ClientsUpdated(object sender, ImbClientStatus e) {
     CheckShare();
 }
Exemplo n.º 2
0
 private void ImbClientRemoved(object sender, ImbClientStatus e)
 {            
     
     e.IsFollowingMyMap = false;
 }
Exemplo n.º 3
0
 public void SendElementImage(ImbClientStatus client, FrameworkElement element)
 {
     if (element != null)
     {
         var imgEncoder = new PngBitmapEncoder();
         RenderTargetBitmap bmpSource = new RenderTargetBitmap((int)element.ActualWidth, (int)element.ActualHeight, 96, 96, PixelFormats.Pbgra32);
         bmpSource.Render(element);
         imgEncoder.Frames.Add(BitmapFrame.Create(bmpSource));
         MemoryStream ms = new MemoryStream();
         imgEncoder.Save(ms);               
         client.Media.SignalBuffer(0, ms.GetBuffer());                
     }
 }
Exemplo n.º 4
0
        private void Imb_ClientRemoved(object sender, ImbClientStatus e) {
            CheckShare();
            //if (_fe.AllowStream)
            //{
            //  if (AppState.Imb.ScreenshotReceivingClients.Count == 1 &&
            //    AppState.Imb.ScreenshotReceivingClients.Contains(e))
            //  {

            //  }
            //}
        }
Exemplo n.º 5
0
 public void SendImage(ImbClientStatus client, string file)
 {
     if (File.Exists(file))
     {
         BitmapSource bs = new BitmapImage(new Uri(file,UriKind.RelativeOrAbsolute));
         SendImage(client,bs);
     }
 }
Exemplo n.º 6
0
        public void SendImage(ImbClientStatus client, BitmapSource image)
        {
            if (image == null || client == null) return;
            var imgEncoder = new PngBitmapEncoder();
            imgEncoder.Frames.Add(BitmapFrame.Create(image));
            MemoryStream ms = new MemoryStream();
            imgEncoder.Save(ms);
            client.Media.SignalBuffer(0, ms.GetBuffer());      

        }
Exemplo n.º 7
0
        private void ParseClient(string aVarName, string value)
        {
            var id = Int32.Parse(aVarName.Split('.')[0]);

            if (id == Id) return;

            if (value == "")
            {
                if (!clients.ContainsKey(id)) return;
                if (clients[id].Client)
                {
                    clients[id].Media.UnPublish();
                    clients[id].Commands.UnPublish();
                }
                Execute.OnUIThread(() =>
                {
                    OnClientRemoved(id);
                    Clients.Remove(id);
                    AllClients.Remove(AllClients.FirstOrDefault(k => k.Id == id));
                        
                });

                // First call OnClientRemoved before you remove the client. Otherwise you will generate an exception.
            }
            else
            {
                if (clients.ContainsKey(id))
                {
                    clients[id].FromString(value);
                    OnClientChanged(clients[id]);
                }
                else
                {
                    var st = new ImbClientStatus();
                    st.FromString(value);
                    if (!string.Equals(st.Application, Status.Application, StringComparison.CurrentCultureIgnoreCase) 
                        && !string.Equals(st.Application, "*")
                        && !string.Equals(Status.Application, "*")) return;
                    if (st.Client)
                    {
                        st.Media = Imb.Publish(st.Id + ".Media");
                        st.Commands = Imb.Publish(st.Id + ".Commands");
                        //st.Positions = Imb.Subscribe(st.Id + ".Position");
                        //st.Positions.OnNormalEvent += Positions_OnNormalEvent;
                    }
                    Execute.OnUIThread(() =>
                    {
                        if (!clients.ContainsKey(id))
                        {
                            Clients.Add(id, st);
                            AllClients.Add(st);
                            OnClientAdded(st);
                        }
                        else
                        {
                            AllClients.Remove(AllClients.FirstOrDefault(k => k.Id == id));
                            Clients[id] = st;
                        }
                    });
                }
            }
        }
Exemplo n.º 8
0
 public PositionChangedEventArgs(Position position, ImbClientStatus status)
 {
     ClientStatus = status;
     Position = position;
 }
Exemplo n.º 9
0
 public void TriggerMediaReceived(Media m)
 {
     var cs = new ImbClientStatus();
     if (MediaReceived!=null) MediaReceived(this, new MediaReceivedEventArgs
     {
         Media = m,
         Sender = cs
     });
 }
Exemplo n.º 10
0
 private void CsImbClientAdded(object sender, ImbClientStatus e)
 {
     if (e.Commands != null)
         e.Commands.OnNormalEvent += Commands_OnNormalEvent;
 }
Exemplo n.º 11
0
 public void TriggerMediaReceived(string url, int sender)
 {
     var cs = new ImbClientStatus();
     if (sender != 0) cs = FindClient(sender);
     var m = new Media
     {
         Location = url,
         Sender = sender.ToString(CultureInfo.InvariantCulture)
     };
     if (MediaReceived!=null) MediaReceived(this, new MediaReceivedEventArgs
     {
         Media = m,
         Sender = cs
     });
 }
Exemplo n.º 12
0
        public void Init(string host, int port, string name, int id, string federation, ImbClientStatus clientStatus, string alternativeHost, int alternativePort)
        {
            if (connecting || AppState.IsClosing) return;
            connecting = true;
            ConnectDate = DateTime.Now;
            if (Imb != null)
            {
                Imb.OnDisconnect   -= ImbOnOnDisconnect;
                Imb.OnVariable     -= Imb_OnVariable;
                Imb.OnStatusUpdate -= Imb_OnStatusUpdate;
                ClientAdded        -= CsImbClientAdded;                
            }

            Imb = new TConnection(host, port, name, id, federation);
            Imb.OnDisconnect += ImbOnOnDisconnect;
            
            Status = clientStatus;

            if (!Imb.Connected)
            {
                // try alternative host
                // TODO EV Why was this uncommented?
                //if (alternativeHost != "") Init(alternativeHost, alternativePort, name, id, federation, clientStatus, "", 0);
                connecting = false;
                reconnecting = false;
                return;
            }

            var tries = 0;
            
            while (Imb.ClientHandle == 0 && tries<1000) {Thread.Sleep(5);
                tries += 1;
            }
            reconnecting = false;
            Imb.OnVariable += Imb_OnVariable;
            Imb.OnStatusUpdate += Imb_OnStatusUpdate;
            ot.Interval = 5000;
            ot.Elapsed += (f, b) =>
            {
                try
                {
                    if (Imb.FClient.Connected)
                    {
                        Imb.SignalString(Id + ".online", "");
                    }
                    else if (!reconnecting)
                    {
                        reconnecting = true;
                        Init(host, port, name, id, federation);
                    }
                }
                catch (Exception)
                {
                    reconnecting = true;
                    Init(host, port, name, id, federation);
                }
            };
            ot.Start();
            UpdateStatus();
            if (Status.Client)
            {
                Status.Media = Imb.Subscribe(Id + ".Media");
                Status.Commands = Imb.Subscribe(Id + ".Commands");
                //Status.Positions = Imb.Subscribe(Id + ".Position");

                Status.Media.OnNormalEvent += Media_OnNormalEvent;
                Status.Media.OnBuffer += Media_OnBuffer;
                Status.Commands.OnNormalEvent += Commands_OnNormalEvent;
                //Status.Positions.OnNormalEvent += Positions_OnNormalEvent;
            }

            ClientAdded += CsImbClientAdded;

            if (Connected != null) Connected(this, null);
            connecting = false;
        }
Exemplo n.º 13
0
 void Imb_ClientChanged(object sender, ImbClientStatus e)
 {
    UpdateStatus();
 }
Exemplo n.º 14
0
 private void ImbClientAdded(object sender, ImbClientStatus e)
 {
     if (this.IsRunning)
     {
         AddClient(e);
         
     }
 }
Exemplo n.º 15
0
 private void OnClientAdded(ImbClientStatus st)
 {
     var handler = ClientAdded;
     if (handler != null) handler(this, st);
 }
Exemplo n.º 16
0
 private void AddClient(ImbClientStatus e)
 {
     if (!e.Client) return;
     AppState.TriggerNotification(e.Name + " is now online",image:e.Image);            
 }
Exemplo n.º 17
0
 void Imb_ClientChanged(object sender, ImbClientStatus e)
 {
     Execute.OnUIThread(UpdateClients);
 }