本文整理汇总了C#中ITextProvider.GetString方法的典型用法代码示例。如果您正苦于以下问题:C# ITextProvider.GetString方法的具体用法?C# ITextProvider.GetString怎么用?C# ITextProvider.GetString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITextProvider
的用法示例。
在下文中一共展示了ITextProvider.GetString方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ClearUndoTooltips
public ClearUndoTooltips(ZenGradientButton button, bool isClear, ITextProvider tprov, int needleHeight)
{
this.isClear = isClear;
this.button = button;
this.needleHeight = needleHeight;
if (isClear) text = tprov.GetString("WritingPadClearTooltip");
else text = tprov.GetString("WritingPadUndoTooltip");
}
示例2: SearchInputControl
/// <summary>
/// Ctor: take parent etc.
/// </summary>
public SearchInputControl(ZenControl owner, ITextProvider tprov)
: base(owner)
{
this.tprov = tprov;
padding = (int)Math.Round(4.0F * Scale);
// The hinted text input control.
txtInput = new HintedTextBox();
txtInput.Name = "txtInput";
txtInput.TabIndex = 0;
txtInput.BorderStyle = BorderStyle.None;
RegisterWinFormsControl(txtInput);
// My font family, and other properties to achieve a borderless inside input field.
txtInput.Font = (SystemFontProvider.Instance as ZydeoSystemFontProvider).GetZhoButtonFont(
FontStyle.Regular, 16F);
txtInput.AutoSize = false;
txtInput.Height = txtInput.PreferredHeight + padding;
txtInput.HintText = tprov.GetString("SearchTextHint");
// My height depends on text box's height at current font settings.
blockSizeChanged = true;
Height = 2 + txtInput.Height;
blockSizeChanged = false;
txtInput.KeyPress += onTextBoxKeyPress;
// Search button
Assembly a = Assembly.GetExecutingAssembly();
var imgSearch = Image.FromStream(a.GetManifestResourceStream("ZD.Gui.Resources.search.png"));
btnSearch = new ZenImageButton(this);
btnSearch.RelLocation = new Point(padding, padding);
btnSearch.Size = new Size(Height - 2 * padding, Height - 2 * padding);
btnSearch.Image = imgSearch;
btnSearch.MouseClick += onClickSearch;
// Clear text button.
var imgCancel = Image.FromStream(a.GetManifestResourceStream("ZD.Gui.Resources.cancel.png"));
btnCancel = new ZenImageButton(this);
btnCancel.Size = new Size(Height - 2 * padding, Height - 2 * padding);
btnCancel.Padding = padding; // We want the X to be somewhat smaller
btnCancel.RelLocation = new Point(Width - padding - btnCancel.Width, padding);
btnCancel.Image = imgCancel;
btnCancel.Visible = false;
btnCancel.MouseClick += onClickCancel;
txtInput.MouseEnter += onTxtMouseEnter;
txtInput.MouseLeave += onTxtMouseLeave;
txtInput.MouseMove += onTxtMouseMove;
txtInput.TextChanged += onTxtTextChanged;
}
示例3: MainForm
/// <summary>
/// Ctor: initializes main form.
/// </summary>
public MainForm(ICedictEngineFactory dictFact, ITextProvider tprov)
: base(tprov)
{
this.tprov = tprov;
// Initialize hanzi renderer
// -- Scale (DPI)
// -- Available systems fonts
HanziRenderer.Scale = Scale;
if (HanziRenderer.IsWinKaiAvailable()) Magic.SetZhoContentFontFamily(IdeoFamily.WinKai);
else Magic.SetZhoContentFontFamily(IdeoFamily.ArphicKai);
// Initialize system font provider with our own
if (SystemFontProvider.Instance as ZydeoSystemFontProvider == null)
SystemFontProvider.Instance = new ZydeoSystemFontProvider();
// Find out last window size and location from settings
Size size = AppSettings.WindowLogicalSize;
Point loc = AppSettings.WindowLoc;
ignoredSavedSizeAndLocation = !verifySizeAndLoc(size, loc);
// If location+size do not make sense, let system position window, and go with default size.
if (ignoredSavedSizeAndLocation)
{
WinForm.StartPosition = FormStartPosition.WindowsDefaultLocation;
LogicalSize = Magic.WinDefaultLogicalSize;
}
// Otherwise, position at last location
else
{
WinForm.StartPosition = FormStartPosition.Manual;
Location = loc;
LogicalSize = size;
}
// Set (logical) minimum size
LogicalMinimumSize = Magic.WinMinimumLogicalSize;
Header = tprov.GetString("WinHeader");
lc = new LookupControl(this, dictFact, tprov);
stgs = new SettingsControl(this, tprov, dictFact);
MainTab = new ZenTab(stgs, tprov.GetString("TabMain"));
Tabs.Add(new ZenTab(lc, tprov.GetString("TabLookup")));
}
示例4: LookupControl
/// <summary>
/// Ctor.
/// </summary>
public LookupControl(ZenControlBase owner, ICedictEngineFactory dictFact, ITextProvider tprov)
: base(owner)
{
this.dictFact = dictFact;
this.tprov = tprov;
padding = (int)Math.Round(5.0F * Scale);
// Init search language and script from user settings
searchLang = AppSettings.SearchLang;
searchScript = AppSettings.SearchScript;
// Init HanziLookup
fsStrokes = new FileStream(Magic.StrokesFileName, FileMode.Open, FileAccess.Read);
brStrokes = new BinaryReader(fsStrokes);
strokesData = new StrokesDataSource(brStrokes);
// Writing pad
writingPad = new WritingPad(this, tprov);
writingPad.RelLocation = new Point(padding, padding);
writingPad.LogicalSize = new Size(200, 200);
writingPad.StrokesChanged += writingPad_StrokesChanged;
// Images for buttons under writing pad; will get owned by buttons, not that it matters.
Assembly a = Assembly.GetExecutingAssembly();
var imgStrokesClear = Image.FromStream(a.GetManifestResourceStream("ZD.Gui.Resources.strokes-clear.png"));
var imgStrokesUndo = Image.FromStream(a.GetManifestResourceStream("ZD.Gui.Resources.strokes-undo.png"));
// Clear and undo buttons under writing pad.
float leftBtnWidth = writingPad.Width / 2 + 1;
float btnHeight = 22.0F * Scale;
// --
btnClearWritingPad = new ZenGradientButton(this);
btnClearWritingPad.RelLocation = new Point(writingPad.RelLeft, writingPad.RelBottom - 1);
btnClearWritingPad.Size = new Size((int)leftBtnWidth, (int)btnHeight);
btnClearWritingPad.Text = tprov.GetString("WritingPadClear");
btnClearWritingPad.SetFont(SystemFontProvider.Instance.GetSystemFont(FontStyle.Regular, 9.0F));
btnClearWritingPad.Padding = (int)(3.0F * Scale);
btnClearWritingPad.ImageExtraPadding = (int)(3.0F * Scale);
btnClearWritingPad.Image = imgStrokesClear;
btnClearWritingPad.Enabled = false;
btnClearWritingPad.MouseClick += onClearWritingPad;
// --
btnUndoStroke = new ZenGradientButton(this);
btnUndoStroke.RelLocation = new Point(btnClearWritingPad.RelRight - 1, writingPad.RelBottom - 1);
btnUndoStroke.Size = new Size(writingPad.RelRight - btnUndoStroke.RelLeft, (int)btnHeight);
btnUndoStroke.Text = tprov.GetString("WritingPadUndo");
btnUndoStroke.SetFont(SystemFontProvider.Instance.GetSystemFont(FontStyle.Regular, 9.0F));
btnUndoStroke.Padding = (int)(3.0F * Scale);
btnUndoStroke.ImageExtraPadding = (int)(1.5F * Scale);
btnUndoStroke.Image = imgStrokesUndo;
btnUndoStroke.Enabled = false;
btnUndoStroke.MouseClick += onUndoStroke;
// --
btnClearWritingPad.Tooltip = new ClearUndoTooltips(btnClearWritingPad, true, tprov, padding);
btnUndoStroke.Tooltip = new ClearUndoTooltips(btnUndoStroke, false, tprov, padding);
// --
// Character picker control under writing pad.
ctrlCharPicker = new CharPicker(this, tprov);
ctrlCharPicker.FontFam = Magic.ZhoContentFontFamily;
ctrlCharPicker.FontScript = searchScript == SearchScript.Traditional ? IdeoScript.Trad : IdeoScript.Simp;
ctrlCharPicker.RelLocation = new Point(padding, btnClearWritingPad.RelBottom + padding);
ctrlCharPicker.LogicalSize = new Size(200, 80);
ctrlCharPicker.CharPicked += onCharPicked;
// Search input control at top
ctrlSearchInput = new SearchInputControl(this, tprov);
ctrlSearchInput.RelLocation = new Point(writingPad.RelRight + padding, padding);
ctrlSearchInput.StartSearch += onStartSearch;
// Tweaks for Chinese text on UI buttons
// This is specific to Segoe UI and Noto Sans S Chinese fonts.
float ofsZho = 0;
//if (!(SystemFontProvider.Instance as ZydeoSystemFontProvider).SegoeExists)
// ofsZho = Magic.ZhoButtonFontSize * Scale / 3.7F;
// Script selector button to the right of search input control
btnSimpTrad = new ZenGradientButton(this);
btnSimpTrad.RelTop = padding;
btnSimpTrad.Height = ctrlSearchInput.Height;
btnSimpTrad.SetFont((SystemFontProvider.Instance as ZydeoSystemFontProvider).GetZhoButtonFont(
FontStyle.Regular, Magic.ZhoButtonFontSize));
btnSimpTrad.Width = getSimpTradWidth();
btnSimpTrad.ForcedCharVertOfs = ofsZho;
btnSimpTrad.RelLeft = Width - padding - btnSimpTrad.Width;
btnSimpTrad.Height = ctrlSearchInput.Height;
btnSimpTrad.MouseClick += onSimpTrad;
// Search language selector to the right of search input control
btnSearchLang = new ZenGradientButton(this);
btnSearchLang.RelTop = padding;
btnSearchLang.Height = ctrlSearchInput.Height;
btnSearchLang.SetFont((SystemFontProvider.Instance as ZydeoSystemFontProvider).GetZhoButtonFont(
FontStyle.Regular, Magic.ZhoButtonFontSize));
btnSearchLang.Width = getSearchLangWidth();
btnSearchLang.ForcedCharVertOfs = ofsZho;
btnSearchLang.RelLeft = btnSimpTrad.RelLeft - padding - btnSearchLang.Width;
//.........这里部分代码省略.........
示例5: ResultsCtxtControl
/// <summary>
/// Ctor: init.
/// </summary>
/// <param name="cmdTriggered">Delegate that will be called when a command is issued.</param>
/// <param name="entry">Cedict entry to fetch clipboard data from.</param>
/// <param name="senseIX">Index of sense over which user right-clicked, or -1.</param>
/// <param name="script">Search script (so two Hanzi items are shown if needed).</param>
public ResultsCtxtControl(CommandTriggeredDelegate cmdTriggered, ITextProvider tprov,
CedictEntry entry,
int senseIx,
SearchScript script)
{
this.cmdTriggered = cmdTriggered;
this.tprov = tprov;
this.entry = entry;
this.senseIx = senseIx;
this.script = script;
InitializeComponent();
BackColor = ZenParams.BorderColor;
pnlTop.BackColor = ZenParams.WindowColor;
tblFull.BackColor = ZenParams.WindowColor;
tblZho.BackColor = ZenParams.WindowColor;
tblSense.BackColor = ZenParams.WindowColor;
// Display strings
string title = tprov.GetString("CtxtCopyTitle");
string fullFormatted, fullCedict, hanzi1, hanzi2, pinyin, sense;
getDisplayStrings(tprov, senseIx, out fullFormatted, out fullCedict,
out hanzi1, out hanzi2, out pinyin, out sense);
lblFullFormatted.Text = fullFormatted;
lblFullCedict.Text = fullCedict;
lblHanzi1.Text = hanzi1;
lblHanzi2.Text = hanzi2;
lblPinyin.Text = pinyin;
lblSense.Text = sense;
// Margin/border tweaks: 1px also at higher DPIs
tblLayout.Location = new Point(1, 1);
pnlTop.Margin = new Padding(0, 0, 0, 1);
tblLayout.RowStyles[1].Height = pnlTop.Height + 1;
tblFull.Margin = new Padding(0, 0, 0, 1);
tblLayout.RowStyles[1].Height = tblFull.Height + 1;
tblZho.Margin = new Padding(0, 0, 0, 1);
tblLayout.RowStyles[2].Height = tblZho.Height + 1;
tblSense.Margin = new Padding(0, 0, 0, 0);
tblLayout.RowStyles[3].Height = tblSense.Height;
tblLayout.Height = tblSense.Bottom;
// Hide rows we don't need: second hanzi
if (hanzi2 == null)
{
int hHanzi2 = lblHanzi2.Height;
tblZho.Controls.Remove(lblHanzi2);
lblPinyin.Top = lblHanzi2.Top;
lblHanzi2.Dispose();
lblHanzi2 = null;
tblZho.Controls.Remove(lblPinyin);
tblZho.Controls.Add(lblPinyin, 0, 2);
tblZho.RowCount -= 1;
tblZho.RowStyles.RemoveAt(2);
tblZho.Height -= hHanzi2;
tblLayout.RowStyles[2].Height -= hHanzi2;
tblLayout.Height -= hHanzi2;
}
// Sense
if (sense == null)
{
int hSense = tblSense.Height;
tblLayout.Controls.Remove(tblSense);
tblSense.Dispose();
tblSense = null;
tblLayout.RowStyles.RemoveAt(tblLayout.RowStyles.Count - 1);
tblLayout.RowCount -= 1;
tblLayout.Height -= hSense + 1;
}
// Label collection for hover
int lblCount = 6;
if (lblHanzi2 == null) --lblCount;
if (lblSense == null) --lblCount;
lblColl = new Label[lblCount];
lblColl[0] = lblFullFormatted;
lblColl[1] = lblFullCedict;
lblColl[2] = lblHanzi1;
int ix = 3;
if (lblHanzi2 != null) { lblColl[ix] = lblHanzi2; ++ix; }
lblColl[ix] = lblPinyin; ++ix;
if (lblSense != null) { lblColl[ix] = lblSense; ++ix; }
// Event handling for hover
tblFull.CellPaint += onTblLayoutCellPaint;
tblZho.CellPaint += onTblLayoutCellPaint;
if (tblSense != null) tblSense.CellPaint += onTblLayoutCellPaint;
}
示例6: getDisplayStrings
/// <summary>
/// Gets display strings by combining entry, sense index, and localized strings.
/// </summary>
private void getDisplayStrings(ITextProvider tprov, int senseIx,
out string fullFormatted, out string fullCedict,
out string hanzi1, out string hanzi2, out string pinyin, out string sense)
{
fullFormatted = tprov.GetString("CtxtCopyEntryFormatted");
fullCedict = tprov.GetString("CtxtCopyEntryCedict");
pinyin = tprov.GetString("CtxtCopyPinyin");
string pinyinVal = CedictFormatter.GetPinyinString(entry.GetPinyinForDisplay(true), Magic.CtxtMenuMaxSyllableLength);
pinyin = string.Format(pinyin, pinyinVal);
sense = null;
hanzi1 = null;
hanzi2 = null;
if (script == SearchScript.Simplified || script == SearchScript.Traditional || entry.ChSimpl == entry.ChTrad)
{
hanzi1 = tprov.GetString("CtxtCopyHanzi");
string hanzi1Val = script == SearchScript.Traditional ? entry.ChTrad : entry.ChSimpl;
hanzi1Val = ellipse(hanzi1Val, Magic.CtxtMenuMaxSyllableLength);
hanzi1 = string.Format(hanzi1, hanzi1Val);
}
else
{
hanzi1 = tprov.GetString("CtxtCopySimplified");
string hanzi1Val = ellipse(entry.ChSimpl, Magic.CtxtMenuMaxSyllableLength);
hanzi1 = string.Format(hanzi1, hanzi1Val);
hanzi2 = tprov.GetString("CtxtCopyTraditional");
string hanzi2Val = ellipse(entry.ChTrad, Magic.CtxtMenuMaxSyllableLength);
hanzi2 = string.Format(hanzi2, hanzi2Val);
}
if (senseIx != -1)
{
sense = tprov.GetString("CtxtCopySense");
string senseVal = getSense(senseIx);
senseVal = ellipse(senseVal, Magic.CtxtMenuMaxSenseLength);
sense = string.Format(sense, senseVal);
}
}
示例7: getSenseHtmlPure
/// <summary>
/// Gets the HTML for a single sense, not including enclosing paragraph etc., only inline markup.
/// </summary>
/// <param name="tprov">Text provider if meta-labels (e.g. "Classifier") are to be included. If null, they are stripped.</param>
private static string getSenseHtmlPure(ITextProvider tprov, CedictSense sense, SearchScript script)
{
StringBuilder sb = new StringBuilder();
string strDomain = HybridToHtml(sense.Domain, script);
string strEquiv = HybridToHtml(sense.Equiv, script);
string strNote = HybridToHtml(sense.Note, script);
if (sense.Domain != HybridText.Empty)
{
if (sense.Domain.EqualsPlainText("CL:"))
{
if (tprov != null)
{
sb.Append(templateItalicsOpen);
sb.Append(escape(tprov.GetString("ResultCtrlClassifier")) + " ");
sb.Append(templateItalicsClose);
}
}
else
{
sb.Append(templateItalicsOpen);
sb.Append(strDomain);
sb.Append(templateItalicsClose);
}
}
if (sense.Domain != HybridText.Empty && !sense.Domain.EqualsPlainText("CL:"))
if (sense.Equiv != HybridText.Empty || sense.Note != HybridText.Empty)
sb.Append(' ');
sb.Append(strEquiv);
if (sense.Equiv != HybridText.Empty && sense.Note != HybridText.Empty)
sb.Append(' ');
if (sense.Note != HybridText.Empty)
{
sb.Append(templateItalicsOpen);
sb.Append(strNote);
sb.Append(templateItalicsClose);
}
// Done
return sb.ToString();
}
示例8: setTexts
private void setTexts(ITextProvider tprov, ICedictEngineFactory dictFact)
{
// Localized labels
lblAbout.Text =tprov.GetString("ZydeoAbout");
lblHeader1.Text = tprov.GetString("ZydeoHeader1");
lblHeader2.Text = tprov.GetString("ZydeoHeader2");
lblSourceCode.Text = tprov.GetString("ZydeoSourceCode");
lblLicense.Text = tprov.GetString("ZydeoLicense");
lblLicenseVal.Text = tprov.GetString("ZydeoLicenseVal");
lblCopyrightVal.Text = tprov.GetString("ZydeoCopyrightVal");
lblCopyright.Text = tprov.GetString("ZydeoCopyright");
lblCharRecogVal.Text = tprov.GetString("ZydeoCharRecogVal");
lblCharRecog.Text = tprov.GetString("ZydeoCharRecog");
lblDictionaryVal.Text = tprov.GetString("ZydeoDictionaryVal");
lblDictionary.Text = tprov.GetString("ZydeoDictionary");
lblVersion.Text = tprov.GetString("ZydeoVersion");
lblWeb.Text = tprov.GetString("ZydeoWeb");
lblUpdates.Text = tprov.GetString("ZydeoUpdates");
chkUpdates.Text = tprov.GetString("ZydeoNotifyUpdates");
// Magic labels: string hard-wired
lblWebVal.Text = Magic.WebUrl;
lblSourceCodeVal.Text = Magic.GithubUrl;
// Runtime data
ICedictInfo info = dictFact.GetInfo(Magic.DictFileName);
string infoStr = tprov.GetString("ZydeoDictionaryVal");
// Formatting entry count with current locale's thousand separator
string entryCountFmt = info.EntryCount.ToString("N0");
// Formatting date in current locale's "short" form
string dateFmt = info.Date.ToShortDateString();
infoStr = string.Format(infoStr, dateFmt, entryCountFmt);
lblDictionaryVal.Text = infoStr;
Version ver = Assembly.GetExecutingAssembly().GetName().Version;
lblVersionVal.Text = ver.Major.ToString() + "." + ver.Minor.ToString();
}
示例9: SearchOptionsTooltip
/// <summary>
/// Initializes tooltip provider for "search language" or "script" button.
/// </summary>
/// <param name="button">The actual button.</param>
/// <param name="isLang">If true, this is tooltip for "search lang"; otherwise, for "script".</param>
/// <param name="tprov">Localized UI strings provider.</param>
/// <param name="script">Current search script.</param>
/// <param name="lang">Current search language.</param>
/// <param name="needleHeight">Needle's height at today's scaling.</param>
public SearchOptionsTooltip(ZenGradientButton button, bool isLang, ITextProvider tprov,
SearchScript script, SearchLang lang, int needleHeight, int boxRight)
{
this.button = button;
this.needleHeight = needleHeight;
this.topOrSide = -boxRight;
if (isLang)
{
if (lang == SearchLang.Chinese) text = tprov.GetString("LangZhoTooltip");
else text = tprov.GetString("LangTrgTooltip");
}
else
{
if (script == SearchScript.Simplified) text = tprov.GetString("ScriptSimpTooltip");
else if (script == SearchScript.Traditional) text = tprov.GetString("ScriptTradTooltip");
else text = tprov.GetString("ScriptBothTooltip");
}
}
示例10: SysBtnTooltips
public SysBtnTooltips(ZenSystemButton button, ITextProvider tprov)
{
this.button = button;
if (button.BtnType == SystemButtonType.Close) text = tprov.GetString("MainCloseTooltip");
else if (button.BtnType == SystemButtonType.Minimize) text = tprov.GetString("MainMinimizeTooltip");
}
示例11: WhiteUpdateControl
// -----------------------------------------
/// <summary>
/// Ctor: take info about update.
/// </summary>
public WhiteUpdateControl(ZenControlBase owner, ITextProvider tprov,
int vmaj, int vmin, DateTime rdate, string rnotes, UpdateNowDelegate updateNow)
: base(owner)
{
this.tprov = tprov;
scale = Scale;
this.updateNow = updateNow;
// Fonts. !! Dispose 'em.
fntTitle = FontCollection.CreateFont(Magic.WhiteUpdFntTitle, Magic.WhiteUpFntTitleSz, FontStyle.Regular);
fntNorm = SystemFontProvider.Instance.GetSystemFont(FontStyle.Regular, Magic.WhiteUpdFntNormSz);
fntTblHead = SystemFontProvider.Instance.GetSystemFont(FontStyle.Bold, Magic.WhiteUpdFntNormSz);
fntTblValues = SystemFontProvider.Instance.GetSystemFont(FontStyle.Italic, 10F);
// Construct UI strings
Version ver = Assembly.GetExecutingAssembly().GetName().Version;
strVersionVal = tprov.GetString("WhiteUpdateTblVersionVal");
strVersionVal = string.Format(strVersionVal, ver.Major + "." + ver.Minor, vmaj + "." + vmin);
string longDateFormat = getLongDateFormat();
strDateVal = rdate.ToString(longDateFormat);
urlRelNotes = rnotes;
strTitle = tprov.GetString("WhiteUpdateTitle");
strBody = tprov.GetString("WhiteUpdateBody");
strTblHead = tprov.GetString("WhiteUpdateTblHeader");
strTblVersion = tprov.GetString("WhiteUpdateTblVersion");
strTblDate = tprov.GetString("WhiteUpdateTblDate");
strTblNotes = tprov.GetString("WhiteUpdateTblNotes");
strTblNotesVal = tprov.GetString("WhiteUpdateTblNotesVal");
// Width update button is fixed
btnUpdateWidth = (int)(scale * 200F);
}