Наследование: Transform, ITranslateTransform
Пример #1
0
        public static void Animate(this UIElement element, double from, double to, double fullDistance)
        {
            if (element == null)
            {
                throw new ArgumentNullException("element");
            }

            var transform = new TranslateTransform();
            element.RenderTransform = transform;

            var xAnimation = new DoubleAnimation
            {
                From = from,
                Duration = TimeSpan.FromMilliseconds(GetAnimationSpeed(from, to, fullDistance)),
                To = to,
                EnableDependentAnimation = true,
                EasingFunction = new SineEase() { EasingMode = EasingMode.EaseOut }
            };

            Storyboard.SetTarget(xAnimation, transform);
            Storyboard.SetTargetProperty(xAnimation, "X");

            var storyboard = new Storyboard();
            storyboard.Children.Add(xAnimation);

            storyboard.Begin();
        }
        public void DrawImage(Point center, Size s, BitmapImage image)
        {
            Image img = new Image();
            img.Source = (ImageSource)image;

            int imageHeight = image.PixelHeight == 0 ? 320 : image.PixelWidth;
            int imageWidth = image.PixelWidth == 0 ? 180 : image.PixelWidth;

            ScaleTransform resizeTransform = new ScaleTransform();
            resizeTransform.ScaleX = (s.Width / imageHeight) * Canvas.Width;
            resizeTransform.ScaleY = (s.Height / imageWidth) * Canvas.Height;

            TranslateTransform posTransform = new TranslateTransform();
            posTransform.X = center.X * Canvas.Width;
            posTransform.Y = center.Y * Canvas.Height;

            TransformGroup transform = new TransformGroup();
            transform.Children.Add(resizeTransform);
            transform.Children.Add(posTransform);

            img.RenderTransform = transform;

            Canvas.Children.Add(img);

        }
Пример #3
0
        public Splash(Windows.ApplicationModel.Activation.SplashScreen splashScreen,
            Nullable<Color> splashBackground = null, Uri splashImage = null)
        {
            this.InitializeComponent();

            // defaults
            if (splashBackground == null)
                splashBackground = Colors.Red;
            this.Background = new SolidColorBrush(Colors.Red);
            if (splashImage == null)
                splashImage = new Uri("ms-appx:///Assets/SplashScreen.png");
            SplashImage.ImageOpened += (s, e) => Window.Current.Activate();
            SplashImage.ImageFailed += (s, e) => Window.Current.Activate();
            SplashImage.Source = new BitmapImage(splashImage);

            // setup resize
            Action resize = () =>
            {
                SplashImage.Stretch = Stretch.Uniform;
                SplashImage.Height = splashScreen.ImageLocation.Height;
                SplashImage.Width = splashScreen.ImageLocation.Width;
                var t = new TranslateTransform
                {
                    X = splashScreen.ImageLocation.Left,
                    Y = splashScreen.ImageLocation.Top,
                };
                SplashImage.RenderTransform = t;
            };

            // init
            Window.Current.SizeChanged += (s, e) => resize();
            resize.Invoke();
        }
Пример #4
0
        public ItemPage()
        {
            this.InitializeComponent();

            _folderTree = new List<DataStructure.Folder>();
            _otherModules = new List<DataStructure.Module>();
            _allGrades = new List<DataStructure.Grade>();

            // virtual keyboard handler
            Windows.UI.ViewManagement.InputPane.GetForCurrentView().Showing += (s, args) =>
            {
                _offSet = (int)args.OccludedRect.Height;
                args.EnsuredFocusedElementInView = true;
                var trans = new TranslateTransform();
                trans.Y = -_offSet;
                this.RenderTransform = trans;
            };

            Windows.UI.ViewManagement.InputPane.GetForCurrentView().Hiding += (s, args) =>
            {
                var trans = new TranslateTransform();
                trans.Y = 0;
                this.RenderTransform = trans;
                args.EnsuredFocusedElementInView = false;
            };

        }
