|
using Newtonsoft.Json;
|
using System;
|
using System.Collections.Generic;
|
using System.Drawing;
|
using System.IO;
|
using System.Linq;
|
using System.Text;
|
using System.Threading.Tasks;
|
using System.Windows.Forms;
|
using static Yw.WinFrmUI.Q3d.MapViewEnum;
|
|
namespace Yw.WinFrmUI.Q3d
|
{
|
|
public static class Global
|
{
|
|
//public static TemplateList TemplateList;
|
|
|
public static List<MapObjectRecord> mapObjectRecords = new List<MapObjectRecord>();
|
public static int RecordIndex = 0;
|
public static List<string> curveStrings = new List<string>() { "流量扬程曲线", "流量功率曲线", "流量效率曲线" };
|
public static void ClearFileReadOnly(string filePath)
|
{
|
if (File.Exists(filePath))
|
{
|
// 获取当前文件属性
|
FileAttributes attributes = File.GetAttributes(filePath);
|
|
// 如果文件被设置为只读,则移除只读属性
|
if ((attributes & FileAttributes.ReadOnly) == FileAttributes.ReadOnly)
|
{
|
attributes &= ~FileAttributes.ReadOnly; // 移除只读标志
|
|
// 设置新的文件属性
|
File.SetAttributes(filePath, attributes);
|
|
|
}
|
|
}
|
}
|
}
|
public static class PointFExtansion
|
{
|
public static Point ToPoint(this PointF p)
|
{
|
return new Point((int)p.X, (int)p.Y);
|
}
|
}
|
|
|
public static class GlobalExtension
|
{
|
public static Type GetObjType(this MapObjectType type)
|
{
|
switch (type)
|
{
|
case MapObjectType.全部: return null;
|
case MapObjectType.节点: return typeof(JunctionViewModel);
|
case MapObjectType.水表: return typeof(MeterViewModel);
|
case MapObjectType.水库: return typeof(ReservoirViewModel);
|
case MapObjectType.水池: return typeof(TankViewModel);
|
case MapObjectType.喷头: return typeof(NozzleViewModel);
|
case MapObjectType.管线: return typeof(PipeViewModel);
|
case MapObjectType.阀门: return typeof(ValveViewModel);
|
|
case MapObjectType.水泵: return typeof(PumpViewModel);
|
|
default: return null;
|
}
|
|
}
|
public static bool isNodeType(this MapObjectType type)
|
{
|
switch (type)
|
{
|
case MapObjectType.全部: return true;
|
case MapObjectType.节点: return true;
|
case MapObjectType.水库: return true;
|
case MapObjectType.水池: return true;
|
case MapObjectType.喷头: return true;
|
case MapObjectType.阀门点: return true;
|
case MapObjectType.水泵点: return true;
|
|
|
|
default: return false;
|
}
|
|
}
|
|
}
|
|
public class MapObjectRecord
|
{
|
public IBaseViewModel mapObject { get; set; }
|
public string ValueName { get; set; }
|
|
public dynamic Value { get; set; }
|
|
}
|
|
|
}
|