|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
using Prism.Mvvm;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Windows.Media;
|
|
|
|
|
using Txgy.EWS.Client.Models;
|
|
|
|
|
|
|
|
|
|
namespace Txgy.EWS.Client.Models
|
|
|
|
|
{
|
|
|
|
|
public class CadLinePropertyModel:BindableBase
|
|
|
|
|
{
|
|
|
|
|
public string Name { get; set; }
|
|
|
|
|
[JsonIgnore]
|
|
|
|
|
public Color LineColor { get; set; }
|
|
|
|
|
[JsonProperty(PropertyName = "width")]
|
|
|
|
|
public double LineWidth { get; set; }
|
|
|
|
|
[JsonProperty(PropertyName = "close")]
|
|
|
|
|
public bool CloseLine { get; set; }
|
|
|
|
|
[JsonProperty(PropertyName = "layerHeight")]
|
|
|
|
|
public double LayerHeight { get; set; }
|
|
|
|
|
|
|
|
|
|
private bool isShow = true;
|
|
|
|
|
[JsonIgnore]
|
|
|
|
|
public bool IsShow
|
|
|
|
|
{
|
|
|
|
|
get { return isShow; }
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
SetProperty(ref isShow, value);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public CadLinePropertyModel()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
public CadLinePropertyModel(string name, Color lineColor, double lineWidth, bool closeLine, double layerHeight)
|
|
|
|
|
{
|
|
|
|
|
Name = name;
|
|
|
|
|
LineColor = lineColor;
|
|
|
|
|
LineWidth = lineWidth;
|
|
|
|
|
CloseLine = closeLine;
|
|
|
|
|
this.LayerHeight = layerHeight;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public static class CadLineList
|
|
|
|
|
{
|
|
|
|
|
public static List<CadLinePropertyModel> LineProperties { get; set; }
|
|
|
|
|
//public CadLineList()
|
|
|
|
|
//{
|
|
|
|
|
// LineProperties = ReadDwgLineList();
|
|
|
|
|
//}
|
|
|
|
|
public static List<CadLinePropertyModel> CreateList()
|
|
|
|
|
{
|
|
|
|
|
List<CadLinePropertyModel> clps = new List<CadLinePropertyModel>();
|
|
|
|
|
|
|
|
|
|
//clps.Add(new CadLinePropertyModel("已完成巷道", Colors.Black, 1));
|
|
|
|
|
|
|
|
|
|
return clps;
|
|
|
|
|
}
|
|
|
|
|
public static List<CadLinePropertyModel> ReadDwgLineList()
|
|
|
|
|
{
|
|
|
|
|
List<CadLinePropertyModel> lds = new List<CadLinePropertyModel>();
|
|
|
|
|
string filePath = AppDomain.CurrentDomain.BaseDirectory +
|
|
|
|
|
System.Configuration.ConfigurationManager.AppSettings["DwgSettings"].ToString();
|
|
|
|
|
string[] rows, cols;
|
|
|
|
|
using (StreamReader sr = new StreamReader(filePath))
|
|
|
|
|
{
|
|
|
|
|
rows = sr.ReadToEnd().Trim().Split(new char[] { '\n' }, StringSplitOptions.RemoveEmptyEntries);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (int i = 1; i < rows.Length; i++)
|
|
|
|
|
{
|
|
|
|
|
cols = rows[i].Trim('\r').Split(new char[] { '\t' }, StringSplitOptions.RemoveEmptyEntries);
|
|
|
|
|
string name = cols[0];
|
|
|
|
|
string[] ci = cols[1].Split(',');
|
|
|
|
|
Color color = Color.FromRgb(byte.Parse(ci[0]), byte.Parse(ci[1]), byte.Parse(ci[2]));
|
|
|
|
|
double lineW = double.Parse(cols[2]);
|
|
|
|
|
bool closeLine = true;
|
|
|
|
|
if (cols[3] == "0")
|
|
|
|
|
{
|
|
|
|
|
closeLine = false;
|
|
|
|
|
}
|
|
|
|
|
double lh = double.Parse(cols[4]);
|
|
|
|
|
lds.Add(new CadLinePropertyModel(name, color, lineW, closeLine, lh));
|
|
|
|
|
}
|
|
|
|
|
return lds;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//public static List<CadLinePropertyModel> ReadDwgFromJson(string fn)
|
|
|
|
|
//{
|
|
|
|
|
// using (System.IO.StreamReader sr = new System.IO.StreamReader(fn))
|
|
|
|
|
// {
|
|
|
|
|
// while (sr.EndOfStream)
|
|
|
|
|
// {
|
|
|
|
|
// string line = sr.ReadLine();
|
|
|
|
|
// if (line.Length>10)
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// List<CadLinePropertyModel> clpms = JsonHelper.DeserializeJsonToList<CadLinePropertyModel>(sr.ReadToEnd());
|
|
|
|
|
// return clpms;
|
|
|
|
|
// }
|
|
|
|
|
//}
|
|
|
|
|
}
|
|
|
|
|
}
|