예제 #1
0
 public LineDetails(ILine line, IDelimiterFinder finder, string delimiter, int minIndex, int tabSize)
 {
     var withoutTabs = line.Text.ReplaceTabs(tabSize);
     Line            = line;
     Index           = finder.GetIndex(line.Text,   delimiter, minIndex, tabSize);
     Position        = finder.GetIndex(withoutTabs, delimiter, minIndex, tabSize);
 }
예제 #2
0
        public static void Reconnect(ICanvas canvas,
            ILine line, IElement splitPin,
            double x, double y,
            List<Connection> connections,
            ILine currentLine,
            IDiagramCreator creator)
        {
            var wire1 = connections[0].Wires.FirstOrDefault();
            var wire2 = connections[1].Wires.FirstOrDefault();
            var startRoot = (wire1.Start != null ? wire1.Start : wire2.Start) as IElement;
            var endRoot = (wire1.End != null ? wire1.End : wire2.End) as IElement;

            PointEx start;
            PointEx end;
            GetLocation(wire1, wire2, out start, out end);

            if (start != null && end != null)
            {
                var startLine = Connect(canvas, startRoot, currentLine, start.X, start.Y, creator);
                var splitLine = Connect(canvas, splitPin, startLine, x, y, creator);
                var endLine = Connect(canvas, splitPin, splitLine, x, y, creator);

                Connect(canvas, endRoot, endLine, start.X + end.X, start.Y + end.Y, creator);

                startLine.SetStartVisible(line.GetStartVisible());
                startLine.SetStartIO(line.GetStartIO());
                endLine.SetEndVisible(line.GetEndVisible());
                endLine.SetEndIO(line.GetEndIO());
            }
            else
            {
                throw new InvalidOperationException("LineEx must have Start and End points.");
            }
        }
예제 #3
0
        public cLimitAgregator(ILine owner, IProject project)
        {
            if(project == null || owner == null) throw new ArgumentNullException();

            _owner = owner;
            _project = project;
        }
예제 #4
0
 /// <summary>
 /// Initialize new instance of <see cref="LineSelection"/> class.
 /// </summary>
 /// <param name="layer">The selection shapes layer.</param>
 /// <param name="shape">The selected shape.</param>
 /// <param name="style">The selection shapes style.</param>
 /// <param name="point">The selection point shape.</param>
 public LineSelection(XLayer layer, ILine shape, ShapeStyle style, BaseShape point)
 {
     _layer = layer;
     _line = shape;
     _style = style;
     _point = point;
 }
        private IPoint[] CalculateIntersectionPoint(ILine line, ILine anotherLine)
        {
            double answer;
            if ((answer = GetHasIntersectionAnswer(line, anotherLine)) == 0)
                return new IPoint[0];

            var intersectionPointOnLine = (((anotherLine.EndingPoint.XCoordinate - anotherLine.StartingPoint.XCoordinate)*
                       (line.StartingPoint.YCoordinate - anotherLine.StartingPoint.YCoordinate)) -
                      ((anotherLine.EndingPoint.YCoordinate - anotherLine.StartingPoint.YCoordinate)*
                       (line.StartingPoint.XCoordinate - anotherLine.StartingPoint.XCoordinate)))/answer;

            var intersectionPointOnAnotherLine = (((line.EndingPoint.XCoordinate - line.StartingPoint.XCoordinate)*
                       (line.StartingPoint.YCoordinate - anotherLine.StartingPoint.YCoordinate)) -
                      ((line.EndingPoint.YCoordinate - line.StartingPoint.YCoordinate)*
                       (line.StartingPoint.XCoordinate - anotherLine.StartingPoint.XCoordinate)))/answer;

            if ((intersectionPointOnLine < 0) || (intersectionPointOnLine > 1) || (intersectionPointOnAnotherLine < 0) || (intersectionPointOnAnotherLine > 1))
            return new IPoint[0];

            return new IPoint[]
                {
                    new Point(
                        line.StartingPoint.XCoordinate +
                        intersectionPointOnLine*(line.EndingPoint.XCoordinate - line.StartingPoint.XCoordinate),
                        line.StartingPoint.YCoordinate +
                        intersectionPointOnLine*(line.EndingPoint.YCoordinate - line.StartingPoint.YCoordinate)
                        )
                };
        }
 private static void Normalize(ILine line, Line normalized)
 {
     var max = line.Max ?? 100.0;
     var stretch = (float)(100.0 / max);
     foreach (var point in line.Points)
         Normalize(point, normalized.AddPoint(point.Value*stretch, point.Timestamp));
 }
        internal double CostForLineSwitch(ILine from,
                                          Constants.LineDirection fromDirection,
                                          ILine to,
                                          Constants.LineDirection toDirection)
        {
            double cost = double.MaxValue;

            if ( fromDirection == Constants.LineDirection.Forward &&
                 toDirection == Constants.LineDirection.Forward )
            {
                cost = from.EndPoint.DistanceTo(to.StartPoint);
            }
            else if ( fromDirection == Constants.LineDirection.Forward &&
                      toDirection == Constants.LineDirection.Reverse )
            {
                cost = from.EndPoint.DistanceTo(to.EndPoint);
            }
            else if ( fromDirection == Constants.LineDirection.Reverse &&
                      toDirection == Constants.LineDirection.Forward )
            {
                cost = from.StartPoint.DistanceTo(to.StartPoint);
            }
            else if ( fromDirection == Constants.LineDirection.Reverse &&
                      toDirection == Constants.LineDirection.Reverse )
            {
                cost = from.StartPoint.DistanceTo(to.EndPoint);
            }

            return cost;
        }
        public ILine[] GetLines(IRectangle rectangle)
        {
            const uint linesInARectangle = 4;
            var lines = new ILine[linesInARectangle];

            lines[0] = _factory.CreateLine(rectangle.StartingPoint.XCoordinate,
                                           rectangle.StartingPoint.YCoordinate,
                                           rectangle.EndingPoint.XCoordinate,
                                           rectangle.StartingPoint.YCoordinate);

            lines[1] = _factory.CreateLine(rectangle.EndingPoint.XCoordinate,
                                           rectangle.StartingPoint.YCoordinate,
                                           rectangle.EndingPoint.XCoordinate,
                                           rectangle.EndingPoint.YCoordinate);

            lines[2] = _factory.CreateLine(rectangle.EndingPoint.XCoordinate,
                                           rectangle.EndingPoint.YCoordinate,
                                           rectangle.StartingPoint.XCoordinate,
                                           rectangle.EndingPoint.YCoordinate);

            lines[3] = _factory.CreateLine(rectangle.StartingPoint.XCoordinate,
                                           rectangle.EndingPoint.YCoordinate,
                                           rectangle.StartingPoint.XCoordinate,
                                           rectangle.StartingPoint.YCoordinate);

            return lines;
        }
예제 #9
0
파일: LineShape.cs 프로젝트: zyouhua/weilai
 public LineShape()
 {
     mPullPoint = new Point2I(default(int), default(int));
     mPullState = PullState_.mNone_;
     mLineStream = null;
     mLine = null;
 }
예제 #10
0
 public static void Convert(ILine oldLine, ILine newLine)
 {
     var drawing = oldLine.Drawing;
     newLine.Style = oldLine.Style;
     Actions.ReplaceWithNew(oldLine, newLine);
     drawing.RaiseUserIsAddingFigures(new Drawing.UIAFEventArgs() { Figures = newLine.AsEnumerable<IFigure>() });
 }
 private static void AssertLine(ILine actual,
                                int expectedId,
                                double expectedX1,
                                double expectedY1,
                                double expectedX2,
                                double expectedY2,
                                bool isUnknown,
                                Constants.LineDirection direction)
 {
     Assert.AreEqual(expectedId,
                     actual.Id,
                     "Id");
     Assert.AreEqual(expectedX1,
                     actual.X1,
                     "X1");
     Assert.AreEqual(expectedY1,
                     actual.Y1,
                     "Y1");
     Assert.AreEqual(expectedX2,
                     actual.X2,
                     "X2");
     Assert.AreEqual(expectedY2,
                     actual.Y2,
                     "Y2");
     Assert.AreEqual(isUnknown,
                     actual.IsUnknown,
                     "IsUnknown");
     Assert.AreEqual(direction,
                     actual.RunDirection,
                     "RunDirection");
 }
