コード例 #1
0
 public override void LoadResources()
 {
     this.Text = PdnResources.GetString("SavePaletteDialog.Text");
     this.Icon = Utility.ImageToIcon(ImageResource.Get("Icons.MenuFileSaveAsIcon.png").Reference);
     this.cancelButton.Text   = PdnResources.GetString("Form.CancelButton.Text");
     this.saveButton.Text     = PdnResources.GetString("Form.SaveButton.Text");
     this.typeANameLabel.Text = PdnResources.GetString("SavePaletteDialog.TypeANameLabel.Text");
     this.palettesLabel.Text  = PdnResources.GetString("SavePaletteDialog.PalettesLabel.Text");
     base.LoadResources();
 }
コード例 #2
0
        public static ImageResource FromImage(Image image)
        {
            if (image == null)
            {
                throw new ArgumentNullException("image");
            }

            ImageResource resource = new ImageResource(image);

            return(resource);
        }
コード例 #3
0
        public static ImageResource Get(string name)
        {
            ImageResource ir;

            if (!images.TryGetValue(name, out ir))
            {
                ir = new ImageResource(name);
                images.Add(name, ir);
            }

            return(ir);
        }
コード例 #4
0
        public override void LoadResources()
        {
            this.Text = PdnResources.GetString("ChooseToolDefaultsDialog.Text");
            this.Icon = Utility.ImageToIcon(ImageResource.Get("Icons.MenuLayersLayerPropertiesIcon.png").Reference);

            this.introText.Text       = PdnResources.GetString("ChooseToolDefaultsDialog.IntroText.Text");
            this.defaultToolText.Text = PdnResources.GetString("ChooseToolDefaultsDialog.DefaultToolText.Text");

            this.loadFromToolBarButton.Text = PdnResources.GetString("ChooseToolDefaultsDialog.LoadFromToolBarButton.Text");
            this.cancelButton.Text          = PdnResources.GetString("Form.CancelButton.Text");
            this.saveButton.Text            = PdnResources.GetString("Form.SaveButton.Text");
            this.resetButton.Text           = PdnResources.GetString("Form.ResetButton.Text");

            base.LoadResources();
        }
コード例 #5
0
ファイル: PdnStatusBar.cs プロジェクト: vip57884381/Paint.Net
        public PdnStatusBar()
        {
            InitializeComponent();

            this.cursorInfoStatusLabel.Image = ImageResource.Get("Icons.CursorXYIcon.png").Reference;
            this.cursorInfoStatusLabel.Text  = string.Empty;

            // imageInfo (width,height info)
            this.imageInfoStatusLabel.Image = ImageResource.Get("Icons.ImageSizeIcon.png").Reference;

            // progress
            this.progressStatusBar.Visible           = false;
            this.progressStatusSeparator.Visible     = false;
            this.progressStatusBar.Height           -= 4;
            this.progressStatusBar.ProgressBar.Style = ProgressBarStyle.Continuous;
        }
コード例 #6
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);
            }
        }
コード例 #7
0
ファイル: ToolInfo.cs プロジェクト: vip57884381/Paint.Net
 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;
 }
コード例 #8
0
ファイル: ToolInfo.cs プロジェクト: cyberjaxx/OpenPDN
 public ToolInfo(
     string name,
     string helpText,
     ImageResource image,
     char hotKey,
     bool skipIfActiveOnHotKey,
     ToolBarConfigItems toolBarConfigItems,
     Type toolType)
 {
     Name                 = name;
     HelpText             = helpText;
     Image                = image;
     HotKey               = hotKey;
     SkipIfActiveOnHotKey = skipIfActiveOnHotKey;
     ToolBarConfigItems   = toolBarConfigItems;
     ToolType             = toolType;
 }
コード例 #9
0
        public override void LoadResources()
        {
            this.Text = PdnResources.GetString("UnsavedChangesDialog.Text");
            this.Icon = Utility.ImageToIcon(ImageResource.Get("Icons.WarningIcon.png").Reference, false);

            this.infoLabel.Text          = PdnResources.GetString("UnsavedChangesDialog.InfoLabel.Text");
            this.documentListHeader.Text = PdnResources.GetString("UnsavedChangesDialog.DocumentListHeader.Text");

            this.saveButton.ActionText      = PdnResources.GetString("UnsavedChangesDialog.SaveButton.ActionText");
            this.saveButton.ExplanationText = PdnResources.GetString("UnsavedChangesDialog.SaveButton.ExplanationText");
            this.saveButton.ActionImage     = ImageResource.Get("Icons.UnsavedChangesDialog.SaveButton.png").Reference;

            this.dontSaveButton.ActionText      = PdnResources.GetString("UnsavedChangesDialog.DontSaveButton.ActionText");
            this.dontSaveButton.ExplanationText = PdnResources.GetString("UnsavedChangesDialog.DontSaveButton.ExplanationText");
            this.dontSaveButton.ActionImage     = ImageResource.Get("Icons.MenuFileCloseIcon.png").Reference;

            this.cancelButton.ActionText      = PdnResources.GetString("UnsavedChangesDialog.CancelButton.ActionText");
            this.cancelButton.ExplanationText = PdnResources.GetString("UnsavedChangesDialog.CancelButton.ExplanationText");
            this.cancelButton.ActionImage     = ImageResource.Get("Icons.CancelIcon.png").Reference;

            base.LoadResources();
        }
コード例 #10
0
ファイル: ImageStrip.cs プロジェクト: cyberjaxx/OpenPDN
        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);
            }
        }
コード例 #11
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);
            }
        }
