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); }
public static void ApplySnap(TransformGroup t, Duration duration) { var scaleT = new ScaleTransform { ScaleY = 1, ScaleX = 1 }; t.Children.Add(scaleT); var storyboard = CreateDPAnimation(scaleT, "ScaleY", duration, 0, 1, false, false, new ElasticEase { Springiness = 0.4 }); storyboard.Begin(); }
/// <summary> /// Builds the visual tree for the ColorPicker control when the template is applied. /// </summary> protected override void OnApplyTemplate() { base.OnApplyTemplate(); m_rootElement = GetTemplateChild("RootElement") as Panel; m_hueMonitor = GetTemplateChild("HueMonitor") as Rectangle; m_sampleSelector = GetTemplateChild("SampleSelector") as Canvas; m_hueSelector = GetTemplateChild("HueSelector") as Canvas; m_selectedColorView = GetTemplateChild("SelectedColorView") as Rectangle; m_colorSample = GetTemplateChild("ColorSample") as Rectangle; m_hexValue = GetTemplateChild("HexValue") as TextBlock; m_rootElement.RenderTransform = m_scale = new ScaleTransform(); m_hueMonitor.PointerPressed += m_hueMonitor_PointerPressed; m_hueMonitor.PointerReleased += m_hueMonitor_PointerReleased; m_hueMonitor.PointerMoved += m_hueMonitor_PointerMoved; m_colorSample.PointerPressed += m_colorSample_PointerPressed; m_colorSample.PointerReleased += m_colorSample_PointerReleased; m_colorSample.PointerMoved += m_colorSample_PointerMoved; m_sampleX = m_colorSample.Width; m_sampleY = 0; m_huePos = 0; UpdateVisuals(); }
private void Started(object sender, PointerRoutedEventArgs e) { Element.RenderTransformOrigin = Origin; ScaleTransform scale = new ScaleTransform(); scale.ScaleX = X; scale.ScaleY = Y; ((FrameworkElement)sender).RenderTransform = scale; }
private void ZoomBehavior_ManipulationDelta(object sender, Windows.UI.Xaml.Input.ManipulationDeltaRoutedEventArgs e) { Image img = sender as Image; ScaleTransform scaleTF = img.RenderTransform as ScaleTransform; if (scaleTF == null) { scaleTF = new ScaleTransform(); } float value = e.Delta.Scale / 2; scaleTF.ScaleY = scaleTF.ScaleX = scaleTF.ScaleX + value; }
public static DoubleAnimation CreateScaleYAnimation(ScaleTransform scale, double to, double seconds) { var scallingYAnimation = new DoubleAnimation { To = to, Duration = new Duration(TimeSpan.FromSeconds(seconds)), EasingFunction = new QuinticEase() }; Storyboard.SetTarget(scallingYAnimation, scale); Storyboard.SetTargetProperty(scallingYAnimation, "ScaleY"); return scallingYAnimation; }
public ESContext() { AppSettings.PropertyChanged += AppSettings_PropertyChanged; RenderTransform = new ScaleTransform(); RenderTransform.ScaleX = RenderTransform.ScaleY = 1.5; UpdateBrush( Parameters.APPEARANCE_CONTENTREADER_CLOCK_ARCOLOR ); UpdateBrush( Parameters.APPEARANCE_CONTENTREADER_CLOCK_HHCOLOR ); UpdateBrush( Parameters.APPEARANCE_CONTENTREADER_CLOCK_MHCOLOR ); UpdateBrush( Parameters.APPEARANCE_CONTENTREADER_CLOCK_SCOLOR ); UpdateBrush( Parameters.APPEARANCE_CONTENTREADER_ES_SCOLOR ); UpdateBrush( Parameters.APPEARANCE_CONTENTREADER_ES_DCOLOR ); UpdateBrush( Parameters.APPEARANCE_CONTENTREADER_ES_BG ); }
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; }
//CompositeTransform cpTransform; public MainPage() { this.InitializeComponent(); this.NavigationCacheMode = NavigationCacheMode.Required; scaleTransform = new ScaleTransform(); //cpTransform = new CompositeTransform(); //cpTransform.CenterX = image.Width / 2; //cpTransform.CenterY = image.Height / 2; //cpTransform.TranslateX = cpTransform.TranslateY = 0; //cpTransform.Rotation = 0; scaleTransform.CenterX = image.Width / 2; scaleTransform.CenterY = image.Height / 2; scaleTransform.ScaleX = scaleTransform.ScaleY = 1; image.RenderTransform = scaleTransform; // image.RenderTransform = cpTransform; }
// Refresh UI private void button4_Click(object sender, RoutedEventArgs e) { Storyboard storyboardscale = new Storyboard(); ScaleTransform scale = new ScaleTransform(); backgr.RenderTransform = scale; DoubleAnimation scaleAnim = new DoubleAnimation(); scaleAnim.Duration = TimeSpan.FromMilliseconds(400); scaleAnim.From = 2.0; scaleAnim.To = 1.0; SineEase easingFunctionscale = new SineEase(); easingFunctionscale.EasingMode = EasingMode.EaseInOut; scaleAnim.EasingFunction = easingFunctionscale; Storyboard.SetTarget(scaleAnim, appBar); Storyboard.SetTargetProperty(scaleAnim, "(UIElement.RenderTransform).(ScaleTransform.ScaleX)"); storyboardscale.Children.Add(scaleAnim); if (isAppBarOpen) storyboardscale.Begin(); fadeInStoryboard.Begin(); fadeInGridOpacity.Begin(); }
protected override void OnApplyTemplate() { base.OnApplyTemplate(); ContentPresenter = (ContentControl)GetTemplateChild("ContentPresenter"); planeProjection = (PlaneProjection)GetTemplateChild("Rotator"); LayoutRoot = (FrameworkElement)GetTemplateChild("LayoutRoot"); Animation = (Storyboard)GetTemplateChild("Animation"); Animation.Completed += Animation_Completed; rotationKeyFrame = (EasingDoubleKeyFrame)GetTemplateChild("rotationKeyFrame"); offestZKeyFrame = (EasingDoubleKeyFrame)GetTemplateChild("offestZKeyFrame"); scaleXKeyFrame = (EasingDoubleKeyFrame)GetTemplateChild("scaleXKeyFrame"); scaleYKeyFrame = (EasingDoubleKeyFrame)GetTemplateChild("scaleYKeyFrame"); scaleTransform = (ScaleTransform)GetTemplateChild("scaleTransform"); planeProjection.RotationY = yRotation; planeProjection.LocalOffsetZ = zOffset; if (ContentPresenter != null) { ContentPresenter.Tapped += ContentPresenter_Tapped; } if (Animation != null) { xAnimation = new DoubleAnimation(); Animation.Children.Add(xAnimation); Storyboard.SetTarget(xAnimation, this); Storyboard.SetTargetProperty(xAnimation, "(Canvas.Left)"); } }
private void button_Click(object sender, RoutedEventArgs e) { isAppBarHBOpened = true; if (!isAppBarOpen) { isAppBarOpen = true; Storyboard storyboard = new Storyboard(); TranslateTransform trans = new TranslateTransform();// { X = 60.0, Y = 0.0 }; //backgr.RenderTransformOrigin = new Point(250.0, 0.0); backgr.RenderTransform = trans; DoubleAnimation moveAnim = new DoubleAnimation(); moveAnim.Duration = TimeSpan.FromMilliseconds(250); moveAnim.From = 0; moveAnim.To = 250 - 64; //moveAnim.BeginTime = TimeSpan.FromSeconds(0.85); SineEase easingFunction = new SineEase(); easingFunction.EasingMode = EasingMode.EaseIn; moveAnim.EasingFunction = easingFunction; Storyboard.SetTarget(moveAnim, backgr); Storyboard.SetTargetProperty(moveAnim, "(UIElement.RenderTransform).(TranslateTransform.X)"); //storyboard.Completed += new System.EventHandler(storyboard_Completed); storyboard.Children.Add(moveAnim); storyboard.Begin(); Storyboard storyboardscale = new Storyboard(); ScaleTransform scale = new ScaleTransform();//{ X = 1.0, Y = 1.0 }; //appBar.RenderTransformOrigin = new Point(250.0/64, 0.0); appBar.RenderTransform = scale; DoubleAnimation scaleAnim = new DoubleAnimation(); scaleAnim.Duration = TimeSpan.FromMilliseconds(250); scaleAnim.From = 1.0; scaleAnim.To = 250.0 / 64; SineEase easingFunctionscale = new SineEase(); easingFunctionscale.EasingMode = EasingMode.EaseIn; scaleAnim.EasingFunction = easingFunctionscale; Storyboard.SetTarget(scaleAnim, appBar); Storyboard.SetTargetProperty(scaleAnim, "(UIElement.RenderTransform).(ScaleTransform.ScaleX)"); //storyboardscale.Completed += new System.EventHandler(storyboard_Completed); storyboardscale.Children.Add(scaleAnim); storyboardscale.Begin(); textBlock1.Text = "Гамбургер открыт"; hamburgerButton.Width = 250; } else { isAppBarOpen = false; Storyboard storyboard = new Storyboard(); TranslateTransform trans = new TranslateTransform();// { X = 60.0, Y = 0.0 }; //backgr.RenderTransformOrigin = new Point(250.0, 0.0); backgr.RenderTransform = trans; DoubleAnimation moveAnim = new DoubleAnimation(); moveAnim.Duration = TimeSpan.FromMilliseconds(250); moveAnim.From = 250-64; moveAnim.To = 0; //moveAnim.BeginTime = TimeSpan.FromSeconds(0.85); SineEase easingFunction = new SineEase(); easingFunction.EasingMode = EasingMode.EaseInOut; moveAnim.EasingFunction = easingFunction; Storyboard.SetTarget(moveAnim, backgr); Storyboard.SetTargetProperty(moveAnim, "(UIElement.RenderTransform).(TranslateTransform.X)"); //storyboard.Completed += new System.EventHandler(storyboard_Completed); storyboard.Children.Add(moveAnim); storyboard.Begin(); Storyboard storyboardscale = new Storyboard(); ScaleTransform scale = new ScaleTransform();//{ X = 1.0, Y = 1.0 }; //appBar.RenderTransformOrigin = new Point(250.0/64, 0.0); appBar.RenderTransform = scale; DoubleAnimation scaleAnim = new DoubleAnimation(); scaleAnim.Duration = TimeSpan.FromMilliseconds(250); scaleAnim.From = 250.0 / 64; scaleAnim.To = 1; SineEase easingFunctionscale = new SineEase(); easingFunctionscale.EasingMode = EasingMode.EaseInOut; scaleAnim.EasingFunction = easingFunctionscale; Storyboard.SetTarget(scaleAnim, appBar); Storyboard.SetTargetProperty(scaleAnim, "(UIElement.RenderTransform).(ScaleTransform.ScaleX)"); //storyboardscale.Completed += new System.EventHandler(storyboard_Completed); storyboardscale.Children.Add(scaleAnim); storyboardscale.Begin(); textBlock1.Text = "Гамбургер закрыт"; hamburgerButton.Width = 64; } }
/// <summary> /// This is click handler for Extract Text button. /// If image size is supported text is extracted and overlaid over displayed image. /// Supported image dimensions are between 40 and 2600 pixels. /// </summary> private async void ExtractTextButton_Click(object sender, RoutedEventArgs e) { // Prevent another OCR request, since only image can be processed at the time at same OCR engine instance. ExtractTextButton.IsEnabled = false; // Check whether is loaded image supported for processing. // Supported image dimensions are between 40 and 2600 pixels. if (bitmap.PixelHeight < 40 || bitmap.PixelHeight > 2600 || bitmap.PixelWidth < 40 || bitmap.PixelWidth > 2600) { ImageText.Text = "Resim Boyutu Desteklenmiyor." + Environment.NewLine + "Seçilen resim Boyutu " + bitmap.PixelWidth + "x" + bitmap.PixelHeight + "." + Environment.NewLine + " 40 ve 2600 pixels Resim Boyutları Desteklenmektedir."; ImageText.Style = (Style)Application.Current.Resources["RedTextStyle"]; rootPage.NotifyUser( String.Format("Desteklenmeyen Görüntü Boyutu. " + Environment.NewLine + "Desteklenen dosya boyutu 40 ve 2600 pixel aralığıdır."), NotifyType.ErrorMessage); return; } // This main API call to extract text from image. var ocrResult = await ocrEngine.RecognizeAsync((uint)bitmap.PixelHeight, (uint)bitmap.PixelWidth, bitmap.PixelBuffer.ToArray()); // OCR result does not contain any lines, no text was recognized. if (ocrResult.Lines != null) { // Used for text overlay. // Prepare scale transform for words since image is not displayed in original format. var scaleTrasform = new ScaleTransform { CenterX = 0, CenterY = 0, ScaleX = PreviewImage.ActualWidth / bitmap.PixelWidth, ScaleY = PreviewImage.ActualHeight / bitmap.PixelHeight, }; if (ocrResult.TextAngle != null) { // If text is detected under some angle then // apply a transform rotate on image around center. PreviewImage.RenderTransform = new RotateTransform { Angle = (double)ocrResult.TextAngle, CenterX = PreviewImage.ActualWidth / 2, CenterY = PreviewImage.ActualHeight / 2 }; } string extractedText = ""; // Iterate over recognized lines of text. foreach (var line in ocrResult.Lines) { // Iterate over words in line. foreach (var word in line.Words) { var originalRect = new Rect(word.Left, word.Top, word.Width, word.Height); var overlayRect = scaleTrasform.TransformBounds(originalRect); // Define the TextBlock. var wordTextBlock = new TextBlock() { Height = overlayRect.Height, Width = overlayRect.Width, FontSize = overlayRect.Height * 0.8, Text = word.Text, Style = (Style)Application.Current.Resources["ExtractedWordTextStyle"] }; // Define position, background, etc. var border = new Border() { Margin = new Thickness(overlayRect.Left, overlayRect.Top, 0, 0), Height = overlayRect.Height, Width = overlayRect.Width, Child = wordTextBlock, Style = (Style)Application.Current.Resources["ExtractedWordBorderStyle"] }; // Put the filled textblock in the results grid. TextOverlay.Children.Add(border); extractedText += word.Text + " "; } extractedText += Environment.NewLine; } ImageText.Text = extractedText; ImageText.Style = (Style)Application.Current.Resources["GreenTextStyle"]; ImageTextbox.Text = extractedText; } else { ImageText.Text = "Metin Yok."; ImageText.Style = (Style)Application.Current.Resources["RedTextStyle"]; } rootPage.NotifyUser( String.Format("Görüntü Başarıyla {0} Dilinde Okundu.", ocrEngine.Language.ToString()), NotifyType.StatusMessage); }
private void Draw() { IsDrawn = true; Map.Children.Clear(); if (Windows.ApplicationModel.DesignMode.DesignModeEnabled) { Map.Children.Add(new TextBlock { Text = "Designer preview is not currently available", Foreground = new SolidColorBrush(Colors.White), FontWeight = FontWeights.Bold, FontSize = 12, //Effect = new DropShadowEffect //{ // ShadowDepth = 2, // RenderingBias = RenderingBias.Performance //} }); return; } var map = MapResolver.Get(Source); if (map == null) return; var desiredSize = new Size(map.DesiredWidth, map.DesiredHeight); var r = desiredSize.Width/desiredSize.Height; var wr = ActualWidth/desiredSize.Width; var hr = ActualHeight/desiredSize.Height; double s; if (wr < hr) { IsWidthDominant = true; Map.Width = ActualWidth; Map.Height = Map.Width/r; s = wr; OriginalPosition = new Point(0, (ActualHeight - Map.Height)*.5); Canvas.SetLeft(Map, OriginalPosition.X); Canvas.SetTop(Map, OriginalPosition.Y); } else { IsWidthDominant = false; Map.Height = ActualHeight; Map.Width = r*ActualHeight; s = hr; OriginalPosition = new Point((ActualWidth - Map.Width)*.5, 0d); Canvas.SetLeft(Map, OriginalPosition.X); Canvas.SetTop(Map, OriginalPosition.Y); } var t = new ScaleTransform() {ScaleX = s, ScaleY = s}; foreach (var land in map.Data) { var p = new Path { Data = GeometryHelper.Parse(land.Data), RenderTransform = t }; land.Shape = p; Lands[land.Id] = land; Map.Children.Add(p); //p.MouseEnter += POnMouseEnter; //p.MouseLeave += POnMouseLeave; //p.MouseMove += POnMouseMove; //p.MouseDown += POnMouseDown; p.SetBinding(Shape.StrokeProperty, new Binding { Path = new PropertyPath("LandStroke"), Source = this }); var behavior = new MultiBindingBehavior() { Converter = new ScaleStrokeConverter(), PropertyName = "StrokeThickness" }; behavior.Items.Add(new MultiBindingItem() {Parent = behavior.Items, Value = new Binding() { Path = new PropertyPath("LandStrokeThickness"), Source = this } }); behavior.Items.Add(new MultiBindingItem() {Parent = behavior.Items, Value = new Binding() { Path = new PropertyPath("ScaleX"), Source = t } }); Interaction.SetBehaviors(p, new BehaviorCollection() {behavior}); } ShowMeSomeHeat(); }
private void button4_Click(object sender, RoutedEventArgs e) { //fadeInStoryboardOpacity.Begin(); Storyboard storyboardscale = new Storyboard(); ScaleTransform scale = new ScaleTransform();//{ X = 1.0, Y = 1.0 }; //appBar.RenderTransformOrigin = new Point(250.0/64, 0.0); backgr.RenderTransform = scale; DoubleAnimation scaleAnim = new DoubleAnimation(); scaleAnim.Duration = TimeSpan.FromMilliseconds(400); scaleAnim.From = 2.0; scaleAnim.To = 1.0; SineEase easingFunctionscale = new SineEase(); easingFunctionscale.EasingMode = EasingMode.EaseInOut; scaleAnim.EasingFunction = easingFunctionscale; Storyboard.SetTarget(scaleAnim, appBar); Storyboard.SetTargetProperty(scaleAnim, "(UIElement.RenderTransform).(ScaleTransform.ScaleX)"); //storyboardscale.Completed += new System.EventHandler(storyboard_Completed); storyboardscale.Children.Add(scaleAnim); if (isAppBarHBOpened) storyboardscale.Begin(); fadeInStoryboard.Begin(); fadeInGridOpacity.Begin(); //Hamburger.Begin(); //AppBarOpacityAnimationIn.Begin(); }
protected override void OnApplyTemplate() { base.OnApplyTemplate(); MainGrid = HelperFunctions.FindControl<Grid>(this, "MainGrid"); Scale = (ScaleTransform)MainGrid.RenderTransform; }
public Windows.UI.Xaml.Shapes.Polygon Outline(double inc) { Windows.UI.Xaml.Shapes.Polygon p = new Windows.UI.Xaml.Shapes.Polygon(); CompositeTransform ct = new CompositeTransform(); ct.ScaleX = ct.ScaleY = 1; ct.Rotation = Phase; ScaleTransform sc = new ScaleTransform(); sc.ScaleY = sc.ScaleX = 1; p.Stroke = new SolidColorBrush(Color.FromArgb(255, 255, 0, 0)); p.RenderTransform = ct; double phse = Phase; double lastr = 0; double r ; double tp; double a = 0; Point pd; int N = (int)Math.Floor(1.0 / inc); for (double i = 1; i < N; i++ ) { double f = i * inc; r = CalcR(f, 0); a = f * twopi; tp = ToolPosition + r - lastr; pd = new Point(tp * Math.Cos(a), tp * Math.Sin(a)); p.Points.Add(pd); lastr = r; } r = CalcR(1.0, 0); a = twopi; tp = ToolPosition + r - lastr; pd = new Point(tp * Math.Cos(a), tp * Math.Sin(a)); p.Points.Add(pd); return p; }
/// <summary> /// This is event handler for 'Extract' button. /// Captures image from camera ,recognizes text and displays it. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private async void ExtractButton_Tapped(object sender, Windows.UI.Xaml.Input.TappedRoutedEventArgs e) { //Get information about the preview. var previewProperties = mediaCapture.VideoDeviceController.GetMediaStreamProperties(MediaStreamType.VideoPreview) as VideoEncodingProperties; int videoFrameWidth = (int)previewProperties.Width; int videoFrameHeight = (int)previewProperties.Height; // In portrait modes, the width and height must be swapped for the VideoFrame to have the correct aspect ratio and avoid letterboxing / black bars. if (!externalCamera && (displayInformation.CurrentOrientation == DisplayOrientations.Portrait || displayInformation.CurrentOrientation == DisplayOrientations.PortraitFlipped)) { videoFrameWidth = (int)previewProperties.Height; videoFrameHeight = (int)previewProperties.Width; } // Create the video frame to request a SoftwareBitmap preview frame. var videoFrame = new VideoFrame(BitmapPixelFormat.Bgra8, videoFrameWidth, videoFrameHeight); // Capture the preview frame. using (var currentFrame = await mediaCapture.GetPreviewFrameAsync(videoFrame)) { // Collect the resulting frame. SoftwareBitmap bitmap = currentFrame.SoftwareBitmap; OcrEngine ocrEngine = OcrEngine.TryCreateFromLanguage(ocrLanguage); if (ocrEngine == null) { rootPage.NotifyUser(ocrLanguage.DisplayName + " is not supported.", NotifyType.ErrorMessage); return; } var imgSource = new WriteableBitmap(bitmap.PixelWidth, bitmap.PixelHeight); bitmap.CopyToBuffer(imgSource.PixelBuffer); PreviewImage.Source = imgSource; var ocrResult = await ocrEngine.RecognizeAsync(bitmap); // Used for text overlay. // Prepare scale transform for words since image is not displayed in original format. var scaleTrasform = new ScaleTransform { CenterX = 0, CenterY = 0, ScaleX = PreviewControl.ActualWidth / bitmap.PixelWidth, ScaleY = PreviewControl.ActualHeight / bitmap.PixelHeight }; if (ocrResult.TextAngle != null) { // If text is detected under some angle in this sample scenario we want to // overlay word boxes over original image, so we rotate overlay boxes. TextOverlay.RenderTransform = new RotateTransform { Angle = (double)ocrResult.TextAngle, CenterX = PreviewImage.ActualWidth / 2, CenterY = PreviewImage.ActualHeight / 2 }; } // Iterate over recognized lines of text. foreach (var line in ocrResult.Lines) { // Iterate over words in line. foreach (var word in line.Words) { // Define the TextBlock. var wordTextBlock = new TextBlock() { Text = word.Text, Style = (Style)this.Resources["ExtractedWordTextStyle"] }; WordOverlay wordBoxOverlay = new WordOverlay(word); // Keep references to word boxes. wordBoxes.Add(wordBoxOverlay); // Define position, background, etc. var overlay = new Border() { Child = wordTextBlock, Style = (Style)this.Resources["HighlightedWordBoxHorizontalLine"] }; // Bind word boxes to UI. overlay.SetBinding(Border.MarginProperty, wordBoxOverlay.CreateWordPositionBinding()); overlay.SetBinding(Border.WidthProperty, wordBoxOverlay.CreateWordWidthBinding()); overlay.SetBinding(Border.HeightProperty, wordBoxOverlay.CreateWordHeightBinding()); // Put the filled textblock in the results grid. TextOverlay.Children.Add(overlay); } } rootPage.NotifyUser("Image processed using " + ocrEngine.RecognizerLanguage.DisplayName + " language.", NotifyType.StatusMessage); } UpdateWordBoxTransform(); PreviewControl.Visibility = Visibility.Collapsed; Image.Visibility = Visibility.Visible; ExtractButton.Visibility = Visibility.Collapsed; CameraButton.Visibility = Visibility.Visible; }
public override void PlayReverse(Action completed) { var storyboard = new Storyboard(); var toPage = ToPage; var scaleTransform = new ScaleTransform { CenterX = ToPage.ActualWidth/2, CenterY = ToPage.ActualHeight/2, ScaleX = 1, ScaleY = 1 }; toPage.RenderTransform = scaleTransform; ToPage.Opacity = 1; storyboard.Duration = new Duration(TimeSpan.FromSeconds(0.15)); var doubleAnimationUsingKeyFrame = new DoubleAnimationUsingKeyFrames { RepeatBehavior = new RepeatBehavior(TimeSpan.FromSeconds(1)), FillBehavior = FillBehavior.HoldEnd }; var doubleAnimationUsingKeyFrame1 = doubleAnimationUsingKeyFrame; var keyFrames = doubleAnimationUsingKeyFrame1.KeyFrames; var easingDoubleKeyFrame = new EasingDoubleKeyFrame { KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(0)), Value = 1, EasingFunction = new CubicEase() }; keyFrames.Add(easingDoubleKeyFrame); var doubleKeyFrameCollection = doubleAnimationUsingKeyFrame1.KeyFrames; var easingDoubleKeyFrame1 = new EasingDoubleKeyFrame { KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(0.15)), Value = 1.4, EasingFunction = new CubicEase() }; doubleKeyFrameCollection.Add(easingDoubleKeyFrame1); Storyboard.SetTarget(doubleAnimationUsingKeyFrame1, ToPage); Storyboard.SetTargetProperty(doubleAnimationUsingKeyFrame1, "(UIElement.RenderTransform).(CompositeTransform.ScaleX)"); storyboard.Children.Add(doubleAnimationUsingKeyFrame1); var doubleAnimationUsingKeyFrame2 = new DoubleAnimationUsingKeyFrames { RepeatBehavior = new RepeatBehavior(TimeSpan.FromSeconds(1)), FillBehavior = FillBehavior.HoldEnd }; var doubleAnimationUsingKeyFrame3 = doubleAnimationUsingKeyFrame2; var keyFrames1 = doubleAnimationUsingKeyFrame3.KeyFrames; var easingDoubleKeyFrame2 = new EasingDoubleKeyFrame { KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(0)), Value = 1, EasingFunction = new CubicEase() }; keyFrames1.Add(easingDoubleKeyFrame2); var doubleKeyFrameCollection1 = doubleAnimationUsingKeyFrame3.KeyFrames; var easingDoubleKeyFrame3 = new EasingDoubleKeyFrame { KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(0.15)), Value = 1.4, EasingFunction = new CubicEase() }; doubleKeyFrameCollection1.Add(easingDoubleKeyFrame3); Storyboard.SetTarget(doubleAnimationUsingKeyFrame3, ToPage); Storyboard.SetTargetProperty(doubleAnimationUsingKeyFrame3, "(UIElement.RenderTransform).(CompositeTransform.ScaleY)"); storyboard.Children.Add(doubleAnimationUsingKeyFrame3); var doubleAnimationUsingKeyFrame4 = new DoubleAnimationUsingKeyFrames { RepeatBehavior = new RepeatBehavior(TimeSpan.FromSeconds(1)), FillBehavior = FillBehavior.HoldEnd }; var doubleAnimationUsingKeyFrame5 = doubleAnimationUsingKeyFrame4; var keyFrames2 = doubleAnimationUsingKeyFrame5.KeyFrames; var easingDoubleKeyFrame4 = new EasingDoubleKeyFrame { KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(0)), Value = 1, EasingFunction = new CubicEase() }; keyFrames2.Add(easingDoubleKeyFrame4); var doubleKeyFrameCollection2 = doubleAnimationUsingKeyFrame5.KeyFrames; var easingDoubleKeyFrame5 = new EasingDoubleKeyFrame { KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(0.15)), Value = 0, EasingFunction = new CubicEase() }; doubleKeyFrameCollection2.Add(easingDoubleKeyFrame5); Storyboard.SetTarget(doubleAnimationUsingKeyFrame5, ToPage); Storyboard.SetTargetProperty(doubleAnimationUsingKeyFrame5, "(UIElement.Opacity)"); storyboard.Children.Add(doubleAnimationUsingKeyFrame5); var fromPage = FromPage; var scaleTransform1 = new ScaleTransform { CenterX = FromPage.ActualWidth/2, CenterY = FromPage.ActualHeight/2, ScaleX = 1, ScaleY = 1 }; fromPage.RenderTransform = scaleTransform1; FromPage.Opacity = 1; var doubleAnimationUsingKeyFrame6 = new DoubleAnimationUsingKeyFrames { RepeatBehavior = new RepeatBehavior(TimeSpan.FromSeconds(1)), FillBehavior = FillBehavior.HoldEnd }; var doubleAnimationUsingKeyFrame7 = doubleAnimationUsingKeyFrame6; var keyFrames3 = doubleAnimationUsingKeyFrame7.KeyFrames; var easingDoubleKeyFrame6 = new EasingDoubleKeyFrame { KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(0)), Value = 0.3, EasingFunction = new SineEase() }; keyFrames3.Add(easingDoubleKeyFrame6); var doubleKeyFrameCollection3 = doubleAnimationUsingKeyFrame7.KeyFrames; var easingDoubleKeyFrame7 = new EasingDoubleKeyFrame { KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(0.15)), Value = 1, EasingFunction = new SineEase() }; doubleKeyFrameCollection3.Add(easingDoubleKeyFrame7); Storyboard.SetTarget(doubleAnimationUsingKeyFrame7, FromPage); Storyboard.SetTargetProperty(doubleAnimationUsingKeyFrame7, "(UIElement.RenderTransform).(CompositeTransform.ScaleX)"); storyboard.Children.Add(doubleAnimationUsingKeyFrame7); var doubleAnimationUsingKeyFrame8 = new DoubleAnimationUsingKeyFrames { RepeatBehavior = new RepeatBehavior(TimeSpan.FromSeconds(1)), FillBehavior = FillBehavior.HoldEnd }; var doubleAnimationUsingKeyFrame9 = doubleAnimationUsingKeyFrame8; var keyFrames4 = doubleAnimationUsingKeyFrame9.KeyFrames; var easingDoubleKeyFrame8 = new EasingDoubleKeyFrame { KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(0)), Value = 0.3, EasingFunction = new SineEase() }; keyFrames4.Add(easingDoubleKeyFrame8); var doubleKeyFrameCollection4 = doubleAnimationUsingKeyFrame9.KeyFrames; var easingDoubleKeyFrame9 = new EasingDoubleKeyFrame { KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(0.15)), Value = 1, EasingFunction = new SineEase() }; doubleKeyFrameCollection4.Add(easingDoubleKeyFrame9); Storyboard.SetTarget(doubleAnimationUsingKeyFrame9, FromPage); Storyboard.SetTargetProperty(doubleAnimationUsingKeyFrame9, "(UIElement.RenderTransform).(CompositeTransform.ScaleY)"); storyboard.Children.Add(doubleAnimationUsingKeyFrame9); var doubleAnimationUsingKeyFrame10 = new DoubleAnimationUsingKeyFrames { RepeatBehavior = new RepeatBehavior(TimeSpan.FromSeconds(1)), FillBehavior = FillBehavior.HoldEnd }; var doubleAnimationUsingKeyFrame11 = doubleAnimationUsingKeyFrame10; var keyFrames5 = doubleAnimationUsingKeyFrame11.KeyFrames; var easingDoubleKeyFrame10 = new EasingDoubleKeyFrame { KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(0)), Value = 0, EasingFunction = new SineEase() }; keyFrames5.Add(easingDoubleKeyFrame10); var doubleKeyFrameCollection5 = doubleAnimationUsingKeyFrame11.KeyFrames; var easingDoubleKeyFrame11 = new EasingDoubleKeyFrame { KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(0.15)), Value = 1, EasingFunction = new SineEase() }; doubleKeyFrameCollection5.Add(easingDoubleKeyFrame11); Storyboard.SetTarget(doubleAnimationUsingKeyFrame11, FromPage); Storyboard.SetTargetProperty(doubleAnimationUsingKeyFrame11, "(UIElement.Opacity)"); storyboard.Children.Add(doubleAnimationUsingKeyFrame11); try { storyboard.Begin(); if (completed != null) { completed.Invoke(); } } catch { base.Play(completed); } }
private void sort8() { int pai, zn; pai = b[8] / 2; zn = b[8] % 2; if (zn == 1)//翻转 { ScaleTransform zn_1 = new ScaleTransform(); zn_1.ScaleY = -1; b5_4.RenderTransform = zn_1; } //选牌 Uri imaUri = new Uri(Src[pai], UriKind.RelativeOrAbsolute); BitmapImage imaSource = new BitmapImage(imaUri); ImageBrush brush = new ImageBrush(); brush.ImageSource = imaSource; b5_4.Background = brush; }
private Size VerticalArrange(Size finalSize) { var scaleTransform = new ScaleTransform { ScaleX = scale, ScaleY = scale }; double heightSoFar = 0; foreach (var child in Children) { var location = new Point(0, heightSoFar * scale); var size = new Size(finalSize.Width / scale, child.DesiredSize.Height); var rect = new Rect(location, size); child.RenderTransform = scaleTransform; child.Arrange(rect); heightSoFar += child.DesiredSize.Height; } return finalSize; }
private Size HorizontalArrange(Size finalSize) { var scaleTransform = new ScaleTransform { ScaleX = scale, ScaleY = scale }; double widthSoFar = 0; foreach (var child in Children) { var location = new Point(widthSoFar * scale, 0); var size = new Size(child.DesiredSize.Width, finalSize.Height / scale); var rect = new Rect(location, size); child.RenderTransform = scaleTransform; child.Arrange(rect); widthSoFar += child.DesiredSize.Width; } return finalSize; }
private void notfocus(object sender, RoutedEventArgs e) { if (isAppBarOpen) { isAppBarOpen = false; Storyboard storyboard = new Storyboard(); TranslateTransform trans = new TranslateTransform();// { X = 60.0, Y = 0.0 }; //backgr.RenderTransformOrigin = new Point(250.0, 0.0); backgr.RenderTransform = trans; DoubleAnimation moveAnim = new DoubleAnimation(); moveAnim.Duration = TimeSpan.FromMilliseconds(250); moveAnim.From = 250 - 64; moveAnim.To = 0; //moveAnim.BeginTime = TimeSpan.FromSeconds(0.85); SineEase easingFunction = new SineEase(); easingFunction.EasingMode = EasingMode.EaseInOut; moveAnim.EasingFunction = easingFunction; Storyboard.SetTarget(moveAnim, backgr); Storyboard.SetTargetProperty(moveAnim, "(UIElement.RenderTransform).(TranslateTransform.X)"); //storyboard.Completed += new System.EventHandler(storyboard_Completed); storyboard.Children.Add(moveAnim); storyboard.Begin(); Storyboard storyboardscale = new Storyboard(); ScaleTransform scale = new ScaleTransform();//{ X = 1.0, Y = 1.0 }; //appBar.RenderTransformOrigin = new Point(250.0/64, 0.0); appBar.RenderTransform = scale; DoubleAnimation scaleAnim = new DoubleAnimation(); scaleAnim.Duration = TimeSpan.FromMilliseconds(250); scaleAnim.From = 250.0 / 64; scaleAnim.To = 1; SineEase easingFunctionscale = new SineEase(); easingFunctionscale.EasingMode = EasingMode.EaseInOut; scaleAnim.EasingFunction = easingFunctionscale; Storyboard.SetTarget(scaleAnim, appBar); Storyboard.SetTargetProperty(scaleAnim, "(UIElement.RenderTransform).(ScaleTransform.ScaleX)"); //storyboardscale.Completed += new System.EventHandler(storyboard_Completed); storyboardscale.Children.Add(scaleAnim); storyboardscale.Begin(); } }
/// <summary> /// Update word box transform to match current UI size. /// </summary> private void UpdateWordBoxTransform() { WriteableBitmap bitmap = PreviewImage.Source as WriteableBitmap; if (bitmap != null) { // Used for text overlay. // Prepare scale transform for words since image is not displayed in original size. ScaleTransform scaleTrasform = new ScaleTransform { CenterX = 0, CenterY = 0, ScaleX = PreviewImage.ActualWidth / bitmap.PixelWidth, ScaleY = PreviewImage.ActualHeight / bitmap.PixelHeight }; foreach (var item in wordBoxes) { item.Transform(scaleTrasform); } } }
protected override void PrepareContainerForItemOverride(DependencyObject element, object item) { base.PrepareContainerForItemOverride(element, item); ListBoxItem item2 = element as ListBoxItem; if (item2 != null && !items.Contains(item2)) { item2.Visibility = Visibility.Collapsed; if (Orientation == Orientation.Horizontal) item2.HorizontalAlignment = HorizontalAlignment.Center; else item2.VerticalAlignment = VerticalAlignment.Center; items.Add(item2); TransformGroup myTransformGroup = new TransformGroup(); ScaleTransform scaleTransform = new ScaleTransform(); TranslateTransform translateTransform = new TranslateTransform(); PlaneProjection planeProjection = new PlaneProjection() { CenterOfRotationX = .5, CenterOfRotationY = .5, CenterOfRotationZ = .5 }; myTransformGroup.Children.Add(scaleTransform); myTransformGroup.Children.Add(translateTransform); // Associate the transforms to the object item2.RenderTransformOrigin = itemRenderTransformOrigin; item2.RenderTransform = myTransformGroup; item2.Projection = planeProjection; if (items.Count < pageCount + 1) { SetLocation(item2, items.Count - 1); } } }
public ElementAdapter(FrameworkElement el) { element_ = el; /** * copy default property */ if(!double.IsNaN(Element.Width)){ Width = Element.Width; } if (!double.IsNaN(Element.Height)) { Height = Element.Height; } X = Canvas.GetLeft(Element); Y = Canvas.GetTop(Element); Alpha = Element.Opacity; /** * Transform */ ScaleTransform myScaleTransform = new ScaleTransform(); myScaleTransform.ScaleX = 1.0; myScaleTransform.ScaleY = 1.0; RotateTransform myRotateTransform = new RotateTransform(); myRotateTransform.Angle = 0; TranslateTransform myTranslate = new TranslateTransform(); myTranslate.X = 0; myTranslate.X = 0; SkewTransform mySkew = new SkewTransform(); mySkew.AngleX = 0; mySkew.AngleY = 0; transformGroup_ = new TransformGroup(); transformGroup_.Children.Add(myScaleTransform); transformGroup_.Children.Add(myRotateTransform); transformGroup_.Children.Add(myTranslate); transformGroup_.Children.Add(mySkew); element_.RenderTransform = transformGroup_; }
private void SetupCatAssets() { ScaleTransform flipTransform = new ScaleTransform() { ScaleX = -1.0 }; int bodyCount = kinectSensor.BodyFrameSource.BodyCount; catEyeRightOpen = new Image[bodyCount]; catEyeRightClosed = new Image[bodyCount]; catEyeLeftOpen = new Image[bodyCount]; catEyeLeftClosed = new Image[bodyCount]; catNose = new Image[bodyCount]; for (int i = 0; i < kinectSensor.BodyFrameSource.BodyCount; i++) { catEyeRightOpen[i] = new Image() { Source = new BitmapImage(new Uri(this.BaseUri, "Assets/CatEye_left_open.png")), Width = 30, Height = 20, RenderTransformOrigin = new Point(0.5, 0.5), RenderTransform = flipTransform }; catEyeRightClosed[i] = new Image() { Source = new BitmapImage(new Uri(this.BaseUri, "Assets/CatEye_left_closed.png")), Width = 30, Height = 20, RenderTransformOrigin = new Point(0.5, 0.5), RenderTransform = flipTransform }; catEyeLeftOpen[i] = new Image() { Source = new BitmapImage(new Uri(this.BaseUri, "Assets/CatEye_left_open.png")), Width = 30, Height = 20 }; catEyeLeftClosed[i] = new Image() { Source = new BitmapImage(new Uri(this.BaseUri, "Assets/CatEye_left_closed.png")), Width = 30, Height = 20 }; catEyeLeftClosed[i].RenderTransformOrigin = new Point(0.5, 0.5); catNose[i] = new Image() { Source = new BitmapImage(new Uri(this.BaseUri, "Assets/CatNose.png")), Width = 40, Height = 25 }; } }
public void Transform(ScaleTransform scale) { // Scale word box bounding rect and update properties. UpdateProps(scale.TransformBounds(word.BoundingRect)); }
private void openAppBarAnimation() { Storyboard storyboard = new Storyboard(); TranslateTransform trans = new TranslateTransform(); backgr.RenderTransform = trans; DoubleAnimation moveAnim = new DoubleAnimation(); moveAnim.Duration = TimeSpan.FromMilliseconds(250); moveAnim.From = 0; moveAnim.To = 250 - 64; SineEase easingFunction = new SineEase(); easingFunction.EasingMode = EasingMode.EaseIn; moveAnim.EasingFunction = easingFunction; Storyboard.SetTarget(moveAnim, backgr); Storyboard.SetTargetProperty(moveAnim, "(UIElement.RenderTransform).(TranslateTransform.X)"); storyboard.Children.Add(moveAnim); storyboard.Begin(); Storyboard storyboardscale = new Storyboard(); ScaleTransform scale = new ScaleTransform(); appBar.RenderTransform = scale; DoubleAnimation scaleAnim = new DoubleAnimation(); scaleAnim.Duration = TimeSpan.FromMilliseconds(250); scaleAnim.From = 1.0; scaleAnim.To = 250.0 / 64; SineEase easingFunctionscale = new SineEase(); easingFunctionscale.EasingMode = EasingMode.EaseIn; scaleAnim.EasingFunction = easingFunctionscale; Storyboard.SetTarget(scaleAnim, appBar); Storyboard.SetTargetProperty(scaleAnim, "(UIElement.RenderTransform).(ScaleTransform.ScaleX)"); storyboardscale.Children.Add(scaleAnim); storyboardscale.Begin(); // change Size of HB hamburgerButton.Width = 250; infoButton.Width = 250; }
private void AddInitialAnimation() { var tf = new TransformGroup(); RenderTransform = tf; ApplyRandomAnimationEffect(this, new Duration(TimeSpan.FromSeconds(1))); var scale = new ScaleTransform { ScaleX = 0, ScaleY = 0, CenterX = 0.5, CenterY = 0.5 }; tf.Children.Add(scale); var sScale = CreateDPAnimation(scale, "ScaleY", new Duration(TimeSpan.FromSeconds(1)), 0, 1); CreateDPAnimation(scale, "ScaleX", new Duration(TimeSpan.FromSeconds(1)), 0, 1, false, false, new SineEase(), sScale); sScale.Begin(); }