public override void OnApplyTemplate()
#endif
		{
			base.OnApplyTemplate();

			ApplyPlatformFeatures();

			_horizontalThumb = GetTemplateChild(HorizontalThumbName) as Thumb;
			_horizontalTrack = GetTemplateChild(HorizontalTrackName) as Rectangle;
			_horizontalFill = GetTemplateChild(HorizontalFillName) as Rectangle;
			_horizontalRectangleGeometry = GetTemplateChild(HorizontalRectangleGeometryName) as RectangleGeometry;
			_horizontalThumbTranslateTransform = GetTemplateChild(HorizontalThumbTranslateTransformName) as TranslateTransform;

			SyncValueAndPosition(Value, Value);

			_isLayoutInit = true;
		}
Example #2
0
        /// <summary>
        /// Update the visual state of the control when its template is changed.
        /// </summary>
        protected override void OnApplyTemplate()
        {
            if (_minThumb != null)
            {
                _minThumb.DragCompleted -= Thumb_DragCompleted;
                _minThumb.DragDelta     -= MinThumb_DragDelta;
                _minThumb.DragStarted   -= MinThumb_DragStarted;
                _minThumb.KeyDown       -= MinThumb_KeyDown;
            }

            if (_maxThumb != null)
            {
                _maxThumb.DragCompleted -= Thumb_DragCompleted;
                _maxThumb.DragDelta     -= MaxThumb_DragDelta;
                _maxThumb.DragStarted   -= MaxThumb_DragStarted;
                _maxThumb.KeyDown       -= MaxThumb_KeyDown;
            }

            if (_containerCanvas != null)
            {
                _containerCanvas.SizeChanged     -= ContainerCanvas_SizeChanged;
                _containerCanvas.PointerPressed  -= ContainerCanvas_PointerPressed;
                _containerCanvas.PointerMoved    -= ContainerCanvas_PointerMoved;
                _containerCanvas.PointerReleased -= ContainerCanvas_PointerReleased;
                _containerCanvas.PointerExited   -= ContainerCanvas_PointerExited;
            }

            IsEnabledChanged -= RangeSelector_IsEnabledChanged;

            // Need to make sure the values can be set in XAML and don't overwrite each other
            VerifyValues();
            _valuesAssigned = true;

            _outOfRangeContentContainer = GetTemplateChild("OutOfRangeContentContainer") as Border;
            _activeRectangle            = GetTemplateChild("ActiveRectangle") as Rectangle;
            _minThumb        = GetTemplateChild("MinThumb") as Thumb;
            _maxThumb        = GetTemplateChild("MaxThumb") as Thumb;
            _containerCanvas = GetTemplateChild("ContainerCanvas") as Canvas;
            _controlGrid     = GetTemplateChild("ControlGrid") as Grid;
            _toolTip         = GetTemplateChild("ToolTip") as Grid;
            _toolTipText     = GetTemplateChild("ToolTipText") as TextBlock;

            if (_minThumb != null)
            {
                _minThumb.DragCompleted += Thumb_DragCompleted;
                _minThumb.DragDelta     += MinThumb_DragDelta;
                _minThumb.DragStarted   += MinThumb_DragStarted;
                _minThumb.KeyDown       += MinThumb_KeyDown;
                _minThumb.KeyUp         += Thumb_KeyUp;
            }

            if (_maxThumb != null)
            {
                _maxThumb.DragCompleted += Thumb_DragCompleted;
                _maxThumb.DragDelta     += MaxThumb_DragDelta;
                _maxThumb.DragStarted   += MaxThumb_DragStarted;
                _maxThumb.KeyDown       += MaxThumb_KeyDown;
                _maxThumb.KeyUp         += Thumb_KeyUp;
            }

            if (_containerCanvas != null)
            {
                _containerCanvas.SizeChanged     += ContainerCanvas_SizeChanged;
                _containerCanvas.PointerEntered  += ContainerCanvas_PointerEntered;
                _containerCanvas.PointerPressed  += ContainerCanvas_PointerPressed;
                _containerCanvas.PointerMoved    += ContainerCanvas_PointerMoved;
                _containerCanvas.PointerReleased += ContainerCanvas_PointerReleased;
                _containerCanvas.PointerExited   += ContainerCanvas_PointerExited;
            }

            VisualStateManager.GoToState(this, IsEnabled ? "Normal" : "Disabled", false);

            IsEnabledChanged += RangeSelector_IsEnabledChanged;

            // Measure our min/max text longest value so we can avoid the length of the scrolling reason shifting in size during use.
            var tb = new TextBlock {
                Text = Maximum.ToString()
            };

            tb.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));

            base.OnApplyTemplate();
        }
Example #3
0
        Thumb GetResizeThumb(Cursor cur, HorizontalAlignment hor, VerticalAlignment ver)
        {
            var thumb = new Thumb()
            {
                Background          = Brushes.Red,
                Width               = THUMB_SIZE,
                Height              = THUMB_SIZE,
                HorizontalAlignment = hor,
                VerticalAlignment   = ver,
                Cursor              = cur,
                Template            = new ControlTemplate(typeof(Thumb))
                {
                    VisualTree = GetFactory(new SolidColorBrush(Colors.Green))
                }
            };

            thumb.DragDelta += (s, e) =>
            {
                var element = AdornedElement as FrameworkElement;
                if (element == null)
                {
                    return;
                }

                Resize(element);

                switch (thumb.VerticalAlignment)
                {
                case VerticalAlignment.Bottom:
                    if (element.Height + e.VerticalChange > MINIMAL_SIZE)
                    {
                        element.Height += e.VerticalChange;
                    }
                    break;

                case VerticalAlignment.Top:
                    if (element.Height - e.VerticalChange > MINIMAL_SIZE)
                    {
                        element.Height -= e.VerticalChange;
                        Canvas.SetTop(element, Canvas.GetTop(element) + e.VerticalChange);
                    }
                    break;
                }
                switch (thumb.HorizontalAlignment)
                {
                case HorizontalAlignment.Left:
                    if (element.Width - e.HorizontalChange > MINIMAL_SIZE)
                    {
                        element.Width -= e.HorizontalChange;
                        Canvas.SetLeft(element, Canvas.GetLeft(element) + e.HorizontalChange);
                    }
                    break;

                case HorizontalAlignment.Right:
                    if (element.Width + e.HorizontalChange > MINIMAL_SIZE)
                    {
                        element.Width += e.HorizontalChange;
                    }
                    break;
                }

                e.Handled = true;
            };
            return(thumb);
        }
Example #4
0
        protected override void OnApplyTemplate()
#endif
        {
            base.OnApplyTemplate();

            //----------------------------
            // Get a reference to the UI elements defined in the control template:
            //----------------------------

            _horizontalRoot          = this.GetTemplateChild("HorizontalRoot") as Canvas;
            _horizontalThumb         = this.GetTemplateChild("HorizontalThumb") as Thumb;
            _horizontalSmallDecrease = this.GetTemplateChild("HorizontalSmallDecrease") as Button;
            _horizontalSmallIncrease = this.GetTemplateChild("HorizontalSmallIncrease") as Button;
            _horizontalLargeDecrease = this.GetTemplateChild("HorizontalLargeDecrease") as Button;
            _horizontalLargeIncrease = this.GetTemplateChild("HorizontalLargeIncrease") as Button;

            _verticalRoot          = this.GetTemplateChild("VerticalRoot") as Canvas;
            _verticalThumb         = this.GetTemplateChild("VerticalThumb") as Thumb;
            _verticalSmallDecrease = this.GetTemplateChild("VerticalSmallDecrease") as Button;
            _verticalSmallIncrease = this.GetTemplateChild("VerticalSmallIncrease") as Button;
            _verticalLargeDecrease = this.GetTemplateChild("VerticalLargeDecrease") as Button;
            _verticalLargeIncrease = this.GetTemplateChild("VerticalLargeIncrease") as Button;


            //----------------------------
            // Register the events:
            //----------------------------
            if (_horizontalThumb != null)
            {
                _horizontalThumb.DragStarted   += HorizontalThumb_DragStarted;
                _horizontalThumb.DragDelta     += HorizontalThumb_DragDelta;
                _horizontalThumb.DragCompleted += HorizontalThumb_DragCompleted;
            }
            if (_verticalThumb != null)
            {
                _verticalThumb.DragStarted   += VerticalThumb_DragStarted;
                _verticalThumb.DragDelta     += VerticalThumb_DragDelta;
                _verticalThumb.DragCompleted += VerticalThumb_DragCompleted;
            }
            if (_horizontalSmallDecrease != null)
            {
                _horizontalSmallDecrease.Click += SmallDecrease_Click;
            }
            if (_verticalSmallDecrease != null)
            {
                _verticalSmallDecrease.Click += SmallDecrease_Click;
            }
            if (_horizontalLargeDecrease != null)
            {
                _horizontalLargeDecrease.Click += LargeDecrease_Click;
            }
            if (_verticalLargeDecrease != null)
            {
                _verticalLargeDecrease.Click += LargeDecrease_Click;
            }
            if (_horizontalSmallIncrease != null)
            {
                _horizontalSmallIncrease.Click += SmallIncrease_Click;
            }
            if (_verticalSmallIncrease != null)
            {
                _verticalSmallIncrease.Click += SmallIncrease_Click;
            }
            if (_horizontalLargeIncrease != null)
            {
                _horizontalLargeIncrease.Click += LargeIncrease_Click;
            }
            if (_verticalLargeIncrease != null)
            {
                _verticalLargeIncrease.Click += LargeIncrease_Click;
            }


            //----------------------------
            // Display the horizontal or vertical root depending on the orientation:
            //----------------------------

            if (_verticalRoot != null)
            {
                _verticalRoot.Visibility = (this.Orientation == Orientation.Vertical ? Visibility.Visible : Visibility.Collapsed);
            }
            if (_horizontalRoot != null)
            {
                _horizontalRoot.Visibility = (this.Orientation == Orientation.Horizontal ? Visibility.Visible : Visibility.Collapsed);
            }
        }
