protected void PaintSideLength(Camera camera, Vector3 edgeCenter, Vector3 circleCenter, float length, string name)
        {
            var textCenter2DA = HandleUtility.WorldToGUIPoint(circleCenter);
            var textCenter2DB = HandleUtility.WorldToGUIPoint(edgeCenter);
            var normal2D      = (textCenter2DB - textCenter2DA).normalized;

            var textCenter2D = textCenter2DB;

            textCenter2D += normal2D * (hover_text_distance * 2);

            var textCenterRay = HandleUtility.GUIPointToWorldRay(textCenter2D);
            var textCenter    = textCenterRay.origin + textCenterRay.direction * ((camera.farClipPlane + camera.nearClipPlane) * 0.5f);

            PaintUtility.DrawLine(edgeCenter, textCenter, Color.black);
            PaintUtility.DrawDottedLine(edgeCenter, textCenter, ColorSettings.SnappedEdges);

            if (float.IsNaN(length) || float.IsInfinity(length))
            {
                PaintUtility.DrawScreenText(textCenter2D, name + " --");
            }
            else
            {
                PaintUtility.DrawScreenText(textCenter2D, name + Units.ToRoundedDistanceString(length));
            }
        }
        protected void PaintSnapVisualisation()
        {
            if (visualSnappedEdges != null)
            {
                PaintUtility.DrawLines(visualSnappedEdges.ToArray(), GUIConstants.oldThickLineScale, ColorSettings.SnappedEdges);
            }

            var _origMatrix = Handles.matrix;

            Handles.matrix = MathConstants.identityMatrix;
            if (visualSnappedGrid != null)
            {
                PaintUtility.DrawDottedLines(visualSnappedGrid.ToArray(), ColorSettings.SnappedEdges);
            }

            if (visualSnappedBrush != null)
            {
                if (visualSnappedBrush.compareTransformation != null &&
                    visualSnappedBrush.ChildData != null &&
                    visualSnappedBrush.ChildData.ModelTransform)
                {
                    var color = ColorSettings.HoverOutlines;
                    var brush_transformation = visualSnappedBrush.compareTransformation.localToWorldMatrix;
                    CSGRenderer.DrawOutlines(visualSnappedBrush.brushNodeID, brush_transformation,
                                             color, color, color, color, GUIConstants.oldThickLineScale);
                }
            }
            Handles.matrix = _origMatrix;
        }
Exemple #3
0
        void PaintSquare()
        {
            //var wireframeColor = ColorSettings.BoundsOutlines;

            if (settings.vertices.Length < 1)
            {
                return;
            }

            Vector3 corner1 = settings.vertices[0];
            Vector3 corner2 = settings.vertices.Length >= 2 ? settings.vertices[1] : worldPosition;
            //Vector3 center				= (corner2 + corner1) * 0.5f;
            Vector3 delta            = corner2 - corner1;
            Vector3 projected_width  = Vector3.Project(delta, gridTangent);
            Vector3 projected_length = Vector3.Project(delta, gridBinormal);

            var point0 = corner1 + projected_width + projected_length;
            var point1 = corner1 + projected_width;
            var point2 = corner1;
            var point3 = corner1 + projected_length;

            var points = new Vector3[] { point0, point1, point1, point2, point2, point3, point3, point0 };

            var color = ColorSettings.ShapeDrawingFill;

            PaintUtility.DrawPolygon(MathConstants.identityMatrix, points, color);
        }
Exemple #4
0
        void PaintCircle()
        {
            if (settings.vertices.Length < 1)
            {
                return;
            }

            var circleCenter = settings.vertices[0];
            var circleRadius = settings.vertices.Length >= 2 ? settings.vertices[1] : worldPosition;
            var delta        = circleRadius - circleCenter;
            var radius       = delta.magnitude;

            var color = ColorSettings.MeshEdgeOutline;

            PaintUtility.DrawCircle(circleCenter, buildPlane.normal, gridTangent, radius, color);

            /*
             * var projected_width  = Vector3.Project(delta, gridTangent);
             * var projected_length = Vector3.Project(delta, gridBinormal);
             *
             * var point0 = circleCenter + projected_width + projected_length;
             * var point1 = circleCenter + projected_width;
             * var point2 = circleCenter;
             * var point3 = circleCenter + projected_length;
             *
             * var points = new Vector3[] { point0, point1, point1, point2, point2, point3, point3, point0 };
             *
             * //PaintUtility.DrawPolygon(MathConstants.identityMatrix, points, color);
             */
        }
        internal static void Render(AABB bounds, Quaternion worldToLocalRotation, bool showEdgePoints)
        {
            var camera = Camera.current;

            if (!camera)
            {
                return;
            }

            var localToWorldRotation = Quaternion.Inverse(worldToLocalRotation);
            var localToWorld         = Matrix4x4.TRS(Vector3.zero, localToWorldRotation, Vector3.one);


            //PaintUtility.DrawDoubleDots(localToWorld, cornerPoints, cornerSizes, cornerColors, cornerPoints.Length);
            PaintUtility.DrawDoubleDots(localToWorld, sidePoints, sidePointSizes, sideColors, sidePoints.Length);
            if (showEdgePoints)
            {
                PaintUtility.DrawDoubleDots(localToWorld, edgePoints, edgePointSizes, edgeColors, edgePoints.Length);
            }

            PaintUtility.RenderBoundsSizes(worldToLocalRotation, localToWorldRotation, camera, cornerPoints,
                                           RealtimeCSG.CSGSettings.LockAxisX ? Color.red : Color.white,
                                           RealtimeCSG.CSGSettings.LockAxisY ? Color.red : Color.white,
                                           RealtimeCSG.CSGSettings.LockAxisZ ? Color.red : Color.white,
                                           true, true, true);
        }
