コード例 #1
0
ファイル: MainWindow.xaml.cs プロジェクト: jugstalt/gview5
            async static public Task <SubPathParentToolStripItem> Create(MainWindow window, IExplorerParentObject exObject)
            {
                var item = new SubPathParentToolStripItem();

                if (exObject != null)
                {
                    item.DisplayStyle      = global::System.Windows.Forms.ToolStripItemDisplayStyle.Image;
                    item.Image             = gView.Win.DataExplorer.Properties.Resources.pfeil_r_s;
                    item.ImageScaling      = global::System.Windows.Forms.ToolStripItemImageScaling.None;
                    item.ShowDropDownArrow = false;

                    if (await exObject.ChildObjects() != null)
                    {
                        foreach (IExplorerObject childObject in await exObject.ChildObjects())
                        {
                            SubPathToolStripItem child = new SubPathToolStripItem(childObject);
                            child.Click += new EventHandler(window.SubPathItem_Click);
                            item.DropDownItems.Add(child);
                        }
                    }
                }
                item.BackColor = global::System.Drawing.Color.White;

                //base.Size = new Size(base.Size.Width, 14);

                return(item);
            }
コード例 #2
0
ファイル: MainWindow.xaml.cs プロジェクト: jugstalt/gview5
        async private Task tree_NodeSelected(global::System.Windows.Forms.TreeNode node)
        {
            if (_toolStripAddress == null)
            {
                return;
            }

            if (node is ExplorerObjectNode && ((ExplorerObjectNode)node).ExplorerObject != null)
            {
                RemovePathButtons();

                IExplorerObject pathObject = ((ExplorerObjectNode)node).ExplorerObject;
                while (pathObject != null)
                {
                    if (pathObject is IExplorerParentObject)
                    {
                        try
                        {
                            _toolStripAddress.Items.Insert(0, await SubPathParentToolStripItem.Create(this, (IExplorerParentObject)pathObject));
                        }
                        catch (Exception ex)
                        {
                            string msg = ex.Message;
                            MessageBox.Show(ex.Message);
                        }
                    }

                    SubPathToolStripItem item = new SubPathToolStripItem(pathObject);
                    item.Click += new EventHandler(SubPathItem_Click);
                    _toolStripAddress.Items.Insert(0, item);

                    pathObject = pathObject.ParentExplorerObject;
                }

                _selected.Clear();
                _selected.Add(_exObject = ((ExplorerObjectNode)node).ExplorerObject);

                await ViewTabPages(_exObject);

                if (_createNewRibbonGroupBox != null)
                {
                    RemoveCreateNewButtons();
                    PlugInManager compMan = new PlugInManager();
                    foreach (var compType in compMan.GetPlugins(gView.Framework.system.Plugins.Type.IExplorerObject))
                    {
                        IExplorerObject ex = compMan.CreateInstance <IExplorerObject>(compType);
                        if (ex is IExplorerObjectCreatable)
                        {
                            if (!((IExplorerObjectCreatable)ex).CanCreate(_exObject))
                            {
                                continue;
                            }

                            //if (_toolStripCreateNew.Items.Count == 0)
                            //{
                            //    _toolStripCreateNew.Items.Add(new System.Windows.Forms.ToolStripLabel(gView.Framework.Globalisation.LocalizedResources.GetResString("Create.New", "Create new") + ":"));
                            //}

                            CreateNewToolStripItem createNewItem = new CreateNewToolStripItem(ex);
                            createNewItem.Click += createNewItem_Click;
                            _createNewRibbonGroupBox.Items.Add(createNewItem);
                        }
                    }
                    if (_createNewRibbonGroupBox.Items.Count > 0)
                    {
                        _createNewRibbonGroupBox.Visibility = Visibility.Visible;
                    }
                }
            }
            else
            {
                RemovePathButtons();
                await ViewTabPages(null);
            }

            ValidateButtons();
        }