Example #5
0
        public override void OnApplyTemplate()
#endif
        {
            base.OnApplyTemplate();

            SliderTrack = GetTemplateChild(nameof(SliderTrack)) as FrameworkElement;
            if (SliderTrack != null)
            {
                SliderTrack.SizeChanged += TimeSlider_SizeChanged;
            }

            HorizontalTrackThumb           = GetTemplateChild(nameof(HorizontalTrackThumb)) as Thumb;
            MinimumThumb                   = GetTemplateChild(nameof(MinimumThumb)) as Thumb;
            MinimumThumbLabel              = GetTemplateChild(nameof(MinimumThumbLabel)) as TextBlock;
            MaximumThumb                   = GetTemplateChild(nameof(MaximumThumb)) as Thumb;
            MaximumThumbLabel              = GetTemplateChild(nameof(MaximumThumbLabel)) as TextBlock;
            SliderTrackStepBackRepeater    = GetTemplateChild(nameof(SliderTrackStepBackRepeater)) as RepeatButton;
            SliderTrackStepForwardRepeater = GetTemplateChild(nameof(SliderTrackStepForwardRepeater)) as RepeatButton;
            PlayPauseButton                = GetTemplateChild(nameof(PlayPauseButton)) as ToggleButton;
            NextButton               = GetTemplateChild(nameof(NextButton)) as ButtonBase;
            PreviousButton           = GetTemplateChild(nameof(PreviousButton)) as ButtonBase;
            Tickmarks                = GetTemplateChild(nameof(Tickmarks)) as Primitives.Tickbar;
            FullExtentStartTimeLabel = GetTemplateChild(nameof(FullExtentStartTimeLabel)) as TextBlock;
            FullExtentEndTimeLabel   = GetTemplateChild(nameof(FullExtentEndTimeLabel)) as TextBlock;

            if (MinimumThumb != null)
            {
#if NETFX_CORE
                MinimumThumb.ManipulationMode   = ManipulationModes.TranslateX;
                MinimumThumb.ManipulationDelta += (s, e) =>
                {
                    // Position is reported relative to the left edge of the thumb.  Adjust it so it is relative to the thumb's center.
                    var translateX = e.Position.X - (MinimumThumb.ActualWidth / 2);
                    OnMinimumThumbDrag(translateX);
                };
#else
                MinimumThumb.DragDelta += (s, e) => OnMinimumThumbDrag(e.HorizontalChange);
#endif
                MinimumThumb.DragCompleted += (s, e) => OnDragCompleted();
                MinimumThumb.DragStarted   += (s, e) => SetFocus();
            }

            if (MaximumThumb != null)
            {
#if NETFX_CORE
                MaximumThumb.ManipulationMode   = ManipulationModes.TranslateX;
                MaximumThumb.ManipulationDelta += (s, e) =>
                {
                    // Position is reported relative to the left edge of the thumb.  Adjust it so it is relative to the thumb's center.
                    var translateX = e.Position.X - (MaximumThumb.ActualWidth / 2);
                    OnMaximumThumbDrag(translateX);
                };
#else
                MaximumThumb.DragDelta += (s, e) => OnMaximumThumbDrag(e.HorizontalChange);
#endif
                MaximumThumb.DragCompleted += (s, e) => OnDragCompleted();
                MaximumThumb.DragStarted   += (s, e) => SetFocus();
            }

            if (HorizontalTrackThumb != null)
            {
#if NETFX_CORE
                HorizontalTrackThumb.ManipulationMode   = ManipulationModes.TranslateX;
                HorizontalTrackThumb.ManipulationDelta += (s, e) =>
                {
                    // Position is reported relative to the left edge of the thumb.  Adjust it so it is relative to the thumb's center.
                    var translateX = e.Position.X - (HorizontalTrackThumb.ActualWidth / 2);
                    OnCurrentExtentThumbDrag(translateX);
                };
#else
                HorizontalTrackThumb.DragDelta += (s, e) => OnCurrentExtentThumbDrag(e.HorizontalChange);
#endif
                HorizontalTrackThumb.DragCompleted += (s, e) => OnDragCompleted();
                HorizontalTrackThumb.DragStarted   += (s, e) => SetFocus();
            }

            if (SliderTrackStepBackRepeater != null)
            {
                SliderTrackStepBackRepeater.Click += (s, e) =>
                {
                    SetFocus();
                    IsPlaying = false;
                    StepBack();
                };
            }

            if (SliderTrackStepForwardRepeater != null)
            {
                SliderTrackStepForwardRepeater.Click += (s, e) =>
                {
                    SetFocus();
                    IsPlaying = false;
                    StepForward();
                };
            }

            if (PlayPauseButton != null)
            {
                IsPlaying = PlayPauseButton.IsChecked.Value;
                PlayPauseButton.Checked   += (s, e) => IsPlaying = true;
                PlayPauseButton.Unchecked += (s, e) => IsPlaying = false;
            }

            if (NextButton != null)
            {
                NextButton.Click += (s, e) => OnNextButtonClick();
            }

            if (PreviousButton != null)
            {
                PreviousButton.Click += (s, e) => OnPreviousButtonClick();
            }

            PositionTickmarks();
            SetButtonVisibility();
            ApplyLabelMode(LabelMode);
        }
Example #6
0
        private Thumb GetResizeThumb(Cursor cur, HorizontalAlignment horizontal, VerticalAlignment vertical)
        {
            var thumb = new Thumb()
            {
                //Background = Brushes.Red,
                Width  = 10,
                Height = 50,
                HorizontalAlignment = horizontal,
                VerticalAlignment   = vertical,
                Cursor   = cur,
                Template = new ControlTemplate(typeof(Thumb))
                {
                    VisualTree = GetThumbTemple(new SolidColorBrush(Colors.Gold))
                }
            };

            thumb.DragDelta += (s, e) =>
            {
                var element = AdornedElement as FrameworkElement;

                if (element == null)
                {
                    return;
                }

                this.ElementResize(element);

                switch (thumb.VerticalAlignment)
                {
                case VerticalAlignment.Bottom:
                    if (element.Height + e.VerticalChange > MINIMAL_SIZE)
                    {
                        element.Height += e.VerticalChange;
                        //thumbRectangle.Height += e.VerticalChange;
                    }
                    break;

                //case VerticalAlignment.Center:
                //    if ()
                //    {

                //    }
                //    break;
                case VerticalAlignment.Top:
                    if (element.Height - e.VerticalChange > MINIMAL_SIZE)
                    {
                        element.Height -= e.VerticalChange;
                        //thumbRectangle.Height -= e.VerticalChange;

                        Canvas.SetTop(element, Canvas.GetTop(element) + e.VerticalChange);
                    }
                    break;
                }
                switch (thumb.HorizontalAlignment)
                {
                case HorizontalAlignment.Left:
                    if (element.Width - e.HorizontalChange > MINIMAL_SIZE)
                    {
                        element.Width -= e.HorizontalChange;
                        //thumbRectangle.Width -= e.HorizontalChange;
                        Canvas.SetLeft(element, Canvas.GetLeft(element) + e.HorizontalChange);
                    }
                    break;

                case HorizontalAlignment.Right:
                    if (element.Width + e.HorizontalChange > MINIMAL_SIZE)
                    {
                        element.Width += e.HorizontalChange;
                        //thumbRectangle.Width += e.HorizontalChange;
                    }
                    break;
                }

                e.Handled = true;
            };
            return(thumb);
        }
