Click here to Skip to main content
15,881,831 members
Articles / Desktop Programming / Windows Forms

.NET MNG Viewer

Rate me:
Please Sign up or sign in to vote.
4.17/5 (5 votes)
9 Apr 2009CPOL2 min read 40.8K   566   13  
A native .NET library and application to view the PNGs embedded in a MNG
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;

namespace SprinterPublishing
{
    public partial class ImageFrame : UserControl
    {
        private double scale = 1.0;
        Color c;

        public ImageFrame()
        {
            InitializeComponent();
            this.label.Text = String.Empty;
            this.pictureBox.Image = null;
            scale = 1.0;
            c = Color.LightGray;
        }

        public ImageFrame( Color backColor, double scale )
        {
            InitializeComponent();
            this.label.Text = String.Empty;
            this.pictureBox.Image = null;
            this.scale = scale;
            c = backColor;
        }

        public Color BackgroundColor
        {
            set
            {
                pictureBox.BackColor = value;
                c = value;
            }
        }

        public void Clear()
        {
            this.Hide();
        }

        public double ImageScale
        {
            get { return scale; }
            set { scale = value; Frame = pictureBox.Image; }
        }

        public Image Frame
        {
            get
            {
                return pictureBox.Image;
            }
            set
            {
                pictureBox.Image = null;
                pictureBox.BackColor = c;
                pictureBox.Image = value;
                if (value != null)
                {
                    this.Size = new Size( (int)(value.Size.Width * scale),
                                          (int)(value.Size.Height * scale + label.Height) );
                    pictureBox.Size = new Size( (int)( value.Size.Width * scale ),
                                                (int)(value.Size.Height * scale) );
                    this.Show();
                }
                else
                {
                    this.Hide();
                }
            }
        }

        public string Label
        {
            get
            {
                return label.Text;
            }
            set
            {
                label.Text = value;
            }
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior) Bally Technologies
United States United States
I've been software developer since early 1991. My focuses have ranged from deeply embedded (Intel and ARM architectures,) to firmware (C and C++), to application level software under Linux and Windows (C, C++ and C#.) Applications developed with .NET under Windows have been primarily test and support applications for other development activities.

Comments and Discussions