Example #1
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);
        }
Example #2
0
 /// <summary>
 /// 添加节点
 /// </summary>
 /// <param name="np"></param>
 public void Add(NPoint np)
 {
     if (np.bSucess)
     {
         listPoint.Add(np);
     }
 }
        /// <summary>
        /// 在未QC库中搜索
        /// </summary>
        private void _searchNotQC(List <SearchItem> list, NnExcel ne)
        {
            StockInfos infos = new StockInfos();

            try
            {
                using (OleDbCommand cmd = new OleDbCommand())
                {
                    cmd.Connection = m_connection;
                    foreach (var v in list)
                    {
                        if (string.IsNullOrWhiteSpace(v.Value))
                        {
                            continue;
                        }
                        if (v.SearchType == SearchType.WorkNo)
                        {
                            _initNotQCWorkNoSearch(infos, cmd, v);
                        }
                        else
                        {
                            _initNotQCCoordinateAndOrderIDSearch(infos, cmd, v);
                        }
                    }
                }
                object[][] vs = infos.GetValues();

                ne.AddValueWithName(vs, 1, 9, "半纯品");
                ne.AutoFit(new int[] { 2, 3, 4, 8 });
                ne.SetColor(NPoint.GetPoint(1, 1), NPoint.GetPoint(1, 7), NnExcel.ColorType.Blue);
                ne.SetColor(NPoint.GetPoint(infos.CountNormal + 2, 1), NPoint.GetPoint(infos.CountNormal + 3, 9), NnExcel.ColorType.Blue);
            }
            catch (Exception e) { Console.WriteLine(e.ToString()); }
        }
Example #4
0
        public void TestGenerateChain()
        {
            HanselChain hc1 = new HanselChain();
            NPoint      p1  = new NPoint();
            NPoint      p2  = new NPoint();

            p2.x = new List <int>()
            {
                0
            };
            p1.x = new List <int>()
            {
                1
            };
            hc1.chain.Add(p1);
            hc1.chain.Add(p2);
            List <HanselChain> ls = new List <HanselChain>();

            ls.Add(hc1);
            List <HanselChain> result = Form1.GenerateNdimCubeAndHanselChain(2, 1, ls);

            Console.Out.WriteLine(String.Format("We get {0} HanselChain(s)", result.Count));
            foreach (HanselChain hc in result)
            {
                Console.Out.WriteLine(hc.ToString());
            }
        }
Example #5
0
        /// <summary>
        /// 得到地图点
        /// 判断是否超过边界, 并计算H G F 值
        /// </summary>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="nParent"></param>
        /// <returns></returns>
        private NPoint GetPoint(int x, int y, NPoint nParent)
        {
            NPoint np;

            np.X       = x;
            np.Y       = y;
            np.ParentX = nParent.X;
            np.ParentY = nParent.Y;
            np.bSucess = true;
            if (x < 0 || y < 0 || x >= map.Width || y >= map.Height || map.bitMap[x, y] != 0 || map.bitDynamic[x, y] != 0)
            {
                NPoint nd = nParent;
                nd.G       = 0;
                nd.bSucess = false;
                return(nd);
            }
            else
            {
                np.H       = (int)Mathf.Abs(nEnd.X - np.X) + (int)Mathf.Abs(nEnd.Y - np.Y) * 10;
                np.G       = CalcG(x, y, nParent);
                np.F       = np.H + np.G;
                np.bSucess = true;
                return(np);
            }
        }
Example #6
0
        public void RotateTest()
        {
            var expected = new NPoint(-1 * target.y, 1 * target.x);

            Rotator.Rotate(ref target, RtDirection.Clockwise);
            Assert.AreEqual(expected, target);
        }
Example #7
0
        /// <summary>Returns the child control of a window corresponding to a screen location.</summary>
        /// <param name="parent">Parent window to explore.</param>
        /// <param name="scrClickLocation">Child control location in screen coordinates.</param>
        private static IntPtr GetRealChildControlFromPoint(IntPtr parent, NPoint scrClickLocation)
        {
            IntPtr curr = parent, child = IntPtr.Zero;

            do
            {
                child = WindowManagerMethods.RealChildWindowFromPoint(curr,
                                                                      WindowManagerMethods.ScreenToClient(curr, scrClickLocation));

                if (child == IntPtr.Zero || child == curr)
                {
                    break;
                }

                //Update for next loop
                curr = child;
            }while (true);

            //Safety check, shouldn't happen
            if (curr == IntPtr.Zero)
            {
                curr = parent;
            }

            return(curr);
        }