Exemple #6
0
        void PaintShape(int id)
        {
            var temp       = Handles.color;
            var origMatrix = Handles.matrix;

            Handles.matrix = MathConstants.identityMatrix;
            var rotation = Camera.current.transform.rotation;

            bool isValid;
            var  realVertices = settings.GetVertices(buildPlane, worldPosition, gridTangent, gridBinormal, out isValid);

            if (editMode == EditMode.EditShape)
            {
                shapeIsValid = isValid;
            }
            if (realVertices != null && realVertices.Length >= 3)
            {
                var wireframeColor = ColorSettings.WireframeOutline;
                if (!shapeIsValid || !isValid)
                {
                    wireframeColor = Color.red;
                }
                for (int i = 1; i < realVertices.Length; i++)
                {
                    PaintUtility.DrawLine(realVertices[i - 1], realVertices[i], ToolConstants.oldLineScale, wireframeColor);
                    PaintUtility.DrawDottedLine(realVertices[i - 1], realVertices[i], wireframeColor, 4.0f);
                }

                PaintUtility.DrawLine(realVertices[realVertices.Length - 1], realVertices[0], ToolConstants.oldLineScale, wireframeColor);
                PaintUtility.DrawDottedLine(realVertices[realVertices.Length - 1], realVertices[0], wireframeColor, 4.0f);

                //var color = ColorSettings.ShapeDrawingFill;
                //PaintUtility.DrawPolygon(MathConstants.identityMatrix, realVertices, color);
            }



            if (settings.vertices != null && settings.vertices.Length > 0)
            {
                Handles.color = ColorSettings.PointInnerStateColor[0];
                for (int i = 0; i < settings.vertices.Length; i++)
                {
                    float handleSize       = CSG_HandleUtility.GetHandleSize(settings.vertices[i]);
                    float scaledHandleSize = handleSize * ToolConstants.handleScale;
                    PaintUtility.SquareDotCap(id, settings.vertices[i], rotation, scaledHandleSize);
                }
                PaintSquare();
                PaintBounds();
            }

            Handles.color = ColorSettings.PointInnerStateColor[3];
            {
                float handleSize       = CSG_HandleUtility.GetHandleSize(worldPosition);
                float scaledHandleSize = handleSize * ToolConstants.handleScale;
                PaintUtility.SquareDotCap(id, worldPosition, rotation, scaledHandleSize);
            }

            Handles.matrix = origMatrix;
            Handles.color  = temp;
        }
Exemple #7
0
        protected void PaintHeightMessage(Vector3 start, Vector3 end, Vector3 normal, float distance)
        {
            if (Mathf.Abs(distance) <= MathConstants.EqualityEpsilon)
            {
                return;
            }

            Vector3 middlePoint = (end + start) * 0.5f;

            var textCenter2DA = HandleUtility.WorldToGUIPoint(middlePoint + normal * 10.0f);
            var textCenter2DB = HandleUtility.WorldToGUIPoint(middlePoint);
            var normal2D      = (textCenter2DB - textCenter2DA).normalized;

            var textCenter2D = textCenter2DB;

            textCenter2D += normal2D * (hover_text_distance * 2);

            var textCenterRay = HandleUtility.GUIPointToWorldRay(textCenter2D);
            var textCenter    = textCenterRay.origin + textCenterRay.direction * ((Camera.current.farClipPlane + Camera.current.nearClipPlane) * 0.5f);

            PaintUtility.DrawLine(middlePoint, textCenter, Color.black);
            PaintUtility.DrawDottedLine(middlePoint, textCenter, ColorSettings.SnappedEdges);

            PaintUtility.DrawScreenText(textCenter2D, "Y: " + Units.ToRoundedDistanceString(Mathf.Abs(distance)));
        }
