Ejemplo n.º 1
0
        void AxMap1MouseMoveEvent(object sender, _DMapEvents_MouseMoveEvent e)
        {
            Labels labels = MainMap.get_DrawingLabels(0);

            labels.Clear();
            // it's assumed here that the layer we want to edit is the first 1 (with 0 index)
            int layerHandle = MainMap.get_LayerHandle(0);
            var sf          = MainMap.get_Shapefile(layerHandle);

            if (sf != null)
            {
                double projX = 0.0;
                double projY = 0.0;
                MainMap.PixelToProj(e.x, e.y, ref projX, ref projY);
                object result = null;
                var    ext    = new Extents();
                ext.SetBounds(projX, projY, 0.0, projX, projY, 0.0);
                if (sf.SelectShapes(ext, 0.0, SelectMode.INTERSECTION, ref result))
                {
                    int[] shapes = result as int[];
                    if (shapes != null && shapes.Length == 1)
                    {
                        string s = "";
                        for (int i = 0; i < sf.NumFields; i++)
                        {
                            s += sf.Field[i].Name + ": " + sf.CellValue[i, shapes[0]] + "\n";
                        }
                        labels.AddLabel(s, e.x + 80, e.y);
                    }
                }
            }
            MainMap.Redraw2(tkRedrawType.RedrawSkipDataLayers);
        }
Ejemplo n.º 2
0
        public void AddChaining()
        {
            var labels = new Labels();

            labels.AddLabel("test-1").AddLabel("test-2");

            Assert.AreEqual(2, labels.Count);
        }
Ejemplo n.º 3
0
        /// -------------------------------------------------------------------------------------------------
        /// <summary> Parse trace data. </summary>
        ///
        /// <remarks> 06/09/2018. </remarks>
        ///
        /// <param name="filename"> Filename of the file. </param>
        /// -------------------------------------------------------------------------------------------------
        public static void ParseTraceData(string filename)
        {
            //z80.asm|25|5|32828
            traceFiles = new List <TraceFile>();


            Regex registersregex = new Regex(@"^(?<filename>[_a-zA-Z0-9\\.]*)\|(?<line>[0-9]*)\|(?<bank>[0-9]*)\|(?<addr>[0-9]*)\|(?<type>[LFT])");

            string[] lines = File.ReadAllLines(filename);

            foreach (string s in lines)
            {
                if (!string.IsNullOrEmpty(s))
                {
                    var match = registersregex.Match(s);
                    //Console.WriteLine(match.Groups["label"] + " " + match.Groups["address"] + " " + match.Groups["type"] + " " + match.Groups["section"]);

                    string fn   = match.Groups["filename"].ToString();
                    int    bank = 0;
                    int.TryParse(match.Groups["bank"].ToString(), NumberStyles.Integer, null, out bank);
                    int line = 0;
                    int.TryParse(match.Groups["line"].ToString(), NumberStyles.Integer, null, out line);
                    int addr = 0;
                    int.TryParse(match.Groups["addr"].ToString(), NumberStyles.Integer, null, out addr);

                    if (match.Groups["type"].ToString() == "T")
                    {
                        TraceFile tracefile = TraceFile.FindTraceFile(fn);
                        if (tracefile == null)
                        {
                            Console.WriteLine("Adding file " + fn);
                            tracefile = new TraceFile(fn);
                            traceFiles.Add(tracefile);
                        }



                        //found source level debug symbol
                        LineData ld = new LineData();

                        ld.address    = addr;
                        ld.bank       = bank;
                        ld.lineNumber = line - 1;


                        tracefile.lines.Add(ld);
                    }
                    else if (match.Groups["type"].ToString() == "L")
                    {
                        Labels.AddLabel(fn, addr, bank, false);
                    }
                    else if (match.Groups["type"].ToString() == "F")
                    {
                        Labels.AddLabel(fn, addr, bank, true);
                    }
                }
            }
        }
Ejemplo n.º 4
0
        //public static void AddLabel(string  str, Labels labels, double projX, double projY)
        //{

        //	int[] i = (int[])result;
        //	Shape shp  = sf.Shape[i[0]];

        //	//	string temp = sf.CellValue[0, i[0]].ToString();
        //	string temp = sf.get_CellValue(1,i[0]).ToString();
        //	Point pnt = shp.Centroid;

        //	string aisLabel = "x=" + "121" + "      "  +
        //				"y=" + "30";
        //	labels.AddLabel(aisLabel, projX, projY, 0.0, -1);
        ////	labels.InsertLabel(0, aisLabel, projX, projY, 0.0, -1);

        //}

        public static void AddLabel(object result, Shapefile sf, Labels labels, double projX, double projY)
        {
            int[]  i    = (int[])result;
            Shape  shp  = sf.Shape[i[0]];
            string temp = sf.get_CellValue(1, i[0]).ToString();
            Point  pnt  = shp.Centroid;

            labels.AddLabel(temp, projX, projY);
        }
