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 addItemToolStripMenuItem_Click( object sender, EventArgs e ) { TreeNode project = treeView1.SelectedNode; while ( project.Parent != null ) project = project.Parent; 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" ) ); string path = ToRightPath( GetNodePath( treeView1.SelectedNode ) + "code" ); int tab = int.Parse( preferencesWindow.tab_spaces.Text ); File.WriteAllText( path, @"using System; namespace " + fp.txt_name.Text.Replace( ' ', '_' ) + @" { }" ); TreeNode node = new TreeNode( Path.GetFileName( path ) ); node.Tag = path; node.ContextMenuStrip = nodeMenuStrip; treeView1.SelectedNode.Nodes.Add( node ); treeView1.SelectedNode.Expand( ); OpenTab( path ); }
private void runReleaseToolStripMenuItem_Click( object sender, EventArgs e ) { TreeNode project = null; FormProperties fp = default( FormProperties ); 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; } 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" ) ); } if ( File.Exists( Path.Combine( project.Tag as string, "Build\\Release\\" + fp.txt_name.Text + ".exe" ) ) ) { Process.Start( Path.Combine( project.Tag as string, "Build\\Release\\" + fp.txt_name.Text + ".exe" ) ); } }
void SaveTab( FATabStripItem item ) { if ( item.Tag is string ) { FormProperties fp = default( FormProperties ); bool setted = false; TreeNode project=default(TreeNode); foreach ( TreeNode node in treeView1.Nodes ) if ( ( item.Tag as string ).Contains( node.Tag as string ) ) { project = node; break; } foreach ( FATabStripItem item2 in _TabControl1.items ) { if ( item2.Controls[ 0 ] is FormProperties && !setted ) { if ( ( ( ( FormProperties )item2.Controls[ 0 ] ).Path ).StartsWith( project.Tag as string ) ) { fp = ( FormProperties )item2.Controls[ 0 ]; setted = true; break; } } } if ( !setted ) fp = new FormProperties( Path.Combine( project.Tag as string, "projectdata.dat" ) ); if ( !item.Saved ) fp.ver_4.Value += 1; fp.MemoryCore.Save( Path.Combine( project.Tag as string, "projectdata.dat" ) ); try { ( ( FATabStripItem )fp.Parent ).Saved = true; } catch { } string filename = item.Tag as string; if ( File.Exists( filename ) ) File.Delete( filename ); File.WriteAllText( filename, ( ( FastColoredTextBox )item.Controls[ 0 ] ).Text ); item.Saved = true; } else if ( item.Controls[ 0 ] is FormProperties ) { FormProperties properties = ( FormProperties )item.Controls[ 0 ]; properties.MemoryCore.Save( properties.Path ); item.Saved = 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" ); } }