예제 #12
0
        public bool Contains(ILine innerLine)
        {
            //Derived from http://stackoverflow.com/questions/328107/how-can-you-determine-a-point-is-between-two-other-points-on-a-line-segment
            if (Equals(innerLine))
                return true;

            return Contains(innerLine.StartingPoint) && Contains(innerLine.EndingPoint);
        }
예제 #13
0
 public dependDotAdapter(object ownerSender, IId IDinterface, ILine LineInterface)
 {
     if(ownerSender == null || IDinterface == null || LineInterface == null) 
         throw new ArgumentNullException();
     sender = ownerSender;
     parentID = IDinterface;
     line = LineInterface;
 }
 public Class(IOpenBraceStatement OpenBraceStatementBase, ILine Line, ILiveStatement LiveStatementBase, System.Boolean Public = false, System.Collections.Generic.List<System.String> Implements = null, System.String Name = null)
 {
     this.OpenBraceStatementBase = OpenBraceStatementBase;
     this.Public = Public;
     this.Line = Line;
     this.LiveStatementBase = LiveStatementBase;
     this.Implements = Implements;
     this.Name = Name;
 }
예제 #15
0
 public bool Insert(ILine line, int position, string text)
 {
     if (UnmanagedExports.insertTextCallback != null)
     {
         UnmanagedExports.insertTextCallback(line.Position + position, text);
         return true;
     }
     return false;
 }
예제 #16
0
        private static SurveyPolyline CreateSurveyPolylineFromLine(ILine line)
        {
            IPolyline polyline = new Polyline(line.Id,
                                              line.RunDirection);

            polyline.AddSegment(line);

            return new SurveyPolyline(polyline);
        }
예제 #17
0
 public ILine[] RemoveEmptyLines(ILine[] lines)
 {
     var result = new List<ILine>();
     foreach (var line in lines) {
         if(!line.IsEmpty) {
             result.Add(line);
         }
     }
     return result.ToArray();
 }
예제 #18
0
        public LineSegment SegmentToLineSegment(ILine segment)
        {
            m_Converter.GeometryPoint = segment.EndPoint;
            m_Converter.Convert();

            var line = new LineSegment(m_Converter.Point,
                                       true);

            return line;
        }
예제 #19
0
        public Graph(ILine line)
        {
            IList<Label> result = new List<Label>();
            foreach (var valuePoint in line) {
                result.Add(new Label {Value = valuePoint.Date.ToShortDateString(), Index=result.Count.ToString() });
            }
            Labels = result.ToArray();

            LinesContainer = new LinesContainer { Lines = new[] { line } };
        }
 public CostForLineSwitchCalculator(ILine from,
                                    Constants.LineDirection fromDirection,
                                    ILine to,
                                    Constants.LineDirection toDirection)
 {
     From = from;
     FromDirection = fromDirection;
     To = to;
     ToDirection = toDirection;
 }
        public IIntersectionResult Solve(ILine line, ILine anotherLine)
        {
            if(line.Equals(anotherLine))
                return  new IntersectionResult(false, new IPoint[0]);

            //Calculation derived from http://devmag.org.za/2009/04/13/basic-collision-detection-in-2d-part-1/
            //and http://devmag.org.za/2009/04/17/basic-collision-detection-in-2d-part-2/

            return new IntersectionResult(CalculateHasIntersection(line, anotherLine), CalculateIntersectionPoint(line, anotherLine));
        }
예제 #22
0
 public int Find(ILine l)
 {
     for (int i = 0; i < lines.Count; i++)
     {
         if (lines[i].IsCongruentTo(l))
         {
             return i;
         }
     }
     return -1;
 }
 private static void AssertLineForward(ILine actual)
 {
     AssertLine(actual,
                1,
                2.0,
                3.0,
                4.0,
                5.0,
                false,
                Constants.LineDirection.Forward);
 }
 private static void AssertLineNull(ILine actual)
 {
     AssertLine(actual,
                1000,
                2000.0,
                3000.0,
                4000.0,
                5000.0,
                false,
                Constants.LineDirection.Unknown);
 }
예제 #25
0
        static IEnumerable<Span> DiffInline(ILine originalLine, ILine modifiedLine)
        {
            var dmp = new diff_match_patch();
            var diffs = dmp.diff_main(originalLine.Value, modifiedLine.Value);

            dmp.diff_cleanupSemantic(diffs);

            return diffs
                .Select(x => new Span(x.text, OperationToKind(x.operation)))
                .ToArray();
        }
 private static void AssertLineReverse(ILine actual)
 {
     AssertLine(actual,
                10,
                20.0,
                30.0,
                40.0,
                50.0,
                false,
                Constants.LineDirection.Reverse);
 }
예제 #27
0
        public void Enqueue(ILine l, List<Shape> shapes)
        {
            int findCount = 0;
            foreach (Shape s in shapes)
            {
                if (s.Contains(l))
                    findCount++;
            }

            if (findCount < 2 && Find(l) < 0)
                lines.Add(l);
        }
 /// <summary>
 /// Creates and Add to Models the Beam and Suports .NodeLine determines
 /// </summary>
 /// <param name="element"></param>
 public void CreateBeam(ILine element)
 {
     try
     {
         List<StructuralElement> ElementsToBeAdded = GetBeamAndSupports(element);
         CreateBeamAndSupport(ElementsToBeAdded);
     }
     catch (Exception exp)
     {
         throw exp;
     }
 }
예제 #29
0
 public bool Remove(ILine l)
 {
     for (int i = 0; i < lines.Count; i++)
     {
         if (lines[i].IsCongruentTo(l))
         {
             lines.RemoveAt(i);
             return true;
         }
     }
     return false;
 }
예제 #30
0
        public static ILine Connect(ICanvas canvas, IElement root, ILine line, double x, double y, IDiagramCreator creator)
        {
            var rootTag = root.GetTag();
            if (rootTag == null)
                root.SetTag(new Connection(root, new List<Wire>()));

            var connection = root.GetTag() as Connection;
            var wires = connection.Wires;

            if (line == null)
                return FirstConnection(canvas, root, x, y, wires, creator);
            else
                return SecondConnection(root, line, x, y, wires);
        }
예제 #31
0
파일: Wpf.cs 프로젝트: 15831944/Sheet
 public double GetX2(ILine line)
 {
     return((line.Native as Line).X2);
 }
예제 #32
0
파일: Wpf.cs 프로젝트: 15831944/Sheet
 public void SetY1(ILine line, double y1)
 {
     (line.Native as Line).Y1 = y1;
 }
예제 #33
0
파일: Wpf.cs 프로젝트: 15831944/Sheet
 public void SetY2(ILine line, double y2)
 {
     (line.Native as Line).Y2 = y2;
 }
예제 #34
0
파일: Wpf.cs 프로젝트: 15831944/Sheet
 public double GetStrokeThickness(ILine line)
 {
     return((line.Native as Line).StrokeThickness);
 }
예제 #35
0
파일: Wpf.cs 프로젝트: 15831944/Sheet
 public void Select(ILine line)
 {
     (line.Native as Line).Stroke = WpfBlockFactory.SelectedBrush;
 }
예제 #36
0
파일: Wpf.cs 프로젝트: 15831944/Sheet
 public double GetX1(ILine line)
 {
     return((line.Native as Line).X1);
 }
예제 #37
0
 public KeyData(ILine line, bool onLine)
 {
     this.line   = line;
     this.onLine = onLine;
 }
