示例#1
0
 private void PropagateDoubleClick(UISensitiveObject sender, UIMouseEventArgs evtArgs)
 {
     if (this.DoubleClick != null)
     {
         this.DoubleClick(sender, evtArgs);
     }
 }
        /// <summary>
        /// Called when the mouse pointer moved over the range of this dropdown selector.
        /// </summary>
        /// <param name="sender">The sender of the event.</param>
        /// <param name="evtArgs">The details of the event.</param>
        private void OnMouseMove(UISensitiveObject sender, UIMouseEventArgs evtArgs)
        {
            if (this.IsEnabled)
            {
                if (this.currentStatus == Status.DroppedDown || this.currentStatus == Status.Selecting)
                {
                    if (this.currentStatus == Status.DroppedDown ? this.optionListRect.Contains(evtArgs.Position) : true)
                    {
                        /// The pointer is now over the option list part of the dropped down control
                        RCIntVector relativePos = evtArgs.Position - this.optionListRect.Location;
                        this.highlightedIndex = relativePos.Y >= 0 && relativePos.Y < this.optionListRect.Height
                                              ? relativePos.Y / this.normalRect.Height
                                              : -1;
                        if (highlightedIndex == -1)
                        {
                            if (relativePos.Y < 0)
                            {
                                this.highlightedIndex = 0;
                            }
                            else if (relativePos.Y >= this.optionListRect.Height)
                            {
                                this.highlightedIndex = this.optionCount - 1;
                            }
                        }

                        this.currentStatus = Status.Selecting;
                    }
                }
            }
        }
示例#3
0
 /// <summary>
 /// Called after a UISensitiveObject has been attached to the sensitive-tree.
 /// </summary>
 /// <param name="obj">The new object.</param>
 private void ObjectAttached(UISensitiveObject obj)
 {
     if (this.raisingMouseEvents)
     {
         /// Postpone the needed sensor operations
         List <UISensitiveObject> newObjects = new List <UISensitiveObject>();
         obj.WalkSensitiveTreeDFS(ref newObjects);
         foreach (UISensitiveObject newObj in newObjects)
         {
             /// Save the created sensor and indicate that it will have to be registered.
             UIMouseSensor newSensor = newObj.MouseSensor as UIMouseSensor;
             if (newSensor == null)
             {
                 throw new UIException("Incompatible mouse sensor!");
             }
             this.tmpSensors.Add(newSensor);
             this.tmpSensorOperations.Add(true);
         }
     }
     else
     {
         /// Execute the needed sensor operations
         List <UISensitiveObject> newObjects = new List <UISensitiveObject>();
         obj.WalkSensitiveTreeDFS(ref newObjects);
         foreach (UISensitiveObject newObj in newObjects)
         {
             UIMouseSensor newSensor = newObj.MouseSensor as UIMouseSensor;
             if (newSensor == null)
             {
                 throw new UIException("Incompatible mouse sensor!");
             }
             this.allSensors.Add(newSensor);
         }
     }
 }
示例#4
0
 /// <summary>
 /// Called when the selected value on the slider control has been changed.
 /// </summary>
 /// <param name="sender">Reference to the slider control.</param>
 private void OnSelectedValueChanged(UISensitiveObject sender)
 {
     if (this.SelectedValueChanged != null)
     {
         this.SelectedValueChanged(this);
     }
 }
示例#5
0
 private void PropagateButtonUp(UISensitiveObject sender, UIMouseEventArgs evtArgs)
 {
     if (this.ButtonUp != null)
     {
         this.ButtonUp(sender, evtArgs);
     }
 }
示例#6
0
 private void PropagateLeave(UISensitiveObject sender)
 {
     if (this.Leave != null)
     {
         this.Leave(sender);
     }
 }
示例#7
0
 private void PropagateMove(UISensitiveObject sender, UIMouseEventArgs evtArgs)
 {
     if (this.Move != null)
     {
         this.Move(sender, evtArgs);
     }
 }
示例#8
0
 private void PropagateEnter(UISensitiveObject sender)
 {
     if (this.Enter != null)
     {
         this.Enter(sender);
     }
 }
示例#9
0
 private void PropagateWheel(UISensitiveObject sender, UIMouseEventArgs evtArgs)
 {
     if (this.Wheel != null)
     {
         this.Wheel(sender, evtArgs);
     }
 }
示例#10
0
 /// <summary>
 /// Called when the SelectedValue property of the vertical scrollbar has been changed.
 /// </summary>
 /// <param name="sender">Reference to the scrollbar that sent this event.</param>
 private void OnScrollBarValueChanged(UISensitiveObject sender)
 {
     if (!this.internalScrollBarValueChange)
     {
         UIScrollBar senderScrollBar = (UIScrollBar)sender;
         this.firstVisibleIndex = senderScrollBar.SelectedValue;
     }
 }
