private void VisitRender(HxlRenderWorkElement element) { string parent = stack.Peek(); string slug = GenerateSlug(element); string renderName = NewVariable("_Render" + slug, false, true); string varName = SafeNewVariable(renderName); CurrentOutput.WriteLine("{0} = global::{2}.Create({1});", varName, renderName.TrimStart('_'), typeof(HxlElement).FullName); stack.Push(varName); PushRenderIsland(renderName.TrimStart('_')); element.WritePreLines(CurrentOutput); if (element.ChildNodes.Count > 0) { CurrentOutput.WriteLine(" __self.RenderBody();"); } element.WritePostLines(CurrentOutput); PopRenderIsland(); CurrentOutput.WriteLine("{0}.Append({1});", parent, varName); VisitAll(element.ChildNodes); stack.Pop(); }
private void btnOK_Click(object sender, EventArgs e) { switch (io.GetType().Name) { case "VoltageExcitation": //Get the value of controls VoltageExcitation ve = (VoltageExcitation)io; ve.ExcitationVoltage.Value = this.txtExcitationValue.Value; ve.ExcitationVoltage.Unit = (Voltage.VoltageUnit) this.cboExcitationUnit.SelectedItem; ve.PhaseFrequency.Value = this.txtFreq.Value; ve.PhaseFrequency.Unit = (Frequency.FrequencyUnit) this.cboFreqUnit.SelectedItem; ve.PhaseDelay = this.txtPhase.Value; ve.TimeDelay.Value = this.txtTimeDelay.Value; ve.TimeDelay.Unit = (Time.TimeUnit) this.cboTimeDelayUnit.SelectedItem; ve.Positive = this.cboSignValue.SelectedIndex; break; case "VoltageOutput": //Get the value of controls VoltageOutput vo = (VoltageOutput)io; vo.Positive = this.cboSignValue.SelectedIndex; break; case "CurrentExcitation": //Get the value of controls CurrentExcitation ce = (CurrentExcitation)io; ce.ExcitationCurrent.Value = this.txtExcitationValue.Value; ce.ExcitationCurrent.Unit = (Current.CurrentUnit) this.cboExcitationUnit.SelectedItem; ce.PhaseFrequency.Value = this.txtFreq.Value; ce.PhaseFrequency.Unit = (Frequency.FrequencyUnit) this.cboFreqUnit.SelectedItem; ce.PhaseDelay = this.txtPhase.Value; ce.TimeDelay.Value = this.txtTimeDelay.Value; ce.TimeDelay.Unit = (Time.TimeUnit) this.cboTimeDelayUnit.SelectedItem; ce.Positive = this.cboSignValue.SelectedIndex; break; case "CurrentOutput": //Get the value of controls CurrentOutput co = (CurrentOutput)io; co.Positive = this.cboSignValue.SelectedIndex; break; default: this.Close(); break; } this.Close(); }
private void ClearLiteralCache() { if (literalCache.Length > 0) { CurrentOutput.WriteLine("base.Write(\"{0}\");", literalCache); literalCache.Length = 0; } }
protected override void VisitAttribute(DomAttribute attribute) { string parent = stack.Peek(); CurrentOutput.WriteLine("{0}.Attribute(\"{1}\", \"{2}\");", parent, CodeUtility.Escape(attribute.Name), CodeUtility.Escape(attribute.Value)); }
protected override void VisitText(HxlTextElement element) { // These should have been converted to render islands, BUT there are a few // cases where we want to keep an object: // - parent is retained (easier to work with) // - only writing a space or tab (no need for the overhead) string parent = stack.Peek(); CurrentOutput.WriteLine("{0}.AppendText(\"{1}\");", parent, CodeUtility.Escape(element.Data)); }
protected override void VisitDocumentType(DomDocumentType documentType) { string varName = SafeNewVariable(documentType.Name); CurrentOutput.WriteLine( "{0} = this.__document.CreateDocumentType(\"{1}\", \"{2}\", \"{3}\");", varName, documentType.Name, documentType.PublicId, documentType.SystemId); DoAppend(varName); }
protected override void VisitElement(DomElement element) { string varName = SafeNewVariable(element.Name); CurrentOutput.WriteLine( "{1} = this.__document.CreateElement(\"{0}\");", element.Name, varName); foreach (var m in element.Annotations <IRenderWorkElementCodeBuilder>()) { m.EmitCode(output, varName, element); } DoChildVisit(element, varName); DoAppend(varName); }
private string SafeNewVariable(string suffix, bool isAttr = false) { string result; suffix = CodeUtility.Slug(suffix); if (stack.Count <= 1) { CurrentOutput.WriteLine(); result = NewVariable("root_" + suffix, isAttr); } else { string variable = stack.Peek(); result = NewVariable(string.Format("{0}_{1}", variable, suffix), isAttr); } return(result); }
private void SetupCurrentOutput() { if (m_project != null) { if (m_project.CurrentSelectedObject is GEMSSingle || m_project.CurrentSelectedObject is GeometryOperation) { GEMSSingle targetSingle = null; if (m_project.CurrentSelectedObject is GEMSSingle) { targetSingle = (GEMSSingle)m_project.CurrentSelectedObject; } else { targetSingle = ((GeometryOperation)m_project.CurrentSelectedObject).Parent; } if (targetSingle.CreateOperation is CreateRectangle || targetSingle.CreateOperation is CreateRound) { CurrentOutput co = null; if (targetSingle.CurrentEO is CurrentOutput) { co = targetSingle.CurrentEO as CurrentOutput; } else { co = new CurrentOutput(targetSingle); } ExcitationOutputForm form = new ExcitationOutputForm(co); if (form.ShowDialog() == DialogResult.OK) { targetSingle.CurrentEO = co; targetSingle.SingleDataChangedAlarm(GEMSSingle.SingleDataChangedEventArgs.DataChangeType.EOChanged); } } } } }
protected override void VisitText(DomText text) { string parent = stack.Peek(); CurrentOutput.WriteLine("{0}.AppendText(\"{1}\");", parent, CodeUtility.Escape(text.Data)); }
private void DoAppend(string variable) { CurrentOutput.Write("{0}.Append({1});", stack.Peek(), variable); CurrentOutput.WriteLine(); }
private void ExcitationOutputForm_Load(object sender, EventArgs e) { if (io == null) { this.Close(); } switch (io.GetType().Name) { case "VoltageExcitation": //Initialize the status of the controls this.txtE0.Text = "Excitation"; this.txtIOType.Text = "Voltage"; this.lbExcitationType.Text = "Voltage"; this.cboExcitationUnit.DataSource = Enum.GetValues(typeof(Voltage.VoltageUnit)); this.cboFreqUnit.DataSource = Enum.GetValues(typeof(Frequency.FrequencyUnit)); this.cboTimeDelayUnit.DataSource = Enum.GetValues(typeof(Time.TimeUnit)); UpdateConstrolsVisibleStatus(true); //Bind controls VoltageExcitation ve = (VoltageExcitation)io; this.txtExcitationValue.Value = ve.ExcitationVoltage.Value; this.cboExcitationUnit.SelectedItem = ve.ExcitationVoltage.Unit; this.txtFreq.Value = ve.PhaseFrequency.Value; this.cboFreqUnit.SelectedItem = ve.PhaseFrequency.Unit; this.txtPhase.Value = ve.PhaseDelay; this.txtTimeDelay.Value = ve.TimeDelay.Value; this.cboTimeDelayUnit.SelectedItem = ve.TimeDelay.Unit; this.cboSignValue.SelectedIndex = ve.Positive; this.cboFreqUnit.SelectedIndexChanged += new System.EventHandler(this.cboFreqUnit_SelectedIndexChanged); this.cboTimeDelayUnit.SelectedIndexChanged += new System.EventHandler(this.cboTimeDelayUnit_SelectedIndexChanged); this.txtTimeDelay.TextChanged += new System.EventHandler(this.txtTimeDelay_TextChanged); break; case "VoltageOutput": //Initialize the status of the controls this.txtE0.Text = "Output"; this.txtIOType.Text = "Voltage"; UpdateConstrolsVisibleStatus(false); //Bind controls VoltageOutput vo = (VoltageOutput)io; this.cboSignValue.SelectedIndex = vo.Positive; break; case "CurrentExcitation": //Initialize the status of the controls this.txtE0.Text = "Excitation"; this.txtIOType.Text = "Current"; this.cboExcitationUnit.DataSource = Enum.GetValues(typeof(Current.CurrentUnit)); this.cboFreqUnit.DataSource = Enum.GetValues(typeof(Frequency.FrequencyUnit)); this.cboTimeDelayUnit.DataSource = Enum.GetValues(typeof(Time.TimeUnit)); this.lbExcitationType.Text = "Current"; UpdateConstrolsVisibleStatus(true); //Bind controls CurrentExcitation ce = (CurrentExcitation)io; this.txtExcitationValue.Value = ce.ExcitationCurrent.Value; this.cboExcitationUnit.SelectedItem = ce.ExcitationCurrent.Unit; this.txtFreq.Value = ce.PhaseFrequency.Value; this.cboFreqUnit.SelectedItem = ce.PhaseFrequency.Unit; this.txtPhase.Value = ce.PhaseDelay; this.txtTimeDelay.Value = ce.TimeDelay.Value; this.cboTimeDelayUnit.SelectedItem = ce.TimeDelay.Unit; this.cboSignValue.SelectedIndex = ce.Positive; this.cboFreqUnit.SelectedIndexChanged += new System.EventHandler(this.cboFreqUnit_SelectedIndexChanged); this.cboTimeDelayUnit.SelectedIndexChanged += new System.EventHandler(this.cboTimeDelayUnit_SelectedIndexChanged); this.txtTimeDelay.TextChanged += new System.EventHandler(this.txtTimeDelay_TextChanged); break; case "CurrentOutput": //Initialize the status of the controls this.txtE0.Text = "Output"; this.txtIOType.Text = "Current"; UpdateConstrolsVisibleStatus(false); //Bind controls CurrentOutput co = (CurrentOutput)io; this.cboSignValue.SelectedIndex = co.Positive; break; default: this.Close(); break; } }
protected void EmitCode(string str) { ClearLiteralCache(); CurrentOutput.WriteLine(str); }