예제 #38
0
        public static void Main(string[] args)
        {
            {
                #region Snippet_0a
                ILine root = LineRoot.Global.Logger(Console.Out, LineStatusSeverity.Ok);
                #endregion Snippet_0a
                #region Snippet_0b
                Console.WriteLine(root.Type("MyClass").Key("OK").Text("OK"));
                #endregion Snippet_0b
                // ResolveOkFromKey|CultureOkMatchedNoCulture|PluralityOkNotUsed|StringFormatOkString Type:MyClass:Key:OK = "OK"
            }
            {
                #region Snippet_1a
                (LineRoot.Global as LineRoot.Mutable).Logger = new LineTextLogger(Console.Out, LineStatusSeverity.Ok);
                #endregion Snippet_1a
            }
            {
                #region Snippet_1b
                Console.WriteLine(LineRoot.Global.Type("MyClass").Key("OK").Text("OK"));
                #endregion Snippet_1b
                // ResolveOkFromKey|CultureOkMatchedNoCulture|PluralityOkNotUsed|StringFormatOkString Type:MyClass:Key:OK = "OK"
                (LineRoot.Global as LineRoot.Mutable).Logger = null;
            }

            {
                #region Snippet_2a
                Trace.Listeners.Add(new TextWriterTraceListener(Console.Out));
                ILine root = LineRoot.Global.DiagnosticsTrace(LineStatusSeverity.Ok);
                #endregion Snippet_2a
                #region Snippet_2b
                Console.WriteLine(root.Type("MyClass").Key("OK").Text("OK"));
                #endregion Snippet_2b
                // docs Information: 0 : ResolveOkFromKey|CultureOkMatchedNoCulture|PluralityOkNotUsed|StringFormatOkString Type:MyClass:Key:OK = "OK"
            }
            {
                #region Snippet_3a
                LoggerFactory loggerFactory = new LoggerFactory();
                loggerFactory.AddConsole(LogLevel.Trace);
                ILogger logger = loggerFactory.CreateLogger("MyClass");
                ILine   root   = LineRoot.Global.ILogger(logger);
                #endregion Snippet_3a
                #region Snippet_3b
                Console.WriteLine(root.Type("MyClass").Key("OK").Text("OK"));
                #endregion Snippet_3b
                //info: MyClass[0]
                //ResolveOkFromKey | CultureOkMatchedNoCulture | PluralityOkNotUsed | StringFormatOkString Type: MyClass: Key: OK = "OK"
            }
            {
                #region Snippet_4a
                LoggerFactory loggerFactory = new LoggerFactory();
                loggerFactory.AddConsole(LogLevel.Trace);
                ILine root = LineRoot.Global.ILogger(loggerFactory);
                #endregion Snippet_4a
                #region Snippet_4b
                Console.WriteLine(root.Type("MyClass").Key("OK").Text("OK"));
                #endregion Snippet_4b
                //info: MyClass[0]
                //ResolveOkFromKey | CultureOkMatchedNoCulture | PluralityOkNotUsed | StringFormatOkString Type: MyClass: Key: OK = "OK"
            }
            {
                #region Snippet_5a
                NLog.ILogger nlog = NLog.LogManager.GetLogger("MyClass");
                ILine        root = LineRoot.Global.NLog(nlog);
                #endregion Snippet_5a
                #region Snippet_5b
                Console.WriteLine(root.Type("MyClass").Key("OK").Text("OK"));
                #endregion Snippet_5b
                // 2019-06-08 14:10:46.4939|INFO|MyClass|ResolveOkFromKey|CultureOkMatchedNoCulture|PluralityOkNotUsed|StringFormatOkString Type:MyClass:Key:OK = "OK"
            }
            {
                #region Snippet_6a
                ILine root = LineRoot.Global.NLog(NLog.LogManager.LogFactory);
                #endregion Snippet_6a
                #region Snippet_6b
                Console.WriteLine(root.Type("MyClass").Key("OK").Text("OK"));
                #endregion Snippet_6b
                // 2019-06-08 14:10:58.9517|INFO|MyClass|ResolveOkFromKey|CultureOkMatchedNoCulture|PluralityOkNotUsed|StringFormatOkString Type:MyClass:Key:OK = "OK"
                Console.WriteLine(root.Key("OK").Text("OK"));
            }
            {
                #region Snippet_7
                #endregion Snippet_7
            }
            {
                #region Snippet_8
                #endregion Snippet_8
            }
        }
예제 #39
0
 public Trapezium(ILine first, float parallelLineDeviation, float parallelLineSizeDifference = 0, Angle angle = default(Angle)) : this()
 {
     Data = Geometry.GetTrapeziumData(first, parallelLineDeviation, angle, StrokeMode.Outer, parallelLineSizeDifference);
     ID = Factory.NewID(Name);
 }
예제 #40
0
 /// <summary>
 /// Initializes the script manager with the current voice line and a starting script.
 /// </summary>
 /// <param name="line">The voice line to use</param>
 /// <param name="startingScript">The first script</param>
 public ScriptManager(ILine line, IScript startingScript)
 {
     NextScript = startingScript;
     _line      = line;
 }
예제 #41
0
 /// <summary>
 /// </summary>
 /// <param name="v"></param>
 public void MoveVector(ILine v)
 {
     (this.m_pGeometry as ITransform2D).MoveVector(v);
     this.RefreshTracker();
 }
예제 #42
0
 /// <summary>
 /// Append part.
 /// </summary>
 /// <param name="appender"></param>
 /// <param name="previous"></param>
 /// <param name="culture"></param>
 /// <param name="line"></param>
 /// <returns></returns>
 public virtual bool TryCreate(ILineFactory appender, ILine previous, CultureInfo culture, out ILineCulture line)
 {
     line = new LineCulture(appender, previous, culture);
     return(true);
 }
예제 #43
0
파일: Wpf.cs 프로젝트: 15831944/Sheet
 public double GetY2(ILine line)
 {
     return((line.Native as Line).Y2);
 }
예제 #44
0
파일: Wpf.cs 프로젝트: 15831944/Sheet
 public double GetY1(ILine line)
 {
     return((line.Native as Line).Y1);
 }
예제 #45
0
 public string InterpretLine(ISourceFile context, ILine line)
 {
     return("");
 }
예제 #46
0
파일: Wpf.cs 프로젝트: 15831944/Sheet
 public void SetX1(ILine line, double x1)
 {
     (line.Native as Line).X1 = x1;
 }
예제 #47
0
 public abstract void Fix(ILine toFix, IList <ILine> compilationResult);