Пример #5
0
        /// <summary>
        /// Begint een nieuw storyboard dat het menu grid uitschuift of inschuift naar een positieve (zichtbaar) of negatieve (onzichtbaar) margin.
        /// </summary>
        public void BeginMenuAnimatie()
        {
            Storyboard storyboard = new Storyboard();
            TranslateTransform beweegTransformatie = new TranslateTransform();
            menu.RenderTransform = beweegTransformatie;
            DoubleAnimation verplaatsMenuAnimatie = new DoubleAnimation();
            verplaatsMenuAnimatie.Duration = new Duration(TimeSpan.FromSeconds(0.15));
            if (btnHideShow.Content.Equals(">"))
            {
                verplaatsMenuAnimatie.To = 303;
                verplaatsMenuAnimatie.From = 0;
                btnHideShow.Content = "<";
            }
            else
            {
                verplaatsMenuAnimatie.To = 0;
                verplaatsMenuAnimatie.From = 303;
                btnHideShow.Content = ">";
            }

            storyboard.Children.Add(verplaatsMenuAnimatie);
            Storyboard.SetTarget(verplaatsMenuAnimatie, beweegTransformatie);
            Storyboard.SetTargetProperty(verplaatsMenuAnimatie, "X");
            storyboard.Begin();
        }
Пример #6
0
            public void Reset()
            {
                Children.Clear();
                InvalidateArrange();
                content = null;
                contentsCenter = new Rect(0, 0, 1, 1);
                contentGravity = ContentGravity.Resize;
                Clip = null;
                InvOriginTransform = new TranslateTransform();
                ClipGeometry = new RectangleGeometry();
                ClipGeometry.Transform = InvOriginTransform;
                RenderTransform = new TranslateTransform();
                _position = new Point(0, 0);
                _origin = new Point(0, 0);
                _size = new Size(0, 0);
                _hidden = false;
                originSet = false;
                _createdTransforms = false;
                LayerOpacity = 1.0;
                backgroundBrush = TransparentBrush;
                backgroundColor.R = 0;
                backgroundColor.G = 0;
                backgroundColor.B = 0;
                backgroundColor.A = 0;

                Set("anchorPoint", new Point(0.5, 0.5));
                _masksToBounds = false;

                this.Background = TransparentBrush;
            }
