コード例 #1
0
        public LoadDocumentCommand(MainWindowViewModel mainWindow)
        {
            Safeguard.EnsureNotNull("mainWindow", mainWindow);

            this.mainWindow = mainWindow;
            this.CanExecuteChanged?.Invoke(this, new EventArgs());
        }
コード例 #2
0
        public WindowCloseCommand(Window window)
        {
            Safeguard.EnsureNotNull("selectColorView", window);

            this.window = window;
            this.CanExecuteChanged?.Invoke(this, new EventArgs());
        }
コード例 #3
0
        public CopyToClipboardCommand(Func <BitmapSource> functionToRetrieveImage)
        {
            Safeguard.EnsureNotNull("functionToRetrieveText", functionToRetrieveImage);

            this.functionToRetrieveImage = functionToRetrieveImage;
            this.CanExecuteChanged?.Invoke(this, new EventArgs());
        }
コード例 #4
0
        public LoadImageCommand(CapturePictureViewModel viewModel)
        {
            Safeguard.EnsureNotNull("viewModel", viewModel);

            this.viewModel = viewModel;
            this.viewModel.PropertyChanged += OnViewModelPropertyChanged;
        }
コード例 #5
0
        public MinimizeWindowCommand(Window window)
        {
            Safeguard.EnsureNotNull("window", window);

            this.window = window;
            this.CanExecuteChanged?.Invoke(this, new EventArgs());
        }
コード例 #6
0
        public ButtonPopupCommand(MainWindowViewModel mainWindowViewModel)
        {
            Safeguard.EnsureNotNull("mainWindowViewModel", mainWindowViewModel);

            this.mainWindowViewModel = mainWindowViewModel;
            this.CanExecuteChanged?.Invoke(this, new EventArgs());
        }
コード例 #7
0
        public static void Fade(this FrameworkElement element, double startOpacity, double toOpacity, TimeSpan timeSpan, EventHandler completedEvent)
        {
            Safeguard.EnsureNotNull("element", element);

            DoubleAnimation fadeAnimation = new DoubleAnimation()
            {
                From     = startOpacity,
                To       = toOpacity,
                Duration = timeSpan
            };

            Storyboard.SetTarget(fadeAnimation, element);
            Storyboard.SetTargetProperty(fadeAnimation, new PropertyPath(UIElement.OpacityProperty));

            Storyboard storyboard = new Storyboard();

            storyboard.Children.Add(fadeAnimation);

            if (completedEvent != null)
            {
                storyboard.Completed += completedEvent;
            }

            storyboard.Begin();
        }
コード例 #8
0
        public SaveDocumentCommand(InkWriterDocument document)
        {
            Safeguard.EnsureNotNull("document", document);

            this.document = document;
            this.CanExecuteChanged?.Invoke(this, new EventArgs());
        }
コード例 #9
0
        public void ResetDocument(InkWriterDocument newDocument)
        {
            Safeguard.EnsureNotNull("newDocument", newDocument);

            this.document.PageChanged -= this.OnDocumentPageChanged;
            this.document              = newDocument;
            this.document.PageChanged += this.OnDocumentPageChanged;
        }
コード例 #10
0
        public ToggleCaptureCommand(CapturePictureViewModel viewModel)
        {
            Safeguard.EnsureNotNull("viewModel", viewModel);

            this.viewModel = viewModel;
            /// TODO: Must get IDisopsable.
            this.viewModel.PropertyChanged += OnViewModelPropertyChanged;
        }
コード例 #11
0
        public NewPageCommand(MainWindowViewModel mainWindow, InkWriterDocument document)
        {
            Safeguard.EnsureNotNull("mainWindow", mainWindow);
            Safeguard.EnsureNotNull("document", document);

            this.mainWindow = mainWindow;
            this.document   = document;
            this.CanExecuteChanged?.Invoke(this, new EventArgs());
        }
コード例 #12
0
        public DeletePageCommand(MainWindowViewModel mainWindow, InkWriterDocument document)
        {
            Safeguard.EnsureNotNull("mainWindow", mainWindow);
            Safeguard.EnsureNotNull("document", document);

            this.mainWindow            = mainWindow;
            this.document              = document;
            this.document.PageChanged += this.OnDocumentPageChanged;
        }
コード例 #13
0
        public EmbeddPictureCommand(CapturePictureViewModel capturePictureView, MainWindowViewModel mainWindow)
        {
            Safeguard.EnsureNotNull("capturePictureView", capturePictureView);
            Safeguard.EnsureNotNull("mainWindow", mainWindow);

            this.capturePictureView  = capturePictureView;
            this.mainWindowViewModel = mainWindow;

            this.capturePictureView.PropertyChanged += this.OnViewModelPropertyChanged;
        }
