AB4D Forum

Full Version: Touch Screen Controls
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
we recently installed a touch screen on the manufacturing floor and i could not understand initially why our application would not register mouse click events.  Until i figured out there is a seperate set of visualevents for this.

I'm not a developer, so I need a little help  i tried to reuse the three visualEventSource3D.MouseEnter,visualEventSource3D.MouseLeave and visualEventSource3D.MouseClick but with visualEventSource3D.TouchEnter, visualEventSource3D.TouchLeave and visualEventSource3D.TouchUp

but i cant get it to work can somebody show me how?

Thanks

Madaxe

Code:
       private void RegisterMouseEventsOnBoxVisual(BoxVisual3D boxVisual3D)
       {
           var visualEventSource3D = new VisualEventSource3D(boxVisual3D);
           visualEventSource3D.MouseEnter += delegate (object sender, Mouse3DEventArgs e)
           {
               ClearMouseOverBoxVisual();

               var hitBoxVisual3D = e.HitObject as BoxVisual3D;

               if (hitBoxVisual3D != null && !ReferenceEquals(hitBoxVisual3D, this._currentlySelectedBoxVisual3D))
               {
                   this._savedMouseOverMaterial = hitBoxVisual3D.Material;

                   hitBoxVisual3D.Material = this._mouseOverBoxMaterial;
                   this._currentMouseOverBoxVisual3D = hitBoxVisual3D;
               }

               Mouse.OverrideCursor = Cursors.Hand;
           };
           visualEventSource3D.MouseLeave += delegate (object sender, Mouse3DEventArgs e)
           {
               var hitBoxVisual3D = e.HitObject as BoxVisual3D;

               if (!ReferenceEquals(hitBoxVisual3D, this._currentlySelectedBoxVisual3D))
                   ClearMouseOverBoxVisual();
               else
                   this._currentMouseOverBoxVisual3D = null;

               Mouse.OverrideCursor = null;
           };
           visualEventSource3D.MouseClick += delegate (object sender, MouseButton3DEventArgs e)
           {
               ClearSelectedBoxVisual();

               var hitBoxVisual3D = e.HitObject as BoxVisual3D;

               if (hitBoxVisual3D != null)
               {
                   hitBoxVisual3D.Material = this._selectedBoxMaterial;
                   this._currentlySelectedBoxVisual3D = hitBoxVisual3D;

                   if (boxVisual3D.Tag is SlatModel)
                   {
                       LekoSticker.Visibility = Visibility.Visible;
                       this._MFGValidationImp.UpDateSticker((SlatModel)boxVisual3D.Tag);
                       this._MFGValidationImp.ValidateGeometry((SlatModel)boxVisual3D.Tag);
                   }
                   
                   Camera1.RotationCenterPosition = hitBoxVisual3D.CenterPosition;
               }
           };

           visualEventSource3D.TouchEnter += delegate (object sender, Touch3DEventArgs e)
           {
               ClearMouseOverBoxVisual();

               var hitBoxVisual3D = e.HitObject as BoxVisual3D;

               if (hitBoxVisual3D != null && !ReferenceEquals(hitBoxVisual3D, this._currentlySelectedBoxVisual3D))
               {
                   this._savedMouseOverMaterial = hitBoxVisual3D.Material;

                   hitBoxVisual3D.Material = this._mouseOverBoxMaterial;
                   this._currentMouseOverBoxVisual3D = hitBoxVisual3D;
               }

               Mouse.OverrideCursor = Cursors.Hand;
           };
           visualEventSource3D.TouchLeave += delegate (object sender, Touch3DEventArgs e)
           {
               var hitBoxVisual3D = e.HitObject as BoxVisual3D;

               if (!ReferenceEquals(hitBoxVisual3D, this._currentlySelectedBoxVisual3D))
                   ClearMouseOverBoxVisual();
               else
                   this._currentMouseOverBoxVisual3D = null;

               Mouse.OverrideCursor = null;
           };
           visualEventSource3D.TouchUp += delegate (object sender, Touch3DEventArgs e)
           {
               ClearSelectedBoxVisual();

               var hitBoxVisual3D = e.HitObject as BoxVisual3D;

               if (hitBoxVisual3D != null)
               {
                   hitBoxVisual3D.Material = this._selectedBoxMaterial;
                   this._currentlySelectedBoxVisual3D = hitBoxVisual3D;

                   if (boxVisual3D.Tag is SlatModel)
                   {
                       LekoSticker.Visibility = Visibility.Visible;
                       this._MFGValidationImp.UpDateSticker((SlatModel)boxVisual3D.Tag);
                       this._MFGValidationImp.ValidateGeometry((SlatModel)boxVisual3D.Tag);
                   }

                   Camera1.RotationCenterPosition = hitBoxVisual3D.CenterPosition;
               }
           };

           this._EventManager3D.RegisterEventSource3D(visualEventSource3D);
       }