示例#11
0
 /// <summary>
 /// Called when the mouse pointer has left the range of this dropdown selector.
 /// </summary>
 /// <param name="sender">The sender of the event.</param>
 private void OnMouseLeave(UISensitiveObject sender)
 {
     if (this.IsEnabled)
     {
         if (this.currentStatus == Status.Highlighted)
         {
             this.currentStatus = Status.Normal;
         }
     }
 }
示例#12
0
        /// <summary>
        /// Handler for child range rectangle changed events.
        /// </summary>
        private void ChildRangeRectChangedHdl(UIObject sender, RCIntRectangle prevRange, RCIntRectangle currRange)
        {
            UISensitiveObject sensitiveSender = sender as UISensitiveObject;

            if (sensitiveSender != null)
            {
                /// Invalidate the cached range rectangle.
                sensitiveSender.absSensitiveRangeCache.Invalidate();
            }
        }
示例#13
0
        /// <summary>
        /// Handler for child cloak rectangle changed events.
        /// </summary>
        private void ChildCloakRectChangedHdl(UIObject sender, RCIntRectangle prevCloak, RCIntRectangle currCloak)
        {
            UISensitiveObject sensitiveSender = sender as UISensitiveObject;

            if (sensitiveSender != null)
            {
                /// Invalidate the cached cloak rectangle.
                sensitiveSender.absSensitiveCloakCache.Invalidate();
            }
        }
示例#14
0
        /// <summary>
        /// Called when a mouse button has been pushed over the range of this UISlider.
        /// </summary>
        /// <param name="sender">The sender of the event.</param>
        /// <param name="evtArgs">The details of the event.</param>
        private void OnMouseDown(UISensitiveObject sender, UIMouseEventArgs evtArgs)
        {
            this.lastKnownMousePosition = evtArgs.Position;

            if (this.IsEnabled && this.activatorBtn == UIMouseButton.Undefined &&
                evtArgs.Button == UIMouseButton.Left)
            {
                this.activatorBtn = evtArgs.Button;
                if (this.currentStatus == Status.Normal)
                {
                    if (this.IsInsideSlider(evtArgs.Position))
                    {
                        this.currentStatus = Status.DraggingSlider;

                        /// Shift the slider and modify the selected value if necessary.
                        if (this.ShiftSlider(evtArgs.Position))
                        {
                            this.internalValueChange = true;
                            this.SelectedValue       = this.ComputeValueFromPosition();
                            this.internalValueChange = false;
                        }
                    }
                    else if (this.IsInsideTrack(evtArgs.Position))
                    {
                        this.trackingDirection     = this.ComputeTrackingDirection(evtArgs.Position);
                        this.timeSinceLastTracking = 0;

                        /// Perform the tracking operation
                        if (this.trackingDirection == TrackingDirection.Decreasing)
                        {
                            this.SelectedValue = Math.Max(0, this.selectedValue - this.trackingValueChange);
                        }
                        else
                        {
                            this.SelectedValue =
                                Math.Min(this.intervalLength - 1, this.selectedValue + this.trackingValueChange);
                        }

                        /// Change the state of the control
                        if (!this.IsInsideSlider(evtArgs.Position) &&
                            this.IsInsideTrack(evtArgs.Position) &&
                            this.ComputeTrackingDirection(evtArgs.Position) == this.trackingDirection)
                        {
                            this.currentStatus = Status.Tracking;
                            UIRoot.Instance.GraphicsPlatform.RenderLoop.FrameUpdate += this.OnFrameUpdate;
                        }
                        else
                        {
                            this.currentStatus = Status.TrackingPaused;
                        }
                    }
                }
            }
        }
示例#15
0
 /// <summary>
 /// Called when a mouse button has been pushed over the range of this button.
 /// </summary>
 /// <param name="sender">The sender of the event.</param>
 /// <param name="evtArgs">The details of the event.</param>
 private void OnMouseDown(UISensitiveObject sender, UIMouseEventArgs evtArgs)
 {
     if (this.IsEnabled && this.activatorBtn == UIMouseButton.Undefined &&
         evtArgs.Button == UIMouseButton.Left)
     {
         this.activatorBtn = evtArgs.Button;
         this.isPushed     = true;
         if (this.Pushed != null)
         {
             this.Pushed(this);
         }
     }
 }
