예제 #1
0
 /// <summary>
 /// Required method for Designer support - do not modify
 /// the contents of this method with the code editor.
 /// </summary>
 private void InitializeComponent()
 {
     System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(frmShellLinkTester));
     this.mnuMain = new IconMainMenu();
     this.mnuFileTop = new IconMenuItem();
     this.mnuNew = new IconMenuItem();
     this.mnuOpen = new IconMenuItem();
     this.mnuClose = new IconMenuItem();
     this.mnuFileSep1 = new IconMenuItem();
     this.mnuSave = new IconMenuItem();
     this.mnuSaveAs = new IconMenuItem();
     this.mnuFileSep2 = new IconMenuItem();
     this.mnuExit = new IconMenuItem();
     this.mnuHelpTop = new IconMenuItem();
     this.mnuAbout = new IconMenuItem();
     this.lblShortCut = new System.Windows.Forms.Label();
     this.lblTarget = new System.Windows.Forms.Label();
     this.txtTarget = new vbAccelerator.Controls.TextBox.AutoCompleteTextBox();
     this.txtArguments = new System.Windows.Forms.TextBox();
     this.txtDescription = new System.Windows.Forms.TextBox();
     this.lblArguments = new System.Windows.Forms.Label();
     this.lblDescription = new System.Windows.Forms.Label();
     this.btnPick = new System.Windows.Forms.Button();
     this.fraIcon = new System.Windows.Forms.GroupBox();
     this.btnChooseIcon = new System.Windows.Forms.Button();
     this.picIcon = new System.Windows.Forms.PictureBox();
     this.picSmallIcon = new System.Windows.Forms.PictureBox();
     this.txtIconIndex = new System.Windows.Forms.TextBox();
     this.txtIconFile = new System.Windows.Forms.TextBox();
     this.lblIconIndex = new System.Windows.Forms.Label();
     this.lblIconFile = new System.Windows.Forms.Label();
     this.fraIcon.SuspendLayout();
     this.SuspendLayout();
     //
     // mnuMain
     //
     this.mnuMain.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
                                                                             this.mnuFileTop,
                                                                             this.mnuHelpTop});
     //
     // mnuFileTop
     //
     this.mnuFileTop.Index = 0;
     this.mnuFileTop.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
                                                                                this.mnuNew,
                                                                                this.mnuOpen,
                                                                                this.mnuClose,
                                                                                this.mnuFileSep1,
                                                                                this.mnuSave,
                                                                                this.mnuSaveAs,
                                                                                this.mnuFileSep2,
                                                                                this.mnuExit});
     this.mnuFileTop.Text = "&File";
     //
     // mnuNew
     //
     this.mnuNew.Index = 0;
     this.mnuNew.Shortcut = System.Windows.Forms.Shortcut.CtrlN;
     this.mnuNew.Text = "&New";
     //
     // mnuOpen
     //
     this.mnuOpen.Index = 1;
     this.mnuOpen.Shortcut = System.Windows.Forms.Shortcut.CtrlO;
     this.mnuOpen.Text = "&Open...";
     //
     // mnuClose
     //
     this.mnuClose.Index = 2;
     this.mnuClose.Text = "&Close";
     //
     // mnuFileSep1
     //
     this.mnuFileSep1.Index = 3;
     this.mnuFileSep1.Text = "-";
     //
     // mnuSave
     //
     this.mnuSave.Index = 4;
     this.mnuSave.Shortcut = System.Windows.Forms.Shortcut.CtrlS;
     this.mnuSave.Text = "&Save";
     //
     // mnuSaveAs
     //
     this.mnuSaveAs.Index = 5;
     this.mnuSaveAs.Text = "Save &As...";
     //
     // mnuFileSep2
     //
     this.mnuFileSep2.Index = 6;
     this.mnuFileSep2.Text = "-";
     //
     // mnuExit
     //
     this.mnuExit.Index = 7;
     this.mnuExit.Text = "E&xit";
     //
     // mnuHelpTop
     //
     this.mnuHelpTop.Index = 1;
     this.mnuHelpTop.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
                                                                                this.mnuAbout});
     this.mnuHelpTop.Text = "&Help";
     //
     // mnuAbout
     //
     this.mnuAbout.Index = 0;
     this.mnuAbout.Text = "&About...";
     //
     // lblShortCut
     //
     this.lblShortCut.BackColor = System.Drawing.SystemColors.ControlDark;
     this.lblShortCut.Font = new System.Drawing.Font("Tahoma", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
     this.lblShortCut.ForeColor = System.Drawing.SystemColors.ControlLight;
     this.lblShortCut.Location = new System.Drawing.Point(4, 4);
     this.lblShortCut.Name = "lblShortCut";
     this.lblShortCut.Size = new System.Drawing.Size(372, 24);
     this.lblShortCut.TabIndex = 0;
     this.lblShortCut.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
     //
     // lblTarget
     //
     this.lblTarget.Location = new System.Drawing.Point(4, 40);
     this.lblTarget.Name = "lblTarget";
     this.lblTarget.Size = new System.Drawing.Size(68, 20);
     this.lblTarget.TabIndex = 1;
     this.lblTarget.Text = "&Target:";
     //
     // txtTarget
     //
     this.txtTarget.AutoCompleteFlags = vbAccelerator.Controls.TextBox.AutoCompleteTextBox.SHAutoCompleteFlags.SHACF_FILESYS_ONLY;
     this.txtTarget.Location = new System.Drawing.Point(72, 36);
     this.txtTarget.Name = "txtTarget";
     this.txtTarget.Size = new System.Drawing.Size(280, 21);
     this.txtTarget.TabIndex = 2;
     this.txtTarget.Text = "";
     //
     // txtArguments
     //
     this.txtArguments.Location = new System.Drawing.Point(72, 60);
     this.txtArguments.Name = "txtArguments";
     this.txtArguments.Size = new System.Drawing.Size(280, 21);
     this.txtArguments.TabIndex = 3;
     this.txtArguments.Text = "";
     //
     // txtDescription
     //
     this.txtDescription.Location = new System.Drawing.Point(72, 112);
     this.txtDescription.MaxLength = 1024;
     this.txtDescription.Multiline = true;
     this.txtDescription.Name = "txtDescription";
     this.txtDescription.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
     this.txtDescription.Size = new System.Drawing.Size(280, 80);
     this.txtDescription.TabIndex = 4;
     this.txtDescription.Text = "";
     //
     // lblArguments
     //
     this.lblArguments.Location = new System.Drawing.Point(4, 64);
     this.lblArguments.Name = "lblArguments";
     this.lblArguments.Size = new System.Drawing.Size(68, 23);
     this.lblArguments.TabIndex = 9;
     this.lblArguments.Text = "Arguments:";
     //
     // lblDescription
     //
     this.lblDescription.Location = new System.Drawing.Point(4, 112);
     this.lblDescription.Name = "lblDescription";
     this.lblDescription.Size = new System.Drawing.Size(68, 23);
     this.lblDescription.TabIndex = 10;
     this.lblDescription.Text = "Description:";
     //
     // btnPick
     //
     this.btnPick.FlatStyle = System.Windows.Forms.FlatStyle.System;
     this.btnPick.Location = new System.Drawing.Point(356, 36);
     this.btnPick.Name = "btnPick";
     this.btnPick.Size = new System.Drawing.Size(20, 20);
     this.btnPick.TabIndex = 13;
     this.btnPick.Text = "...";
     this.btnPick.Click += new System.EventHandler(this.btnPick_Click);
     //
     // fraIcon
     //
     this.fraIcon.Anchor = System.Windows.Forms.AnchorStyles.None;
     this.fraIcon.Controls.AddRange(new System.Windows.Forms.Control[] {
                                                                           this.btnChooseIcon,
                                                                           this.picIcon,
                                                                           this.picSmallIcon,
                                                                           this.txtIconIndex,
                                                                           this.txtIconFile,
                                                                           this.lblIconIndex,
                                                                           this.lblIconFile});
     this.fraIcon.FlatStyle = System.Windows.Forms.FlatStyle.System;
     this.fraIcon.Location = new System.Drawing.Point(8, 200);
     this.fraIcon.Name = "fraIcon";
     this.fraIcon.Size = new System.Drawing.Size(344, 156);
     this.fraIcon.TabIndex = 14;
     this.fraIcon.TabStop = false;
     this.fraIcon.Text = "Icon:";
     //
     // btnChooseIcon
     //
     this.btnChooseIcon.FlatStyle = System.Windows.Forms.FlatStyle.System;
     this.btnChooseIcon.Location = new System.Drawing.Point(64, 116);
     this.btnChooseIcon.Name = "btnChooseIcon";
     this.btnChooseIcon.Size = new System.Drawing.Size(76, 32);
     this.btnChooseIcon.TabIndex = 19;
     this.btnChooseIcon.Text = "Pick...";
     this.btnChooseIcon.Click += new System.EventHandler(this.btnChooseIcon_Click);
     //
     // picIcon
     //
     this.picIcon.Location = new System.Drawing.Point(68, 80);
     this.picIcon.Name = "picIcon";
     this.picIcon.Size = new System.Drawing.Size(32, 32);
     this.picIcon.TabIndex = 18;
     this.picIcon.TabStop = false;
     //
     // picSmallIcon
     //
     this.picSmallIcon.Location = new System.Drawing.Point(104, 80);
     this.picSmallIcon.Name = "picSmallIcon";
     this.picSmallIcon.Size = new System.Drawing.Size(32, 32);
     this.picSmallIcon.TabIndex = 17;
     this.picSmallIcon.TabStop = false;
     //
     // txtIconIndex
     //
     this.txtIconIndex.BackColor = System.Drawing.SystemColors.Control;
     this.txtIconIndex.Location = new System.Drawing.Point(64, 52);
     this.txtIconIndex.Name = "txtIconIndex";
     this.txtIconIndex.ReadOnly = true;
     this.txtIconIndex.Size = new System.Drawing.Size(276, 21);
     this.txtIconIndex.TabIndex = 16;
     this.txtIconIndex.Text = "";
     //
     // txtIconFile
     //
     this.txtIconFile.BackColor = System.Drawing.SystemColors.Control;
     this.txtIconFile.Location = new System.Drawing.Point(64, 24);
     this.txtIconFile.Name = "txtIconFile";
     this.txtIconFile.ReadOnly = true;
     this.txtIconFile.Size = new System.Drawing.Size(276, 21);
     this.txtIconFile.TabIndex = 15;
     this.txtIconFile.Text = "";
     //
     // lblIconIndex
     //
     this.lblIconIndex.Location = new System.Drawing.Point(4, 52);
     this.lblIconIndex.Name = "lblIconIndex";
     this.lblIconIndex.TabIndex = 14;
     this.lblIconIndex.Text = "Icon Index:";
     //
     // lblIconFile
     //
     this.lblIconFile.Location = new System.Drawing.Point(4, 24);
     this.lblIconFile.Name = "lblIconFile";
     this.lblIconFile.Size = new System.Drawing.Size(60, 23);
     this.lblIconFile.TabIndex = 13;
     this.lblIconFile.Text = "Icon File:";
     //
     // frmShellLinkTester
     //
     this.AutoScaleBaseSize = new System.Drawing.Size(5, 14);
     this.ClientSize = new System.Drawing.Size(380, 365);
     this.Controls.AddRange(new System.Windows.Forms.Control[] {
                                                                   this.fraIcon,
                                                                   this.btnPick,
                                                                   this.lblDescription,
                                                                   this.lblArguments,
                                                                   this.txtDescription,
                                                                   this.txtArguments,
                                                                   this.txtTarget,
                                                                   this.lblTarget,
                                                                   this.lblShortCut});
     this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
     this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
     this.Menu = this.mnuMain;
     this.Name = "frmShellLinkTester";
     this.Text = "Shell Link Tester";
     this.Load += new System.EventHandler(this.frmShellLinkTester_Load);
     this.fraIcon.ResumeLayout(false);
     this.ResumeLayout(false);
 }