Example #8
0
 internal override void Accept(FlatModel flatModel)
 {
     this.ID         = flatModel.ID;
     this.Text       = flatModel.Text;
     this.StartPoint = flatModel.StartPoint;
     this.EndPoint   = flatModel.EndPoint;
 }
        /// <summary>
        /// Gets the data point from the specified point
        /// </summary>
        /// <param name="point"></param>
        /// <returns></returns>
        protected int GetDataPointIndexFromPoint(NPoint point)
        {
            NPointSeries pointSeries = m_DragPlane.PointSeries;
            NChart       chart       = pointSeries.Chart;
            NModel3DToViewTransformation model3DToViewTransformation = new NModel3DToViewTransformation(GetView().Context, chart.Projection);

            float xHotSpotArea = 10;
            float yHotSpotArea = 10;

            int dataPointIndex = -1;

            for (int i = 0; i < pointSeries.Values.Count; i++)
            {
                double x = (double)pointSeries.XValues[i];
                double y = (double)pointSeries.Values[i];
                double z = (double)pointSeries.ZValues[i];

                NVector3DF vecModelPoint;
                vecModelPoint.X = chart.Axis(StandardAxis.PrimaryX).TransformScaleToModel(false, x);
                vecModelPoint.Y = chart.Axis(StandardAxis.PrimaryY).TransformScaleToModel(false, y);
                vecModelPoint.Z = chart.Axis(StandardAxis.Depth).TransformScaleToModel(false, z);

                NPointF viewPoint = NPointF.Empty;
                model3DToViewTransformation.Transform(vecModelPoint, ref viewPoint);

                if (Math.Abs(viewPoint.X - point.X) < xHotSpotArea &&
                    Math.Abs(viewPoint.Y - point.Y) < yHotSpotArea)
                {
                    dataPointIndex = i;
                    break;
                }
            }

            return(dataPointIndex);
        }
Example #10
0
        protected override void InitDiagram()
        {
            base.InitDiagram();

            m_DrawingDocument.HistoryService.Pause();
            try
            {
                NDrawing drawing    = m_DrawingDocument.Content;
                NPage    activePage = drawing.ActivePage;

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

                // Create all shapes
                NArrowShapeFactory factory = new NArrowShapeFactory();
                factory.DefaultSize = new NSize(60, 60);

                int    row = 0, col = 0;
                double cellWidth  = 180;
                double cellHeight = 120;

                for (int i = 0; i < factory.ShapeCount; i++, col++)
                {
                    NShape shape = factory.CreateShape(i);
                    shape.HorizontalPlacement = ENHorizontalPlacement.Center;
                    shape.VerticalPlacement   = ENVerticalPlacement.Center;
                    shape.Text = factory.GetShapeInfo(i).Name;
                    MoveTextBelowShape(shape);
                    activePage.Items.Add(shape);

                    if (col >= 5)
                    {
                        row++;
                        col = 0;
                    }

                    NPoint beginPoint = new NPoint(50 + col * cellWidth, 50 + row * cellHeight);
                    if (shape.ShapeType == ENShapeType.Shape1D)
                    {
                        NPoint endPoint = beginPoint + new NPoint(cellWidth - 100, cellHeight - 100);
                        shape.SetBeginPoint(beginPoint);
                        shape.SetEndPoint(endPoint);
                    }
                    else
                    {
                        shape.SetBounds(beginPoint.X, beginPoint.Y, shape.Width, shape.Height);
                    }
                }

                // size page to content
                activePage.Layout.ContentPadding = new NMargins(40);
                activePage.SizeToContent();
            }
            finally
            {
                m_DrawingDocument.HistoryService.Resume();
            }
        }
        private NShape CreateFlexiArrow2Shape(NPoint from, NPoint to)
        {
            NShape shape = new NShape();

            shape.Init1DShape(EN1DShapeXForm.Vector);

            shape.Height = 0;
            shape.BeginX = from.X;
            shape.BeginY = from.Y;
            shape.EndX   = to.X;
            shape.EndY   = to.Y;

            // add controls
            NControl controlPoint = new NControl();

            controlPoint.SetFx("X", "13.0956");
            controlPoint.SetFx("Y", "Height*0.75");
            controlPoint.Visible   = true;
            controlPoint.XBehavior = ENCoordinateBehavior.OffsetFromMin;
            controlPoint.YBehavior = ENCoordinateBehavior.OffsetFromMid;
            controlPoint.Tooltip   = "Modify arrowhead 1";
            shape.Controls.AddChild(controlPoint);

            controlPoint = new NControl();
            controlPoint.SetFx("X", "Width-40");
            controlPoint.SetFx("Y", "Height*1");
            controlPoint.Visible   = true;
            controlPoint.XBehavior = ENCoordinateBehavior.OffsetFromMax;
            controlPoint.YBehavior = ENCoordinateBehavior.OffsetFromMid;
            controlPoint.Tooltip   = "Modify arrowhead 2";
            shape.Controls.AddChild(controlPoint);

            controlPoint = new NControl();
            controlPoint.SetFx("X", "Width-20");
            controlPoint.SetFx("Y", "Height*1");
            controlPoint.Visible   = true;
            controlPoint.XBehavior = ENCoordinateBehavior.OffsetFromMax;
            controlPoint.YBehavior = ENCoordinateBehavior.OffsetFromMid;
            controlPoint.Tooltip   = "Modify arrowhead 3";
            shape.Controls.AddChild(controlPoint);

            // add a geometry
            NGeometry geometry   = new NGeometry();
            NMoveTo   plotFigure =
                geometry.MoveTo("Width*0", "Height*0.5");

            geometry.LineTo("Controls.0.X", "ABS(Controls.0.Y)");
            geometry.LineTo("Controls.1.X", "ABS(Controls.1.Y)");
            geometry.LineTo("Controls.2.X", "ABS(Controls.2.Y)");
            geometry.LineTo("Width", "Height*0.5");
            geometry.LineTo("Controls.2.X", "Height-Geometry.3.Y");
            geometry.LineTo("Controls.1.X", "Height-Geometry.2.Y");
            geometry.LineTo("Controls.0.X", "Height-Geometry.1.Y");
            geometry.LineTo("Geometry.0.X", "Geometry.0.Y");
            plotFigure.CloseFigure = true;
            shape.Geometry         = geometry;

            return(shape);
        }
