Esempio n. 1
0
        // NOTE: Your constructor must be able to run successfully with a documentWorkspace
        //       of null. This is sent in while the DocumentControl static constructor
        //       class is building a list of ToolInfo instances, so that it may construct
        //       the list without having to also construct a DocumentControl.
        public Tool(DocumentWorkspace documentWorkspace,
                    ImageResource toolBarImage,
                    string name,
                    string helpText,
                    char hotKey,
                    bool skipIfActiveOnHotKey,
                    ToolBarConfigItems toolBarConfigItems)
        {
            this.documentWorkspace = documentWorkspace;
            this.toolBarImage      = toolBarImage;
            this.toolInfo          = new ToolInfo(name, helpText, toolBarImage, hotKey, skipIfActiveOnHotKey, toolBarConfigItems, this.GetType());

            if (this.documentWorkspace != null)
            {
                this.documentWorkspace.UpdateStatusBarToToolHelpText(this);
            }
        }
Esempio n. 2
0
 public ToolInfo(
     string name,
     string helpText,
     ImageResource image,
     char hotKey,
     bool skipIfActiveOnHotKey,
     ToolBarConfigItems toolBarConfigItems,
     Type toolType)
 {
     this.name                 = name;
     this.helpText             = helpText;
     this.image                = image;
     this.hotKey               = hotKey;
     this.skipIfActiveOnHotKey = skipIfActiveOnHotKey;
     this.toolBarConfigItems   = toolBarConfigItems;
     this.toolType             = toolType;
 }
Esempio n. 3
0
        protected virtual void DrawItemCloseButton(
            Graphics g,
            Item item,
            Rectangle itemRect,
            Rectangle closeButtonRect)
        {
            if (item.Checked && item.Selected)
            {
                const string resourceNamePrefix = "Images.ImageStrip.CloseButton.";
                const string resourceNameSuffix = ".png";
                string       resourceNameInfix  = item.CloseRenderState.ToString();

                string resourceName = resourceNamePrefix + resourceNameInfix + resourceNameSuffix;

                ImageResource imageResource = PdnResources.GetImageResource(resourceName);
                Image         image         = imageResource.Reference;

                g.SmoothingMode     = SmoothingMode.AntiAlias;
                g.InterpolationMode = InterpolationMode.HighQualityBicubic;

                g.DrawImage(image, closeButtonRect, new Rectangle(0, 0, image.Width, image.Width), GraphicsUnit.Pixel);
            }
        }
Esempio n. 4
0
        private void ChooseToolButton_DropDownOpening(object sender, EventArgs e)
        {
            this.chooseToolButton.DropDownItems.Clear();

            if (this.showChooseDefaults)
            {
                string        chooseToolText = PdnResources.GetString("ToolChooserStrip.ChooseToolDefaults.Text");
                ImageResource chooseToolIcon = PdnResources.GetImageResource("Icons.MenuLayersLayerPropertiesIcon.png");

                ToolStripMenuItem tsmi = new ToolStripMenuItem(
                    chooseToolText,
                    chooseToolIcon.Reference,
                    ChooseTool_Click);

                this.chooseToolButton.DropDownItems.Add(tsmi);
                this.chooseToolButton.DropDownItems.Add(new ToolStripSeparator());
            }

            for (int i = 0; i < this.toolInfos.Length; ++i)
            {
                ToolStripMenuItem toolMI = new ToolStripMenuItem();
                toolMI.Image = this.toolInfos[i].Image.Reference;
                toolMI.Text  = this.toolInfos[i].Name;
                toolMI.Tag   = this.toolInfos[i];

                if (this.toolInfos[i].ToolType == this.activeTool)
                {
                    toolMI.Checked = true;
                }
                else
                {
                    toolMI.Checked = false;
                }

                this.chooseToolButton.DropDownItems.Add(toolMI);
            }
        }
Esempio n. 5
0
 public void SetIcon(ImageResource image)
 {
     this.ImageTransparentColor = Utility.TransparentKey;
     this.Image = image.Reference;
 }
