Skip to content
This repository has been archived by the owner on Feb 8, 2018. It is now read-only.

Commit

Permalink
svn path=/trunk/winforms-tools/; revision=51343
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Olk committed Oct 6, 2005
1 parent 50d5136 commit e33d947
Show file tree
Hide file tree
Showing 14 changed files with 367 additions and 257 deletions.
59 changes: 37 additions & 22 deletions MWFResourceEditor/AboutDialog.cs
Expand Up @@ -83,31 +83,40 @@ public PaintPanel( )

protected override void OnPaint( PaintEventArgs pea )
{
base.OnPaint( pea );

Bitmap bmp = new Bitmap( pea.ClipRectangle.Width, pea.ClipRectangle.Height, pea.Graphics );
Graphics gr = Graphics.FromImage( bmp );

if ( formsDrawn )
using ( Bitmap bmp = new Bitmap( pea.ClipRectangle.Width, pea.ClipRectangle.Height, pea.Graphics ) )
{
gr.DrawString( "Managed", paintFont, shadowBrush, new Point( 75, 15 ) );
gr.DrawString( "Windows", paintFont, shadowBrush, new Point( 75, 65 ) );
gr.DrawString( "Forms", paintFont, shadowBrush, new Point( 75, 115 ) );

gr.DrawString( "Resource Editor", smallFont, new SolidBrush( Color.Black ), new Point( 80, 185 ) );

managedPaintBrush = new SolidBrush( Color.Red );
windowsPaintBrush = new SolidBrush( Color.Red );
formsPaintBrush = new SolidBrush( Color.Red );
using ( Graphics gr = Graphics.FromImage( bmp ) )
{
if ( formsDrawn )
{
gr.DrawString( "Managed", paintFont, shadowBrush, new Point( 75, 15 ) );
gr.DrawString( "Windows", paintFont, shadowBrush, new Point( 75, 65 ) );
gr.DrawString( "Forms", paintFont, shadowBrush, new Point( 75, 115 ) );

gr.DrawString( "Resource Editor", smallFont, new SolidBrush( Color.Black ), new Point( 80, 185 ) );

if ( managedPaintBrush != null )
managedPaintBrush.Dispose();
managedPaintBrush = new SolidBrush( Color.Red );
if ( windowsPaintBrush != null )
windowsPaintBrush.Dispose();
windowsPaintBrush = new SolidBrush( Color.Red );
if ( formsPaintBrush != null )
formsPaintBrush.Dispose();
formsPaintBrush = new SolidBrush( Color.Red );
}

gr.DrawString( "Managed", paintFont, managedPaintBrush, new Point( 70, 10 ) );

gr.DrawString( "Windows", paintFont, windowsPaintBrush, new Point( 70, 60 ) );

gr.DrawString( "Forms", paintFont, formsPaintBrush, new Point( 70, 110 ) );

pea.Graphics.DrawImage( bmp, pea.ClipRectangle.X, pea.ClipRectangle.Y );
}
}

gr.DrawString( "Managed", paintFont, managedPaintBrush, new Point( 70, 10 ) );

gr.DrawString( "Windows", paintFont, windowsPaintBrush, new Point( 70, 60 ) );

gr.DrawString( "Forms", paintFont, formsPaintBrush, new Point( 70, 110 ) );

pea.Graphics.DrawImage( bmp, pea.ClipRectangle.X, pea.ClipRectangle.Y );
base.OnPaint( pea );
}

