Exemple #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="row"></param>
        /// <param name="col"></param>
        /// <param name="rowSpan"></param>
        /// <param name="colSpan"></param>
        /// <returns></returns>
        protected NRectangle GetGridCell(int row, int col, int rowSpan, int colSpan)
        {
            NRectangle cell1 = GetGridCell(row, col, m_GridOrigin, m_GridCellSize, m_GridSpacing);
            NRectangle cell2 = GetGridCell(row + rowSpan, col + colSpan, m_GridOrigin, m_GridCellSize, m_GridSpacing);

            return(NRectangle.Union(cell1, cell2));
        }
Exemple #2
0
        /// <summary>
        /// Performs the element post-children custom paint. Overriden to paint the status
        /// of this example tile (if it has one) in its bottom-left corner.
        /// </summary>
        /// <param name="visitor"></param>
        protected override void OnPostPaint(NPaintVisitor visitor)
        {
            base.OnPostPaint(visitor);

            if (String.IsNullOrEmpty(m_Status))
            {
                return;
            }

            // Paint a new label in the bottom left corner
            NRectangle bounds = GetContentEdge();

            NFont font = new NFont(FontName, 5.0, ENFontStyle.Regular);

            font.RasterizationMode = ENFontRasterizationMode.Aliased;
            NSize      textSize = font.MeasureString(m_Status, this.OwnerDocument);
            NRectangle textRect = new NRectangle(bounds.X - 1, bounds.Bottom - textSize.Height,
                                                 textSize.Width + 3, textSize.Height);

            // Paint the text background
            NColor color = HomePage.GetStatusColor(m_Status);

            visitor.SetFill(color);
            visitor.PaintRectangle(textRect);

            // Paint the text
            visitor.SetFill(NColor.White);
            visitor.SetFont(font);

            NPoint location = textRect.Location;
            NPaintTextPointSettings settings = new NPaintTextPointSettings();

            visitor.PaintString(location, m_Status, ref settings);
        }
            public void Paint(NPaintVisitor visitor)
            {
                NColor color;

                switch (State)
                {
                case ENTouchDeviceState.Down:
                    color = NColor.Blue;
                    break;

                case ENTouchDeviceState.Unknown:
                    color = NColor.Green;
                    break;

                case ENTouchDeviceState.Up:
                    color = NColor.Red;
                    break;

                default:
                    throw new Exception("New ENTouchDeviceState?");
                }

                NSize size = Size;

                if (size.Width == 0 || size.Height == 0)
                {
                    size = new NSize(5, 5);
                }

                visitor.SetStroke(new NStroke(color));
                visitor.PaintEllipse(NRectangle.FromCenterAndSize(Location, size));
            }
            private NBorderWall CreateOpenedBorderWall()
            {
                NRectangle outer = GetBorderEdge();
                NRectangle inner = GetContentEdge();

                NBorderWall wall = new NBorderWall(false);

                double leftSide   = inner.X - outer.X;
                double topSide    = inner.Y - outer.Y;
                double rightSide  = outer.Right - inner.Right;
                double bottomSide = outer.Bottom - inner.Bottom;

                double topClipStart = inner.X + inner.Width / 3;
                double topClipEnd   = inner.Right - inner.Width / 3;

                wall.AddTopSide(new NRectangle(topClipEnd, outer.Y, inner.Right - topClipEnd, topSide));
                wall.AddTopRightCorner(new NRectangle(inner.Right, outer.Y, rightSide, topSide));
                wall.AddRightSide(new NRectangle(inner.Right, inner.Y, rightSide, inner.Height));
                wall.AddRightBottomCorner(new NRectangle(inner.Right, inner.Bottom, rightSide, bottomSide));
                wall.AddBottomSide(new NRectangle(inner.X, inner.Bottom, inner.Width, bottomSide));
                wall.AddBottomLeftCorner(new NRectangle(outer.X, inner.Bottom, leftSide, bottomSide));
                wall.AddLeftSide(new NRectangle(outer.X, inner.Y, leftSide, inner.Height));
                wall.AddLeftTopCorner(new NRectangle(outer.X, outer.Y, leftSide, topSide));
                wall.AddTopSide(new NRectangle(inner.X, outer.Y, topClipStart - inner.X, topSide));

                return(wall);
            }
        protected override void OnPostPaint(NPaintVisitor visitor)
        {
            base.OnPostPaint(visitor);

            if (String.IsNullOrEmpty(m_Status))
            {
                return;
            }

            visitor.ClearStyles();
            visitor.SetFont(Font);

            // Determine status bounds
            NRectangle contentArea  = GetContentEdge();
            double     length       = NMath.Max(contentArea.Width, contentArea.Height) * 0.3;
            NRectangle statusBounds = new NRectangle(contentArea.Right - length - 5,
                                                     contentArea.Top + 5, length, length);

            // Fill the status bounds with a circle
            NExamplesHomePage homePage = (NExamplesHomePage)GetFirstAncestor(NExamplesHomePage.NExamplesHomePageSchema);
            NColor            color    = homePage.GetStatusColor(m_Status);

            visitor.SetFill(new NColor(color, 160));
            visitor.PaintEllipse(statusBounds);

            // Create text paint settings
            NPaintTextRectSettings settings = new NPaintTextRectSettings();

            settings.HorzAlign = ENTextHorzAlign.Center;
            settings.VertAlign = ENTextVertAlign.Center;

            // Paint the status text in the top right corner
            visitor.SetFill(NColor.White);
            visitor.PaintString(statusBounds, m_Status, ref settings);
        }
        private static NGraphicsPath CreateRoundedRectangle(double w, double h)
        {
            NRectangle    rect = new NRectangle(0.05 * w, 0.25 * h, 0.9 * w, 0.5 * h);
            NGraphicsPath path = new NGraphicsPath();

            path.AddRoundedRectangle(rect, h * 0.05);
            return(path);
        }
        private static NGraphicsPath CreateEllipseSegment(double w, double h)
        {
            NRectangle    rect = new NRectangle(0.05 * w, 0.25 * h, 0.9 * w, 0.5 * h);
            NGraphicsPath path = new NGraphicsPath();

            path.AddEllipseSegment(rect, NMath.PI * 0.1, NMath.PI * 1.2);
            return(path);
        }
        /// <summary>
        /// Overriden to create the family tree template
        /// </summary>
        /// <param name="document">document in which to create the template</param>
        protected override void CreateTemplate(NDrawingDocument document)
        {
            NPoint pt;
            NShape node;
            NShape edge = null;
            NPage  page = document.Content.ActivePage;

            // determine the elements dimensions
            double childrenWidth = m_nChildrenCount * m_VerticesSize.Width + (m_nChildrenCount - 1) * m_fHorizontalSpacing;
            double parentsWidth  = m_VerticesSize.Width * 2 + m_fHorizontalSpacing;

            // determine the template dimensions
            double     templateWidth  = Math.Max(childrenWidth, parentsWidth);
            NRectangle templateBounds = new NRectangle(m_Origin.X, m_Origin.Y, templateWidth, m_VerticesSize.Height * 2 + m_fVerticalSpacing);
            NPoint     center         = templateBounds.Center;

            // create the parent nodes
            NShape father = CreateVertex(m_VerticesShape);

            pt = new NPoint(center.X - (m_VerticesSize.Width + m_fHorizontalSpacing / 2), templateBounds.Y);
            father.SetBounds(new NRectangle(pt, m_VerticesSize));
            page.Items.AddChild(father);

            NShape mother = CreateVertex(m_VerticesShape);

            pt = new NPoint(center.X + m_fHorizontalSpacing / 2, templateBounds.Y);
            mother.SetBounds(new NRectangle(pt, m_VerticesSize));
            page.Items.AddChild(mother);

            // create the children
            if (m_nChildrenCount > 0)
            {
                double childrenY = templateBounds.Y + m_VerticesSize.Height + m_fVerticalSpacing;
                for (int i = 0; i < m_nChildrenCount; i++)
                {
                    // create the child
                    node = CreateVertex(m_VerticesShape);
                    pt   = new NPoint(i * (m_VerticesSize.Width + m_fHorizontalSpacing), childrenY);
                    node.SetBounds(new NRectangle(pt, m_VerticesSize));
                    page.Items.AddChild(node);

                    // attach it to the parents
                    edge = CreateEdge(ENConnectorShape.BottomToTop1);
                    page.Items.AddChild(edge);

                    edge.GlueBeginToGeometryIntersection(father);
                    edge.GlueEndToShape(node);

                    edge = CreateEdge(ENConnectorShape.BottomToTop1);
                    page.Items.AddChild(edge);

                    edge.GlueBeginToGeometryIntersection(mother);
                    edge.GlueEndToShape(node);
                }
            }
        }
