private void button4_Click( object sender, EventArgs e ) { if ( packs.SelectedRows.Count != 0 ) { StreamReader sr = new StreamReader( "pkg.m" ); MemorizePortable MemoryCore = new MemorizePortable( ); while ( !sr.EndOfStream ) { Package package = new Package( ); MemorizePortable package_mem = new MemorizePortable( ); package_mem.AddOwner( package ); package_mem.Load( sr ); MemoryCore.AddOwner( package ); } sr.Close( ); List<DataGridViewRow> lggr = new List<DataGridViewRow>( ); foreach ( DataGridViewRow row in packs.SelectedRows ) { lggr.Add( row ); foreach ( PropertyInfo prop in MemoryCore.lpi ) if ( prop.DeclaringType.Name == "Package" && prop.Name == "ID" ) if ( ( ( string )row.Cells[ 2 ].Value ) == prop.GetGetMethod( ).Invoke( MemoryCore.owners[ MemoryCore.lpi.IndexOf( prop ) ], new object[ 0 ] ).ToString( ) ) { Package _pack = ( Package )MemoryCore.owners[ MemoryCore.lpi.IndexOf( prop ) ]; string str = "pkg\\" + Build.GeneratePlatform( _pack.Platform, _pack.is64X ) + "\\" + _pack.ID; MemoryCore.DeleteOwner( _pack ); try { File.Delete( str + ".a" ); } catch { } try { File.Delete( str + ".obj" ); } catch { } try { Directory.Delete( "src\\pkg\\" + _pack.ID, true ); } catch { } break; } } foreach ( var v in lggr ) packs.Rows.Remove( v ); File.Delete( "pkg.m" ); MemoryCore.Save( "pkg.m" ); } }
private void buildProjectToolStripMenuItem1_Click( object sender, EventArgs e ) { DateTime dt = DateTime.Now; TreeNode project = null; if ( _TabControl1.Items.Count == 0 ) { if ( treeView1.Nodes.Count == 0 ) { MessageBox.Show( this,"To build one you should open a project (See File->Open or File->New)" ); return; } project = treeView1.Nodes[ 0 ]; } else { _TabControl1.Invalidate( ); foreach ( TreeNode node in treeView1.Nodes ) if ( _TabControl1.SelectedItem.Tag is string ) { if ( ( _TabControl1.SelectedItem.Tag as string ).Contains( node.Tag as string ) ) { project = node; break; } } else if ( _TabControl1.SelectedItem.Controls[ 0 ] is FormProperties ) { if ( ( ( ( FormProperties )_TabControl1.SelectedItem.Controls[ 0 ] ).Path ).Contains( node.Tag as string ) ) { project = node; break; } } if ( project == null ) { MessageBox.Show( this,"To build one you should open a project (See File->Open or File->New)" ); return; } FormProperties fp = default( FormProperties ); bool setted = false; foreach ( FATabStripItem item in _TabControl1.items ) { if ( item.Controls[ 0 ] is FormProperties && !setted ) { if ( ( ( ( FormProperties )item.Controls[ 0 ] ).Path ).StartsWith( project.Tag as string ) ) { fp = ( FormProperties )item.Controls[ 0 ]; setted = true; } } SaveTab( item ); } if ( !setted ) fp = new FormProperties( Path.Combine( project.Tag as string, "projectdata.dat" ) ); fp.ver_3.Value += 1; fp.MemoryCore.Save( Path.Combine( project.Tag as string, "projectdata.dat" ) ); try { ( ( FATabStripItem )fp.Parent ).Saved = true; } catch { } } List<TreeNode> ls = new List<TreeNode>( ); ls.Add( project ); BuildResult result = null; FormProperties prop = new FormProperties( Path.Combine( project.Tag as string, "projectdata.dat" ) ); Package package = new Package( ); string cmpdir = "cmpdir"; if ( prop.ProjectType.Text == "Package" ) { package.ID = random.Next( ); cmpdir = "src\\pkg\\" + package.ID; } while ( ls.Count != 0 ) { TreeNode node = ls[ 0 ]; ls.RemoveAt( 0 ); if ( node.Parent == null || node.Tag == null ) { foreach ( TreeNode node2 in node.Nodes ) ls.Add( node2 ); continue; } string path = node.Tag as string; if ( path.EndsWith( ".cs" ) || path.EndsWith( ".go" ) || path.EndsWith( ".c" ) ) File.Copy( Path.GetFileName( path ), path ); else build.AddSource( File.ReadAllText( path ) ); } string bat = Path.GetRandomFileName( ) + ".cmd"; try { ProcessStartInfo psi = new ProcessStartInfo( "cmd", "/C " + bat ); psi.CreateNoWindow = true; psi.UseShellExecute = true; File.WriteAllText( bat, prop.PreBuildText.Text ); Process.Start( psi ).WaitForExit( ); List<String> packages = new List<string>( ); foreach ( DataGridViewRow row in prop.packs.Rows ) { packages.Add( Path.GetFullPath( Path.Combine( "pkg\\" + Build.GeneratePlatform( ( prop.cmb_platform.SelectedIndex == 0 ? Build.Platform.Windows : ( prop.cmb_platform.SelectedIndex == 1 ? Build.Platform.Linux : Build.Platform.Mac ) ), prop.ProjectSet.Text.Contains( "64" ) ), ( string )row.Cells[ 2 ].Value ) + ".obj" ) ); } build.InterpretTo( cmpdir, out result, prop.ProjectType.Text == "Package" , prop.txt_name.Text, package.ID ); if ( result.Type != BuildResultType.None ) { Parser.Source source = new Parser.Source( ); foreach ( Parser.CodeErrorException exception in ( Parser.CodeErrorException[ ] )result.Result ) source.AppendLine( exception.Message ); MessageBox.Show(this, source.Content ); if ( File.Exists( bat ) ) File.Delete( bat ); File.WriteAllText( bat, prop.PostBuildText.Text ); Process.Start( psi ).WaitForExit( ); return; } else { build.Linking( cmpdir, out result, ( int )prop.WarnLvl.Value, prop.WarnAsErr.Checked, prop.ProjectType.Text == "Package", packages, prop.txt_name.Text ); if ( result.Type != BuildResultType.None ) { Parser.Source source = new Parser.Source( ); foreach ( CompilerError error in ( CompilerError[ ] )result.Result ) source.AppendLine( error.ErrorText ); MessageBox.Show(this, source.Content ); if ( File.Exists( bat ) ) File.Delete( bat ); File.WriteAllText( bat, prop.PostBuildText.Text ); Process.Start( psi ).WaitForExit( ); return; } else { build.Analyzing( cmpdir, prop.ProjectType.Text == "Package", prop.txt_name.Text, packages, ( prop.cmb_platform.SelectedIndex == 0 ? Build.Platform.Windows : ( prop.cmb_platform.SelectedIndex == 1 ? Build.Platform.Linux : Build.Platform.Mac ) ), prop.ProjectSet.Text.Contains( "64" ) , cmpdir, package.ID ); string output = build.Compiling( cmpdir, out result, prop.UPXComp.Checked, ( prop.cmb_platform.SelectedIndex == 0 ? Build.Platform.Windows : ( prop.cmb_platform.SelectedIndex == 1 ? Build.Platform.Linux : Build.Platform.Mac ) ), prop.ProjectSet.Text.Contains( "64" ), prop.ProjectType.Text == "Package" ); if ( result.Type != BuildResultType.None ) { Parser.Source source = new Parser.Source( ); foreach ( CompileError error in ( CompileError[ ] )result.Result ) source.AppendLine( error.FullText ); MessageBox.Show(this, source.Content ); if ( File.Exists( bat ) ) File.Delete( bat ); File.WriteAllText( bat, prop.PostBuildText.Text ); Process.Start( psi ).WaitForExit( ); return; } if ( prop.ProjectType.Text == "Package" ) { if ( Directory.Exists( "pkgcmp" ) ) Directory.Delete( "pkgcmp", true ); Directory.CreateDirectory( "pkgcmp" ); var v = new ZipForge( ); v.FileName = Path.GetFullPath( Path.Combine( project.Tag as string, "build\\release\\" + prop.txt_name.Text + ".vpak" ) ); v.OpenArchive( System.IO.FileMode.Create ); v.BaseDir = Path.GetFullPath( cmpdir ); package.Name = prop.txt_name.Text; package.PlatformString = Environment.GetEnvironmentVariable( "GOOS" ) + "_" + Environment.GetEnvironmentVariable( "GOARCH" ); package.Platform = ( prop.cmb_platform.SelectedIndex == 0 ? Build.Platform.Windows : ( prop.cmb_platform.SelectedIndex == 1 ? Build.Platform.Linux : Build.Platform.Mac ) ); package.is64X = prop.ProjectSet.Text.Contains( "64" ); package.DefaultNamespace = prop.txt_namespace.Text; package.Description = prop.txt_description.Text; package.Version = string.Join( ".", new string[ ] { prop.ver_1.Value.ToString( ), prop.ver_2.Value.ToString( ), prop.ver_3.Value.ToString( ), prop.ver_4.Value.ToString( ) } ); MemorizePortable mem = new MemorizePortable( ); mem.AddOwner( package ); mem.Save( Path.Combine( v.BaseDir, "install.dat" ) ); File.Move( output, Path.Combine( v.BaseDir, prop.txt_name.Text + ".a" ) ); foreach ( string file in Directory.GetFiles( v.BaseDir,"*.go" ) ) { string newcode = PackageInstallation.CompressGo( file ); File.Delete( file ); File.WriteAllText( file, newcode ); } v.AddFiles( Path.Combine( v.BaseDir, "*.*" ) ); v.CloseArchive( ); } else { string exe = Path.Combine( project.Tag as string, "build\\release\\" + prop.txt_name.Text + ".exe" ); if ( File.Exists( exe ) ) File.Delete( exe ); File.Move( output, exe ); } } } if ( File.Exists( bat ) ) File.Delete( bat ); File.WriteAllText( bat, prop.PostBuildText.Text ); Process.Start( psi ).WaitForExit( ); MessageBox.Show( this,"Build's time: " + ( DateTime.Now - dt ).TotalMilliseconds ); } finally { File.Delete( bat ); if ( Directory.Exists( "pkgcmp" ) ) Directory.Delete( "pkgcmp", true ); Directory.Delete( cmpdir, true ); } }
private void projectToolStripMenuItem1_Click( object sender, EventArgs e ) { NewProjectResult result = new NewProjectResult( ); new NewProject( result ).ShowDialog( ); if ( !result.Cancelled ) { Directory.CreateDirectory( "projects\\" + result.Name + "\\Source" ); Directory.CreateDirectory( "projects\\" + result.Name + "\\Source-Debug" ); Directory.CreateDirectory( "projects\\" + result.Name + "\\Build\\Debug" ); Directory.CreateDirectory( "projects\\" + result.Name + "\\Build\\Release" ); Directory.CreateDirectory( "projects\\" + result.Name + "\\Data" ); foreach ( string import in result.importfrom ) DirectoryCopy( import, "projects\\" + result.Name ); int tab=int.Parse(preferencesWindow.tab_spaces.Text); File.WriteAllText( "projects\\" + result.Name + "\\Data\\main", @"using System; namespace " + result.Name.Replace( ' ', '_' ) + @" { " + new string( ' ', tab ) + @"class Program { " + new string( ' ', tab * 2 ) + @"static void Main() { " + new string( ' ', tab * 3 ) + @" " + new string( ' ', tab * 2 ) + @"} " + new string( ' ', tab ) + @"} }" ); LoadProject( "projects\\" + result.Name ); FormProperties prop = new FormProperties( "projects\\" + result.Name + "\\projectdata.dat" ); if ( File.Exists( "pkg.m" ) ) { StreamReader reader = new StreamReader( "pkg.m" ); while ( !reader.EndOfStream ) { Package package = new Package( ); MemorizePortable mem = new MemorizePortable( ); mem.AddOwner( package ); mem.Load( reader ); if ( package.Name == "BaseProject" ) { prop.MemoryCore.AddOwner( package ); } } reader.Close( ); } prop.MemoryCore.Save( prop.Path ); FATabStripItem item = new FATabStripItem( ); item.Title = "Properties"; item.Controls.Add( new FormProperties( prop.Path ) ); _TabControl1.Items.Add( _TabControl1.SelectedItem = item ); OpenTab( "projects\\" + result.Name + "\\Data\\main" ); } }
private void button2_Click( object sender, EventArgs e ) { StreamWriter streamWriter = new StreamWriter( Stream.Null ); try { List<Package> packages = new List<Package>( ); MemorizePortable mem; StreamReader SR = new StreamReader( Stream.Null ); try { SR = new StreamReader( "pkg.m" ); while ( !SR.EndOfStream ) { Package package = new Package( ); mem = new MemorizePortable( ); mem.AddOwner( package ); mem.Load( SR ); packages.Add( package ); } } catch { } finally { SR.Close( ); } foreach ( Package pack in packages ) if ( package.ID == pack.ID ) { alertLabel1.Alert( Color.Red, "Package is exists" ); return; } streamWriter = new StreamWriter( "pkg.m", true ); mem = new MemorizePortable( ); mem.AddOwner( package ); File.Move( Directory.GetFiles( pkg, "*.a" )[ 0 ], Path.Combine("pkg\\"+Build.GeneratePlatform(package.Platform,package.is64X),package.ID + ".a") ); if ( Directory.Exists( "src\\pkg\\" + package.ID ) ) Directory.Delete( "src\\pkg\\" + package.ID, true ); Directory.CreateDirectory( "src\\pkg\\" + package.ID ); File.Move( Directory.GetFiles( pkg, "*.obj" )[ 0 ], Path.Combine( "pkg\\" + Build.GeneratePlatform( package.Platform, package.is64X ), package.ID + ".obj" ) ); //foreach ( string file in Directory.GetFiles( pkg, "*.c" ) ) // File.Move( file, "src\\pkg\\" + package.ID + "\\" + Path.GetFileName( file ) ); foreach ( string file in Directory.GetFiles( pkg, "*.go" ) ) File.Move( file, "src\\pkg\\" + package.ID + "\\" + Path.GetFileName( file ) ); foreach ( string file in Directory.GetFiles( pkg, "*.cs" ) ) File.Move( file, "src\\pkg\\" + package.ID + "\\" + Path.GetFileName( file ) ); alertLabel1.Alert( Color.Green, "Package's installation succesfully installed" ); mem.Save( streamWriter ); streamWriter.Close( ); //} catch (Exception ex) { //alertLabel1.Alert( Color.Red, "Unable to install package" ); } finally { streamWriter.Close( ); } }
private void PackageInstallation_Load( object sender, EventArgs e ) { MemorizePortable mem = new MemorizePortable( ); mem.AddOwner( package ); mem.Load( Path.Combine( pkg, "install.dat" ) ); txt_name.Text = package.Name; txt_platform.Text = package.Platform.ToString( ) + " (" + ( package.is64X ? "64x)" : "86x)" ); txt_namespace.Text = package.DefaultNamespace; txt_description.Text = package.Description; txt_version.Text = package.Version; }
private void ChooseReference_Load( object sender, EventArgs e ) { List<Package> packages = new List<Package>( ); MemorizePortable mem; dataGridView1.Rows.Clear( ); try { StreamReader SR = new StreamReader( "pkg.m" ); while ( !SR.EndOfStream ) { Package package = new Package( ); mem = new MemorizePortable( ); mem.AddOwner( package ); mem.Load( SR ); foreach (int id in una) if ( id == package.ID ) { package = null; } if ( package == null ) continue; else { if ( package.Platform != platform || package.is64X != is64x ) continue; } dataGridView1.Rows.Add( false, package.Name, package.Version, package.ID.ToString( ), package.DefaultNamespace ); } SR.Close( ); } catch { } }
private void PackageManager_Load( object sender, EventArgs e ) { MemorizePortable mem; packs.Rows.Clear( ); try { StreamReader SR = new StreamReader( "pkg.m" ); while ( !SR.EndOfStream ) { Package package = new Package( ); mem = new MemorizePortable( ); mem.AddOwner( package ); mem.Load( SR ); packs.Rows.Add( package.Name, package.Version, package.ID.ToString( ), package.DefaultNamespace ); } SR.Close( ); } catch { } }