Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
97 changes: 94 additions & 3 deletions RdlDesign/FontCtl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ internal class FontCtl : System.Windows.Forms.UserControl, IProperty
private List<XmlNode> _ReportItems;
private DesignXmlDraw _Draw;
private bool fHorzAlign, fFormat, fDirection, fWritingMode, fTextDecoration;
private bool fColor, fVerticalAlign, fFontStyle, fFontWeight, fFontSize, fFontFamily;
private bool fColor, fVerticalAlign, fFontStyle, fFontWeight, fFontSize, fFontFamily, fLineHeight;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.Label label6;
Expand Down Expand Up @@ -57,6 +57,9 @@ internal class FontCtl : System.Windows.Forms.UserControl, IProperty
private System.Windows.Forms.Button bVertical;
private System.Windows.Forms.Button bWrtMode;
private System.Windows.Forms.Button bFormat;
private System.Windows.Forms.Label lblLineHeight;
private System.Windows.Forms.ComboBox cbLineHeight;
private System.Windows.Forms.Button bLineHeight;
/// <summary>
/// Required designer variable.
/// </summary>
Expand All @@ -71,6 +74,9 @@ public FontCtl(DesignXmlDraw dxDraw, string[] names, List<XmlNode> styles)
// This call is required by the Windows.Forms Form Designer.
InitializeComponent();

// Add line height controls programmatically
InitLineHeightControls();

// Initialize form using the style node values
InitTextStyles();
}
Expand Down Expand Up @@ -100,6 +106,7 @@ private void InitTextStyles()
string sFormat="";
string sDirection="LTR";
string sWritingMode="lr-tb";
string sLineHeight="";
foreach (XmlNode lNode in sNode)
{
if (lNode.NodeType != XmlNodeType.Element)
Expand Down Expand Up @@ -139,6 +146,9 @@ private void InitTextStyles()
case "WritingMode":
sWritingMode = lNode.InnerText;
break;
case "LineHeight":
sLineHeight = lNode.InnerText;
break;
}
}

Expand All @@ -159,9 +169,10 @@ private void InitTextStyles()
this.cbFormat.Text = sFormat;
this.cbDirection.Text = sDirection;
this.cbWritingMode.Text = sWritingMode;
this.cbLineHeight.Text = sLineHeight;

fHorzAlign = fFormat = fDirection = fWritingMode = fTextDecoration =
fColor = fVerticalAlign = fFontStyle = fFontWeight = fFontSize = fFontFamily = false;
fColor = fVerticalAlign = fFontStyle = fFontWeight = fFontSize = fFontFamily = fLineHeight = false;

return;
}
Expand All @@ -181,6 +192,47 @@ protected override void Dispose( bool disposing )
base.Dispose( disposing );
}

private void InitLineHeightControls()
{
// Line Height label
lblLineHeight = new System.Windows.Forms.Label();
lblLineHeight.Text = "Line Height";
lblLineHeight.Location = new System.Drawing.Point(16, 222);
lblLineHeight.Size = new System.Drawing.Size(80, 16);
lblLineHeight.TabIndex = 30;
lblLineHeight.Name = "lblLineHeight";

// Line Height combo box
cbLineHeight = new System.Windows.Forms.ComboBox();
cbLineHeight.Location = new System.Drawing.Point(104, 219);
cbLineHeight.Size = new System.Drawing.Size(272, 21);
cbLineHeight.TabIndex = 31;
cbLineHeight.Name = "cbLineHeight";
cbLineHeight.Items.AddRange(new object[] {
"", "8pt", "9pt", "10pt", "11pt", "12pt", "14pt", "16pt", "18pt",
"20pt", "22pt", "24pt", "26pt", "28pt", "36pt", "48pt", "72pt"});
cbLineHeight.TextChanged += new System.EventHandler(this.cbLineHeight_TextChanged);

// Line Height expression button
bLineHeight = new System.Windows.Forms.Button();
bLineHeight.Location = new System.Drawing.Point(384, 222);
bLineHeight.Size = new System.Drawing.Size(22, 16);
bLineHeight.TabIndex = 32;
bLineHeight.Name = "bLineHeight";
bLineHeight.Tag = "lineheight";
bLineHeight.Text = "fx";
bLineHeight.Font = new System.Drawing.Font("Arial", 8.25f, System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Italic);
bLineHeight.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
bLineHeight.Click += new System.EventHandler(this.bExpr_Click);

// Expand the control to fit the new row
this.Size = new System.Drawing.Size(this.Width, this.Height + 26);

this.Controls.Add(lblLineHeight);
this.Controls.Add(cbLineHeight);
this.Controls.Add(bLineHeight);
}

#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
Expand Down Expand Up @@ -573,6 +625,19 @@ public bool IsValid()
}

}
if (fLineHeight && cbLineHeight.Text.Trim().Length > 0)
{
try
{
if (!this.cbLineHeight.Text.Trim().StartsWith("="))
DesignerUtility.ValidateSize(this.cbLineHeight.Text, false, false);
}
catch (Exception e)
{
MessageBox.Show(e.Message, Strings.FontCtl_Show_InvalidLineHeight);
return false;
}
}
return true;
}