Example #7
0
 public override void CreateThumb()
 {
     if (m_ThumbB == null)
     {
         m_ThumbB         = new Thumb();
         m_ThumbL         = new Thumb();
         m_ThumbLB        = new Thumb();
         m_ThumbLT        = new Thumb();
         m_ThumbR         = new Thumb();
         m_ThumbRB        = new Thumb();
         m_ThumbRT        = new Thumb();
         m_ThumbT         = new Thumb();
         ThumbMove        = new Thumb();
         m_ThumbB.Height  = Setting.Thumb_w;
         m_ThumbB.Width   = Setting.Thumb_w;
         m_ThumbL.Height  = Setting.Thumb_w;
         m_ThumbL.Width   = Setting.Thumb_w;
         m_ThumbLB.Height = Setting.Thumb_w;
         m_ThumbLB.Width  = Setting.Thumb_w;
         m_ThumbLT.Height = Setting.Thumb_w;
         m_ThumbLT.Width  = Setting.Thumb_w;
         m_ThumbR.Height  = Setting.Thumb_w;
         m_ThumbR.Width   = Setting.Thumb_w;
         m_ThumbRB.Height = Setting.Thumb_w;
         m_ThumbRB.Width  = Setting.Thumb_w;
         m_ThumbRT.Height = Setting.Thumb_w;
         m_ThumbRT.Width  = Setting.Thumb_w;
         m_ThumbT.Height  = Setting.Thumb_w;
         m_ThumbT.Width   = Setting.Thumb_w;
         ThumbMove.Height = Setting.Thumb_c;
         ThumbMove.Width  = Setting.Thumb_c;
         double num  = (double)m_rectangle.GetValue(Canvas.LeftProperty);
         double num2 = (double)m_rectangle.GetValue(Canvas.TopProperty);
         m_ThumbB.SetValue(Canvas.LeftProperty, num + m_rectangle.Width / 2.0 - Setting.Thumb_w / 2.0);
         m_ThumbB.SetValue(Canvas.TopProperty, num2 + m_rectangle.Height - Setting.Thumb_w / 2.0);
         m_ThumbL.SetValue(Canvas.LeftProperty, num - Setting.Thumb_w / 2.0);
         m_ThumbL.SetValue(Canvas.TopProperty, num2 + m_rectangle.Height / 2.0 - Setting.Thumb_w / 2.0);
         m_ThumbLB.SetValue(Canvas.LeftProperty, num - Setting.Thumb_w / 2.0);
         m_ThumbLB.SetValue(Canvas.TopProperty, num2 + m_rectangle.Height - Setting.Thumb_w / 2.0);
         m_ThumbLT.SetValue(Canvas.LeftProperty, num - Setting.Thumb_w / 2.0);
         m_ThumbLT.SetValue(Canvas.TopProperty, num2 - Setting.Thumb_w / 2.0);
         m_ThumbR.SetValue(Canvas.LeftProperty, num + m_rectangle.Width - Setting.Thumb_w / 2.0);
         m_ThumbR.SetValue(Canvas.TopProperty, num2 + m_rectangle.Height / 2.0 - Setting.Thumb_w / 2.0);
         m_ThumbRB.SetValue(Canvas.LeftProperty, num + m_rectangle.Width - Setting.Thumb_w / 2.0);
         m_ThumbRB.SetValue(Canvas.TopProperty, num2 + m_rectangle.Height - Setting.Thumb_w / 2.0);
         m_ThumbRT.SetValue(Canvas.LeftProperty, num + m_rectangle.Width - Setting.Thumb_w / 2.0);
         m_ThumbRT.SetValue(Canvas.TopProperty, num2 - Setting.Thumb_w / 2.0);
         m_ThumbT.SetValue(Canvas.LeftProperty, num + m_rectangle.Width / 2.0 - Setting.Thumb_w / 2.0);
         m_ThumbT.SetValue(Canvas.TopProperty, num2 - Setting.Thumb_w / 2.0);
         ThumbMove.SetValue(Canvas.LeftProperty, num + m_rectangle.Width / 2.0 - Setting.Thumb_c / 2.0);
         ThumbMove.SetValue(Canvas.TopProperty, num2 + m_rectangle.Height / 2.0 - Setting.Thumb_c / 2.0);
         M_FiguresCanvas.Children.Add(m_ThumbL);
         M_FiguresCanvas.Children.Add(m_ThumbLB);
         M_FiguresCanvas.Children.Add(m_ThumbLT);
         M_FiguresCanvas.Children.Add(m_ThumbR);
         M_FiguresCanvas.Children.Add(m_ThumbRT);
         M_FiguresCanvas.Children.Add(m_ThumbT);
         M_FiguresCanvas.Children.Add(ThumbMove);
         M_FiguresCanvas.Children.Add(m_ThumbB);
         M_FiguresCanvas.Children.Add(m_ThumbRB);
         m_ThumbB.DragDelta        += m_ThumbB_DragDelta;
         m_ThumbL.DragDelta        += m_ThumbL_DragDelta;
         m_ThumbLB.DragDelta       += m_ThumbLB_DragDelta;
         m_ThumbLT.DragDelta       += m_ThumbLT_DragDelta;
         m_ThumbR.DragDelta        += m_ThumbR_DragDelta;
         m_ThumbRB.DragDelta       += m_ThumbRB_DragDelta;
         m_ThumbRT.DragDelta       += m_ThumbRT_DragDelta;
         m_ThumbT.DragDelta        += m_ThumbT_DragDelta;
         m_ThumbMove.DragDelta     += m_ThumbMove_DragDelta;
         m_ThumbB.DragCompleted    += DragCompleted;
         m_ThumbL.DragCompleted    += DragCompleted;
         m_ThumbLB.DragCompleted   += DragCompleted;
         m_ThumbLT.DragCompleted   += DragCompleted;
         m_ThumbR.DragCompleted    += DragCompleted;
         m_ThumbRB.DragCompleted   += DragCompleted;
         m_ThumbRT.DragCompleted   += DragCompleted;
         m_ThumbT.DragCompleted    += DragCompleted;
         m_ThumbMove.DragCompleted += DragCompleted;
     }
 }
Example #8
0
 public static bool GetIsCustomThumb(Thumb element)
 {
     return((bool)element.GetValue(IsCustomThumbProperty));
 }
Example #9
0
 private void OnLoaded(object sender, RoutedEventArgs e)
 {
     _thumb      = (Thumb)GetTemplateChild("SliderThumb");
     _peakMeter1 = (Border)GetTemplateChild("PeakMeter1");
     _peakMeter2 = (Border)GetTemplateChild("PeakMeter2");
 }
 public override void OnApplyTemplate()
 {
     base.OnApplyTemplate();
     _thumb         = (Thumb)GetTemplateChild("Thumb");
     _thumb.Opacity = 0;
 }
Example #11
0
  private static void Callback(object state)
  {	
    DirectoryInfo myDirectory = new DirectoryInfo(dir);
    FileInfo[] _files = myDirectory.GetFiles();
    foreach (FileInfo file in _files)
    {
      String s;
      Thumb thumb = new Thumb(file.FullName);
      if(thumb.Exists() == 0)
	thumb.Generate();
      s = thumb.Preview;
      TableImage i = new TableImage(s);
      items.Add(i);
    }

	
    imageTable.ItemSize(96, 96);
    imageTable.HorizSpacer = 10;
    imageTable.VertSpacer = 10;
    imageTable.Resize(640 - 70 - 2, 480 - 37 - 2);
    Box box_images = (Box)Application.EE.DataGet("box_images");
    box_images.Show();	
    System.GC.KeepAlive(imageTable);
  }   
