コード例 #1
0
        private void Construct(IDiagramPresenter owner, ICaptionedShape shape, int captionIndex, string currentText,
                               string newText)
        {
            if (owner == null)
            {
                throw new ArgumentNullException("owner");
            }
            if (shape == null)
            {
                throw new ArgumentNullException("shape");
            }
            if (captionIndex < 0 || captionIndex >= shape.CaptionCount)
            {
                throw new ArgumentOutOfRangeException("captionIndex");
            }
            // Set control styles
            SetStyle(ControlStyles.ResizeRedraw | ControlStyles.SupportsTransparentBackColor, true);
            UpdateStyles();

            // Set caption / style specific properties
            this.owner        = owner;
            this.shape        = shape;
            this.captionIndex = captionIndex;

            // Set general properties
            this.BackColor        = Color.Transparent;      // Does not matter - see CreateParams()
            this.AutoScrollOffset = Point.Empty;
            this.ScrollBars       = RichTextBoxScrollBars.None;
            this.BorderStyle      = BorderStyle.None;
            // Set Styles here because the ParagraphStyle is needed for resizing
            characterStyle = shape.GetCaptionCharacterStyle(captionIndex);
            paragraphStyle = shape.GetCaptionParagraphStyle(captionIndex);


            // Set base' members
            SuspendLayout();
            try {
                this.WordWrap   = paragraphStyle.WordWrap;
                this.Font       = ToolCache.GetFont(characterStyle);
                this.ZoomFactor = owner.ZoomLevel / 100f;

                // Get line height
                Size textSize = TextRenderer.MeasureText(((IDisplayService)owner).InfoGraphics, "Iq", Font);
                owner.DiagramToControl(textSize, out textSize);
                lineHeight = textSize.Height;

                DoUpdateBounds();

                SelectAll();
                SelectionAlignment = ConvertToHorizontalAlignment(paragraphStyle.Alignment);
                DeselectAll();
            }
            finally {
                ResumeLayout();
            }
            OnPaddingChanged(EventArgs.Empty);
        }
コード例 #2
0
ファイル: InplaceTextBox.cs プロジェクト: jestonitiro/nshape
		private void Construct(IDiagramPresenter owner, ICaptionedShape shape, int captionIndex, string currentText, string newText) {
			if (owner == null) throw new ArgumentNullException("owner");
			if (shape == null) throw new ArgumentNullException("shape");
			if (captionIndex < 0 || captionIndex >= shape.CaptionCount) throw new ArgumentOutOfRangeException("captionIndex");
			// Set control styles
			SetStyle(ControlStyles.ResizeRedraw | ControlStyles.SupportsTransparentBackColor, true);
			UpdateStyles();

			// Set general properties
			this.BackColor = Color.Transparent;	// Does not matter - see CreateParams()
			this.AutoScrollOffset = Point.Empty;
			this.ScrollBars = RichTextBoxScrollBars.None;
			this.BorderStyle = BorderStyle.None;

			// Set caption / style specific properties
			this.owner = owner;
			this.shape = shape;
			this.captionIndex = captionIndex;
			// Set Styles here because the ParagraphStyle is needed for resizing
			characterStyle = shape.GetCaptionCharacterStyle(captionIndex);
			paragraphStyle = shape.GetCaptionParagraphStyle(captionIndex);

			// set base' members
			SuspendLayout();
			try {
				this.WordWrap = paragraphStyle.WordWrap;
				this.Font = ToolCache.GetFont(characterStyle);
				this.ZoomFactor = owner.ZoomLevel / 100f;

				// Get line height
				Size textSize = TextRenderer.MeasureText(((IDisplayService)owner).InfoGraphics, "Iq", Font);
				owner.DiagramToControl(textSize, out textSize);
				lineHeight = textSize.Height;

				DoUpdateBounds();

				SelectAll();
				SelectionAlignment = ConvertToHorizontalAlignment(paragraphStyle.Alignment);
				DeselectAll();
			} finally {
				ResumeLayout();
			}
		}
コード例 #3
0
ファイル: Tool.cs プロジェクト: jestonitiro/nshape
		private bool IsMinRotateRangeExceeded(IDiagramPresenter diagramPresenter, MouseState mouseState) {
			if (diagramPresenter == null) throw new ArgumentNullException("diagramPresenter");
			if (mouseState == MouseState.Empty) throw new ArgumentException("mouseState");
			Point p;
			if (PendingToolActionsCount <= 1) p = ActionStartMouseState.Position;
			else {
				MouseState prevMouseState = GetPreviousMouseState();
				p = prevMouseState.Position;
			}
			Debug.Assert(Geometry.IsValid(p));
			int dist = (int)Math.Round(Geometry.DistancePointPoint(p.X, p.Y, mouseState.X, mouseState.Y));
			diagramPresenter.DiagramToControl(dist, out dist);
			return (dist > diagramPresenter.MinRotateRange);
		}