Expand All @@ -587,7 +652,7 @@ public void Apply()
ApplyChanges(riNode);

fHorzAlign = fFormat = fDirection = fWritingMode = fTextDecoration =
fColor = fVerticalAlign = fFontStyle = fFontWeight = fFontSize = fFontFamily = false;
fColor = fVerticalAlign = fFontStyle = fFontWeight = fFontSize = fFontFamily = fLineHeight = false;
}

public void ApplyChanges(XmlNode node)
Expand Down Expand Up @@ -639,6 +704,24 @@ public void ApplyChanges(XmlNode node)
_Draw.SetElement(sNode, "Direction", cbDirection.Text);
if (fWritingMode)
_Draw.SetElement(sNode, "WritingMode", cbWritingMode.Text);
if (fLineHeight)
{
if (cbLineHeight.Text.Trim().Length == 0)
_Draw.RemoveElement(sNode, "LineHeight");
else
{
float lh = DesignXmlDraw.GetSize(cbLineHeight.Text);
if (lh <= 0)
lh = DesignXmlDraw.GetSize(cbLineHeight.Text + "pt"); // Try assuming pt
if (lh > 0)
{
string rs = string.Format(NumberFormatInfo.InvariantInfo, "{0:0.#}pt", lh);
_Draw.SetElement(sNode, "LineHeight", rs);
}
else
_Draw.SetElement(sNode, "LineHeight", cbLineHeight.Text); // expression
}
}

return;
}
Expand Down Expand Up @@ -797,6 +880,11 @@ private void cbFormat_TextChanged(object sender, System.EventArgs e)
fFormat = true;
}

private void cbLineHeight_TextChanged(object sender, System.EventArgs e)
{
fLineHeight = true;
}

private void bExpr_Click(object sender, System.EventArgs e)
{
Button b = sender as Button;
Expand Down Expand Up @@ -840,6 +928,9 @@ private void bExpr_Click(object sender, System.EventArgs e)
case "format":
c = cbFormat;
break;
case "lineheight":
c = cbLineHeight;
break;
}

if (c == null)
Expand Down
9 changes: 9 additions & 0 deletions RdlDesign/Resources/Strings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions RdlDesign/Resources/Strings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,9 @@ XML in error:
<data name="FontCtl_Show_InvalidFontSize" xml:space="preserve">
<value>Invalid Font Size</value>
</data>
<data name="FontCtl_Show_InvalidLineHeight" xml:space="preserve">
<value>Invalid Line Height</value>
</data>
<data name="GridCtl_Show_Grid" xml:space="preserve">
<value>Grid</value>
</data>
Expand Down
97 changes: 94 additions & 3 deletions RdlDesign/StyleTextCtl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ internal class StyleTextCtl : System.Windows.Forms.UserControl, IProperty
private DesignXmlDraw _Draw;
private string _DataSetName;
private bool fHorzAlign, fFormat, fDirection, fWritingMode, fTextDecoration;
private bool fColor, fVerticalAlign, fFontStyle, fFontWeight, fFontSize, fFontFamily;
private bool fColor, fVerticalAlign, fFontStyle, fFontWeight, fFontSize, fFontFamily, fLineHeight;
private bool fValue;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label label5;
Expand Down Expand Up @@ -59,6 +59,9 @@ internal class StyleTextCtl : System.Windows.Forms.UserControl, IProperty
private System.Windows.Forms.Button bVertical;
private System.Windows.Forms.Button bWrtMode;
private System.Windows.Forms.Button bFormat;
private System.Windows.Forms.Label lblLineHeight;
private System.Windows.Forms.ComboBox cbLineHeight;
private System.Windows.Forms.Button bLineHeight;
/// <summary>
/// Required designer variable.
/// </summary>
Expand All @@ -71,6 +74,9 @@ internal StyleTextCtl(DesignXmlDraw dxDraw, List<XmlNode> styles, PropertyDialog
// This call is required by the Windows.Forms Form Designer.
InitializeComponent();

// Add line height controls programmatically
InitLineHeightControls();

// Initialize form using the style node values
InitTextStyles();
myDialog.Shown += MyDialog_Shown;
Expand Down Expand Up @@ -149,6 +155,7 @@ private void InitTextStyles()
string sFormat="";
string sDirection="LTR";
string sWritingMode="lr-tb";
string sLineHeight="";
foreach (XmlNode lNode in sNode)
{
if (lNode.NodeType != XmlNodeType.Element)
Expand Down Expand Up @@ -188,6 +195,9 @@ private void InitTextStyles()
case "WritingMode":
sWritingMode = lNode.InnerText;
break;
case "LineHeight":
sLineHeight = lNode.InnerText;
break;
}
}