Example #12
0
	void  Update (){
		if(gun_type == GunType.AUTOMATIC){
			if(magazine_instance_in_gun){
				var mag_pos= transform.FindChild("point_mag_inserted").position;
				var mag_rot= transform.rotation;
				var mag_seated_display= mag_seated;
				if(disable_springs){
					mag_seated_display = Mathf.Floor(mag_seated_display + 0.5f);
				}
				mag_pos += (transform.FindChild("point_mag_to_insert").position - 
							transform.FindChild("point_mag_inserted").position) * 
						   (1.0f - mag_seated_display);
			   magazine_instance_in_gun.transform.position = mag_pos;
			   magazine_instance_in_gun.transform.rotation = mag_rot;
			}
			
			if(mag_stage == MagStage.INSERTING){
				mag_seated += Time.deltaTime * 5.0f;
				if(mag_seated >= 1.0f){
					mag_seated = 1.0f;
					mag_stage = MagStage.IN;
					if(slide_amount > 0.7f){
						ChamberRoundFromMag();
					}
					recoil_transfer_y += Random.Range(-40.0f,40.0f);
					recoil_transfer_x += Random.Range(50.0f,300.0f);
					rotation_transfer_x += Random.Range(-0.4f,0.4f);
					rotation_transfer_y += Random.Range(0.0f,1.0f);
				}
			}
			if(mag_stage == MagStage.REMOVING){
				mag_seated -= Time.deltaTime * 5.0f;
				if(mag_seated <= 0.0f){
					mag_seated = 0.0f;
					ready_to_remove_mag = true;
					mag_stage = MagStage.OUT;
				}
			}
		}
		
		if(has_safety){
			if(safety == Safety.OFF){
				safety_off = Mathf.Min(1.0f, safety_off + Time.deltaTime * 10.0f);
			} else if(safety == Safety.ON){
				safety_off = Mathf.Max(0.0f, safety_off - Time.deltaTime * 10.0f);
			}
		}
		
		if(has_auto_mod){
			if(auto_mod_stage == AutoModStage.ENABLED){
				auto_mod_amount = Mathf.Min(1.0f, auto_mod_amount + Time.deltaTime * 10.0f);
			} else if(auto_mod_stage == AutoModStage.DISABLED){
				auto_mod_amount = Mathf.Max(0.0f, auto_mod_amount - Time.deltaTime * 10.0f);
			}
		}
		
		if(thumb_on_hammer == Thumb.SLOW_LOWERING){
			hammer_cocked -= Time.deltaTime * 10.0f;
			if(hammer_cocked <= 0.0f){
				hammer_cocked = 0.0f;
				thumb_on_hammer = Thumb.OFF_HAMMER;
				PlaySoundFromGroup(sound_hammer_decock, kGunMechanicVolume);
				//PlaySoundFromGroup(sound_mag_eject_button, kGunMechanicVolume);
			}
		}

		if(has_slide){
			if(slide_stage == SlideStage.PULLBACK || slide_stage == SlideStage.HOLD){
				if(slide_stage == SlideStage.PULLBACK){
					slide_amount += Time.deltaTime * 10.0f;
					if(slide_amount >= kSlideLockPosition && slide_lock){
						slide_amount = kSlideLockPosition;
						slide_stage = SlideStage.HOLD;
						PlaySoundFromGroup(sound_slide_back, kGunMechanicVolume);
					}
					if(slide_amount >= kPressCheckPosition && slide_lock){
						slide_amount = kPressCheckPosition;
						slide_stage = SlideStage.HOLD;
						slide_lock = false;
						PlaySoundFromGroup(sound_slide_back, kGunMechanicVolume);
					}
					if(slide_amount >= 1.0f){
						PullSlideBack();
						slide_amount = 1.0f;
						slide_stage = SlideStage.HOLD;
						PlaySoundFromGroup(sound_slide_back, kGunMechanicVolume);
					}
				}
			}	
			
			var slide_amount_display= slide_amount;
			if(disable_springs){
				slide_amount_display = Mathf.Floor(slide_amount_display + 0.5f);
				if(slide_amount == kPressCheckPosition){
					slide_amount_display = kPressCheckPosition;
				}
			}
			transform.FindChild("slide").localPosition = 
				slide_rel_pos + 
				(transform.FindChild("point_slide_end").localPosition - 
				 transform.FindChild("point_slide_start").localPosition) * slide_amount_display;
		}
		
		if(has_hammer){
			var hammer= GetHammer();
			var point_hammer_cocked= transform.FindChild("point_hammer_cocked");
			var hammer_cocked_display= hammer_cocked;
			if(disable_springs){
				hammer_cocked_display = Mathf.Floor(hammer_cocked_display + 0.5f);
			}
			hammer.localPosition = 
				Vector3.Lerp(hammer_rel_pos, point_hammer_cocked.localPosition, hammer_cocked_display);
			hammer.localRotation = 
				Quaternion.Slerp(hammer_rel_rot, point_hammer_cocked.localRotation, hammer_cocked_display);
		}
			
		if(has_safety){
			var safety_off_display= safety_off;
			if(disable_springs){
				safety_off_display = Mathf.Floor(safety_off_display + 0.5f);
			}
			transform.FindChild("safety").localPosition = 
				Vector3.Lerp(safety_rel_pos, transform.FindChild("point_safety_off").localPosition, safety_off_display);
			transform.FindChild("safety").localRotation = 
				Quaternion.Slerp(safety_rel_rot, transform.FindChild("point_safety_off").localRotation, safety_off_display);
		}
		
		if(has_auto_mod){
			var auto_mod_amount_display= auto_mod_amount;
			if(disable_springs){
				auto_mod_amount_display = Mathf.Floor(auto_mod_amount_display + 0.5f);
			}
			var slide= transform.FindChild("slide");
			slide.FindChild("auto mod toggle").localPosition = 
				Vector3.Lerp(auto_mod_rel_pos, slide.FindChild("point_auto_mod_enabled").localPosition, auto_mod_amount_display);
		}
				
		if(gun_type == GunType.AUTOMATIC){
			hammer_cocked = Mathf.Max(hammer_cocked, slide_amount);
			if(hammer_cocked != 1.0f && thumb_on_hammer == Thumb.OFF_HAMMER  && (pressure_on_trigger == PressureState.NONE || action_type == ActionType.SINGLE)){
				hammer_cocked = Mathf.Min(hammer_cocked, slide_amount);
			}
		} else {
			if(hammer_cocked != 1.0f && thumb_on_hammer == Thumb.OFF_HAMMER && (pressure_on_trigger == PressureState.NONE || action_type == ActionType.SINGLE)){
				hammer_cocked = 0.0f;
			}
		}
		
		if(has_slide){
			if(slide_stage == SlideStage.NOTHING){
				var old_slide_amount= slide_amount;
				slide_amount = Mathf.Max(0.0f, slide_amount - Time.deltaTime * kSlideLockSpeed);
				if(!slide_lock && slide_amount == 0.0f && old_slide_amount != 0.0f){
					PlaySoundFromGroup(sound_slide_front, kGunMechanicVolume*1.5f);
					if(round_in_chamber){
						round_in_chamber.transform.position = transform.FindChild("point_chambered_round").position;
						round_in_chamber.transform.rotation = transform.FindChild("point_chambered_round").rotation;
					}
				}
				if(slide_amount == 0.0f && round_in_chamber_state == RoundState.LOADING){
					round_in_chamber_state = RoundState.READY;
				}
				if(slide_lock && old_slide_amount >= kSlideLockPosition){
					slide_amount = Mathf.Max(kSlideLockPosition, slide_amount);
					if(old_slide_amount != kSlideLockPosition && slide_amount == kSlideLockPosition){
						PlaySoundFromGroup(sound_slide_front, kGunMechanicVolume);
					}
				}
			}
		}
		
		if(gun_type == GunType.REVOLVER){
			if(yolk_stage == YolkStage.CLOSED && hammer_cocked == 1.0f){
				target_cylinder_offset = 0;
			}
			if(target_cylinder_offset != 0){
				var target_cylinder_rotation= ((active_cylinder + target_cylinder_offset) * 360.0f / cylinder_capacity);
				cylinder_rotation = Mathf.Lerp(target_cylinder_rotation, cylinder_rotation, Mathf.Pow(0.2f,Time.deltaTime));
				if(cylinder_rotation > (active_cylinder + 0.5f)  * 360.0f / cylinder_capacity){
					++active_cylinder;
					--target_cylinder_offset;
					if(yolk_stage == YolkStage.CLOSED){
						PlaySoundFromGroup(sound_cylinder_rotate, kGunMechanicVolume);
					}
				}
				if(cylinder_rotation < (active_cylinder - 0.5f)  * 360.0f / cylinder_capacity){
					--active_cylinder;
					++target_cylinder_offset;
					if(yolk_stage == YolkStage.CLOSED){
						PlaySoundFromGroup(sound_cylinder_rotate, kGunMechanicVolume);
					}
				}
			}
			if(yolk_stage == YolkStage.CLOSING){
				yolk_open -= Time.deltaTime * 5.0f;
				if(yolk_open <= 0.0f){
					yolk_open = 0.0f;
					yolk_stage = YolkStage.CLOSED;
					PlaySoundFromGroup(sound_cylinder_close, kGunMechanicVolume * 2.0f);
					target_cylinder_offset = 0;
				}
			}
			if(yolk_stage == YolkStage.OPENING){
				yolk_open += Time.deltaTime * 5.0f;
				if(yolk_open >= 1.0f){
					yolk_open = 1.0f;
					yolk_stage = YolkStage.OPEN;
					PlaySoundFromGroup(sound_cylinder_open, kGunMechanicVolume * 2.0f);
				}
			}
			if(extractor_rod_stage == ExtractorRodStage.CLOSING){
				extractor_rod_amount -= Time.deltaTime * 10.0f;
				if(extractor_rod_amount <= 0.0f){
					extractor_rod_amount = 0.0f;
					extractor_rod_stage = ExtractorRodStage.CLOSED;
					PlaySoundFromGroup(sound_extractor_rod_close, kGunMechanicVolume);
				}
				for(var i=0; i<cylinder_capacity; ++i){
					if(cylinders[i]._object){
						cylinders[i].falling = false;
					}
				}
			}
			if(extractor_rod_stage == ExtractorRodStage.OPENING){
				var old_extractor_rod_amount= extractor_rod_amount;
				extractor_rod_amount += Time.deltaTime * 10.0f;
				if(extractor_rod_amount >= 1.0f){
					if(!extracted){
						for(var i=0; i<cylinder_capacity; ++i){
							if(cylinders[i]._object){
								if(Random.Range(0.0f,3.0f) > cylinders[i].seated){
									cylinders[i].falling = true;
									cylinders[i].seated -= Random.Range(0.0f,0.5f);
								} else {
									cylinders[i].falling = false;
								}
							}
						}
						extracted = true;
					}
					for(var i=0; i<cylinder_capacity; ++i){
						if(cylinders[i]._object && cylinders[i].falling){
							cylinders[i].seated -= Time.deltaTime * 5.0f;
							if(cylinders[i].seated <= 0.0f){
								var bullet= cylinders[i]._object;
								var rbody = bullet.AddComponent<Rigidbody>();
								bullet.transform.parent = null;
								rbody.interpolation = RigidbodyInterpolation.Interpolate;
								rbody.velocity = velocity;
								rbody.angularVelocity = new Vector3(Random.Range(-40.0f,40.0f),Random.Range(-40.0f,40.0f),Random.Range(-40.0f,40.0f));
								cylinders[i]._object = null;
								cylinders[i].can_fire = false;
							}
						}
					}
					extractor_rod_amount = 1.0f;
					extractor_rod_stage = ExtractorRodStage.OPEN;
					if(old_extractor_rod_amount < 1.0f){
						PlaySoundFromGroup(sound_extractor_rod_open, kGunMechanicVolume);
					}
				}
			}
			if(extractor_rod_stage == ExtractorRodStage.OPENING || extractor_rod_stage == ExtractorRodStage.OPEN){
				extractor_rod_stage = ExtractorRodStage.CLOSING;
			}
				
			var yolk_open_display= yolk_open;
			var extractor_rod_amount_display= extractor_rod_amount;
			if(disable_springs){
				yolk_open_display = Mathf.Floor(yolk_open_display + 0.5f);
				extractor_rod_amount_display = Mathf.Floor(extractor_rod_amount_display + 0.5f);
			}
			var yolk_pivot= transform.FindChild("yolk_pivot");
			yolk_pivot.localRotation = Quaternion.Slerp(yolk_pivot_rel_rot, 
				transform.FindChild("point_yolk_pivot_open").localRotation,
				yolk_open_display);
			var cylinder_assembly= yolk_pivot.FindChild("yolk").FindChild("cylinder_assembly");
			var eulerAngles = cylinder_assembly.localEulerAngles;
			eulerAngles.z = cylinder_rotation;
			cylinder_assembly.localEulerAngles = eulerAngles;
			var extractor_rod= cylinder_assembly.FindChild("extractor_rod");
			extractor_rod.localPosition = Vector3.Lerp(
				extractor_rod_rel_pos, 
				cylinder_assembly.FindChild("point_extractor_rod_extended").localPosition,
				extractor_rod_amount_display);	
		
			for(var i=0; i<cylinder_capacity; ++i){
				if(cylinders[i]._object){
					var name= "point_chamber_"+(i+1);
					var bullet_chamber= extractor_rod.FindChild(name);
					cylinders[i]._object.transform.position = bullet_chamber.position;
					cylinders[i]._object.transform.rotation = bullet_chamber.rotation;
					cylinders[i]._object.transform.localScale = transform.localScale;
				}
			}
		}
	}
Example #13
0
	public void  ReleaseHammer (){
		if(!has_hammer){
			return;
		}
		if((pressure_on_trigger != PressureState.NONE && safety_off == 1.0f) || hammer_cocked != 1.0f){
			thumb_on_hammer = Thumb.SLOW_LOWERING;
			trigger_pressed = 1.0f;
		} else {
			thumb_on_hammer = Thumb.OFF_HAMMER;
		}
	}
Example #14
0
	public void  PressureOnHammer (){
		if(!has_hammer){
			return;
		}
		thumb_on_hammer = Thumb.ON_HAMMER;
		if(gun_type == GunType.REVOLVER && yolk_stage != YolkStage.CLOSED){
			return;
		}
		CockHammer();
	}
Example #15
0
 private void SetPosition(Thumb thumb, double x, double y)
 {
     Canvas.SetTop(thumb, y - ThumbWidth / 2);
     Canvas.SetLeft(thumb, x - ThumbWidth / 2);
 }
