/// <summary> /// Localizes the specified chart object by adding the specified /// prefix in groupBox2 to the beginning of each localizable string. /// /// Of course, no one would really want to do this, but it /// demonstrates how to modify and localize the strings used in the /// dialogs and property descriptions. /// </summary> /// <param name="objChart"></param> private void localizeChart(object objChart) { // a MemoryStream is used for demo purposes. MemoryStream ChartLocalizationStream = new MemoryStream(); if (objChart is C1Chart) { C1Chart chart = objChart as C1Chart; if (chart.SaveLocalizations(ChartLocalizationStream)) { addPrefixToLocalizations(ChartLocalizationStream); chart.LoadLocalizations(ChartLocalizationStream); } } else if (objChart is C1Chart3D) { C1Chart3D chart = objChart as C1Chart3D; if (chart.SaveLocalizations(ChartLocalizationStream)) { addPrefixToLocalizations(ChartLocalizationStream); chart.LoadLocalizations(ChartLocalizationStream); } } ChartLocalizationStream.Close(); ChartLocalizationStream.Dispose(); }
/// <summary> /// Creates a form and show the localization XML for the specified chart. /// /// The localization XML is saved to a byte array for easy conversion to /// text. Note that the first bytes of the array may be byte encodings. /// /// The form is sizeable. /// </summary> /// <param name="objChart"></param> private void showLocalizations(object objChart) { string title = " string localizations."; byte[] ChartLocalizationBytes = null; if (objChart is C1Chart) { C1Chart chart = objChart as C1Chart; chart.SaveLocalizations(out ChartLocalizationBytes); title = chart.Name + title; } else if (objChart is C1Chart3D) { C1Chart3D chart = objChart as C1Chart3D; chart.SaveLocalizations(out ChartLocalizationBytes); title = chart.Name + title; } else { MessageBox.Show("Object specified is not supported."); return; } string ChartLocalizationString = Encoding.UTF8.GetString(ChartLocalizationBytes); Form frm = new Form(); TextBox tb = new TextBox(); frm.Text = title; frm.Size = this.Size; frm.WindowState = FormWindowState.Normal; frm.FormBorderStyle = FormBorderStyle.Sizable; frm.Controls.Add(tb); tb.Dock = DockStyle.Fill; tb.Multiline = true; tb.ReadOnly = true; tb.ScrollBars = ScrollBars.Both; tb.Text = ChartLocalizationString; tb.SelectionStart = 0; tb.SelectionLength = 0; tb.Visible = true; frm.Show(); }