private void PerformLayout(object sender, RoutedEventArgs e)
        {
            Point  currentPosition = RenderTransform.Transform(new Point(0.0, 0.0));
            double onScreenState   = (currentPosition.Y - m_yPosInactive) / (m_yPosActive - m_yPosInactive);

            MainWindow mainWindow   = (MainWindow)Application.Current.MainWindow;
            double     screenHeight = mainWindow.ActualHeight;
            double     screenWidth  = mainWindow.ActualWidth;
            double     viewHeight   = ActualHeight;
            double     viewWidth    = ActualWidth;

            m_yPosActive   = screenHeight * 0.5 - (viewHeight * 0.5 + ConversionHelpers.AndroidToWindowsDip(16));
            m_yPosInactive = screenHeight * 0.5 + viewHeight * 0.5;
            double layoutY = m_yPosInactive;

            if (!m_isFirstLayout)
            {
                layoutY = onScreenState * (m_yPosActive - m_yPosInactive) + m_yPosInactive;
            }

            m_isFirstLayout = false;

            var transform = new TranslateTransform(
                -(viewWidth * 0.5 + ConversionHelpers.AndroidToWindowsDip(32)),
                layoutY);

            RenderTransform = transform;
        }
Ejemplo n.º 2
0
        public void UpdateHeading(float headingAngleRadians)
        {
            float verticalPointOffsetPx = ((float)m_compassPoint.Height * 0.5f) + 7.0f;
            float theta    = -headingAngleRadians;
            float sinTheta = (float)Math.Sin(theta);
            float cosTheta = (float)Math.Cos(theta);
            float x        = (float)(-m_compassPoint.Width * 0.5);
            float y        = (float)ConversionHelpers.AndroidToWindowsDip(-verticalPointOffsetPx);
            float newX     = x * cosTheta - y * sinTheta;
            float newY     = y * cosTheta + x * sinTheta;

            var translateTransform = new TranslateTransform(
                m_compassPointOffsetX + newX,
                m_compassPointOffsetY + newY);

            var rotateTransform = new RotateTransform(
                -headingAngleRadians * 180 / Math.PI);

            var transformGroup = new TransformGroup();

            transformGroup.Children.Add(rotateTransform);
            transformGroup.Children.Add(translateTransform);

            m_compassPoint.RenderTransform = transformGroup;
            m_compassPoint.Visibility      = Visibility.Visible;
        }
Ejemplo n.º 3
0
        private void UpdateOrientationTransform(float headingAngleRadians)
        {
            float verticalPointOffsetPx = ((float)m_compassNew.Height * 0.5f) + 7.0f;
            float theta    = -headingAngleRadians;
            float sinTheta = (float)Math.Sin(theta);
            float cosTheta = (float)Math.Cos(theta);
            float x        = (float)(-m_compassNew.Width * 0.5);
            float y        = (float)ConversionHelpers.AndroidToWindowsDip(-verticalPointOffsetPx);
            float newX     = cosTheta * sinTheta;
            float newY     = cosTheta * sinTheta;

            m_translateTransform.X = m_compassPointOffsetX + newX;
            m_translateTransform.Y = m_compassPointOffsetY + newY;

            m_rotateTransform.Angle = Rad2Deg(-headingAngleRadians);
        }
        private void PerformLayout(object sender, RoutedEventArgs e)
        {
            Point currentPosition = RenderTransform.Transform(new Point(0.0, 0.0));

            MainWindow   mainWindow   = (MainWindow)Application.Current.MainWindow;
            double       screenHeight = mainWindow.MainGrid.ActualHeight;
            double       screenWidth  = mainWindow.MainGrid.ActualWidth;
            double       viewHeight   = ActualHeight;
            double       viewWidth    = ActualWidth;
            const double margin       = 23.0;

            m_yPosActive   = screenHeight * 0.5 - (viewHeight * 0.5) - (margin);
            m_yPosInactive = screenHeight * 0.5 + viewHeight * 0.5;

            var transform = new TranslateTransform(
                ConversionHelpers.AndroidToWindowsDip(32) + viewWidth * 0.5,
                m_isActive ? m_yPosActive : m_yPosInactive);

            RenderTransform = transform;
        }