Exemple #8
0
        void PaintShape(int id)
        {
            var rotation = Camera.current.transform.rotation;

            var temp       = Handles.color;
            var origMatrix = Handles.matrix;

            {
                Handles.matrix = MathConstants.identityMatrix;

                Handles.color = ColorSettings.PointInnerStateColor[3];
                {
                    float handleSize       = CSG_HandleUtility.GetHandleSize(worldPosition);
                    float scaledHandleSize = handleSize * ToolConstants.handleScale;
                    PaintUtility.SquareDotCap(id, worldPosition, rotation, scaledHandleSize);
                }

                if (settings.vertices != null && settings.vertices.Length > 0)
                {
                    Handles.color = ColorSettings.PointInnerStateColor[0];
                    for (int i = 0; i < settings.vertices.Length; i++)
                    {
                        float handleSize       = CSG_HandleUtility.GetHandleSize(settings.vertices[i]);
                        float scaledHandleSize = handleSize * ToolConstants.handleScale;
                        PaintUtility.SquareDotCap(id, settings.vertices[i], rotation, scaledHandleSize);
                    }
                    PaintSquare();
                    PaintBounds();
                }
            }

            Handles.matrix = origMatrix;
            Handles.color  = temp;
        }
Exemple #9
0
        protected void PaintSnapVisualisation()
        {
            if (visualSnappedEdges != null)
            {
                PaintUtility.DrawLines(visualSnappedEdges.ToArray(), ToolConstants.oldThickLineScale, ColorSettings.SnappedEdges);
            }

            var _origMatrix = Handles.matrix;

            Handles.matrix = MathConstants.identityMatrix;
            if (visualSnappedGrid != null)
            {
                PaintUtility.DrawDottedLines(visualSnappedGrid.ToArray(), ColorSettings.SnappedEdges);
            }

            if (visualSnappedBrush != null)
            {
                var brush_cache = InternalCSGModelManager.GetBrushCache(visualSnappedBrush);
                if (brush_cache != null &&
                    brush_cache.compareTransformation != null &&
                    brush_cache.childData != null &&
                    brush_cache.childData.ModelTransform != null &&
                    brush_cache.childData.ModelTransform)
                {
                    var color             = ColorSettings.HoverOutlines;
                    var brush_translation = brush_cache.compareTransformation.modelLocalPosition + brush_cache.childData.ModelTransform.position;
                    CSGRenderer.DrawOutlines(visualSnappedBrush.brushID, brush_translation,
                                             color, color, color, color, ToolConstants.oldThickLineScale);
                }
            }
            Handles.matrix = _origMatrix;
        }
		void PaintCircle(SceneView sceneView, int id)
		{
            var camera      = sceneView.camera;
            var temp		= Handles.color;
			var origMatrix	= Handles.matrix;
					
			Handles.matrix = MathConstants.identityMatrix;
			var rotation = camera.transform.rotation;

			bool isValid;
			var realVertices = settings.GetVertices(buildPlane, worldPosition, gridTangent, gridBinormal, out isValid);
			if (realVertices != null && realVertices.Length >= 3)
			{
				var wireframeColor = ColorSettings.WireframeOutline;
				if (!shapeIsValid || !isValid)
					wireframeColor = Color.red;
				
				for (int i = 1; i < realVertices.Length; i++)
				{
					PaintUtility.DrawLine(realVertices[i - 1], realVertices[i], GUIConstants.oldLineScale, wireframeColor);
					PaintUtility.DrawDottedLine(realVertices[i - 1], realVertices[i], wireframeColor, 4.0f);
				}

				PaintUtility.DrawLine(realVertices[realVertices.Length - 1], realVertices[0], GUIConstants.oldLineScale, wireframeColor);
				PaintUtility.DrawDottedLine(realVertices[realVertices.Length - 1], realVertices[0], wireframeColor, 4.0f);
				
				if (realVertices.Length >= 3)
				{
					var color = ColorSettings.ShapeDrawingFill;
					PaintUtility.DrawPolygon(MathConstants.identityMatrix, realVertices, color);
				}

				PaintSquare(camera);
			}



			if (settings.vertices != null && settings.vertices.Length > 0)
			{
				Handles.color = ColorSettings.PointInnerStateColor[0];
				for (int i = 0; i < settings.vertices.Length; i++)
				{
					float handleSize = CSG_HandleUtility.GetHandleSize(settings.vertices[i]);
					float scaledHandleSize = handleSize * GUIConstants.handleScale;
					PaintUtility.SquareDotCap(id, settings.vertices[i], rotation, scaledHandleSize);
				}
				PaintRadiusMessage(camera);
			}
						
			Handles.color = ColorSettings.PointInnerStateColor[3];
			{
				float handleSize = CSG_HandleUtility.GetHandleSize(worldPosition);
				float scaledHandleSize = handleSize * GUIConstants.handleScale;
				PaintUtility.SquareDotCap(id, worldPosition, rotation, scaledHandleSize);
			}
			
			Handles.matrix = origMatrix;
			Handles.color = temp;
		}
		void PaintSquare(Camera camera)
		{
			var wireframeColor = ColorSettings.BoundsOutlines;

			var endPosition = settings.vertices.Length == 1 ? worldPosition : settings.vertices[1];
			var centerPoint = settings.vertices[0];
			var height		= (endPosition - centerPoint).magnitude;

			var upVector = buildPlane.normal * height;

			var point0 = settings.vertices[0] + (gridTangent * settings.sphereRadius) + (gridBinormal * settings.sphereRadius);
			var point1 = settings.vertices[0] + (gridTangent * settings.sphereRadius) - (gridBinormal * settings.sphereRadius);
			var point2 = settings.vertices[0] - (gridTangent * settings.sphereRadius) - (gridBinormal * settings.sphereRadius);
			var point3 = settings.vertices[0] - (gridTangent * settings.sphereRadius) + (gridBinormal * settings.sphereRadius);
			
			var point4 = point0;
			var point5 = point1;
			var point6 = point2;
			var point7 = point3;

            var point8 = point0 + upVector;
            var point9 = point1 + upVector;
            var pointA = point2 + upVector;
            var pointB = point3 + upVector;
			if (!IsHemiSphere)
			{
				point4 -= upVector;
				point5 -= upVector;
				point6 -= upVector;
				point7 -= upVector;
			}

			var points = new Vector3[] { point8, point9, point9, pointA, pointA, pointB, pointB, point8,
										point4, point5, point5, point6, point6, point7, point7, point4,
										point8, point4, point9, point5, pointA, point6, pointB, point7};

			PaintUtility.DrawDottedLines(points, wireframeColor, 4.0f);

			if (settings.vertices.Length == 0)
				return;

			{
				var volume = new Vector3[8];

				var localBounds = new AABB();
				localBounds.Reset();
				localBounds.Extend(toGridQuaternion * (point0 + upVector));
				localBounds.Extend(toGridQuaternion * (point1 + upVector));
				localBounds.Extend(toGridQuaternion * (point2 + upVector));
				localBounds.Extend(toGridQuaternion * (point3 + upVector));
				if (IsHemiSphere)
					localBounds.Extend(toGridQuaternion * point3);
				else
					localBounds.Extend(toGridQuaternion * (point3 - upVector));
				BoundsUtilities.GetBoundsCornerPoints(localBounds, volume);
				
				PaintUtility.RenderBoundsSizes(toGridQuaternion, fromGridQuaternion, camera, volume, Color.white, Color.white, Color.white, true, true, true);
			}
		}
		void PaintRadiusMessage(Camera camera)
		{
			if (settings.vertices == null || settings.vertices.Length == 0)
				return;

			var endPosition = settings.vertices.Length == 1 ? worldPosition : settings.vertices[1];
			var centerPoint	= settings.vertices[0];
			var delta		= (endPosition - centerPoint).normalized;

			PaintUtility.DrawLength(camera, "radius: ", HandleUtility.GetHandleSize(centerPoint), Matrix4x4.identity, Vector3.Cross(buildPlane.normal, delta), centerPoint, endPosition, Color.white);
		}
		void PaintBounds(Camera camera)
		{
			if (HaveHeight)
			{
				var localBounds = GetShapeBounds(toGridQuaternion);

				var volume = new Vector3[8];
				BoundsUtilities.GetBoundsCornerPoints(localBounds, volume);

				PaintUtility.RenderBoundsSizes(toGridQuaternion, fromGridQuaternion, camera, volume, Color.white, Color.white, Color.white, true, true, true);
			}
		}
