예제 #1
0
		public TextBinding(INotifyPropertyChanged dataTarget,
						   string writingSystemId,
						   WeSayTextBox widgetTarget)
		{
			Debug.Assert(dataTarget != null);
			_dataTarget = dataTarget;
			_dataTarget.PropertyChanged += OnDataPropertyChanged;
			_writingSystemId = writingSystemId;
			_textBoxTarget = widgetTarget;
			_textBoxTarget.TextChanged += OnTextBoxChanged;
			_textBoxTarget.HandleDestroyed += _textBoxTarget_HandleDestroyed;
			_textBoxTarget.Disposed += _textBoxTarget_Disposed;
			_textBoxTarget.Enter += OnTextBoxEntered;
			_textBoxTarget.Leave += OnTextBoxExit;
			_textBoxTarget.LostFocus+=OnTextBoxExit;
		}
예제 #2
0
        private WeSayTextBox AddTextBox(WritingSystem writingSystem, MultiTextBase multiText)
        {
            WeSayTextBox box = new WeSayTextBox(writingSystem, Name);
            box.ReadOnly = (_visibility == CommonEnumerations.VisibilitySetting.ReadOnly);
            box.Multiline = true;
            box.WordWrap = true;
            box.IsSpellCheckingEnabled = _isSpellCheckingEnabled;
            //box.Enabled = !box.ReadOnly;

            _textBoxes.Add(box);
            box.Name = Name.Replace("-mtc", "") + "_" + writingSystem.Id;
            //for automated tests to find this particular guy
            box.Text = multiText[writingSystem.Id];

            box.TextChanged += OnTextOfSomeBoxChanged;
            box.KeyDown += OnKeyDownInSomeBox;
            box.MouseWheel += subControl_MouseWheel;

            return box;
        }
예제 #3
0
        private static Label AddWritingSystemLabel(WeSayTextBox box)
        {
            Label label = new Label();
            label.Text = box.WritingSystem.Abbreviation;
            label.ForeColor = DisplaySettings.Default.WritingSystemLabelColor;
            label.Anchor = AnchorStyles.Left | AnchorStyles.Top;
            label.Font = _writingSystemLabelFont;

            label.AutoSize = true;

            //            Graphics g = CreateGraphics();
            //            int descent = box.Font.FontFamily.GetCellDescent(box.Font.Style);
            //            int descentPixel = (int) (box.Font.Size * descent / box.Font.FontFamily.GetEmHeight(box.Font.Style));
            //
            //            //todo: this only takes into account the textbox descent, not the label's!
            //            label.Location = new Point(0, (int) (box.Bottom -
            //                                                 ( g.MeasureString(label.Text, label.Font).Height + descentPixel )) );

            //todo: switch to TextRenderer.Measure
            int labelAscentInPixels =
                    (int)
                    (label.Font.Size * label.Font.FontFamily.GetCellAscent(label.Font.Style) /
                     label.Font.FontFamily.GetEmHeight(box.Font.Style));
            int contentAscentInPixels =
                    (int)
                    (box.Font.Size * box.Font.FontFamily.GetCellAscent(box.Font.Style) /
                     label.Font.FontFamily.GetEmHeight(box.Font.Style));
            int howMuchFartherDownToPlaceLabelThanText = Math.Max(0,
                                                                  contentAscentInPixels -
                                                                  labelAscentInPixels);

            label.Margin = new Padding(0, box.Top + howMuchFartherDownToPlaceLabelThanText, 0, 0);
            return label;
        }
예제 #4
0
		/// <summary>
		/// Drop our connections to everything so garbage collection can happen and we aren't
		/// a zombie responding to data change events.
		/// </summary>
		private void TearDown()
		{
			if (null != _pendingValueChange)//nb: string.emtpy is still a value we want to set!
			{
				SetTargetValue(_pendingValueChange);
			}
			//Debug.WriteLine(" BindingTearDown boundTo: " + this._textBoxTarget.Name);

			if (_dataTarget == null)
			{
				return; //teardown was called twice
			}

			_dataTarget.PropertyChanged -= OnDataPropertyChanged;
			_dataTarget = null;
			_textBoxTarget.TextChanged -= OnTextBoxChanged;
			_textBoxTarget.HandleDestroyed -= _textBoxTarget_HandleDestroyed;
			_textBoxTarget.Disposed -= _textBoxTarget_Disposed;
			_textBoxTarget = null;
		}