Esempio n. 1
0
        private void AddItemButton_Click(object sender, EventArgs e)
        {
            var contextmenu = presentation.AddSourceContextMenu();

            contextmenu.ItemClicked += (o, args) =>
            {
                var tag    = (Tuple <string, string>)args.ClickedItem.Tag;
                var source = presentation.CreateSource(tag.Item1, tag.Item2);
                var item   = presentation.CreateItem(source);
                if (new TestProperties(source).ShowDialog() == DialogResult.OK)
                {
                    presentation.AddSource(source);

                    presentation.AddItem(item);

                    ItemListBox.SelectedIndex   = 0;
                    SourceListBox.SelectedIndex = 0;
                }
                else
                {
                    item.Remove();
                    item.Dispose();
                    source.Remove();
                    source.Dispose();
                }
            };
            contextmenu.Show(this, PointToClient(Cursor.Position));
        }