Exemple #14
0
        /// <summary>
        /// Draw control border.
        /// </summary>
        public void DrawBorder()
        {
            if (!Bar.ShowBorders)
            {
                return;
            }
            var rect = new Rectangle(Bounds.X, Bounds.Y, Bounds.Width - 1, Bounds.Height - 1);

            PaintUtility.DrawBorder(Graphics, rect, Appearance.AppearanceBorder.CornerShape,
                                    Appearance.AppearanceBorder.BorderVisibility,
                                    Appearance.AppearanceBorder.BorderLineStyle, Appearance.CornerRadius,
                                    Bar.Focused ? Appearance.FocusedBorder : Appearance.NormalBorder, null, null);
        }
Exemple #15
0
        /// <summary>
        /// Draws Item Background.
        /// </summary>
        public void DrawItemBackGround()
        {
            if (Bounds.Height == 0 || Bounds.Width == 0)
            {
                return;
            }
            switch (State)
            {
            case State.Selected:
                PaintUtility.PaintGradientRectangle(Graphics, Bounds,
                                                    Item.Appearance.SelectedStyle.IsEmpty
                                                            ? Bar.CurrentAppearance.Item.SelectedStyle
                                                            : Item.Appearance.SelectedStyle);
                break;

            case State.Disabled:
                PaintUtility.PaintGradientRectangle(Graphics, Bounds,
                                                    Item.Appearance.DisabledStyle.IsEmpty
                                                            ? Bar.CurrentAppearance.Item.DisabledStyle
                                                            : Item.Appearance.DisabledStyle);
                break;

            case State.Hover:
                PaintUtility.PaintGradientRectangle(Graphics, Bounds,
                                                    Item.Appearance.HoverStyle.IsEmpty
                                                            ? Bar.CurrentAppearance.Item.HoverStyle
                                                            : Item.Appearance.HoverStyle);
                break;

            case State.SelectedHover:
                PaintUtility.PaintGradientRectangle(Graphics, Bounds,
                                                    Item.Appearance.SelectedHoverStyle.IsEmpty
                                                            ? Bar.CurrentAppearance.Item.SelectedHoverStyle
                                                            : Item.Appearance.SelectedHoverStyle);
                break;

            case State.Normal:
                PaintUtility.PaintGradientRectangle(Graphics, Bounds,
                                                    Item.Appearance.BackStyle.IsEmpty
                                                            ? Bar.CurrentAppearance.Item.BackStyle
                                                            : Item.Appearance.BackStyle);
                break;

            case State.Pressed:
                PaintUtility.PaintGradientRectangle(Graphics, Bounds,
                                                    Item.Appearance.ClickStyle.IsEmpty
                                                            ? Bar.CurrentAppearance.Item.ClickStyle
                                                            : Item.Appearance.ClickStyle);
                break;
            }
        }