예제 #48
0
        public static void Main(string[] args)
        {
            {
                #region Snippet_A1
                IPluralRules rules = PluralRulesResolver.Default.Resolve("Unicode.CLDR35");
                ILine        root  = LineRoot.Global.PluralRules(rules);
                #endregion Snippet_A1
            }
            {
                #region Snippet_A2
                ILine root = LineRoot.Global.PluralRules("Unicode.CLDR35");
                #endregion Snippet_A2
            }
            {
                #region Snippet_A3
                ILine root = LineRoot.Global.PluralRules("[Category=cardinal,Case=zero,Optional=1]n=0[Category=cardinal,Case=one]n=1[Category=cardinal,Case=other]true");
                #endregion Snippet_A3
            }

            {
                #region Snippet_0a
                IAsset    asset = LineReaderMap.Default.FileAsset("PluralityExample0a.xml");
                ILineRoot root  = new LineRoot(asset);
                ILine     key   = root.Key("Cats").Format("{0} cat(s)");

                // Print with the default string (without culture policy)
                for (int cats = 0; cats <= 2; cats++)
                {
                    Console.WriteLine(key.Value(cats));
                }

                // Print Culture "en"
                for (int cats = 0; cats <= 2; cats++)
                {
                    Console.WriteLine(key.Culture("en").Value(cats));
                }

                // Print Culture "fi"
                for (int cats = 0; cats <= 2; cats++)
                {
                    Console.WriteLine(key.Culture("fi").Value(cats));
                }
                #endregion Snippet_0a
            }
            {
                #region Snippet_0a2
                IAsset    asset = LineReaderMap.Default.FileAsset("PluralityExample0a.json");
                ILineRoot root  = new LineRoot(asset);
                ILine     line  = root.Key("Cats").Format("{0} cat(s)");

                // Print with the default string (without culture policy)
                for (int cats = 0; cats <= 2; cats++)
                {
                    Console.WriteLine(line.Value(cats));
                }

                // Print Culture "en"
                for (int cats = 0; cats <= 2; cats++)
                {
                    Console.WriteLine(line.Culture("en").Value(cats));
                }

                // Print Culture "fi"
                for (int cats = 0; cats <= 2; cats++)
                {
                    Console.WriteLine(line.Culture("fi").Value(cats));
                }
                #endregion Snippet_0a2
            }
            {
                #region Snippet_0a3
                IAsset    asset = LineReaderMap.Default.FileAsset("PluralityExample0a.ini");
                ILineRoot root  = new LineRoot(asset);
                ILine     key   = root.Key("Cats").Format("{0} cat(s)");

                // Print with the default string (without culture policy)
                for (int cats = 0; cats <= 2; cats++)
                {
                    Console.WriteLine(key.Value(cats));
                }

                // Print Culture "en"
                for (int cats = 0; cats <= 2; cats++)
                {
                    Console.WriteLine(key.Culture("en").Value(cats));
                }

                // Print Culture "fi"
                for (int cats = 0; cats <= 2; cats++)
                {
                    Console.WriteLine(key.Culture("fi").Value(cats));
                }
                #endregion Snippet_0a3
            }

            {
                #region Snippet_0b
                ILineRoot root = new LineRoot();
                ILine     line = root.Key("Cats")
                                 .PluralRules("Unicode.CLDR35")
                                 .Format("{cardinal:0} cat(s)") // Default string
                                 .Inline("N:zero", "no cats")
                                 .Inline("N:one", "a cat")
                                 .Inline("N:other", "{0} cats");
                #endregion Snippet_0b
                for (int cats = 0; cats <= 2; cats++)
                {
                    Console.WriteLine(line.Value(cats));
                }
            }

            {
                #region Snippet_0c
                ILineRoot root = new LineRoot();
                ILine     line = root.Key("Cats")
                                 .PluralRules("Unicode.CLDR35")
                                 .Format("{0} cat(s)") // Default string
                                 .Inline("Culture:en", "{cardinal:0} cat(s)")
                                 .Inline("Culture:en:N:zero", "no cats")
                                 .Inline("Culture:en:N:one", "a cat")
                                 .Inline("Culture:en:N:other", "{0} cats")
                                 .Inline("Culture:fi", "{cardinal:0} kissa(a)")
                                 .Inline("Culture:fi:N:zero", "ei kissoja")
                                 .Inline("Culture:fi:N:one", "yksi kissa")
                                 .Inline("Culture:fi:N:other", "{0} kissaa");

                for (int cats = 0; cats <= 2; cats++)
                {
                    Console.WriteLine(line.Culture("en").Value(cats));
                }
                #endregion Snippet_0c
            }

            {
                // CLDR35 has rules for "" culture
                #region Snippet_1a
                IAsset asset = LineReaderMap.Default.FileAsset("PluralityExample0b.xml");
                ILine  key   = new LineRoot(asset).Key("Cats");

                for (int cats = 0; cats <= 2; cats++)
                {
                    Console.WriteLine(key.Value(cats));
                }
                #endregion Snippet_1a
            }


            {
                // Plurality permutations for argument 0
                #region Snippet_2
                ILine line = LineRoot.Global.Key("CatsDogs")
                             .PluralRules("Unicode.CLDR35")
                             .Format("{cardinal:0} cat(s) and {1} dog(s)")
                             .Inline("N:zero", "no cats and {1} dog(s)")
                             .Inline("N:one", "a cat and {1} dog(s)")
                             .Inline("N:other", "{0} cats and {1} dog(s)");

                for (int cats = 0; cats <= 2; cats++)
                {
                    for (int dogs = 0; dogs <= 2; dogs++)
                    {
                        Console.WriteLine(line.Value(cats, dogs));
                    }
                }
                #endregion Snippet_2
            }

            {
                // Plurality permutations for argument 0
                #region Snippet_3
                IAsset asset = LineReaderMap.Default.FileAsset("PluralityExample1.xml");
                ILine  key   = new LineRoot(asset).Key("CatsDogs");

                for (int cats = 0; cats <= 2; cats++)
                {
                    for (int dogs = 0; dogs <= 2; dogs++)
                    {
                        Console.WriteLine(key.Value(cats, dogs));
                    }
                }
                #endregion Snippet_3
            }

            {
                // Plurality permutations for argument 0 and argument 1
                #region Snippet_5
                IAsset    asset = LineReaderMap.Default.FileAsset("PluralityExample2.xml");
                ILineRoot root  = new LineRoot(asset);
                ILine     key   = root.Key("CatsDogs").Format("{0} cat(s) and {1} dog(s)");

                for (int cats = 0; cats <= 2; cats++)
                {
                    for (int dogs = 0; dogs <= 2; dogs++)
                    {
                        Console.WriteLine(key.Culture("en").Value(cats, dogs));
                    }
                }
                #endregion Snippet_5
            }
            {
                // Plurality for 4 arguments
                #region Snippet_6
                IAsset asset = LineReaderMap.Default.FileAsset("PluralityExample4.xml");
                ILine  key   = new LineRoot(asset).Key("CatsDogsPoniesHorses");

                for (int cats = 0; cats <= 2; cats++)
                {
                    for (int dogs = 0; dogs <= 2; dogs++)
                    {
                        for (int ponies = 0; ponies <= 2; ponies++)
                        {
                            for (int horses = 0; horses <= 2; horses++)
                            {
                                Console.WriteLine(key.Value(cats, dogs, ponies, horses));
                            }
                        }
                    }
                }
                #endregion Snippet_6
            }
            {
                // Plural expression in localization file
                // [Category=cardinal,Case=zero,Optional=1]n=0[Category=cardinal,Case=one]n=1[Category=cardinal,Case=other]true
                #region Snippet_7
                IAsset asset = LineReaderMap.Default.FileAsset("PluralityExample5.xml");
                ILine  key   = new LineRoot(asset).Key("CatsDogs");

                for (int cats = 0; cats <= 2; cats++)
                {
                    for (int dogs = 0; dogs <= 2; dogs++)
                    {
                        Console.WriteLine(key.Value(cats, dogs));
                    }
                }
                #endregion Snippet_7
            }
            {
                #region Snippet_8
                #endregion Snippet_8
            }
        }
예제 #49
0
파일: Wpf.cs 프로젝트: 15831944/Sheet
 public void Set(ILine line, IBoolState state)
 {
     (line.Native as Line).Stroke = SelectBrush(state);
 }