Example #16
0
        /// <summary>
        /// 创建调节大小所需的控件
        /// </summary>
        void CreateResizeParts()
        {
            // 创建拖动手柄容器
            _grid = new Grid();
            _grid.RowDefinitions.Add(new RowDefinition {
                Height = GridLength.Auto
            });
            _grid.RowDefinitions.Add(new RowDefinition());
            _grid.RowDefinitions.Add(new RowDefinition {
                Height = GridLength.Auto
            });
            _grid.ColumnDefinitions.Add(new ColumnDefinition {
                Width = GridLength.Auto
            });
            _grid.ColumnDefinitions.Add(new ColumnDefinition());
            _grid.ColumnDefinitions.Add(new ColumnDefinition {
                Width = GridLength.Auto
            });

            // 创建拖动手柄
            Thumb topThumb = new Thumb()
            {
                Margin = new Thickness(0, -10, 0, 0)
            };

            topThumb.SetCursor(CoreCursorType.SizeNorthSouth);
            topThumb.DragStarted   += OnResizeStarted;
            topThumb.DragDelta     += OnTopDragDelta;
            topThumb.DragCompleted += OnResizeCompleted;
            Grid.SetRow(topThumb, 0);
            Grid.SetColumn(topThumb, 1);
            _grid.Children.Add(topThumb);

            Thumb leftThumb = new Thumb()
            {
                Margin = new Thickness(-10, 0, 0, 0)
            };

            leftThumb.SetCursor(CoreCursorType.SizeWestEast);
            leftThumb.DragStarted   += OnResizeStarted;
            leftThumb.DragDelta     += OnLeftDragDelta;
            leftThumb.DragCompleted += OnResizeCompleted;
            Grid.SetRow(leftThumb, 1);
            Grid.SetColumn(leftThumb, 0);
            _grid.Children.Add(leftThumb);

            Thumb rightThumb = new Thumb()
            {
                Margin = new Thickness(0, 0, -10, 5)
            };

            rightThumb.SetCursor(CoreCursorType.SizeWestEast);
            rightThumb.DragStarted   += OnResizeStarted;
            rightThumb.DragDelta     += OnRightDragDelta;
            rightThumb.DragCompleted += OnResizeCompleted;
            Grid.SetRow(rightThumb, 1);
            Grid.SetColumn(rightThumb, 2);
            _grid.Children.Add(rightThumb);

            Thumb bottomThumb = new Thumb()
            {
                Margin = new Thickness(0, 0, 5, -10)
            };

            bottomThumb.SetCursor(CoreCursorType.SizeNorthSouth);
            bottomThumb.DragStarted   += OnResizeStarted;
            bottomThumb.DragDelta     += OnBottomDragDelta;
            bottomThumb.DragCompleted += OnResizeCompleted;
            Grid.SetRow(bottomThumb, 2);
            Grid.SetColumn(bottomThumb, 1);
            _grid.Children.Add(bottomThumb);

            Thumb rightBottomThumb = new Thumb()
            {
                Margin = new Thickness(0, 0, -5, -5)
            };

            rightBottomThumb.SetCursor(CoreCursorType.SizeNorthwestSoutheast);
            rightBottomThumb.DragStarted   += OnResizeStarted;
            rightBottomThumb.DragDelta     += OnRightBottomDragDelta;
            rightBottomThumb.DragCompleted += OnResizeCompleted;
            Grid.SetRow(rightBottomThumb, 2);
            Grid.SetColumn(rightBottomThumb, 2);
            _grid.Children.Add(rightBottomThumb);
        }
Example #17
0
 public ThumbAutomationPeer(Thumb owner)
     : base(owner)
 {
 }
Example #18
0
 void HdrParser_onEventData(object sender, thialgou.lib.events.FrameEventDrawArgs e)
 {
     Thumb thumb = new Thumb(e.Id, e.Luma, e.ChromaU, e.ChromaV, e.Width, e.Height, e.Stride);
     m_Thumbs.Add(thumb);
 }
Example #19
0
        /// <summary>
        /// When overridden in a derived class, is invoked whenever application code or internal processes call <see cref="M:System.Windows.FrameworkElement.ApplyTemplate"/>.
        /// </summary>
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            minimizeButton = (Button)Template.FindName("MinimizeButton", this);
            maximizeButton = (Button)Template.FindName("MaximizeButton", this);
            closeButton    = (Button)Template.FindName("CloseButton", this);
            buttonsPanel   = (StackPanel)Template.FindName("ButtonsPanel", this);

            if (minimizeButton != null)
            {
                minimizeButton.Click += new RoutedEventHandler(minimizeButton_Click);
            }

            if (maximizeButton != null)
            {
                maximizeButton.Click += new RoutedEventHandler(maximizeButton_Click);
            }

            if (closeButton != null)
            {
                closeButton.Click += new RoutedEventHandler(closeButton_Click);
            }

            Thumb dragThumb = (Thumb)Template.FindName("DragThumb", this);

            if (dragThumb != null)
            {
                dragThumb.DragStarted += new DragStartedEventHandler(Thumb_DragStarted);
                dragThumb.DragDelta   += new DragDeltaEventHandler(dragThumb_DragDelta);

                dragThumb.MouseDoubleClick += (sender, e) =>
                {
                    if (this.Resizable)
                    {
                        if (WindowState == WindowState.Minimized)
                        {
                            minimizeButton_Click(null, null);
                        }
                        else if (WindowState == WindowState.Normal)
                        {
                            maximizeButton_Click(null, null);
                        }
                        else if (WindowState == WindowState.Maximized)
                        {
                            maximizeButton_Click(null, null);
                        }
                    }
                };
            }

            Thumb resizeLeft        = (Thumb)Template.FindName("ResizeLeft", this);
            Thumb resizeTopLeft     = (Thumb)Template.FindName("ResizeTopLeft", this);
            Thumb resizeTop         = (Thumb)Template.FindName("ResizeTop", this);
            Thumb resizeTopRight    = (Thumb)Template.FindName("ResizeTopRight", this);
            Thumb resizeRight       = (Thumb)Template.FindName("ResizeRight", this);
            Thumb resizeBottomRight = (Thumb)Template.FindName("ResizeBottomRight", this);
            Thumb resizeBottom      = (Thumb)Template.FindName("ResizeBottom", this);
            Thumb resizeBottomLeft  = (Thumb)Template.FindName("ResizeBottomLeft", this);

            if (resizeLeft != null)
            {
                resizeLeft.DragStarted += new DragStartedEventHandler(Thumb_DragStarted);
                resizeLeft.DragDelta   += new DragDeltaEventHandler(ResizeLeft_DragDelta);
            }

            if (resizeTop != null)
            {
                resizeTop.DragStarted += new DragStartedEventHandler(Thumb_DragStarted);
                resizeTop.DragDelta   += new DragDeltaEventHandler(ResizeTop_DragDelta);
            }

            if (resizeRight != null)
            {
                resizeRight.DragStarted += new DragStartedEventHandler(Thumb_DragStarted);
                resizeRight.DragDelta   += new DragDeltaEventHandler(ResizeRight_DragDelta);
            }

            if (resizeBottom != null)
            {
                resizeBottom.DragStarted += new DragStartedEventHandler(Thumb_DragStarted);
                resizeBottom.DragDelta   += new DragDeltaEventHandler(ResizeBottom_DragDelta);
            }

            if (resizeTopLeft != null)
            {
                resizeTopLeft.DragStarted += new DragStartedEventHandler(Thumb_DragStarted);

                resizeTopLeft.DragDelta += (sender, e) =>
                {
                    ResizeTop_DragDelta(null, e);
                    ResizeLeft_DragDelta(null, e);

                    Container.InvalidateSize();
                };
            }

            if (resizeTopRight != null)
            {
                resizeTopRight.DragStarted += new DragStartedEventHandler(Thumb_DragStarted);

                resizeTopRight.DragDelta += (sender, e) =>
                {
                    ResizeTop_DragDelta(null, e);
                    ResizeRight_DragDelta(null, e);

                    Container.InvalidateSize();
                };
            }

            if (resizeBottomRight != null)
            {
                resizeBottomRight.DragStarted += new DragStartedEventHandler(Thumb_DragStarted);

                resizeBottomRight.DragDelta += (sender, e) =>
                {
                    ResizeBottom_DragDelta(null, e);
                    ResizeRight_DragDelta(null, e);

                    Container.InvalidateSize();
                };
            }

            if (resizeBottomLeft != null)
            {
                resizeBottomLeft.DragStarted += new DragStartedEventHandler(Thumb_DragStarted);

                resizeBottomLeft.DragDelta += (sender, e) =>
                {
                    ResizeBottom_DragDelta(null, e);
                    ResizeLeft_DragDelta(null, e);

                    Container.InvalidateSize();
                };
            }

            MinimizeBoxValueChanged(this, new DependencyPropertyChangedEventArgs(MinimizeBoxProperty, true, MinimizeBox));
            MaximizeBoxValueChanged(this, new DependencyPropertyChangedEventArgs(MaximizeBoxProperty, true, MaximizeBox));
        }
 private void Thumb_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
 {
     isDragging = Thumb.CaptureMouse();
     ignoreJump = isDragging;
     thumbProg  = sliderProg;
 }
        private void Drag_Delta(object sender, DragDeltaEventArgs e)
        {
            Thumb thumb = e.OriginalSource as Thumb;

            if (thumb == null)
            {
                return;
            }
            Int32 DragDirection = -1;

            if (!Int32.TryParse((String)thumb.Tag, out DragDirection))
            {
                return;
            }
            double VerticalChange   = e.VerticalChange;
            double HorizontalChange = e.HorizontalChange;
            Double left             = Canvas.GetLeft(this);
            Double top    = Canvas.GetTop(this);
            Double width  = this.Width;
            Double height = this.Height;

            switch (DragDirection)
            {
            case 7:
                height = this.Height - VerticalChange < 1 ? 1 : this.Height - VerticalChange;
                top    = Canvas.GetTop(this) + (this.Height - height);
                width  = this.Width - HorizontalChange < 1 ? 1 : this.Width - HorizontalChange;
                left   = Canvas.GetLeft(this) + (this.Width - width);
                break;

            case 0:
                height = this.Height - VerticalChange < 1 ? 1 : this.Height - VerticalChange;
                top    = Canvas.GetTop(this) + (this.Height - height);
                break;

            case 1:
                height = this.Height - VerticalChange < 1 ? 1 : this.Height - VerticalChange;
                top    = Canvas.GetTop(this) + (this.Height - height);
                width  = this.Width + HorizontalChange;
                break;

            case 6:
                width = this.Width - HorizontalChange < 1 ? 1 : this.Width - HorizontalChange;
                left  = Canvas.GetLeft(this) + (this.Width - width);
                break;

            case 8:
                left = Canvas.GetLeft(this) + HorizontalChange;
                top  = Canvas.GetTop(this) + VerticalChange;

                //left = left < 0 ? 0 : left;
                //top = top < 0 ? 0 : top;
                break;

            case 2:
                width = this.Width + HorizontalChange;
                break;

            case 5:
                width  = this.Width - HorizontalChange < 1 ? 1 : this.Width - HorizontalChange;
                left   = Canvas.GetLeft(this) + (this.Width - width);
                height = this.Height + VerticalChange;
                break;

            case 4:
                height = this.Height + VerticalChange;
                break;

            case 3:
                width  = this.Width + HorizontalChange;
                height = this.Height + VerticalChange;
                break;

            default:
                break;
            }
            //if (top < 0)
            //{
            //    height = height - Math.Abs(top);
            //    top = 0;
            //}



            width       = width < 1 ? 1 : width;
            this.Width  = width;
            height      = height < 1 ? 1 : height;
            this.Height = height;
            Canvas.SetTop(this, top);
            Canvas.SetLeft(this, left);
            this.RaiseEvent(new RoutedEventArgs(OnDragDeltaEvent, this));
            //
            e.Handled = true;
        }
