public static Image GetImage( string iconfilename , Data.DataType datatype , string softwaredir ) { String fullpathsoftware = MultiplePathCombine( new String [ ] { Settings.startpath , Settings.iconspath , iconfilename } ); String fullpathicons = MultiplePathCombine( new String [ ] { Settings.startpath , Settings.setupspath , softwaredir , iconfilename } ); if ( iconfilename.Length > 4 ) { if ( iconfilename.Contains( "." ) ) { try { if ( File.Exists( iconfilename ) ) { if ( Path.GetExtension( iconfilename ).ToLower( ) == ".ico" ) { Icon a1 = new Icon( iconfilename ); return ( Image ) a1.ToBitmap( ); } else { return new Bitmap( new Bitmap( iconfilename ) , new Size( 32 , 32 ) ); } } else if ( File.Exists( fullpathsoftware ) ) { if ( Path.GetExtension( fullpathsoftware ).ToLower( ) == ".ico" ) { Icon a1 = new Icon( fullpathsoftware ); return ( Image ) a1.ToBitmap( ); } else { return new Bitmap( new Bitmap( fullpathsoftware ) , new Size( 32 , 32 ) ); } } else if ( File.Exists( fullpathicons ) ) { if ( Path.GetExtension( fullpathicons ).ToLower( ).TrimEnd( ' ' ) == ".ico" ) { Icon a1 = new Icon( fullpathicons ); return ( Image ) a1.ToBitmap( ); } else { return new Bitmap( new Bitmap( fullpathicons ) , new Size( 32 , 32 ) ); } } } catch ( Exception ex ) { Debug.WriteLine( ex.ToString( ) ); } } } return null; }
public Main( ) { try { try { Thread.CurrentThread.CurrentUICulture = Thread.CurrentThread.CurrentCulture; InitializeComponent( ); VersionLabel.Text = Application.ProductVersion; LocalizeControls( mainSplitter ); GetV getv = new GetV( ); getv.OnGetOnlineVersion += new GetV.UserRequest( getv_OnGetOnlineVersion ); getv.Run( ); Settings.startpath = Application.StartupPath; } catch ( SecurityException ) { Settings.fullpermissions = false; } myImageList.ImageSize = new Size( 32 , 32 ); myImageList.ColorDepth = ColorDepth.Depth32Bit; ProgramList.ImageList = myImageList; ProgramList.SelectedImageIndex = 0; SettingsGet( ); this.Text = mysettings.aplicationName; if ( Settings.startpath != null ) Data.filename = Path.Combine( Settings.startpath , InternalRes.BaseFileName ); else Data.filename = InternalRes.BaseFileName; data = new Data( ); data = data.LoadData( ); LoadData( ); settings = new ItemsEditor( ); editItemControls = new Control [ ] { MainMenuItemName, MainMenuDescription, MainMenuDirectoryTextBox, MainMenuVersionTextBox, iconMenuStrip }; } catch ( Exception ex ) { Debug.WriteLine( ex.ToString( ) ); } }
/// <summary> /// /// </summary> private void BrowseIcon( Data.DataType type ) { BrowseIconDialog.Reset( ); if ( type == Data.DataType.SoftwareCategory ) { BrowseIconDialog.InitialDirectory = Utils.MultiplePathCombine( new String [ ] { Settings.startpath , Settings.iconspath } ); if ( !Directory.Exists( BrowseIconDialog.InitialDirectory ) ) { Directory.CreateDirectory( BrowseIconDialog.InitialDirectory ); } } else { String directoryForIcon = Utils.MultiplePathCombine( new String [ ] { Settings.startpath , Settings.setupspath , directoryTexBox.Text } ); if ( directoryTexBox.Text != "" && Directory.Exists( directoryForIcon ) ) { BrowseIconDialog.InitialDirectory = directoryForIcon; } else { BrowseIconDialog.InitialDirectory = Utils.MultiplePathCombine( new String [ ] { Settings.startpath , Settings.setupspath } ); } } { if ( BrowseIconDialog.ShowDialog( ) == DialogResult.OK ) { iconPathTextBox.Text = Path.GetFileName( BrowseIconDialog.FileName ); String Drectory = Path.GetDirectoryName( iconPathTextBox.Text ); AfterIconSelect( BrowseIconDialog.FileName ); } } }
public static Image GetImage( string path , Data.DataType datatype ) { if ( path == null ) return null; return GetImage( path , datatype , "" ); }
public Data LoadData( ) { Data ss1 = new Data( ); FileStream fs = null; try { if ( File.Exists( filename ) ) { // UnknownNode and UnknownAttribute events.*/ XmlSerializer serializer = new XmlSerializer( typeof( Data ) ); serializer.UnknownNode += new XmlNodeEventHandler( serializer_UnknownNode ); serializer.UnknownAttribute += new XmlAttributeEventHandler( serializer_UnknownAttribute ); fs = new FileStream( filename , FileMode.Open ); ss1 = ( Data ) serializer.Deserialize( fs ); fs.Close( ); } /* else { if (Settings.fullpermissions) MessageBox.Show(filename + " Don't exists.", "Critical Error", MessageBoxButtons.OK, MessageBoxIcon.Error); else MessageBox.Show(filename + " Don't exists or user don't have permissions to read this file.", "Critical Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } */ return ss1; } catch ( Exception ex ) { if ( fs != null ) fs.Close( ); Debug.WriteLine( ex.ToString( ) ); if ( File.Exists( filename ) ) { if ( File.Exists( filename + ".bak" ) ) File.Delete( filename + ".bak" ); File.Move( filename , filename + ".bak" ); System.Windows.Forms.Application.Exit( ); } return ss1; } }
internal bool isunic( string newname , Data.DataType type ) { switch ( type ) { case DataType.SoftwareCategory: if ( newname == String.Empty ) return false; foreach ( Category ccat in categories ) { if ( ccat.name == newname ) return false; } break; case DataType.SoftwareItem: if ( newname == String.Empty ) return false; foreach ( Category ccat in categories ) { foreach ( SoftwareItem s in ccat.softwareItem ) if ( s.name == newname ) return false; break; } break; } return true; }
public void SaveData( Data tosave ) { try { if ( Utils.ifFileWriteble( filename ) ) { XmlSerializer serializer = CreateOverrider( ); TextWriter writer = new StreamWriter( filename ); serializer.Serialize( writer , tosave ); writer.Close( ); } else { Debug.WriteLine( FlashAutorun.CreateFileError + " " + filename ); } } catch ( Exception exx ) { Debug.WriteLine( exx.Message ); System.Windows.Forms.Application.Exit( ); } }