コード例 #1
0
        private void TextBox_TextChanged(object sender, TextChangedEventArgs e)
        {
            Vm.DisplayPreview();
            WideCanvasControl.Invalidate();

            Vm.DisplaySquarePreview();
            SquareCanvasControl.Invalidate();
        }
コード例 #2
0
        private void TextBox_LostFocus(object sender, RoutedEventArgs e)
        {
            Vm.DisplayPreview();
            WideCanvasControl.Invalidate();

            Vm.DisplaySquarePreview();
            SquareCanvasControl.Invalidate();
        }
コード例 #3
0
        /// <summary>
        /// Open Image and load to ViewModel
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public async void OpenImage_Tapped(object sender, TappedRoutedEventArgs e)
        {
            FileOpenPicker openPicker = new FileOpenPicker
            {
                ViewMode = PickerViewMode.Thumbnail,
                SuggestedStartLocation = PickerLocationId.PicturesLibrary
            };

            openPicker.FileTypeFilter.Add(".jpg");
            openPicker.FileTypeFilter.Add(".jpeg");
            openPicker.FileTypeFilter.Add(".png");
            openPicker.FileTypeFilter.Add(".bmp");

            Vm.File = await openPicker.PickSingleFileAsync();

            if (Vm.File == null)
            {
                return;
            }

            using (IRandomAccessStream fileStream = await Vm.File.OpenAsync(FileAccessMode.Read))
            {
                // Set the image source to the selected bitmap
                BitmapImage bm = new BitmapImage();
                await bm.SetSourceAsync(fileStream);

                Vm.MaxWidth  = bm.PixelWidth;
                Vm.MaxHeight = bm.PixelHeight;

                XPos.Maximum = Vm.MaxWidth;
                YPos.Maximum = Vm.MaxHeight;

                XPos.Minimum = Vm.MaxWidth * (-1);
                YPos.Minimum = Vm.MaxHeight * (-1);

                //Square
                Vm.SMaxWidth  = bm.PixelWidth;
                Vm.SMaxHeight = bm.PixelHeight;

                SqXPos.Maximum = Vm.SMaxWidth;
                SqYPos.Maximum = Vm.SMaxHeight;

                SqXPos.Minimum = Vm.SMaxWidth * (-1);
                SqYPos.Minimum = Vm.SMaxHeight * (-1);
            }

            await Vm.LoadBitmap();

            Vm.IsCaculation  = true;
            Vm.SIsCaculation = true;
            Vm.DisplayPreview();
            Vm.DisplaySquarePreview();
            WideCanvasControl.Invalidate();
            SquareCanvasControl.Invalidate();
        }
コード例 #4
0
        private void DrawButton_OnClick(object sender, RoutedEventArgs e)
        {
            Vm.IsCaculation = true;
            Vm.DisplayPreview();
            WideCanvasControl.Invalidate();

            if (!Vm.IsManualAdjustSquareImage)
            {
                Vm.SIsCaculation = true;
                Vm.DisplaySquarePreview();
                SquareCanvasControl.Invalidate();
            }
        }
コード例 #5
0
 public void InvalidateCanvasControl()
 {
     WideCanvasControl.Invalidate();
     SquareCanvasControl.Invalidate();
 }