Exemple #9
0
        /// <summary>
        /// Creates an ellipse shapeand applies the specified class to ut (used for Start and End shapes)
        /// </summary>
        /// <param name="bounds"></param>
        /// <param name="userClass"></param>
        /// <returns></returns>
        NShape CreateEllipse(NRectangle bounds, string userClass)
        {
            NBasicShapeFactory factory = new NBasicShapeFactory();
            NShape             shape   = factory.CreateShape(ENBasicShape.Ellipse);

            shape.SetBounds(bounds);
            shape.UserClass = userClass;
            m_DrawingDocument.Content.ActivePage.Items.Add(shape);
            return(shape);
        }
Exemple #10
0
        private void CreateRectanglePrototype()
        {
            Path   myPath = new Path();
            string type   = "Rectangle";

            myPath.Tag = type;
            NRectangle rectangle = new NRectangle(myPath);

            prototypedFigures.Add(type, rectangle);
        }
Exemple #11
0
        private void UpdateOuputPath()
        {
            NRectangle bounds = new NRectangle();
            int        count  = m_InputPaths.Count;

            // compute the ouput path and the bounds
            if (count != 0)
            {
                NRegion result = NRegion.FromPath(m_InputPaths[0], ENFillRule.EvenOdd);
                bounds = result.Bounds;

                for (int i = 1; i < count; i++)
                {
                    NRegion operand = NRegion.FromPath(m_InputPaths[i], ENFillRule.EvenOdd);
                    bounds = NRectangle.Union(bounds, operand.Bounds);

                    switch (m_OperatorCombo.SelectedIndex)
                    {
                    case 0:                             // union
                        result = result.Union(operand);
                        break;

                    case 1:                             // intersection
                        result = result.Intersect(operand);
                        break;

                    case 2:
                        result = result.Subtract(operand);
                        break;

                    case 3:
                        result = result.ExclusiveOr(operand);
                        break;
                    }
                }

                m_OutputPath = new NGraphicsPath(result.GetPath());
            }
            else
            {
                m_OutputPath = new NGraphicsPath();
            }

            // normalize the coordinates
            for (int i = 0; i < count; i++)
            {
                NGraphicsPath path = m_InputPaths[i];
                //NRectangle pathBounds = path.GetBounds();
                path.Translate(-bounds.X, -bounds.Y);
            }
            m_OutputPath.Translate(-bounds.X, -bounds.Y);

            m_Canvas.PreferredSize = new NSize(bounds.Width + 20, bounds.Height + 20);
            m_Canvas.InvalidateDisplay();
        }