Пример #7
0
        public ShoppingCart()
        {
            this.InitializeComponent();
            InitParam();            
            if (Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons"))
            {
                Windows.Phone.UI.Input.HardwareButtons.BackPressed += HardwareButtons_BackPressed;
                TranslateTransform trans = new TranslateTransform();
                trans.X = 0;
                trans.Y = 7;
                priceSymbol.SetValue(RenderTransformProperty,trans);
            }
            string platform = Windows.System.Profile.AnalyticsInfo.VersionInfo.DeviceFamily;//Windows.Mobile Windows.Desktop
            if(platform.Equals("Windows.Mobile"))
            {
                priceText.Margin = new Thickness(20, 0, 0, 0);
                price.Margin = new Thickness(0, 0, 20, 0);
                priceSymbol.Margin = new Thickness(0, 0, 0, 0);
            }
            else
            {
                priceText.Margin = new Thickness(20, 10, 0, 0);
                price.Margin = new Thickness(0, 10, 0, 0);
                priceSymbol.Margin = new Thickness(0, 0, 0, 10);
            }

        }
Пример #8
0
        public void MoveTo(Point from, Point to, EventHandler<object> completed = null)
        {
            TranslateTransform trans = new TranslateTransform();

            _participant.Name = "MyTarget";
            _participant.RenderTransform = trans;

            DoubleAnimation anim1 = new DoubleAnimation() { From = from.X, To = to.X, Duration = TimeSpan.FromMilliseconds(Utility.GAME_TICK_MS - 1) };
            DoubleAnimation anim2 = new DoubleAnimation() { From = from.Y, To = to.Y, Duration = TimeSpan.FromMilliseconds(Utility.GAME_TICK_MS - 1) };

            Storyboard.SetTarget(anim1, _participant);
            Storyboard.SetTargetName(anim1, _participant.Name);
            Storyboard.SetTargetProperty(anim1, "(Canvas.Left)");

            Storyboard.SetTarget(anim2, _participant);
            Storyboard.SetTargetName(anim2, _participant.Name);
            Storyboard.SetTargetProperty(anim2, "(Canvas.Top)");

            Storyboard sb = new Storyboard();
            sb.Children.Add(anim1);
            sb.Children.Add(anim2);

            if (completed == null)
                sb.Completed += (object sender, object e) => { };
            else
                sb.Completed += completed;

            sb.Begin();
        }
Пример #9
0
        private void shape_Tapped(object sender, TappedRoutedEventArgs e)
        {
            var bounds = Window.Current.Bounds;

            double height = bounds.Height;
            double width = bounds.Width;

            int iheight = (Convert.ToInt32(height));
            int iwidth = (Convert.ToInt32(width));

            Random no = new Random();
            int x = no.Next(iheight, iwidth);
            int y = no.Next(iheight, iwidth);

            string swidth = iwidth.ToString();
            //   a.Text = swidth;

            string sheight = iheight.ToString();
            //    cc.Text = sheight;

            string sx = Convert.ToString(x);
            string sy = Convert.ToString(y);

            //  boundsx.Text = sx;
            //   boundsy.Text = sy;

            TranslateTransform posTransform = new TranslateTransform();
            posTransform.X = (height - x);
            posTransform.Y = (width - y);

            // pop.Play();

            shape.RenderTransform = posTransform;
        }
        protected override void ApplyTargetProperties(DependencyObject target, Storyboard animation)
        {
            var fe = (FrameworkElement)target;
            TranslateTransform tt = fe.RenderTransform as TranslateTransform;

            if (tt == null)
            {
                fe.RenderTransform = tt = new TranslateTransform();
            }

            var da = (DoubleAnimation)animation.Children[0];

            Storyboard.SetTarget(da, tt);

            if (Direction == DirectionOfMotion.RightToLeft ||
                Direction == DirectionOfMotion.LeftToRight)
            {
                Storyboard.SetTargetProperty(da, "X");

                if (Mode == AnimationMode.In)
                {
                    da.From =
                        Direction == DirectionOfMotion.LeftToRight
                            ? -fe.ActualWidth
                            : fe.ActualWidth;
                    da.To = 0;
                }
                else
                {
                    da.From = 0;
                    da.To =
                        Direction == DirectionOfMotion.LeftToRight
                            ? fe.ActualWidth
                            : -fe.ActualWidth;
                }
            }
            else
            {
                Storyboard.SetTargetProperty(da, "Y");

                if (Mode == AnimationMode.In)
                {
                    da.From =
                        Direction == DirectionOfMotion.TopToBottom
                            ? -fe.ActualHeight
                            : fe.ActualHeight;
                    da.To = 0;
                }
                else
                {
                    da.From = 0;
                    da.To =
                        Direction == DirectionOfMotion.TopToBottom
                            ? fe.ActualHeight
                            : -fe.ActualHeight;
                }
            }
        }
Пример #11
0
        public Sticky()
        {
            this.InitializeComponent();
            this.RenderTransform = this.translateTransform = new TranslateTransform();

            this.ManipulationStarted += Sticky_ManipulationStarted;
            this.ManipulationDelta += Sticky_ManipulationDelta;
            this.ManipulationCompleted += Sticky_ManipulationCompleted;
        }
Пример #12
0
        public override void Paint()
        {
            base.Paint();

            this.isLeftSide = this.position.x < 0;

            this.lastVelocity = new Velocity() { x = 0, y = 0 };

            TranslateTransform translateTransform = new TranslateTransform()
            {
                X = this.position.x,
                Y = this.position.y,
            };

            SolidColorBrush mySolidColorBrush = new SolidColorBrush();

            if (isLeftSide)
            {
                mySolidColorBrush.Color = Color.FromArgb(50, 124, 252, 0);
            }
            else
            {
                mySolidColorBrush.Color = Color.FromArgb(50, 255, 215, 0);
            }

            this.ellipse.Fill = mySolidColorBrush;
            this.ellipse.Width = this.size.width;
            this.ellipse.Height = this.size.height;
            this.ellipse.RenderTransform = translateTransform;
            this.ellipse.ManipulationDelta += ellipse_ManipulationDelta;
            this.ellipse.ManipulationMode = Windows.UI.Xaml.Input.ManipulationModes.All;
            this.ellipse.Tapped += ellipse_Tapped;

            GameContainer.mainGrid.Children.Add(this.ellipse);

            miniPlayer = new MiniPlayerEntity()
            {
                position = new Position()
                {
                    x = this.isLeftSide ? GlobalMethods.FromCornerXToMiddleXAxis((float)(GlobalVariables.fieldWidth - GlobalVariables.playerFieldWidth - 200)) :
                                           GlobalMethods.FromCornerXToMiddleXAxis((float)(GlobalVariables.playerFieldWidth + 200)),
                    y = this.position.y,
                },

                size = new Pongaline.Classes.Size
                {
                    height = 100,
                    width = 30,
                },

                imageURI = this.isLeftSide ? new Uri("ms-appx:///Assets/DontSueUs/yoshiRight.png") : new Uri("ms-appx:///Assets/DontSueUs/yoshiLeft.png"),

            };

            GameContainer.AddEntity(miniPlayer);
        }
        public Joystick()
        {
            this.InitializeComponent();

            // Set up the gesture handling
            controlStickTransform = new TranslateTransform();
            controlStick.RenderTransform = controlStickTransform;
            controlStick.ManipulationMode = ManipulationModes.TranslateX | ManipulationModes.TranslateY;
            controlStick.ManipulationDelta += onControlStickMoved;
            controlStick.ManipulationCompleted += onControlStickReleased;
        }
Пример #14
0
 public Index()
 {
     this.InitializeComponent();
     Init();
     this.NavigationCacheMode = NavigationCacheMode.Required;
     rootFrame = Window.Current.Content as Frame;
     ContentGrid.ManipulationDelta += ContentGrid_ManipulationDelta;
     ContentGrid.ManipulationStarted += ContentGrid_ManipulationStarted;
     transfer = new TranslateTransform();
     ContentGrid.RenderTransform = this.transfer;
 }
Пример #15
0
        public static void Appear(FrameworkElement el, int millisecondPostpone = 0)
        {
            if (el.GetType().Name == "SplashScreenView")
            {
                el.Opacity =1.0;
                return;
            }


            DispatchedHandler invokedHandler = new DispatchedHandler(() =>
            {
                TranslateTransform translateTransform = new TranslateTransform();
                el.RenderTransform = translateTransform;
                translateTransform.X = (double)Animation.pixelsMove;
                if (translateTransform != null)
                {
                    SplineDoubleKeyFrame splineDoubleKeyFrame = new SplineDoubleKeyFrame();
                    splineDoubleKeyFrame.KeyTime = TimeSpan.FromMilliseconds((double)(10 + millisecondPostpone));
                    splineDoubleKeyFrame.Value = (double)Animation.pixelsMove;
                    SplineDoubleKeyFrame splineDoubleKeyFrame2 = new SplineDoubleKeyFrame();
                    splineDoubleKeyFrame2.KeyTime = TimeSpan.FromMilliseconds((double)(350 + millisecondPostpone));
                    splineDoubleKeyFrame2.Value = 0.0;
                    splineDoubleKeyFrame2.KeySpline = new KeySpline();
                    splineDoubleKeyFrame2.KeySpline.ControlPoint1 = new Point(0.0, 0.0);
                    splineDoubleKeyFrame2.KeySpline.ControlPoint2 = new Point(0.0, 1.0);
                    DoubleAnimationUsingKeyFrames doubleAnimationUsingKeyFrames = new DoubleAnimationUsingKeyFrames();
                    Storyboard.SetTarget(doubleAnimationUsingKeyFrames, translateTransform);
                    Storyboard.SetTargetProperty(doubleAnimationUsingKeyFrames, "(TranslateTransform.X)");
                    doubleAnimationUsingKeyFrames.KeyFrames.Add(splineDoubleKeyFrame);
                    doubleAnimationUsingKeyFrames.KeyFrames.Add(splineDoubleKeyFrame2);
                    SplineDoubleKeyFrame splineDoubleKeyFrame3 = new SplineDoubleKeyFrame();
                    splineDoubleKeyFrame3.KeyTime = TimeSpan.FromMilliseconds((double)millisecondPostpone);
                    splineDoubleKeyFrame3.Value = 0.0;
                    SplineDoubleKeyFrame splineDoubleKeyFrame4 = new SplineDoubleKeyFrame();
                    splineDoubleKeyFrame4.KeyTime = TimeSpan.FromMilliseconds((double)(300 + millisecondPostpone));
                    splineDoubleKeyFrame4.Value = 1.0;
                    DoubleAnimationUsingKeyFrames doubleAnimationUsingKeyFrames2 = new DoubleAnimationUsingKeyFrames();
                    Storyboard.SetTarget(doubleAnimationUsingKeyFrames2, el);
                    Storyboard.SetTargetProperty(doubleAnimationUsingKeyFrames2, "(UIElement.Opacity)");
                    doubleAnimationUsingKeyFrames2.KeyFrames.Add(splineDoubleKeyFrame3);
                    doubleAnimationUsingKeyFrames2.KeyFrames.Add(splineDoubleKeyFrame4);
                    Storyboard storyboard = new Storyboard();
                    storyboard.Children.Add(doubleAnimationUsingKeyFrames);
                    storyboard.Children.Add(doubleAnimationUsingKeyFrames2);
                    storyboard.Begin();
                }

            });


            el.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, invokedHandler).GetResults();
        }
