Esempio n. 1
0
        public FileSheet(WizardForm creator)
            : base(creator)
        {
            this.AutoScroll = true;

            titleLabel         = new Label();
            titleLabel.Text    = "Add files and folders to install.";
            titleLabel.Dock    = DockStyle.Top;
            titleLabel.Height  = 20;
            titleLabel.Left    = 0;
            titleLabel.Top     = 0;
            titleLabel.Padding = new Padding(5, 5, 5, 0);
            titleLabel.Font    = new Font("Verdana",
                                          10,
                                          FontStyle.Bold,
                                          GraphicsUnit.Point
                                          );
            titleLabel.BackColor = Color.White;

            descriptionLabel           = new Label();
            descriptionLabel.Text      = "Select Files and Directories you want to add to the installer";
            descriptionLabel.Dock      = DockStyle.Top;
            descriptionLabel.Height    = 50 - titleLabel.Height;
            descriptionLabel.Left      = 0;
            descriptionLabel.Top       = titleLabel.Height;
            descriptionLabel.Padding   = new Padding(8, 3, 5, 0);
            descriptionLabel.BackColor = Color.White;

            this.Controls.Add(descriptionLabel);

            this.Controls.Add(titleLabel);


            lineLabel             = new Label();
            lineLabel.Anchor      = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
            lineLabel.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
            lineLabel.Location    = new Point(0, titleLabel.Height + descriptionLabel.Height);
            lineLabel.Size        = new Size(this.Width, 2);

            this.Controls.Add(lineLabel);

            tree = new TreeView();
            tree.HideSelection = false;
            tree.Anchor        = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
            tree.Location      = new Point(4, titleLabel.Height + descriptionLabel.Height + lineLabel.Height + 5);
            tree.Width         = this.Width - 8 - 100 - 8;
            tree.Height        = this.Height - tree.Top - 7;
            tree.ImageList     = ImageListFactory.GetImageList();
            tree.MouseDown    += new MouseEventHandler(tree_MouseDown);

            this.Controls.Add(tree);

            newFolderButton          = new Button();
            newFolderButton.Anchor   = AnchorStyles.Top | AnchorStyles.Right;
            newFolderButton.Location = new Point(tree.Location.X + tree.Width + 8, tree.Top);
            newFolderButton.Width    = 100;
            newFolderButton.Height   = 23;
            newFolderButton.Text     = "New folder";
            newFolderButton.Click   += new EventHandler(newFolderButton_Click);

            this.Controls.Add(newFolderButton);

            removeButton          = new Button();
            removeButton.Anchor   = AnchorStyles.Top | AnchorStyles.Right;
            removeButton.Location = new Point(tree.Location.X + tree.Width + 8, newFolderButton.Bottom + 8);
            removeButton.Width    = 100;
            removeButton.Height   = 23;
            removeButton.Text     = "Remove folder";
            removeButton.Click   += new EventHandler(removeButton_Click);

            this.Controls.Add(removeButton);

            importDirectoryButton          = new Button();
            importDirectoryButton.Anchor   = AnchorStyles.Top | AnchorStyles.Right;
            importDirectoryButton.Location = new Point(tree.Location.X + tree.Width + 8, removeButton.Bottom + 8);
            importDirectoryButton.Width    = 100;
            importDirectoryButton.Height   = 23;
            importDirectoryButton.Text     = "Import directory";
            importDirectoryButton.Click   += new EventHandler(importDirectoryButton_Click);

            this.Controls.Add(importDirectoryButton);

            importFilesButton          = new Button();
            importFilesButton.Anchor   = AnchorStyles.Top | AnchorStyles.Right;
            importFilesButton.Location = new Point(tree.Location.X + tree.Width + 8, importDirectoryButton.Bottom + 8);
            importFilesButton.Width    = 100;
            importFilesButton.Height   = 23;
            importFilesButton.Text     = "Import files";
            importFilesButton.Click   += new EventHandler(importFilesButton_Click);

            this.Controls.Add(importFilesButton);

            contextMenu        = new ContextMenu();
            contextMenu.Popup += new EventHandler(contextMenu_Popup);
            // tree.ContextMenu = contextMenu;

            importFilesMenuItem        = new IconMenuItem("&Import Files", new Bitmap(WixFiles.GetResourceStream("bmp.import.bmp")));
            importFilesMenuItem.Click += new System.EventHandler(importFilesMenuItem_Click);
            contextMenu.MenuItems.Add(importFilesMenuItem);

            newFolderMenuItem        = new IconMenuItem("&New Folder", new Bitmap(WixFiles.GetResourceStream("bmp.new.bmp")));
            newFolderMenuItem.Click += new System.EventHandler(newFolderMenuItem_Click);
            contextMenu.MenuItems.Add(newFolderMenuItem);

            importFolderMenuItem        = new IconMenuItem("&Import Folder", new Bitmap(WixFiles.GetResourceStream("bmp.import.bmp")));
            importFolderMenuItem.Click += new System.EventHandler(importFolderMenuItem_Click);
            contextMenu.MenuItems.Add(importFolderMenuItem);

            newSpecialFolderMenuItem = new IconMenuItem("New Special Folder", new Bitmap(WixFiles.GetResourceStream("bmp.new.bmp")));
            foreach (string specialFolder in specialFolders)
            {
                IconMenuItem subItem = new IconMenuItem(specialFolder);
                subItem.Click += new EventHandler(specialFolderSubItem_Click);
                newSpecialFolderMenuItem.MenuItems.Add(subItem);
            }
            contextMenu.MenuItems.Add(newSpecialFolderMenuItem);

            newComponentMenuItem        = new IconMenuItem("New Component", new Bitmap(WixFiles.GetResourceStream("bmp.new.bmp")));
            newComponentMenuItem.Click += new EventHandler(newComponentMenuItem_Click);
            contextMenu.MenuItems.Add(newComponentMenuItem);

            deleteMenuItem        = new IconMenuItem("&Delete", new Bitmap(WixFiles.GetResourceStream("bmp.delete.bmp")));
            deleteMenuItem.Click += new EventHandler(deleteMenuItem_Click);
            contextMenu.MenuItems.Add(deleteMenuItem);


            XmlDocument         wxsDoc   = Wizard.WixFiles.WxsDocument;
            XmlNamespaceManager wxsNsmgr = Wizard.WixFiles.WxsNsmgr;

            XmlNodeList        dirNodes  = wxsDoc.SelectNodes("/wix:Wix/*/wix:Directory", wxsNsmgr);
            TreeNodeCollection treeNodes = tree.Nodes;

            InitTreeView(dirNodes);
        }
        private void InitializeComponent()
        {
            currTreeView = new TreeView();
            splitter1    = new Splitter();
            panel1       = new Panel();

            CustomPropertyGrid currGrid            = new CustomPropertyGrid();
            ContextMenu        currGridContextMenu = new ContextMenu();

            panelContextMenu        = new ContextMenu();
            panelContextMenu.Popup += new EventHandler(PopupPanelContextMenu);

            currTreeView.HideSelection      = false;
            currTreeView.Dock               = DockStyle.Left;
            currTreeView.ImageIndex         = -1;
            currTreeView.Location           = new Point(0, 0);
            currTreeView.Name               = "currTreeView";
            currTreeView.SelectedImageIndex = -1;
            currTreeView.Size               = new Size(256, 266);
            currTreeView.TabIndex           = 6;
            currTreeView.ImageList          = ImageListFactory.GetImageList();
            currTreeView.AfterSelect       += new TreeViewEventHandler(OnAfterSelect);
            currTreeViewContextMenu         = new ContextMenu();
            currTreeViewContextMenu.Popup  += new EventHandler(PopupTreeViewContextMenu);
            currTreeView.MouseDown         += new MouseEventHandler(TreeViewMouseDown);
            currTreeView.KeyDown           += new KeyEventHandler(TreeViewKeyDown);

            splitter1.Dock     = DockStyle.Left;
            splitter1.Location = new Point(140, 0);
            splitter1.Name     = "splitter1";
            splitter1.Size     = new Size(2, 266);
            splitter1.TabIndex = 7;
            splitter1.TabStop  = false;

            currGridContextMenu.Popup += new EventHandler(OnPropertyGridPopupContextMenu);

            currGrid.Dock                  = DockStyle.Fill;
            currGrid.Font                  = new Font("Tahoma", 8.25F, FontStyle.Regular, GraphicsUnit.Point, ((System.Byte)(0)));
            currGrid.Location              = new Point(140, 0);
            currGrid.Name                  = "_currGrid";
            currGrid.Size                  = new Size(250, 266);
            currGrid.TabIndex              = 1;
            currGrid.PropertySort          = PropertySort.Alphabetical;
            currGrid.ToolbarVisible        = false;
            currGrid.PropertyValueChanged += new PropertyValueChangedEventHandler(OnPropertyValueChanged);
            currGrid.ContextMenu           = currGridContextMenu;

            panel1.Controls.Add(currGrid);
            panel1.Dock     = DockStyle.Fill;
            panel1.Location = new Point(142, 0);
            panel1.Name     = "panel1";
            panel1.Size     = new Size(409, 266);
            panel1.TabIndex = 9;

            Controls.Add(panel1);
            Controls.Add(splitter1);
            Controls.Add(currTreeView);

            CurrentGrid            = currGrid;
            CurrentGridContextMenu = currGridContextMenu;
        }