Ejemplo n.º 1
0
 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");
 }
Ejemplo n.º 2
0
        /// <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;
            btnSearchLang.Height = ctrlSearchInput.Height;
            btnSearchLang.MouseClick += onSearchLang;

            // Update button texts; do it here so tooltip locations will be correct.
            simpTradChanged();
            searchLangChanged();

            // Lookup results control.
            ctrlResults = new ResultsControl(this, tprov, onLookupThroughLink, onGetEntry);
            ctrlResults.RelLocation = new Point(writingPad.RelRight + padding, ctrlSearchInput.RelBottom + padding);
        }
Ejemplo n.º 3
0
 /// <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");
     }
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Creates "update now" button when it's time to show it in fade-in animation.
 /// </summary>
 private void doCreateBtnUpdate()
 {
     btnUpdate = new ZenGradientButton(this);
     btnUpdate.Height = (int)(scale * 24F);
     btnUpdate.Width = btnUpdateWidth;
     btnUpdate.RelLocation = btnUpdateRelLoc;
     btnUpdate.SetFont(SystemFontProvider.Instance.GetSystemFont(FontStyle.Regular, 10F));
     btnUpdate.Text = tprov.GetString("WhiteUpdateButton");
     btnUpdate.MouseClick += onBtnUpdateClick;
 }