Пример #16
0
        /*!
         * @brief	creates a joystick with the given @a puck element for a @a sphero
         * @param	puck the puck to control with the joystick
         * @param	sphero the sphero to control
         */
        public Joystick(FrameworkElement puck, RobotKit.Sphero sphero) {
            m_sphero = sphero;

            m_puckControl = puck;
            m_puckControl.PointerPressed += PointerPressed;
            m_puckControl.PointerMoved += PointerMoved;
            m_puckControl.PointerReleased += PointerReleased;
            m_puckControl.PointerCaptureLost += PointerReleased;
            m_puckControl.PointerCanceled += PointerReleased;

            m_translateTransform = new TranslateTransform();
            m_puckControl.RenderTransform = m_translateTransform;
        }
Пример #17
0
        private void HandleLowerTextBoxGotFocus(object sender, RoutedEventArgs e)
        {
            Transform stackPanelRestore = DebugHelper.CastAndAssert<Transform>(((TextBox)sender).TransformToVisual(rootStackPanel));

            TranslateTransform shiftDown = new TranslateTransform();
            shiftDown.Y = 90;

            TransformGroup group = new TransformGroup();

            group.Children.Add(DebugHelper.CastAndAssert<Transform>(stackPanelRestore.Inverse));
            group.Children.Add(shiftDown);

            rootStackPanel.RenderTransform = group;
        }
