Author: aolk
Date: 2005-04-01 11:39:16 -0500 (Fri, 01 Apr 2005)
New Revision: 42464
Added:
trunk/winforms-tools/MWFResourceEditor/
trunk/winforms-tools/MWFResourceEditor/AboutDialog.cs
trunk/winforms-tools/MWFResourceEditor/Changelog
trunk/winforms-tools/MWFResourceEditor/ContentStruct.cs
trunk/winforms-tools/MWFResourceEditor/ContentType.cs
trunk/winforms-tools/MWFResourceEditor/ImagePanel.cs
trunk/winforms-tools/MWFResourceEditor/MWFResourceEditor.csproj
trunk/winforms-tools/MWFResourceEditor/MWFResourceEditor.sln
trunk/winforms-tools/MWFResourceEditor/MainForm.cs
trunk/winforms-tools/MWFResourceEditor/Makefile
trunk/winforms-tools/MWFResourceEditor/TextEntryDialog.cs
trunk/winforms-tools/MWFResourceEditor/TextPanel.cs
Log:
Initial import
Added: trunk/winforms-tools/MWFResourceEditor/AboutDialog.cs
===================================================================
--- trunk/winforms-tools/MWFResourceEditor/AboutDialog.cs 2005-04-01
14:54:12 UTC (rev 42463)
+++ trunk/winforms-tools/MWFResourceEditor/AboutDialog.cs 2005-04-01
16:39:16 UTC (rev 42464)
@@ -0,0 +1,161 @@
+using System;
+using System.Drawing;
+using System.Windows.Forms;
+
+namespace MWFResourceEditor
+{
+ public class AboutDialog : Form
+ {
+ private Button okButton;
+ private PaintPanel paintPanel;
+
+ public AboutDialog( )
+ {
+ okButton = new Button( );
+ paintPanel = new PaintPanel( );
+
+ SuspendLayout( );
+
+ okButton.Text = "OK";
+ okButton.Location = new Point( 170, 260 );
+ okButton.Click += new EventHandler( OnOkButtonClick );
+
+ paintPanel.BorderStyle = BorderStyle.Fixed3D;
+ paintPanel.Location = new Point( 10, 10 );
+ paintPanel.Size = new Size( 380, 240 );
+ paintPanel.BackColor = Color.White;
+
+ Text = "About MWFResourceEditor...";
+
+ this.FormBorderStyle = FormBorderStyle.FixedDialog;
+
+ ClientSize = new Size( 400, 300 );
+
+ AcceptButton = okButton;
+
+ Controls.Add( okButton );
+ Controls.Add( paintPanel );
+
+ ResumeLayout( false );
+ }
+
+ void OnOkButtonClick( object sender, EventArgs e )
+ {
+ Close( );
+ }
+
+ internal class PaintPanel : Panel
+ {
+ private System.Windows.Forms.Timer timer = new
System.Windows.Forms.Timer();
+
+ private Font paintFont;
+ private Font smallFont;
+ private SolidBrush managedPaintBrush;
+ private SolidBrush windowsPaintBrush;
+ private SolidBrush formsPaintBrush;
+ private SolidBrush shadowBrush;
+ private Color paintColor;
+ private int counter = 0;
+ private bool managedDrawn = false;
+ private bool windowsDrawn = false;
+ private bool formsDrawn = false;
+
+ private const int alphaMax = 32;
+
+ public PaintPanel( )
+ {
+ paintFont = new Font(
FontFamily.GenericMonospace, 36, FontStyle.Regular );
+ smallFont = new Font(
FontFamily.GenericSansSerif, 18, FontStyle.Italic );
+
+ paintColor = Color.FromArgb( 0, Color.Red );
+ shadowBrush = new SolidBrush( Color.FromArgb(
180, Color.LightBlue ) );
+
+ windowsPaintBrush = new SolidBrush( paintColor
);
+ managedPaintBrush = new SolidBrush( paintColor
);
+ formsPaintBrush = new SolidBrush( paintColor );
+
+ timer.Tick += new EventHandler( OnTimerTick );
+ timer.Interval = 50;
+ }
+
+ 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 )
+ {
+ 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 );
+ }
+
+ 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 );
+ }
+
+ protected override void OnVisibleChanged( EventArgs e )
+ {
+ if ( Visible )
+ timer.Start( );
+ else
+ timer.Stop( );
+
+ base.OnVisibleChanged( e );
+ }
+
+ void OnTimerTick( object sender, EventArgs e )
+ {
+ if ( !managedDrawn )
+ {
+ paintColor = Color.FromArgb( counter++,
Color.Red );
+ managedPaintBrush = new SolidBrush(
paintColor );
+ if ( counter == alphaMax )
+ {
+ managedDrawn = true;
+ counter = 0;
+ }
+ }
+ else
+ if ( !windowsDrawn )
+ {
+ paintColor = Color.FromArgb( counter++,
Color.Red );
+ windowsPaintBrush = new SolidBrush(
paintColor );
+ if ( counter == alphaMax )
+ {
+ windowsDrawn = true;
+ counter = 0;
+ }
+ }
+ else
+ if ( !formsDrawn )
+ {
+ paintColor = Color.FromArgb( counter++,
Color.Red );
+ formsPaintBrush = new SolidBrush(
paintColor );
+ if ( counter == alphaMax )
+ {
+ formsDrawn = true;
+ timer.Stop( );
+ }
+ }
+
+
+ Invalidate( );
+ Update( );
+ }
+ }
+ }
+}
Added: trunk/winforms-tools/MWFResourceEditor/Changelog
===================================================================
--- trunk/winforms-tools/MWFResourceEditor/Changelog 2005-04-01 14:54:12 UTC
(rev 42463)
+++ trunk/winforms-tools/MWFResourceEditor/Changelog 2005-04-01 16:39:16 UTC
(rev 42464)
@@ -0,0 +1,5 @@
+2005-04-01 Alexander Olk <[EMAIL PROTECTED]>
+
+ * AboutDialog.cs, ContentStruct.cs, ContentType.cs, ImagePanel.cs,
+ MainForm.cs, TextEntryDialog.cs, TextPanel.cs:
+ Initial import
Added: trunk/winforms-tools/MWFResourceEditor/ContentStruct.cs
===================================================================
--- trunk/winforms-tools/MWFResourceEditor/ContentStruct.cs 2005-04-01
14:54:12 UTC (rev 42463)
+++ trunk/winforms-tools/MWFResourceEditor/ContentStruct.cs 2005-04-01
16:39:16 UTC (rev 42464)
@@ -0,0 +1,24 @@
+using System;
+using System.Drawing;
+
+namespace MWFResourceEditor
+{
+ public struct ContentStruct
+ {
+ public Image image;
+
+ public string text;
+
+ public ContentType ctype;
+
+ public ContentStruct Clone( )
+ {
+ return (ContentStruct)MemberwiseClone( );
+ }
+ }
+}
+
+
+
+
+
Added: trunk/winforms-tools/MWFResourceEditor/ContentType.cs
===================================================================
--- trunk/winforms-tools/MWFResourceEditor/ContentType.cs 2005-04-01
14:54:12 UTC (rev 42463)
+++ trunk/winforms-tools/MWFResourceEditor/ContentType.cs 2005-04-01
16:39:16 UTC (rev 42464)
@@ -0,0 +1,13 @@
+using System;
+
+namespace MWFResourceEditor
+{
+ public enum ContentType
+ {
+ TypeImage,
+ TypeString,
+ TypeByte
+ }
+}
+
+
Added: trunk/winforms-tools/MWFResourceEditor/ImagePanel.cs
===================================================================
--- trunk/winforms-tools/MWFResourceEditor/ImagePanel.cs 2005-04-01
14:54:12 UTC (rev 42463)
+++ trunk/winforms-tools/MWFResourceEditor/ImagePanel.cs 2005-04-01
16:39:16 UTC (rev 42464)
@@ -0,0 +1,89 @@
+using System;
+using System.Drawing;
+using System.Windows.Forms;
+
+namespace MWFResourceEditor
+{
+ public class ImagePanel : Panel
+ {
+ private Image image;
+ private string imageName;
+ private PictureBox pictureBox;
+ private Button button;
+
+ private MainForm parentForm;
+
+ public ImagePanel( MainForm parentForm )
+ {
+ this.parentForm = parentForm;
+
+ button = new Button( );
+ pictureBox = new PictureBox( );
+ SuspendLayout( );
+
+ BackColor = Color.LightSlateGray;
+
+ button.Location = new Point( 10, 10 );
+ button.Size = new Size( 120, 21 );
+ button.Text = "Change Image";
+ button.Click += new EventHandler( OnClickButton );
+
+ Controls.Add( button );
+ Controls.Add( pictureBox );
+
+ ResumeLayout( false );
+ }
+
+ public Image Image
+ {
+ set
+ {
+ image = value;
+ pictureBox.Image = value;
+ pictureBox.Size = image.Size;
+ pictureBox.Location = new Point( ( Width / 2 )
- ( image.Width / 2 ), ( Height / 2 ) - ( image.Height / 2 ) );
+ }
+
+ get
+ {
+ return image;
+ }
+ }
+
+ public string ImageName
+ {
+ set
+ {
+ imageName = value;
+ }
+
+ get
+ {
+ return imageName;
+ }
+ }
+
+ void OnClickButton( object sender, EventArgs e )
+ {
+ OpenFileDialog ofd = new OpenFileDialog( );
+ ofd.CheckFileExists = true;
+
+ ofd.Filter = "Images
(*.png;*.jpg;*.gif;*.bmp)|*.png;*.jpg;*.gif;*.bmp|All files (*.*)|*.*";
+
+ if ( DialogResult.OK == ofd.ShowDialog( ) )
+ {
+ Image = Image.FromFile( ofd.FileName );
+
+ imageName = ofd.FileName;
+
+ string[] split = imageName.Split( new Char[] {
'\\', '/' } );
+
+ if ( split.Length > 0 )
+ imageName = split[ split.Length - 1 ];
+
+ parentForm.ChangeContentImage( );
+ }
+ }
+ }
+}
+
Added: trunk/winforms-tools/MWFResourceEditor/MWFResourceEditor.csproj
===================================================================
--- trunk/winforms-tools/MWFResourceEditor/MWFResourceEditor.csproj
2005-04-01 14:54:12 UTC (rev 42463)
+++ trunk/winforms-tools/MWFResourceEditor/MWFResourceEditor.csproj
2005-04-01 16:39:16 UTC (rev 42464)
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"
DefaultTargets="Build">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == ''
">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>8.0.30703</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{BC33943A-2C2F-488F-B544-6556791094FB}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <RootNamespace>MWFResourceEditor</RootNamespace>
+ <AssemblyName>MWFResourceEditor</AssemblyName>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' ==
'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <AllowUnsafeBlocks>false</AllowUnsafeBlocks>
+ <AllowUnsafeBlocks>false</AllowUnsafeBlocks>
+ <AllowUnsafeBlocks>false</AllowUnsafeBlocks>
+ <AllowUnsafeBlocks>false</AllowUnsafeBlocks>
+ <AllowUnsafeBlocks>false</AllowUnsafeBlocks>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' ==
'Release|AnyCPU' ">
+ <DebugSymbols>false</DebugSymbols>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <AllowUnsafeBlocks>false</AllowUnsafeBlocks>
+ <AllowUnsafeBlocks>false</AllowUnsafeBlocks>
+ <AllowUnsafeBlocks>false</AllowUnsafeBlocks>
+ <AllowUnsafeBlocks>false</AllowUnsafeBlocks>
+ <AllowUnsafeBlocks>false</AllowUnsafeBlocks>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System"/>
+ <Reference Include="System.Data"/>
+ <Reference Include="System.Drawing"/>
+ <Reference Include="System.Windows.Forms"/>
+ <Reference Include="System.Xml"/>
+ </ItemGroup>
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets"/>
+ <ItemGroup>
+ <Compile Include="AboutDialog.cs"/>
+ <Compile Include="ContentStruct.cs"/>
+ <Compile Include="ContentType.cs"/>
+ <Compile Include="ImagePanel.cs"/>
+ <Compile Include="MainForm.cs"/>
+ <Compile Include="TextEntryDialog.cs"/>
+ <Compile Include="TextPanel.cs"/>
+ </ItemGroup>
+</Project>
Added: trunk/winforms-tools/MWFResourceEditor/MWFResourceEditor.sln
===================================================================
--- trunk/winforms-tools/MWFResourceEditor/MWFResourceEditor.sln
2005-04-01 14:54:12 UTC (rev 42463)
+++ trunk/winforms-tools/MWFResourceEditor/MWFResourceEditor.sln
2005-04-01 16:39:16 UTC (rev 42464)
@@ -0,0 +1,18 @@
+Microsoft Visual Studio Solution File, Format Version 9.00
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MWFResourceEditor",
"MWFResourceEditor.csproj", "{BC33943A-2C2F-488F-B544-6556791094FB}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {BC33943A-2C2F-488F-B544-6556791094FB}.Debug|Any CPU.ActiveCfg
= Debug|Any CPU
+ {BC33943A-2C2F-488F-B544-6556791094FB}.Debug|Any CPU.Build.0 =
Debug|Any CPU
+ {BC33943A-2C2F-488F-B544-6556791094FB}.Release|Any
CPU.ActiveCfg = Release|Any CPU
+ {BC33943A-2C2F-488F-B544-6556791094FB}.Release|Any CPU.Build.0
= Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
Added: trunk/winforms-tools/MWFResourceEditor/MainForm.cs
===================================================================
--- trunk/winforms-tools/MWFResourceEditor/MainForm.cs 2005-04-01 14:54:12 UTC
(rev 42463)
+++ trunk/winforms-tools/MWFResourceEditor/MainForm.cs 2005-04-01 16:39:16 UTC
(rev 42464)
@@ -0,0 +1,740 @@
+using System;
+using System.Drawing;
+using System.Collections;
+using System.Windows.Forms;
+using System.Resources;
+
+using System.ComponentModel;
+
+namespace MWFResourceEditor
+{
+ public class MainForm : Form
+ {
+ private MainMenu mainMenu;
+ private MenuItem menuItemFile;
+ private MenuItem menuItemNew;
+ private MenuItem menuItemLoad;
+ private MenuItem menuItemSave;
+ private MenuItem menuItemSaveAs;
+ private MenuItem menuItemDash1;
+ private MenuItem menuItemExit;
+ private MenuItem menuItemResources;
+ private MenuItem menuItemAddString;
+ private MenuItem menuItemAddFiles;
+ private MenuItem menuItemCopy;
+// private MenuItem menuItemCut;
+ private MenuItem menuItemDelete;
+ private MenuItem menuItemPaste;
+ private MenuItem menuItemDash3;
+ private MenuItem menuItemRename;
+ private MenuItem menuItemHelp;
+ private MenuItem menuItemAbout;
+ private MenuItem menuItemDash2;
+ private Panel resourcePanel;
+ private Control contentControl;
+ private ImagePanel imagePanel;
+ private TextPanel textPanel;
+ private ListView resourceListView;
+ private ColumnHeader nameColumnHeader;
+ private ColumnHeader typeColumnHeader;
+ private ColumnHeader contentColumnHeader;
+ private ContextMenu contextMenu;
+
+ private ResXResourceReader resXResourceReader;
+
+ private ImageList imageList = new ImageList();
+
+ private Hashtable hashtable = new Hashtable();
+
+ private Panel activePanel;
+
+ private ContentStruct contentStructCopy;
+ private string itemNameCopy = "";
+
+ private string fullFileName = "New Resource.resx";
+
+ static int copyCounter = 1;
+
+ public MainForm( )
+ {
+ InitializeComponent( );
+ }
+
+ public TextPanel TextPanel
+ {
+ set
+ {
+ textPanel = value;
+ }
+
+ get
+ {
+ return textPanel;
+ }
+ }
+
+ private void InitializeComponent( )
+ {
+ menuItemFile = new MenuItem( );
+ menuItemNew = new MenuItem( );
+ menuItemLoad = new MenuItem( );
+ menuItemSave = new MenuItem( );
+ menuItemSaveAs = new MenuItem( );
+ menuItemDash1 = new MenuItem( );
+ menuItemExit = new MenuItem( );
+
+ menuItemResources = new MenuItem( );
+ menuItemAddString = new MenuItem( );
+ menuItemAddFiles = new MenuItem( );
+ menuItemDash2 = new MenuItem( );
+ menuItemDelete = new MenuItem( );
+ menuItemCopy = new MenuItem( );
+// menuItemCut = new MenuItem( );
+ menuItemPaste = new MenuItem( );
+ menuItemDash3 = new MenuItem( );
+ menuItemRename = new MenuItem( );
+
+ menuItemHelp = new MenuItem( );
+ menuItemAbout = new MenuItem( );
+
+ mainMenu = new MainMenu( );
+
+ contextMenu = new ContextMenu( );
+
+ imagePanel = new ImagePanel( this );
+ textPanel = new TextPanel( this );
+ resourcePanel = new Panel( );
+
+ nameColumnHeader = new ColumnHeader( );
+ typeColumnHeader = new ColumnHeader( );
+ contentColumnHeader = new ColumnHeader( );
+
+ resourceListView = new ListView( );
+
+ contentControl = new Control( );
+ contentControl.SuspendLayout( );
+ resourcePanel.SuspendLayout( );
+ SuspendLayout( );
+
+ // menuItemFile
+ menuItemFile.Index = 0;
+ menuItemFile.MenuItems.AddRange( new MenuItem[] {
+ menuItemNew,
+ menuItemLoad,
+ menuItemSave,
+ menuItemSaveAs,
+ menuItemDash1,
+ menuItemExit} );
+ menuItemFile.Text = "&File";
+
+ // menuItemNew
+ menuItemNew.Index = 1;
+ menuItemNew.Text = "&New";
+ menuItemNew.Click += new EventHandler(
OnMenuItemNewClick );
+
+ // menuItemLoad
+ menuItemLoad.Index = 2;
+ menuItemLoad.Text = "L&oad";
+ menuItemLoad.Click += new EventHandler(
OnMenuItemLoadClick );
+
+ // menuItemSave
+ menuItemSave.Index = 3;
+ menuItemSave.Text = "&Save";
+ menuItemSave.Click += new EventHandler(
OnMenuItemSaveClick );
+
+ // menuItemSaveAs
+ menuItemSaveAs.Index = 4;
+ menuItemSaveAs.Text = "S&ave as";
+
+ // menuItemDash
+ menuItemDash1.Index = 5;
+ menuItemDash1.Text = "-";
+
+ // menuItemExit
+ menuItemExit.Index = 6;
+ menuItemExit.Text = "E&xit";
+ menuItemExit.Click += new EventHandler(
OnMenuItemExitClick );
+
+ // menuItemResources
+ menuItemResources.Index = 7;
+ menuItemResources.MenuItems.AddRange( new MenuItem[] {
+
menuItemAddString,
+
menuItemAddFiles,
+
menuItemDash2,
+
menuItemDelete,
+
menuItemCopy,
+//
menuItemCut,
+
menuItemPaste,
+
menuItemRename } );
+ menuItemResources.Text = "Resources";
+
+ // menuItemAddString
+ menuItemAddString.Index = 8;
+ menuItemAddString.Text = "Add S&tring";
+ menuItemAddString.Click += new EventHandler(
OnMenuItemAddStringClick );
+
+ // menuItemAddFiles
+ menuItemAddFiles.Index = 9;
+ menuItemAddFiles.Text = "Add Fi&le(s)";
+ menuItemAddFiles.Click += new EventHandler(
OnMenuItemAddFilesClick );
+
+ // menuItemDash2
+ menuItemDash2.Index = 10;
+ menuItemDash2.Text = "-";
+
+ // menuItemDelete
+ menuItemDelete.Index = 11;
+ menuItemDelete.Text = "&Delete";
+ menuItemDelete.Click += new EventHandler(
OnMenuItemDeleteClick );
+
+ // menuItemCopy
+ menuItemCopy.Index = 12;
+ menuItemCopy.Text = "&Copy";
+ menuItemCopy.Click += new EventHandler(
OnMenuItemCopyClick );
+
+ // menuItemCut
+// menuItemCut.Index = 13;
+// menuItemCut.Text = "Cut";
+// menuItemCut.Click += new EventHandler(
OnMenuItemCutClick );
+
+ // menuItemPaste
+ menuItemPaste.Index = 14;
+ menuItemPaste.Text = "Paste";
+ menuItemPaste.Click += new EventHandler(
OnMenuItemPasteClick );
+
+ menuItemDash3.Index = 15;
+ menuItemDash3.Text = "-";
+
+ menuItemRename.Index = 16;
+ menuItemRename.Text = "Rename";
+ menuItemRename.Click += new EventHandler(
OnMenuItemRenameClick );
+
+ // menuItemHelp
+ menuItemHelp.Index = 17;
+ menuItemHelp.MenuItems.AddRange( new MenuItem[] {
+ menuItemAbout}
);
+ menuItemHelp.Text = "&Help";
+
+ // menuItemAbout
+ menuItemAbout.Index = 18;
+ menuItemAbout.Text = "A&bout";
+ menuItemAbout.Click += new EventHandler(
OnMenuItemAboutClick );
+
+ // mainMenu
+ mainMenu.MenuItems.AddRange( new MenuItem[] {
+ menuItemFile,
+ menuItemResources,
+ menuItemHelp} );
+
+ // contentControl
+ contentControl.Dock = DockStyle.Fill;
+ contentControl.Location = new Point( 0, 328 );
+ contentControl.Size = new Size( 592, 213 );
+ contentControl.TabIndex = 3;
+ contentControl.Controls.Add( textPanel );
+
+ activePanel = textPanel;
+
+ // textPanel
+ textPanel.Dock = DockStyle.Fill;
+ textPanel.Location = new Point( 0, 0 );
+ textPanel.Size = new Size( 592, 213 );
+
+ // imagePanel
+ imagePanel.Dock = DockStyle.Fill;
+ imagePanel.Location = new Point( 0, 0 );
+ imagePanel.Size = new Size( 592, 213 );
+
+ // nameColumnHeader
+ nameColumnHeader.Text = "Name";
+ nameColumnHeader.Width = 200;
+
+ // typeColumnHeader
+ typeColumnHeader.Text = "Type";
+ typeColumnHeader.Width = 150;
+
+ // contentColumnHeader
+ contentColumnHeader.Text = "Content";
+ contentColumnHeader.Width = 250;
+
+ // resourceListView
+ resourceListView.Columns.AddRange( new ColumnHeader[] {
+
nameColumnHeader,
+
typeColumnHeader,
+
contentColumnHeader} );
+ resourceListView.Dock = DockStyle.Fill;
+ resourceListView.GridLines = true;
+ resourceListView.Location = new Point( 0, 0 );
+ resourceListView.Size = new Size( 592, 328 );
+ resourceListView.TabIndex = 0;
+ resourceListView.View = View.Details;
+ resourceListView.FullRowSelect = true;
+ resourceListView.MultiSelect = false;
+ resourceListView.LabelEdit = true;
+ resourceListView.ContextMenu = contextMenu;
+
+ // resourcePanel
+ resourcePanel.Controls.Add( resourceListView );
+ resourcePanel.Dock = DockStyle.Top;
+ resourcePanel.Location = new Point( 0, 0 );
+ resourcePanel.Size = new Size( 592, 328 );
+ resourcePanel.TabIndex = 0;
+
+ // contextMenu
+ contextMenu.MenuItems.AddRange( new MenuItem[] {
+
menuItemAddString.CloneMenu( ),
+
menuItemAddFiles.CloneMenu( ),
+
menuItemDash2.CloneMenu( ),
+
menuItemDelete.CloneMenu( ),
+
menuItemCopy.CloneMenu( ),
+
menuItemPaste.CloneMenu( ),
+
menuItemRename.CloneMenu( )
+ } );
+
+ // MainForm
+ AutoScaleBaseSize = new Size( 5, 14 );
+ ClientSize = new Size( 592, 541 );
+
+ Controls.Add( contentControl );
+ Controls.Add( resourcePanel );
+
+ Menu = mainMenu;
+ Text = "MWF ResourceEditor";
+ contentControl.ResumeLayout( false );
+ resourcePanel.ResumeLayout( false );
+ ResumeLayout( false );
+
+ resourceListView.SelectedIndexChanged += new
EventHandler( OnResourceListViewSelectedIndexChanged );
+ }
+
+ void OnMenuItemNewClick( object sender, EventArgs e )
+ {
+ fullFileName = "New Resource.resx";
+
+ Text = fullFileName;
+
+ ResetListViewAndHashtable( );
+ }
+
+ private void ResetListViewAndHashtable( )
+ {
+ if ( resourceListView.Items.Count > 0 )
+ resourceListView.Clear( );
+
+ if ( hashtable.Count > 0 )
+ hashtable.Clear( );
+
+ if ( activePanel == imagePanel )
+ {
+ imagePanel.Hide( );
+ contentControl.Controls.Remove( imagePanel );
+ contentControl.Controls.Add( textPanel );
+
+ activePanel = textPanel;
+ textPanel.Show( );
+ }
+ }
+
+ void OnMenuItemLoadClick( object sender, EventArgs e )
+ {
+ ResetListViewAndHashtable( );
+
+ OpenFileDialog ofd = new OpenFileDialog( );
+ ofd.CheckFileExists = true;
+ ofd.Filter = "resx files (*.resx)|*.resx|All files
(*.*)|*.*";
+
+ if ( DialogResult.OK == ofd.ShowDialog( ) )
+ {
+ resXResourceReader = new ResXResourceReader(
ofd.FileName );
+
+ string fileName = ofd.FileName;
+
+ fullFileName = fileName;
+
+ string[] split = fileName.Split( new Char[] {
'\\', '/' } );
+
+ if ( split.Length > 0 )
+ fileName = split[ split.Length - 1 ];
+
+ Text = fileName;
+
+ FillListView( );
+
+ resXResourceReader.Close( );
+ }
+ }
+
+ void OnMenuItemSaveClick( object sender, EventArgs e )
+ {
+ if ( resourceListView.Items.Count == 0 )
+ return;
+
+ // disabled for now...
+ // as soon as ResXResourceWriter is fixed it will be
enabled again
+
+ /*System.IO.File.Delete( fullFileName );
+
+ ResXResourceWriter rxrw = new ResXResourceWriter(
fullFileName );
+
+ IDictionaryEnumerator ienumerator =
hashtable.GetEnumerator();
+
+ while ( ienumerator.MoveNext() )
+ {
+ ContentStruct cs = (ContentStruct)ienumerator.Value;
+
+ if ( cs.ctype == ContentType.TypeImage )
+ {
+ using (System.IO.MemoryStream mem = new
System.IO.MemoryStream())
+ {
+ cs.image.Save(mem,
System.Drawing.Imaging.ImageFormat.Png);
+
+ rxrw.AddResource( ienumerator.Key.ToString(),
mem.ToArray() );
+ }
+ }
+ else
+ if ( cs.ctype == ContentType.TypeString )
+ rxrw.AddResource( ienumerator.Key.ToString(), cs.text
);
+ }
+
+ rxrw.Close();*/
+ }
+
+ void OnMenuItemExitClick( object sender, EventArgs e )
+ {
+ Close( );
+ }
+
+ void OnMenuItemAddStringClick( object sender, EventArgs e )
+ {
+ string new_item_string = TextEntryDialog.Show( "New
String", "Enter new string:" );
+
+ if ( new_item_string.Length != 0 )
+ {
+ ContentStruct cs = new ContentStruct( );
+ cs.text = new_item_string;
+ cs.ctype = ContentType.TypeString;
+
+ hashtable.Add( new_item_string, cs );
+
+ ListViewItem listViewItem = new ListViewItem(
new_item_string );
+
+ listViewItem.SubItems.Add( "System.String" );
+ listViewItem.SubItems.Add( new_item_string );
+
+ resourceListView.BeginUpdate( );
+ if ( resourceListView.Items.Count == 0 )
+ resourceListView.Items.Add(
listViewItem );
+ else
+ resourceListView.Items.Insert( 0,
listViewItem );
+ resourceListView.EndUpdate( );
+ }
+ }
+
+ // currently only images...
+ void OnMenuItemAddFilesClick( object sender, EventArgs e )
+ {
+ OpenFileDialog ofd = new OpenFileDialog( );
+ ofd.CheckFileExists = true;
+ ofd.Multiselect = true;
+
+ ofd.Filter = "Images
(*.png;*.jpg;*.gif;*.bmp)|*.png;*.jpg;*.gif;*.bmp|All files (*.*)|*.*";
+
+ if ( DialogResult.OK == ofd.ShowDialog( ) )
+ {
+ foreach ( string s in ofd.FileNames )
+ {
+ try
+ {
+ Image image = Image.FromFile( s
);
+
+ string[] split = s.Split( new
Char[] { '\\', '/' } );
+
+ string imageName = "";
+
+ if ( split.Length > 0 )
+ imageName = split[
split.Length - 1 ];
+
+ ContentStruct cs = new
ContentStruct( );
+ cs.image = image;
+ cs.ctype =
ContentType.TypeImage;
+
+ imageList.Images.Add( image );
+
+ hashtable.Add( imageName, cs );
+
+ ListViewItem listViewItem = new
ListViewItem( imageName );
+
+ listViewItem.SubItems.Add(
image.ToString( ) );
+ listViewItem.SubItems.Add(
GetImageSizeString( image ) );
+
+ resourceListView.BeginUpdate( );
+ if (
resourceListView.Items.Count == 0 )
+
resourceListView.Items.Add( listViewItem );
+ else
+
resourceListView.Items.Insert( 0, listViewItem );
+ resourceListView.EndUpdate( );
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine( "File {0}
not found.", s );
+ }
+ }
+ }
+ }
+
+ void OnMenuItemDeleteClick( object sender, EventArgs e )
+ {
+ if ( resourceListView.SelectedItems.Count == 0 )
+ return;
+
+ hashtable.Remove( resourceListView.SelectedItems[ 0
].Text );
+
+ resourceListView.SelectedItems[ 0 ].Remove( );
+ }
+
+ void OnMenuItemCopyClick( object sender, EventArgs e )
+ {
+ if ( resourceListView.SelectedItems.Count == 0 )
+ return;
+
+ itemNameCopy = resourceListView.SelectedItems[ 0 ].Text;
+
+ ContentStruct cs = (ContentStruct)hashtable[
itemNameCopy ];
+
+ contentStructCopy = cs.Clone( );
+
+ BuildNameWithNumber( );
+ }
+
+ private void BuildNameWithNumber( )
+ {
+ string itemNameTest = itemNameCopy + "_" +
copyCounter.ToString( );
+
+ while ( hashtable.ContainsKey( itemNameTest ) )
+ {
+ copyCounter++;
+ itemNameTest = itemNameCopy + "_" +
copyCounter.ToString( );
+ }
+
+ itemNameCopy = itemNameTest;
+ }
+
+// void OnMenuItemCutClick( object sender, EventArgs e )
+// {
+// if ( resourceListView.SelectedItems.Count == 0 )
+// return;
+// }
+
+ void OnMenuItemPasteClick( object sender, EventArgs e )
+ {
+ if ( itemNameCopy == "" )
+ return;
+
+ hashtable.Add( itemNameCopy, contentStructCopy );
+
+ ListViewItem listViewItem = new ListViewItem(
itemNameCopy );
+
+ if ( contentStructCopy.ctype == ContentType.TypeString )
+ {
+ listViewItem.SubItems.Add( "System.String" );
+ listViewItem.SubItems.Add(
contentStructCopy.text );
+ }
+ else
+ if ( contentStructCopy.ctype == ContentType.TypeImage )
+ {
+ listViewItem.SubItems.Add(
contentStructCopy.image.ToString( ) );
+ listViewItem.SubItems.Add( GetImageSizeString(
contentStructCopy.image ) );
+ }
+
+ resourceListView.BeginUpdate( );
+ resourceListView.Items.Add( listViewItem );
+ resourceListView.EndUpdate( );
+ }
+
+ void OnMenuItemRenameClick( object sender, EventArgs e )
+ {
+ if ( resourceListView.SelectedItems.Count == 0 )
+ return;
+
+ string item_name = resourceListView.SelectedItems[ 0
].Text;
+
+ string new_item_string = TextEntryDialog.Show(
"Rename", "Enter new name for \"" + item_name + "\":" );
+
+ if ( new_item_string.Length != 0 )
+ {
+ ContentStruct cs = (ContentStruct)hashtable[
item_name ];
+
+ hashtable.Remove( item_name );
+
+ hashtable.Add( new_item_string, cs );
+
+ resourceListView.BeginUpdate( );
+ resourceListView.SelectedItems[ 0 ].Text =
new_item_string;
+ resourceListView.EndUpdate( );
+ }
+ }
+
+ void OnResourceListViewSelectedIndexChanged( object sender,
EventArgs e )
+ {
+ if ( resourceListView.SelectedItems.Count == 0 )
+ return;
+
+ ContentStruct cs = (ContentStruct)hashtable[
resourceListView.SelectedItems[ 0 ].Text ];
+
+ if ( cs.ctype == ContentType.TypeImage )
+ {
+ if ( activePanel == textPanel )
+ {
+ textPanel.Hide( );
+ contentControl.Controls.Remove(
textPanel );
+ contentControl.Controls.Add( imagePanel
);
+
+ activePanel = imagePanel;
+ imagePanel.Show( );
+ }
+
+ imagePanel.Image = cs.image;
+ }
+ else
+ if ( cs.ctype == ContentType.TypeString )
+ {
+ if ( activePanel == imagePanel )
+ {
+ imagePanel.Hide( );
+ contentControl.Controls.Remove(
imagePanel );
+ contentControl.Controls.Add( textPanel
);
+
+ activePanel = textPanel;
+ textPanel.Show( );
+ }
+
+ textPanel.ContentTextBox.Text = cs.text;
+ }
+ }
+
+ void OnMenuItemAboutClick( object sender, EventArgs e )
+ {
+ AboutDialog ad = new AboutDialog( );
+ ad.ShowDialog( );
+ }
+
+ void FillListView( )
+ {
+ IDictionaryEnumerator id =
resXResourceReader.GetEnumerator( );
+
+ resourceListView.BeginUpdate( );
+
+ foreach ( DictionaryEntry de in resXResourceReader )
+ {
+ ContentStruct cs = new ContentStruct( );
+
+ string hashName = de.Key.ToString( );
+
+ ListViewItem listViewItem = new ListViewItem(
hashName );
+
+ if ( de.Value.GetType( ) == typeof(Bitmap) )
+ {
+ listViewItem.SubItems.Add(
de.Value.GetType( ).ToString( ) );
+
+ Image image = (Image)de.Value;
+
+ cs.ctype = ContentType.TypeImage;
+ cs.image = image;
+
+ string imagesize = GetImageSizeString(
image );
+
+ listViewItem.SubItems.Add( imagesize );
+
+ imageList.Images.Add( image );
+ }
+ else
+ if ( de.Value.GetType( ) == typeof(String) )
+ {
+ cs.image = null;
+ cs.ctype = ContentType.TypeString;
+
+ cs.text = de.Value.ToString( );
+
+ listViewItem.SubItems.Add(
de.Value.GetType( ).ToString( ) );
+ listViewItem.SubItems.Add(
de.Value.ToString( ) );
+ }
+
+ hashtable.Add( hashName, cs );
+ resourceListView.Items.Add( listViewItem );
+ }
+
+ resourceListView.EndUpdate( );
+ }
+
+ private string GetImageSizeString( Image image )
+ {
+ string imagesize = "[Widht = ";
+ imagesize += image.Width + ", Height = ";
+ imagesize += image.Height + "]";
+ return imagesize;
+ }
+
+ public void ChangeContentText( )
+ {
+ if ( resourceListView.SelectedItems.Count != 0 )
+ {
+ resourceListView.BeginUpdate( );
+
+ string name = resourceListView.SelectedItems[ 0
].Text;
+
+ ContentStruct csnew = new ContentStruct( );
+
+ csnew.ctype = ContentType.TypeString;
+ csnew.text = textPanel.ContentTextBox.Text;
+
+ hashtable.Remove( name );
+
+ hashtable.Add( name, csnew );
+
+ ListViewItem lvichange =
resourceListView.Items[ resourceListView.Items.IndexOf(
resourceListView.SelectedItems[ 0 ] ) ];
+
+ lvichange.BeginEdit( );
+ lvichange.SubItems[ 2 ].Text =
textPanel.ContentTextBox.Text;
+
+ resourceListView.EndUpdate( );
+ }
+ }
+
+ public void ChangeContentImage( )
+ {
+ if ( resourceListView.SelectedItems.Count != 0 )
+ {
+ string imagename =
resourceListView.SelectedItems[ 0 ].Text;
+
+ ContentStruct csold = (ContentStruct)hashtable[
imagename ];
+
+ ContentStruct csnew = new ContentStruct( );
+
+ csnew.image = imagePanel.Image;
+ csnew.ctype = ContentType.TypeImage;
+
+ hashtable.Remove( imagename );
+
+ hashtable.Add( imagename, csnew );
+
+ if ( csold.image.Size != csnew.image.Size )
+ {
+ resourceListView.BeginUpdate( );
+
+ ListViewItem lvichange =
resourceListView.Items[ resourceListView.Items.IndexOf(
resourceListView.SelectedItems[ 0 ] ) ];
+
+ lvichange.BeginEdit( );
+ lvichange.SubItems[ 2 ].Text =
GetImageSizeString( csnew.image );
+
+ resourceListView.EndUpdate( );
+ }
+ }
+ }
+
+ [STAThread]
+ static void Main( )
+ {
+ Application.Run( new MainForm( ) );
+ }
+ }
+}
Added: trunk/winforms-tools/MWFResourceEditor/Makefile
===================================================================
--- trunk/winforms-tools/MWFResourceEditor/Makefile 2005-04-01 14:54:12 UTC
(rev 42463)
+++ trunk/winforms-tools/MWFResourceEditor/Makefile 2005-04-01 16:39:16 UTC
(rev 42464)
@@ -0,0 +1,10 @@
+all: mono
+
+mono:
+ mcs -out:resedit.exe MainForm.cs TextPanel.cs ImagePanel.cs
TextEntryDialog.cs AboutDialog.cs ContentType.cs ContentStruct.cs
/r:System.Windows.Forms.dll /r:System.Drawing.dll
+
+dotnet:
+ csc -out:resedit.exe MainForm.cs TextPanel.cs ImagePanel.cs
TextEntryDialog.cs AboutDialog.cs ContentType.cs ContentStruct.cs
/r:System.Windows.Forms.dll /r:System.Drawing.dll
+
+clean:
+ rm resedit.exe -r -f
Added: trunk/winforms-tools/MWFResourceEditor/TextEntryDialog.cs
===================================================================
--- trunk/winforms-tools/MWFResourceEditor/TextEntryDialog.cs 2005-04-01
14:54:12 UTC (rev 42463)
+++ trunk/winforms-tools/MWFResourceEditor/TextEntryDialog.cs 2005-04-01
16:39:16 UTC (rev 42464)
@@ -0,0 +1,134 @@
+using System;
+using System.Drawing;
+using System.Windows.Forms;
+
+// simple text entry dialog
+// returns an empty string if cancel is pressed otherwise the entered string
+// ListView item edit isn't implemented yet, so let's use this one...
+
+namespace MWFResourceEditor
+{
+ public class TextEntryDialog : Form
+ {
+ private string message;
+ private string dialogTitle;
+ private string dialogResultText;
+ private Button okButton;
+ private Button cancelButton;
+ private Label messageLabel;
+ private TextBox textBox;
+
+ public TextEntryDialog( )
+ {
+ okButton = new Button( );
+ cancelButton = new Button( );
+ textBox = new TextBox( );
+ messageLabel = new Label( );
+
+ SuspendLayout( );
+
+ okButton.Location = new Point( 40, 85 );
+ okButton.Size = new Size( 75, 23 );
+ okButton.Text = "OK";
+ okButton.Click += new EventHandler( OnClickButton );
+
+ cancelButton.Location = new Point( 130, 85 );
+ cancelButton.Size = new Size( 75, 23 );
+ cancelButton.Text = "Cancel";
+ cancelButton.Click += new EventHandler( OnClickButton );
+
+ messageLabel.Location = new Point( 10, 10 );
+ messageLabel.AutoSize = true;
+
+ textBox.Location = new Point( 10, 40 );
+ textBox.Size = new Size( 198, 23 );
+ textBox.ReadOnly = false;
+
+ ClientSize = new Size( 220, 140 );
+
+ FormBorderStyle = FormBorderStyle.FixedDialog;
+ MaximizeBox = false;
+ MinimizeBox = false;
+ AcceptButton = okButton;
+ CancelButton = cancelButton;
+ CenterToParent( );
+
+ Controls.Add( textBox );
+ Controls.Add( messageLabel );
+ Controls.Add( okButton );
+ Controls.Add( cancelButton );
+
+ ResumeLayout( false );
+ }
+
+ public string Message
+ {
+ set
+ {
+ message = value;
+ messageLabel.Text = message;
+ }
+
+ get
+ {
+ return message;
+ }
+ }
+
+ public string DialogResultText
+ {
+ set
+ {
+ dialogResultText = value;
+ }
+
+ get
+ {
+ return dialogResultText;
+ }
+ }
+
+ public string DialogTitle
+ {
+ set
+ {
+ dialogTitle = value;
+ Text = value;
+ }
+
+ get
+ {
+ return dialogTitle;
+ }
+ }
+
+
+ void OnClickButton( object sender, EventArgs e )
+ {
+ if ( sender == okButton )
+ {
+ dialogResultText = textBox.Text.Trim( );
+ }
+ else
+ {
+ dialogResultText = "";
+ }
+
+ Close( );
+ }
+
+ public static string Show( string message )
+ {
+ return Show( "Enter Text", message );
+ }
+
+ public static string Show( string title, string message )
+ {
+ TextEntryDialog td = new TextEntryDialog( );
+ td.DialogTitle = title;
+ td.Message = message;
+ td.ShowDialog( );
+ return td.DialogResultText;
+ }
+ }
+}
Added: trunk/winforms-tools/MWFResourceEditor/TextPanel.cs
===================================================================
--- trunk/winforms-tools/MWFResourceEditor/TextPanel.cs 2005-04-01 14:54:12 UTC
(rev 42463)
+++ trunk/winforms-tools/MWFResourceEditor/TextPanel.cs 2005-04-01 16:39:16 UTC
(rev 42464)
@@ -0,0 +1,54 @@
+using System;
+using System.Drawing;
+using System.Windows.Forms;
+
+namespace MWFResourceEditor
+{
+ public class TextPanel : Panel
+ {
+ private TextBox contentTextBox;
+
+ private MainForm parentForm;
+
+ public TextPanel( MainForm parentForm )
+ {
+ this.parentForm = parentForm;
+
+ contentTextBox = new TextBox( );
+
+ SuspendLayout( );
+
+ contentTextBox.Multiline = true;
+ contentTextBox.Dock = DockStyle.Fill;
+ contentTextBox.AcceptsReturn = true;
+ contentTextBox.AcceptsTab = true;
+ contentTextBox.ScrollBars = ScrollBars.Vertical |
ScrollBars.Horizontal;
+
+ Controls.Add( contentTextBox );
+
+ contentTextBox.TextChanged += new EventHandler(
OnContentTextBoxTextChanged );
+
+ ResumeLayout( false );
+ }
+
+ public TextBox ContentTextBox
+ {
+ set
+ {
+ contentTextBox = value;
+ }
+
+ get
+ {
+ return contentTextBox;
+ }
+ }
+
+ void OnContentTextBoxTextChanged( object sender, EventArgs e )
+ {
+ parentForm.ChangeContentText( );
+ }
+ }
+}
+
+
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches