コード例 #1
0
    private void Initialize()
    {
        var list = new AvaloniaList <object>();

        var menuItemCopyCellContents = new TabMenuItem("Copy - _Cell Contents");

        menuItemCopyCellContents.Click += MenuItemCopyCellContents_Click;
        list.Add(menuItemCopyCellContents);

        list.Add(new Separator());

        var menuItemCopyColumn = new TabMenuItem("Copy - Co_lumn");

        menuItemCopyColumn.Click += MenuItemCopyColumn_Click;
        list.Add(menuItemCopyColumn);

        var menuItemCopyRow = new TabMenuItem("Copy - _Row");

        menuItemCopyRow.Click += MenuItemCopyRow_Click;
        list.Add(menuItemCopyRow);

        list.Add(new Separator());

        var menuItemCopySelected = new TabMenuItem("Copy - _Selected");

        menuItemCopySelected.Click += MenuItemCopySelected_Click;
        list.Add(menuItemCopySelected);

        var menuItemCopySelectedCsv = new TabMenuItem("Copy - Selected - CSV");

        menuItemCopySelectedCsv.Click += MenuItemCopySelectedCsv_Click;
        list.Add(menuItemCopySelectedCsv);

        list.Add(new Separator());

        var menuItemCopyDataGrid = new TabMenuItem("Copy - _DataGrid");

        menuItemCopyDataGrid.Click += MenuItemCopyDataGrid_Click;
        list.Add(menuItemCopyDataGrid);

        var menuItemCopyDataGridCsv = new TabMenuItem("Copy - DataGrid - CS_V");

        menuItemCopyDataGridCsv.Click += MenuItemCopyDataGridCsv_Click;
        list.Add(menuItemCopyDataGridCsv);

        Items = list;

        DataGrid.CellPointerPressed += DataGrid_CellPointerPressed;
    }
コード例 #2
0
    // 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;
    }
コード例 #3
0
ファイル: TabContextMenu.cs プロジェクト: garyhertel/Atlas
    private void Initialize()
    {
        var list = new AvaloniaList <object>();

        var menuItemRefresh = new TabMenuItem("_Refresh");

        menuItemRefresh.Click += MenuItemRefresh_Click;
        list.Add(menuItemRefresh);

        var menuItemReload = new TabMenuItem("_Reload");

        menuItemReload.Click += MenuItemReload_Click;
        list.Add(menuItemReload);

        var menuItemReset = new TabMenuItem("Re_set");

        menuItemReset.Click += MenuItemReset_Click;
        list.Add(menuItemReset);

#if DEBUG
        var menuItemDebug = new TabMenuItem("_Debug");
        menuItemDebug.Click += MenuItemDebug_Click;
        list.Add(menuItemDebug);

        list.Add(new Separator());

        _checkboxAutoLoad = new CheckBox()
        {
            IsChecked = TabInstance.Project.UserSettings.AutoLoad,
        };
        var menuItemAutoLoad = new TabMenuItem()
        {
            Header = "_AutoLoad",
            Icon   = _checkboxAutoLoad,
        };
        menuItemAutoLoad.Click += MenuItemAutoLoad_Click;
        list.Add(menuItemAutoLoad);
#endif

        Items = list;
    }
コード例 #4
0
        protected virtual void DrawItems()
        {
            Grid tempGrid = new Grid()
            {
                Padding = new Thickness(0), Margin = new Thickness(0), ColumnSpacing = 0, RowSpacing = 0
            };

            for (int i = 0; i < ItemSource.Count; i++)
            {
                var         curItem = ItemSource[i] as TabMenuItemModel;
                TabMenuItem item    = new TabMenuItem()
                {
                    Data = curItem
                };
                item.Clicked += Item_Clicked;
                if (Orientation == StackOrientation.Horizontal)
                {
                    tempGrid.ColumnDefinitions.Add(new ColumnDefinition()
                    {
                        Width = GridLength.Star
                    });
                    tempGrid.Children.Add(item);
                    Grid.SetColumn(item, i);
                }
                else
                {
                    tempGrid.RowDefinitions.Add(new RowDefinition()
                    {
                        Height = GridLength.Star
                    });
                    tempGrid.Children.Add(item);
                    Grid.SetRow(item, i);
                }
            }
            Content = tempGrid;
        }
コード例 #5
0
ファイル: AvaloniaUtils.cs プロジェクト: garyhertel/Atlas
    public static void AddContextMenu(TextBox textBox)
    {
        var contextMenu = new ContextMenu()
        {
            Foreground = Theme.Foreground,
        };

        var keymap = AvaloniaLocator.Current.GetService <PlatformHotkeyConfiguration>();

        var list = new AvaloniaList <object>();

        if (!textBox.IsReadOnly)
        {
            var menuItemCut = new TabMenuItem("Cut");
            menuItemCut.Click += delegate { SendTextBoxKey(textBox, keymap.Cut); };
            list.Add(menuItemCut);
        }

        var menuItemCopy = new TabMenuItem("_Copy");

        menuItemCopy.Click += delegate { SendTextBoxKey(textBox, keymap.Copy); };
        list.Add(menuItemCopy);

        if (!textBox.IsReadOnly)
        {
            var menuItemPaste = new TabMenuItem("Paste");
            menuItemPaste.Click += delegate { SendTextBoxKey(textBox, keymap.Paste); };
            list.Add(menuItemPaste);
        }

        //list.Add(new Separator());

        contextMenu.Items = list;

        textBox.ContextMenu = contextMenu;
    }
コード例 #6
0
ファイル: AvaloniaUtils.cs プロジェクト: garyhertel/Atlas
    // 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;
    }