コード例 #14
0
        public PageNavigationCommand(MainWindowViewModel mainWindow, InkWriterDocument document, NavigationRequestType navigationRequestType)
        {
            Safeguard.EnsureNotNull("mainWindow", mainWindow);
            Safeguard.EnsureNotNull("document", document);

            this.document              = document;
            this.mainWindow            = mainWindow;
            this.document.PageChanged += this.OnDocumentPageChanged;
            this.navigationRequestType = navigationRequestType;
        }
コード例 #15
0
        public SelectColorViewModel(InkCanvas inkCanvas, List <Color> selectableColors, Window window)
        {
            Safeguard.EnsureNotNull("window", window);
            Safeguard.EnsureNotNull("inkCanvas", inkCanvas);
            Safeguard.EnsureNotNull("selectableColors", selectableColors);

            this.window           = window;
            this.inkCanvas        = inkCanvas;
            this.SelectableColors = selectableColors;

            this.CloseCommand = new CommonCommands.WindowCloseCommand(window);
        }
コード例 #16
0
        public CloseApplicationCommand(MainWindowViewModel mainWindow, InkWriterDocument document, InkWriterSettings settings)
        {
            Safeguard.EnsureNotNull("mainWindow", mainWindow);
            Safeguard.EnsureNotNull("document", document);
            Safeguard.EnsureNotNull("settings", settings);

            this.document   = document;
            this.settings   = settings;
            this.mainWindow = mainWindow;

            this.CanExecuteChanged?.Invoke(this, new EventArgs());
        }
コード例 #17
0
        public SelectWidthViewModel(InkCanvas inkCanvas, List <double> selectableWidths, Window window)
        {
            Safeguard.EnsureNotNull("window", window);
            Safeguard.EnsureNotNull("inkCanvas", inkCanvas);
            Safeguard.EnsureNotNull("selectableWidths", selectableWidths);

            this.window           = window;
            this.inkCanvas        = inkCanvas;
            this.SelectableWidths = selectableWidths;

            this.CloseCommand = new CommonCommands.WindowCloseCommand(window);
        }
コード例 #18
0
        public ZoomImageCommand(ZoomType zoomType, VideoCaptureDevice videoCaptureDevice)
        {
            Safeguard.EnsureNotNull("videoCaptureDevice", videoCaptureDevice);

            this.zoomType           = zoomType;
            this.videoCaptureDevice = videoCaptureDevice;

            if (!Initialized)
            {
                this.videoCaptureDevice.GetCameraPropertyRange(CameraControlProperty.Zoom, out MinZoom, out MaxZoom, out StepSize, out DefaultValue, out ControlFlags);
                Initialized = true;
            }
        }
コード例 #19
0
        public static void InvokeOnGui(this DispatcherObject application, DispatcherPriority priority, Action action)
        {
            Safeguard.EnsureNotNull("application", application);
            Safeguard.EnsureNotNull("action", action);

            Dispatcher dispatcher = application.Dispatcher;

            if (dispatcher == null || dispatcher.CheckAccess())
            {
                action();
            }
            else
            {
                dispatcher.Invoke(priority, action);
            }
        }
コード例 #20
0
        public void Execute(object parameter)
        {
            Safeguard.EnsureNotNull("mainWindowViewModel.InkCanvas", mainWindowViewModel.InkCanvas);

            Bitmap      bitmap      = (Bitmap)BitmapToBitmapSourceConverter.ConvertBack(this.capturePictureView.Image, typeof(Bitmap), null, CultureInfo.CurrentUICulture);
            Bitmap      copy        = ImageManipulation.Copy(bitmap);
            ImageSource imageSource = (ImageSource)BitmapToBitmapSourceConverter.Convert(copy, typeof(ImageSource), null, CultureInfo.CurrentUICulture);

            this.mainWindowViewModel.InkCanvas.Children.Add(new System.Windows.Controls.Image
            {
                Source = imageSource
            });

            this.capturePictureView.PropertyChanged -= this.OnViewModelPropertyChanged;
            this.capturePictureView.CloseCommand.Execute(null);

            this.mainWindowViewModel.UpdatePage();
        }
コード例 #21
0
ファイル: Child.cs プロジェクト: MemoryException/InkWriter
        public Child(UIElement uiElement)
        {
            Safeguard.EnsureNotNull("uiElement", uiElement);

            if (uiElement is Image)
            {
                this.ChildType = ChildType.Image;

                Image image = uiElement as Image;
                this.Width  = image.RenderSize.Width;
                this.Height = image.RenderSize.Height;

                UIElement container        = VisualTreeHelper.GetParent(uiElement) as UIElement;
                Point     relativeLocation = uiElement.TranslatePoint(new Point(0, 0), container);
                this.Left = relativeLocation.X;
                this.Top  = relativeLocation.Y;

                this.Data = ByteImageConverter.ConvertBitmapSourceToByteArray(image.Source);
                return;
            }

            throw new NotSupportedException("Type " + uiElement.GetType() + " not supported.");
        }