Exemple #16
0
        /// <summary>
        /// Draws Item Border
        /// </summary>
        public void DrawItemBorder()
        {
            if (!Bar.ShowBorders && Item.ShowBorder == ShowBorder.Inherit || Item.ShowBorder == ShowBorder.NotShow)
            {
                return;
            }
            switch (State)
            {
            case State.Selected:
                PaintUtility.PaintBorder(Graphics, Bounds,
                                         Item.Appearance.SelectedBorder.IsEmpty
                                                 ? Bar.CurrentAppearance.Item.SelectedBorder
                                                 : Item.Appearance.SelectedBorder);
                break;

            case State.Disabled:
                PaintUtility.PaintBorder(Graphics, Bounds,
                                         Item.Appearance.DisabledBorder.IsEmpty
                                                 ? Bar.CurrentAppearance.Item.DisabledBorder
                                                 : Item.Appearance.DisabledBorder);
                break;

            case State.Hover:
                PaintUtility.PaintBorder(Graphics, Bounds,
                                         Item.Appearance.HoverBorder.IsEmpty
                                                 ? Bar.CurrentAppearance.Item.HoverBorder
                                                 : Item.Appearance.HoverBorder);
                break;

            case State.SelectedHover:
                PaintUtility.PaintBorder(Graphics, Bounds,
                                         Item.Appearance.HoverBorder.IsEmpty
                                                 ? Bar.CurrentAppearance.Item.HoverBorder
                                                 : Item.Appearance.HoverBorder);
                break;

            case State.Normal:
                PaintUtility.PaintBorder(Graphics, Bounds,
                                         Item.Appearance.NormalBorder.IsEmpty
                                                 ? Bar.CurrentAppearance.Item.NormalBorder
                                                 : Item.Appearance.NormalBorder);
                break;

            case State.Pressed:
                PaintUtility.PaintBorder(Graphics, Bounds,
                                         Item.Appearance.SelectedBorder.IsEmpty
                                                 ? Bar.CurrentAppearance.Item.SelectedBorder
                                                 : Item.Appearance.SelectedBorder);
                break;
            }
        }
        public void Render()
        {
            var endAngle = RotateCurrentStartAngle + RotateCurrentSnappedAngle;

            if (HaveRotateStartAngle)
            {
                PaintUtility.DrawRotateCirclePie(RotateCenterPoint, RotateSurfaceNormal, RotateSurfaceTangent, RotateRadius,
                                                 RotateOriginalAngle, RotateCurrentStartAngle, endAngle,
                                                 ColorSettings.RotateCircleOutline);                                               //, RotateCirclePieFill, ColorSettings.RotateCirclePieOutline);
            }
            PaintUtility.DrawRotateCircle(RotateCenterPoint, RotateSurfaceNormal, RotateSurfaceTangent, RotateRadius,
                                          RotateOriginalAngle, RotateCurrentStartAngle, endAngle,
                                          ColorSettings.RotateCircleOutline);                                              //, ColorSettings.RotateCircleHatches);
        }
        private void DrawDay(Graphics g, DateTime day, bool selected)
        {
            var dayIndex        = GetCellIndex(day);
            var dayCellPosition = GetCellAtIndex(dayIndex);
            var rect            = new Rectangle(dayCellPosition.X - 4, dayCellPosition.Y + 1, DaysCell.Width - 1, DaysCell.Height - 1);
            var br = selected ? currentAppearance.SelectedBackColor.GetBrush(rect) : currentAppearance.ButtonBackColor.GetBrush(rect);

            PaintUtility.DrawBackground(g, rect, br, currentAppearance.SelectedDateAppearance.CornerShape, currentAppearance.Radius, null);
            if (day.Day < 10)
            {
                dayCellPosition.X += 4;
            }
            g.DrawString(day.Day.ToString(), Font, new SolidBrush(((selected) ? currentAppearance.SelectedDateTextColor : currentAppearance.ActiveTextColor)), dayCellPosition.X, dayCellPosition.Y);
        }
