C#反省規范圖幅編號。本站提示廣大學習愛好者:(C#反省規范圖幅編號)文章只能為提供參考,不一定能成為您想要的結果。以下是C#反省規范圖幅編號正文
/// <summary> /// 反省能否為規范圖幅編號 /// </summary> /// <param name="MapNumber">圖幅編號</param> /// <returns>反省後果True/false</returns> private bool CheckMapNumber(string MapNumber) { int ColumnNumber100; if (MapNumber.Length == 3)//1:100萬圖幅規則 { Regex RegMapNumber = new Regex(@"^[A-S]\d\d$"); if (RegMapNumber.IsMatch(MapNumber.ToUpper())) { ColumnNumber100 = Convert.ToInt32(MapNumber.Substring(1, 2)); if (ColumnNumber100 <= 60) { return true; } } } if (MapNumber.Length == 10)//其他圖幅規則 { string ScaleMark = ""; int ColumnNumber; int RowNumber; int RowMax = 0; int ColumnMax = 0; Regex RegMapNumber = new Regex(@"^[A-S]\d\d[B-H]\d\d\d\d\d\d$"); if (RegMapNumber.IsMatch(MapNumber.ToUpper())) { ScaleMark = MapNumber.Substring(3, 1); switch(ScaleMark) { case "B": RowMax = 2; ColumnMax = 2; break; case "C": RowMax = 4; ColumnMax = 4; break; case "D": RowMax = 12; ColumnMax = 12; break; case "E": RowMax = 24; ColumnMax = 24; break; case "F": RowMax = 48; ColumnMax = 48; break; case "G": RowMax = 96; ColumnMax = 96; break; case "H": RowMax = 192; ColumnMax = 192; break; default: RowMax = 0; ColumnMax = 0; break; } ColumnNumber100 = Convert.ToInt32(MapNumber.Substring(1, 2)); RowNumber = Convert.ToInt32(MapNumber.Substring(4, 3)); ColumnNumber = Convert.ToInt32(MapNumber.Substring(7, 3)); if (ColumnNumber100 <= 60 && RowNumber <= RowMax && ColumnNumber <= ColumnMax) { return true; } } } return false; }