示例#16
0
        /// <summary>
        /// Handler for child position changed events.
        /// </summary>
        private void ChildPositionChangedHdl(UIObject sender, RCIntVector prevPos, RCIntVector currPos)
        {
            UISensitiveObject sensitiveSender = sender as UISensitiveObject;

            if (sensitiveSender != null)
            {
                /// Invalidate the cached values of the sender.
                sensitiveSender.InvalidateSensitivePosition();
                sensitiveSender.InvalidateSensitiveClipRect();
                sensitiveSender.InvalidateSensitiveCloakRect();
                sensitiveSender.InvalidateSensitiveRangeRect();
            }
        }
示例#17
0
        /// <summary>
        /// Detaches the given sensitive child of this UISensitiveObject.
        /// </summary>
        /// <param name="whichChild">The UISensitiveObject you want to detach.</param>
        public void DetachSensitive(UISensitiveObject whichChild)
        {
            if (UIRoot.Instance.GraphicsPlatform.RenderLoop.IsRendering)
            {
                throw new InvalidOperationException("Rendering is in progress!");
            }
            if (whichChild.Parent != this)
            {
                throw new UIException("The object is already detached by UIObject.Detach!");
            }
            if (whichChild == null)
            {
                throw new ArgumentNullException("whichChild");
            }

            if (!this.sensitiveChildrenSet.Contains(whichChild))
            {
                return;
            }

            /// Raise the UISensitiveObject.ObjectDetaching event of the sensitive-root.
            if (this.SensitiveRoot.ObjectDetaching != null)
            {
                this.SensitiveRoot.ObjectDetaching(whichChild);
            }

            /// Detach
            //this.Detach(whichChild);
            this.sensitiveChildrenSet.Remove(whichChild);
            this.sensitiveChildren.Remove(whichChild);
            whichChild.sensitiveParent = null;

            /// Unbscribe from the PositionChanged, ClipRectChanged, CloakRectChanged and RangeRectChanged
            /// events of whichChild
            whichChild.PositionChanged  -= this.ChildPositionChangedHdl;
            whichChild.ClipRectChanged  -= this.ChildClipRectChangedHdl;
            whichChild.CloakRectChanged -= this.ChildCloakRectChangedHdl;
            whichChild.RangeRectChanged -= this.ChildRangeRectChangedHdl;

            /// Unsubscribe from the Z-order events of whichChild
            whichChild.BroughtForward -= this.BroughtForwardHdl;
            whichChild.BroughtToTop   -= this.BroughtToTopHdl;
            whichChild.SentBackward   -= this.SentBackwardHdl;
            whichChild.SentToBottom   -= this.SentToBottomHdl;

            /// Invalidate the cached values in the detached UISensitiveObject
            whichChild.InvalidateSensitivePosition();
            whichChild.InvalidateSensitiveClipRect();
            whichChild.InvalidateSensitiveCloakRect();
            whichChild.InvalidateSensitiveRangeRect();
        }
示例#18
0
        /// <summary>
        /// Called when a mouse button has been released over the range of this listbox.
        /// </summary>
        /// <param name="sender">The sender of the event.</param>
        /// <param name="evtArgs">The details of the event.</param>
        private void OnMouseUp(UISensitiveObject sender, UIMouseEventArgs evtArgs)
        {
            if (this.IsEnabled && this.activatorBtn == UIMouseButton.Left &&
                evtArgs.Button == UIMouseButton.Left)
            {
                this.activatorBtn = UIMouseButton.Undefined;

                if (this.currentStatus != Status.Normal)
                {
                    this.currentStatus = Status.Normal;
                    this.SelectedIndex = this.highlightedIndex;
                }
            }
        }
示例#19
0
 /// <summary>
 /// Called when a mouse button has been pushed over the range of this dropdown selector.
 /// </summary>
 /// <param name="sender">The sender of the event.</param>
 /// <param name="evtArgs">The details of the event.</param>
 private void OnMouseDown(UISensitiveObject sender, UIMouseEventArgs evtArgs)
 {
     if (this.IsEnabled && this.activatorBtn == UIMouseButton.Undefined &&
         evtArgs.Button == UIMouseButton.Left)
     {
         this.activatorBtn = evtArgs.Button;
         if (this.currentStatus == Status.Highlighted)
         {
             this.Range = this.droppedDownRect;
             this.BringToTop();
             this.currentStatus = Status.DroppedDown;
         }
     }
 }
示例#20
0
 /// <summary>
 /// Called when the mouse pointer has entered to the range of this button.
 /// </summary>
 /// <param name="sender">The sender of the event.</param>
 private void OnMouseEnter(UISensitiveObject sender)
 {
     if (this.IsEnabled)
     {
         this.isHighlighted = true;
         if (this.activatorBtn == UIMouseButton.Left)
         {
             this.isPushed = true;
             if (this.Pushed != null)
             {
                 this.Pushed(this);
             }
         }
     }
 }
