Inheritance: RleObject, IComparable
コード例 #1
0
ファイル: LookupTable.cs プロジェクト: nohal/RleEditor
 public LookupTable Clone()
 {
     LookupTable lt = new LookupTable(this.ToString());
     lt.AttributeCombination = AttributeCombination;
     return lt;
 }
コード例 #2
0
ファイル: RleEditorForm.cs プロジェクト: nohal/RleEditor
 private void ReplaceLupt(string luptName)
 {
     OpenFileDialog dlg = new OpenFileDialog();
     dlg.Filter = "Lookup Table Files|*.dic|All Files|*.*";
     if (dlg.ShowDialog() == DialogResult.OK)
     {
         if (File.Exists(dlg.FileName))
         {
             StreamReader sr = new StreamReader(dlg.FileName);
             string line;
             while (!sr.EndOfStream)
             {
                 line = sr.ReadLine();
                 if (!line.StartsWith(";") && !line.StartsWith("*")) //Not header or remark
                 {
                     LookupTable lt = new LookupTable(line, 0, luptName);
                     bool found = false;
                     foreach (LookupTable lupt in parser.LookupTables[luptName].Values)
                     {
                         if (lupt.CompareTo(lt) == 0)
                         {
                             lt.ObjectId = lupt.ObjectId;
                             found = true;
                         }
                     }
                     if (!found)
                     {
                         lt.ObjectId = parser.NextId;
                         parser.NextId++;
                         parser.LookupTables[luptName].Add(lt.ObjectId, lt);
                     }
                     else
                     {
                         parser.LookupTables[luptName][lt.ObjectId] = lt;
                     }
                 }
             }
             sr.Close();
             changesSaved = false;
             RefillLookupTableView();
         }
     }
 }
コード例 #3
0
ファイル: RleParser.cs プロジェクト: nohal/RleEditor
 public string GetPointsSimplifiedText()
 {
     StringBuilder sb = new StringBuilder();
     foreach (var datacomponent in datacomponents)
     {
         if (IsSimplified(datacomponent))
         {
             LookupTable lu = new LookupTable(datacomponent);
             sb.AppendLine(lu.ToLuptString());
         }
     }
     return sb.ToString();
 }