Example #12
0
            /// <summary>
            ///
            /// </summary>
            /// <param name="i"></param>
            /// <param name="iParentX"></param>
            /// <param name="iParentY"></param>
            public void SetParent(int i, int iParentX, int iParentY)
            {
                NPoint n = listPoint[i];

                n.ParentX    = iParentX;
                n.ParentY    = iParentY;
                listPoint[i] = n;
            }
Example #13
0
        private static void InjectDoubleRightMouseClick(IntPtr child, NPoint clientLocation)
        {
            var lParamClickLocation = MessagingMethods.MakeLParam(clientLocation.X, clientLocation.Y);

            MessagingMethods.PostMessage(child, Wm.Rbuttondblclk, new IntPtr(Mk.Rbutton), lParamClickLocation);

            Log.Debug($"Double right click on window #{child} at {clientLocation}");
        }
Example #14
0
 /// <summary>
 /// 检查是否存在于关闭表
 /// </summary>
 /// <param name="npoint"></param>
 /// <returns></returns>
 public bool CheckClosePoint(NPoint npoint)
 {
     if (arrClose.Find(npoint) > -1)
     {
         return(true);
     }
     return(false);
 }
            public static void KNearestNeighbor(List <NPoint> input, NPoint point, int k)
            {
                input.Sort((x, y) => (Distance(x, point) - Distance(y, point)).CompareTo(0));
                //Select(x=>new{Class = x.Class, count = 1}).Aggregate
                var cl = input.Take(k).GroupBy(x => x.Class).Select(x => new { Class = x.Key, Count = x.Count() }).OrderByDescending(x => x.Count).First().Class;

                point.Class = cl;
            }
        void PaintTriangle(NPaintVisitor paintVisitor, double w, double h)
        {
            NPoint p1 = new NPoint(0.5 * w, 0.1 * h);
            NPoint p2 = new NPoint(0.9 * w, 0.9 * h);
            NPoint p3 = new NPoint(0.1 * w, 0.8 * h);

            paintVisitor.PaintTriangle(p1, p2, p3);
        }
Example #17
0
        internal static float DistanceToLine(NPoint StartPoint, NPoint EndPoint, int x, int y)
        {
            float A = x - StartPoint.X;
            float B = y - StartPoint.Y;
            float C = EndPoint.X - StartPoint.X;
            float D = EndPoint.Y - StartPoint.Y;

            return((float)(Math.Abs(A * D - C * B) / Math.Sqrt(C * C + D * D)));
        }
        void PaintQuadrangle(NPaintVisitor paintVisitor, double w, double h)
        {
            NPoint p1 = new NPoint(0.2 * w, 0.1 * h);
            NPoint p2 = new NPoint(0.6 * w, 0.1 * h);
            NPoint p3 = new NPoint(0.9 * w, 0.9 * h);
            NPoint p4 = new NPoint(0.1 * w, 0.6 * h);

            paintVisitor.PaintQuadrangle(p1, p2, p3, p4);
        }
Example #19
0
        private static void InjectLeftMouseClick(IntPtr child, NPoint clientLocation)
        {
            var lParamClickLocation = MessagingMethods.MakeLParam(clientLocation.X, clientLocation.Y);

            MessagingMethods.PostMessage(child, Wm.Lbuttondown, new IntPtr(Mk.Lbutton), lParamClickLocation);
            MessagingMethods.PostMessage(child, Wm.Lbuttonup, new IntPtr(Mk.Lbutton), lParamClickLocation);

            Log.Debug($"Left click on window #{child} at {clientLocation}");
        }