예제 #2
0
        private void DrawIcon(Graphics gfx, Rectangle rect,
                              bool isSelected, bool isChecked, bool isRadioChecked, bool isEnabled)
        {
            System.Windows.Forms.ImageList iconImageList = null;

            IconMainMenu m = (IconMainMenu)this.GetMainMenu();

            if (m != null)
            {
                iconImageList = m.IconImageList;
            }
            else
            {
                IconContextMenu c = (IconContextMenu)this.GetContextMenu();
                if (c != null)
                {
                    iconImageList = c.IconImageList;
                }
            }

            bool hasIcon = false;

            if (iconImageList != null)
            {
                if ((m_iconIndex >= 0) && (m_iconIndex < iconImageList.Images.Count))
                {
                    hasIcon = true;

                    int x = rect.Left + (iconWidth - iconImageList.ImageSize.Width) / 2;
                    int y = rect.Top + (rect.Height - iconImageList.ImageSize.Height) / 2;

                    if ((isSelected) && (isEnabled))
                    {
                        // draw icon as a shadow here
                        ControlPaint.DrawImageDisabled(gfx,
                                                       iconImageList.Images[m_iconIndex],
                                                       x, y, Color.FromKnownColor(KnownColor.Control));
                        x -= 1;
                        y -= 1;
                    }
                    if (isEnabled)
                    {
                        iconImageList.Draw(gfx, x, y,
                                           iconImageList.ImageSize.Width, iconImageList.ImageSize.Height, m_iconIndex);
                    }
                    else
                    {
                        ControlPaint.DrawImageDisabled(gfx,
                                                       iconImageList.Images[m_iconIndex],
                                                       x, y, Color.FromKnownColor(KnownColor.Control));
                    }
                }
            }

            if (isChecked)
            {
                Rectangle checkRect = rect;
                checkRect.Width = iconWidth;
                checkRect.Inflate(-1, -1);
                checkRect.Height -= 1;
                Pen pen = SystemPens.Highlight;
                gfx.DrawRectangle(pen, checkRect);
                if (!hasIcon)
                {
                    int x = rect.Left + (iconWidth - SystemInformation.MenuCheckSize.Width) / 2;
                    int y = rect.Top + (rect.Height - SystemInformation.MenuCheckSize.Width) / 2;

                    // Fill the background of the check item with an alpha-blended
                    // highlight colour:
                    int alpha = 24;
                    if (isSelected)
                    {
                        alpha = 128;
                    }
                    Brush br = new SolidBrush(Color.FromArgb(alpha, Color.FromKnownColor(KnownColor.Highlight)));
                    gfx.FillRectangle(br, checkRect);
                    br.Dispose();

                    // create a new bitmap to draw the menu glyph onto:
                    Bitmap   bm = new Bitmap(SystemInformation.MenuCheckSize.Width, SystemInformation.MenuCheckSize.Height);
                    Graphics gr = Graphics.FromImage(bm);
                    if (isRadioChecked)
                    {
                        // draw radio option
                        ControlPaint.DrawMenuGlyph(gr, 0, 0,
                                                   bm.Width, bm.Height,
                                                   MenuGlyph.Bullet);
                    }
                    else
                    {
                        // draw check mark
                        ControlPaint.DrawMenuGlyph(gr, 0, 0,
                                                   bm.Width, bm.Height,
                                                   MenuGlyph.Checkmark);
                    }
                    Rectangle outRect = new Rectangle(x, y, bm.Width, bm.Height);
                    // Draw the menu glyph transparently:
                    ImageAttributes imgAttr = new ImageAttributes();
                    imgAttr.SetColorKey(bm.GetPixel(0, 0), bm.GetPixel(0, 0), ColorAdjustType.Default);
                    gfx.DrawImage(bm, outRect, 0, 0, bm.Width, bm.Height, GraphicsUnit.Pixel, imgAttr);
                    imgAttr.Dispose();
                    bm.Dispose();
                    gr.Dispose();
                }
            }
        }