コード例 #4
0
ファイル: RleParser.cs プロジェクト: nohal/RleEditor
        public RleParser(string rleFilename)
        {
            ColorTables = new Dictionary<string, ColorTable>();
            SymbolBitmaps = new Dictionary<string, BitmapSymbol>();
            PatternBitmaps = new Dictionary<string, BitmapPattern>();
            SymbolVectors = new Dictionary<string, VectorSymbol>();
            LineVectors = new Dictionary<string, VectorLine>();
            PatternVectors = new Dictionary<string, VectorPattern>();
            LookupTables = new Dictionary<string, Dictionary<int, LookupTable>>();
            LookupTables.Add(PLAIN_BOUNDARIES, new Dictionary<int, LookupTable>());
            LookupTables.Add(SYMBOLIZED_BOUNDARIES, new Dictionary<int, LookupTable>());
            LookupTables.Add(LINES, new Dictionary<int, LookupTable>());
            LookupTables.Add(SIMPLIFIED, new Dictionary<int, LookupTable>());
            LookupTables.Add(PAPER_CHART, new Dictionary<int, LookupTable>());

            StringBuilder sb = new StringBuilder();
            StringBuilder sbremarks = new StringBuilder();
            StreamReader sr = new StreamReader(rleFilename);
            string line;
            int counter = 1;
            while ((line = sr.ReadLine()) != null)
            {
                if (!line.Trim().StartsWith(";") && line.Trim() != string.Empty)
                {
                    if (line.StartsWith("0001"))
                    {
                        sb.Length = 0;
                    }
                    sb.AppendLine(line);
                    if (line.StartsWith("****"))
                    {
                        datacomponents.Add(sb.ToString());
                        if (IsColorTable(sb.ToString()))
                        {
                            ColorTable ct = new ColorTable(sb.ToString());
                            if (DefaultColorTable == null)
                            {
                                DefaultColorTable = ct;
                            }
                            ColorTables.Add(ct.Name, ct);
                        }

                        if (IsBitmap(sb.ToString()))
                        {
                            MergeBitmaps(sb.ToString());
                        }

                        if (IsVector(sb.ToString()))
                        {
                            MergeVectors(sb.ToString());
                        }
                        if (IsPaperChart(sb.ToString()))
                        {
                            LookupTable bp = new LookupTable(sb.ToString());
                            try
                            {
                                LookupTables[PAPER_CHART].Add(bp.ObjectId, bp);
                            }
                            catch (Exception ex)
                            {
                                Debug.Print("Lookup table {0} ({1}) can't be loaded with following message: {2}, replacing with the later definition",
                                                              bp.ObjectId, bp.Code, ex.Message);
                                LookupTables[PAPER_CHART][bp.ObjectId] = bp;
                            }
                            if (bp.ObjectId >= NextId)
                            {
                                NextId = bp.ObjectId + 1;
                            }
                        }

                        if (IsSimplified(sb.ToString()))
                        {
                            LookupTable bp = new LookupTable(sb.ToString());
                            try
                            {
                                LookupTables[RleParser.SIMPLIFIED].Add(bp.ObjectId, bp);
                            }
                            catch (Exception ex)
                            {
                                Debug.Print("Lookup table {0} ({1}) can't be loaded with following message: {2}, replacing with the later definition",
                                                              bp.ObjectId, bp.Code, ex.Message);
                                LookupTables[RleParser.SIMPLIFIED][bp.ObjectId] = bp;
                            }
                            if (bp.ObjectId >= NextId)
                            {
                                NextId = bp.ObjectId + 1;
                            }
                        }

                        if (IsLines(sb.ToString()))
                        {
                            LookupTable bp = new LookupTable(sb.ToString());
                            try
                            {
                                LookupTables[LINES].Add(bp.ObjectId, bp);
                            }
                            catch (Exception ex)
                            {
                                Debug.Print(
                                    "Lookup table {0} ({1}) can't be loaded with following message: {2}, replacing with the later definition",
                                    bp.ObjectId, bp.Code, ex.Message);
                                LookupTables[LINES][bp.ObjectId] = bp;
                            }
                            if (bp.ObjectId >= NextId)
                            {
                                NextId = bp.ObjectId + 1;
                            }
                        }

                        if (IsPlainBoundaries(sb.ToString()))
                        {
                            LookupTable bp = new LookupTable(sb.ToString());
                            try
                            {
                                LookupTables[PLAIN_BOUNDARIES].Add(bp.ObjectId, bp);
                            }
                            catch (Exception ex)
                            {
                                Debug.Print(
                                    "Lookup table {0} ({1}) can't be loaded with following message: {2}, replacing with the later definition",
                                    bp.ObjectId, bp.Code, ex.Message);
                                LookupTables[PLAIN_BOUNDARIES][bp.ObjectId] = bp;
                            }
                            if (bp.ObjectId >= NextId)
                            {
                                NextId = bp.ObjectId + 1;
                            }
                        }

                        if (IsSymbolizedBoundaries(sb.ToString()))
                        {
                            LookupTable bp = new LookupTable(sb.ToString());
                            try
                            {
                                LookupTables[SYMBOLIZED_BOUNDARIES].Add(bp.ObjectId, bp);
                            }
                            catch (Exception ex)
                            {
                                Debug.Print(
                                    "Lookup table {0} ({1}) can't be loaded with following message: {2}, replacing with the later definition",
                                    bp.ObjectId, bp.Code, ex.Message);
                                LookupTables[SYMBOLIZED_BOUNDARIES][bp.ObjectId] = bp;
                            }
                            if (bp.ObjectId >= NextId)
                            {
                                NextId = bp.ObjectId + 1;
                            }
                        }
                        sb.Length = 0; //Just to make sure in the official file at least one '0001' was missing...
                    }
                }
                else
                {
                    sbremarks.AppendLine(String.Format("{0:00000;-0000}: {1}", counter, line));
                }
                counter++;
            }
            sr.Close();
            remarks = sbremarks.ToString();
        }
コード例 #5
0
ファイル: RleParser.cs プロジェクト: nohal/RleEditor
 public string GetAreaSymbolizedBoundariesText()
 {
     StringBuilder sb = new StringBuilder();
     foreach (var datacomponent in datacomponents)
     {
         if (IsSymbolizedBoundaries(datacomponent))
         {
             LookupTable lu = new LookupTable(datacomponent);
             sb.AppendLine(lu.ToLuptString());
         }
     }
     return sb.ToString();
 }