Exemple #19
0
        void PaintBounds()
        {
            if (HaveHeight)
            {
                var camera = Camera.current;

                var localBounds = GetShapeBounds(toGridQuaternion);

                var volume = new Vector3[8];
                BoundsUtilities.GetBoundsVertices(localBounds, volume);

                PaintUtility.RenderBoundsSizes(toGridQuaternion, fromGridQuaternion, camera, volume, Color.white, Color.white, Color.white, true, true, true);
            }
        }
        private void DrawCurSelection()
        {
            switch (displayType)
            {
            case DisplayType.Dates:
            {
                var dayIndex        = GetCellIndex(selectedDate);
                var dayCellPosition = GetCellAtIndex(dayIndex);
                var rect            = new Rectangle(dayCellPosition.X - 4, dayCellPosition.Y + 1, DaysCell.Width - 1, DaysCell.Height - 1);
                PaintUtility.DrawBackground(graphics, rect, currentAppearance.SelectedBackColor.GetBrush(rect), currentAppearance.SelectedDateAppearance.CornerShape, currentAppearance.Radius, null);
                if (selectedDate.Day < 10)
                {
                    dayCellPosition.X += 4;
                }
                graphics.DrawString(selectedDate.Day.ToString(), Font, new SolidBrush(currentAppearance.SelectedDateTextColor), dayCellPosition.X, dayCellPosition.Y);
            }
            break;

            case DisplayType.Monthes:
            {
                var monthPosition = GetCellAtIndex(selectedDate.Month - 1);
                var rect          = new Rectangle(monthPosition.X - 5, monthPosition.Y, MonthCell.Width, MonthCell.Height);
                PaintUtility.DrawBackground(graphics, rect, currentAppearance.SelectedBackColor.GetBrush(rect), currentAppearance.SelectedDateAppearance.CornerShape, currentAppearance.Radius, null);
                graphics.DrawString(selectedDate.ToString("MMM"), Font, new SolidBrush(currentAppearance.SelectedDateTextColor), monthPosition.X, monthPosition.Y + MonthCell.Height / 2 - Font.Height / 2);
            }
            break;

            case DisplayType.Years:
            {
                var startYear    = 10 * (selectedDate.Year / 10);
                var yearPosition = GetCellAtIndex(selectedDate.Year - startYear);
                var rect         = new Rectangle(yearPosition.X - 5, yearPosition.Y, MonthCell.Width, MonthCell.Height);
                PaintUtility.DrawBackground(graphics, rect, currentAppearance.SelectedBackColor.GetBrush(rect), currentAppearance.SelectedDateAppearance.CornerShape, currentAppearance.Radius, null);
                graphics.DrawString(selectedDate.ToString("yyyy"), Font, new SolidBrush(currentAppearance.SelectedDateTextColor), yearPosition.X, yearPosition.Y + MonthCell.Height / 2 - Font.Height / 2);
            }
            break;

            case DisplayType.YearsRange:
            {
                var startYear     = 100 * (selectedDate.Year / 100);
                var rangePosition = GetCellAtIndex((selectedDate.Year - startYear) / 100);
                GetCellIndex(selectedDate);
                var rect = new Rectangle(rangePosition.X - 5, rangePosition.Y, MonthCell.Width, MonthCell.Height);
                PaintUtility.DrawBackground(graphics, rect, currentAppearance.SelectedBackColor.GetBrush(rect), currentAppearance.SelectedDateAppearance.CornerShape, currentAppearance.Radius, null);
                var text = (startYear + (100 * ((selectedDate.Year - startYear) / 100))).ToString().PadLeft(4, '0') + "-\n" + (startYear + (100 * ((selectedDate.Year - startYear) / 100)) + 99).ToString().PadLeft(4, '0');
                graphics.DrawString(text, Font, new SolidBrush(currentAppearance.SelectedDateTextColor), rangePosition.X, rangePosition.Y);
            }
            break;
            }
        }
        private void DrawHoverSelection(Graphics g, int index, bool drawOrErase)
        {
            if (!hotAppearance)
            {
                return;
            }
            if ((index < 0) || (index >= 12))
            {
                return;
            }
            var rangeCellPosition = GetCellAtIndex(index);
            var rect = new Rectangle(rangeCellPosition.X - 5, rangeCellPosition.Y, MonthCell.Width, MonthCell.Height);
            var br   = new SolidBrush(drawOrErase ? currentAppearance.HoverColor : currentAppearance.ControlBackColor);

            PaintUtility.DrawBorder(g, rect, currentAppearance.SelectedDateAppearance.CornerShape, currentAppearance.SelectedDateAppearance.BorderVisibility, currentAppearance.SelectedDateAppearance.BorderLineStyle, currentAppearance.Radius, br, null);
        }
        void PaintSquare(Camera camera)
        {
            var wireframeColor = ColorSettings.BoundsOutlines;

            if (HaveHeight)
            {
                var localBounds = GetShapeBounds(toGridQuaternion);

                var volume = new Vector3[8];
                BoundsUtilities.GetBoundsCornerPoints(localBounds, volume);

                PaintUtility.DrawDottedLines(Matrix4x4.TRS(Vector3.zero, fromGridQuaternion, Vector3.one), volume, BoundsUtilities.AABBLineIndices, wireframeColor, 4.0f);

                PaintUtility.RenderBoundsSizes(toGridQuaternion, fromGridQuaternion, camera, volume, Color.white, Color.white, Color.white, true, true, true);
            }
        }