Example #22
0
 private void Thumb_Move(object sender, EventArgs e)
 {
     Thumb.Refresh();
     lblGraph.Refresh();
 }
 public abstract void DrawEditor(ref Thumb left, ref Thumb right, ref Rectangle rect, ref Canvas canvas, ref Button btn);
        /// <summary>
        /// Update the visual state of the control when its template is changed.
        /// </summary>
        protected override void OnApplyTemplate()
        {
            if (_outOfRangeContentContainer != null)
            {
                _outOfRangeContentContainer.PointerPressed  -= OutOfRangeContentContainer_PointerPressed;
                _outOfRangeContentContainer.PointerMoved    -= OutOfRangeContentContainer_PointerMoved;
                _outOfRangeContentContainer.PointerReleased -= OutOfRangeContentContainer_PointerReleased;
                _outOfRangeContentContainer.PointerExited   -= OutOfRangeContentContainer_PointerExited;
            }

            if (_minThumb != null)
            {
                _minThumb.DragCompleted -= Thumb_DragCompleted;
                _minThumb.DragDelta     -= MinThumb_DragDelta;
                _minThumb.DragStarted   -= MinThumb_DragStarted;
                _minThumb.KeyDown       -= MinThumb_KeyDown;
            }

            if (_maxThumb != null)
            {
                _maxThumb.DragCompleted -= Thumb_DragCompleted;
                _maxThumb.DragDelta     -= MaxThumb_DragDelta;
                _maxThumb.DragStarted   -= MaxThumb_DragStarted;
                _maxThumb.KeyDown       -= MaxThumb_KeyDown;
            }

            if (_containerCanvas != null)
            {
                _containerCanvas.SizeChanged -= ContainerCanvas_SizeChanged;
            }

            IsEnabledChanged -= RangeSelector_IsEnabledChanged;

            // Need to make sure the values can be set in XAML and don't overwrite each other
            VerifyValues();
            _valuesAssigned = true;

            _outOfRangeContentContainer = GetTemplateChild("OutOfRangeContentContainer") as Border;
            _activeRectangle            = GetTemplateChild("ActiveRectangle") as Rectangle;
            _minThumb        = GetTemplateChild("MinThumb") as Thumb;
            _maxThumb        = GetTemplateChild("MaxThumb") as Thumb;
            _containerCanvas = GetTemplateChild("ContainerCanvas") as Canvas;

            if (_outOfRangeContentContainer != null)
            {
                _outOfRangeContentContainer.PointerPressed  += OutOfRangeContentContainer_PointerPressed;
                _outOfRangeContentContainer.PointerMoved    += OutOfRangeContentContainer_PointerMoved;
                _outOfRangeContentContainer.PointerReleased += OutOfRangeContentContainer_PointerReleased;
                _outOfRangeContentContainer.PointerExited   += OutOfRangeContentContainer_PointerExited;
            }

            if (_minThumb != null)
            {
                _minThumb.DragCompleted += Thumb_DragCompleted;
                _minThumb.DragDelta     += MinThumb_DragDelta;
                _minThumb.DragStarted   += MinThumb_DragStarted;
                _minThumb.KeyDown       += MinThumb_KeyDown;
            }

            if (_maxThumb != null)
            {
                _maxThumb.DragCompleted += Thumb_DragCompleted;
                _maxThumb.DragDelta     += MaxThumb_DragDelta;
                _maxThumb.DragStarted   += MaxThumb_DragStarted;
                _maxThumb.KeyDown       += MaxThumb_KeyDown;
            }

            if (_containerCanvas != null)
            {
                _containerCanvas.SizeChanged    += ContainerCanvas_SizeChanged;
                _containerCanvas.PointerEntered += ContainerCanvas_PointerEntered;
                _containerCanvas.PointerExited  += ContainerCanvas_PointerExited;
            }

            VisualStateManager.GoToState(this, IsEnabled ? "Normal" : "Disabled", false);

            IsEnabledChanged += RangeSelector_IsEnabledChanged;

            base.OnApplyTemplate();
        }
Example #25
0
        private static void Thumb_DragCompleted(object sender, DragCompletedEventArgs e)
        {
            Thumb thumb = (Thumb)sender;

            thumb.Cursor = null;
        }
Example #26
0
    void Start()
    {
        hand         = this.gameObject;
        thumb        = new Thumb();
        indexFinger  = new Finger();
        middleFinger = new Finger();
        ringFinger   = new Finger();
        littleFinger = new Finger();

        if (whichHand == WhichHands.Left)
        {
            thumb.transform        = animator.GetBoneTransform((HumanBodyBones)LeftHandBones.ThumbIntermediate);
            indexFinger.transform  = animator.GetBoneTransform((HumanBodyBones)LeftHandBones.IndexProximal);
            middleFinger.transform = animator.GetBoneTransform((HumanBodyBones)LeftHandBones.MiddleProximal);
            ringFinger.transform   = animator.GetBoneTransform((HumanBodyBones)LeftHandBones.RingProximal);
            littleFinger.transform = animator.GetBoneTransform((HumanBodyBones)LeftHandBones.LittleProximal);

            shoulder = animator.GetBoneTransform(HumanBodyBones.LeftUpperArm);
        }
        else
        {
            thumb.transform        = animator.GetBoneTransform((HumanBodyBones)RightHandBones.ThumbIntermediate);
            indexFinger.transform  = animator.GetBoneTransform((HumanBodyBones)RightHandBones.IndexProximal);
            middleFinger.transform = animator.GetBoneTransform((HumanBodyBones)RightHandBones.MiddleProximal);
            ringFinger.transform   = animator.GetBoneTransform((HumanBodyBones)RightHandBones.RingProximal);
            littleFinger.transform = animator.GetBoneTransform((HumanBodyBones)RightHandBones.LittleProximal);

            shoulder = animator.GetBoneTransform(HumanBodyBones.RightUpperArm);
        }

        GameObject x = new GameObject("Hand Palm");

        x.transform.position = hand.transform.position;
        x.transform.LookAt(indexFinger.transform.transform, Vector3.up);
        Vector3 handRightAxis = hand.transform.InverseTransformDirection(x.transform.right);

        palmOffset  = (indexFinger.transform.transform.position - hand.transform.position) * 0.85f;
        palmOffset  = hand.transform.InverseTransformDirection(palmOffset);
        palmOffset += new Vector3(0, 0, -0.03f);         // to get it into the hand palm HACK

        x.transform.parent = hand.transform;

        if (handTarget.childCount > 0)
        {
            cHandTarget = handTarget.GetChild(0);             // retrieves the palm target
        }
        else
        {
            GameObject cHandTargetGO = new GameObject();
            cHandTargetGO.name                     = "Corrected Target";
            cHandTarget                            = cHandTargetGO.transform;
            cHandTarget.transform.parent           = handTarget;
            cHandTarget.transform.localPosition    = Vector3.zero;
            cHandTarget.transform.localEulerAngles = Vector3.zero;
            cHandTarget.transform.localScale       = new Vector3(1, 1, 1);
        }

        digits    = new Digit[5];
        digits[0] = thumb;
        digits[1] = indexFinger;
        digits[2] = middleFinger;
        digits[3] = ringFinger;
        digits[4] = littleFinger;

        thumb.Init(hand, handRightAxis, whichHand);
        for (int i = 1; i < digits.Length; i++)
        {
            digits[i].Init(hand, handRightAxis, whichHand);
        }

        MakeTrigger(handTarget.gameObject);
    }
Example #27
0
        private static void Thumb_DragStarted(object sender, DragStartedEventArgs e)
        {
            Thumb thumb = (Thumb)sender;

            thumb.Cursor = Cursors.Hand;
        }
