/// <summary> /// Refresh the Helm renderer to redraw the content /// </summary> /// <param name="helm"></param> /// <param name="size"></param> public void ResizeRendering() { string script = ""; if (RendererMode != HelmControlMode.BrowserEditor) // all modes except editor { script += "jsd.setSize(" + Browser.Width + "," + Browser.Height + ");"; script += "jsd.refresh();"; // redraws the structure JavaScriptManager.ExecuteScript(this, script); return; } else // editor mode { script += "app.resizeWindow();"; //script += "app.refresh();"; // this seems to be slower than the resizeWindow call above JavaScriptManager.ExecuteScript(this, script); return; } }
/// <summary> /// Store the helm in the Scilligence component and render it /// </summary> /// <param name="helm"></param> /// <param name="size"></param> public void SetHelmAndRender( string helm, Size size = new Size()) { string script = ""; Helm = helm; if (RendererMode != HelmControlMode.BrowserEditor) // all modes except editor { //if (!String.IsNullOrWhiteSpace(helm)) // don't do this check, need to set if blank to clear out existing structure { script += "jsd.setHelm(\"" + helm + "\");"; // var jsd = new JSDraw(...) is JSDraw canvas object JavaScript variable //JavaScriptManager.ExecuteScript(this, script); script = ""; // debug - one command at a time } if (!size.IsEmpty) { script += "jsd.setSize(" + size.Width + "," + size.Height + ");"; //JavaScriptManager.ExecuteScript(this, script); script = ""; // debug - one command at a time } script += "jsd.refresh();"; // redraws the structure JavaScriptManager.ExecuteScript(this, script); return; } else // editor mode { script += // set the helm allowing for blank helm to clear the structure "app.canvas.setHelm(\"" + helm + "\");"; // var app = new scil.helm.App(), app.canvas is JSDraw canvas object //if (!size.IsEmpty) // script += "app.canvas.setSize(" + scaledCanvasWidth + "," + scaledCanvasHeight + ");"; script += "app.canvas.refresh();"; // redraws the structure JavaScriptManager.ExecuteScript(this, script); return; } }
/// <summary> /// Get molfile form of structure /// </summary> /// <param name="outputFormat">molfile, molfile2000 or molfile3000</param> /// <returns></returns> public string GetMolfile( string outputFormat = "molfile") { if (Debug) { DebugLog.Message("GetMolfile Entered" + IdText); } Stopwatch sw = Stopwatch.StartNew(); // Define the JavaScript function to get the molfile for the helm //string script = @" // function getMolfileString() { // var data = { jsdraw: jsd.getXml(), outputformat: 'molfile' }; // var result = scil.Utils.ajaxwait( // call ajax to invoke the service // JSDrawServices.url + '?cmd=jsdraw.helm2mol', // the url and command // data); // the data); i.e. parameters for service call // return result == null ? null : result.output // } //"; //script = script.Replace("<outputFormat>", outputFormat); //JavaScriptManager.ExecuteJavaScript(Browser, script); string molfile = JavaScriptManager.CallFunction(this, "getMolfileString"); // call asynch function to get the molfile string txt = (molfile != null ? molfile.Length.ToString() : "<null>"); if (Debug) { DebugLog.StopwatchMessage("GetMolfileString Complete: " + txt + ", Time: ", sw); } return(molfile); }
/// <summary> /// ExecuteJavaScript /// </summary> /// <param name="script"></param> void ExecuteJavaScript(string script) { LoadInitialPage(); // be sure initial page is loaded JavaScriptManager.ExecuteScript(this, script); return; }