コード例 #12
0
        public ControlShadow()
        {
            this.SetStyle(ControlStyles.Opaque, true);
            this.SetStyle(ControlStyles.UserPaint, true);
            this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
            this.SetStyle(ControlStyles.SupportsTransparentBackColor, true);

            this.Dock           = DockStyle.Fill;
            this.DoubleBuffered = true;
            this.ResizeRedraw   = true;

            // This call is required by the Windows.Forms Form Designer.
            InitializeComponent();
            BackColor = Color.Transparent;

            this.roundedEdgeUL = ImageResource.Get("Images.RoundedEdgeUL.png").Reference;
            this.roundedEdgeUR = ImageResource.Get("Images.RoundedEdgeUR.png").Reference;
            this.roundedEdgeLL = ImageResource.Get("Images.RoundedEdgeLL.png").Reference;
            this.roundedEdgeLR = ImageResource.Get("Images.RoundedEdgeLR.png").Reference;

            if (!PdnInfo.IsFinalBuild && !betaTagDone)
            {
                betaTagDone = true;

                string betaTagStringFormat = PdnResources.GetString("ControlShadow.BetaTag.Text.Format");
                string appName             = PdnInfo.GetFullAppName();
                string expiredDateString   = PdnInfo.ExpirationDate.ToShortDateString();
                this.betaTagString = string.Format(betaTagStringFormat, appName, expiredDateString);

                this.betaTagStart          = DateTime.Now;
                this.betaTagTimer          = new Timer();
                this.betaTagTimer.Interval = 100;
                this.betaTagTimer.Tick    += new EventHandler(BetaTagTimer_Tick);
                this.betaTagTimer.Enabled  = true;
            }
        }
コード例 #13
0
 public HistoryMemento(string name, ImageResource image)
 {
     this.name  = name;
     this.image = image;
     this.id    = Interlocked.Increment(ref nextId);
 }
コード例 #14
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);
        }
コード例 #15
0
ファイル: PdnMenuItem.cs プロジェクト: onelifeonelover/cstd
 public void SetIcon(ImageResource image)
 {
     this.ImageTransparentColor = Utility.TransparentKey;
     this.Image = image.Reference;
 }
コード例 #16
0
ファイル: MainForm.cs プロジェクト: vip57884381/Paint.Net
        protected override void OnDragDrop(DragEventArgs drgevent)
        {
            Activate();

            if (!IsCurrentModalForm || !Enabled)
            {
                // do nothing
            }
            else if (drgevent.Data.GetDataPresent(DataFormats.FileDrop))
            {
                string[] allFiles = (string[])drgevent.Data.GetData(DataFormats.FileDrop);

                if (allFiles == null)
                {
                    return;
                }

                string[] files = PruneDirectories(allFiles);

                bool importAsLayers = true;

                if (files.Length == 0)
                {
                    return;
                }
                else
                {
                    TaskButton openTB = new TaskButton(
                        ImageResource.Get("Icons.MenuFileOpenIcon.png").Reference,
                        PdnResources.GetString("DragDrop.OpenOrImport.OpenButton.ActionText"),
                        PdnResources.GetString("DragDrop.OpenOrImport.OpenButton.ExplanationText"));

                    string importLayersExplanation;
                    if (this.appWorkspace.DocumentWorkspaces.Length == 0)
                    {
                        importLayersExplanation = PdnResources.GetString("DragDrop.OpenOrImport.ImportLayers.ExplanationText.NoImagesYet");
                    }
                    else
                    {
                        importLayersExplanation = PdnResources.GetString("DragDrop.OpenOrImport.ImportLayers.ExplanationText");
                    }

                    TaskButton importLayersTB = new TaskButton(
                        ImageResource.Get("Icons.MenuLayersImportFromFileIcon.png").Reference,
                        PdnResources.GetString("DragDrop.OpenOrImport.ImportLayers.ActionText"),
                        importLayersExplanation);

                    TaskButton clickedTB = TaskDialog.Show(
                        this,
                        new Icon(PdnResources.GetResourceStream("Icons.Question.ico")),
                        PdnInfo.GetBareProductName(),
                        null,
                        false,
                        PdnResources.GetString("DragDrop.OpenOrImport.InfoText"),
                        new TaskButton[] { openTB, importLayersTB, TaskButton.Cancel },
                        null,
                        TaskButton.Cancel);

                    if (clickedTB == openTB)
                    {
                        importAsLayers = false;
                    }
                    else if (clickedTB == importLayersTB)
                    {
                        importAsLayers = true;
                    }
                    else
                    {
                        return;
                    }
                }

                if (!importAsLayers)
                {
                    // open files into new tabs
                    this.appWorkspace.OpenFilesInNewWorkspace(files);
                }
                else
                {
                    // no image open? we will have to create one
                    if (this.appWorkspace.ActiveDocumentWorkspace == null)
                    {
                        Size newSize = this.appWorkspace.GetNewDocumentSize();

                        this.appWorkspace.CreateBlankDocumentInNewWorkspace(
                            newSize,
                            Document.DefaultDpuUnit,
                            Document.GetDefaultDpu(Document.DefaultDpuUnit),
                            false);
                    }

                    ImportFromFileAction action = new ImportFromFileAction();
                    HistoryMemento       ha     = action.ImportMultipleFiles(this.appWorkspace.ActiveDocumentWorkspace, files);

                    if (ha != null)
                    {
                        this.appWorkspace.ActiveDocumentWorkspace.History.PushNewMemento(ha);
                    }
                }
            }

            base.OnDragDrop(drgevent);
        }
コード例 #17
0
ファイル: PdnMenuItem.cs プロジェクト: leejungho2/xynotecgui
 public void SetIcon(string imageName)
 {
     this.ImageTransparentColor = Utility.TransparentKey;
     this.Image = ImageResource.Get(imageName).Reference;
 }