Exemple #23
0
        /// <summary>
        /// Converts an object into its XML representation.
        /// </summary>
        /// <param name="writer">The <see cref="T:System.Xml.XmlWriter"/> stream to which the object is serialized. </param>
        public void WriteXml(XmlWriter writer)
        {
            writer.WriteStartElement("BackStyle");
            BackStyle.WriteXml(writer);
            writer.WriteEndElement();

            writer.WriteElementString("NormalBorder", PaintUtility.GetString(NormalBorder));
            writer.WriteElementString("DisabledMask", PaintUtility.GetString(DisabledMask));
            writer.WriteElementString("FocusedBorder", PaintUtility.GetString(FocusedBorder));

            writer.WriteStartElement("AppearanceBorder");
            AppearanceBorder.WriteXml(writer);
            writer.WriteEndElement();

            writer.WriteElementString("CornerRadius", CornerRadius.ToString());
        }
        /// <summary>
        /// Raises the <see cref="E:System.Windows.Forms.Control.Paint"/> event.
        /// </summary>
        /// <param name="e">A <see cref="T:System.Windows.Forms.PaintEventArgs"/> that contains the event data. </param>
        protected override void OnPaint(PaintEventArgs e)
        {
            CreateMemoryBitmap();
            //SetDefaults();
            CalculateFirstDate();
            graphics.Clear(currentAppearance.ControlBackColor);
            e.Graphics.SmoothingMode      = SmoothingMode.AntiAlias;
            e.Graphics.TextRenderingHint  = TextRenderingHint.ClearTypeGridFit;
            e.Graphics.CompositingQuality = CompositingQuality.HighQuality;
            e.Graphics.InterpolationMode  = InterpolationMode.HighQualityBicubic;
            DrawCaption(graphics);
            switch (displayType)
            {
            case DisplayType.Dates:
                DrawDaysOfWeek(graphics);
                DrawDays(graphics);
                break;

            case DisplayType.Monthes:
                DrawMonths(graphics);
                MarkerRectangle = Rectangle.Empty;
                break;

            case DisplayType.Years:
                DrawYears(graphics);
                MarkerRectangle = Rectangle.Empty;
                break;

            case DisplayType.YearsRange:
                DrawYearRange(graphics);
                MarkerRectangle = Rectangle.Empty;
                break;
            }
            DrawCurSelection();
            DrawTodaySelection(graphics);
            DrawBottomLabels(graphics);
            graphics.DrawRectangle(new Pen(currentAppearance.ControlBorderColor), 0, 0, Width - 1, Height - 1);
            if (!Enabled)
            {
                graphics.FillRectangle(new SolidBrush(Color.FromArgb(150, currentAppearance.DisabledMask)), 0, 0, Width - 1, Height - 1);
            }
            if (Focused && drawFocused)
            {
                graphics.DrawRectangle(new Pen(currentAppearance.FocusedBorder), 0, 0, Width - 1, Height - 1);
            }
            PaintUtility.DrawImage(e.Graphics, new Rectangle(0, 0, bmp.Width, bmp.Height), bmp, (int)(BackgroundImage == null ? 100 * 2.55 : backGroundImageAlpha * 2.55));
        }
        private void DrawHoverSelection(Graphics g, DateTime date, bool drawOrErase)
        {
            if (!hotAppearance)
            {
                return;
            }
            var dayIndex = GetCellIndex(date);

            if ((dayIndex < 0) || (dayIndex >= days.Length))
            {
                return;
            }
            var dayCellPosition = GetCellAtIndex(dayIndex);
            var rect            = new Rectangle(dayCellPosition.X - 5, dayCellPosition.Y, DaysCell.Width, DaysCell.Height);
            var br = new SolidBrush(drawOrErase ? currentAppearance.HoverColor : currentAppearance.ControlBackColor);

            PaintUtility.DrawBorder(g, rect, currentAppearance.SelectedDateAppearance.CornerShape, currentAppearance.SelectedDateAppearance.BorderVisibility, currentAppearance.SelectedDateAppearance.BorderLineStyle, currentAppearance.Radius, br, null);
        }
        void PaintBounds(Camera camera)
        {
            var worldToLocalRotation = GetWorldToLocalRotation();
            var localToWorldRotation = Quaternion.Inverse(worldToLocalRotation);
            var localBounds          = GetShapeBounds(worldToLocalRotation);

            var volume = new Vector3[8];

            BoundsUtilities.GetBoundsCornerPoints(localBounds, volume);

            var boundOutlinesColor = ColorSettings.MeshEdgeOutline;
            var localToWorld       = Matrix4x4.TRS(Vector3.zero, localToWorldRotation, Vector3.one);

            PaintUtility.DrawDottedLines(localToWorld, volume, BoundsUtilities.AABBLineIndices, boundOutlinesColor, 4.0f);
            PaintUtility.DrawLines(localToWorld, volume, BoundsUtilities.AABBLineIndices, GUIConstants.oldLineScale, boundOutlinesColor);

            PaintUtility.RenderBoundsSizes(worldToLocalRotation, localToWorldRotation, camera, volume, Color.white, Color.white, Color.white, true, true, true);
        }
        private void DrawTodaySelection(Graphics g)
        {
            if (displayType != DisplayType.Dates)
            {
                return;
            }
            var dayIndex = GetCellIndex(DateTime.Now);

            if (((dayIndex < 0) || (dayIndex >= days.Length)) || (DateTime.Now.Month != selectedDate.Month))
            {
                return;
            }
            var dayCellPosition = GetCellAtIndex(dayIndex);
            var rect            = new Rectangle(dayCellPosition.X - 5, dayCellPosition.Y, DaysCell.Width, DaysCell.Height);
            var br = new SolidBrush(currentAppearance.TodayBorderColor);

            PaintUtility.DrawBorder(g, rect, currentAppearance.SelectedDateAppearance.CornerShape, currentAppearance.SelectedDateAppearance.BorderVisibility, currentAppearance.SelectedDateAppearance.BorderLineStyle, currentAppearance.Radius, br, null);
        }