예제 #50
0
        public bool projectBackward(string szInputShpFilename, IRasterLayer pDemLayer, string szXmlFilename, string szOutShpFilename)
        {
            if (string.IsNullOrEmpty(szInputShpFilename) || pDemLayer == null || string.IsNullOrEmpty(szXmlFilename) || string.IsNullOrEmpty(szOutShpFilename))
            {
                return(false);
            }

            ClsGDBDataCommon processDataCommon = new ClsGDBDataCommon();
            string           strInputPath      = System.IO.Path.GetDirectoryName(szInputShpFilename);
            string           strInputName      = System.IO.Path.GetFileName(szInputShpFilename);

            #region 读取SHP文件
            IWorkspace        pWorkspace        = processDataCommon.OpenFromShapefile(strInputPath);
            IFeatureWorkspace pFeatureWorkspace = pWorkspace as IFeatureWorkspace;
            IFeatureClass     pInputFC          = pFeatureWorkspace.OpenFeatureClass(strInputName);
            #endregion

            #region 读取DEM文件
            IRasterLayer pRasterLayer = pDemLayer;// new RasterLayerClass();
            //pRasterLayer.CreateFromFilePath(szDemFilename);
            IRaster      pDemRaster      = pRasterLayer.Raster;
            IRasterProps pDemRasterProps = pDemRaster as IRasterProps;
            #endregion

            #region 得到曲线信息
            List <ISegmentCollection> pSegmentCollection = new List <ISegmentCollection>();
            List <IFeature>           pFeatureList       = new List <IFeature>();
            IFeatureCursor            pFCursor           = pInputFC.Search(null, false);
            IFeature pFeature = null;// pFCursor.NextFeature();
            while ((pFeature = pFCursor.NextFeature()) != null)
            {
                IPolyline pPolyline = pFeature.Shape as IPolyline;
                if (pPolyline == null)
                {
                    //pFeature = pFCursor.NextFeature();
                    continue;
                }

                IFeature pTmpFeature = pFeature;
                pFeatureList.Add(pTmpFeature);

                ISegmentCollection pCurrentSegmentCollection = pPolyline as ISegmentCollection;
                pSegmentCollection.Add(pCurrentSegmentCollection);
            }
            #endregion

            #region 读取相机姿态参数
            ClsCameraPara cameraPara = ParseXmlFileToGetPara(szXmlFilename);
            if (cameraPara == null)
            {
                return(false);
            }

            //根据姿态参数获得旋转矩阵
            OriAngle oriAngle      = new OriAngle();
            Matrix   pRotateMatrix = new Matrix(3, 3);

            oriAngle.kap = cameraPara.dKappa;
            oriAngle.omg = cameraPara.dOmg;
            oriAngle.phi = cameraPara.dPhi;
            if (!ClsGetCameraView.OPK2RMat(oriAngle, ref pRotateMatrix))
            {
                return(false);
            }
            #endregion

            #region 创建输出SHP文件
            string strOutputPath      = System.IO.Path.GetDirectoryName(szOutShpFilename);
            string strOutputName      = System.IO.Path.GetFileName(szOutShpFilename);
            string strPointOutputName = System.IO.Path.GetFileNameWithoutExtension(szOutShpFilename) + "_point" + System.IO.Path.GetExtension(szOutShpFilename);

            //设置空间参考
            ISpatialReference pSpatialRef = new UnknownCoordinateSystemClass(); //没有这一句就报错,说尝试读取或写入受保护的内存。
            pSpatialRef.SetDomain(MIN_INT, MAX_INT, MIN_INT, MAX_INT);          //没有这句就抛异常来自HRESULT:0x8004120E。
            pSpatialRef.SetZDomain(MIN_INT, MAX_INT);

            //创建POLYLINE文件的字段
            IFields pFields = pInputFC.Fields;

            //创建点SHP文件的字段
            IFields     pPointFields = new FieldsClass();
            IFieldsEdit pFieldsEdit  = (IFieldsEdit)pPointFields;

            //设置字段
            IField     pField     = new FieldClass();
            IFieldEdit pFieldEdit = (IFieldEdit)pField;

            //创建类型为几何类型的字段
            pFieldEdit.Name_2 = "shape";
            pFieldEdit.Type_2 = esriFieldType.esriFieldTypeGeometry;

            IGeometryDef     pGeoDef     = new GeometryDefClass();
            IGeometryDefEdit pGeoDefEdit = (IGeometryDefEdit)pGeoDef;
            pGeoDefEdit.GeometryType_2     = esriGeometryType.esriGeometryPoint;
            pGeoDefEdit.HasM_2             = false;
            pGeoDefEdit.HasZ_2             = false;
            pGeoDefEdit.SpatialReference_2 = pSpatialRef;
            //pFieldEdit.Name_2 = "SHAPE";
            //pFieldEdit.Type_2 = esriFieldType.esriFieldTypeGeometry;
            pFieldEdit.GeometryDef_2 = pGeoDef;
            pFieldEdit.IsNullable_2  = true;
            pFieldEdit.Required_2    = true;
            pFieldsEdit.AddField(pField);

            IFeatureClass pOutputFC      = processDataCommon.CreateShapefile(strOutputPath, strOutputName, pFields, pSpatialRef);
            IFeatureClass pOutputPointFC = processDataCommon.CreateShapefile(strOutputPath, strPointOutputName, pPointFields, pSpatialRef);
            if (pOutputFC == null || pOutputPointFC == null)
            {
                return(false);
            }
            #endregion

            #region 节点位置反投影
            List <List <Pt2d> > ptImageFeaturePoints            = new List <List <Pt2d> >();
            List <List <Pt2d> > ptImageFeaturePointsForPointShp = new List <List <Pt2d> >();
            ClsGetCameraView    pGetCameraView = new ClsGetCameraView();

            for (int i = 0; i < pSegmentCollection.Count; i++)
            {
                List <Pt2d> ptSingleImageFeaturePoints            = new List <Pt2d>();
                List <Pt2d> ptSingleImageFeaturePointsForPointShp = new List <Pt2d>();
                for (int j = 0; j < pSegmentCollection[i].SegmentCount; j++)
                {
                    ISegment pCurrentSegment = pSegmentCollection[i].get_Segment(j);
                    if (pCurrentSegment == null)
                    {
                        continue;
                    }

                    //直线
                    if (pCurrentSegment.GeometryType == esriGeometryType.esriGeometryLine)
                    {
                        ILine pLine = pCurrentSegment as ILine;

                        //起始点
                        IPoint ptFrom   = pLine.FromPoint;
                        Pt2d   ptFrom2d = getProjectBackwardPoint(ptFrom, pDemRaster, pGetCameraView, pRotateMatrix, cameraPara);
                        if (ptFrom2d != null)
                        {
                            ptSingleImageFeaturePoints.Add(ptFrom2d);
                            ptSingleImageFeaturePointsForPointShp.Add(ptFrom2d);
                        }

                        //终止点
                        IPoint ptTo   = pLine.ToPoint;
                        Pt2d   ptTo2d = getProjectBackwardPoint(ptTo, pDemRaster, pGetCameraView, pRotateMatrix, cameraPara);
                        if (ptTo2d != null)
                        {
                            ptSingleImageFeaturePoints.Add(ptTo2d);
                            if (j == pSegmentCollection[i].SegmentCount - 1)   //最后一条直线段
                            {
                                ptSingleImageFeaturePointsForPointShp.Add(ptTo2d);
                            }
                        }
                    }
                    else if (pCurrentSegment.GeometryType == esriGeometryType.esriGeometryCircularArc) //圆弧
                    {
                        ICircularArc pCircularArc  = pCurrentSegment as ICircularArc;
                        double       dbCurveLength = pCircularArc.Length;
                        int          nCount        = 15;
                        double       dbOffset      = dbCurveLength / nCount;
                        for (int nCurrent = 0; nCurrent < nCount; nCurrent++)
                        {
                            IPoint ptCurrent = new Point();
                            pCircularArc.QueryPoint(esriSegmentExtension.esriNoExtension, nCurrent * dbOffset, false, ptCurrent);
                            Pt2d ptCurrentImagePoint = getProjectBackwardPoint(ptCurrent, pDemRaster, pGetCameraView, pRotateMatrix, cameraPara);
                            if (ptCurrentImagePoint != null)
                            {
                                ptSingleImageFeaturePoints.Add(ptCurrentImagePoint);

                                //只保留端点的信息,用于创建点SHP图层
                                if (nCurrent == 0 || nCurrent == nCount - 1)
                                {
                                    ptSingleImageFeaturePointsForPointShp.Add(ptCurrentImagePoint);
                                }
                            }
                        }
                    }
                    else
                    {
                        continue;
                    }
                }

                ptImageFeaturePoints.Add(ptSingleImageFeaturePoints);
                ptImageFeaturePointsForPointShp.Add(ptSingleImageFeaturePointsForPointShp);
            }
            #endregion

            #region 写入POLYLINE节点信息
            IDataset   dataset   = (IDataset)pOutputFC;
            IWorkspace workspace = dataset.Workspace;

            //Cast for an IWorkspaceEdit
            IWorkspaceEdit workspaceEdit = workspace as IWorkspaceEdit;
            workspaceEdit.StartEditing(true);
            workspaceEdit.StartEditOperation();

            //////////////////////////////////////////////////////////////////////////
            //整条路线的添加
            IFeatureCursor pOutFCursor = null;
            for (int i = 0; i < ptImageFeaturePoints.Count; i++)
            {
                int            nPtsCount      = ptImageFeaturePoints[i].Count;
                IFeatureBuffer pFeatureBuffer = pOutputFC.CreateFeatureBuffer();
                pOutFCursor = pOutputFC.Insert(true);

                IPolyline        pPolyline        = new PolylineClass();
                IPointCollection pPointCollection = pPolyline as IPointCollection;

                for (int j = 0; j < nPtsCount; j++)
                {
                    IPoint pt = new PointClass();
                    pt.PutCoords(ptImageFeaturePoints[i][j].X, ptImageFeaturePoints[i][j].Y);
                    pPointCollection.AddPoint(pt);
                }

                if (!ClsGDBDataCommon.CopyFeatureFieldValue(pFeatureList[i], pFeatureBuffer as IFeature))
                {
                    continue;
                }

                pFeatureBuffer.Shape = pPolyline as IGeometry;
                object featureOID = pOutFCursor.InsertFeature(pFeatureBuffer);
            }
            pOutFCursor.Flush();

            //分段路线的添加
            for (int i = 0; i < ptImageFeaturePoints.Count; i++)
            {
                int nPtsCount = ptImageFeaturePoints[i].Count;
                for (int j = 0; j < nPtsCount - 1; j++)
                {
                    IFeatureBuffer pFeatureBuffer = pOutputFC.CreateFeatureBuffer();
                    pOutFCursor = pOutputFC.Insert(true);
                    IPolyline        pPolyline        = new PolylineClass();
                    IPointCollection pPointCollection = pPolyline as IPointCollection;

                    IPoint pt = new PointClass();
                    pt.PutCoords(ptImageFeaturePoints[i][j].X, ptImageFeaturePoints[i][j].Y);
                    pPointCollection.AddPoint(pt);
                    pt.PutCoords(ptImageFeaturePoints[i][j + 1].X, ptImageFeaturePoints[i][j + 1].Y);
                    pPointCollection.AddPoint(pt);

                    if (!ClsGDBDataCommon.CopyFeatureFieldValue(pFeatureList[i], pFeatureBuffer as IFeature))
                    {
                        continue;
                    }
                    pFeatureBuffer.Shape = pPolyline as IGeometry;
                    object featureOID = pOutFCursor.InsertFeature(pFeatureBuffer);
                }
            }
            pOutFCursor.Flush();
            //featureCursor.Flush();
            workspaceEdit.StopEditOperation();
            workspaceEdit.StopEditing(true);
            #endregion

            #region 点SHP文件的添加
            IDataset   pPointDataset   = (IDataset)pOutputPointFC;
            IWorkspace pPointWorkspace = pPointDataset.Workspace;

            //Cast for an IWorkspaceEdit
            IWorkspaceEdit pPointWorkspaceEdit = pPointWorkspace as IWorkspaceEdit;
            pPointWorkspaceEdit.StartEditing(true);
            pPointWorkspaceEdit.StartEditOperation();

            IFeatureCursor pOutPointFCursor = null;
            for (int i = 0; i < ptImageFeaturePointsForPointShp.Count; i++)
            {
                //int nSegmentCount = pSegmentCollection[i].SegmentCount;

                //IMultipoint pMultiPoint = new MultipointClass();
                for (int j = 0; j < ptImageFeaturePointsForPointShp[i].Count; j++)
                {
                    IFeatureBuffer pFeatureBuffer = pOutputPointFC.CreateFeatureBuffer();
                    pOutPointFCursor = pOutputPointFC.Insert(true);
                    IPoint pt   = new PointClass();
                    Pt2d   pt2d = ptImageFeaturePointsForPointShp[i][j];
                    pt.PutCoords(pt2d.X, pt2d.Y);

                    //CopyFeatureField(pFeatureList[i], pFeatureBuffer);
                    pFeatureBuffer.Shape = pt as IGeometry;
                    object featureOID = pOutPointFCursor.InsertFeature(pFeatureBuffer);
                }
            }
            pOutPointFCursor.Flush();

            //featureCursor.Flush();
            pPointWorkspaceEdit.StopEditOperation();
            pPointWorkspaceEdit.StopEditing(true);
            #endregion

            return(true);
        }