示例#21
0
        /// <summary>
        /// Called when a sensitive child has been brought forward in the Z-order.
        /// </summary>
        private void BroughtForwardHdl(UIObject whichChild)
        {
            UISensitiveObject sensitiveChild = whichChild as UISensitiveObject;

            if (sensitiveChild != null && (sensitiveChild.PreviousSibling as UISensitiveObject) != null)
            {
                int childIndex = this.sensitiveChildren.IndexOf(sensitiveChild);
                if (childIndex > 0)
                {
                    /// Swap the given UISensitiveObject and the UISensitiveObject in front of it.
                    this.sensitiveChildren[childIndex]     = this.sensitiveChildren[childIndex - 1];
                    this.sensitiveChildren[childIndex - 1] = sensitiveChild;
                }
            }
        }
示例#22
0
 /// <summary>
 /// Called when the mouse pointer has left the range of this button.
 /// </summary>
 /// <param name="sender">The sender of the event.</param>
 private void OnMouseLeave(UISensitiveObject sender)
 {
     if (this.IsEnabled)
     {
         this.isHighlighted = false;
         if (this.activatorBtn == UIMouseButton.Left)
         {
             this.isPushed = false;
             if (this.Released != null)
             {
                 this.Released(this);
             }
         }
     }
 }
示例#23
0
        /// <summary>
        /// Called when a sensitive child has been sent backward in the Z-order.
        /// </summary>
        private void SentBackwardHdl(UIObject whichChild)
        {
            UISensitiveObject sensitiveChild = whichChild as UISensitiveObject;

            if (sensitiveChild != null && (sensitiveChild.NextSibling as UISensitiveObject) != null)
            {
                int childIndex = this.sensitiveChildren.IndexOf(sensitiveChild);
                if (-1 != childIndex && childIndex < this.sensitiveChildren.Count - 1)
                {
                    /// Swap the given UISensitiveObject and the UISensitiveObject behind it.
                    this.sensitiveChildren[childIndex]     = this.sensitiveChildren[childIndex + 1];
                    this.sensitiveChildren[childIndex + 1] = sensitiveChild;
                }
            }
        }
示例#24
0
 /// <summary>
 /// Called before a UISensitiveObject is detached from the sensitive-tree.
 /// </summary>
 /// <param name="obj">The detaching object.</param>
 private void ObjectDetaching(UISensitiveObject obj)
 {
     if (this.raisingMouseEvents)
     {
         /// Postpone the needed sensor operations
         List <UISensitiveObject> detachingObjects = new List <UISensitiveObject>();
         obj.WalkSensitiveTreeDFS(ref detachingObjects);
         foreach (UISensitiveObject detachingObj in detachingObjects)
         {
             /// Save the removed sensor and indicate that it will have to be unregistered.
             UIMouseSensor removedSensor = detachingObj.MouseSensor as UIMouseSensor;
             if (removedSensor == null)
             {
                 throw new UIException("Incompatible mouse sensor!");
             }
             this.tmpSensors.Add(removedSensor);
             this.tmpSensorOperations.Add(false);
         }
     }
     else
     {
         /// Execute the needed sensor operations
         List <UISensitiveObject> detachingObjects = new List <UISensitiveObject>();
         obj.WalkSensitiveTreeDFS(ref detachingObjects);
         foreach (UISensitiveObject detachingObj in detachingObjects)
         {
             UIMouseSensor deletedSensor = detachingObj.MouseSensor as UIMouseSensor;
             if (deletedSensor != null && this.allSensors.Contains(deletedSensor))
             {
                 deletedSensor.Reset();
                 this.allSensors.Remove(deletedSensor);
                 int idxOfDeleted = this.touchedSensors.IndexOf(deletedSensor);
                 if (idxOfDeleted != -1)
                 {
                     this.touchedSensors.RemoveRange(idxOfDeleted, this.touchedSensors.Count - idxOfDeleted);
                 }
                 if (this.activeSensor == deletedSensor)
                 {
                     this.activeSensor = null;
                 }
             }
             else
             {
                 throw new UIException("UIMouseSensor not registered!");
             }
         }
     }
 }