Exemple #12
0
        /// <summary>
        /// Converts client size rectangle to window rectangle, according to window styles.
        /// </summary>
        /// <param name="clientRectangle">Client area bounding box.</param>
        /// <param name="windowStyle">Style of window to compute.</param>
        /// <param name="extendedWindowStyle">Extended style of window to compute.</param>
        public static NRectangle ConvertClientToWindowRect(NRectangle clientRectangle, long windowStyle, long extendedWindowStyle)
        {
            NRectangle tmp = clientRectangle;

            if (AdjustWindowRectEx(ref tmp, windowStyle, false, extendedWindowStyle))
            {
                return(tmp);
            }
            else
            {
                return(clientRectangle);
            }
        }
Exemple #13
0
        private void OnRandomRectButtonClick(NEventArgs args)
        {
            NRectangle rect = new NRectangle(m_Random.Next(500), m_Random.Next(500), m_Random.Next(500), m_Random.Next(500));

            rect.Normalize();

            NGraphicsPath path = new NGraphicsPath();

            path.AddRectangle(rect);

            m_InputPaths.Add(path);
            UpdateOuputPath();
        }
        /// <summary>
        /// Creates a predefined flow charting shape
        /// </summary>
        /// <param name="flowChartShape">flow charting shape</param>
        /// <param name="bounds">bounds</param>
        /// <param name="text">default label text</param>
        /// <param name="userClass">name of the stylesheet from which to inherit styles</param>
        /// <returns>new basic shape</returns>
        private NShape CreateFlowChartingShape(ENFlowchartingShape flowChartShape, NRectangle bounds, string text, string userClass)
        {
            // create shape
            NShape shape = new NFlowchartingShapeFactory().CreateShape(flowChartShape);

            // set bounds, text and user class
            shape.SetBounds(bounds);
            shape.Text      = text;
            shape.UserClass = userClass;

            // add to active page
            m_DrawingDocument.Content.ActivePage.Items.Add(shape);
            return(shape);
        }