Пример #18
0
        public void UpdateMargins()
        {
            double fullWidth = Windows.UI.Xaml.Window.Current.Bounds.Width - this.Margin.Left - this.Margin.Right;

            double newCenterPoint = this.Center - (this.ActualWidth / 2);

            if (newCenterPoint < 0) newCenterPoint = 0;
            if (newCenterPoint > fullWidth - (this.ActualWidth)) newCenterPoint = fullWidth - (this.ActualWidth);

            TranslateTransform tt = new TranslateTransform();
            tt.X = newCenterPoint;

            this.RenderTransform = tt;
        }
Пример #19
0
        /*!
         * @brief	creates a joystick with the given @a puck element for a @a sphero
         * @param	puck the puck to control with the joystick
         * @param	sphero the sphero to control
         */
        public ColorWheel(FrameworkElement puck, RobotKit.Sphero sphero) {
            m_sphero = sphero;

            m_puckControl = puck;
            m_puckControl.PointerPressed += PointerPressed;
            m_puckControl.PointerMoved += PointerMoved;
            m_puckControl.PointerReleased += PointerReleased;
            m_puckControl.PointerCaptureLost += PointerReleased;
            m_puckControl.PointerCanceled += PointerReleased;

            m_translateTransform = new TranslateTransform();
            m_puckControl.RenderTransform = m_translateTransform;

            m_lastCommandSentTimeMs = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond;
        }
