private async void ProjectNew_ExecuteRequested(XamlUICommand sender, ExecuteRequestedEventArgs args) { // Prompt user to save unsaved changes (if applicable) if (await ProceedAfterPromptToSaveChanges() == false) { return; } var dlg = new TextPromptDialog { Title = "New Project", PromptText = "Enter a name for the new project", PrimaryButtonText = "OK", CloseButtonText = "Cancel" }; var dlgResult = await dlg.ShowAsync(); if (dlgResult == ContentDialogResult.Primary) { ActiveProject = new Project { Name = dlg.Text } } ; }
private async void ProjectSaveAs_ExecuteRequested(XamlUICommand sender, ExecuteRequestedEventArgs args) { ActiveProject.StorageFile = await PromptSaveLocation(); ActiveProject.Save(); }
public ImageResultHolder(ImageRequest request, ImageCacheService service, XamlUICommand uiCommand) { _request = request; _service = service; _copyCommand = uiCommand; LoadAsync(false); }
private void EditRedoCommand_ExecuteRequested(XamlUICommand sender, ExecuteRequestedEventArgs args) { byte[] b = History.Redo().bmp; SelectionTool.RedoSelection(); DrawArea.ImageDataLayer.BitmapDrawingData.PixelBuffer.AsStream().Write(b, 0, b.Length); DrawArea.ImageDataLayer.BitmapDrawingData.Invalidate(); }
private void MediaLibraryRemoveMarker_ExecuteRequested(XamlUICommand sender, ExecuteRequestedEventArgs args) { if (ActiveDescriptor is IMarkable markable && _descriptorContext is Marker marker) { markable.Markers.Remove(marker); } }
/// <summary> /// Gets the file location to save the Bitmap /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// <summary> /// Closes the Program /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private async void saveBtn_Command(XamlUICommand sender, ExecuteRequestedEventArgs args) { FileSavePicker fileSavePicker = new FileSavePicker(); fileSavePicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary; fileSavePicker.FileTypeChoices.Add("JPEG files", new List <string>() { ".jpg", ".jpeg" }); fileSavePicker.FileTypeChoices.Add("PNG files", new List <string>() { ".png" }); fileSavePicker.SuggestedFileName = "image"; var outputFile = await fileSavePicker.PickSaveFileAsync(); if (outputFile != null) { SoftwareBitmap outputBitmap = SoftwareBitmap.CreateCopyFromBuffer( mainCanvas.Bitmap.PixelBuffer, BitmapPixelFormat.Bgra8, mainCanvas.Bitmap.PixelWidth, mainCanvas.Bitmap.PixelHeight); SaveSoftwareBitmapToFile(outputBitmap, outputFile); } }
private void PlayerRateDecrease_ExecuteRequested(XamlUICommand sender, ExecuteRequestedEventArgs args) { if (_player.PlaybackSession.PlaybackRate > 0.5) { _player.PlaybackSession.PlaybackRate -= 0.5; } }
private void IncreaseBrushSize_ExecuteRequested(XamlUICommand sender, ExecuteRequestedEventArgs args) { if (brushSizeSlider.Maximum != brushSizeSlider.Value) { brushSizeSlider.Value++; } }
internal static void BindToDescriptionPropertiesIfUnset( XamlUICommand uiCommand, FrameworkElement target) { string localHelpText = AutomationProperties.GetHelpText(target); if (localHelpText == null || string.IsNullOrEmpty(localHelpText)) { target.SetBinding(AutomationProperties.HelpTextProperty, new Binding { Path = "Description", Source = uiCommand }); } object localToolTipAsI; localToolTipAsI = ToolTipService.GetToolTip(target); string localToolTipAsString = null; ToolTip localToolTip = null; if (localToolTipAsI != null) { localToolTipAsString = localToolTipAsI.ToString(); localToolTip = localToolTipAsI as ToolTip; } if ((localToolTipAsString == null || string.IsNullOrEmpty(localToolTipAsString)) && localToolTip == null) { target.SetBinding(ToolTipService.ToolTipProperty, new Binding { Path = "Description", Source = uiCommand }); } }
private void FileSaveCommand_ExecuteRequested(XamlUICommand sender, ExecuteRequestedEventArgs args) { if (outputFile != null) { isNewFile = Exists(); } Save(); }
private void MediaLibraryRemoveItem_ExecuteRequested(XamlUICommand sender, ExecuteRequestedEventArgs args) { if (ActiveNode.Parent.Children.Remove(ActiveNode)) { ActiveProject.HasUnsavedChanges = true; } }
private void PlayerNextFrame_ExecuteRequested(XamlUICommand sender, ExecuteRequestedEventArgs args) { var rate = _player.PlaybackSession.PlaybackRate; _player.PlaybackSession.PlaybackRate = 0; _player.PlaybackSession.Position += Slider.FrameDuration; _player.PlaybackSession.PlaybackRate = rate; }
private void UndoCommand_OnExecuteRequested(XamlUICommand sender, ExecuteRequestedEventArgs args) { if (!Editor.IsIdle()) { Editor.WaitForIdle(); } Editor.Undo(); }
private async void EditTodoBtn_Click(XamlUICommand sender, ExecuteRequestedEventArgs args) { string id = args.Parameter as string; EditDialog.Tag = id; TxbEditTitle.Text = TodoList.GetTodo(id).Title; TxbEditDescription.Text = TodoList.GetTodo(id).Description; await EditDialog.ShowAsync(); }
private void ColorSwap_ExecuteRequested(XamlUICommand sender, ExecuteRequestedEventArgs args) { Color temp = secondary; secondary = colorPicker.Color; colorPicker.Color = temp; RColor.Fill = new SolidColorBrush(secondary); LColor.Fill = new SolidColorBrush(colorPicker.Color); }
private void PlayerZoomOutTimelime_CanExecuteRequested(XamlUICommand sender, CanExecuteRequestedEventArgs args) { args.CanExecute = IsLoaded && _player.Source != null && _player.Source is MediaSource source && source.IsOpen && source.State == MediaSourceState.Opened; }
private void PlayerRateNormal_CanExecuteRequested(XamlUICommand sender, CanExecuteRequestedEventArgs args) { args.CanExecute = IsLoaded && _player.Source != null && _player.Source is MediaSource source && source.IsOpen && source.State == MediaSourceState.Opened && _player.PlaybackSession.PlaybackState == MediaPlaybackState.Playing; }
private async void FileLoadCommand_ExecuteRequested(XamlUICommand sender, ExecuteRequestedEventArgs args) { fileOpenPicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary; fileOpenPicker.FileTypeFilter.Add(".jpg"); fileOpenPicker.FileTypeFilter.Add(".png"); fileOpenPicker.FileTypeFilter.Add(customFileExtension); StorageFile inputFile = await fileOpenPicker.PickSingleFileAsync(); //User cancelled load if (inputFile == null) { return; } ImageProperties imageProperties = await inputFile.Properties.GetImagePropertiesAsync(); if (inputFile.FileType == customFileExtension) { using (Stream stream = await inputFile.OpenStreamForReadAsync()) { DataContractSerializer ser = new DataContractSerializer(typeof(Exportable)); object obj = ser.ReadObject(stream); Exportable exp = (Exportable)obj; SetDrawingArea((int)exp.width, (int)exp.height); DrawArea.ImageDataLayer.BitmapDrawingData.PixelBuffer.AsStream().Write(exp.bytes, 0, exp.bytes.Length); DrawArea.ImageDataLayer.BitmapDrawingData.Invalidate(); History.StartHistory(exp.bytes); DrawingCanvas.canvas.ImageDataLayer.DrawBrush(new Stroke(), new DrawPoint(new Point(0, 0), new Point(0, 0))); History.Undo(); } return; } using (IRandomAccessStream fileStream = await inputFile.OpenAsync(Windows.Storage.FileAccessMode.Read)) { /* BitmapDecoder decoder = await BitmapDecoder.CreateAsync(BitmapDecoder.JpegDecoderId, fileStream); * //if (inputFile.FileType == ".png") decoder = await BitmapDecoder.CreateAsync(BitmapEncoder.PngEncoderId, fileStream); * //if (inputFile.FileType == ".jpg") decoder = await BitmapDecoder.CreateAsync(BitmapEncoder.JpegEncoderId, fileStream); * SoftwareBitmap bitmap = await decoder.GetSoftwareBitmapAsync(); * byte[] pixels = bitmap.BitmapPixelFormat * drawArea.ImageDataLayer.BitmapDrawingData.SetPixel*/ newHeight = (int)imageProperties.Height; newWidth = (int)imageProperties.Width; SetDrawingArea(newWidth, newHeight); //WriteableBitmap bi = new WriteableBitmap(newWidth, newHeight); //await bi.SetSourceAsync(fileStream); //byte[] pixels = bi.ToByteArray(); //DrawArea.ImageDataLayer.BitmapDrawingData.FromByteArray(pixels); //^V does the same await drawArea.ImageDataLayer.BitmapDrawingData.SetSourceAsync(fileStream); //Look at this updateLoad(); } }
static MediaLibraryImportFolderCommand() { MediaLibraryImportFolder = new XamlUICommand { Label = "Folder...", Description = "Browse for media folder to import", IconSource = new SymbolIconSource { Symbol = Symbol.ImportAll } }; }
private void PlayerPreviousFrame_CanExecuteRequested(XamlUICommand sender, CanExecuteRequestedEventArgs args) { args.CanExecute = IsLoaded && _player.Source != null && _player.Source is MediaSource source && source.IsOpen && source.State == MediaSourceState.Opened && _player.PlaybackSession.PlaybackState == MediaPlaybackState.Paused && _player.PlaybackSession.Position >= Slider.FrameDuration; }
private async void ChangeFirstNameCommand_ExecuteRequested(XamlUICommand sender, ExecuteRequestedEventArgs args) { ListView lv = (ListView)args.Parameter; if (lv.SelectedIndex != -1) { await SpeakAsync($"Changing First name, from {_employeesOC[lv.SelectedIndex].FirstName}, to, {txtFirstName.Text}"); _employeesOC[lv.SelectedIndex].FirstName = txtFirstName.Text; } }
static MediaLibraryNewFolderCommand() { MediaLibraryNewFolder = new XamlUICommand { Label = "New Folder...", Description = "Create new folder", IconSource = new SymbolIconSource { Symbol = Symbol.NewFolder } }; }
static MediaLibraryRemoveMarkerCommand() { MediaLibraryRemoveMarker = new XamlUICommand { Label = "Remove", Description = "Remove marker", IconSource = new SymbolIconSource { Symbol = Symbol.Remove } }; }
static MediaLibraryRenameItemCommand() { MediaLibraryRenameItem = new XamlUICommand { Label = "Rename...", Description = "Rename item", IconSource = new SymbolIconSource { Symbol = Symbol.Rename } }; }
static MediaLibraryRemoveItemCommand() { MediaLibraryRemoveItem = new XamlUICommand { Label = "Item", Description = "Remove item", IconSource = new SymbolIconSource { Symbol = Symbol.TouchPointer } }; }
static MediaLibraryImportFilesCommand() { MediaLibraryImportFiles = new XamlUICommand { Label = "Files...", Description = "Browse for media files to import", IconSource = new SymbolIconSource { Symbol = Symbol.Import } }; }
public HelpViewModel() { BackCommand = new XamlUICommand(); ((XamlUICommand)BackCommand).ExecuteRequested += (s, e) => { GoBack(); }; SeeAlsoCommand = new XamlUICommand(); ((XamlUICommand)SeeAlsoCommand).ExecuteRequested += (s, e) => { OnSeeAlso((RelatedTopicViewModel)e.Parameter); }; }
private async void MediaLibraryImportFolder_ExecuteRequested(XamlUICommand sender, ExecuteRequestedEventArgs args) { var picker = new FolderPicker { ViewMode = PickerViewMode.Thumbnail, SuggestedStartLocation = PickerLocationId.Desktop, CommitButtonText = "Import" }; picker.FileTypeFilter.Add(".jpg"); picker.FileTypeFilter.Add(".jpeg"); picker.FileTypeFilter.Add(".png"); picker.FileTypeFilter.Add(".bmp"); picker.FileTypeFilter.Add(".avi"); picker.FileTypeFilter.Add(".mov"); picker.FileTypeFilter.Add(".wmv"); picker.FileTypeFilter.Add(".mp4"); picker.FileTypeFilter.Add(".mkv"); var folder = await picker.PickSingleFolderAsync(); if (folder == null) { return; } var files = await folder.GetFilesAsync(); if (files.Count == 0) { return; } var mediaFolder = new MediaTreeFolder { Name = folder.DisplayName }; foreach (var file in files) { if (file.ContentType.Contains("image")) { mediaFolder.Children.Add(new ImageFile(file)); } else if (file.ContentType.Contains("video")) { mediaFolder.Children.Add(new VideoFile(file)); } } ActiveNode.Children.Add(mediaFolder); ActiveProject.HasUnsavedChanges = true; }
private void PlayerNextMarker_CanExecuteRequested(XamlUICommand sender, CanExecuteRequestedEventArgs args) { args.CanExecute = IsLoaded && _player.Source != null && _player.Source is MediaSource source && source.IsOpen && source.State == MediaSourceState.Opened && (_player.PlaybackSession.PlaybackState == MediaPlaybackState.Playing || _player.PlaybackSession.PlaybackState == MediaPlaybackState.Paused) && NextMarkerFromCurrentPosition() != null; }
public SettingsViewModel() { BackCommand = new XamlUICommand(); ((XamlUICommand)BackCommand).ExecuteRequested += (s, e) => { GoBack(); }; GetHelpCommand = new XamlUICommand(); ((XamlUICommand)GetHelpCommand).ExecuteRequested += (s, e) => { OnGetHelp(); }; }