예제 #51
0
파일: Wpf.cs 프로젝트: 15831944/Sheet
 public void SetStrokeThickness(ILine line, double thickness)
 {
     (line.Native as Line).StrokeThickness = thickness;
 }
예제 #52
0
        public bool projectBackward(IFeatureClass pInputFeatureClass, IRasterLayer pDemLayer, string szXmlFilename,
                                    ref IFeatureClass pOutputPolylineFeatureClass, ref IFeatureClass pOutputPointFeatureClass)
        {
            if (pInputFeatureClass == null || pDemLayer == null || string.IsNullOrEmpty(szXmlFilename) || pOutputPointFeatureClass == null || pOutputPolylineFeatureClass == null)
            {
                return(false);
            }

            #region 读取DEM文件
            IRasterLayer pRasterLayer = pDemLayer;// new RasterLayerClass();
            //pRasterLayer.CreateFromFilePath(szDemFilename);
            IRaster      pDemRaster      = pRasterLayer.Raster;
            IRasterProps pDemRasterProps = pDemRaster as IRasterProps;
            #endregion

            #region 读取相机姿态参数
            ClsCameraPara cameraPara = ParseXmlFileToGetPara(szXmlFilename);
            if (cameraPara == null)
            {
                return(false);
            }

            //根据姿态参数获得旋转矩阵
            OriAngle oriAngle      = new OriAngle();
            Matrix   pRotateMatrix = new Matrix(3, 3);

            oriAngle.kap = cameraPara.dKappa;
            oriAngle.omg = cameraPara.dOmg;
            oriAngle.phi = cameraPara.dPhi;
            if (!ClsGetCameraView.OPK2RMat(oriAngle, ref pRotateMatrix))
            {
                return(false);
            }
            #endregion

            #region 得到曲线信息
            List <ISegmentCollection> pSegmentCollection = new List <ISegmentCollection>();
            List <IFeature>           pFeatureList       = new List <IFeature>();
            IFeatureCursor            pFCursor           = pInputFeatureClass.Search(null, false);
            IFeature pFeature = null;// pFCursor.NextFeature();
            while ((pFeature = pFCursor.NextFeature()) != null)
            {
                IPolyline pPolyline = pFeature.Shape as IPolyline;
                if (pPolyline == null)
                {
                    //pFeature = pFCursor.NextFeature();
                    continue;
                }

                IFeature pTmpFeature = pFeature;
                pFeatureList.Add(pTmpFeature);

                ISegmentCollection pCurrentSegmentCollection = pPolyline as ISegmentCollection;
                pSegmentCollection.Add(pCurrentSegmentCollection);
            }
            #endregion

            #region 节点位置反投影
            List <List <Pt2d> > ptImageFeaturePoints            = new List <List <Pt2d> >();
            List <List <Pt2d> > ptImageFeaturePointsForPointShp = new List <List <Pt2d> >();
            ClsGetCameraView    pGetCameraView = new ClsGetCameraView();

            for (int i = 0; i < pSegmentCollection.Count; i++)
            {
                List <Pt2d> ptSingleImageFeaturePoints            = new List <Pt2d>();
                List <Pt2d> ptSingleImageFeaturePointsForPointShp = new List <Pt2d>();
                for (int j = 0; j < pSegmentCollection[i].SegmentCount; j++)
                {
                    ISegment pCurrentSegment = pSegmentCollection[i].get_Segment(j);
                    if (pCurrentSegment == null)
                    {
                        continue;
                    }

                    //直线
                    if (pCurrentSegment.GeometryType == esriGeometryType.esriGeometryLine)
                    {
                        ILine pLine = pCurrentSegment as ILine;

                        //起始点
                        IPoint ptFrom   = pLine.FromPoint;
                        Pt2d   ptFrom2d = getProjectBackwardPoint(ptFrom, pDemRaster, pGetCameraView, pRotateMatrix, cameraPara);
                        if (ptFrom2d != null)
                        {
                            ptSingleImageFeaturePoints.Add(ptFrom2d);
                            ptSingleImageFeaturePointsForPointShp.Add(ptFrom2d);
                        }

                        //终止点
                        IPoint ptTo   = pLine.ToPoint;
                        Pt2d   ptTo2d = getProjectBackwardPoint(ptTo, pDemRaster, pGetCameraView, pRotateMatrix, cameraPara);
                        if (ptTo2d != null)
                        {
                            if (j == pSegmentCollection[i].SegmentCount - 1)   //最后一条直线段
                            {
                                ptSingleImageFeaturePointsForPointShp.Add(ptTo2d);
                                ptSingleImageFeaturePoints.Add(ptTo2d);
                            }
                        }
                    }
                    else if (pCurrentSegment.GeometryType == esriGeometryType.esriGeometryCircularArc) //圆弧
                    {
                        ICircularArc pCircularArc  = pCurrentSegment as ICircularArc;
                        double       dbCurveLength = pCircularArc.Length;
                        int          nCount        = 15;
                        double       dbOffset      = dbCurveLength / nCount;
                        for (int nCurrent = 0; nCurrent <= nCount; nCurrent++)
                        {
                            IPoint ptCurrent = new Point();
                            pCircularArc.QueryPoint(esriSegmentExtension.esriNoExtension, nCurrent * dbOffset, false, ptCurrent);
                            Pt2d ptCurrentImagePoint = getProjectBackwardPoint(ptCurrent, pDemRaster, pGetCameraView, pRotateMatrix, cameraPara);
                            if (ptCurrentImagePoint != null)
                            {
                                ptSingleImageFeaturePoints.Add(ptCurrentImagePoint);

                                //只保留端点的信息,用于创建点SHP图层
                                if (nCurrent == 0 || nCurrent == nCount)
                                {
                                    ptSingleImageFeaturePointsForPointShp.Add(ptCurrentImagePoint);
                                }
                            }
                        }
                    }
                    else
                    {
                        continue;
                    }
                }

                ptImageFeaturePoints.Add(ptSingleImageFeaturePoints);
                ptImageFeaturePointsForPointShp.Add(ptSingleImageFeaturePointsForPointShp);
            }
            #endregion

            #region 把节点位置信息写入
            IDataset   dataset   = (IDataset)pOutputPolylineFeatureClass;
            IWorkspace workspace = dataset.Workspace;

            //Cast for an IWorkspaceEdit
            IWorkspaceEdit workspaceEdit = workspace as IWorkspaceEdit;
            workspaceEdit.StartEditing(true);
            workspaceEdit.StartEditOperation();

            //////////////////////////////////////////////////////////////////////////
            //整条路线的添加
            IFeatureCursor pOutFCursor = null;
            for (int i = 0; i < ptImageFeaturePoints.Count; i++)
            {
                int            nPtsCount      = ptImageFeaturePoints[i].Count;
                IFeatureBuffer pFeatureBuffer = pOutputPolylineFeatureClass.CreateFeatureBuffer();
                pOutFCursor = pOutputPolylineFeatureClass.Insert(true);

                IPolyline        pPolyline        = new PolylineClass();
                IPointCollection pPointCollection = pPolyline as IPointCollection;

                for (int j = 0; j < nPtsCount; j++)
                {
                    IPoint pt = new PointClass();
                    pt.PutCoords(ptImageFeaturePoints[i][j].X, ptImageFeaturePoints[i][j].Y);
                    pPointCollection.AddPoint(pt);
                }

                if (!ClsGDBDataCommon.CopyFeatureFieldValue(pFeatureList[i], pFeatureBuffer as IFeature))
                {
                    continue;
                }
                pFeatureBuffer.Shape = pPolyline as IGeometry;
                object featureOID = pOutFCursor.InsertFeature(pFeatureBuffer);
            }

            if (pOutFCursor != null)
            {
                pOutFCursor.Flush();
            }

            //分段路线的添加
            for (int i = 0; i < ptImageFeaturePoints.Count; i++)
            {
                int nPtsCount = ptImageFeaturePoints[i].Count;
                for (int j = 0; j < nPtsCount - 1; j++)
                {
                    IFeatureBuffer pFeatureBuffer = pOutputPolylineFeatureClass.CreateFeatureBuffer();
                    pOutFCursor = pOutputPolylineFeatureClass.Insert(true);
                    IPolyline        pPolyline        = new PolylineClass();
                    IPointCollection pPointCollection = pPolyline as IPointCollection;

                    IPoint pt = new PointClass();
                    pt.PutCoords(ptImageFeaturePoints[i][j].X, ptImageFeaturePoints[i][j].Y);
                    pPointCollection.AddPoint(pt);
                    pt.PutCoords(ptImageFeaturePoints[i][j + 1].X, ptImageFeaturePoints[i][j + 1].Y);
                    pPointCollection.AddPoint(pt);

                    if (!ClsGDBDataCommon.CopyFeatureFieldValue(pFeatureList[i], pFeatureBuffer as IFeature))
                    {
                        continue;
                    }
                    pFeatureBuffer.Shape = pPolyline as IGeometry;
                    object featureOID = pOutFCursor.InsertFeature(pFeatureBuffer);
                }
            }
            if (pOutFCursor != null)
            {
                pOutFCursor.Flush();
            }

            //featureCursor.Flush();
            workspaceEdit.StopEditOperation();
            workspaceEdit.StopEditing(true);
            #endregion

            #region 点SHP文件的添加
            IDataset   pPointDataset   = (IDataset)pOutputPointFeatureClass;
            IWorkspace pPointWorkspace = pPointDataset.Workspace;

            //Cast for an IWorkspaceEdit
            IWorkspaceEdit pPointWorkspaceEdit = pPointWorkspace as IWorkspaceEdit;
            pPointWorkspaceEdit.StartEditing(true);
            pPointWorkspaceEdit.StartEditOperation();

            IFeatureCursor pOutPointFCursor = null;
            for (int i = 0; i < ptImageFeaturePointsForPointShp.Count; i++)
            {
                //int nSegmentCount = pSegmentCollection[i].SegmentCount;

                //IMultipoint pMultiPoint = new MultipointClass();
                for (int j = 0; j < ptImageFeaturePointsForPointShp[i].Count; j++)
                {
                    IFeatureBuffer pFeatureBuffer = pOutputPointFeatureClass.CreateFeatureBuffer();
                    pOutPointFCursor = pOutputPointFeatureClass.Insert(true);
                    IPoint pt   = new PointClass();
                    Pt2d   pt2d = ptImageFeaturePointsForPointShp[i][j];
                    pt.PutCoords(pt2d.X, pt2d.Y);

                    //CopyFeatureField(pFeatureList[i], pFeatureBuffer);
                    pFeatureBuffer.Shape = pt as IGeometry;
                    object featureOID = pOutPointFCursor.InsertFeature(pFeatureBuffer);
                }
            }

            if (pOutPointFCursor != null)
            {
                pOutPointFCursor.Flush();
            }

            //featureCursor.Flush();
            pPointWorkspaceEdit.StopEditOperation();
            pPointWorkspaceEdit.StopEditing(true);
            #endregion

            return(true);
        }