Example #20
0
        private static void InjectLeftMouseDown(IntPtr child, NPoint clientLocation)
        {
            IntPtr lParamClickLocation = MessagingMethods.MakeLParam(clientLocation.X, clientLocation.Y);

            MessagingMethods.PostMessage(child, WM.LBUTTONDOWN, new IntPtr(MK.LBUTTON), lParamClickLocation);
#if DEBUG
            System.Diagnostics.Debug.WriteLine("InjectLeftMouseDownMove #" + child.ToString() + " at " + clientLocation.ToString());
#endif
        }
Example #21
0
            /// <summary>
            /// 删除
            /// </summary>
            /// <param name="x"></param>
            /// <param name="y"></param>
            public void Remove(NPoint npoint)
            {
                int i = Find(npoint);

                if (i > -1)
                {
                    listPoint.RemoveAt(i);
                }
            }
Example #22
0
 protected void DrawVertex(Graphics graphics, NPoint point)
 {
     if (point != null)
     {
         NPoint s = point.Clone().Add(-NConfig.BLOCK_SIZE, -NConfig.BLOCK_SIZE);
         graphics.FillRectangle(Brushes.CornflowerBlue, s.X, s.Y, NConfig.BLOCK_SIZE_2, NConfig.BLOCK_SIZE_2);
         graphics.DrawRectangle(Pens.Red, s.X, s.Y, NConfig.BLOCK_SIZE_2, NConfig.BLOCK_SIZE_2);
     }
 }
        /// <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);
                }
            }
        }
Example #24
0
        private static void InjectDoubleRightMouseClick(IntPtr child, NPoint clientLocation)
        {
            IntPtr lParamClickLocation = MessagingMethods.MakeLParam(clientLocation.X, clientLocation.Y);

            MessagingMethods.PostMessage(child, WM.RBUTTONDBLCLK, new IntPtr(MK.RBUTTON), lParamClickLocation);

#if DEBUG
            System.Diagnostics.Debug.WriteLine("Double right click on window #" + child.ToString() + " at " + clientLocation.ToString());
#endif
        }
Example #25
0
        /// <summary>
        /// Sets the right top corner of a shape
        /// </summary>
        /// <param name="shape"></param>
        /// <param name="location"></param>
        void SetRightTop(NShape shape, NPoint location)
        {
            // align local pin to left/top corner so pin point can change the location
            shape.LocPinX        = 1;
            shape.LocPinY        = 0;
            shape.LocPinRelative = true;

            // set the pin point
            shape.SetPinPoint(location);
        }
        private static NGraphicsPath CreateCircleSegment(double w, double h)
        {
            double radius = 0.4 * NMath.Min(w, h);
            NPoint center = new NPoint(0.5 * w, 0.5 * h);

            NGraphicsPath path = new NGraphicsPath();

            path.AddCircleSegment(center, radius, 0.25 * NMath.PI, 1.5 * NMath.PI);
            return(path);
        }
            public static double Distance(NPoint a, NPoint b)
            {
                double sum = 0;

                for (int i = 0; i < a.X.Length; i++)
                {
                    sum += (a.X[i] - b.X[i]) * (a.X[i] - b.X[i]);
                }
                return(Math.Sqrt(sum));
            }
Example #28
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="np"></param>
 /// <returns></returns>
 public int FindParent(NPoint np)
 {
     for (int i = 0; i < listPoint.Count; i++)
     {
         if (np.ParentX == listPoint[i].X && np.ParentY == listPoint[i].Y)
         {
             return(i);
         }
     }
     return(-1);
 }
Example #29
0
        void PaintTriangle(NPaintVisitor paintVisitor, double w, double h)
        {
            paintVisitor.SetStroke(NColor.Black, 2);
            paintVisitor.SetFill(NColor.Crimson);

            NPoint p1 = new NPoint(0.5 * w, 0.2 * h);
            NPoint p2 = new NPoint(0.8 * w, 0.8 * h);
            NPoint p3 = new NPoint(0.2 * w, 0.7 * h);

            paintVisitor.PaintTriangle(p1, p2, p3);
        }
Example #30
0
        public Piece(Field field, int x, int y, PcType type, PcColor?color = null)
        {
            this.Field = field;
            this.pos   = new NPoint(x, y);
            this.Color = color ?? PC_CLRS[(int)type];

            var PcShp = PC_SHPS[(int)type];

            this.Shape = new NPoint[PcShp.Length];
            PcShp.CopyTo(this.Shape, 0);
        }