Пример #20
0
        protected void OnManipulationDelta(object sender, ManipulationDeltaRoutedEventArgs e)
        {
            if (e.OriginalSource != _mainpage)
                return;

            var compositeTransform = (CompositeTransform)_mainpage.MainCanvas.RenderTransform;
            var tmpTranslate = new TranslateTransform
            {
                X = compositeTransform.CenterX,
                Y = compositeTransform.CenterY
            };

            var center = compositeTransform.Inverse.TransformPoint(e.Position);

            var localPoint = tmpTranslate.Inverse.TransformPoint(center);

            //Now scale the point in local space
            localPoint.X *= compositeTransform.ScaleX;
            localPoint.Y *= compositeTransform.ScaleY;

            //Transform local space into world space again
            var worldPoint = tmpTranslate.TransformPoint(localPoint);

            //Take the actual scaling...
            var distance = new Point(
                worldPoint.X - center.X,
                worldPoint.Y - center.Y);

            //...and balance the jump of the changed scaling origin by changing the translation

            compositeTransform.TranslateX += distance.X;
            compositeTransform.TranslateY += distance.Y;

            //Also set the scaling values themselves, especially set the new scale center...
            compositeTransform.ScaleX *= e.Delta.Scale;
            compositeTransform.ScaleY *= e.Delta.Scale;

            compositeTransform.CenterX = center.X;
            compositeTransform.CenterY = center.Y;

            //And consider a translational shift
            compositeTransform.TranslateX += e.Delta.Translation.X;
            compositeTransform.TranslateY += e.Delta.Translation.Y;

            _mainpage.MainCanvas.RenderTransform = compositeTransform;

            Settings.ZoomLevel = compositeTransform.ScaleX;
        }
Пример #21
0
        void init()
        {
            Height = 900.0;
            Width = 60.0;
            HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Left;
            RenderTransform = new TranslateTransform() { X = 200};

            icon_image = new Image() { Width = 60, Height = 60 };
            Children.Add(icon_image);

            top_line = new Grid() { Width = 3, Height = 376, VerticalAlignment = Windows.UI.Xaml.VerticalAlignment.Top };
            Children.Add(top_line);

            botton_line = new Grid() { Width = 3, Height = 376, VerticalAlignment = Windows.UI.Xaml.VerticalAlignment.Bottom };
            Children.Add(botton_line);
        }
        public TestLineupPage()
        {
            this.InitializeComponent();

            TransformGroup tg = new TransformGroup();

            ScaleTransform st = new ScaleTransform();
            tg.Children.Add(st);

            RotateTransform rt = new RotateTransform();
            tg.Children.Add(rt);

            TranslateTransform tl = new TranslateTransform();
            tg.Children.Add(tl);

            _viewbox.RenderTransform = tg;
        }
        public BasePage(PageStytle style = PageStytle.None)
        {
            this.IsTextScaleFactorEnabled = false;
            this.SizeChanged += BasePage_SizeChanged;
            this.Loaded += BasePage_Loaded;
            this.Unloaded += BasePage_Unloaded;
            PageStytle = style;
            if (PageStytle != PageStytle.Main)
            {
                this.ManipulationMode = ManipulationModes.TranslateX;
                this.ManipulationCompleted += BasePage_ManipulationCompleted;
                this.ManipulationDelta += BasePage_ManipulationDelta;

                _tt = this.RenderTransform as TranslateTransform;
                if (_tt == null) this.RenderTransform = _tt = new TranslateTransform();
            }
        }
