func init // define project name sys.set_project(this.name) // init AssemblyInfo element this.parent.init_managers('AssemblyInfo') if(linked("onError")) this.setfield('ex', 'ex' + this.id) end // initialize properties platform_target = this.props("Platform").value sys.set_typed_field(20, 'AcceptButton') sys.set_typed_field(104, 'AutoScroll') sys.set_typed_field(104, 'AutoSize') sys.set_undef_field_const('AutoSizeMode', this.props('AutoSizeMode'), 'System.Windows.Forms.AutoSizeMode') sys.set_typed_field(20, 'CancelButton') sys.set_typed_field(20, 'ClientSize') sys.set_typed_field(104, 'ControlBox') sys.set_undef_field_const('FormBorderStyle', this.props('FormBorderStyle'), 'System.Windows.Forms.FormBorderStyle') sys.set_typed_field(104, 'HelpButton') // Load icon from application if(isdef("Icon")) blk_init.println('try { this.Icon = (Icon)(typeof(Icon).GetMethod("ExtractAssociatedIcon", BindingFlags.NonPublic | BindingFlags.Static, null, new Type[] { typeof(string), typeof(int) }, null)).Invoke(null, new object[] { Application.ExecutablePath, 0 }); } catch {}') else sys.set_typed_field(6, 'Icon') end sys.set_typed_field(104, 'IsMdiContainer') sys.set_typed_field(104, 'KeyPreview') sys.set_typed_field(20, 'Location') sys.set_typed_field(20, 'MainMenuStrip') sys.set_typed_field(104, 'MaximizeBox') sys.set_typed_field(20, 'MaximumSize') sys.set_typed_field(104, 'MinimizeBox') sys.set_typed_field(20, 'MinimumSize') sys.set_typed_field(7, 'Opacity') sys.set_typed_field(104, 'RightToLeftLayout') sys.set_typed_field(104, 'ShowIcon') sys.set_typed_field(104, 'ShowInTaskbar') sys.set_typed_field(20, 'Size') sys.set_undef_field_const('SizeGripStyle', this.props('SizeGripStyle'), 'System.Windows.Forms.SizeGripStyle') sys.set_undef_field_const('StartPosition', this.props('StartPosition'), 'System.Windows.Forms.FormStartPosition') sys.set_typed_field(104, 'TopMost') sys.set_typed_field(8, 'TransparencyKey') sys.set_undef_field_const('WindowState', this.props('WindowState'), 'System.Windows.Forms.FormWindowState') // makes implementation methods for properties sys._prop_init('AcceptButton', 1, 1, 0) sys._prop_init('ActiveForm', 1, 0, 0, 'Form') sys._prop_init('ActiveMdiChild', 1, 0, 0) sys._prop_init('AutoScale', 1, 1, 104) sys._prop_init('AutoScaleBaseSize', 1, 1, 0) sys._prop_init('AutoScroll', 1, 1, 104) sys._prop_init('AutoSize', 1, 1, 104) sys._prop_init('AutoSizeMode', 1, 1, 0) sys._prop_init('CancelButton', 1, 1, 0) sys._prop_init('ClientSize', 1, 1, 0) sys._prop_init('ControlBox', 1, 1, 104) sys._prop_init('DesktopBounds', 1, 1, 0) sys._prop_init('DesktopLocation', 1, 1, 0) sys._prop_init('DialogResult', 1, 1, 0) sys._prop_init('FormBorderStyle', 1, 1, 0) sys._prop_init('HelpButton', 1, 1, 104) sys._prop_init('Icon', 1, 1, 0) sys._prop_init('IsMdiChild', 1, 0, 104) sys._prop_init('IsMdiContainer', 1, 1, 104) sys._prop_init('KeyPreview', 1, 1, 104) sys._prop_init('Location', 1, 1, 0) sys._prop_init('MainMenuStrip', 1, 1, 0) sys._prop_init('Margin', 1, 1, 0) sys._prop_init('MaximizeBox', 1, 1, 104) sys._prop_init('MaximumSize', 1, 1, 0) sys._prop_init('MdiChildren', 1, 0, 0) sys._prop_init('MdiParent', 1, 1, 0) sys._prop_init('Menu', 1, 1, 0) sys._prop_init('MergedMenu', 1, 0, 0) sys._prop_init('MinimizeBox', 1, 1, 104) sys._prop_init('MinimumSize', 1, 1, 0) sys._prop_init('Modal', 1, 0, 104) sys._prop_init('Opacity', 1, 1, 7) sys._prop_init('OwnedForms', 1, 0, 0) sys._prop_init('Owner', 1, 1, 0) sys._prop_init('RestoreBounds', 1, 0, 0) sys._prop_init('RightToLeftLayout', 1, 1, 104) sys._prop_init('ShowIcon', 1, 1, 104) sys._prop_init('ShowInTaskbar', 1, 1, 104) sys._prop_init('Size', 1, 1, 0) sys._prop_init('SizeGripStyle', 1, 1, 0) sys._prop_init('StartPosition', 1, 1, 0) sys._prop_init('TabIndex', 1, 1, 1) sys._prop_init('TabStop', 1, 1, 104) sys._prop_init('TopLevel', 1, 1, 104) sys._prop_init('TopMost', 1, 1, 104) sys._prop_init('TransparencyKey', 1, 1, 0) sys._prop_init('WindowState', 1, 1, 0) // makes implementation of methods as properties sys._mtd_as_prop_init('ShowDialog()') sys._mtd_as_prop_init('Form') // makes implementation of simple methods sys._method_init('Activate') //sys._method_init('Close') // initialize events sys.add_event_type('onActivated', 'Activated', 'Event', 'args') sys.add_event_type('onAutoSizeChanged', 'AutoSizeChanged', 'Event', 'args') sys.add_event_type('onAutoValidateChanged', 'AutoValidateChanged', 'Event', 'args') sys.add_event_type('onClosed', 'Closed', 'Event', 'args') if(linked('onClosing')) // add using modules sys.add_use('System.ComponentModel') sys.add_event_type('onClosing', 'Closing', 'CancelEvent', 'args') end sys.add_event_type('onDeactivate', 'Deactivate', 'Event', 'args') sys.add_event_type('onFormClosed', 'FormClosed', 'FormClosedEvent', 'args') sys.add_event_type('onFormClosing', 'FormClosing', 'FormClosingEvent', 'args') sys.add_event_type('onHelpButtonClicked', 'HelpButtonClicked', 'CancelEvent', 'args') sys.add_event_type('onInputLanguageChanged', 'InputLanguageChanged', 'InputLanguageChangedEvent', 'args') sys.add_event_type('onInputLanguageChanging', 'InputLanguageChanging', 'InputLanguageChangingEvent', 'args') sys.add_event_type('onLoad', 'Load', 'Event', 'args') sys.add_event_type('onMarginChanged', 'MarginChanged', 'Event', 'args') sys.add_event_type('onMaximizedBoundsChanged', 'MaximizedBoundsChanged', 'Event', 'args') sys.add_event_type('onMaximumSizeChanged', 'MaximumSizeChanged', 'Event', 'args') sys.add_event_type('onMdiChildActivate', 'MdiChildActivate', 'Event', 'args') sys.add_event_type('onMenuComplete', 'MenuComplete', 'Event', 'args') sys.add_event_type('onMenuStart', 'MenuStart', 'Event', 'args') sys.add_event_type('onMinimumSizeChanged', 'MinimumSizeChanged', 'Event', 'args') sys.add_event_type('onResizeBegin', 'ResizeBegin', 'Event', 'args') sys.add_event_type('onResizeEnd', 'ResizeEnd', 'Event', 'args') sys.add_event_type('onRightToLeftLayoutChanged', 'RightToLeftLayoutChanged', 'Event', 'args') sys.add_event_type('onShown', 'Shown', 'Event', 'args') sys.add_event_type('onTabStopChanged', 'TabStopChanged', 'Event', 'args') // initialize common events and properties include("ContainerControl-init") include("ScrollableControl-init") include("Control-init") end func doStart() // add using namespaces sys.add_use('System') sys.add_use('System.Windows.Forms') sys.add_use('System.Drawing') sys.add_use('System.Reflection') if(not isdef("OneInstance")) sys.add_use('System.Threading') end // add common references sys.reference_add('System') sys.reference_add('System.Core') sys.reference_add('System.Xml.Linq') sys.reference_add('System.Data.DataSetExtensions') sys.reference_add('Microsoft.CSharp') sys.reference_add('System.Data') sys.reference_add('System.Deployment') sys.reference_add('System.Drawing') sys.reference_add('System.Windows.Forms') sys.reference_add('System.Xml') event('onCreate') // init all unlinked elements ---------------------------------- this.parent.initall() end func _finally() // create main unit --------------------------------------------- if(linked("onError")) // save original blocks sys.blocks_store() blk.inc() event("onError", this.ex + '.Message') // move blocks to implementation a = block.reggen() if(not blk_lvars.empty()) a.copyhere(blk_lvars) end a.copyhere(blk) // restore original blocks sys.blocks_restore() end b = block.reggen() b.copyhere(blk_using) .println() namespace = 'my' + code(replace(replace(project_name(), "-" , "_"), " " , "_")) b.println('namespace ', namespace) .println('{').inc() if(not blk_struct.empty()) b.copyhere(blk_struct) .println() end b.print('public class MyForm : Form') if(interfaces.size()) b.println(', ' + code(interfaces.join(', '))) else b.println() end b.println('{').inc() .println('private MyForm ', this.codename, ';') if(not blk_fields.empty()) b.copyhere(blk_fields) .println() end b.println('private System.ComponentModel.IContainer components = null;') .copyhere(blk_vars) .println() .println('public MyForm(string[] args) {').inc() .println(this.codename, ' = this;') .println('#region initialize') .println('this.SuspendLayout();') if(this.props("StartPosition").value == 'Manual') b.println('this.DesktopBounds = new Rectangle(', this.props("Left"), ', ', this.props("Top"), ', ', this.props("Width"), ', ', this.props("Height"), ');') elseif(this.props("StartPosition").value != 'WindowsDefaultBounds') b.println('this.Size = new Size(', this.props("Width"), ', ', this.props("Height"), ');') end b.copyhere(blk_init) .println('this.ResumeLayout(false);') .println('this.PerformLayout();') .println('#endregion') .println('#region main body') .copyhere(blk_lvars) .println() .copyhere(blk_body) .println('#endregion') .dec().println('}') .println('protected override void Dispose(bool disposing) {').inc() .println('if (disposing && (components != null)) {').inc() .println('components.Dispose();') .dec().println('}') .println('base.Dispose(disposing);') .dec().println('}') .println('private void addWidget(Control frame, Control ctl, int x, int y, int w, int h) {').inc() .println('ctl.SetBounds(x, y, w, h, BoundsSpecified.All);') .println('frame.Controls.Add(ctl);') .println('ctl.BringToFront();') .dec().println('}') .copyhere(blk_proc_imp) for(i = 0; i < inits.size(); i++) b.copyhere(inits.get(i)) end b.copyhere(blk_attr) .println('[STAThreadAttribute]') .println('static void Main(string[] args) {').inc() .println('if (!Application.CurrentCulture.NumberFormat.NumberDecimalSeparator.Equals(".")) {').inc() .println('System.Globalization.NumberFormatInfo nfi = new System.Globalization.NumberFormatInfo() { NumberDecimalSeparator = "." };') .println('System.Globalization.CultureInfo ci = Application.CurrentCulture.Clone() as System.Globalization.CultureInfo;') .println('ci.NumberFormat = nfi;') .println('Application.CurrentCulture = ci;') .dec().println('}') .println('Application.EnableVisualStyles();') linked("onError") ? b.println('try {').inc() : '' if(not isdef("OneInstance")) b.println('using (Mutex mutex = new Mutex(false, "Global\\\\my', code(project_name()), '")) {').inc() .println('if(!mutex.WaitOne(0, false)) {').inc() .println('MessageBox.Show("Instance already running");') .println('return;') .dec().println('}') .println('Application.Run(new MyForm(args));') .dec().println('}') else b.println('Application.Run(new MyForm(args));') end if(linked("onError")) b.dec().println('} catch (Exception ', this.ex, ') {').inc() .copyhere(a) .dec().println('}') end b.dec().println('}') .dec().println('}') .copyhere(blk_class) .dec().println('}') .println('// Made by HiAsm Studio version ' + version) pname = code(project_name()) fname = pname + '.cs' b.save(fname) // Make Settings if(settings.size()) c = block.reggen() c.println('') .println('').inc() .println('') .println('').inc() .copyhere(blk_settings) .dec().println('') .dec().println('') c.save('Settings.settings') block.delete(c) c = block.reggen() c.println('namespace ', namespace, '.Properties {').inc() .println('[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]') .println('[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")]') .println('internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {').inc() .println('private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));') .println('public static Settings Default {').inc() .println('get {').inc() .println('return defaultInstance;') .dec().println('}') .dec().println('}') .copyhere(blk_settings_designer) .dec().println('}') .dec().println('}') c.save('Settings.Designer.cs') block.delete(c) end // Make manifest if(not isdef("Embed")) c = block.reggen() c.println('') .println('').inc() .println('') .println('').inc() .println('').inc() .println('').inc() .println('') .dec().println('') .dec().println('') .dec().println('') if(not isdef("Compatibility")) c.println('').inc() .println('').inc() if(trace(this.props("Compatibility").value) == 1) c.println('') elseif(this.props("Compatibility").value == 2) c.println('') elseif(this.props("Compatibility").value == 3) c.println('') elseif(this.props("Compatibility").value == 4) c.println('') elseif(this.props("Compatibility").value == 5) c.println('') end c.dec().println('') .dec().println('') end if(not isdef("DpiAware")) c.println('').inc() .println('').inc() .println('true') .dec().println('') .dec().println('') end if(not isdef("Themes")) c.println('').inc() .println('').inc() .println('') .dec().println('') .dec().println('') end c.dec().println('') c.save('app.manifest') block.delete(c) end blk = block.reg("result") blk.println('') .println('').inc() .println('').inc() .println('', this.props("Configuration").value, '') .println('', this.props("Platform").value, '') .println('WinExe') .println('', namespace, '') .println('', pname, '') .println('v', code(this.props("Framework").value), '') .println('') .println('') .println('', this.props("FileAligment").value, '') .dec().println('') // Custom configuration .println('').inc() .println('', this.props("Platform").value, '') b = this.props("Constants").value arr = new array() if(b _and_ 1) arr.add('DEBUG') end if(b _and_ 2) arr.add('TRACE') end blk.println('true') if(not isdef("Symbols")) arr.add(code(this.props("Symbols").value)) end blk.println('', lower(this.props("DebugInfo").value), '') .println('', lower(this.props("Optimize").value), '') if(isdef("OuputPath")) blk.println('', code(project_dir()), '') else blk.println('', code(this.props("OutputPath").value), '') end blk.println('', arr.join(';'), '') .println('', lower(this.props("ErrorReport").value), '') .println('', this.props("WarningLevel").value, '') this.InsertOtherParams() blk.dec().println('') // Debug configuration .println('').inc() .println('', this.props("Platform").value, '') .println('true') arr = new array('DEBUG','TRACE') if(not isdef("Symbols")) arr.add(code(this.props("Symbols").value)) end blk.println('full') .println('false') if(isdef("OuputPath")) blk.println('', code(project_dir()), '') else blk.println('', code(this.props("OutputPath").value), '') end blk.println('', arr.join(';'), '') .println('prompt') .println('4') this.InsertOtherParams() blk.dec().println('') // Release configuration .println('').inc() .println('', this.props("Platform").value, '') .println('true') arr = new array('TRACE') if(not isdef("Symbols")) arr.add(code(this.props("Symbols").value)) end blk.println('pdbonly') .println('true') if(isdef("OuputPath")) blk.println('', code(project_dir()), '') else blk.println('', code(this.props("OutputPath").value), '') end blk.println('', arr.join(';'), '') .println('prompt') .println('4') this.InsertOtherParams() blk.dec().println('') // Build params .println('').inc() .println('', namespace, '.MyForm') .dec().println('') if(not isdef("Embed")) blk.println('').inc() .println('app.manifest') .dec().println('') end blk.println('').inc() .copyhere(blk_refs) .dec().println('') .println('').inc() .println('').inc() .println('Form') .dec().println('') .copyhere(blk_comp) if(settings.size()) blk.println('').inc() .println('True') .println('True') .println('Settings.settings') .dec().println('') end blk.dec().println('') .copyhere(blk_resx) if(settings.size()) blk.println('').inc() .println('').inc() .println('SettingsSingleFileGenerator') .println('Settings.Designer.cs') .dec().println('') .dec().println('') end blk.println('').inc() .println('') .dec().println('') .println('') .dec().println('') end func InsertOtherParams() if(not isdef("Unsafe")) blk.println('', lower(this.props("Unsafe").value), '') end if(not isdef("SuppressWarning")) blk.println('', code(this.props("SuppressWarning").value), '') end if(not isdef("TreatWarnings")) blk.println('true') end if(not isdef("WarningsAsErrors")) blk.println('', code(this.props("WarningsAsErrors").value), '') end blk.println('', lower(this.props("Serialization").value), '') if(not isdef("Language")) blk.println('', code(this.props("Language").value), '') end if(not isdef("CheckOverflow")) blk.println('true') end if(not isdef("NoStdLib")) blk.println('true') end blk.copyhere(blk_prop) .println('true') end func doAddOwnedForm(ownedForm) blk.println(this.codename, '.AddOwnedForm(', d("ownedForm"), ');') end func doClose() blk.println(this.codename, '.Close();') end func doGetAutoScaleSize(font) if(linked("onGetAutoScaleSize")) event("onGetAutoScaleSize", 'Form.GetAutoScaleSize(' + d("font") + ')') else blk.println('Form.GetAutoScaleSize(', d("font"), ');') end end func doLayoutMdi(value) blk.println(this.codename, '.LayoutMdi(', d("value"), ');') end func doRemoveOwnedForm(ownedForm) blk.println(this.codename, '.RemoveOwnedForm(', d("ownedForm"), ');') end func doSetDesktopBounds(x, y, width, height) blk.println(this.codename, '.SetDesktopBounds(', d("x"), ', ', d("y"), ', ', d("width"), ', ', d("height"), ');') end func doSetDesktopLocation(x, y) blk.println(this.codename, '.SetDesktopLocation(', d("x"), ', ', d("y"), ');') end func doShow(ownerWindow) blk.println(this.codename, '.Show(', d("ownerWindow"), ');') end func doShowDialog2(ownerWindow) if(linked("onShowDialog")) event("onShowDialog", this.codename + '.ShowDialog(' + d("ownerWindow") + ')') else blk.println(this.codename, '.ShowDialog(', d("ownerWindow"), ');') end end func Arguments return('args') end include("ContainerControl") include("ScrollableControl") include("Control")