Example #28
0
 public ResizingAdorner(UIElement adornedElement)
     : base(adornedElement)
 {
     visualChildren = new VisualCollection(this);
     bottomRight    = BuildAdornerCorner(Cursors.SizeNWSE, HandleBottomRight);
 }
        private void CreatePopupWindow(object viewModel, string type)
        {
            var thumb = new Thumb {
                Width = 0, Height = 0
            };
            object vm;

            if (type == "map")
            {
                vm = viewModel as MapViewModel;
            }
            else
            {
                vm = viewModel as PlotViewModel;
            }
            if (vm == null)
            {
                return;
            }
            object duplicateView;

            if (type == "map")
            {
                duplicateView = new MapView {
                    DataContext         = vm,
                    HorizontalAlignment = HorizontalAlignment.Stretch,
                    VerticalAlignment   = VerticalAlignment.Stretch,
                    Margin   = new Thickness(0, 0, 3, 0),
                    MapImage =
                    {
                        HorizontalAlignment = HorizontalAlignment.Stretch,
                        VerticalAlignment   = VerticalAlignment.Stretch,
                        Stretch             = Stretch.Uniform,
                        Margin              = new Thickness(0,0, 10, 0)
                    }
                };
            }
            else
            {
                duplicateView = new PlotView {
                    DataContext         = vm,
                    HorizontalAlignment = HorizontalAlignment.Stretch,
                    VerticalAlignment   = VerticalAlignment.Stretch,
                    Margin    = new Thickness(0, 0, 3, 0),
                    MinHeight = 600
                };
            }
            var viewBorder = new Border {
                Background      = Brushes.White,
                CornerRadius    = new CornerRadius(0),
                BorderThickness = new Thickness(2),
                BorderBrush     = Brushes.Gray
            };
            var viewPanel   = new StackPanel();
            var closeButton = new Button {
                Content             = "X",
                HorizontalAlignment = HorizontalAlignment.Right,
                VerticalAlignment   = VerticalAlignment.Top,
                Margin = new Thickness(5),
                Width  = 25,
                Height = 25
            };

            viewPanel.Children.Add(closeButton);
            viewPanel.Children.Add((UIElement)duplicateView);
            viewPanel.Children.Add(thumb);
            viewBorder.Child = viewPanel;
            //Popup behavior is to always be on top so we need to find another solution for this control
            var newViewWindow = new Popup {
                Name                = "wndView" + _numViews++,
                Child               = viewBorder,
                VerticalAlignment   = VerticalAlignment.Top,
                HorizontalAlignment = HorizontalAlignment.Left,
                Placement           = PlacementMode.Relative,
                IsOpen              = true,
                AllowsTransparency  = true
            };

            closeButton.Click += (sender, e) => { newViewWindow.IsOpen = false; };

            newViewWindow.MouseDown += (sender, e) => {
                if (e.ChangedButton != MouseButton.Left)
                {
                    return;
                }
                var popupWindow = (Popup)sender;
                Topmost = false;
                popupWindow.Focus();
                thumb.RaiseEvent(e);
            };

            thumb.DragDelta += (sender, e) => {
                newViewWindow.HorizontalOffset += e.HorizontalChange;
                newViewWindow.VerticalOffset   += e.VerticalChange;
            };
        }
Example #30
0
        /// <summary>
        /// When overridden in a derived class, is invoked whenever application code or internal processes call <see cref="M:System.Windows.FrameworkElement.ApplyTemplate"/>.
        /// </summary>
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            object objMinimizedWidth   = TryFindResource("WindowMinimized_Width");
            object objMinimized_Height = TryFindResource("WindowMinimized_Height");

            if (objMinimizedWidth != null)
            {
                MinimizedWidth = (double)objMinimizedWidth;
            }

            if (objMinimized_Height != null)
            {
                MinimizedHeight = (double)objMinimized_Height;
            }

            minimizeButton = (Button)Template.FindName("MinimizeButton", this);
            maximizeButton = (Button)Template.FindName("MaximizeButton", this);
            closeButton    = (Button)Template.FindName("CloseButton", this);
            buttonsPanel   = (StackPanel)Template.FindName("ButtonsPanel", this);

            if (minimizeButton != null)
            {
                minimizeButton.Click += minimizeButton_Click;
            }

            if (maximizeButton != null)
            {
                maximizeButton.Click += maximizeButton_Click;
            }

            if (closeButton != null)
            {
                closeButton.Click += closeButton_Click;
            }

            Thumb dragThumb = (Thumb)Template.FindName("DragThumb", this);

            if (dragThumb != null)
            {
                dragThumb.DragStarted += Thumb_DragStarted;
                dragThumb.DragDelta   += dragThumb_DragDelta;

                dragThumb.MouseDoubleClick += (sender, e) =>
                {
                    if (WindowState == WindowState.Minimized)
                    {
                        minimizeButton_Click(null, null);
                    }
                    else if (WindowState == WindowState.Normal)
                    {
                        maximizeButton_Click(null, null);
                    }
                };
            }

            Thumb resizeLeft        = (Thumb)Template.FindName("ResizeLeft", this);
            Thumb resizeTopLeft     = (Thumb)Template.FindName("ResizeTopLeft", this);
            Thumb resizeTop         = (Thumb)Template.FindName("ResizeTop", this);
            Thumb resizeTopRight    = (Thumb)Template.FindName("ResizeTopRight", this);
            Thumb resizeRight       = (Thumb)Template.FindName("ResizeRight", this);
            Thumb resizeBottomRight = (Thumb)Template.FindName("ResizeBottomRight", this);
            Thumb resizeBottom      = (Thumb)Template.FindName("ResizeBottom", this);
            Thumb resizeBottomLeft  = (Thumb)Template.FindName("ResizeBottomLeft", this);

            if (resizeLeft != null)
            {
                resizeLeft.DragStarted += Thumb_DragStarted;
                resizeLeft.DragDelta   += ResizeLeft_DragDelta;
            }

            if (resizeTop != null)
            {
                resizeTop.DragStarted += Thumb_DragStarted;
                resizeTop.DragDelta   += ResizeTop_DragDelta;
            }

            if (resizeRight != null)
            {
                resizeRight.DragStarted += Thumb_DragStarted;
                resizeRight.DragDelta   += ResizeRight_DragDelta;
            }

            if (resizeBottom != null)
            {
                resizeBottom.DragStarted += Thumb_DragStarted;
                resizeBottom.DragDelta   += ResizeBottom_DragDelta;
            }

            if (resizeTopLeft != null)
            {
                resizeTopLeft.DragStarted += Thumb_DragStarted;

                resizeTopLeft.DragDelta += (sender, e) =>
                {
                    ResizeTop_DragDelta(null, e);
                    ResizeLeft_DragDelta(null, e);

                    Container.InvalidateSize();
                };
            }

            if (resizeTopRight != null)
            {
                resizeTopRight.DragStarted += Thumb_DragStarted;

                resizeTopRight.DragDelta += (sender, e) =>
                {
                    ResizeTop_DragDelta(null, e);
                    ResizeRight_DragDelta(null, e);

                    Container.InvalidateSize();
                };
            }

            if (resizeBottomRight != null)
            {
                resizeBottomRight.DragStarted += Thumb_DragStarted;

                resizeBottomRight.DragDelta += (sender, e) =>
                {
                    ResizeBottom_DragDelta(null, e);
                    ResizeRight_DragDelta(null, e);

                    Container.InvalidateSize();
                };
            }

            if (resizeBottomLeft != null)
            {
                resizeBottomLeft.DragStarted += Thumb_DragStarted;

                resizeBottomLeft.DragDelta += (sender, e) =>
                {
                    ResizeBottom_DragDelta(null, e);
                    ResizeLeft_DragDelta(null, e);

                    Container.InvalidateSize();
                };
            }

            MinimizeBoxValueChanged(this, new DependencyPropertyChangedEventArgs(MinimizeBoxProperty, true, MinimizeBox));
            MaximizeBoxValueChanged(this, new DependencyPropertyChangedEventArgs(MaximizeBoxProperty, true, MaximizeBox));
            CloseBoxValueChanged(this, new DependencyPropertyChangedEventArgs(CloseBoxProperty, true, CloseBox));
        }
Example #31
0
 public static bool GetThumbCanBeDragged(Thumb el)
 {
     return((bool)el.GetValue(ThumbCanBeDraggedProperty));
 }
        public ComposingAdorner2(UIElement adornedElement, Maniglie qualiManiglie) : base(adornedElement)
        {
            visualChildren = new VisualCollection(this);

            // --- GRUPPO
            transformGroup = adornedElement.RenderTransform as TransformGroup;
            if (transformGroup == null)
            {
                transformGroup = new TransformGroup();
            }

            // --- ROTAZIONE
            if (qualiManiglie == Maniglie.All || (qualiManiglie & Maniglie.Rotate) == Maniglie.Rotate)
            {
                rotateHandle        = new Thumb();
                rotateHandle.Cursor = Cursors.Hand;
                rotateHandle.Width  = HANDLESIZE;
                rotateHandle.Height = HANDLESIZE;

                rotateHandle.Background     = Brushes.Blue;
                rotateHandle.DragStarted   += rotateHandle_DragStarted;
                rotateHandle.DragDelta     += rotateHandle_DragDelta;
                rotateHandle.DragCompleted += rotateHandle_DragCompleted;

                //
                rotateTfx = initRotateBinding();
                transformGroup.Children.Add(rotateTfx);
            }

            // --- FLIP SPECCHIO
            if (qualiManiglie == Maniglie.All || (qualiManiglie & Maniglie.Flip) == Maniglie.Flip)
            {
                flipHandle                   = new Thumb();
                flipHandle.Cursor            = Cursors.Hand;
                flipHandle.Width             = 20;
                flipHandle.Height            = 20;
                flipHandle.MinWidth          = 20;
                flipHandle.MinHeight         = 20;
                flipHandle.Background        = Brushes.Orange;
                flipHandle.PreviewMouseDown += new MouseButtonEventHandler(flipHandle_MouseDown);
            }

            // --- MOVE SPOSTA TRASLA
            if (qualiManiglie == Maniglie.All || (qualiManiglie & Maniglie.Move) == Maniglie.Move)
            {
                moveHandle            = new Thumb();
                moveHandle.Cursor     = Cursors.SizeAll;
                moveHandle.Width      = double.NaN;             // grande quanto tutta la foto
                moveHandle.Height     = double.NaN;             // grande quanto tutta la foto
                moveHandle.Background = Brushes.Transparent;
                moveHandle.Opacity    = 0;

                moveHandle.DragDelta            += new DragDeltaEventHandler(moveHandle_DragDelta);
                moveHandle.DragStarted          += new DragStartedEventHandler(moveHandle_DragStarted);
                moveHandle.DragCompleted        += new DragCompletedEventHandler(moveHandle_DragCompleted);
                moveHandle.MouseRightButtonDown += new MouseButtonEventHandler(moveHandle_PreviewMouseRightButtonDown);
                moveHandle.PreviewMouseWheel    += moveHandle_PreviewMouseWheel;

                //
                translateTfx = initTransformBinding();
                transformGroup.Children.Add(translateTfx);
            }

            // --- SCALE ZOOM
            if (qualiManiglie == Maniglie.All || (qualiManiglie & Maniglie.Scale) == Maniglie.Scale)
            {
                scaleHandle            = new Thumb();
                scaleHandle.Cursor     = Cursors.SizeNS;
                scaleHandle.Width      = 20;
                scaleHandle.Height     = 20;
                scaleHandle.MinWidth   = 20;
                scaleHandle.MinHeight  = 20;
                scaleHandle.Background = Brushes.Green;

                scaleHandle.DragStarted   += scaleHandle_DragStarted;
                scaleHandle.DragDelta     += scaleHandle_DragDelta;
                scaleHandle.DragCompleted += scaleHandle_DragCompleted;

                //
                scaleFactor = 1;
                scaleTfx    = initScaleBinding();
                // TODO vedremo
                // scaleRotella = new ScaleTransform();

                transformGroup.Children.Add(scaleTfx);
            }


            // ---
            outline = new Path();

            outline.Stroke          = Brushes.Blue;
            outline.StrokeThickness = 1;

            visualChildren.Add(outline);

            if (rotateHandle != null)
            {
                visualChildren.Add(rotateHandle);
            }
            if (moveHandle != null)
            {
                visualChildren.Add(moveHandle);
            }
            if (scaleHandle != null)
            {
                visualChildren.Add(scaleHandle);
            }
            if (flipHandle != null)
            {
                visualChildren.Add(flipHandle);
            }

            adornedElement.RenderTransform = transformGroup;
        }