Пример #24
0
 protected override Size ArrangeOverride(Size arrangeBounds)
 {
     TranslateTransform tt = new TranslateTransform();
     RadialScale scale = Owner as RadialScale;
     if (scale != null)
     {
         // Calculate the geometry again. The first time this was done the owner had a size of (0,0)
         // and so did the indicator. Once the owner has the correct size (MeasureOverride has been called)
         // we should re-calculate the shape of the indicator
         SetIndicatorGeometry(scale, Value);
         Point center = scale.GetIndicatorOffset();
         tt.X = center.X;
         tt.Y = center.Y;
         RenderTransform = tt;
     }
     return base.ArrangeOverride(arrangeBounds);
 }
        protected override void OnApplyTemplate()
        {
            var rootLayout = (FrameworkElement)GetTemplateChild("RootLayout");

            // 实际内容容器。
            _contentBorder = (ContentControl)GetTemplateChild("ContentBorder");

            // 倒影图片。
            _reflectionImage = (Image)GetTemplateChild("ReflectionImage");

            // 倒影位移。
            _spacingTransform = (TranslateTransform)GetTemplateChild("SpacingTransform");
            _spacingTransform.Y = ReflectionSpacing;

            if (DesignMode.DesignModeEnabled == false)
            {
                rootLayout.LayoutUpdated += RootLayoutChanged;
            }
        }
Пример #26
0
        private async void colorEllipse_PointerMoved(object sender, PointerRoutedEventArgs e)
        {
            ellipse.Visibility = Windows.UI.Xaml.Visibility.Visible;
            PointerPoint position = e.GetCurrentPoint(colorEllipse);
            double px = position.Position.X - (ellipse.Width / 2);
            double py = position.Position.Y - (ellipse.Width / 2);
            TranslateTransform translateTransform = new TranslateTransform();
            translateTransform.X = px;
            translateTransform.Y = py;
            ellipse.RenderTransform = translateTransform;
            //Point pointer = e.GetPosition(colorWheelEllipse);

            //WriteableBitmap writeableBitmap = new WriteableBitmap(400, 400);
            //writeableBitmap.SetSourceAsync(await storageFile.OpenAsync(FileAccessMode.Read));

            BitmapDecoder bitmapDecoder = await BitmapDecoder.CreateAsync(await storageFile.OpenAsync(FileAccessMode.Read));

            PixelDataProvider pp = await bitmapDecoder.GetPixelDataAsync();
            try
            {
                byte[] pixels = pp.DetachPixelData();
                double index = position.Position.Y * bitmapDecoder.OrientedPixelHeight + 4 * position.Position.X;
                byte r = pixels[(int)index];//;Convert.ToInt32(((position.Position.Y * bitmapDecoder.OrientedPixelHeight +4*position.Position.X)))];
                byte g = pixels[(int)index+1];//Convert.ToInt32(((position.Position.Y * bitmapDecoder.OrientedPixelHeight) + position.Position.X) * 4 + 1)];
                byte b = pixels[(int)index+2];//Convert.ToInt32(((position.Position.Y * bitmapDecoder.OrientedPixelHeight) + position.Position.X) * 4 + 2)];
                byte a = pixels[(int)index+3];//Convert.ToInt32(((position.Position.Y * bitmapDecoder.OrientedPixelHeight) + position.Position.X) * 4 + 3)];
                //byte a = pixels[Convert.ToInt32(((position.Position.Y * bitmapDecoder.OrientedPixelHeight) + position.Position.X) * 4)];
                //byte r = pixels[Convert.ToInt32(((position.Position.Y * bitmapDecoder.OrientedPixelHeight) + position.Position.X) * 4 + 1)];
                //byte g = pixels[Convert.ToInt32(((position.Position.Y * bitmapDecoder.OrientedPixelHeight) + position.Position.X) * 4 + 2)];
                //byte b = pixels[Convert.ToInt32(((position.Position.Y * bitmapDecoder.OrientedPixelHeight) + position.Position.X) * 4 + 3)];
                //Color color = Color.FromArgb(100, pixels[Convert.ToInt32((pointer.Y*32 + pointer.X)*4)], pixels[Convert.ToInt32((pointer.Y*32 + pointer.X)*4+1)], pixels[Convert.ToInt32((pointer.Y*32 + pointer.X)*4+2)]);

                Color color = Color.FromArgb(255, r, g, b);

                colorRectangle.Fill = new SolidColorBrush(color);
                //int k = 0;
            }
            catch (Exception ex)
            {
                //int k = 0;
            }
        }