示例#25
0
        /// <summary>
        /// Called when a mouse button has been pushed over the range of this listbox.
        /// </summary>
        /// <param name="sender">The sender of the event.</param>
        /// <param name="evtArgs">The details of the event.</param>
        private void OnMouseDown(UISensitiveObject sender, UIMouseEventArgs evtArgs)
        {
            if (this.IsEnabled && this.activatorBtn == UIMouseButton.Undefined &&
                evtArgs.Button == UIMouseButton.Left)
            {
                this.activatorBtn = evtArgs.Button;

                if (this.scrollbar == null ||
                    (this.scrollbar != null && !(this.scrollbar.Position + this.scrollbar.Range).Contains(evtArgs.Position)))
                {
                    this.highlightedIndex = this.totalItemCount > 0 ?
                                            Math.Min((evtArgs.Position.Y / this.itemSize.Y) + this.firstVisibleIndex, this.totalItemCount - 1) :
                                            -1;
                    this.currentStatus = Status.Selecting;
                }
            }
        }
示例#26
0
        /// <summary>
        /// Internal method for checking the existence of the tree property after an attach.
        /// </summary>
        /// <returns>True if the tree property still exists, false otherwise.</returns>
        private bool CheckTreeProperty()
        {
            UISensitiveObject current = this;

            while (current.sensitiveParent != null)
            {
                if (current.sensitiveParent == this)
                {
                    return(false);
                }
                else
                {
                    current = current.sensitiveParent;
                }
            }
            return(true);
        }
示例#27
0
        /// <summary>
        /// Called when a sensitive child has been sent to bottom in the Z-order.
        /// </summary>
        private void SentToBottomHdl(UIObject whichChild)
        {
            UISensitiveObject sensitiveChild = whichChild as UISensitiveObject;

            if (sensitiveChild != null)
            {
                int childIndex = this.sensitiveChildren.IndexOf(sensitiveChild);
                if (-1 != childIndex && childIndex < this.sensitiveChildren.Count - 1)
                {
                    for (int i = childIndex; i < this.sensitiveChildren.Count - 1; i++)
                    {
                        this.sensitiveChildren[i] = this.sensitiveChildren[i + 1];
                    }
                    this.sensitiveChildren[this.sensitiveChildren.Count - 1] = sensitiveChild;
                }
            }
        }
示例#28
0
        /// <summary>
        /// Called when a sensitive child has been brought to top in the Z-order.
        /// </summary>
        private void BroughtToTopHdl(UIObject whichChild)
        {
            UISensitiveObject sensitiveChild = whichChild as UISensitiveObject;

            if (sensitiveChild != null)
            {
                int childIndex = this.sensitiveChildren.IndexOf(sensitiveChild);
                if (childIndex > 0)
                {
                    for (int i = childIndex; i > 0; i--)
                    {
                        this.sensitiveChildren[i] = this.sensitiveChildren[i - 1];
                    }
                    this.sensitiveChildren[0] = sensitiveChild;
                }
            }
        }
示例#29
0
        /// <summary>
        /// Called when the increase or decrease button has been pushed by an input device.
        /// </summary>
        /// <param name="sender">Reference to the sender button.</param>
        private void OnButtonPushed(UISensitiveObject sender)
        {
            this.pushedButton = (UIButton)sender;

            this.timeSinceLastStep = 0;
            if (this.pushedButton == this.decreaseButton)
            {
                this.sliderControl.SelectedValue =
                    Math.Max(0, this.sliderControl.SelectedValue - this.stepValueChange);
            }
            else if (this.pushedButton == this.increaseButton)
            {
                this.sliderControl.SelectedValue =
                    Math.Min(this.intervalLength - 1, this.sliderControl.SelectedValue + this.stepValueChange);
            }

            UIRoot.Instance.GraphicsPlatform.RenderLoop.FrameUpdate += this.OnFrameUpdate;
        }
示例#30
0
 /// <summary>
 /// Called when a mouse button has been released over the range of this dropdown selector.
 /// </summary>
 /// <param name="sender">The sender of the event.</param>
 /// <param name="evtArgs">The details of the event.</param>
 private void OnMouseUp(UISensitiveObject sender, UIMouseEventArgs evtArgs)
 {
     if (this.IsEnabled && this.activatorBtn == UIMouseButton.Left &&
         evtArgs.Button == UIMouseButton.Left)
     {
         this.activatorBtn = UIMouseButton.Undefined;
         if (this.currentStatus == Status.DroppedDown || this.currentStatus == Status.Selecting)
         {
             this.Range = this.normalRect;
             bool selectIdx = this.currentStatus == Status.Selecting;
             this.currentStatus = this.normalRect.Contains(evtArgs.Position) ? Status.Highlighted
                                                                             : Status.Normal;
             if (selectIdx)
             {
                 this.SelectedIndex = this.highlightedIndex;
             }
         }
     }
 }