private void TextBox_TextChanged(object sender, TextChangedEventArgs e)
        {
            Vm.DisplayPreview();
            WideCanvasControl.Invalidate();

            Vm.DisplaySquarePreview();
            SquareCanvasControl.Invalidate();
        }
        private void TextBox_LostFocus(object sender, RoutedEventArgs e)
        {
            Vm.DisplayPreview();
            WideCanvasControl.Invalidate();

            Vm.DisplaySquarePreview();
            SquareCanvasControl.Invalidate();
        }
        /// <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();
        }
        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();
            }
        }
 public void InvalidateCanvasControl()
 {
     WideCanvasControl.Invalidate();
     SquareCanvasControl.Invalidate();
 }