예제 #53
0
파일: Wpf.cs 프로젝트: 15831944/Sheet
 public void SetX2(ILine line, double x2)
 {
     (line.Native as Line).X2 = x2;
 }
예제 #54
0
 public void AddLine(ILine line)
 {
     Lines.Add(line);
 }
예제 #55
0
 /// <summary>
 /// 判断两点间是否存在直接连线
 /// </summary>
 /// <param name="src_id">出发点ID</param>
 /// <param name="dst_id">目标点ID</param>
 /// <param name="line">连接线</param>
 /// <returns>如果存在直接连线,返回true</returns>
 bool _HasDirectLine(string src_id, string dst_id, out ILine line)
 {
     return(this.dct_lines.TryGetValue(string.Format("{0}.{1}", src_id, dst_id), out line));
 }
예제 #56
0
 /// <summary>
 /// Initiates the class with a voice line
 /// </summary>
 /// <param name="line">The voice line to ask the questions on</param>
 public PromptFunctions(ILine line)
 {
     _line = line;
 }
예제 #57
0
            /// <summary>
            ///     Changes the type of the selected line.
            /// </summary>
            /// <param name="value">The value.</param>
            private void ChangeLineType(object value)
            {
                Type type = value as Type;

                if (type == null)
                {
                    throw new ArgumentException();
                }

                SelectedLine selectedLine = _selectedLine;

                if (selectedLine == null)
                {
                    return;
                }

                ILine currLine     = selectedLine.Line;
                Type  currLineType = currLine.GetType();

                if (type == currLineType)
                {
                    return;
                }

                ILine newLine;

                if (type == typeof(Line))
                {
                    newLine = new Line(currLine.Start, currLine.End);
                }
                else if (type == typeof(QuadraticBezierCurve))
                {
                    if (currLineType == typeof(Line))
                    {
                        newLine = new QuadraticBezierCurve(
                            currLine.Start,
                            new LineVector((currLine.Start.Vector + currLine.End.Vector) / 2),
                            currLine.End);
                    }
                    else if (currLineType == typeof(CubicBezierCurve))
                    {
                        CubicBezierCurve cubic = (CubicBezierCurve)currLine;

                        Vector2 vec = currLine.Start.Vector + (currLine.End.Vector - currLine.Start.Vector) / 2;
                        newLine = new QuadraticBezierCurve(
                            cubic.Start,
                            new LineVector(vec),
                            cubic.End);
                    }
                    else
                    {
                        throw new NotSupportedException(
                                  $"Cannot change a line of type '{currLineType.FullName}' to a line of type '{type.FullName}'.");
                    }
                }
                else if (type == typeof(CubicBezierCurve))
                {
                    if (currLineType == typeof(Line))
                    {
                        Vector2 vec = (currLine.End.Vector - currLine.Start.Vector) / 3;
                        newLine = new CubicBezierCurve(
                            currLine.Start,
                            new LineVector(currLine.Start.Vector + vec),
                            new LineVector(currLine.Start.Vector + vec + vec),
                            currLine.End);
                    }
                    else if (currLineType == typeof(QuadraticBezierCurve))
                    {
                        QuadraticBezierCurve quad = (QuadraticBezierCurve)currLine;

                        Vector2 start   = quad.Start.Vector;
                        Vector2 end     = quad.End.Vector;
                        Vector2 control = quad.ControlPoint.Vector;

                        newLine = new CubicBezierCurve(
                            quad.Start,
                            new LineVector(start + (2f / 3f * (control - start))),
                            new LineVector(end + (2f / 3f * (control - end))),
                            quad.End);
                    }
                    else
                    {
                        throw new NotSupportedException(
                                  $"Cannot change a line of type '{currLineType.FullName}' to a line of type '{type.FullName}'.");
                    }
                }
                else
                {
                    throw new NotSupportedException(
                              $"Cannot change a line of type '{currLineType.FullName}' to a line of type '{type.FullName}'.");
                }

                Debug.Assert(newLine.GetType() == type, "newLine.GetType() == type");

                selectedLine.EdgePart.Lines.Replace(currLine, newLine);

                _selectedLine = new SelectedLine(
                    selectedLine.Tile,
                    selectedLine.EdgePart,
                    newLine,
                    selectedLine.LineTransform);
            }
