public LoadDocumentCommand(MainWindowViewModel mainWindow) { Safeguard.EnsureNotNull("mainWindow", mainWindow); this.mainWindow = mainWindow; this.CanExecuteChanged?.Invoke(this, new EventArgs()); }
public WindowCloseCommand(Window window) { Safeguard.EnsureNotNull("selectColorView", window); this.window = window; this.CanExecuteChanged?.Invoke(this, new EventArgs()); }
public CopyToClipboardCommand(Func <BitmapSource> functionToRetrieveImage) { Safeguard.EnsureNotNull("functionToRetrieveText", functionToRetrieveImage); this.functionToRetrieveImage = functionToRetrieveImage; this.CanExecuteChanged?.Invoke(this, new EventArgs()); }
public LoadImageCommand(CapturePictureViewModel viewModel) { Safeguard.EnsureNotNull("viewModel", viewModel); this.viewModel = viewModel; this.viewModel.PropertyChanged += OnViewModelPropertyChanged; }
public MinimizeWindowCommand(Window window) { Safeguard.EnsureNotNull("window", window); this.window = window; this.CanExecuteChanged?.Invoke(this, new EventArgs()); }
public ButtonPopupCommand(MainWindowViewModel mainWindowViewModel) { Safeguard.EnsureNotNull("mainWindowViewModel", mainWindowViewModel); this.mainWindowViewModel = mainWindowViewModel; this.CanExecuteChanged?.Invoke(this, new EventArgs()); }
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(); }
public SaveDocumentCommand(InkWriterDocument document) { Safeguard.EnsureNotNull("document", document); this.document = document; this.CanExecuteChanged?.Invoke(this, new EventArgs()); }
public void ResetDocument(InkWriterDocument newDocument) { Safeguard.EnsureNotNull("newDocument", newDocument); this.document.PageChanged -= this.OnDocumentPageChanged; this.document = newDocument; this.document.PageChanged += this.OnDocumentPageChanged; }
public ToggleCaptureCommand(CapturePictureViewModel viewModel) { Safeguard.EnsureNotNull("viewModel", viewModel); this.viewModel = viewModel; /// TODO: Must get IDisopsable. this.viewModel.PropertyChanged += OnViewModelPropertyChanged; }
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()); }
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; }
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; }
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; }
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); }
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()); }
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); }
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; } }
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); } }
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(); }
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."); }
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); }
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); }
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); }
public SettingsViewModel(Window window) { Safeguard.EnsureNotNull("window", window); this.CloseCommand = new CommonCommands.WindowCloseCommand(window); }
public void ResetDocument(InkWriterDocument documentToSet) { Safeguard.EnsureNotNull("document", documentToSet); this.document = documentToSet; }
public WindowCloseCommand(Window window, Action closeAction) : this(window) { Safeguard.EnsureNotNull("closeAction", closeAction); this.closeAction = closeAction; }
public void ResetDocument(InkWriterDocument newDocument) { Safeguard.EnsureNotNull("newDocument", newDocument); this.document = newDocument; }
public OkCommand(FileDialogViewModel viewModel) { Safeguard.EnsureNotNull("viewModel", viewModel); this.viewModel = viewModel; }
public CancelCommand(FileDialogViewModel viewModel) { Safeguard.EnsureNotNull("viewModel", viewModel); this.viewModel = viewModel; this.CanExecuteChanged?.Invoke(this, new EventArgs()); }