Пример #27
0
        public Card()
        {
            this.InitializeComponent();
            vm = new CardViewModel();
            this.DataContext = vm;
            vm.ClearGeneratedCards();
            NewCard_Click(this, null);
            _transformVerb = new TranslateTransform();
            _transformAdjectives = new TranslateTransform();
            _transformNoun = new TranslateTransform();
            _transformImage = new TranslateTransform();

            VerbTextBlock.RenderTransform = _transformVerb;
            AdjectivesTextBlock.RenderTransform = _transformAdjectives;
            NounTextBlock.RenderTransform = _transformNoun;
            Image.RenderTransform = _transformImage;

            // Hide the status bar
            HideStatusbar();
        }
Пример #28
0
        protected void ArrangeChildFluently(UIElement child, Point targetPosition, Size childSize, Duration duration)
        {
            if (_currentStoryboardDisposable == null)
                throw new InvalidOperationException("You must call BeginStoryboard before arranging UI Elements fluently");

            var translateTransform = child.RenderTransform as TranslateTransform;
            if (translateTransform == null)
                child.RenderTransform = translateTransform = new TranslateTransform();

            child.Arrange(new Rect(new Point(), childSize));

            _currentStoryboardDisposable.AddAnimtation(CreateDoubleAnimation(targetPosition.X,
                                                                             duration,
                                                                             child,
                                                                             TranslateXPath));
            _currentStoryboardDisposable.AddAnimtation(CreateDoubleAnimation(targetPosition.Y,
                                                                             duration,
                                                                             child,
                                                                             TranslateYPath));
        }
        public UploadPage()
        {
            InitializeComponent();

            _viewModel = ServiceLocator.Current.GetInstance<UploadViewModel>();
            DataContext = _viewModel;

            Loaded += UploadPage_Loaded;

            // We need to prevent the virtual keyboard covering the textbox control
            InputPane.GetForCurrentView().Showing += (s, args) =>
            {
                RenderTransform = new TranslateTransform { Y = -args.OccludedRect.Height };
                args.EnsuredFocusedElementInView = true;
            };

            InputPane.GetForCurrentView().Hiding += (s, args) =>
            {
                RenderTransform = new TranslateTransform { Y = 0 };
                args.EnsuredFocusedElementInView = false;
            };
        }
Пример #30
0
        public override void Paint()
        {
            BitmapImage bulletEntity = new BitmapImage();

            if (this.velocity.x > 0) { bulletEntity.UriSource = new Uri("ms-appx:///Assets/DontSueUs/bulletRight.png"); }
            else { bulletEntity.UriSource = new Uri("ms-appx:///Assets/DontSueUs/bulletLeft.png"); }

            TranslateTransform translateTransform = new TranslateTransform()
            {
                X = this.position.x,
                Y = this.position.y,
            };

            this.image = new Image()
            {
                Source = bulletEntity,
                Width = this.size.width,
                Height = this.size.height,
                RenderTransform = translateTransform,
            };

            GameContainer.mainGrid.Children.Add(this.image);
        }