protected override void OnVisibleChanged( EventArgs e )
Expand All @@ -125,6 +134,8 @@ void OnTimerTick( object sender, EventArgs e )
if ( !managedDrawn )
{
paintColor = Color.FromArgb( counter++, Color.Red );
if ( managedPaintBrush != null )
managedPaintBrush.Dispose();
managedPaintBrush = new SolidBrush( paintColor );
if ( counter == alphaMax )
{
Expand All @@ -136,6 +147,8 @@ void OnTimerTick( object sender, EventArgs e )
if ( !windowsDrawn )
{
paintColor = Color.FromArgb( counter++, Color.Red );
if ( windowsPaintBrush != null )
windowsPaintBrush.Dispose();
windowsPaintBrush = new SolidBrush( paintColor );
if ( counter == alphaMax )
{
Expand All @@ -147,6 +160,8 @@ void OnTimerTick( object sender, EventArgs e )
if ( !formsDrawn )
{
paintColor = Color.FromArgb( counter++, Color.Red );
if ( formsPaintBrush != null )
formsPaintBrush.Dispose();
formsPaintBrush = new SolidBrush( paintColor );
if ( counter == alphaMax )
{
Expand Down
14 changes: 9 additions & 5 deletions MWFResourceEditor/ByteArrayPanel.cs
Expand Up @@ -42,7 +42,7 @@ public ByteArrayPanel( MainForm parentForm )
| System.Windows.Forms.AnchorStyles.Left )
| System.Windows.Forms.AnchorStyles.Right ) ) );
textBox.Size = new Size( 586, 180 );
textBox.ScrollBars = ScrollBars.Vertical | ScrollBars.Horizontal;
// textBox.ScrollBars = ScrollBars.Vertical;
textBox.Font = new Font( FontFamily.GenericMonospace, 8 );

Controls.Add( textBox );
Expand Down Expand Up @@ -84,13 +84,17 @@ private void GenerateTextAndHexOutput( )
{
bool new_line = false;

int show_how_many_bytes = byteArray.Length > 1024 ? 1024 : byteArray.Length;

StringBuilder back_string = back_string = new StringBuilder( 19 );

sb_hex.Append( "00000000 " );

for ( int i = 0; i < byteArray.Length; i++ )
for ( int i = 0; i < show_how_many_bytes; i++ )
{
sb_text.Append( Convert.ToChar( byteArray[ i ] ) );
char c = Convert.ToChar( byteArray[ i ] );

sb_text.Append( c );

if ( new_line )
{
Expand All @@ -109,8 +113,8 @@ private void GenerateTextAndHexOutput( )

sb_hex.Append( byteArray[ i ].ToString( "X2" ) + " " );

if ( byteArray[ i ] != 9 && byteArray[ i ] != 10 && byteArray[ i ] != 13 )
back_string.Append( Convert.ToChar( byteArray[ i ] ) );
if ( Char.IsLetterOrDigit( c ) )
back_string.Append( c );
else
back_string.Append( "." );

Expand Down
18 changes: 18 additions & 0 deletions MWFResourceEditor/Changelog
@@ -1,3 +1,21 @@
2005-10-06 Alexander Olk <alex.olk@googlemail.com>

* AboutDialog.cs, ByteArrayPanel.cs, ImagePanel.cs, MainForm.cs,
ResourceBase.cs, ResourceByteArray.cs, ResourceColor.cs, ResourceCursor.cs,
ResourceIcon.cs, ResourceImage.cs, ResourceListBox.cs, ResourceString.cs,
TextPanel.cs:
- Use "Dispose" or "using" for graphics objects wherever it is possible
- Disable TextBox ScrollBars until they are fixed
- Reduce number of shown bytes in ByteArrayPanel to 1024
- Draw Button in ImagePanel after PictureBox
- Give a little hint in the titlebar if a file isn't saved
- On exit ask if an unsaved file should be saved
- During runtime FileDialog remembers the recently used path now and doesn't
delete the currently used resources if you press cancel in OpenFileDialog
- Moved some code from the ResourceXXX classes to ResourceBase
- Use Image.GetThumbnailImage to get a thumbnail for an image or an icon
- Keep aspect ratio in thumbnails

2005-09-21 Alexander Olk <xenomorph2@onlinehome.de>

* ResourceListBox.cs: Add cursor here, too
Expand Down
9 changes: 8 additions & 1 deletion MWFResourceEditor/ImagePanel.cs
Expand Up @@ -12,6 +12,7 @@ public class ImagePanel : Panel
{
private Image image;
private Icon icon;
private Icon old_icon;
private string imageOrIconName;
private PictureBox pictureBox;
private Button button;
Expand All @@ -27,6 +28,7 @@ public ImagePanel( MainForm parentForm )
SuspendLayout( );

BackColor = Color.LightSlateGray;
pictureBox.BackColor = Color.LightSlateGray;

button.Location = new Point( 10, 10 );
button.Size = new Size( 120, 21 );
Expand All @@ -36,8 +38,8 @@ public ImagePanel( MainForm parentForm )
Dock = DockStyle.Fill;
DockPadding.All = 5;

Controls.Add( button );
Controls.Add( pictureBox );
Controls.Add( button );

ResumeLayout( false );
}
Expand Down Expand Up @@ -73,6 +75,11 @@ public Icon Icon
set {
icon = value;

if ( old_icon != null )
old_icon.Dispose();

old_icon = icon;

pictureBox.Image = icon.ToBitmap( );
pictureBox.Size = pictureBox.Image.Size;
pictureBox.Location = new Point( ( Width / 2 ) - ( icon.Width / 2 ), ( Height / 2 ) - ( icon.Height / 2 ) );
Expand Down

0 comments on commit e33d947

Please sign in to comment.