Ejemplo n.º 5
0
        // <summary>
        // Adds randomly positioned labels to the image layer.
        // </summary>
        public void ImageLabels(AxMap axMap1)
        {
            axMap1.Projection             = tkMapProjection.PROJECTION_NONE;
            axMap1.GrabProjectionFromData = true;

            Image          img = new Image();
            OpenFileDialog dlg = new OpenFileDialog {
                Filter = img.CdlgFilter
            };

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                img.Open(dlg.FileName, ImageType.USE_FILE_EXTENSION, false, null);
                axMap1.AddLayer(img, true);

                Labels lbl = img.Labels;
                lbl.FontSize = 12;
                lbl.FontBold = true;

                lbl.FontOutlineVisible = true;
                lbl.FontOutlineColor   = (255 << 16) + (255 << 8) + 255; //white
                lbl.FontOutlineWidth   = 4;

                LabelCategory cat = lbl.AddCategory("Red");
                cat.FontColor = 255;

                cat           = lbl.AddCategory("Blue");
                cat.FontColor = 255 << 16;

                cat           = lbl.AddCategory("Yellow");
                cat.FontColor = 255 + 255 << 8;

                Extents ext    = img.Extents;
                double  xRange = ext.xMax - ext.xMin;
                double  yRange = ext.yMax - ext.yMin;
                Random  rnd    = new Random();

                for (int i = 0; i < 100; i++)
                {
                    double x = xRange * rnd.NextDouble();
                    double y = yRange * rnd.NextDouble();

                    int categoryIndex = i % 3;
                    lbl.AddLabel("label" + Convert.ToString(i),
                                 ext.xMin + x, ext.yMin + y, i * 3.6, categoryIndex);
                }

                axMap1.Redraw();
            }
        }
Ejemplo n.º 6
0
        public void AddText(double x, double y)
        {
            Labels labels = sf.Labels;

            labels.FontSize     = 15;
            labels.FontBold     = true;
            labels.FrameVisible = false;
            labels.FrameType    = tkLabelFrameType.lfRectangle;
            labels.AutoOffset   = false;
            labels.OffsetX      = 40;

            LabelCategory cat = labels.AddCategory("wenzi");

            cat.FontColor = 255;


            string aisLabel = "文字部分";

            labels.AddLabel(aisLabel, x, y, 0.0, -1);
        }
Ejemplo n.º 7
0
        public void ImmediateValidationForAdd()
        {
            var labels = new Labels();

            labels.AddLabel("test-1").AddLabel("test.2");
        }
Ejemplo n.º 8
0
 public void Add(string text, double x, double y, double rotation = 0, int category = -1)
 {
     _labels.AddLabel(text, x, y, rotation, category);
 }
Ejemplo n.º 9
0
        /// -------------------------------------------------------------------------------------------------
        /// <summary> Parse trace data. </summary>
        ///
        /// <remarks> 06/09/2018. </remarks>
        ///
        /// <param name="filename"> Filename of the file. </param>
        /// -------------------------------------------------------------------------------------------------
        public static void ParseTraceData(string filename)
        {
            //z80.asm|25|5|32828
            traceFiles = new List <TraceFile>();

            string filenameregexchars = @"[_a-zA-Z0-9\\., :/@#$%^(){}\[\]!+=~-]";
            Regex  registersregex     = new Regex(
                @"^(?<filename>" + filenameregexchars + @"*)\|"
                + @"(?<line>[0-9:]+)\|"
                + @"(?<macrofile>" + filenameregexchars + @"*)\|"
                + @"(?<macroline>[0-9:]+)\|"
                + @"(?<bank>-?[0-9]+)\|"
                + @"(?<value>-?[0-9]+)\|"
                + @"(?<type>[LFTDZ])\|"
                + @"(?<label>.*)"
                );



            int index = 0;

            string[] lines = File.ReadAllLines(filename);

            foreach (string s in lines)
            {
                index++;
                if (!string.IsNullOrEmpty(s))
                {
                    if (s.StartsWith("||"))
                    {
                        Console.WriteLine("# comment: " + s.Substring(2));
                        continue;
                    }
                    if (s.StartsWith("|SLD.data.version|"))
                    {
                        var sldversion = s.Substring(18);
                        if (!"0".Equals(sldversion))
                        {
                            Console.WriteLine("# Unknown SLD version: " + sldversion);
                            //TODO some warning about unsupported SLD version
                        }
                        continue;
                    }
                    var match = registersregex.Match(s);
                    if (!match.Success)
                    {
                        Console.WriteLine("! matching failed for line: " + s);
                        continue;
                    }
                    Console.WriteLine(s);
                    //Console.WriteLine(match.Groups["label"] + " " + match.Groups["address"] + " " + match.Groups["type"] + " " + match.Groups["section"]);

                    string mfn   = match.Groups["macrofile"].ToString();
                    var    mline = ParseLineNumber(match.Groups["macroline"].ToString());

                    string fn    = match.Groups["filename"].ToString();
                    string label = match.Groups["label"].ToString();

                    int bank = 0;
                    int.TryParse(match.Groups["bank"].ToString(), NumberStyles.Integer, null, out bank);
                    var line  = ParseLineNumber(match.Groups["line"].ToString());
                    int value = 0;
                    int.TryParse(match.Groups["value"].ToString(), NumberStyles.Integer, null, out value);



                    if (match.Groups["type"].ToString() == "T")                         //Trace Data
                    {
                        fn = Path.GetFileName(fn);

                        TraceFile tracefile = TraceFile.FindTraceFile(fn);
                        if (tracefile == null)
                        {
                            Console.WriteLine("Adding file " + fn);
                            tracefile = new TraceFile(fn);
                            traceFiles.Add(tracefile);
                        }



                        //found source level debug symbol
                        LineData ld = new LineData();

                        //ld.address = addr;
                        //ld.bank = bank;
                        ld.lineNumber  = line.Item1 - 1;
                        ld.nextAddress = new NextAddress(value, bank);
                        ld.tf          = tracefile;

                        tracefile.lines.Add(ld);
                    }
                    else if (match.Groups["type"].ToString() == "L")                            //Label
                    {
                        Labels.AddLabel(label, value, bank, false, false);
                    }
                    else if (match.Groups["type"].ToString() == "D")        //Define
                    {
                        Labels.AddLabel(label, value, bank, false, true);
                    }
                    else if (match.Groups["type"].ToString() == "F")                            //Function
                    {
                        Labels.AddLabel(label, value, bank, true, false);
                    }
                }
            }
        }