private async void Current_SizeChanged(object sender, Windows.UI.Core.WindowSizeChangedEventArgs e) { var height = ApplicationView.GetForCurrentView().VisibleBounds.Height; var width = ApplicationView.GetForCurrentView().VisibleBounds.Width; if (UWPPlatformTool.IsMobile) { border.Width = this.Width = width; border.Height = this.Height = height; } else { border.Width = width; border.Height = height; this.Height = height * 0.8; this.Width = this.Height * 1.6; } SetCanvas(); MyCanvas.Invalidate(); await Task.Delay(10); SetCanvas(); MyCanvas.Invalidate(); }
private void SetCanvas() { var w = MainWorkSapce.ActualWidth - 40; // var h = MainWorkSapce.ActualHeight - 40; // if (w <= 0 || h <= 0) { return; } if (_size_mode == 0) //1:1 { var l = w > h ? h : w; MyCanvas.Width = MyCanvas.Height = l; } else if (_size_mode == 1) //4:3 { if (w <= h) { MyCanvas.Width = w; MyCanvas.Height = MyCanvas.Width * 3 / 4; } else { if (w / h <= (double)4 / 3) { MyCanvas.Width = w; MyCanvas.Height = MyCanvas.Width * 3 / 4; } else { MyCanvas.Height = h; MyCanvas.Width = MyCanvas.Height * 4 / 3; } } } else //3:4 { if (h <= w) { MyCanvas.Height = h; MyCanvas.Width = MyCanvas.Height * 3 / 4; } else { if (h / w <= (double)4 / 3) { MyCanvas.Height = h; MyCanvas.Width = MyCanvas.Height * 3 / 4; } else { MyCanvas.Width = w; MyCanvas.Height = MyCanvas.Width * 4 / 3; } } } MyCanvas.Invalidate(); }
private void UpdateEffect() { // Update Video Effect's values if (PageViewModel.SelectedEffect == null) { return; } MyCanvas.Invalidate(); }
private void Filters_ItemClick(object sender, ItemClickEventArgs e) { foreach (var item in Filters.Items) { (((item as GridViewItem).Content as StackPanel).Children[1] as Border).Background = new SolidColorBrush(Colors.Pink); ((((item as GridViewItem).Content as StackPanel).Children[1] as Border).Child as TextBlock).Foreground = new SolidColorBrush(Colors.Black); } ((e.ClickedItem as StackPanel).Children[1] as Border).Background = new SolidColorBrush(Colors.Pink); (((e.ClickedItem as StackPanel).Children[1] as Border).Child as TextBlock).Foreground = new SolidColorBrush(Colors.DeepPink); _filter_index = int.Parse((e.ClickedItem as StackPanel).Tag.ToString()); MyCanvas.Invalidate(); }
public async void Show(StorageFile image) { try { Show(); WaitLoading.IsActive = true; CanvasDevice cd = CanvasDevice.GetSharedDevice(); var stream = await image.OpenAsync(FileAccessMode.Read); _image = await CanvasBitmap.LoadAsync(cd, stream); WaitLoading.IsActive = false; MyCanvas.Invalidate(); } catch { } }
private async Task LoadVirtualBitmap() { try { ShowBusyIndicator("loading image..."); if (virtualBitmap != null) { virtualBitmap.Dispose(); virtualBitmap = null; } if (!string.IsNullOrEmpty(imageFilePath)) { var storageFile = await StorageFile.GetFileFromPathAsync(imageFilePath); using (var stream = await storageFile.OpenReadAsync()) { virtualBitmap = await CanvasVirtualBitmap.LoadAsync(MyCanvas.Device, stream); } } // This can happen if the page is unloaded while this method is running if (MyCanvas == null || virtualBitmap == null) { return; } MyCanvas.Width = virtualBitmap.Size.Width; MyCanvas.Height = virtualBitmap.Size.Height; MyCanvas.Invalidate(); } catch (Exception ex) { await new MessageDialog($"Something went wrong loading the image: {ex}", "Exception").ShowAsync(); } finally { HideBusyIndicator(); } }
private void Slider_ValueChanged(object sender, RangeBaseValueChangedEventArgs e) { MyCanvas.Invalidate(); }