Esempio n. 1
0
        void marker_ManipulationDelta(object sender, Windows.UI.Xaml.Input.ManipulationDeltaRoutedEventArgs e)
        {
            if (Owner is RadialScale)
            {
                RadialScale rs = (RadialScale)Owner;
                //Debug.WriteLine("radial angle: " + rs.GetAngleFromValue(Value));
                GetAngle(this.Center, rs.Center);
                // this.Angle = GetAngle(e.Position, this.RenderSize);
                double radius            = rs.GetIndicatorRadius();
                double diameter          = radius * 2;
                Size   rsSize            = new Size(diameter, radius);
                Point  radialScaleAbsPos = (((UIElement)rs).TransformToVisual((Frame)Window.Current.Content) as GeneralTransform).TransformPoint(new Point(0, 0));
                //Debug.WriteLine("position: " + e.Position + " size: " + rsSize + " center: " + RadialScaleHelper.GetCenterPosition(rs.RadialType, rsSize, rs.MinAngle, rs.MaxAngle, rs.SweepDirection) + " angle: " + GetAngle(e.Position, new Size(diameter, diameter)));

                //Debug.WriteLine("angle: " + GetAngle(this.Center, rs.Center));
                //Debug.WriteLine("Final Val: " + rs.GetValueFromAngle(GetAngle(this.Center.Add(e.Cumulative.Translation), rs.Center)));
                Value = rs.GetValueFromAngle(GetAngle(this.Center.Add(e.Position), rs.Center));
            }
        }
Esempio n. 2
0
 // Sets the indicator geometry based on the scale and the current value
 private void SetIndicatorGeometry(RadialScale scale, double value)
 {
     if (thePath != null)
     {
         double min = scale.MinAngle;
         double max = scale.GetAngleFromValue(Value);
         if (scale.SweepDirection == SweepDirection.Counterclockwise)
         {
             min = -min;
             max = -max;
         }
         double rad = scale.GetIndicatorRadius();
         if (rad > BarThickness)
         {
             Geometry geom = RadialScaleHelper.CreateArcGeometry(min, max, rad, BarThickness, scale.SweepDirection);
             // Stop the recursive loop. Only set a new geometry if it is different from the current one
             if (thePath.Data == null || thePath.Data.Bounds != geom.Bounds)
             {
                 thePath.Data = geom;
             }
         }
     }
 }
Esempio n. 3
0
        private void PositionMarker()
        {
            if (Owner == null)
            {
                return;
            }
            if (Owner is RadialScale)
            {
                RadialScale rs = (RadialScale)Owner;
                // Get the angle based on the value
                double angle = rs.GetAngleFromValue(Value);
                if (rs.SweepDirection == SweepDirection.Counterclockwise)
                {
                    angle = -angle;
                }
                // Rotate the marker by angle
                TransformGroup tg = RenderTransform as TransformGroup;
                if (tg != null)
                {
                    RotateTransform rt = tg.Children[0] as RotateTransform;
                    if (rt != null)
                    {
                        rt.Angle = angle;
                    }
                }
                // Position the marker based on the radius
                Point  offset = rs.GetIndicatorOffset();
                double rad    = rs.GetIndicatorRadius();

                //position the marker
                double px = offset.X + (rad - DesiredSize.Height / 2) * Math.Sin(angle * Math.PI / 180);
                double py = offset.Y - (rad - DesiredSize.Height / 2) * Math.Cos(angle * Math.PI / 180);

                // Cache the intended position of the Indicator before it's centered
                this.Center = new Point(px, py);

                // Subtract the width of the Indicator's size so that it looks centered
                px -= DesiredSize.Width / 2;
                py -= DesiredSize.Height / 2;
                if (tg != null)
                {
                    TranslateTransform tt = tg.Children[1] as TranslateTransform;
                    if (tt != null)
                    {
                        tt.X = px;
                        tt.Y = py;
                    }
                }
            }
            //else
            //{
            //    LinearScale ls = Owner as LinearScale;
            //    Point offset = ls.GetIndicatorOffset(this);
            //    //the getIndicatorOffset returns only one correct dimension
            //    //for marker indicators the other dimension will have to be calculated again
            //    if (ls.Orientation == Orientation.Horizontal)
            //    {
            //        offset.X = ls.ActualWidth * (Value - ls.Minimum) / (ls.Maximum - ls.Minimum) - DesiredSize.Width / 2;
            //    }
            //    else
            //    {
            //        offset.Y = ls.ActualHeight - ls.ActualHeight * (Value - ls.Minimum) / (ls.Maximum - ls.Minimum) - DesiredSize.Height / 2;
            //    }
            //    TransformGroup tg = RenderTransform as TransformGroup;
            //    if (tg != null)
            //    {
            //        TranslateTransform tt = tg.Children[1] as TranslateTransform;
            //        if (tt != null)
            //        {
            //            tt.X = offset.X;
            //            tt.Y = offset.Y;
            //        }
            //    }
            //}
        }
Esempio n. 4
0
 // Sets the indicator geometry based on the scale and the current value
 private void SetIndicatorGeometry(RadialScale scale, double value)
 {
     if (thePath != null)
     {
         double min = scale.MinAngle;
         double max = scale.GetAngleFromValue(Value);
         if (scale.SweepDirection == SweepDirection.Counterclockwise)
         {
             min = -min;
             max = -max;
         }
         double rad = scale.GetIndicatorRadius();
         if (rad > BarThickness)
         {
             Geometry geom = RadialScaleHelper.CreateArcGeometry(min, max, rad, BarThickness, scale.SweepDirection);
             // Stop the recursive loop. Only set a new geometry if it is different from the current one
             if (thePath.Data == null || thePath.Data.Bounds != geom.Bounds)
             {
                 thePath.Data = geom;
             }
         }
     }
 }