Esempio n. 1
0
        public void EndEdit()
        {
            if (siteLabelElement == null)
            {
                return;
            }

            labelTextBox.KeyPress -= new KeyPressEventHandler(labelTextBox_KeyPress);

            ILabelController lblCtrl = ControllerHelper.GetLabelController(siteLabelElement);

            labelElement.Size = MeasureTextSize();
            labelElement.Text = labelTextBox.Text;
            labelTextBox.Hide();
            if (lblCtrl != null)
            {
                lblCtrl.SetLabelPosition();
            }
            else
            {
                labelElement.PositionBySite(siteLabelElement);
            }
            labelElement.Invalidate();
            siteLabelElement = null;
            labelElement     = null;
            labelTextBox     = null;
        }
Esempio n. 2
0
        public void StartEdit(BaseElement el, TextBox textBox)
        {
            if (!(el is ILabelElement))
            {
                return;
            }

            if (((ILabelElement)el).Label.ReadOnly)
            {
                return;
            }

            this.siteLabelElement = el;
            this.labelElement     = ((ILabelElement)siteLabelElement).Label;
            this.labelTextBox     = textBox;
            if (siteLabelElement is BaseLinkElement)
            {
                this.direction = LabelEditDirection.Both;
            }
            else
            {
                this.direction = LabelEditDirection.UpDown;
            }

            EditLabelAction.SetTextBoxLocation(siteLabelElement, labelTextBox);

            labelTextBox.AutoSize = true;
            labelTextBox.Show();
            labelTextBox.Text     = labelElement.Text;
            labelTextBox.Font     = labelElement.Font;
            labelTextBox.WordWrap = labelElement.Wrap;

            labelElement.Invalidate();

            switch (labelElement.Alignment)
            {
            case StringAlignment.Near:
                labelTextBox.TextAlign = HorizontalAlignment.Left;
                break;

            case StringAlignment.Center:
                labelTextBox.TextAlign = HorizontalAlignment.Center;
                break;

            case StringAlignment.Far:
                labelTextBox.TextAlign = HorizontalAlignment.Right;
                break;
            }

            labelTextBox.KeyPress += new KeyPressEventHandler(labelTextBox_KeyPress);
            labelTextBox.Focus();
            center.X = textBox.Location.X + (textBox.Size.Width / 2);
            center.Y = textBox.Location.Y + (textBox.Size.Height / 2);
        }
Esempio n. 3
0
		public void StartEdit(BaseElement el, TextBox textBox)
		{
			if (!(el is ILabelElement)) return;

			if (((ILabelElement) el).Label.ReadOnly) return;

			this.siteLabelElement = el;
			this.labelElement = ((ILabelElement) siteLabelElement).Label;
			this.labelTextBox = textBox;
			if (siteLabelElement is BaseLinkElement)
				this.direction = LabelEditDirection.Both;
			else
				this.direction = LabelEditDirection.UpDown;
			
			EditLabelAction.SetTextBoxLocation(siteLabelElement, labelTextBox);

			labelTextBox.AutoSize = true;
			labelTextBox.Show();
			labelTextBox.Text = labelElement.Text;
			labelTextBox.Font = labelElement.Font;
			labelTextBox.WordWrap = labelElement.Wrap;
			
			labelElement.Invalidate();
			
			switch(labelElement.Alignment)
			{
				case StringAlignment.Near:
					labelTextBox.TextAlign = HorizontalAlignment.Left;
					break;
				case StringAlignment.Center:
					labelTextBox.TextAlign = HorizontalAlignment.Center;
					break;
				case StringAlignment.Far:
					labelTextBox.TextAlign = HorizontalAlignment.Right;
					break;
			}	

			labelTextBox.KeyPress += new KeyPressEventHandler(labelTextBox_KeyPress);
			labelTextBox.Focus();
			center.X = textBox.Location.X + (textBox.Size.Width / 2);
			center.Y = textBox.Location.Y + (textBox.Size.Height / 2);
		}
Esempio n. 4
0
        private void UpdateLinkPosition(NodeElement node)
        {
            foreach (ConnectorElement conn in node.Connectors)
            {
                foreach (BaseElement el in conn.Links)
                {
                    BaseLinkElement lnk  = (BaseLinkElement)el;
                    IController     ctrl = ((IControllable)lnk).GetController();
                    if (ctrl is IMoveController)
                    {
                        IMoveController mctrl = (IMoveController)ctrl;
                        if (!mctrl.IsMoving)
                        {
                            lnk.NeedCalcLink = true;
                        }
                    }
                    else
                    {
                        lnk.NeedCalcLink = true;
                    }

                    if (lnk is ILabelElement)
                    {
                        LabelElement label = ((ILabelElement)lnk).Label;

                        ILabelController lblCtrl = ControllerHelper.GetLabelController(lnk);
                        if (lblCtrl != null)
                        {
                            lblCtrl.SetLabelPosition();
                        }
                        else
                        {
                            label.PositionBySite(lnk);
                        }
                        label.Invalidate();
                    }
                }
            }
        }
Esempio n. 5
0
        public static void SetTextBoxLocation(BaseElement el, TextBox tb)
        {
            if (!(el is ILabelElement))
            {
                return;
            }

            LabelElement lab = ((ILabelElement)el).Label;

            el.Invalidate();
            lab.Invalidate();

            if (lab.Text.Length > 0)
            {
                tb.Location = lab.Location;
                tb.Size     = lab.Size;
            }
            else
            {
                string tmpText = "XXXXXXX";
                Size   sizeTmp = DiagramUtil.MeasureString(tmpText, lab.Font, lab.Size.Width, lab.Format);

                if (el is BaseLinkElement)
                {
                    tb.Size     = sizeTmp;
                    tb.Location = new Point(el.Location.X + (el.Size.Width / 2) - (sizeTmp.Width / 2),
                                            el.Location.Y + (el.Size.Height / 2) - (sizeTmp.Height / 2));
                }
                else
                {
                    sizeTmp.Width = el.Size.Width;
                    tb.Size       = sizeTmp;
                    tb.Location   = new Point(el.Location.X,
                                              el.Location.Y + (el.Size.Height / 2) - (sizeTmp.Height / 2));
                }
            }

            SetTextBoxBorder(tb);
        }