예제 #1
0
        private void HandleKey(KeyEventArgs e)
        {
            if (e.Key == Key.Enter)
            {
                TextBox box = this.TextBox;
                if (box != null && !box.AcceptsReturn)
                {
                    TextEditingTool tool = this.TextEditingTool;
                    if (tool != null)
                    {
                        tool.AcceptText(TextEditingReason.Enter);
                    }
                    return;
                }
            }
            else if (e.Key == Key.Tab)
            {
                TextBox box = this.TextBox;
                if (box != null



                    )
                {
                    TextEditingTool tool = this.TextEditingTool;
                    if (tool != null)
                    {
                        tool.AcceptText(TextEditingReason.Tab);
                    }
                    return;
                }
            }
        }
예제 #2
0
        private void LostFocus()
        {
            TextEditingTool tool = this.TextEditingTool;

            if (tool != null)
            {
                tool.AcceptText(TextEditingReason.LostFocus);
            }
        }
예제 #3
0
        private void LayoutBox(TextBox box)
        {
            if (box == null)
            {
                return;
            }
            TextEditingTool tool = this.TextEditingTool;

            if (tool == null)
            {
                return;
            }
            TextBlock block = tool.TextBlock;

            if (block == null)
            {
                return;
            }
            Adornment edad = tool.EditorAdornment;

            if (edad == null)
            {
                return;
            }
            Thickness thick = box.BorderThickness;
            Thickness pad   = box.Padding;

            if (block.TextWrapping != TextWrapping.NoWrap)
            {
                double w  = MeasureWrappedTextWidth(box.Text, box, block);
                Size   es = edad.GetEffectiveSize(block);
                double ww = Math.Max(w, es.Width);                                       // at least existing width
                box.MaxWidth = ww + thick.Left + thick.Right + pad.Left + pad.Right + 6; //??? hard-coded sizes
                //Diagram.Debug(Diagram.Str(ds) + Diagram.Str(es) + " ww: " + Diagram.Str(ww) + " maxw: " + Diagram.Str(box.MaxWidth));
            }
            edad.Remeasure();
        }