Ejemplo n.º 1
0
        private void CreateItem()
        {
            string itemName = _path + NameTextBox.Text;

            if ((DirectoryRadioButton.IsChecked ?? false))
            {
                Directory.CreateDirectory(itemName);

                _curretnItem.Items.Add(new TreeViewItemBuilder(NameTextBox.Text)
                                       .SetTag(itemName)
                                       .SetOnSelectedHandler(TreeViewBuilder.SelectedEventHandler)
                                       .AddContextMenu(new ContextMenuBuilder()
                                                       .AddMenuItem("Delete", TreeViewBuilder.DeleteEventHandler)
                                                       .AddMenuItem("Create new...")
                                                       .Build())
                                       .Build());
            }
            else
            {
                var attr = (FileAttributes)0;
                if (ReadOnlyCheckbox.IsChecked ?? false)
                {
                    attr |= FileAttributes.ReadOnly;
                }
                if (ArchiveCheckbox.IsChecked ?? false)
                {
                    attr |= FileAttributes.Archive;
                }
                if (SystemCheckbox.IsChecked ?? false)
                {
                    attr |= FileAttributes.System;
                }
                if (HiddenCheckbox.IsChecked ?? false)
                {
                    attr |= FileAttributes.Hidden;
                }

                File.Create(itemName);
                File.SetAttributes(itemName, attr);

                var cmb = new ContextMenuBuilder().AddMenuItem("Delete", TreeViewBuilder.DeleteEventHandler);
                if (NameTextBox.Text.EndsWith(".txt"))
                {
                    cmb.AddMenuItem("Open", TreeViewBuilder.OpenEventHandler);
                }

                _curretnItem.Items.Add(new TreeViewItemBuilder(NameTextBox.Text)
                                       .SetTag(itemName)
                                       .SetOnSelectedHandler(TreeViewBuilder.SelectedEventHandler)
                                       .AddContextMenu(cmb.Build())
                                       .Build());
            }
        }
Ejemplo n.º 2
0
        public void TestMultiselectContextMenu()
        {
            XmlDocument storedResults = new XmlDocument();

            storedResults.Load(TestResource("ContextMenuBuilderTestResults.xml"));

            foreach (Selection selection in XenObjectSelections)
            {
                MW(() =>
                {
                    ContextMenuBuilder cmd = new ContextMenuBuilder(_pluginManager, _mainWindow);
                    ToolStripItem[] items  = cmd.Build(selection.Objects.ConvertAll(x => new SelectedItem(GetAnyXenObject(xx => xx.opaque_ref == x.opaque_ref))));
                    AssertItemsMatchStoredResults(storedResults, selection, items);
                });
            }

            // use this to save results
            // Serializer.SerializeTestResult(TestResource("ContextMenuBuilderTestResults.xml"), s, items);
        }
Ejemplo n.º 3
0
        public void TestContextMenuFontCorrect()
        {
            ContextMenuBuilder builder = new ContextMenuBuilder(MainWindowWrapper.PluginManager, Program.MainWindow);

            MW(() => TestMenuFontCorrect(builder.Build(GetAnyVM())));
        }
        public void ShowContextMenu(Vector2 mousePosition, List <ContextMenuItem> contextMenuItems)
        {
            var genericMenu = ContextMenuBuilder.Build(contextMenuItems, mousePosition);

            genericMenu.ShowAsContext();
        }