예제 #58
0
        /// <summary>
        /// Match parameters of an object and convert into a string.
        /// </summary>
        /// <param name="pattern"></param>
        /// <param name="key"></param>
        /// <returns>match as string or null</returns>
        public static string MatchToString(this ILinePattern pattern, ILine key)
        {
            ILinePatternMatch match = pattern.Match(key);

            return(pattern.Print(match.PartValues));
        }
예제 #59
0
        /// <summary>
        /// Get all resource names as string keys. If all cannot be returned, returns null.
        ///
        /// If <paramref name="filterKey"/> is provided, then the resulted lines are filtered based on the parameters in the <paramref name="filterKey"/>.
        /// If <paramref name="filterKey"/> has parameter assignment(s) <see cref="ILineParameter"/>, then result must be filtered to lines that have matching value for each parameter.
        /// If the parameter has value "", then the result must be filtered to keys that have "" for the same parameter, or don't have that same parameter assigned.
        ///
        /// The returned enumerable must be multi-thread safe. If the implementing class is mutable or <see cref="IAssetReloadable"/>, then
        /// it must return an enumerable that is a snapshot and will not throw <see cref="InvalidOperationException"/>.
        /// </summary>
        /// <param name="asset"></param>
        /// <param name="filterKey">(optional) key as filter</param>
        /// <returns>resource names, or null</returns>
        public static IEnumerable <ILine> GetAllResourceKeys(this IAsset asset, ILine filterKey = null)
        {
            IEnumerable <ILine> result = null;

            if (asset is IResourceAssetKeysEnumerable casted)
            {
                result = casted.GetAllResourceKeys(filterKey);
            }
            if (asset is IAssetComposition composition)
            {
                foreach (IResourceAssetKeysEnumerable component in composition.GetComponents <IResourceAssetKeysEnumerable>(true) ?? Enumerable.Empty <IResourceAssetKeysEnumerable>())
                {
                    IEnumerable <ILine> _result = component.GetAllResourceKeys(filterKey);
                    if (_result == null)
                    {
                        return(null);
                    }
                    if (_result is Array _array && _array.Length == 0)
                    {
                        continue;
                    }
                    result = result == null ? _result : result.Concat(_result);
                }
                foreach (IAssetProvider component in composition.GetComponents <IAssetProvider>(true) ?? Enumerable.Empty <IAssetProvider>())
                {
                    IEnumerable <IAsset> assets = component.LoadAssets(filterKey);
                    if (assets != null)
                    {
                        foreach (IAsset loaded_asset in assets)
                        {
                            IEnumerable <ILine> _result = loaded_asset.GetAllResourceKeys(filterKey);
                            if (_result == null)
                            {
                                return(null);
                            }
                            if (_result is Array _array && _array.Length == 0)
                            {
                                continue;
                            }
                            result = result == null ? _result : result.Concat(_result);
                        }
                    }
                }
            }
            if (asset is IAssetProvider provider)
            {
                IEnumerable <IAsset> assets = provider.LoadAllAssets(filterKey);
                if (assets != null)
                {
                    foreach (IAsset loaded_asset in assets)
                    {
                        IEnumerable <ILine> _result = loaded_asset.GetAllResourceKeys(filterKey);
                        if (_result == null)
                        {
                            return(null);
                        }
                        if (_result is Array _array && _array.Length == 0)
                        {
                            continue;
                        }
                        result = result == null ? _result : result.Concat(_result);
                    }
                }
            }
            return(result);
        }
예제 #60
0
파일: Wpf.cs 프로젝트: 15831944/Sheet
 public ItemColor GetStroke(ILine line)
 {
     return(GetItemColor((line.Native as Line).Stroke));
 }