コード例 #22
0
        protected static string GetPropertyName <T>(Expression <Func <T> > propertyExpression)
        {
            Safeguard.EnsureNotNull("propertyExpression", propertyExpression);

            MemberExpression memberExpression = null;

            if (propertyExpression.Body is UnaryExpression unary)
            {
                memberExpression = (MemberExpression)unary.Operand;
            }
            else
            {
                memberExpression = (MemberExpression)propertyExpression.Body;
            }

            string propertyName = memberExpression.Member.Name;

            if (string.IsNullOrEmpty(propertyName))
            {
                throw new InvalidOperationException("Failed to get property name.");
            }

            return(propertyName);
        }
コード例 #23
0
        public CapturePictureViewModel(Window window, MainWindowViewModel mainWindow)
        {
            Safeguard.EnsureNotNull("window", window);
            Safeguard.EnsureNotNull("mainWindow", mainWindow);

            this.CloseCommand       = new CommonCommands.WindowCloseCommand(window, () => { this.StopLiveVideo(); });
            this.ToggleVideoCommand = new ToggleCaptureCommand(this);
            this.CutImageCommand    = new CutImageCommand(this);
            this.SaveImageCommand   = new SaveImageCommand(this);
            this.LoadImageCommand   = new LoadImageCommand(this);

            this.State = CapturePictureViewState.StoppedCapture;

            this.StartLiveVideo();

            /// TODO: Release on dispose, CapturePictureView must get disposable
            this.DecreaseZoomCommand              = new ZoomImageCommand(ZoomType.DecreaseZoom, this.videoSource);
            this.DecreaseZoomCommand.ZoomChanged += ZoomChanged;
            this.IncreaseZoomCommand              = new ZoomImageCommand(ZoomType.IncreaseZoom, this.videoSource);
            this.IncreaseZoomCommand.ZoomChanged += ZoomChanged;
            this.ResetZoomCommand              = new ZoomImageCommand(ZoomType.ResetZoom, this.videoSource);
            this.ResetZoomCommand.ZoomChanged += ZoomChanged;
            this.EmbeddPictureCommand          = new EmbeddPictureCommand(this, mainWindow);
        }
コード例 #24
0
        private PageContent GetPageContent(PrintDialog printDialog, BitmapSource bitmapSource)
        {
            Safeguard.EnsureNotNull("printDialog", printDialog);

            PageContent pageContent = new PageContent
            {
                Width  = printDialog.PrintableAreaWidth,
                Height = printDialog.PrintableAreaHeight,

                Child = new FixedPage()
                {
                    Width  = printDialog.PrintableAreaWidth,
                    Height = printDialog.PrintableAreaHeight,
                }
            };

            Image pageImage = new Image();

            pageImage.BeginInit();
            FixedPage.SetLeft(pageImage, pageContent.Width * 0.05);
            FixedPage.SetTop(pageImage, pageContent.Height * 0.05);
            pageImage.Stretch             = System.Windows.Media.Stretch.Uniform;
            pageImage.Width               = pageContent.Width * 0.9;
            pageImage.Height              = pageContent.Height * 0.9;
            pageImage.HorizontalAlignment = HorizontalAlignment.Center;
            pageImage.VerticalAlignment   = VerticalAlignment.Center;
            pageImage.Source              = bitmapSource;
            pageImage.EndInit();

            pageImage.Measure(pageContent.RenderSize);
            pageImage.UpdateLayout();

            pageContent.Child.Children.Add(pageImage);

            return(pageContent);
        }
コード例 #25
0
        public SettingsViewModel(Window window)
        {
            Safeguard.EnsureNotNull("window", window);

            this.CloseCommand = new CommonCommands.WindowCloseCommand(window);
        }
コード例 #26
0
        public void ResetDocument(InkWriterDocument documentToSet)
        {
            Safeguard.EnsureNotNull("document", documentToSet);

            this.document = documentToSet;
        }
コード例 #27
0
 public WindowCloseCommand(Window window, Action closeAction)
     : this(window)
 {
     Safeguard.EnsureNotNull("closeAction", closeAction);
     this.closeAction = closeAction;
 }
コード例 #28
0
        public void ResetDocument(InkWriterDocument newDocument)
        {
            Safeguard.EnsureNotNull("newDocument", newDocument);

            this.document = newDocument;
        }
コード例 #29
0
 public OkCommand(FileDialogViewModel viewModel)
 {
     Safeguard.EnsureNotNull("viewModel", viewModel);
     this.viewModel = viewModel;
 }
コード例 #30
0
 public CancelCommand(FileDialogViewModel viewModel)
 {
     Safeguard.EnsureNotNull("viewModel", viewModel);
     this.viewModel = viewModel;
     this.CanExecuteChanged?.Invoke(this, new EventArgs());
 }