Exemple #15
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="args"></param>
        private void OnCanvasPrePaint(NCanvasPaintEventArgs args)
        {
            NCanvas canvas = args.TargetNode as NCanvas;

            if (canvas == null)
            {
                return;
            }

            NPaintVisitor paintVisitor = args.PaintVisitor;

            NRectangle contentEge = canvas.GetContentEdge();

            // create the text bounds
            double width  = contentEge.Width * m_WidthPercentUpDown.Value / 100.0;
            double height = contentEge.Height * m_HeightPercentUpDown.Value / 100.0;
            NPoint center = contentEge.Center;

            NRectangle textBounds = new NRectangle(center.X - width / 2.0, center.Y - height / 2.0, width, height);

            // create the settings
            NPaintTextRectSettings settings = new NPaintTextRectSettings();

            settings.SingleLine = m_SingleLineCheckBox.Checked;
            settings.WrapMode   = (ENTextWrapMode)m_WrapModeCombo.SelectedIndex;
            settings.HorzAlign  = (ENTextHorzAlign)m_HorizontalAlignmentCombo.SelectedIndex;
            settings.VertAlign  = (ENTextVertAlign)m_VerticalAlignmentCombo.SelectedIndex;

            // create the text
            StringBuilder builder = new StringBuilder();

            builder.AppendLine("Paint text at bounds [" + textBounds.X.ToString("0.") + ", " + textBounds.Y.ToString("0.") + "]");
            builder.AppendLine("Horizontal Alignment [" + settings.HorzAlign.ToString() + "]");
            builder.AppendLine("Vertical Alignment [" + settings.VertAlign.ToString() + "]");

            // paint the bounding box
            paintVisitor.ClearStyles();
            paintVisitor.SetFill(NColor.LightBlue);
            paintVisitor.PaintRectangle(textBounds);

            // init font and fill
            paintVisitor.SetFill(NColor.Black);
            NFont font = new NFont(NFontDescriptor.DefaultSansFamilyName, 10);


            NGraphicsPath path = font.GetTextPath(builder.ToString(), textBounds, this.OwnerDocument, ref settings);

            paintVisitor.PaintPath(path);
        }
        void OnTimerTick()
        {
            NPoint       centerOfRotation = new NPoint(m_DrawingDocument.Content.ActivePage.Bounds.CenterX, 300);
            const double radius           = 150;

            NPoint beginCenter = centerOfRotation + new NPoint(Math.Cos(m_dAngle) * radius, Math.Sin(m_dAngle) * radius);

            m_BeginShape.SetBounds(NRectangle.FromCenterAndSize(beginCenter, m_BeginShape.Width, m_BeginShape.Height));

            NPoint endCenter = centerOfRotation + new NPoint(Math.Cos(m_dAngle + NMath.PI) * radius, Math.Sin(m_dAngle + NMath.PI) * radius);

            m_EndShape.SetBounds(NRectangle.FromCenterAndSize(endCenter, m_EndShape.Width, m_EndShape.Height));

            m_dAngle += NMath.PI / 180;
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="args"></param>
        private void OnCanvasPrePaint(NCanvasPaintEventArgs args)
        {
            NCanvas canvas = args.TargetNode as NCanvas;

            if (canvas == null)
            {
                return;
            }

            NPaintVisitor paintVisitor = args.PaintVisitor;

            NRectangle contentEge = canvas.GetContentEdge();

            // create the text bounds
            double width  = contentEge.Width * 0.5;
            double height = contentEge.Height * 0.5;
            NPoint center = contentEge.Center;

            NRectangle textBounds = new NRectangle(center.X - width / 2.0, center.Y - height / 2.0, width, height);

            // create the settings
            NPaintTextRectSettings settings = new NPaintTextRectSettings();

            settings.SingleLine = false;
            settings.WrapMode   = ENTextWrapMode.WordWrap;
            settings.HorzAlign  = ENTextHorzAlign.Center;
            settings.VertAlign  = ENTextVertAlign.Center;

            // create the text
            StringBuilder builder = new StringBuilder();

            builder.AppendLine("This text is displayed using Liberation Fonts!");
            builder.AppendLine("distributed under the SIL Open Font License (OFL)");

            // paint the bounding box
            paintVisitor.ClearStyles();
            paintVisitor.SetFill(NColor.LightBlue);
            paintVisitor.PaintRectangle(textBounds);

            // init font and fill
            paintVisitor.SetFill(NColor.Black);
            ENFontStyle fontStyle = NFontFaceDescriptor.FontVariantToFontStyle(m_FontDescriptor.FontVariant);

            paintVisitor.SetFont(new NFont(m_FontDescriptor.FamilyName, 10, fontStyle));

            // paint the text
            paintVisitor.PaintString(textBounds, builder.ToString(), ref settings);
        }
        void PaintCustomBackground(NTreeListPaintContext context, NTreeListColumnHeader item)
        {
            NRectangle bounds = context.PaintBounds;

            bounds.Inflate(0, -1);

            Rectangle gdiRect = bounds.ToRectangle();

            Color c1 = Color.Empty;
            Color c2 = Color.Empty;

            switch (item.VisualState)
            {
            case ItemVisualState.Normal:
                c1 = Color.FloralWhite;
                c2 = Color.Chocolate;
                break;

            case ItemVisualState.Hot:
                c1 = Color.Orange;
                c2 = Color.Red;
                break;

            case ItemVisualState.Pressed:
                c1 = Color.Red;
                c2 = Color.Orange;
                break;
            }

            LinearGradientBrush br = new LinearGradientBrush(gdiRect, c1, c2, 90F);

            context.Graphics.FillRectangle(br, gdiRect);

            br.Dispose();

            if (item.Owner.VisibleIndex == 0)
            {
                return;
            }

            Pen p = new Pen(Color.Black);

            context.Graphics.DrawLine(p, bounds.X - 1, bounds.Y + 3, bounds.X - 1, bounds.Bottom - 4);
            p.Color = Color.Wheat;
            context.Graphics.DrawLine(p, bounds.X, bounds.Y + 4, bounds.X, bounds.Bottom - 3);

            p.Dispose();
        }
Exemple #19
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="args"></param>
        private void OnCanvasPrePaint(NCanvasPaintEventArgs args)
        {
            NCanvas canvas = args.TargetNode as NCanvas;

            if (canvas == null)
            {
                return;
            }

            NPaintVisitor paintVisitor = args.PaintVisitor;
            NRectangle    contentEge   = canvas.GetContentEdge();

            // create the settings
            NPaintTextRectSettings settings = new NPaintTextRectSettings();

            settings.SingleLine = false;
            settings.WrapMode   = ENTextWrapMode.WordWrap;
            settings.HorzAlign  = ENTextHorzAlign.Left;
            settings.VertAlign  = ENTextVertAlign.Top;

            // create the text
            string text = m_TextBox.Text;

            // calculate the text bounds the text bounds
            double resolution = canvas.OwnerDocument.GetEffectiveResolution();
            NFont  font       = new NFont(NFontDescriptor.DefaultSansFamilyName, 10, ENFontStyle.Regular);
            NSize  textSize   = font.MeasureString(text.ToCharArray(), resolution, contentEge.Width, false, ref settings);

            NPoint     center     = contentEge.Center;
            NRectangle textBounds = new NRectangle(
                center.X - textSize.Width / 2.0,
                center.Y - textSize.Height / 2.0,
                textSize.Width,
                textSize.Height);

            // paint the bounding box
            paintVisitor.ClearStyles();
            paintVisitor.SetFill(NColor.LightBlue);
            paintVisitor.PaintRectangle(textBounds);

            // init font and fill
            paintVisitor.SetFill(NColor.Black);
            paintVisitor.SetFont(font);

            // paint the text
            paintVisitor.PaintString(textBounds, text.ToCharArray(), ref settings);
        }
Exemple #20
0
        public override void PostPaintItem(NTreeListNodeSubItem item, NTreeListPaintContext context)
        {
            Font orig    = context.Font;
            Font newFont = null;

            NRectangle bounds = context.TreeList.GetSubItemRect(item);

            switch (item.ItemType)
            {
            case TreeListNodeSubItemType.String:
                if (item.Owner.IsEven)
                {
                    newFont = new Font(orig, FontStyle.Strikeout);
                }
                else
                {
                    newFont = new Font(orig, FontStyle.Italic);
                }
                break;

            case TreeListNodeSubItemType.Numeric:
            case TreeListNodeSubItemType.DateTime:
                if (item.Owner.IsEven == false)
                {
                    newFont = new Font(orig, FontStyle.Strikeout);
                }
                else
                {
                    newFont = new Font(orig, FontStyle.Italic);
                }
                break;
            }

            if (newFont != null)
            {
                context.Font = newFont;
            }

            base.PostPaintItem(item, context);

            if (newFont != null)
            {
                newFont.Dispose();
            }

            context.Font = orig;
        }
Exemple #21
0
        protected override NWidget CreateExampleContent()
        {
            m_PositionX = 100;
            m_PositionY = 220;
            m_Angle1    = -50;
            m_Angle2    = 40;
            m_Angle3    = 90;
            m_ClipRect  = new NRectangle(20, 20, 500, 360);

            m_Canvas = new NCanvas();
            m_Canvas.PreferredSize       = new NSize(600, 400);
            m_Canvas.BackgroundFill      = new NColorFill(new NColor(220, 220, 200));
            m_Canvas.HorizontalPlacement = ENHorizontalPlacement.Center;
            m_Canvas.VerticalPlacement   = ENVerticalPlacement.Center;
            m_Canvas.PrePaint           += new Function <NCanvasPaintEventArgs>(OnCanvasPrePaint);

            NScrollContent scroll = new NScrollContent();

            scroll.Content        = m_Canvas;
            scroll.NoScrollHAlign = ENNoScrollHAlign.Center;
            scroll.NoScrollVAlign = ENNoScrollVAlign.Center;
            return(scroll);
        }
Exemple #22
0
        /// <summary>
        /// Performs the element post-children custom paint. Overriden to paint the status
        /// of this category header's group (if it has one) in the top-right corner of the header.
        /// </summary>
        /// <param name="visitor"></param>
        protected override void OnPostPaint(NPaintVisitor visitor)
        {
            base.OnPostPaint(visitor);

            if (String.IsNullOrEmpty(m_Status))
            {
                return;
            }

            // Determine the text bounds
            NRectangle bounds     = GetContentEdge();
            NSize      textSize   = Font.MeasureString(((NLabel)Box2).Text);
            NRectangle textBounds = NRectangle.FromCenterAndSize(bounds.Center, textSize.Width, textSize.Height);

            textBounds.X += Box1.Width / 2;

            // Calculate a rectangle for the status text located to the right of the text rectangle
            textSize = StatusFont.MeasureString(m_Status, OwnerDocument);
            NRectangle textRect = new NRectangle(textBounds.Right + StatusLeftPadding, textBounds.Top,
                                                 textSize.Width + StatusRightPadding, textSize.Height);

            // Paint the text background
            NExamplesHomePage homePage = (NExamplesHomePage)GetFirstAncestor(NExamplesHomePage.NExamplesHomePageSchema);
            NColor            color    = homePage.GetStatusColor(m_Status);

            visitor.SetFill(color);
            visitor.PaintRectangle(textRect);

            // Paint the text
            visitor.SetFill(NColor.White);
            visitor.SetFont(StatusFont);

            NPoint location = textRect.Location;
            NPaintTextPointSettings settings = new NPaintTextPointSettings();

            visitor.PaintString(location, m_Status, ref settings);
        }
Exemple #23
0
            public override NMatrix Calibrate(NPaintVisitor visitor, double imgWidth, double imgHeight, NRectangle targetRect)
            {
                // Initialize the image transform
                NMatrix matrix = NMatrix.Identity;

                // Scale the image so that it fits 2 times in width and 3 times in height
                matrix.Scale(
                    NCustomTextureMappingExample.RectWidth / (2.0 * imgWidth),
                    NCustomTextureMappingExample.RectHeight / (3.0 * imgHeight));

                // Rotate the image to the specified angle
                matrix.Rotate(m_TextureMapping.TextureAngle * NAngle.Degree2Rad);

                // Translate the image to the specfied pin point
                matrix.Translate(m_TextureMapping.PinPoint.X, m_TextureMapping.PinPoint.Y);

                return(matrix);
            }
        /// <summary>
        /// Overriden to create the triangular grid template in the specified document
        /// </summary>
        /// <param name="document">document in which to create the template</param>
        protected override void CreateTemplate(NDrawingDocument document)
        {
            NPage      page           = document.Content.ActivePage;
            NRectangle templateBounds = new NRectangle(m_Origin.X, m_Origin.Y,
                                                       m_nLevels * m_VerticesSize.Width + (m_nLevels - 1) * m_fHorizontalSpacing,
                                                       m_nLevels * m_VerticesSize.Height + (m_nLevels - 1) * m_fVerticalSpacing);
            NPoint location;
            NShape cur = null, prev = null;
            NShape edge = null;

            NList <NShape> curRowNodes  = null;
            NList <NShape> prevRowNodes = null;

            for (int level = 1; level <= m_nLevels; level++)
            {
                // determine the location of the first node in the level
                location = new NPoint(templateBounds.X + (templateBounds.Width - level * m_VerticesSize.Width - (level - 1) * m_fHorizontalSpacing) / 2,
                                      templateBounds.Y + (level - 1) * (m_VerticesSize.Height + m_fVerticalSpacing));

                curRowNodes = new NList <NShape>();
                for (int i = 0; i < level; i++)
                {
                    cur = CreateVertex(m_VerticesShape);
                    cur.SetBounds(new NRectangle(location, m_VerticesSize));
                    page.Items.AddChild(cur);

                    location.X += m_VerticesSize.Width + m_fHorizontalSpacing;

                    // connect the current node with its ancestors and prev node
                    if (m_bConnectGrid == false)
                    {
                        continue;
                    }

                    // connect with prev
                    if (i > 0)
                    {
                        edge = CreateEdge(ENConnectorShape.Line);
                        page.Items.AddChild(edge);

                        edge.GlueBeginToGeometryIntersection(prev);
                        edge.GlueEndToShape(cur);
                    }

                    // connect with ancestors
                    if (level > 1)
                    {
                        if (i < prevRowNodes.Count)
                        {
                            edge = CreateEdge(ENConnectorShape.Line);
                            page.Items.AddChild(edge);

                            edge.GlueBeginToGeometryIntersection((NShape)prevRowNodes[i]);
                            edge.GlueEndToShape(cur);
                        }

                        if (i > 0)
                        {
                            edge = CreateEdge(ENConnectorShape.Line);
                            page.Items.AddChild(edge);

                            edge.GlueBeginToGeometryIntersection((NShape)prevRowNodes[i - 1]);
                            edge.GlueEndToShape(cur);
                        }
                    }

                    curRowNodes.Add(cur);
                    prev = cur;
                }

                prevRowNodes = curRowNodes;
            }
        }
Exemple #25
0
 public static extern bool GetClientRect(IntPtr handle, out NRectangle rect);
Exemple #26
0
 public static extern bool GetWindowRect(IntPtr handle, out NRectangle rect);
Exemple #27
0
        private NShape CreateAndShape()
        {
            NShape shape = new NShape();

            shape.Init2DShape();

            NSize         normalSize = new NSize(1, 1);
            NGraphicsPath path       = new NGraphicsPath();

            // create input lines
            double x1 = 0;
            double y1 = normalSize.Height / 3;

            path.StartFigure(x1, y1);
            path.LineTo(normalSize.Width / 4, y1);

            double y2 = normalSize.Height * 2 / 3;
            double x2 = 0;

            path.StartFigure(x2, y2);
            path.LineTo(normalSize.Width / 4, y2);

            // create body
            path.StartFigure(normalSize.Width / 4, 0);
            path.LineTo(normalSize.Width / 4, 1);
            NPoint ellipseCenter = new  NPoint(normalSize.Width / 4, 0.5);

            path.AddEllipseSegment(NRectangle.FromCenterAndSize(ellipseCenter, normalSize.Width, normalSize.Height), NMath.PIHalf, -NMath.PI);
            path.CloseFigure();

            // create output
            double y3 = normalSize.Height / 2;
            double x3 = normalSize.Width;

            path.StartFigure(normalSize.Width * 3 / 4, y3);
            path.LineTo(x3, y3);

            shape.Geometry.AddRelative(new NDrawPath(new NRectangle(0, 0, 1, 1), path));

            // create ports
            NPort input1 = new NPort();

            input1.X        = x1;
            input1.Y        = y1;
            input1.Relative = true;
            input1.SetDirection(ENBoxDirection.Left);
            input1.FlowMode = ENPortFlowMode.Input;
            shape.Ports.Add(input1);

            NPort input2 = new NPort();

            input2.X        = x2;
            input2.Y        = y2;
            input2.Relative = true;
            input2.SetDirection(ENBoxDirection.Left);
            input2.FlowMode = ENPortFlowMode.Input;
            shape.Ports.Add(input2);

            NPort output1 = new NPort();

            output1.X        = x3;
            output1.Y        = y3;
            output1.Relative = true;
            output1.SetDirection(ENBoxDirection.Right);
            output1.FlowMode = ENPortFlowMode.Output;
            shape.Ports.Add(output1);

            // by default this shape does not accept shape-to-shape connections
            shape.DefaultShapeGlue = ENDefaultShapeGlue.None;

            // set text
            shape.Text = "AND";

            return(shape);
        }
        protected override void InitDiagram()
        {
            base.InitDiagram();

            NStyleSheet sheet = new NStyleSheet();

            m_DrawingDocument.StyleSheets.Add(sheet);

            // create a rule that applies to the geometries of all shapes with user class Connectors
            const string connectorsClass = "Connector";
            {
                NRule rule = sheet.CreateRule(delegate(NSelectorBuilder sb)
                {
                    sb.Type(NGeometry.NGeometrySchema); sb.ChildOf(); sb.UserClass(connectorsClass);
                });
                rule.AddValueDeclaration <NArrowhead>(NGeometry.EndArrowheadProperty, new NArrowhead(ENArrowheadShape.TriangleNoFill), true);
            }

            // create a rule that applies to the TextBlocks of all shapes with user class Connectors
            {
                NRule rule = sheet.CreateRule(delegate(NSelectorBuilder sb)
                {
                    sb.Type(NTextBlock.NTextBlockSchema); sb.ChildOf(); sb.UserClass(connectorsClass);
                });
                rule.AddValueDeclaration <NFill>(NTextBlock.BackgroundFillProperty, new NColorFill(NColor.White));
            }

            // create a rule that applies to shapes with user class  "STARTEND"
            {
                NRule rule = sheet.CreateRule(delegate(NSelectorBuilder sb)
                {
                    sb.Type(NGeometry.NGeometrySchema); sb.ChildOf(); sb.UserClass("STARTEND");
                });
                rule.AddValueDeclaration <NFill>(NGeometry.FillProperty, new NStockGradientFill(ENGradientStyle.Horizontal, ENGradientVariant.Variant1, new NColor(247, 150, 56), new NColor(251, 203, 156)));
            }

            // create a rule that applies to shapes with user class  "QUESTION"
            {
                NRule rule = sheet.CreateRule(delegate(NSelectorBuilder sb)
                {
                    sb.Type(NGeometry.NGeometrySchema); sb.ChildOf(); sb.UserClass("QUESTION");
                });
                rule.AddValueDeclaration <NFill>(NGeometry.FillProperty, new NStockGradientFill(ENGradientStyle.Horizontal, ENGradientVariant.Variant1, new NColor(129, 133, 133), new NColor(192, 194, 194)));
            }

            // create a rule that applies to shapes with user class  "ACTION"
            {
                NRule rule = sheet.CreateRule(delegate(NSelectorBuilder sb)
                {
                    sb.Type(NGeometry.NGeometrySchema); sb.ChildOf(); sb.UserClass("ACTION");
                });
                rule.AddValueDeclaration <NFill>(NGeometry.FillProperty, new NStockGradientFill(ENGradientStyle.Horizontal, ENGradientVariant.Variant1, new NColor(68, 90, 108), new NColor(162, 173, 182)));
            }

            // get drawing and active page
            NDrawing drawing    = m_DrawingDocument.Content;
            NPage    activePage = drawing.ActivePage;

            // hide ports and grid
            drawing.ScreenVisibility.ShowGrid  = false;
            drawing.ScreenVisibility.ShowPorts = false;

            NBasicShapeFactory        basicShapesFactory        = new NBasicShapeFactory();
            NFlowchartingShapeFactory flowChartingShapesFactory = new NFlowchartingShapeFactory();
            NConnectorShapeFactory    connectorShapesFactory    = new NConnectorShapeFactory();

            NRectangle bounds;

            int vSpacing   = 35;
            int hSpacing   = 45;
            int topMargin  = 10;
            int leftMargin = 10;

            int shapeWidth  = 90;
            int shapeHeight = 55;

            int col1 = leftMargin;
            int col2 = col1 + shapeWidth + hSpacing;
            int col3 = col2 + shapeWidth + hSpacing;
            int col4 = col3 + shapeWidth + hSpacing;

            int row1 = topMargin;
            int row2 = row1 + shapeHeight + vSpacing;
            int row3 = row2 + shapeHeight + vSpacing;
            int row4 = row3 + shapeHeight + vSpacing;
            int row5 = row4 + shapeHeight + vSpacing;
            int row6 = row5 + shapeHeight + vSpacing;

            bounds = new NRectangle(col2, row1, shapeWidth, shapeHeight);
            NShape start = CreateFlowChartingShape(ENFlowchartingShape.Termination, bounds, "START", "STARTEND");

            // row 2
            bounds = new NRectangle(col2, row2, shapeWidth, shapeHeight);
            NShape haveSerialNumber = CreateFlowChartingShape(ENFlowchartingShape.Decision, bounds, "Have a serial number?", "QUESTION");

            bounds = new NRectangle(col3, row2, shapeWidth, shapeHeight);
            NShape getSerialNumber = CreateFlowChartingShape(ENFlowchartingShape.Process, bounds, "Get serial number", "ACTION");

            // row 3
            bounds = new NRectangle(col1, row3, shapeWidth, shapeHeight);
            NShape enterSerialNumber = CreateFlowChartingShape(ENFlowchartingShape.Process, bounds, "Enter serial number", "ACTION");

            bounds = new NRectangle(col2, row3, shapeWidth, shapeHeight);
            NShape haveDiskSpace = CreateFlowChartingShape(ENFlowchartingShape.Decision, bounds, "Have disk space?", "QUESTION");

            bounds = new NRectangle(col3, row3, shapeWidth, shapeHeight);
            NShape freeUpSpace = CreateFlowChartingShape(ENFlowchartingShape.Process, bounds, "Free up space", "ACTION");

            // row 4
            bounds = new NRectangle(col1, row4, shapeWidth, shapeHeight);
            NShape runInstallRect = CreateFlowChartingShape(ENFlowchartingShape.Process, bounds, "Run install file", "ACTION");

            bounds = new NRectangle(col2, row4, shapeWidth, shapeHeight);
            NShape registerNow = CreateFlowChartingShape(ENFlowchartingShape.Decision, bounds, "Register now?", "QUESTION");

            bounds = new NRectangle(col3, row4, shapeWidth, shapeHeight);
            NShape fillForm = CreateFlowChartingShape(ENFlowchartingShape.Process, bounds, "Fill out form", "ACTION");

            bounds = new NRectangle(col4, row4, shapeWidth, shapeHeight);
            NShape submitForm = CreateFlowChartingShape(ENFlowchartingShape.Process, bounds, "Submit form", "ACTION");

            // row 5
            bounds = new NRectangle(col1, row5, shapeWidth, shapeHeight);
            NShape finishInstall = CreateFlowChartingShape(ENFlowchartingShape.Process, bounds, "Finish installation", "ACTION");

            bounds = new NRectangle(col2, row5, shapeWidth, shapeHeight);
            NShape restartNeeded = CreateFlowChartingShape(ENFlowchartingShape.Decision, bounds, "Restart needed?", "QUESTION");

            bounds = new NRectangle(col3, row5, shapeWidth, shapeHeight);
            NShape restart = CreateFlowChartingShape(ENFlowchartingShape.Process, bounds, "Restart", "ACTION");

            // row 6
            bounds = new NRectangle(col2, row6, shapeWidth, shapeHeight);
            NShape run = CreateFlowChartingShape(ENFlowchartingShape.Process, bounds, "RUN", "STARTEND");

            // create connectors
            CreateConnector(start, "Bottom", haveSerialNumber, "Top", ENConnectorShape.Line, "");
            CreateConnector(getSerialNumber, "Top", haveSerialNumber, "Top", ENConnectorShape.RoutableConnector, "");
            CreateConnector(haveSerialNumber, "Right", getSerialNumber, "Left", ENConnectorShape.Line, "No");
            CreateConnector(haveSerialNumber, "Bottom", enterSerialNumber, "Top", ENConnectorShape.BottomToTop1, "Yes");
            CreateConnector(enterSerialNumber, "Right", haveDiskSpace, "Left", ENConnectorShape.Line, "");
            CreateConnector(freeUpSpace, "Top", haveDiskSpace, "Top", ENConnectorShape.RoutableConnector, "");
            CreateConnector(haveDiskSpace, "Right", freeUpSpace, "Left", ENConnectorShape.Line, "No");
            CreateConnector(haveDiskSpace, "Bottom", runInstallRect, "Top", ENConnectorShape.BottomToTop1, "Yes");
            CreateConnector(registerNow, "Right", fillForm, "Left", ENConnectorShape.Line, "Yes");
            CreateConnector(registerNow, "Bottom", finishInstall, "Top", ENConnectorShape.BottomToTop1, "No");
            CreateConnector(fillForm, "Right", submitForm, "Left", ENConnectorShape.Line, "");
            CreateConnector(submitForm, "Bottom", finishInstall, "Top", ENConnectorShape.BottomToTop1, "");
            CreateConnector(finishInstall, "Right", restartNeeded, "Left", ENConnectorShape.Line, "");
            CreateConnector(restart, "Bottom", run, "Top", ENConnectorShape.BottomToTop1, "");
            CreateConnector(restartNeeded, "Right", restart, "Left", ENConnectorShape.Line, "Yes");
            CreateConnector(restartNeeded, "Bottom", run, "Top", ENConnectorShape.Line, "No");
        }
Exemple #29
0
 public static extern bool AdjustWindowRectEx(ref NRectangle clientToWindowRect, long windowStyle, bool hasMenu, long extendedWindowStyle);
            private NBorderWall CreateCrossBorderWall()
            {
                NRectangle r0 = GetContentEdge();

                NMargins bt = BorderThickness;

                bt.Left   = Math.Min(bt.Left, r0.Width / 6);
                bt.Right  = Math.Min(bt.Right, r0.Width / 6);
                bt.Top    = Math.Min(bt.Top, r0.Height / 6);
                bt.Bottom = Math.Min(bt.Bottom, r0.Height / 6);

                NRectangle r1 = bt.GetInnerRect(r0);

                NRectangle r2 = NRectangle.FromLTRB(
                    r1.X + r1.Width / 3 - (bt.Left / 2),
                    r1.Y + r1.Height / 3 - (bt.Top / 2),
                    r1.Right - r1.Width / 3 + (bt.Right / 2),
                    r1.Bottom - r1.Height / 3 + (bt.Bottom / 2));

                NRectangle r3 = bt.GetInnerRect(r2);

                double x0 = r0.X;
                double x1 = r1.X;
                double x2 = r2.X;
                double x3 = r3.X;
                double x4 = r3.Right;
                double x5 = r2.Right;
                double x6 = r1.Right;
                double x7 = r0.Right;

                double y0 = r0.Y;
                double y1 = r1.Y;
                double y2 = r2.Y;
                double y3 = r3.Y;
                double y4 = r3.Bottom;
                double y5 = r2.Bottom;
                double y6 = r1.Bottom;
                double y7 = r0.Bottom;

                NBorderWall wall = new NBorderWall(true);

                wall.AddLeftTopCorner(new NRectangle(x2, y0, bt.Left, bt.Top));
                wall.AddTopSide(new NRectangle(x3, y0, x4 - x3, bt.Top));
                wall.AddTopRightCorner(new NRectangle(x4, y0, bt.Right, bt.Top));
                wall.AddRightSide(new NRectangle(x4, y1, bt.Right, y2 - y1));
                wall.AddRightTopCorner(new NRectangle(x4, y2, bt.Right, bt.Top));
                wall.AddTopSide(new NRectangle(x5, y2, x6 - x5, bt.Top));
                wall.AddTopRightCorner(new NRectangle(x6, y2, bt.Right, bt.Top));
                wall.AddRightSide(new NRectangle(x6, y3, bt.Right, y4 - y3));
                wall.AddRightBottomCorner(new NRectangle(x6, y4, bt.Right, bt.Bottom));
                wall.AddBottomSide(new NRectangle(x5, y4, x6 - x5, bt.Bottom));
                wall.AddBottomRightCorner(new NRectangle(x4, y4, bt.Right, bt.Bottom));
                wall.AddRightSide(new NRectangle(x4, y5, bt.Right, y6 - y5));
                wall.AddRightBottomCorner(new NRectangle(x4, y6, bt.Right, bt.Bottom));
                wall.AddBottomSide(new NRectangle(x3, y6, x4 - x3, bt.Bottom));
                wall.AddBottomLeftCorner(new NRectangle(x2, y6, bt.Left, bt.Bottom));
                wall.AddLeftSide(new NRectangle(x2, y5, bt.Left, y6 - y5));
                wall.AddLeftBottomCorner(new NRectangle(x2, y4, bt.Left, bt.Bottom));
                wall.AddBottomSide(new NRectangle(x1, y4, x2 - x1, bt.Bottom));
                wall.AddBottomLeftCorner(new NRectangle(x0, y4, bt.Left, bt.Bottom));
                wall.AddLeftSide(new NRectangle(x0, y3, bt.Left, y4 - y3));
                wall.AddLeftTopCorner(new NRectangle(x0, y2, bt.Left, bt.Top));
                wall.AddTopSide(new NRectangle(x1, y2, x2 - x1, bt.Top));
                wall.AddTopLeftCorner(new NRectangle(x2, y2, bt.Left, bt.Top));
                wall.AddLeftSide(new NRectangle(x2, y1, bt.Left, y2 - y1));

                return(wall);
            }