Пример #1
0
 public void P2PClientDataReceived(byte[] data, int receiveBytesNum)
 {
     if (receiveBytesNum < RemotePointer.PackageLength)
     {
         return;
     }
     StringBuilder sb = new StringBuilder();
     sb.Append(Encoding.UTF8.GetString(data, 0, receiveBytesNum));
     string dataStr = sb.ToString();
     if (dataStr.IndexOf("\n") < RemotePointer.PackageLength - 1)
     {
         return;
     }
     byte[] validDataChunk = new byte[RemotePointer.PackageLength];
     Array.Copy(data,dataStr.IndexOf("\n") - (RemotePointer.PackageLength - 1), validDataChunk, 0, RemotePointer.PackageLength);
     RemotePointer remotePointer = new RemotePointer();
     remotePointer.Parse(validDataChunk);
     if (!remotePointerList.ContainsKey(remotePointer.Id))
     {
         if (remotePointer.X >= 0 && remotePointer.X <= 1
             && remotePointer.Y >= 0 && remotePointer.Y <= 1)
         {
             remotePointer.IsActive = true;
             remotePointerList.Add(remotePointer.Id, remotePointer);
             if (pointerEventListener != null)
             {
                 pointerEventListener.NewPointerAddedEvent(remotePointer,pointerColors[nextColorIndex]);
                 nextColorIndex = (nextColorIndex + 1)%pointerColors.Length;
             }
         }
     }
     else
     {
         if (remotePointer.X >= 0 && remotePointer.X <= 1
             && remotePointer.Y >= 0 && remotePointer.Y <= 1)
         {
             remotePointer.IsActive = true;
             remotePointerList[remotePointer.Id] = remotePointer;
             if (pointerEventListener != null)
             {
                 pointerEventListener.PointerUpdatedEvent(remotePointer);
             }
         }
         else
         {
             remotePointer.IsActive = false;
             remotePointerList[remotePointer.Id] = remotePointer;
             if (pointerEventListener != null)
             {
                 pointerEventListener.PointerUpdatedEvent(remotePointer);
             }
         }
     }
 }
Пример #2
0
        public void NewPointerAddedEvent(RemotePointer addedPointer, string assignedColorCode)
        {
            this.Dispatcher.Invoke(new Action(() =>
            {
                try
                {
                    ScatterViewItem pointerContainer = new ScatterViewItem();
                    pointerContainer.ApplyTemplate();
                    RemotePointerUI pointerUI = new RemotePointerUI();
                    pointerUI.PointerID = addedPointer.Id;
                    pointerUI.setPointerColor(assignedColorCode);
                    pointerUI.Width = pointerUI.Height = 50;
                    pointerContainer.Width = pointerUI.Width;
                    pointerContainer.Height = pointerUI.Height;
                    //disable surrounding shadow
                    pointerContainer.Background = null;
                    pointerContainer.BorderThickness = new Thickness(0);
                    pointerContainer.ShowsActivationEffects = false;
                    //SurfaceShadowChrome ssc = pointerContainer.Template.FindName("shadow", pointerContainer) as SurfaceShadowChrome;
                    //ssc.Visibility = Visibility.Collapsed;
                    //add to the canvas and adjust location
                    pointerContainer.Content = pointerUI;
                    pointerContainer.Tag = addedPointer;
                    sv_RemotePointerCanvas.Items.Add(pointerContainer);
                    int X = (int)(addedPointer.X * canvasesContainer.Width);
                    int Y = (int)(addedPointer.Y * canvasesContainer.Height);
                    pointerContainer.Center = new System.Windows.Point(X, Y);
                    sv_RemotePointerCanvas.UpdateLayout();

                    Utilities.BrainstormingEventLogger.GetInstance(dropboxGeneralNoteDownloader.Storage).UploadLogString(Utilities.BrainstormingEventLogger.getLogStr_RemotePointerAdded(addedPointer));
                }
                catch (Exception ex)
                {
                    Utilities.UtilitiesLib.LogError(ex);
                }
            }));
        }
Пример #3
0
 public void PointerUpdatedEvent(RemotePointer updatedPointer)
 {
     this.Dispatcher.Invoke(new Action(() =>
     {
         try
         {
             ScatterViewItem pointerContainer = findViewItemWithPointerID(updatedPointer.Id);
             if (pointerContainer == null)
             {
                 return;
             }
             if (!updatedPointer.IsActive)
             {
                 //make pointer fade out
                 DoubleAnimation anim = new DoubleAnimation(0, TimeSpan.FromSeconds(2));
                 pointerContainer.BeginAnimation(UserControl.OpacityProperty, anim);
                 //pointerContainer.Visibility = System.Windows.Visibility.Hidden;
                 sv_RemotePointerCanvas.UpdateLayout();
                 pointerContainer.Tag = updatedPointer;
                 Utilities.BrainstormingEventLogger.GetInstance(dropboxGeneralNoteDownloader.Storage).UploadLogString(Utilities.BrainstormingEventLogger.getLogStr_RemotePointerLeft(updatedPointer));
             }
             else
             {
                 //make pointer fade in
                 if (!((RemotePointer)pointerContainer.Tag).IsActive)
                 {
                     DoubleAnimation anim = new DoubleAnimation(1, TimeSpan.FromSeconds(0.2));
                     pointerContainer.BeginAnimation(UserControl.OpacityProperty, anim);
                     Utilities.BrainstormingEventLogger.GetInstance(dropboxGeneralNoteDownloader.Storage).UploadLogString(Utilities.BrainstormingEventLogger.getLogStr_RemotePointerReentered(updatedPointer));
                 }
                 //update location
                 int X = (int)(updatedPointer.X * canvasesContainer.Width);
                 int Y = (int)(updatedPointer.Y * canvasesContainer.Height);
                 pointerContainer.Center = new System.Windows.Point(X, Y);
                 if (((RemotePointer)pointerContainer.Tag).IsActive)
                 {
                     Utilities.BrainstormingEventLogger.GetInstance(dropboxGeneralNoteDownloader.Storage).UploadLogString(Utilities.BrainstormingEventLogger.getLogStr_RemotePointerMoved(updatedPointer));
                 }
                 pointerContainer.Tag = updatedPointer;
                 sv_RemotePointerCanvas.UpdateLayout();
             }
         }
         catch (Exception ex)
         {
             Utilities.UtilitiesLib.LogError(ex);
         }
     }));
 }
Пример #4
0
 public static string getLogStr_RemotePointerReentered(RemotePointer pointer)
 {
     string logStr = "";
     string addedTime = DateTime.Now.ToString("HH:mm:ss.ff");
     string id = pointer.Id.ToString();
     string objectType = "Pointer";
     string commandType = "Reentered";
     logStr = string.Format("{0};{1};{2};{3};{4};{5}", addedTime, id, objectType, commandType, pointer.X, pointer.Y);
     return logStr;
 }