Exemple #28
0
        public static void CircleDotCap(int controlID, Vector3 position, Quaternion rotation, float size, EventType eventType)
        {
            switch (eventType)
            {
            case EventType.Layout:
            {
                HandleUtility.AddControl(controlID, HandleUtility.DistanceToCircle(position, size * .1f));
                break;
            }

            case EventType.Repaint:
            {
                var direction = rotation * Vector3.forward;
                PaintUtility.CircleDotCap(controlID, position, Quaternion.LookRotation(direction), size * .2f);
                break;
            }
            }
        }
Exemple #29
0
        /// <summary>
        /// Generates an object from its XML representation.
        /// </summary>
        /// <param name="reader">The <see cref="T:System.Xml.XmlReader"/> stream from which the object is deserialized. </param>
        public void ReadXml(XmlReader reader)
        {
            var doc = new XmlDocument();

            doc.Load(reader);
            if (doc.GetElementsByTagName("BackColor1").Count > 0)
            {
                BackColor1 = PaintUtility.GetColor(doc.GetElementsByTagName("BackColor1")[0].InnerText);
            }
            if (doc.GetElementsByTagName("BackColor2").Count > 0)
            {
                BackColor2 = PaintUtility.GetColor(doc.GetElementsByTagName("BackColor2")[0].InnerText);
            }
            if (doc.GetElementsByTagName("Gradient").Count > 0)
            {
                Gradient = Convert.ToInt32(doc.GetElementsByTagName("Gradient")[0].InnerText);
            }
        }
        void PaintRadiusMessage()
        {
            if (settings.vertices == null || settings.vertices.Length == 0)
            {
                return;
            }

            var endPosition = settings.vertices.Length == 1 ? worldPosition : settings.vertices[1];
            var centerPoint = settings.vertices[0];
            var delta       = (endPosition - centerPoint).normalized;

            PaintUtility.DrawLength("radius: ", HandleUtility.GetHandleSize(centerPoint), Matrix4x4.identity, Vector3.Cross(buildPlane.normal, delta), centerPoint, endPosition, Color.white);

            /*
             * PaintUtility.DrawDottedLine(endPosition, settings.vertices[0], ColorSettings.BoundsEdgeHover, 4.0f);
             *
             *
             * Vector3 radiusPoint = endPosition;
             * float radius = (endPosition - centerPoint).magnitude;
             * if (float.IsNaN(radius) || float.IsInfinity(radius))
             *      radiusPoint = centerPoint;
             *
             * var edgeCenter = (centerPoint + radiusPoint) * 0.5f;
             *
             * var textCenter2DA = HandleUtility.WorldToGUIPoint(centerPoint);
             * var textCenter2DB = HandleUtility.WorldToGUIPoint(radiusPoint);
             * var textCenter2DC = HandleUtility.WorldToGUIPoint(edgeCenter);
             * var normal2D = (textCenter2DB - textCenter2DA).normalized;
             * var temp = normal2D;
             * normal2D.x = -temp.y;
             * normal2D.y = temp.x;
             *
             * var textCenter2D = textCenter2DC;
             * textCenter2D += normal2D * (hover_text_distance * 2);
             *
             * var textCenterRay = HandleUtility.GUIPointToWorldRay(textCenter2D);
             * var textCenter = textCenterRay.origin + textCenterRay.direction * ((Camera.current.farClipPlane + Camera.current.nearClipPlane) * 0.5f);
             *
             * PaintUtility.DrawLine(edgeCenter, textCenter, Color.black);
             * PaintUtility.DrawDottedLine(edgeCenter, textCenter, ColorSettings.SnappedEdges);
             *
             * PaintUtility.DrawScreenText(textCenter2D,
             *      "radius " + Units.ToRoundedDistanceString(radius));*/
        }