Example #33
0
 public static void SetThumbCanBeDragged(Thumb el, bool value)
 {
     el.SetValue(ThumbCanBeDraggedProperty, value);
 }
Example #34
0
 /// <summary>
 /// <see cref="DragablzItem" /> templates contain a thumb, which is used to drag the item around.
 /// For most scenarios this is fine, but by setting this flag to <value>true</value> you can define
 /// a custom thumb in your content, without having to override the template.  This can be useful if you
 /// have extra content; such as a custom button that you want the user to be able to interact with (as usually
 /// the default thumb will handle mouse interaction).
 /// </summary>
 public static void SetIsCustomThumb(Thumb element, bool value)
 {
     element.SetValue(IsCustomThumbProperty, value);
 }
Example #35
0
        private void Thumb_OnDragCompleted(object sender, DragCompletedEventArgs e)
        {
            Thumb thumb = (Thumb)sender;

            this.UpdateNavigatorForThumbChange(thumb);
        }
    void Start()
    {
        hand = this.gameObject;
        thumb = new Thumb();
        indexFinger = new Finger();
        middleFinger = new Finger();
        ringFinger = new Finger();
        littleFinger = new Finger();

        if (whichHand == WhichHands.Left) {
            thumb.transform = animator.GetBoneTransform((HumanBodyBones) LeftHandBones.ThumbIntermediate);
            indexFinger.transform = animator.GetBoneTransform((HumanBodyBones) LeftHandBones.IndexProximal);
            middleFinger.transform = animator.GetBoneTransform((HumanBodyBones) LeftHandBones.MiddleProximal);
            ringFinger.transform = animator.GetBoneTransform((HumanBodyBones) LeftHandBones.RingProximal);
            littleFinger.transform = animator.GetBoneTransform((HumanBodyBones) LeftHandBones.LittleProximal);

            shoulder = animator.GetBoneTransform(HumanBodyBones.LeftUpperArm);

        } else {
            thumb.transform = animator.GetBoneTransform((HumanBodyBones) RightHandBones.ThumbIntermediate);
            indexFinger.transform = animator.GetBoneTransform((HumanBodyBones) RightHandBones.IndexProximal);
            middleFinger.transform = animator.GetBoneTransform((HumanBodyBones) RightHandBones.MiddleProximal);
            ringFinger.transform = animator.GetBoneTransform((HumanBodyBones) RightHandBones.RingProximal);
            littleFinger.transform = animator.GetBoneTransform((HumanBodyBones) RightHandBones.LittleProximal);

            shoulder = animator.GetBoneTransform(HumanBodyBones.RightUpperArm);
        }

        GameObject x = new GameObject("Hand Palm");
        x.transform.position = hand.transform.position;
        x.transform.LookAt(indexFinger.transform.transform, Vector3.up);
        Vector3 handRightAxis = hand.transform.InverseTransformDirection(x.transform.right);

        palmOffset = (indexFinger.transform.transform.position - hand.transform.position) * 0.85f;
        palmOffset = hand.transform.InverseTransformDirection(palmOffset);
        palmOffset += new Vector3(0, 0, -0.03f); // to get it into the hand palm HACK

        x.transform.parent = hand.transform;

        if (handTarget.childCount > 0) {
            cHandTarget = handTarget.GetChild(0); // retrieves the palm target
        } else {
            GameObject cHandTargetGO = new GameObject();
            cHandTargetGO.name = "Corrected Target";
            cHandTarget = cHandTargetGO.transform;
            cHandTarget.transform.parent = handTarget;
            cHandTarget.transform.localPosition = Vector3.zero;
            cHandTarget.transform.localEulerAngles = Vector3.zero;
            cHandTarget.transform.localScale = new Vector3(1, 1, 1);
        }

        digits = new Digit[5];
        digits[0] = thumb;
        digits[1] = indexFinger;
        digits[2] = middleFinger;
        digits[3] = ringFinger;
        digits[4] = littleFinger;

        thumb.Init (hand, handRightAxis, whichHand);
        for (int i = 1; i < digits.Length; i++)
            digits[i].Init(hand, handRightAxis, whichHand);

        MakeTrigger(handTarget.gameObject);
    }
Example #37
0
        void InitRangeSlider()
        {
            try
            {
                (this.GetTemplateChild(HoriontalTemplate) as Grid).Visibility = this.Orientation == Orientation.Vertical ? Visibility.Collapsed : Visibility.Visible;
                (this.GetTemplateChild(VerticalTemplate) as Grid).Visibility  = this.Orientation == Orientation.Vertical ? Visibility.Visible : Visibility.Collapsed;
                thumbFrom   = this.Orientation == Orientation.Vertical ? this.GetTemplateChild(thumbVerticalFrom) as Thumb : this.GetTemplateChild(thumbHoriontalFrom) as Thumb;
                thumbTo     = this.Orientation == Orientation.Vertical ? this.GetTemplateChild(thumbVerticalTo) as Thumb : this.GetTemplateChild(thumbHoriontalTo) as Thumb;
                fromLength  = this.Orientation == Orientation.Vertical ? this.thumbFrom.Height : this.thumbFrom.Width;
                toLength    = this.Orientation == Orientation.Vertical ? this.thumbTo.Height : this.thumbTo.Width;
                totalLength = this.Orientation == Orientation.Vertical ? this.Height : this.Width;
            }
            catch { }
            totalValue = FromThumbVisbilty == Visibility.Visible ? totalLength - fromLength - toLength - toLength / 2 : totalLength - toLength;

            if ((this.Maximum - this.Minimum) >= 0)
            {
                perValue = totalValue / (this.Maximum - this.Minimum);
                if (FromThumbVisbilty == Visibility.Collapsed)
                {
                    RangeFrom = 0;
                    RangeTo   = perValue * (this.Maximum - this.Value) + toLength;
                }
                else
                {
                    RangeFrom = perValue * (FromValue - this.Minimum) + fromLength;
                    RangeTo   = perValue * (this.Maximum - Value) + toLength;
                }
            }

            MinValue = FromValue.ToString();
            MaxValue = Value.ToString();
            if (thumbFrom != null)
            {
                thumbFrom.ManipulationStarted   += fromThumb_ManipulationStarted;
                thumbFrom.ManipulationDelta     += fromThumb_ManipulationDelta;
                thumbFrom.PointerEntered        += thumbFrom_PointerEntered;
                thumbFrom.ManipulationCompleted += thumbFrom_ManipulationCompleted;
                thumbFrom.LostFocus             += thumbTo_LostFocus;
                thumbFrom.PointerExited         += thumbTo_PointerExited;
            }
            if (thumbTo != null)
            {
                thumbTo.ManipulationStarted   += thumbTo_ManipulationStarted;
                thumbTo.ManipulationDelta     += thumbTo_ManipulationDelta;
                thumbTo.PointerEntered        += thumbTo_PointerEntered;
                thumbTo.ManipulationCompleted += thumbFrom_ManipulationCompleted;
                thumbTo.LostFocus             += thumbTo_LostFocus;
                thumbTo.PointerExited         += thumbTo_PointerExited;
            }

            try
            {
                Grid      rectLeftHoriontal  = this.GetTemplateChild(gridLeftHoriontal) as Grid;
                Rectangle MiddleHoriontal    = this.GetTemplateChild(rectMiddleHoriontal) as Rectangle;
                Grid      rectRightHoriontal = this.GetTemplateChild(gridRightHoriontal) as Grid;
                Grid      rectLeftVertical   = this.GetTemplateChild(gridLeftVertical) as Grid;
                Rectangle MiddleVertical     = this.GetTemplateChild(rectMiddleVertical) as Rectangle;
                Grid      rectRightVertical  = this.GetTemplateChild(gridRightVertical) as Grid;

                rectLeftHoriontal.Tapped  += rect_Tapped;
                MiddleHoriontal.Tapped    += rect_Tapped;
                rectRightHoriontal.Tapped += rect_Tapped;
                rectLeftVertical.Tapped   += rect_Tapped;
                MiddleVertical.Tapped     += rect_Tapped;
                rectRightVertical.Tapped  += rect_Tapped;
            }
            catch { }
        }