protected override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); 產生手寫軌跡的測試資料(); solidColorBrush1 = new SolidColorBrush(ColorsHelper.Parse("ff1a1a1a")); solidColorBrush2 = new SolidColorBrush(ColorsHelper.Parse("ff999999")); solidColorBrush3 = new SolidColorBrush(ColorsHelper.Parse("ffff0000")); solidColorBrush4 = new SolidColorBrush(ColorsHelper.Parse("ff006cff")); solidColorBrush5 = new SolidColorBrush(ColorsHelper.Parse("ff0da522")); wbContentImage = BitmapFactory.New(768, 1024); wbContentImage.Clear(Colors.Transparent); cnUsingWriteableBitmap.Source = wbContentImage; d2dBrush = new ImageBrush(); cnUsingGeometries.Background = d2dBrush; // Safely dispose any previous instance // Creates a new DeviceManager (Direct3D, Direct2D, DirectWrite, WIC) deviceManager = new DeviceManager(); shapeRenderer = new ShapeRenderer(); DisplayInformation DisplayInformation = Windows.Graphics.Display.DisplayInformation.GetForCurrentView(); int pixelWidth = (int)(cnUsingGeometries.Width * DisplayInformation.LogicalDpi / 96.0); int pixelHeight = (int)(cnUsingGeometries.Height * DisplayInformation.LogicalDpi / 96.0); d2dTarget = new SurfaceImageSourceTarget(pixelWidth, pixelHeight); d2dBrush.ImageSource = d2dTarget.ImageSource; imgUsingInkManager.Source = d2dTarget.ImageSource; // Add Initializer to device manager deviceManager.OnInitialize += d2dTarget.Initialize; deviceManager.OnInitialize += shapeRenderer.Initialize; // Render the cube within the CoreWindow d2dTarget.OnRender += shapeRenderer.Render; // Initialize the device manager and all registered deviceManager.OnInitialize deviceManager.Initialize(DisplayProperties.LogicalDpi); // Setup rendering callback //CompositionTarget.Rendering += CompositionTarget_Rendering; // Callback on DpiChanged DisplayProperties.LogicalDpiChanged += DisplayProperties_LogicalDpiChanged; #region Scenario1 Scenario1Drawing = new Scenario1ImageSource((int)cnUsingDirectXs.Width, (int)cnUsingDirectXs.Height, true); // Use Scenario1Drawing as a source for the Ellipse shape's fill cnUsingDirectXs.Background = new ImageBrush() { ImageSource = Scenario1Drawing }; #endregion }
/// <summary> /// Invoked when this page is about to be displayed in a Frame. /// </summary> /// <param name="e">Event data that describes how this page was reached. The Parameter /// property is typically used to configure the page.</param> protected override void OnNavigatedTo(NavigationEventArgs e) { d2dDragHandler = new DragHandler(d2dCanvas) { CursorOver = new Windows.UI.Core.CoreCursor(Windows.UI.Core.CoreCursorType.SizeAll, 1) }; d2dBrush = new ImageBrush(); d2dRectangle.Fill = d2dBrush; effectRenderer = new EffectRenderer(); deviceManager = new DeviceManager(); int pixelWidth = (int)(d2dRectangle.Width * DisplayProperties.LogicalDpi / 96.0); int pixelHeight = (int)(d2dRectangle.Height * DisplayProperties.LogicalDpi / 96.0); d2dTarget = new SurfaceImageSourceTarget(pixelWidth, pixelHeight); d2dBrush.ImageSource = d2dTarget.ImageSource; d2dTarget.OnRender += effectRenderer.Render; deviceManager.OnInitialize += d2dTarget.Initialize; deviceManager.OnInitialize += effectRenderer.Initialize; deviceManager.Initialize(DisplayProperties.LogicalDpi); var window = CoreWindow.GetForCurrentThread(); if (window.Visible) BindRenderingEvents(); window.VisibilityChanged += (_, args) => { if (args.Visible) BindRenderingEvents(); else UnbindRenderingEvents(); }; }
private void ItemContainerGenerator_ItemsChanged(object sender, ItemsChangedEventArgs e) { if (e.Action == 1) { Position item = lstPositions.Items.Last() as Position; layers = new MapLayer(); image = new BitmapImage(); image.UriSource = (new Uri(SelectedFriend.Picture, UriKind.Absolute)); grid = new Grid(); grid.DataContext = item; grid.RightTapped += grid_RightTapped; textBlock = new TextBlock(); textBlock.Text = item.Counter.ToString(); textBlock.VerticalAlignment = VerticalAlignment.Bottom; textBlock.HorizontalAlignment = HorizontalAlignment.Center; brush = new ImageBrush(); brush.ImageSource = image; ellipse = new Ellipse(); ellipse.Height = 100; ellipse.Width = 100; ellipse.Fill = brush; grid.Children.Add(ellipse); grid.Children.Add(textBlock); layers.Children.Add(grid); MapLayer.SetPosition(grid, new Location(item.Latitude, item.Longitude)); myMap.Children.Add(layers); } }
public MediaPlayer() { this.InitializeComponent(); ImageBrush IBbackground = new ImageBrush(); BitmapImage bmpBack = new BitmapImage(new Uri("ms-appx:///Assets/backG.jpg")); IBbackground.ImageSource = bmpBack; grBackGround.Background = IBbackground; ImageBrush IBback01 = new ImageBrush(); BitmapImage bmpBack01 = new BitmapImage(new Uri("ms-appx:///Assets/back01.jpg")); IBback01.ImageSource = bmpBack01; grBack01.Background = IBback01; ImageBrush IBback02 = new ImageBrush(); BitmapImage bmpBack02 = new BitmapImage(new Uri("ms-appx:///Assets/back2.jpg")); IBback02.ImageSource = bmpBack02; grBack02.Background = IBback02; ImageBrush IBback03 = new ImageBrush(); BitmapImage bmpBack03 = new BitmapImage(new Uri("ms-appx:///Assets/back3.jpg")); IBback03.ImageSource = bmpBack03; grBack03.Background = IBback03; cbSite.Items.Add("mp3.zing.vn"); cbSite.Items.Add("nhaccuatui.com"); myMedia.MediaEnded += media_MediaEnded; }
private ImageBrush setBrush() { image = new BitmapImage(new Uri("ms-appx:///Assets/bomb-30x31.png")); ImageBrush imageb = new ImageBrush(); imageb.ImageSource = image; return imageb; }
/// <summary> /// Invoked when this page is about to be displayed in a Frame. /// </summary> /// <param name="e">Event data that describes how this page was reached. The Parameter /// property is typically used to configure the page.</param> protected override void OnNavigatedTo(NavigationEventArgs e) { var imageBrush = new ImageBrush(); imageBrush.ImageSource = _sisWrapper; rectangle.Fill = imageBrush; _sisWrapper.BeginDraw(); var context = new SharpDX.Direct2D1.DeviceContext(new IntPtr(_sisWrapper.GetDeviceContext())); context.Clear(new SharpDX.Color4(0.4f, 0.3f, 0.15f, 1.0f)); var random = new Random(); for (int i = 0; i < 20; ++i) { var brush = new SharpDX.Direct2D1.SolidColorBrush(context, new SharpDX.Color4( (float)random.NextDouble(), (float)random.NextDouble(), (float)random.NextDouble(), 1.0f)); var left = (float)(250.0f * random.NextDouble()); var top = (float)(250.0f * random.NextDouble()); context.FillRectangle(new SharpDX.RectangleF( left, top, left + 50.0f, top + 50.0f), brush); } _sisWrapper.EndDraw(); }
public TiledBackground() { this.backgroundImageBrush = new ImageBrush(); this.Background = backgroundImageBrush; this.SizeChanged += TiledBackground_SizeChanged; }
protected override void OnNavigatedTo(NavigationEventArgs e) { item = e.Parameter as Eventos; if (item.Nombre != null) nombre.Text = item.Nombre; if (item.Fecha != null) fecha.Text = item.Fecha; if (item.Hora != null) hora.Text = item.Hora; if (item.Lugar != null) lugar.Text = item.Lugar; if (item.Descripcion != null) descri.Text = item.Descripcion; if (item.Foto != null) { ImageBrush brush = new ImageBrush(); brush.Stretch = Stretch.UniformToFill; BitmapImage image = new BitmapImage(new Uri(item.Foto)); brush.ImageSource = image; foto.Fill = brush; } }
private ImageBrush setBrush(string uriPath) { image = new BitmapImage(new Uri(uriPath)); ImageBrush imageb = new ImageBrush(); imageb.ImageSource = image; return imageb; }
public override Rectangle Render() { Rectangle rectangle = new Rectangle(); //rectangle.ManipulationMode = ManipulationModes.All; //rectangle.ManipulationDelta += rectangle_ManipulationDelta; //rectangle.Tapped += rectangle_Tapped; ParentCanvas.ManipulationMode = ManipulationModes.All; ParentCanvas.ManipulationDelta += rectangle_ManipulationDelta; ParentCanvas.Tapped += rectangle_Tapped; rectangle.StrokeThickness = 3; rectangle.Height = Utility.SPRITE_HEIGHT; rectangle.Width = Utility.SPRITE_WIDTH; _participant = rectangle; ImageBrush ib = new ImageBrush(); ib.ImageSource = new BitmapImage(new Uri("ms-appx:/Assets/ship 90x60.png", UriKind.RelativeOrAbsolute)); _participant.Fill = ib; _participant.SetValue(Canvas.LeftProperty, _position.X); _participant.SetValue(Canvas.TopProperty, _position.Y); return _participant; }
protected override void OnNavigatedTo(NavigationEventArgs e) { item = e.Parameter as Fundacion; if (item.Nombre != null) nombre.Text = item.Nombre; if (item.Direccion != null) direccion.Text = item.Direccion; if (item.Correo != null) correo.Text = item.Correo; if (item.Telefono != null) telefono.Text = item.Telefono; if (item.Cuenta_bancaria != null) cuentaBancaria.Text = item.Cuenta_bancaria; if (item.Descripcion != null) descri.Text = item.Descripcion; if (item.Foto != null) { ImageBrush brush = new ImageBrush(); brush.Stretch = Stretch.UniformToFill; BitmapImage image = new BitmapImage(new Uri(item.Foto)); brush.ImageSource = image; foto.Fill = brush; } }
async void getPhoto_Click(object sender, RoutedEventArgs e) { if (string.IsNullOrEmpty(previousDays.Text)) return; using (var client = new HttpClient()) { var fullBingUrl = string.Format("{0}{1}", bingUrlPrefix, previousDays.Text); var xmlString = await client.GetStringAsync(new Uri(fullBingUrl)); var doc = XDocument.Parse(xmlString); var imageUrlElement = doc .Descendants("image") .Descendants("url") .FirstOrDefault(); if (imageUrlElement != null) { var imageUrl = imageUrlElement.Value; var imageBrush = new ImageBrush(); imageBrush.ImageSource = new BitmapImage(new Uri("http://www.bing.com/" + imageUrl)); mainGrid.Background = imageBrush; } } }
protected override void LoadState(Object navigationParameter, Dictionary<String, Object> pageState) { Random random = new Random(); Uri uri = new Uri("ms-appx:///Assets/background_" + random.Next(1,7) +".jpg", UriKind.RelativeOrAbsolute); ImageBrush background = new ImageBrush(); background.ImageSource = new BitmapImage(uri); this.SplitPage_Main_Grid.Background = background; var group = SampleDataSource.GetGroup((String)navigationParameter); this.DefaultViewModel["Group"] = group; this.DefaultViewModel["Items"] = group.Items; if (pageState == null) { this.itemListView.SelectedItem = null; if (!this.UsingLogicalPageNavigation() && this.itemsViewSource.View != null) { this.itemsViewSource.View.MoveCurrentToFirst(); } } else { if (pageState.ContainsKey("SelectedItem") && this.itemsViewSource.View != null) { var selectedItem = SampleDataSource.GetItem((String)pageState["SelectedItem"]); this.itemsViewSource.View.MoveCurrentTo(selectedItem); } } }
public async void LoadData(IEnumerable<XElement> sprites, StorageFile spriteSheetFile, string appExtensionId) { var bitmapImage = new BitmapImage(); using (var stream = await spriteSheetFile.OpenReadAsync()) { await bitmapImage.SetSourceAsync(stream); } //xaml List<ImageListItem> listOfImages = new List<ImageListItem>(); foreach (var sprite in sprites) { var row = int.Parse(sprite.Attributes("Row").First().Value); var col = int.Parse(sprite.Attributes("Column").First().Value); var brush = new ImageBrush(); brush.ImageSource = bitmapImage; brush.Stretch = Stretch.UniformToFill; brush.AlignmentX = AlignmentX.Left; brush.AlignmentY = AlignmentY.Top; brush.Transform = new CompositeTransform() { ScaleX = 2.35, ScaleY = 2.35, TranslateX = col * (-140), TranslateY = row * (-87) }; listOfImages.Add(new ImageListItem() { Title = sprite.Attributes("Title").First().Value, SpriteSheetBrush = brush, File = sprite.Attributes("File").First().Value, AppExtensionId = appExtensionId }); } lbPictures.ItemsSource = listOfImages; }
private async void seleccionarImagen(object sender, RoutedEventArgs e) { FileOpenPicker picker = new FileOpenPicker(); picker.SuggestedStartLocation = PickerLocationId.PicturesLibrary; picker.FileTypeFilter.Add(".png"); file = await picker.PickSingleFileAsync(); BitmapImage image = new BitmapImage(); try { using (var stream = await file.OpenAsync(FileAccessMode.Read)) { await image.SetSourceAsync(stream); } ImageBrush brush = new ImageBrush(); brush.Stretch = Stretch.UniformToFill; brush.ImageSource = image; imagen.Fill = brush; } catch (Exception exception) { } }
/// <summary> /// Invoked when this page is about to be displayed in a Frame. /// </summary> /// <param name="e">Event data that describes how this page was reached. The Parameter /// property is typically used to configure the page.</param> protected override void OnNavigatedTo(NavigationEventArgs e) { d2dDragHandler = new DragHandler(d2dCanvas) { CursorOver = new Windows.UI.Core.CoreCursor(Windows.UI.Core.CoreCursorType.SizeAll, 1) }; d2dBrush = new ImageBrush(); d2dRectangle.Fill = d2dBrush; effectRenderer = new EffectRenderer(d2dRectangle, root); deviceManager = new DeviceManager(); int pixelWidth = (int)(d2dRectangle.Width * DisplayProperties.LogicalDpi / 96.0); int pixelHeight = (int)(d2dRectangle.Height * DisplayProperties.LogicalDpi / 96.0); d2dTarget = new SurfaceImageSourceTarget(pixelWidth, pixelHeight); d2dBrush.ImageSource = d2dTarget.ImageSource; d2dTarget.OnRender += effectRenderer.Render; deviceManager.OnInitialize += d2dTarget.Initialize; deviceManager.OnInitialize += effectRenderer.Initialize; deviceManager.Initialize(DisplayProperties.LogicalDpi); // Setup rendering callback CompositionTarget.Rendering += CompositionTarget_Rendering; }
/// <summary> /// Invoked when this page is about to be displayed in a Frame. /// </summary> /// <param name="e">Event data that describes how this page was reached. The Parameter /// property is typically used to configure the page.</param> protected override void OnNavigatedTo(NavigationEventArgs e) { var imageBrush = new ImageBrush(); imageBrush.ImageSource = _d2dComponent; rectangle.Fill = imageBrush; _d2dComponent.BeginDraw(); _d2dComponent.Clear(Windows.UI.Colors.Bisque); var random = new Random(); for (int i = 0; i < 20; ++i) { _d2dComponent.FillRectangle( random.Next(0, 250), random.Next(0, 250), 50, 50, Windows.UI.Color.FromArgb( (byte)255, (byte)random.Next(0, 255), (byte)random.Next(0, 255), (byte)random.Next(0, 255))); } _d2dComponent.EndDraw(); }
protected override void LoadState(Object navigationParameter, Dictionary<String, Object> pageState) { Random random = new Random(); Uri uri = new Uri("ms-appx:///Assets/background_" + random.Next(1,7) +".jpg", UriKind.RelativeOrAbsolute); ImageBrush background = new ImageBrush(); background.ImageSource = new BitmapImage(uri); this.UpdateDataPage_Main_Grid.Background = background; }
public ImageLoaderQueueItem DisplayImage(String uri, ImageBrush imageBrush) { return DownloadImage(uri, (state, url, v, img) => { if (state == LoadingState.Completed) { imageBrush.ImageSource = img; } }); }
public void level() { switch (App.level) { case 1: ImageBrush brush1 = new ImageBrush(); brush1.ImageSource = new BitmapImage(new Uri("ms-appx:///Pictures/cooltext174981939091066.png", UriKind.Absolute)); image1.Source = brush1.ImageSource; ImageBrush brush2 = new ImageBrush(); brush2.ImageSource = new BitmapImage(new Uri("ms-appx:///Pictures/cooltext174877648874930.png", UriKind.Absolute)); image2.Source = brush2.ImageSource; textBlock.Text = App.easyLevel.ToString(); break; case 2: if (App.gameOver==false) { ImageBrush brush3 = new ImageBrush(); brush3.ImageSource = new BitmapImage(new Uri("ms-appx:///Pictures/cooltext174981939091066.png", UriKind.Absolute)); image1.Source = brush3.ImageSource; ImageBrush brush4 = new ImageBrush(); brush4.ImageSource = new BitmapImage(new Uri("ms-appx:///Pictures/cooltext174907777842293.png", UriKind.Absolute)); image2.Source = brush4.ImageSource; textBlock.Text = App.mediumLevel.ToString(); } else if (App.gameOver==true) { ImageBrush brush5 = new ImageBrush(); brush5.ImageSource = new BitmapImage(new Uri("ms-appx:///Pictures/cooltext175048263066794.png", UriKind.Absolute)); image1.Source = brush5.ImageSource; } break; case 3: if (App.gameOver == false) { ImageBrush brush6 = new ImageBrush(); brush6.ImageSource = new BitmapImage(new Uri("ms-appx:///Pictures/cooltext174981939091066.png", UriKind.Absolute)); image1.Source = brush6.ImageSource; ImageBrush brush7 = new ImageBrush(); brush7.ImageSource = new BitmapImage(new Uri("ms-appx:///Pictures/cooltext175048491304424.png", UriKind.Absolute)); image2.Source = brush7.ImageSource; textBlock.Text = App.hardLevel.ToString(); } else if (App.gameOver == true) { ImageBrush brush8 = new ImageBrush(); brush8.ImageSource = new BitmapImage(new Uri("ms-appx:///Pictures/cooltext175048350622307.png", UriKind.Absolute)); image1.Source = brush8.ImageSource; } break; } }
public void loadBackground() { //make a image brush using backgroundImage and assign it to the background of the Grid ImageBrush myBrush = new ImageBrush(); Image image = new Image(); image.Source = new BitmapImage(new Uri("ms-appx:///Images/" + App.backgroundImage)); myBrush.ImageSource = image.Source; landScapeMode.Background = myBrush; }
protected override void OnNavigatedTo(NavigationEventArgs e) { FotoMascota foto = e.Parameter as FotoMascota; ImageBrush brush = new ImageBrush(); brush.Stretch = Stretch.Uniform; BitmapImage image = new BitmapImage(new Uri(foto.Url)); brush.ImageSource = image; imagenMascota.Fill = brush; }
protected override void OnApplyTemplate() { base.OnApplyTemplate(); _imageBrush = (ImageBrush)GetTemplateChild("imageBrush"); _imageBrush.ImageOpened += ImageOpened; _imageBrush.ImageFailed += ImageFailed; _imageBrush.ImageSource = Source; _imageBrush.Stretch = Stretch; }
private async void MainPage_Loaded(object sender, RoutedEventArgs e) { ImageBrush brush = new ImageBrush(); StorageFile file = await KnownFolders.PicturesLibrary.GetFileAsync("teste.png"); BitmapImage bitmapImage = await LoadImage(file); brush.ImageSource = bitmapImage; brush.Stretch = Stretch.Uniform; ; brush.AlignmentX = AlignmentX.Center; brush.AlignmentY = AlignmentY.Top; output.Background = brush; }
protected override void LoadState(Object navigationParameter, Dictionary<String, Object> pageState) { Random random = new Random(); Uri uri = new Uri("ms-appx:///Assets/background_" + random.Next(1,7) +".jpg", UriKind.RelativeOrAbsolute); ImageBrush background = new ImageBrush(); background.ImageSource = new BitmapImage(uri); this.MainPage_Grid.Background = background; var sampleDataGroups = SampleDataSource.GetGroups("AllGroups"); this.DefaultViewModel["Items"] = sampleDataGroups; }
/// <summary> /// Convert the ImageFileName to an BitmapImage object. /// </summary> /// <param name="value">The image file name.</param> /// <param name="targetType">BitmapImage</param> /// <param name="parameter">The source data being passed to the target.</param> /// <param name="language">The language of the conversion.</param> /// <returns>The converted value.</returns> public object Convert(object value, Type targetType, object parameter, string language) { Uri uri = value as Uri; ImageBrush imageBrush = new ImageBrush(); BitmapImage bitmapImage = new BitmapImage { UriSource = uri }; imageBrush.ImageSource = bitmapImage; return imageBrush; }
private async void MainPage_Loaded(object sender, RoutedEventArgs e) { ImageBrush brush = new ImageBrush(); StorageFile arquivo = await KnownFolders.PicturesLibrary.GetFileAsync("teste.png"); BitmapImage bitmapImage = await CarregarImagem(arquivo); brush.ImageSource = bitmapImage; brush.Stretch = Stretch.Uniform; ; brush.AlignmentX = AlignmentX.Center; brush.AlignmentY = AlignmentY.Top; output.Background = brush; tamCaneta = 6; corCaneta = new SolidColorBrush(Colors.Red); }
protected override void OnNavigatedTo(NavigationEventArgs e) { item = e.Parameter as GaleryItem; date.Text = item.Date; ImageBrush brush = new ImageBrush(); brush.Stretch = Stretch.UniformToFill; BitmapImage image = new BitmapImage(new Uri(item.Url)); brush.ImageSource = image; img.Fill = brush; }
/// <summary> /// Invoked when this page is about to be displayed in a Frame. /// </summary> /// <param name="e">Event data that describes how this page was reached. The Parameter /// property is typically used to configure the page.</param> protected override void OnNavigatedTo(NavigationEventArgs e) { pointers = new List<PointerData>(); // Get the Screen size var bounds = Window.Current.Bounds; double height = bounds.Height; double width = bounds.Width; Debug.WriteLine("Screen width:" + width + " Screen height" + height); _Rect.Width = width; _Rect.Height = height; int pixelWidth = (int)(_Rect.Width * DisplayProperties.LogicalDpi / 96.0); int pixelHeight = (int)(_Rect.Height * DisplayProperties.LogicalDpi / 96.0); #region sharpDX Initialization // Use Rectangle that makes sharpDX to draw d2dBrush = new ImageBrush(); _Rect.Fill = d2dBrush; // Safely dispose any previous instance // Creates a new DeviceManager (Direct3D, Direct2D, DirectWrite, WIC) deviceManager = new DeviceManager(); // New CubeRenderer shapeRenderer = new ShapeRenderer(pointers); fpsRenderer = new FpsRenderer(); d2dTarget = new SurfaceImageSourceTarget(pixelWidth, pixelHeight); d2dBrush.ImageSource = d2dTarget.ImageSource; // Add Initializer to device manager deviceManager.OnInitialize += d2dTarget.Initialize; deviceManager.OnInitialize += shapeRenderer.Initialize; deviceManager.OnInitialize += fpsRenderer.Initialize; // Render the cube within the CoreWindow d2dTarget.OnRender += shapeRenderer.Render; d2dTarget.OnRender += fpsRenderer.Render; // Initialize the device manager and all registered deviceManager.OnInitialize deviceManager.Initialize(DisplayProperties.LogicalDpi); // Setup rendering callback CompositionTarget.Rendering += CompositionTarget_Rendering; // Callback on DpiChanged DisplayProperties.LogicalDpiChanged += DisplayProperties_LogicalDpiChanged; #endregion }
private CalendarCellStyle createBloodyCellStyle() { CalendarCellStyle c = new CalendarCellStyle(); c.DecorationStyle = new Style(typeof(Border)); c.ContentStyle = new Style(typeof(TextBlock)); ImageBrush background = new ImageBrush(); background.ImageSource = new BitmapImage(new Uri("ms-appx:///Assets/blood-drop-icon.png")); c.DecorationStyle.Setters.Add(new Setter(Border.BackgroundProperty, background)); c.ContentStyle.Setters.Add(new Setter(TextBlock.FontSizeProperty, 35)); c.ContentStyle.Setters.Add(new Setter(TextBlock.HorizontalAlignmentProperty, HorizontalAlignment.Center)); c.ContentStyle.Setters.Add(new Setter(TextBlock.VerticalAlignmentProperty, VerticalAlignment.Center)); return c; }
public object ConvertToNative(Brush brush, object context) { winMedia.Brush winBrush = null; // SolidColorBrush if (brush is SolidColorBrush) { SolidColorBrush xamBrush = brush as SolidColorBrush; winBrush = new winMedia.SolidColorBrush { Color = ConvertColor(xamBrush.Color) }; } // LinearGradientBrush else if (brush is LinearGradientBrush) { LinearGradientBrush xamBrush = brush as LinearGradientBrush; winBrush = new winMedia.LinearGradientBrush { StartPoint = ConvertPoint(xamBrush.StartPoint), EndPoint = ConvertPoint(xamBrush.EndPoint), SpreadMethod = ConvertGradientSpread(xamBrush.SpreadMethod) }; foreach (GradientStop xamGradientStop in xamBrush.GradientStops) { winMedia.GradientStop winGradientStop = new winMedia.GradientStop { Color = ConvertColor(xamGradientStop.Color), Offset = xamGradientStop.Offset }; (winBrush as winMedia.LinearGradientBrush).GradientStops.Add(winGradientStop); } } else if (brush is ImageBrush) { ImageBrush xamBrush = brush as ImageBrush; winBrush = new winMedia.ImageBrush { Stretch = (winMedia.Stretch)(int) xamBrush.Stretch, AlignmentX = (winMedia.AlignmentX)(int) xamBrush.AlignmentX, AlignmentY = (winMedia.AlignmentY)(int) xamBrush.AlignmentY, }; ImageSource xamImageSource = (brush as ImageBrush).ImageSource; if (xamImageSource != null) { IImageSourceHandler handler = null; if (xamImageSource.GetType() == typeof(FileImageSource)) { handler = new FileImageSourceHandler(); } else if (xamImageSource.GetType() == typeof(StreamImageSource)) { handler = new StreamImageSourceHandler(); } else if (xamImageSource.GetType() == typeof(UriImageSource)) { handler = new UriImageSourceHandler(); } if (handler != null) { Task <winMedia.ImageSource> winImageSourceTask = handler.LoadImageAsync(xamImageSource); winImageSourceTask.ContinueWith((task) => { winFound.IAsyncAction asyncAction = winBrush.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { (winBrush as winMedia.ImageBrush).ImageSource = task.Result; }); }); } } } if (winBrush != null) { winBrush.Transform = brush.Transform?.GetNativeObject() as winMedia.MatrixTransform; // TODO: RelativeTransform and Opacity } return(winBrush); }