예제 #1
0
        /// <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;
        }
예제 #2
0
        /// <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;
        }