From: <du...@us...> - 2007-07-01 14:58:55
|
Revision: 663 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=663&view=rev Author: dukus Date: 2007-07-01 07:58:53 -0700 (Sun, 01 Jul 2007) Log Message: ----------- New Control panel Modified Paths: -------------- trunk/plugins/mpinstaler/MPInstaler/Build dialog.cs trunk/plugins/mpinstaler/MPInstaler/Form1.cs trunk/plugins/mpinstaler/MPInstaler/MPInstaler.csproj trunk/plugins/mpinstaler/MPInstaler/MPinstalerStruct.cs trunk/plugins/mpinstaler/MPInstaler/MPpackageStruct.cs trunk/plugins/mpinstaler/MPInstaler/Properties/AssemblyInfo.cs trunk/plugins/mpinstaler/MPInstaler/SkinSelect.Designer.cs trunk/plugins/mpinstaler/MPInstaler/SkinSelect.cs trunk/plugins/mpinstaler/MPInstaler/wizard/controlp.Designer.cs trunk/plugins/mpinstaler/MPInstaler/wizard/controlp.cs trunk/plugins/mpinstaler/MPInstaler/wizard/controlp.resx trunk/plugins/mpinstaler/MPInstaler.sln Added Paths: ----------- trunk/plugins/mpinstaler/MPInstaler/MozBarControl/ trunk/plugins/mpinstaler/MPInstaler/MozBarControl/AssemblyInfo.cs trunk/plugins/mpinstaler/MPInstaler/MozBarControl/ImageListPanel.cs trunk/plugins/mpinstaler/MPInstaler/MozBarControl/ImageListPanel.resx trunk/plugins/mpinstaler/MPInstaler/MozBarControl/ImageMapEditor.cs trunk/plugins/mpinstaler/MPInstaler/MozBarControl/MozBar.csproj trunk/plugins/mpinstaler/MPInstaler/MozBarControl/MozBar.csproj.user trunk/plugins/mpinstaler/MPInstaler/MozBarControl/MozBar.snk trunk/plugins/mpinstaler/MPInstaler/MozBarControl/MozItem.bmp trunk/plugins/mpinstaler/MPInstaler/MozBarControl/MozItem.cs trunk/plugins/mpinstaler/MPInstaler/MozBarControl/MozItem.resx trunk/plugins/mpinstaler/MPInstaler/MozBarControl/MozPane.bmp trunk/plugins/mpinstaler/MPInstaler/MozBarControl/MozPane.cs trunk/plugins/mpinstaler/MPInstaler/MozBarControl/MozPane.resx trunk/plugins/mpinstaler/MPInstaler/MozBarControl/ScrollableControlWithScrollEvents.cs trunk/plugins/mpinstaler/MPInstaler/MozBarControl/ScrollableControlWithScrollEvents.resx trunk/plugins/mpinstaler/MPInstaler/MozBarControl/ThemeManager.cs Modified: trunk/plugins/mpinstaler/MPInstaler/Build dialog.cs =================================================================== --- trunk/plugins/mpinstaler/MPInstaler/Build dialog.cs 2007-07-01 14:56:20 UTC (rev 662) +++ trunk/plugins/mpinstaler/MPInstaler/Build dialog.cs 2007-07-01 14:58:53 UTC (rev 663) @@ -7,6 +7,8 @@ using System.IO; using System.Net; using System.Windows.Forms; +using MediaPortal.Utils.Web; +using MediaPortal.Utils; namespace MPInstaler { @@ -166,5 +168,9 @@ textBox4.Enabled = true; } } + + private void button5_Click(object sender, EventArgs e) + { + } } } \ No newline at end of file Modified: trunk/plugins/mpinstaler/MPInstaler/Form1.cs =================================================================== --- trunk/plugins/mpinstaler/MPInstaler/Form1.cs 2007-07-01 14:56:20 UTC (rev 662) +++ trunk/plugins/mpinstaler/MPInstaler/Form1.cs 2007-07-01 14:58:53 UTC (rev 663) @@ -29,6 +29,7 @@ { proiect_file_name = fil; InitializeComponent(); + proiectt_textBox6.Items.AddRange(MPinstalerStruct.CategoriListing); _struct.LoadFromFile(fil); _struct.ProiectdFileName = fil; loadProperties(); @@ -41,12 +42,9 @@ private void sToolStripMenuItem_Click(object sender, EventArgs e) { - if (proiectt_textBox1.Text.Length == 0) - { - MessageBox.Show("Name is mandatory !", "Stop"); - proiectt_textBox1.Focus(); + if (!IsGoodToSave()) return; - } + saveFileDialog1.Filter = "Proiect files (*.xmp)|*.xmp|All files (*.*)|*.*"; saveFileDialog1.DefaultExt = "*.xmp"; if (Path.GetFileName(proiect_file_name) == "Untitled" || String.IsNullOrEmpty(proiect_file_name.Trim())) @@ -293,16 +291,13 @@ private void buildToolStripMenuItem_Click(object sender, EventArgs e) { - if (proiectt_textBox1.Text.Length == 0) + if (IsGoodToSave()) { - MessageBox.Show("Name is mandatory !", "Stop"); - proiectt_textBox1.Focus(); - return; + sToolStripMenuItem_Click(sender, e); + Build_dialog buildfrm = new Build_dialog(this._struct); + buildfrm.ShowDialog(); + this._struct = buildfrm._struct; } - sToolStripMenuItem_Click(sender, e); - Build_dialog buildfrm = new Build_dialog(this._struct); - buildfrm.ShowDialog(); - this._struct = buildfrm._struct; } private void newToolStripMenuItem_Click(object sender, EventArgs e) @@ -676,5 +671,21 @@ } } + private bool IsGoodToSave() + { + if (proiectt_textBox1.Text.Length == 0) + { + MessageBox.Show("Name is mandatory !", "Stop"); + proiectt_textBox1.Focus(); + return false; + } + if (proiectt_textBox6.Text.Length == 0) + { + MessageBox.Show("Group is mandatory !", "Stop"); + proiectt_textBox6.Focus(); + return false; + } + return true; + } } } \ No newline at end of file Modified: trunk/plugins/mpinstaler/MPInstaler/MPInstaler.csproj =================================================================== --- trunk/plugins/mpinstaler/MPInstaler/MPInstaler.csproj 2007-07-01 14:56:20 UTC (rev 662) +++ trunk/plugins/mpinstaler/MPInstaler/MPInstaler.csproj 2007-07-01 14:58:53 UTC (rev 663) @@ -59,6 +59,7 @@ <Reference Include="System.Configuration.Install" /> <Reference Include="System.Data" /> <Reference Include="System.Deployment" /> + <Reference Include="System.Design" /> <Reference Include="System.Drawing" /> <Reference Include="System.Management" /> <Reference Include="System.Windows.Forms" /> @@ -87,7 +88,6 @@ <Compile Include="GroupForm.Designer.cs"> <DependentUpon>GroupForm.cs</DependentUpon> </Compile> - <Compile Include="ItemCombo.cs" /> <Compile Include="MPinstalerStruct.cs" /> <Compile Include="Form1.cs"> <SubType>Form</SubType> @@ -225,6 +225,12 @@ <Install>true</Install> </BootstrapperPackage> </ItemGroup> + <ItemGroup> + <ProjectReference Include="MozBarControl\MozBar.csproj"> + <Project>{180E4B12-A45B-4091-8A6F-91031C28DA3D}</Project> + <Name>MozBar</Name> + </ProjectReference> + </ItemGroup> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> <!-- To modify your build process, add your task inside one of the targets below and uncomment it. Other similar extension points exist, see Microsoft.Common.targets. Modified: trunk/plugins/mpinstaler/MPInstaler/MPinstalerStruct.cs =================================================================== --- trunk/plugins/mpinstaler/MPInstaler/MPinstalerStruct.cs 2007-07-01 14:56:20 UTC (rev 662) +++ trunk/plugins/mpinstaler/MPInstaler/MPinstalerStruct.cs 2007-07-01 14:58:53 UTC (rev 663) @@ -17,7 +17,11 @@ { public class MPinstalerStruct { + public const string DEFAULT_UPDATE_SITE = "http://dukus.extra.hu"; + static public string[] CategoriListing ={ "Audio/Radio", "Automation", "EPG/TV", "Games", "Input", "Others", "PIM", "Skins", "Utilities", "Video/Movies", "Web", "TV Logo" }; + + public const string PLUGIN_TYPE = "Plugin"; public const string PLUGIN_WINDOW_SUBTYPE = "Window"; public const string PLUGIN_PROCESS_SUBTYPE = "Process"; @@ -40,7 +44,7 @@ string _builFileName = string.Empty; string _proiectFileName = string.Empty; string _author = string.Empty; - string _update = string.Empty; + string _update = DEFAULT_UPDATE_SITE; string _name = string.Empty; string _version = string.Empty; string _description = string.Empty; @@ -53,7 +57,6 @@ public List<ActionInfo> Actions; public List<GroupString> SetupGroups; public List<GroupStringMapping> SetupGroupsMappig; - public MPinstalerStruct() { Language = new List<LanguageString>(); @@ -68,7 +71,7 @@ get { return _update; } set { - if (value == null) _update = ""; else _update = value.Trim(); + if (String.IsNullOrEmpty(value)) _update = DEFAULT_UPDATE_SITE; else _update = value.Trim(); } } Modified: trunk/plugins/mpinstaler/MPInstaler/MPpackageStruct.cs =================================================================== --- trunk/plugins/mpinstaler/MPInstaler/MPpackageStruct.cs 2007-07-01 14:56:20 UTC (rev 662) +++ trunk/plugins/mpinstaler/MPInstaler/MPpackageStruct.cs 2007-07-01 14:58:53 UTC (rev 663) @@ -25,6 +25,8 @@ public string txt_readme = String.Empty; public bool isNew = false; public bool isUpdated = false; + public bool isLocal = false; + public bool isInstalled = false; public bool containsSkin = false; public bool isValid = false; public List<string> SkinList; @@ -38,6 +40,7 @@ isValid = false; isNew = false; isUpdated = false; + isLocal = false; SkinList = new List<string>(); InstallableSkinList = new List<string>(); @@ -298,8 +301,17 @@ Directory.CreateDirectory(InstalDir); } if (Path.GetFullPath(pk.FileName) != Path.GetFullPath(InstalDir + @"\" + Path.GetFileName(pk.FileName))) + if (File.Exists(Path.GetFullPath(pk.FileName))) File.Copy(pk.FileName, InstalDir + @"\" + Path.GetFileName(pk.FileName), true); } + + public void AddRange(MPInstallHelper mpih) + { + foreach (MPpackageStruct pk in mpih.lst) + { + this.Add(pk); + } + } public int IndexOf(MPpackageStruct pk) { Added: trunk/plugins/mpinstaler/MPInstaler/MozBarControl/AssemblyInfo.cs =================================================================== --- trunk/plugins/mpinstaler/MPInstaler/MozBarControl/AssemblyInfo.cs (rev 0) +++ trunk/plugins/mpinstaler/MPInstaler/MozBarControl/AssemblyInfo.cs 2007-07-01 14:58:53 UTC (rev 663) @@ -0,0 +1,58 @@ +using System.Reflection; +using System.Runtime.CompilerServices; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly: AssemblyTitle("MozBar")] +[assembly: AssemblyDescription(".NET Component")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("PABO Software")] +[assembly: AssemblyProduct("")] +[assembly: AssemblyCopyright("Copyright 2005 Patrik Bohman")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly: AssemblyVersion("1.5.1.0")] + +// +// In order to sign your assembly you must specify a key to use. Refer to the +// Microsoft .NET Framework documentation for more information on assembly signing. +// +// Use the attributes below to control which key is used for signing. +// +// Notes: +// (*) If no key is specified, the assembly is not signed. +// (*) KeyName refers to a key that has been installed in the Crypto Service +// Provider (CSP) on your machine. KeyFile refers to a file which contains +// a key. +// (*) If the KeyFile and the KeyName values are both specified, the +// following processing occurs: +// (1) If the KeyName can be found in the CSP, that key is used. +// (2) If the KeyName does not exist and the KeyFile does exist, the key +// in the KeyFile is installed into the CSP and used. +// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility. +// When specifying the KeyFile, the location of the KeyFile should be +// relative to the project output directory which is +// %Project Directory%\obj\<configuration>. For example, if your KeyFile is +// located in the project directory, you would specify the AssemblyKeyFile +// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")] +// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework +// documentation for more information on this. +// +[assembly: AssemblyDelaySign(false)] +[assembly: AssemblyKeyFile("..\\..\\MozBar.snk")] +[assembly: AssemblyKeyName("")] Added: trunk/plugins/mpinstaler/MPInstaler/MozBarControl/ImageListPanel.cs =================================================================== --- trunk/plugins/mpinstaler/MPInstaler/MozBarControl/ImageListPanel.cs (rev 0) +++ trunk/plugins/mpinstaler/MPInstaler/MozBarControl/ImageListPanel.cs 2007-07-01 14:58:53 UTC (rev 663) @@ -0,0 +1,356 @@ +// ImageListPopup by John O'Byrne +// This class pops up window displaying the different images +// contained in an ImageList and allows to select one. +// History: 24/02/2003 : Initial Release +// 25/02/2003 : Added Keyboard support (arrows + space or enter to validate) +// Added Drag'n'Drop Support (disabled by default) - The selected Image +// and its Id are available to the drop target + +using System; +using System.Drawing; +using System.Drawing.Imaging; +using System.Drawing.Drawing2D; +using System.Windows.Forms; +using System.ComponentModel; +using System.Diagnostics; + +namespace CustomUIControls +{ + + #region Delegates + + public delegate void ImageListPanelEventHandler(object sender, ImageListPanelEventArgs ilpea); + + #endregion + + [ToolboxItem(false)] + public class ImageListPanel : System.Windows.Forms.Control + { + + #region Protected Member Variables + protected Bitmap _Bitmap = null; + protected ImageList _imageList = null; + protected int _nBitmapWidth = 0; + protected int _nBitmapHeight = 0; + protected int _nItemWidth = 0; + protected int _nItemHeight = 0; + protected int _nRows = 0; + protected int _nColumns = 0; + protected int _nHSpace = 0; + protected int _nVSpace = 0; + protected int _nCoordX = -1; + protected int _nCoordY = -1; + protected bool _bIsMouseDown = false; + + protected int _defaultImage; + + #endregion + + #region Public Properties + public Color BackgroundColor = Color.FromArgb(255,255,255); + public Color BackgroundOverColor = Color.FromArgb(241,238,231); + public Color HLinesColor = Color.FromArgb(222,222,222); + public Color VLinesColor = Color.FromArgb(165,182,222); + public Color BorderColor = Color.FromArgb(0,16,123); + public bool EnableDragDrop = false; + #endregion + + #region Events + + public event ImageListPanelEventHandler ItemClick = null; + #endregion + + + #region Constructor + public ImageListPanel() + { + + } + #endregion + + #region Public Methods + public bool Init(ImageList imageList, int nHSpace, int nVSpace, int nColumns, int defaultImage) + { + int nRows; + + Brush bgBrush = new SolidBrush(BackgroundColor); + Pen vPen = new Pen(VLinesColor); + Pen hPen = new Pen(HLinesColor); + Pen borderPen = new Pen(BorderColor); + + _imageList = imageList; + _nColumns = nColumns; + + _defaultImage = defaultImage; + if (_defaultImage > _imageList.Images.Count) + _defaultImage = _imageList.Images.Count; + if (_defaultImage < 0) _defaultImage = -1; + + + nRows = imageList.Images.Count / _nColumns; + if (imageList.Images.Count % _nColumns > 0) nRows++; + + _nRows = nRows; + _nHSpace = nHSpace; + _nVSpace = nVSpace; + _nItemWidth = _imageList.ImageSize.Width + nHSpace; + _nItemHeight = _imageList.ImageSize.Height + nVSpace; + _nBitmapWidth = _nColumns * _nItemWidth + 1; + _nBitmapHeight = _nRows * _nItemHeight + 1; + this.Width = _nBitmapWidth; + this.Height = _nBitmapHeight; + + + _Bitmap = new Bitmap(_nBitmapWidth,_nBitmapHeight); + Graphics grfx = Graphics.FromImage(_Bitmap); + grfx.FillRectangle(bgBrush, 0, 0, _nBitmapWidth, _nBitmapHeight); + for (int i=0;i<_nColumns;i++) + grfx.DrawLine(vPen, i*_nItemWidth, 0, i*_nItemWidth, _nBitmapHeight-1); + for (int i=0;i<_nRows;i++) + grfx.DrawLine(hPen, 0, i*_nItemHeight, _nBitmapWidth-1, i*_nItemHeight); + + grfx.DrawRectangle(borderPen, 0 ,0 , _nBitmapWidth-1, _nBitmapHeight-1); + + for (int i=0;i<_nColumns;i++) + for (int j=0;j<_nRows ;j++) + { + if ((j*_nColumns+i) < imageList.Images.Count) + imageList.Draw(grfx, + i*_nItemWidth+_nHSpace/2, + j*_nItemHeight+nVSpace/2, + imageList.ImageSize.Width, + imageList.ImageSize.Height, + j*_nColumns+i); + + } + + /* int a = (_defaultImage / _nColumns); // rad + int b = (_defaultImage % _nColumns); // kolumn; + + _nCoordX = b*(_nItemWidth+_nHSpace/2)-1; + _nCoordY = a*(_nItemHeight+nVSpace/2)-1; + */ + + // Clean up + bgBrush.Dispose(); + vPen.Dispose(); + hPen.Dispose(); + borderPen.Dispose(); + + Invalidate(); + return true; + } + + public void Show(int x, int y) + { + this.Left = x; + this.Top = y; + base.Show(); + } + #endregion + + + #region Overrides + + protected override void OnMouseLeave(EventArgs ea) + { + // We repaint the popup if the mouse is no more over it + base.OnMouseLeave(ea); + _nCoordX = -1; + _nCoordY = -1; + Invalidate(); + } + + /*protected override void OnDeactivate(EventArgs ea) + { + // If the form loses focus, we hide it + this.Hide(); + }*/ + + protected override void OnKeyDown(KeyEventArgs kea) + { + if (_nCoordX==-1 || _nCoordY==-1) + { + _nCoordX = 0; + _nCoordY = 0; + Invalidate(); + } + else + { + switch(kea.KeyCode) + { + case Keys.Down: + if (_nCoordY<_nRows-1) + { + _nCoordY++; + Invalidate(); + } + break; + case Keys.Up: + if (_nCoordY>0) + { + _nCoordY--; + Invalidate(); + } + break; + case Keys.Right: + if (_nCoordX<_nColumns-1) + { + _nCoordX++; + Invalidate(); + } + break; + case Keys.Left: + if (_nCoordX>0) + { + _nCoordX--; + Invalidate(); + } + break; + case Keys.Enter: + case Keys.Space: + // We fire the event only when the mouse is released + int nImageId = _nCoordY*_nColumns + _nCoordX; + if (ItemClick != null && nImageId>=0 && nImageId<_imageList.Images.Count) + { + ItemClick(this, new ImageListPanelEventArgs(nImageId)); + _nCoordX = -1; + _nCoordY = -1; + Hide(); + } + break; + case Keys.Escape: + _nCoordX = -1; + _nCoordY = -1; + Hide(); + break; + } + } + } + + protected override void OnMouseMove(MouseEventArgs mea) + { + // Update the popup only if the image selection has changed + if (ClientRectangle.Contains(new Point(mea.X,mea.Y))) + { + if (EnableDragDrop && _bIsMouseDown) + { + int nImage = _nCoordY*_nColumns+_nCoordX; + if (nImage <=_imageList.Images.Count-1) + { + DataObject data = new DataObject(); + data.SetData(DataFormats.Text,nImage.ToString()); + data.SetData(DataFormats.Bitmap,_imageList.Images[nImage]); + try + { + DragDropEffects dde = DoDragDrop(data, DragDropEffects.Copy | DragDropEffects.Move); + } + catch + { + + } + _bIsMouseDown = false; + } + } + + if ( ((mea.X/_nItemWidth)!=_nCoordX) || ((mea.Y/_nItemHeight)!=_nCoordY) ) + { + _nCoordX = mea.X/_nItemWidth; + _nCoordY = mea.Y/_nItemHeight; + Invalidate(); + } + } + else + { + _nCoordX = -1; + _nCoordY = -1; + Invalidate(); + } + base.OnMouseMove(mea); + } + + protected override void OnMouseDown(MouseEventArgs mea) + { + base.OnMouseDown(mea); + _bIsMouseDown = true; + Invalidate(); + } + + protected override void OnMouseUp(MouseEventArgs mea) + { + base.OnMouseDown(mea); + _bIsMouseDown = false; + + // We fire the event only when the mouse is released + int nImageId = _nCoordY*_nColumns + _nCoordX; + // check that imageID is a valid image + if (ItemClick != null && nImageId>=0 && nImageId<_imageList.Images.Count) + { + ItemClick(this, new ImageListPanelEventArgs(nImageId)); + Hide(); + } + } + + + protected override void OnPaintBackground(PaintEventArgs pea) + { + Graphics grfx = pea.Graphics; + grfx.PageUnit = GraphicsUnit.Pixel; + + // Basic double buffering technique + Bitmap offscreenBitmap = new Bitmap(_nBitmapWidth, _nBitmapHeight); + Graphics offscreenGrfx = Graphics.FromImage(offscreenBitmap); + // We blit the precalculated bitmap on the offscreen Graphics + offscreenGrfx.DrawImage(_Bitmap, 0, 0); + + if (_nCoordX!=-1 && _nCoordY!=-1 && (_nCoordY*_nColumns+_nCoordX)<_imageList.Images.Count) + { + // We draw the selection rectangle + offscreenGrfx.FillRectangle(new SolidBrush(BackgroundOverColor), _nCoordX*_nItemWidth + 1, _nCoordY*_nItemHeight + 1, _nItemWidth-1, _nItemHeight-1); + if (_bIsMouseDown) + { + // Mouse Down aspect for the image + _imageList.Draw(offscreenGrfx, + _nCoordX*_nItemWidth + _nHSpace/2 + 1, + _nCoordY*_nItemHeight + _nVSpace/2 + 1, + _imageList.ImageSize.Width, + _imageList.ImageSize.Height, + _nCoordY*_nColumns + _nCoordX); + } + else + { + // Normal aspect for the image + _imageList.Draw(offscreenGrfx, + _nCoordX*_nItemWidth + _nHSpace/2, + _nCoordY*_nItemHeight + _nVSpace/2, + _imageList.ImageSize.Width, + _imageList.ImageSize.Height, + _nCoordY*_nColumns + _nCoordX); + } + // Border selection Rectangle + offscreenGrfx.DrawRectangle(new Pen(BorderColor), _nCoordX*_nItemWidth, _nCoordY*_nItemHeight, _nItemWidth, _nItemHeight); + } + + // We blit the offscreen image on the screen + grfx.DrawImage(offscreenBitmap, 0, 0); + + // Clean up + offscreenGrfx.Dispose (); + } + #endregion + } + + #region ImageListPanelEventArgs + + public class ImageListPanelEventArgs : EventArgs + { + public int SelectedItem; + + public ImageListPanelEventArgs(int selectedItem) + { + SelectedItem = selectedItem; + } + } + + #endregion +} \ No newline at end of file Added: trunk/plugins/mpinstaler/MPInstaler/MozBarControl/ImageListPanel.resx =================================================================== --- trunk/plugins/mpinstaler/MPInstaler/MozBarControl/ImageListPanel.resx (rev 0) +++ trunk/plugins/mpinstaler/MPInstaler/MozBarControl/ImageListPanel.resx 2007-07-01 14:58:53 UTC (rev 663) @@ -0,0 +1,42 @@ +<?xml version="1.0" encoding="utf-8" ?> +<root> + <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> + <xsd:element name="root" msdata:IsDataSet="true"> + <xsd:complexType> + <xsd:choice maxOccurs="unbounded"> + <xsd:element name="data"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> + <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" /> + <xsd:attribute name="type" type="xsd:string" /> + <xsd:attribute name="mimetype" type="xsd:string" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="resheader"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" use="required" /> + </xsd:complexType> + </xsd:element> + </xsd:choice> + </xsd:complexType> + </xsd:element> + </xsd:schema> + <resheader name="ResMimeType"> + <value>text/microsoft-resx</value> + </resheader> + <resheader name="Version"> + <value>1.0.0.0</value> + </resheader> + <resheader name="Reader"> + <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> + <resheader name="Writer"> + <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> +</root> Added: trunk/plugins/mpinstaler/MPInstaler/MozBarControl/ImageMapEditor.cs =================================================================== --- trunk/plugins/mpinstaler/MPInstaler/MozBarControl/ImageMapEditor.cs (rev 0) +++ trunk/plugins/mpinstaler/MPInstaler/MozBarControl/ImageMapEditor.cs 2007-07-01 14:58:53 UTC (rev 663) @@ -0,0 +1,169 @@ +/* + * Copyright \xA9 2005, Patrik Bohman + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + */ + +using System; +using System.Windows.Forms; +using System.Windows.Forms.Design; +using System.Drawing.Design; +using System.Drawing; +using CustomUIControls; + +namespace Pabo.MozBar +{ + /// <summary> + /// Summary description for ImageEditor. + /// </summary> + public class ImageMapEditor : System.Drawing.Design.UITypeEditor + { + + #region properties + + private IWindowsFormsEditorService wfes = null ; + private int m_selectedIndex = -1 ; + private ImageListPanel m_imagePanel = null ; + + #endregion + + #region constructor + + public ImageMapEditor() + { + + } + + #endregion + + #region Methods + + protected virtual ImageList GetImageList(object component) + { + if (component is MozItem.ImageCollection) + { + return ((MozItem.ImageCollection) component).GetImageList(); + } + + return null ; + } + + #endregion + + #region overrides + + public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, IServiceProvider provider, object value) + { + wfes = (IWindowsFormsEditorService) provider.GetService(typeof(IWindowsFormsEditorService)); + if((wfes == null) || (context == null)) + return null ; + + ImageList imageList = GetImageList(context.Instance) ; + if ((imageList == null) || (imageList.Images.Count==0)) + return -1 ; + + m_imagePanel = new ImageListPanel(); + + m_imagePanel.BackgroundColor = Color.FromArgb(241,241,241); + m_imagePanel.BackgroundOverColor = Color.FromArgb(102,154,204); + m_imagePanel.HLinesColor = Color.FromArgb(182,189,210); + m_imagePanel.VLinesColor = Color.FromArgb(182,189,210); + m_imagePanel.BorderColor = Color.FromArgb(0,0,0); + m_imagePanel.EnableDragDrop = true; + m_imagePanel.Init(imageList,12,12,6,(int)value); + + // add listner for event + m_imagePanel.ItemClick += new ImageListPanelEventHandler(OnItemClicked); + + // set m_selectedIndex to -1 in case the dropdown is closed without selection + m_selectedIndex = -1; + // show the popup as a drop-down + wfes.DropDownControl(m_imagePanel) ; + + // return the selection (or the original value if none selected) + return (m_selectedIndex != -1) ? m_selectedIndex : (int) value ; + } + + public override System.Drawing.Design.UITypeEditorEditStyle GetEditStyle(System.ComponentModel.ITypeDescriptorContext context) + { + if(context != null && context.Instance != null ) + { + return UITypeEditorEditStyle.DropDown ; + } + return base.GetEditStyle (context); + } + + + public override bool GetPaintValueSupported(System.ComponentModel.ITypeDescriptorContext context) + { + return true; + } + + public override void PaintValue(System.Drawing.Design.PaintValueEventArgs pe) + { + int imageIndex = -1 ; + // value is the image index + if(pe.Value != null) + { + try + { + imageIndex = (int)Convert.ToUInt16( pe.Value.ToString() ) ; + } + catch + { + } + } + // no instance, or the instance represents an undefined image + if((pe.Context.Instance == null) || (imageIndex < 0)) + return ; + // get the image set + ImageList imageList = GetImageList(pe.Context.Instance) ; + // make sure everything is valid + if((imageList == null) || (imageList.Images.Count == 0) || (imageIndex >= imageList.Images.Count)) + return ; + // Draw the preview image + pe.Graphics.DrawImage(imageList.Images[imageIndex],pe.Bounds); + } + + #endregion + + #region EventHandlers + + public void OnItemClicked(object sender, ImageListPanelEventArgs e) + { + m_selectedIndex = ((ImageListPanelEventArgs) e).SelectedItem; + + //remove listner + m_imagePanel.ItemClick -= new ImageListPanelEventHandler(OnItemClicked); + + // close the drop-dwon, we are done + wfes.CloseDropDown() ; + + m_imagePanel.Dispose() ; + m_imagePanel = null ; + } + + #endregion + + } +} Added: trunk/plugins/mpinstaler/MPInstaler/MozBarControl/MozBar.csproj =================================================================== --- trunk/plugins/mpinstaler/MPInstaler/MozBarControl/MozBar.csproj (rev 0) +++ trunk/plugins/mpinstaler/MPInstaler/MozBarControl/MozBar.csproj 2007-07-01 14:58:53 UTC (rev 663) @@ -0,0 +1,140 @@ +<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <PropertyGroup> + <ProjectType>Local</ProjectType> + <ProductVersion>8.0.50727</ProductVersion> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{180E4B12-A45B-4091-8A6F-91031C28DA3D}</ProjectGuid> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <ApplicationIcon> + </ApplicationIcon> + <AssemblyKeyContainerName> + </AssemblyKeyContainerName> + <AssemblyName>MozBar</AssemblyName> + <AssemblyOriginatorKeyFile> + </AssemblyOriginatorKeyFile> + <DefaultClientScript>JScript</DefaultClientScript> + <DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout> + <DefaultTargetSchema>IE50</DefaultTargetSchema> + <DelaySign>false</DelaySign> + <OutputType>Library</OutputType> + <RootNamespace>Pabo.MozBar</RootNamespace> + <RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent> + <StartupObject> + </StartupObject> + <FileUpgradeFlags> + </FileUpgradeFlags> + <UpgradeBackupLocation> + </UpgradeBackupLocation> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + <OutputPath>bin\Debug\</OutputPath> + <AllowUnsafeBlocks>false</AllowUnsafeBlocks> + <BaseAddress>285212672</BaseAddress> + <CheckForOverflowUnderflow>false</CheckForOverflowUnderflow> + <ConfigurationOverrideFile> + </ConfigurationOverrideFile> + <DefineConstants>DEBUG;TRACE</DefineConstants> + <DocumentationFile> + </DocumentationFile> + <DebugSymbols>true</DebugSymbols> + <FileAlignment>4096</FileAlignment> + <NoStdLib>false</NoStdLib> + <NoWarn> + </NoWarn> + <Optimize>false</Optimize> + <RegisterForComInterop>false</RegisterForComInterop> + <RemoveIntegerChecks>false</RemoveIntegerChecks> + <TreatWarningsAsErrors>false</TreatWarningsAsErrors> + <WarningLevel>4</WarningLevel> + <DebugType>full</DebugType> + <ErrorReport>prompt</ErrorReport> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + <OutputPath>bin\Release\</OutputPath> + <AllowUnsafeBlocks>false</AllowUnsafeBlocks> + <BaseAddress>285212672</BaseAddress> + <CheckForOverflowUnderflow>false</CheckForOverflowUnderflow> + <ConfigurationOverrideFile> + </ConfigurationOverrideFile> + <DefineConstants>TRACE</DefineConstants> + <DocumentationFile> + </DocumentationFile> + <DebugSymbols>false</DebugSymbols> + <FileAlignment>4096</FileAlignment> + <NoStdLib>false</NoStdLib> + <NoWarn> + </NoWarn> + <Optimize>true</Optimize> + <RegisterForComInterop>false</RegisterForComInterop> + <RemoveIntegerChecks>false</RemoveIntegerChecks> + <TreatWarningsAsErrors>false</TreatWarningsAsErrors> + <WarningLevel>4</WarningLevel> + <DebugType>none</DebugType> + <ErrorReport>prompt</ErrorReport> + </PropertyGroup> + <ItemGroup> + <Reference Include="System"> + <Name>System</Name> + </Reference> + <Reference Include="System.Data"> + <Name>System.Data</Name> + </Reference> + <Reference Include="System.Design"> + <Name>System.Design</Name> + </Reference> + <Reference Include="System.Drawing"> + <Name>System.Drawing</Name> + </Reference> + <Reference Include="System.Windows.Forms"> + <Name>System.Windows.Forms</Name> + </Reference> + <Reference Include="System.Xml"> + <Name>System.XML</Name> + </Reference> + </ItemGroup> + <ItemGroup> + <Compile Include="AssemblyInfo.cs"> + <SubType>Code</SubType> + </Compile> + <Compile Include="ImageListPanel.cs"> + <SubType>Component</SubType> + </Compile> + <Compile Include="ImageMapEditor.cs"> + <SubType>Code</SubType> + </Compile> + <Compile Include="MozItem.cs"> + <SubType>Component</SubType> + </Compile> + <Compile Include="MozPane.cs"> + <SubType>Component</SubType> + </Compile> + <Compile Include="ScrollableControlWithScrollEvents.cs"> + <SubType>Component</SubType> + </Compile> + <Compile Include="ThemeManager.cs"> + <SubType>Code</SubType> + </Compile> + <EmbeddedResource Include="ImageListPanel.resx"> + <DependentUpon>ImageListPanel.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="MozItem.bmp" /> + <EmbeddedResource Include="MozItem.resx"> + <DependentUpon>MozItem.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="MozPane.bmp" /> + <EmbeddedResource Include="MozPane.resx"> + <DependentUpon>MozPane.cs</DependentUpon> + </EmbeddedResource> + <EmbeddedResource Include="ScrollableControlWithScrollEvents.resx"> + <DependentUpon>ScrollableControlWithScrollEvents.cs</DependentUpon> + </EmbeddedResource> + </ItemGroup> + <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> + <PropertyGroup> + <PreBuildEvent> + </PreBuildEvent> + <PostBuildEvent> + </PostBuildEvent> + </PropertyGroup> +</Project> \ No newline at end of file Added: trunk/plugins/mpinstaler/MPInstaler/MozBarControl/MozBar.csproj.user =================================================================== --- trunk/plugins/mpinstaler/MPInstaler/MozBarControl/MozBar.csproj.user (rev 0) +++ trunk/plugins/mpinstaler/MPInstaler/MozBarControl/MozBar.csproj.user 2007-07-01 14:58:53 UTC (rev 663) @@ -0,0 +1,56 @@ +<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <PropertyGroup> + <LastOpenVersion>7.10.3077</LastOpenVersion> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <ReferencePath>E:\Work\Pabo\MozBar\bin\Release\</ReferencePath> + <CopyProjectDestinationFolder> + </CopyProjectDestinationFolder> + <CopyProjectUncPath> + </CopyProjectUncPath> + <CopyProjectOption>0</CopyProjectOption> + <ProjectView>ProjectFiles</ProjectView> + <ProjectTrust>0</ProjectTrust> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + <EnableASPDebugging>false</EnableASPDebugging> + <EnableASPXDebugging>false</EnableASPXDebugging> + <EnableUnmanagedDebugging>false</EnableUnmanagedDebugging> + <EnableSQLServerDebugging>false</EnableSQLServerDebugging> + <RemoteDebugEnabled>false</RemoteDebugEnabled> + <RemoteDebugMachine> + </RemoteDebugMachine> + <StartAction>Project</StartAction> + <StartArguments> + </StartArguments> + <StartPage> + </StartPage> + <StartProgram> + </StartProgram> + <StartURL> + </StartURL> + <StartWorkingDirectory> + </StartWorkingDirectory> + <StartWithIE>true</StartWithIE> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + <EnableASPDebugging>false</EnableASPDebugging> + <EnableASPXDebugging>false</EnableASPXDebugging> + <EnableUnmanagedDebugging>false</EnableUnmanagedDebugging> + <EnableSQLServerDebugging>false</EnableSQLServerDebugging> + <RemoteDebugEnabled>false</RemoteDebugEnabled> + <RemoteDebugMachine> + </RemoteDebugMachine> + <StartAction>Program</StartAction> + <StartArguments> + </StartArguments> + <StartPage> + </StartPage> + <StartProgram>E:\Work\Pabo\Test\Test\bin\Release\Test.exe</StartProgram> + <StartURL> + </StartURL> + <StartWorkingDirectory> + </StartWorkingDirectory> + <StartWithIE>false</StartWithIE> + </PropertyGroup> +</Project> \ No newline at end of file Added: trunk/plugins/mpinstaler/MPInstaler/MozBarControl/MozBar.snk =================================================================== (Binary files differ) Property changes on: trunk/plugins/mpinstaler/MPInstaler/MozBarControl/MozBar.snk ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/plugins/mpinstaler/MPInstaler/MozBarControl/MozItem.bmp =================================================================== (Binary files differ) Property changes on: trunk/plugins/mpinstaler/MPInstaler/MozBarControl/MozItem.bmp ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/plugins/mpinstaler/MPInstaler/MozBarControl/MozItem.cs =================================================================== --- trunk/plugins/mpinstaler/MPInstaler/MozBarControl/MozItem.cs (rev 0) +++ trunk/plugins/mpinstaler/MPInstaler/MozBarControl/MozItem.cs 2007-07-01 14:58:53 UTC (rev 663) @@ -0,0 +1,1546 @@ +/* + * Copyright \xA9 2005, Patrik Bohman + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + */ + +using System; +using System.Collections; +using System.ComponentModel; +using System.Drawing; +using System.Data; +using System.Windows.Forms; +using System.Windows.Forms.Design; + +namespace Pabo.MozBar +{ + + #region Enumerations + public enum MozItemState {Normal = 0, Focus = 1, Selected = 2} + + public enum MozItemStyle {Text = 0, Picture = 1, TextAndPicture = 2, Divider = 3} + public enum MozTextAlign {Bottom = 0, Right = 1, Top = 2, Left = 3} + #endregion + + #region delegates + + public delegate void MozItemEventHandler(object sender, MozItemEventArgs e); + public delegate void MozItemClickEventHandler(object sender, MozItemClickEventArgs e); + public delegate void ImageChangedEventHandler(object sender, ImageChangedEventArgs e); + + #endregion + + /// <summary> + /// Summary description for MozItem. + /// </summary> + + [DesignerAttribute(typeof(MozItemDesigner))] + [ToolboxItem(true)] + [DefaultEvent("Click")] + [ToolboxBitmap(typeof(MozItem),"Pabo.MozBar.MozItem.bmp")] + public class MozItem : System.Windows.Forms.Control + { + + #region EventHandler + + internal event MozItemEventHandler ItemGotFocus; + internal event MozItemEventHandler ItemLostFocus; + internal event MozItemClickEventHandler ItemClick; + internal event MozItemClickEventHandler ItemDoubleClick; + + [Browsable(true)] + [Category("Property Changed")] + [Description("Indicates that the ItemStyle has changed.")] + public event EventHandler ItemStyleChanged; + + [Browsable(true)] + [Category("Property Changed")] + [Description("Indicates that an item image has changed.")] + public event ImageChangedEventHandler ImageChanged; + + [Browsable(true)] + [Category("Property Changed")] + [Description("Indicates that TextAlign has changed.")] + public event EventHandler TextAlignChanged; + + #endregion + + #region private class members + + private MozPane m_mozPane; + private MouseButtons m_mouseButton; + private Image image; + + private ImageCollection m_imageCollection; + + private MozTextAlign m_textAlign; + + private MozItemState m_state; + private MozItemStyle m_itemStyle; + + private System.ComponentModel.Container components = null; + + #endregion + + #region constructor + + public MozItem() + { + // This call is required by the Windows.Forms Form Designer. + InitializeComponent(); + + this.SetStyle(ControlStyles.DoubleBuffer, true); + this.SetStyle(ControlStyles.AllPaintingInWmPaint, true); + this.SetStyle(ControlStyles.UserPaint, true); + this.SetStyle(ControlStyles.ResizeRedraw, true); + this.SetStyle(ControlStyles.SupportsTransparentBackColor, true); + + // TODO: Add any initialization after the InitializeComponent call + + m_imageCollection = new ImageCollection(this); + + image = null; + + m_state = MozItemState.Normal; + + m_itemStyle = MozItemStyle.TextAndPicture; + m_textAlign = MozTextAlign.Bottom; + DoLayout(); + + } + + #endregion + + #region dispose + + /// <summary> + /// Clean up any resources being used. + /// </summary> + protected override void Dispose( bool disposing ) + { + if( disposing ) + { + if(components != null) + { + components.Dispose(); + } + + // Delete images... + if (image!=null) image.Dispose(); + image = null; + m_imageCollection.Dispose(); + + } + base.Dispose( disposing ); + } + + #endregion + + #region Component Designer generated code + /// <summary> + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// </summary> + private void InitializeComponent() + { + + } + #endregion + + + #region Properties + + #region Colors + + private Color SelectedColor + { + get + { + if (m_mozPane!=null) + return m_mozPane.ItemColors.SelectedBackground; + else + return Color.FromArgb(193,210,238); + } + + } + + private Color SelectedBorderColor + { + get + { + if (m_mozPane!=null) + return m_mozPane.ItemColors.SelectedBorder; + else + return Color.FromArgb(49,106,197); + } + } + + private Color SelectedText + { + get + { + if (m_mozPane!=null) + return m_mozPane.ItemColors.SelectedText; + else + return Color.Black; + } + } + + private Color FocusText + { + get + { + if (m_mozPane!=null) + return m_mozPane.ItemColors.FocusText; + else + return Color.Black; + } + } + + private Color FocusColor + { + get + { + if (m_mozPane!=null) + return m_mozPane.ItemColors.FocusBackground; + else + return Color.FromArgb(224,232,246); + } + } + + private Color FocusBorderColor + { + get + { + if (m_mozPane!=null) + return m_mozPane.ItemColors.FocusBorder; + else + return Color.White; + } + } + + private Color TextColor + { + get + { + if (m_mozPane!=null) + return m_mozPane.ItemColors.Text; + else + return Color.Black; + + } + } + + private Color BackgroundColor + { + get + { + if (m_mozPane!=null) + return m_mozPane.ItemColors.Background; + else + return Color.White; + } + } + + private Color BorderColor + { + get + { + if (m_mozPane!=null) + return m_mozPane.ItemColors.Border; + else + return Color.FromArgb(152,180,226); + } + } + + private Color DividerColor + { + get + { + if (m_mozPane!=null) + return m_mozPane.ItemColors.Divider; + else + return Color.FromArgb(127,157,185); + } + } + + #endregion + + #region BorderStyles + + private ButtonBorderStyle SelectedBorderStyle + { + get + { + if (m_mozPane!=null) + return m_mozPane.ItemBorderStyles.Selected; + else + return ButtonBorderStyle.Solid; + } + } + + private ButtonBorderStyle NormalBorderStyle + { + get + { + if (m_mozPane!=null) + return m_mozPane.ItemBorderStyles.Normal; + else + return ButtonBorderStyle.None; + } + } + + private ButtonBorderStyle FocusBorderStyle + { + get + { + if (m_mozPane!=null) + return m_mozPane.ItemBorderStyles.Focus; + else + return ButtonBorderStyle.Solid; + } + } + + + #endregion + + [Browsable(true)] + [Category("Appearance")] + [Description("Images for various states.")] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] + public ImageCollection Images + { + get + { + return m_imageCollection; + } + set + { + if ((value != null) && (value!=m_imageCollection)) + { + m_imageCollection = value; + } + } + } + + [Browsable(true)] + [Category("Appearance")] + [Description("The alignment of the text that will be displayed.")] + [DefaultValue(typeof(MozTextAlign),"Bottom")] + public MozTextAlign TextAlign + { + get + { + return m_textAlign; + } + set + { + if (m_textAlign!=value) + { + m_textAlign = value; + DoLayout(); + if (this.MozPane != null) + { + this.MozPane.DoLayout(); + } + if (this.TextAlignChanged!=null) this.TextAlignChanged(this,new EventArgs()); + + this.Invalidate(); + } + } + } + + public override string Text + { + get + { + return base.Text; + } + set + { + if (value!=base.Text) + { + base.Text = value; + this.DoLayout(); + this.Invalidate(); + } + } + } + + [Browsable(true)] + [Category("Appearance")] + [Description("The visual appearance of the item.")] + [DefaultValue(typeof(MozItemStyle),"TextAndPicture")] + public MozItemStyle ItemStyle + { + get + { + return m_itemStyle; + } + set + { + if (value!=m_itemStyle) + { + m_itemStyle = value; + DoLayout(); + if (this.MozPane != null) + { + this.MozPane.DoLayout(); + } + if (ItemStyleChanged!=null) this.ItemStyleChanged(this,new EventArgs()); + this.Invalidate(); + } + } + } + + // obsolete properties + + [Browsable(false)] + [EditorBrowsable(EditorBrowsableState.Never)] + [ObsoleteAttribute("This property is not supported",true)] + public override Color BackColor + { + get + { + return base.BackColor; + } + set + { + base.BackColor = value; + } + } + + [Browsable(false)] + [EditorBrowsable(EditorBrowsableState.Never)] + [ObsoleteAttribute("This property is not supported",true)] + public override Color ForeColor + { + get + { + return base.ForeColor; + } + set + { + base.ForeColor = value; + } + } + + + + [Browsable(false)] + [EditorBrowsable(EditorBrowsableState.Never)] + [ObsoleteAttribute("This property is not supported",true)] + public override Image BackgroundImage + { + get + { + return base.BackgroundImage; + } + set + { + base.BackgroundImage = value; + } + } + + [Browsable(false)] + [EditorBrowsable(EditorBrowsableState.Never)] + [ObsoleteAttribute("This property is not supported",true)] + public override RightToLeft RightToLeft + { + get + { + return base.RightToLeft; + } + set + { + base.RightToLeft = value; + } + } + + protected internal MozPane MozPane + { + get + { + return this.m_mozPane; + } + + set + { + this.m_mozPane = value; + } + } + + + internal MozItemState state + { + get + { + return m_state; + } + set + { + m_state = value; + Invalidate(); + } + } + + #endregion + + #region methods + + public void DoLayout() + { + int imageHeight; + int imageWidth; + MozPaneStyle mode; + + ImageList list = GetImageList(); + + if (list!=null) + { + imageHeight = list.ImageSize.Height; + imageWidth = list.ImageSize.Width; + } + else + { + imageHeight = 32; + imageWidth = 32; + } + + if (m_mozPane!=null) + mode = m_mozPane.Style; + else + mode = MozPaneStyle.Vertical; + + switch (mode) + { + case MozPaneStyle.Vertical: + { + if (m_mozPane!=null) + { + if (!m_mozPane.IsVerticalScrollBarVisible()) + this.Width = m_mozPane.Width -(2*m_mozPane.Padding.Horizontal); + else + this.Width = m_mozPane.Width -(2*m_mozPane.Padding.Horizontal)-3 - (SystemInformation.VerticalScrollBarWidth-2); + } + else + this.Width = 40; + + switch (m_itemStyle) + { + + case MozItemStyle.Divider: + { + this.Height = 2*4; + break; + } + + case MozItemStyle.Picture: + { + this.Height = imageHeight + (2*4); + break; + } + case MozItemStyle.Text: + { + this.Height = base.Font.Height + (2*4); + break; + } + case MozItemStyle.TextAndPicture: + { + switch (m_textAlign) + { + case MozTextAlign.Bottom: + case MozTextAlign.Top: + { + this.Height = imageHeight + (3*4) + base.Font.Height; + break; + } + case MozTextAlign.Right: + case MozTextAlign.Left: + { + this.Height = imageHeight + (2*4); + break; + } + + } + break; + } + } + break; + } + case MozPaneStyle.Horizontal: + { + if (m_mozPane!=null) + if (!m_mozPane.IsHorizontalScrollBarVisible()) + this.Height = m_mozPane.Height -(2*m_mozPane.Padding.Vertical); + else + this.Height = m_mozPane.Height -(2*m_mozPane.Padding.Vertical)-3 - (SystemInformation.HorizontalScrollBarHeight-2); + + else + this.Height = 40; + + switch (m_itemStyle) + { + case MozItemStyle.Divider: + { + this.Width = 2*4; + break; + } + case MozItemStyle.Picture: + { + this.Width = imageWidth + (2*4); + break; + } + case MozItemStyle.Text: + { + + this.Width = (2*4)+ (int)MeasureString(this.Text); + break; + } + case MozItemStyle.TextAndPicture: + { + switch (m_textAlign) + { + case MozTextAlign.Bottom: + case MozTextAlign.Top: + { + int minWidth = 2 * 4 + imageWidth; + int stringWidth = (2*4)+ (int)MeasureString(this.Text); + if (stringWidth > minWidth) + this.Width = stringWidth; + else + this.Width = minWidth; + break; + } + case MozTextAlign.Right: + case MozTextAlign.Left: + { + this.Width = (3*4)+ (int)MeasureString(this.Text) + imageWidth; + break; + } + + } + break; + } + } + break; + } + } + + } + + private float MeasureString(string str) + { + + SizeF f = new SizeF(); + Graphics g; + g = this.CreateGraphics(); + f = g.MeasureString(str,this.Font); + g.Dispose(); + g = null; + + return f.Width; + } + + public ImageList GetImageList() + { + if (m_mozPane == null) + return null; + else + return m_mozPane.ImageList; + } + + public bool IsSelected() + { + if (m_state == MozItemState.Selected) + return true; + else + return false; + } + + public void SelectItem() + { + if (this.Enabled) + { + if (ItemClick!=null) this.ItemClick(this,new MozItemClickEventArgs(this,MouseButtons.Left)); + Invalidate(); + } + } + + #endregion + + + #region Events + + protected override void OnEnabledChanged(EventArgs e) + { + base.OnEnabledChanged (e); + // Enabled has changed, Invalidate.. + Invalidate(); + } + + protected override void OnFontChanged(EventArgs e) + { + base.OnFontChanged (e); + DoLayout(); + Invalidate(); + } + + protected override void OnSizeChanged(EventArgs e) + { + base.OnSizeChanged (e); + + if (m_mozPane!=null) + { + m_mozPane.DoLayout(); + m_mozPane.Invalidate(); + } + DoLayout(); + Invalidate(); + + } + + protected override void OnMouseEnter(EventArgs e) + { + if (ItemGotFocus != null) this.ItemGotFocus(this,new MozItemEventArgs(this)); + } + + protected override void OnMouseLeave(EventArgs e) + { + if (ItemLostFocus!=null) this.ItemLostFocus(this,new MozItemEventArgs(this)); + } + + protected override void OnMouseDown(MouseEventArgs e) + { + m_mouseButton = e.Button; + if (ItemClick!=null) this.ItemClick(this,new MozItemClickEventArgs(this,m_mouseButton)); + } + + protected override void OnDoubleClick(EventArgs e) + { + if (ItemDoubleClick!=null) this.ItemDoubleClick(this,new MozItemClickEventArgs(this,m_mouseButton)); + } + + protected override void OnClick(EventArgs e) + { + base.OnClick (e); + } + + protected override void OnPaint(PaintEventArgs e) + { + + int imageHeight; + int imageWidth; + int paddingX; + int paddingY; + + + Pen dividerPen = new Pen(this.DividerColor,0); + Brush textBrush = new SolidBrush(this.TextColor); + Brush disabledTextBrush = new SolidBrush(Color.Gray); + Brush bgBrush = new SolidBrush(Color.Black); + Color borderColor = Color.Black; + ButtonBorderStyle btnBorderStyle = ButtonBorderStyle.None; + + // Check if a ImageList exist + ImageList list = GetImageList(); + if (list!=null) + { + // if so get Height and Width + imageHeight = list.ImageSize.Height; + imageWidth = list.ImageSize.Width; + } + else + { + // if not use default values + imageHeight = 32; + imageWidth = 32; + } + + // Check if the item has belongs to a MozPane + if (m_mozPane!=null) + { + // If so get the padding + paddingX = m_mozPane.Padding.Horizontal; + paddingY = m_mozPane.Padding.Vertical; + } + else + { + // use some kind of padding if no daddy is found + paddingX = 1; + paddingY = 1; + } + + Rectangle textRect = new Rectangle(); + Rectangle imageRect = new Rectangle(0,0,imageWidth,imageHeight); + Rectangle borderRect = new Rectangle(); + + StringFormat f = new StringFormat(); + + Point borderLocation = new Point(); + + borderLocation.X = 0; + borderLocation.Y = 0; + + borderRect.Location = borderLocation; + borderRect.Width = this.Width; + borderRect.Height = this.Height; + + // Draw background + e.Graphics.FillRectangle(new SolidBrush(this.BackgroundColor),this.DisplayRectangle); + + // Use Normal image for disabled state + if (!this.Enabled) this.m_state = MozItemState.Normal; + // A divider should not be able to be selected or recieve focus + if (this.ItemStyle == MozItemStyle.Divider) this.m_state = MozItemState.Normal; + + // Check state for item, to decide image + switch (m_state) + { + case MozItemState.Focus: + { + + textBrush = new SolidBrush(this.FocusText); + bgBrush = new SolidBrush(this.FocusColor); + borderColor = this.FocusBorderColor; + btnBorderStyle = this.FocusBorderStyle; + if (m_imageCollection.FocusImage!= null) + image = m_imageCollection.FocusImage; + else + // if focusimage isnt set use Normal image + image = m_imageCollection.NormalImage; + break; + } + case MozItemState.Selected: + { + textBrush = new SolidBrush(this.SelectedText); + bgBrush = new SolidBrush(this.SelectedColor); + borderColor = this.SelectedBorderColor; + btnBorderStyle = this.SelectedBorderStyle; + if (m_imageCollection.SelectedImage!= null) + image = m_imageCollection.SelectedImage; + else + image = m_imageCollection.NormalImage; + break; + } + case MozItemState.Normal: + { + image = m_imageCollection.NormalImage; + bgBrush = new SolidBrush(this.BackgroundColor); + btnBorderStyle = this.NormalBorderStyle; + borderColor = this.BorderColor; + break; + } + } + + e.Graphics.FillRectangle(bgBrush,borderRect); + ControlPaint.DrawBorder(e.Graphics,borderRect,borderColor,btnBorderStyle); + + // check for itemStyle + switch (m_itemStyle) + { + case MozItemStyle.Divider: + { + float ptY; + float ptX; + + if (m_mozPane!=null) + { + // Check MozPane orientation + if (m_mozPane.Style == MozPaneStyle.Vertical) + { + ptY = borderRect.Top + (borderRect.Height / 2); + e.Graphics.DrawLine(dividerPen,borderRect.Left,ptY,borderRect.Right,ptY); + } + else + { + ptX = borderRect.Left + (borderRect.Width / 2); + e.Graphics.DrawLine(dividerPen,ptX,borderRect.Top,ptX,borderRect.Bottom); + } + } + else + { + ptY = borderRect.Top + (borderRect.Height / 2); + e.Graphics.DrawLine(dividerPen,borderRect.Left,ptY,borderRect.Right,ptY); + } + + break; + } + case MozItemStyle.Text: + { + f.Alignment = StringAlignment.Center; + f.LineAlignment = StringAlignment.Center; + textRect = borderRect; + if (m_state == MozItemState.Selected) + { + textRect.X+=1; + textRect.Y+=1; + } + if (this.Enabled) + e.Graphics.DrawString(this.Text,this.Font,textBrush,textRect,f); + else + e.Graphics.DrawString(this.Text,this.Font,disabledTextBrush,textRect,f); + break; + } + case MozItemStyle.Picture: + { + if (image!=null) + { + // center image + imageRect.X = ((borderRect.Width/2) - (imageRect.Width/2)); + imageRect.Y = ((borderRect.Height/2) - (imageRect.Height/2)); + if (m_state == MozItemState.Selected) + { + imageRect.X+=1; + imageRect.Y+=1; + } + + if (this.Enabled) + if (image!=null) + e.Graphics.DrawImage(image,imageRect); + else + if (image!=null) + ControlPaint.D... [truncated message content] |