private async void MenuItemCopySelectedCsv_Click(object sender, RoutedEventArgs e) { string text = DataGrid.SelectedToCsv(); if (text != null) { await ClipBoardUtils.SetTextAsync(text); } }
private async void MenuItemCopyDataGrid_Click(object sender, RoutedEventArgs e) { string text = DataGrid.ToStringTable(); if (text != null) { await ClipBoardUtils.SetTextAsync(text); } }
private async void MenuItemCopyRow_Click(object sender, RoutedEventArgs e) { string text = DataGrid.RowToString(Cell.DataContext); if (text != null) { await ClipBoardUtils.SetTextAsync(text); } }
private async void MenuItemCopyColumn_Click(object sender, RoutedEventArgs e) { if (Column is DataGridPropertyTextColumn column) { string text = DataGrid.ColumnToStringTable(column); if (text != null) { await ClipBoardUtils.SetTextAsync(text); } } }
// Adds a context menu to the text block /*private void AddHeaderContextMenu() * { * ContextMenu contextMenu = new(); * * var keymap = AvaloniaLocator.Current.GetService<PlatformHotkeyConfiguration>(); * * var list = new AvaloniaList<object>(); * * MenuItem menuItemCopy = new MenuItem() { Header = "_Copy - Column" }; * menuItemCopy.Click += delegate * { * ClipBoardUtils.SetTextAsync(ColumnText); * }; * list.Add(menuItemCopy); * * //list.Add(new Separator()); * * contextMenu.Items = list; * * //this.ContextMenu = contextMenu; * }*/ // Adds a context menu to the text block private void AddTextBlockContextMenu(TextBlock textBlock) { var contextMenu = new ContextMenu(); var keymap = AvaloniaLocator.Current.GetService <PlatformHotkeyConfiguration>(); var list = new AvaloniaList <object>(); var menuItemCopy = new TabMenuItem("_Copy - Cell Contents"); menuItemCopy.Click += delegate { ClipBoardUtils.SetText(textBlock.Text); }; list.Add(menuItemCopy); list.Add(new Separator()); var menuItemCopyDataGrid = new TabMenuItem("Copy - _DataGrid"); menuItemCopyDataGrid.Click += delegate { string text = DataGrid.ToStringTable(); if (text != null) { ClipBoardUtils.SetText(text); } }; list.Add(menuItemCopyDataGrid); var menuItemCopyDataGridCsv = new TabMenuItem("Copy - DataGrid - C_SV"); menuItemCopyDataGridCsv.Click += delegate { string text = DataGrid.ToCsv(); if (text != null) { ClipBoardUtils.SetText(text); } }; list.Add(menuItemCopyDataGridCsv); //list.Add(new Separator()); contextMenu.Items = list; textBlock.ContextMenu = contextMenu; }
private async Task LinkAsync(Call call) { Bookmark bookmark = TabView.Instance.CreateBookmark(); TabBookmark leafNode = bookmark.TabBookmark.GetLeaf(); // Get the shallowest root node if (leafNode != bookmark.TabBookmark) { bookmark.Name = leafNode.Tab?.ToString(); bookmark.TabBookmark = leafNode; bookmark.BookmarkType = BookmarkType.Leaf; } else { bookmark.BookmarkType = BookmarkType.Full; } string uri = Project.Linker.GetLinkUri(call, bookmark); await ClipBoardUtils.SetTextAsync(uri); }
private async void MenuItemCopyCellContents_Click(object sender, RoutedEventArgs e) { if (Column == null) { return; } object content = Cell.Content; if (content is Border border) { content = border.Child; } if (content is TextBlock textBlock) { string value = FormatValueConverter.ObjectToString(Column.PropertyInfo.GetValue(textBlock.DataContext), MaxCellValueLength, Column.FormatConverter.IsFormatted); await ClipBoardUtils.SetTextAsync(value); } }
// TextBlock control doesn't allow selecting text, so add a Copy command to the context menu public static void AddContextMenu(TextBlock textBlock) { var contextMenu = new ContextMenu(); var keymap = AvaloniaLocator.Current.GetService <PlatformHotkeyConfiguration>(); var list = new AvaloniaList <object>(); var menuItemCopy = new TabMenuItem() { Header = "_Copy", Foreground = Brushes.Black, }; menuItemCopy.Click += delegate { ClipBoardUtils.SetText(textBlock.Text); }; list.Add(menuItemCopy); contextMenu.Items = list; textBlock.ContextMenu = contextMenu; }
private void ButtonImport_Click(object sender, global::Avalonia.Interactivity.RoutedEventArgs e) { string clipboardText = ClipBoardUtils.GetTextAsync().Result; TimeSpan?timeSpan = DateTimeUtils.ConvertTextToTimeSpan(clipboardText); if (timeSpan != null) { DateTime?newDateTime = _dateTimeConverter.Convert(timeSpan, typeof(string), null, null) as DateTime?; Property.PropertyInfo.SetValue(Property.Object, newDateTime); _timeTextBox.Text = timeSpan.ToString(); e.Handled = true; } else { DateTime?dateTime = DateTimeUtils.ConvertTextToDateTime(clipboardText); if (dateTime != null) { Property.PropertyInfo.SetValue(Property.Object, dateTime); _datePicker.SelectedDate = dateTime; _timeTextBox.Text = (string)_dateTimeConverter.Convert(dateTime, typeof(string), null, null); e.Handled = true; } } }
private async Task ImportBookmarkAsync(Call call) { string clipboardText = await ClipBoardUtils.GetTextAsync(); ImportBookmark(call, clipboardText, true); }