Expand All @@ -208,10 +218,11 @@ private void InitTextStyles()
this.cbFormat.Text = sFormat;
this.cbDirection.Text = sDirection;
this.cbWritingMode.Text = sWritingMode;
this.cbLineHeight.Text = sLineHeight;

fHorzAlign = fFormat = fDirection = fWritingMode = fTextDecoration =
fColor = fVerticalAlign = fFontStyle = fFontWeight = fFontSize = fFontFamily =
fValue = false;
fLineHeight = fValue = false;

return;
}
Expand All @@ -231,6 +242,47 @@ protected override void Dispose( bool disposing )
base.Dispose( disposing );
}

private void InitLineHeightControls()
{
// Line Height label
lblLineHeight = new System.Windows.Forms.Label();
lblLineHeight.Text = "Line Height";
lblLineHeight.Location = new System.Drawing.Point(16, 263);
lblLineHeight.Size = new System.Drawing.Size(80, 16);
lblLineHeight.TabIndex = 30;
lblLineHeight.Name = "lblLineHeight";

// Line Height combo box
cbLineHeight = new System.Windows.Forms.ComboBox();
cbLineHeight.Location = new System.Drawing.Point(104, 260);
cbLineHeight.Size = new System.Drawing.Size(272, 21);
cbLineHeight.TabIndex = 31;
cbLineHeight.Name = "cbLineHeight";
cbLineHeight.Items.AddRange(new object[] {
"", "8pt", "9pt", "10pt", "11pt", "12pt", "14pt", "16pt", "18pt",
"20pt", "22pt", "24pt", "26pt", "28pt", "36pt", "48pt", "72pt"});
cbLineHeight.TextChanged += new System.EventHandler(this.cbLineHeight_TextChanged);

// Line Height expression button
bLineHeight = new System.Windows.Forms.Button();
bLineHeight.Location = new System.Drawing.Point(384, 263);
bLineHeight.Size = new System.Drawing.Size(22, 16);
bLineHeight.TabIndex = 32;
bLineHeight.Name = "bLineHeight";
bLineHeight.Tag = "lineheight";
bLineHeight.Text = "fx";
bLineHeight.Font = new System.Drawing.Font("Arial", 8.25f, System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Italic);
bLineHeight.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
bLineHeight.Click += new System.EventHandler(this.bExpr_Click);

// Expand the control to fit the new row
this.Size = new System.Drawing.Size(this.Width, this.Height + 30);

this.Controls.Add(lblLineHeight);
this.Controls.Add(cbLineHeight);
this.Controls.Add(bLineHeight);
}

#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
Expand Down Expand Up @@ -670,6 +722,19 @@ public bool IsValid()
}

}
if (fLineHeight && cbLineHeight.Text.Trim().Length > 0)
{
try
{
if (!cbLineHeight.Text.Trim().StartsWith("="))
DesignerUtility.ValidateSize(cbLineHeight.Text, false, false);
}
catch (Exception e)
{
MessageBox.Show(e.Message, Strings.FontCtl_Show_InvalidLineHeight);
return false;
}
}
return true;
}

Expand All @@ -685,7 +750,7 @@ public void Apply()

fHorzAlign = fFormat = fDirection = fWritingMode = fTextDecoration =
fColor = fVerticalAlign = fFontStyle = fFontWeight = fFontSize = fFontFamily =
fValue = false;
fLineHeight = fValue = false;
}

public void ApplyChanges(XmlNode node)
Expand Down Expand Up @@ -741,6 +806,24 @@ public void ApplyChanges(XmlNode node)
_Draw.SetElement(sNode, "Direction", cbDirection.Text);
if (fWritingMode)
_Draw.SetElement(sNode, "WritingMode", cbWritingMode.Text);
if (fLineHeight)
{
if (cbLineHeight.Text.Trim().Length == 0)
_Draw.RemoveElement(sNode, "LineHeight");
else
{
float lh = DesignXmlDraw.GetSize(cbLineHeight.Text);
if (lh <= 0)
lh = DesignXmlDraw.GetSize(cbLineHeight.Text + "pt"); // Try assuming pt
if (lh > 0)
{
string rs = string.Format(NumberFormatInfo.InvariantInfo, "{0:0.#}pt", lh);
_Draw.SetElement(sNode, "LineHeight", rs);
}
else
_Draw.SetElement(sNode, "LineHeight", cbLineHeight.Text); // expression
}
}

return;
}
Expand Down Expand Up @@ -900,6 +983,11 @@ private void cbFormat_TextChanged(object sender, System.EventArgs e)
fFormat = true;
}

private void cbLineHeight_TextChanged(object sender, System.EventArgs e)
{
fLineHeight = true;
}

private void bExpr_Click(object sender, System.EventArgs e)
{
Button b = sender as Button;
Expand Down Expand Up @@ -946,6 +1034,9 @@ private void bExpr_Click(object sender, System.EventArgs e)
case "format":
c = cbFormat;
break;
case "lineheight":
c = cbLineHeight;
break;
}

if (c == null)
Expand Down
Loading