public BackgroundThread(RunFunction newFunction) { thisFunction = newFunction; Bw = new BackgroundWorker(); Bw.DoWork += new DoWorkEventHandler(Bw_DoWork); Bw.RunWorkerCompleted += new RunWorkerCompletedEventHandler(Bw_RunWorkerCompleted); }
public void BackgroundLoading(RunFunction newFunction) { ThisFunction = newFunction; _processHelper = new BackgroundWorker(); _processHelper.DoWork += new DoWorkEventHandler(_processHelper_DoWork); _processHelper.RunWorkerCompleted += new RunWorkerCompletedEventHandler(_processHelper_RunWorkerCompleted); }
public override int GetHashCode() { int hash = 1; if (Label.Length != 0) { hash ^= Label.GetHashCode(); } if (actionTypeCase_ == ActionTypeOneofCase.OpenLink) { hash ^= OpenLink.GetHashCode(); } if (actionTypeCase_ == ActionTypeOneofCase.RunFunction) { hash ^= RunFunction.GetHashCode(); } hash ^= (int)actionTypeCase_; if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
public static void Run(RunFunction func) { var cb = new CodeBite(func); cb.Run(); }
public PopupButton(string textOn, string textOff, float width, RunFunction function) { buttonText = textOff; buttonTextOn = textOn; buttonTextOff = textOff; isToggleButton = true; buttonWidth = width; genericFunction = function; }
public PopupButton(string text, float width, RunFunction function) { buttonText = text; buttonWidth = width; genericFunction = function; isToggleButton = false; }
public CodeBite(RunFunction func) { _func = RunFuncInternal; _runFunc = func; _exception = null; }
public void CreateCtlFile(string filename) { LogTextOutput?.Invoke(this, "====== .ctl file creation starting ======"); StringBuilder sb = new StringBuilder(); // listing used materials List <MeepMaterialType> materials = new List <MeepMaterialType>(); if (DefaultMaterial != null) { materials.Add(DefaultMaterial); } foreach (MeepGeometricObject obj in Geometry) { if (!materials.Contains(obj.Material)) { materials.Add(obj.Material); } } LogTextOutput?.Invoke(this, " complete -> listing used materials"); // generating code header sb.AppendLine("; ========================================================================"); sb.AppendLine("; == =="); sb.AppendLine("; == This code was generated by MeepManagerForWaveguideDesigner.dll. =="); sb.AppendLine("; == =="); sb.AppendLine("; ========================================================================"); sb.AppendLine(); LogTextOutput?.Invoke(this, " complete -> generating code header"); // generating material definitions as variables foreach (MeepMaterialType material in materials) { sb.AppendLine(string.Format("(define {0} {1}) ", material.Name, material)); } sb.AppendLine(); LogTextOutput?.Invoke(this, " complete -> generating material definitions as variables"); // setting default-material if (DefaultMaterial != null) { sb.AppendLine(string.Format("(set! default-material {0}) ", DefaultMaterial.Name)); sb.AppendLine(); } LogTextOutput?.Invoke(this, " complete -> setting default-material"); // setting geometry-lattice if (GeometricLattice != null) { sb.AppendLine(string.Format("(set! geometry-lattice {0}) ", GeometricLattice)); sb.AppendLine(); } LogTextOutput?.Invoke(this, " complete -> setting geometry-lattice"); // setting geometry if (Geometry.Count != 0) { sb.Append("(set! geometry "); if (GlobalShift != MeepVector3.Zero) { sb.Append(string.Format("(geometric-objects-duplicates {0} 1 1 ", GlobalShift)); } sb.Append("(list "); foreach (MeepGeometricObject obj in Geometry) // all geometric objects constructor { sb.Append(obj.ToString() + " "); } sb.Append(")"); // (list closer if (GlobalShift != MeepVector3.Zero) { sb.Append(")"); // (geometric-objects-duplicates closer } sb.AppendLine(") "); // (set! closer sb.AppendLine(); } LogTextOutput?.Invoke(this, " complete -> setting geometry"); // setting pml-layers if (PmlLayers.Count != 0) { sb.Append("(set! pml-layers (list "); foreach (MeepPml pml in PmlLayers) { sb.Append(pml.ToString() + " "); } sb.AppendLine(")) "); sb.AppendLine(); } LogTextOutput?.Invoke(this, " complete -> setting pml-layers"); // setting resolution if (Resolution != 10) { sb.AppendLine(string.Format("(set! resolution {0}) ", Resolution)); sb.AppendLine(); } LogTextOutput?.Invoke(this, " complete -> setting resolution"); // setting sources if (Sources.Count != 0) { sb.Append("(set! sources (list "); foreach (MeepSource src in Sources) { sb.Append(src.ToString() + " "); } sb.AppendLine(")) "); sb.AppendLine(); } LogTextOutput?.Invoke(this, " complete -> setting sources"); // definition of fluxes foreach (MeepFlux flux in FluxAnalyses) { sb.AppendLine(flux.ToString() + " "); } sb.AppendLine(); LogTextOutput?.Invoke(this, " complete -> definition of fluxes"); // setting run function if (RunFunction != null) { sb.AppendLine(RunFunction.ToString() + " "); } sb.AppendLine(); LogTextOutput?.Invoke(this, " complete -> setting run function"); // generating output fluxes foreach (MeepFlux flux in FluxAnalyses) { sb.AppendLine(flux.ToString(MeepFlux.CodeType.SaveFlux) + " "); } sb.AppendLine(); LogTextOutput?.Invoke(this, " complete -> generating output fluxes"); using (StreamWriter sw = new StreamWriter(filename)) { try { sw.WriteLine(sb.ToString()); } catch (Exception e) { throw e; } } LogTextOutput?.Invoke(this, " complete -> writing in .ctl file"); LogTextOutput?.Invoke(this, "====== .ctl file creation completed ======"); }
void Add(string cmd, string help, RunFunction func) { cmdhelp[cmd] = help; cmdfunc[cmd] = func; }