Inheritance: Caliburn.Micro.PropertyChangedBase
示例#1
0
 private void ClientsUpdated(object sender, ImbClientStatus e) {
     CheckShare();
 }
示例#2
0
 private void ImbClientRemoved(object sender, ImbClientStatus e)
 {            
     
     e.IsFollowingMyMap = false;
 }
示例#3
0
文件: csImb.cs 项目: TNOCS/csTouch
 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());                
     }
 }
示例#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))
            //  {

            //  }
            //}
        }
示例#5
0
文件: csImb.cs 项目: TNOCS/csTouch
 public void SendImage(ImbClientStatus client, string file)
 {
     if (File.Exists(file))
     {
         BitmapSource bs = new BitmapImage(new Uri(file,UriKind.RelativeOrAbsolute));
         SendImage(client,bs);
     }
 }
示例#6
0
文件: csImb.cs 项目: TNOCS/csTouch
        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());      

        }
示例#7
0
文件: csImb.cs 项目: TNOCS/csTouch
        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;
                        }
                    });
                }
            }
        }
示例#8
0
 public PositionChangedEventArgs(Position position, ImbClientStatus status)
 {
     ClientStatus = status;
     Position = position;
 }
示例#9
0
文件: csImb.cs 项目: TNOCS/csTouch
 public void TriggerMediaReceived(Media m)
 {
     var cs = new ImbClientStatus();
     if (MediaReceived!=null) MediaReceived(this, new MediaReceivedEventArgs
     {
         Media = m,
         Sender = cs
     });
 }
示例#10
0
文件: csImb.cs 项目: TNOCS/csTouch
 private void CsImbClientAdded(object sender, ImbClientStatus e)
 {
     if (e.Commands != null)
         e.Commands.OnNormalEvent += Commands_OnNormalEvent;
 }
示例#11
0
文件: csImb.cs 项目: TNOCS/csTouch
 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
     });
 }
示例#12
0
文件: csImb.cs 项目: TNOCS/csTouch
        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;
        }
示例#13
0
 void Imb_ClientChanged(object sender, ImbClientStatus e)
 {
    UpdateStatus();
 }
示例#14
0
 private void ImbClientAdded(object sender, ImbClientStatus e)
 {
     if (this.IsRunning)
     {
         AddClient(e);
         
     }
 }
示例#15
0
文件: csImb.cs 项目: TNOCS/csTouch
 private void OnClientAdded(ImbClientStatus st)
 {
     var handler = ClientAdded;
     if (handler != null) handler(this, st);
 }
示例#16
0
 private void AddClient(ImbClientStatus e)
 {
     if (!e.Client) return;
     AppState.TriggerNotification(e.Name + " is now online",image:e.Image);            
 }
示例#17
0
 void Imb_ClientChanged(object sender, ImbClientStatus e)
 {
     Execute.OnUIThread(UpdateClients);
 }