Esempio n. 6
0
        protected override void OnPaint(PaintEventArgs e)
        {
            if (this.historyStack != null)
            {
                using (SolidBrush backBrush = new SolidBrush(BackColor))
                {
                    e.Graphics.FillRectangle(backBrush, e.ClipRectangle);
                }

                e.Graphics.TranslateTransform(0, -this.scrollOffset);

                int afterImageHMargin = UI.ScaleWidth(1);

                StringFormat stringFormat = (StringFormat)StringFormat.GenericTypographic.Clone();
                stringFormat.LineAlignment = StringAlignment.Center;
                stringFormat.Trimming      = StringTrimming.EllipsisCharacter;

                Rectangle visibleViewRectangle = ClientRectangleToViewRectangle(ClientRectangle);

                // Fill in the background for the undo items
                Rectangle undoRect = UndoViewRectangle;
                e.Graphics.FillRectangle(SystemBrushes.Window, undoRect);

                // We only want to draw what's visible, so figure out the first and last
                // undo items that are actually visible and only draw them.
                Rectangle visibleUndoRect = Rectangle.Intersect(visibleViewRectangle, undoRect);

                int beginUndoIndex;
                int endUndoIndex;
                if (visibleUndoRect.Width > 0 && visibleUndoRect.Height > 0)
                {
                    ItemType itemType;
                    ViewPointToStackIndex(visibleUndoRect.Location, out itemType, out beginUndoIndex);
                    ViewPointToStackIndex(new Point(visibleUndoRect.Left, visibleUndoRect.Bottom - 1), out itemType, out endUndoIndex);
                }
                else
                {
                    beginUndoIndex = 0;
                    endUndoIndex   = -1;
                }

                // Draw undo items
                for (int i = beginUndoIndex; i <= endUndoIndex; ++i)
                {
                    Image         image;
                    ImageResource imageResource = this.historyStack.UndoStack[i].Image;

                    if (imageResource != null)
                    {
                        image = imageResource.Reference;
                    }
                    else
                    {
                        image = null;
                    }

                    int drawWidth;
                    if (image != null)
                    {
                        drawWidth = (image.Width * this.itemHeight) / image.Height;
                    }
                    else
                    {
                        drawWidth = this.itemHeight;
                    }

                    Brush textBrush;

                    if (i == this.undoItemHighlight)
                    {
                        Rectangle itemRect = new Rectangle(
                            0,
                            i * this.itemHeight,
                            ViewWidth,
                            this.itemHeight);

                        e.Graphics.FillRectangle(SystemBrushes.Highlight, itemRect);
                        textBrush = SystemBrushes.HighlightText;
                    }
                    else
                    {
                        textBrush = SystemBrushes.WindowText;
                    }

                    if (image != null)
                    {
                        e.Graphics.DrawImage(
                            image,
                            new Rectangle(0, i * this.itemHeight, drawWidth, this.itemHeight),
                            new Rectangle(0, 0, image.Width, image.Height),
                            GraphicsUnit.Pixel);
                    }

                    int textX = drawWidth + afterImageHMargin;

                    Rectangle textRect = new Rectangle(
                        textX,
                        i * this.itemHeight,
                        ViewWidth - textX,
                        this.itemHeight);

                    e.Graphics.DrawString(
                        this.historyStack.UndoStack[i].Name,
                        Font,
                        textBrush,
                        textRect,
                        stringFormat);
                }

                // Fill in the background for the redo items
                Rectangle redoRect = RedoViewRectangle;
                e.Graphics.FillRectangle(Brushes.SlateGray, redoRect);

                Font redoFont = new Font(Font, Font.Style | FontStyle.Italic);

                // We only want to draw what's visible, so figure out the first and last
                // redo items that are actually visible and only draw them.
                Rectangle visibleRedoRect = Rectangle.Intersect(visibleViewRectangle, redoRect);

                int beginRedoIndex;
                int endRedoIndex;
                if (visibleRedoRect.Width > 0 && visibleRedoRect.Height > 0)
                {
                    ItemType itemType;
                    ViewPointToStackIndex(visibleRedoRect.Location, out itemType, out beginRedoIndex);
                    ViewPointToStackIndex(new Point(visibleRedoRect.Left, visibleRedoRect.Bottom - 1), out itemType, out endRedoIndex);
                }
                else
                {
                    beginRedoIndex = 0;
                    endRedoIndex   = -1;
                }

                // Draw redo items
                for (int i = beginRedoIndex; i <= endRedoIndex; ++i)
                {
                    Image         image;
                    ImageResource imageResource = this.historyStack.RedoStack[i].Image;

                    if (imageResource != null)
                    {
                        image = imageResource.Reference;
                    }
                    else
                    {
                        image = null;
                    }

                    int drawWidth;

                    if (image != null)
                    {
                        drawWidth = (image.Width * this.itemHeight) / image.Height;
                    }
                    else
                    {
                        drawWidth = this.itemHeight;
                    }

                    int y = redoRect.Top + i * this.itemHeight;

                    Brush textBrush;
                    if (i == this.redoItemHighlight)
                    {
                        Rectangle itemRect = new Rectangle(
                            0,
                            y,
                            ViewWidth,
                            this.itemHeight);

                        e.Graphics.FillRectangle(SystemBrushes.Highlight, itemRect);
                        textBrush = SystemBrushes.HighlightText;
                    }
                    else
                    {
                        textBrush = SystemBrushes.InactiveCaptionText;
                    }

                    if (image != null)
                    {
                        e.Graphics.DrawImage(
                            image,
                            new Rectangle(0, y, drawWidth, this.itemHeight),
                            new Rectangle(0, 0, image.Width, image.Height),
                            GraphicsUnit.Pixel);
                    }

                    int textX = drawWidth + afterImageHMargin;

                    Rectangle textRect = new Rectangle(
                        textX,
                        y,
                        ViewWidth - textX,
                        this.itemHeight);

                    e.Graphics.DrawString(
                        this.historyStack.RedoStack[i].Name,
                        redoFont,
                        textBrush,
                        textRect,
                        stringFormat);
                }

                redoFont.Dispose();
                redoFont = null;

                stringFormat.Dispose();
                stringFormat = null;

                e.Graphics.TranslateTransform(0, this.scrollOffset);
            }

            base.OnPaint(e);
        }