提交 066b4882 编写于 作者: cdy816's avatar cdy816

日常Bug修改

上级 cab56e41
......@@ -15,7 +15,7 @@ namespace Cdy.Tag
/// <summary>
/// 质量戳常量
/// </summary>
public enum QulityConst
public enum QualityConst
{
/// <summary>
/// 好
......@@ -26,9 +26,13 @@ namespace Cdy.Tag
/// </summary>
Bad= 20,
/// <summary>
/// 初始状态
/// </summary>
Init = 63,
/// <summary>
/// 无数据
/// </summary>
Tick=253,
Tick =253,
/// <summary>
/// 保持和前置一样
/// </summary>
......
......@@ -185,52 +185,135 @@ namespace DBDevelopClientApi
///
/// </summary>
/// <param name="database"></param>
/// <param name="group"></param>
/// <returns></returns>
public Dictionary<int,Tuple<Cdy.Tag.Tagbase,Cdy.Tag.HisTag>> QueryTagByGroup(string database,string group)
public Dictionary<int, Tuple<Cdy.Tag.Tagbase, Cdy.Tag.HisTag>> QueryAllTag(string database)
{
Dictionary<int, Tuple<Cdy.Tag.Tagbase, Cdy.Tag.HisTag>> re = new Dictionary<int, Tuple<Cdy.Tag.Tagbase, Cdy.Tag.HisTag>>();
if (mCurrentClient != null && !string.IsNullOrEmpty(mLoginId))
{
var result = mCurrentClient.GetTagByGroup(new DBDevelopService.GetTagByGroupRequest() { Database = database, LoginId = mLoginId,Group=group });
Dictionary<int, Cdy.Tag.Tagbase> mRealTag = new Dictionary<int, Cdy.Tag.Tagbase>();
foreach(var vv in result.RealTag)
int idx = 0;
int count = 0;
do
{
var tag = GetTag((int)vv.TagType);
tag.Id = (int)vv.Id;
tag.LinkAddress = vv.LinkAddress;
tag.Name = vv.Name;
tag.Desc = vv.Desc;
mRealTag.Add(tag.Id, tag);
}
var result = mCurrentClient.GetAllTag(new DBDevelopService.GetTagByGroupRequest() { Database = database, LoginId = mLoginId });
Dictionary<int, Cdy.Tag.HisTag> mHisTag = new Dictionary<int, Cdy.Tag.HisTag>();
foreach (var vv in result.HisTag)
{
var tag = new Cdy.Tag.HisTag { Id = (int)vv.Id, TagType = (Cdy.Tag.TagType)vv.TagType, Type = (Cdy.Tag.RecordType)vv.Type, CompressType = (int)vv.CompressType };
if(vv.Parameter.Count>0)
idx = result.Index;
count = result.Count;
if (!result.Result) break;
Dictionary<int, Cdy.Tag.Tagbase> mRealTag = new Dictionary<int, Cdy.Tag.Tagbase>();
foreach (var vv in result.RealTag)
{
var tag = GetTag((int)vv.TagType);
tag.Id = (int)vv.Id;
tag.LinkAddress = vv.LinkAddress;
tag.Name = vv.Name;
tag.Desc = vv.Desc;
tag.Group = vv.Group;
mRealTag.Add(tag.Id, tag);
}
Dictionary<int, Cdy.Tag.HisTag> mHisTag = new Dictionary<int, Cdy.Tag.HisTag>();
foreach (var vv in result.HisTag)
{
var tag = new Cdy.Tag.HisTag { Id = (int)vv.Id, TagType = (Cdy.Tag.TagType)vv.TagType, Type = (Cdy.Tag.RecordType)vv.Type, CompressType = (int)vv.CompressType };
if (vv.Parameter.Count > 0)
{
tag.Parameters = new Dictionary<string, double>();
foreach (var vvv in vv.Parameter)
{
tag.Parameters.Add(vvv.Name, vvv.Value);
}
}
mHisTag.Add(tag.Id, tag);
}
foreach (var vv in mRealTag)
{
tag.Parameters = new Dictionary<string, double>();
foreach(var vvv in vv.Parameter)
if (mHisTag.ContainsKey(vv.Key))
{
tag.Parameters.Add(vvv.Name, vvv.Value);
re.Add(vv.Key, new Tuple<Cdy.Tag.Tagbase, Cdy.Tag.HisTag>(mRealTag[vv.Key], mHisTag[vv.Key]));
}
else
{
re.Add(vv.Key, new Tuple<Cdy.Tag.Tagbase, Cdy.Tag.HisTag>(mRealTag[vv.Key], null));
}
}
mHisTag.Add(tag.Id, tag);
idx++;
}
while (idx < count);
}
return re;
}
foreach(var vv in mRealTag)
/// <summary>
///
/// </summary>
/// <param name="database"></param>
/// <param name="group"></param>
/// <returns></returns>
public Dictionary<int,Tuple<Cdy.Tag.Tagbase,Cdy.Tag.HisTag>> QueryTagByGroup(string database,string group)
{
Dictionary<int, Tuple<Cdy.Tag.Tagbase, Cdy.Tag.HisTag>> re = new Dictionary<int, Tuple<Cdy.Tag.Tagbase, Cdy.Tag.HisTag>>();
if (mCurrentClient != null && !string.IsNullOrEmpty(mLoginId))
{
int idx = 0;
int count = 0;
do
{
if (mHisTag.ContainsKey(vv.Key))
var result = mCurrentClient.GetTagByGroup(new DBDevelopService.GetTagByGroupRequest() { Database = database, LoginId = mLoginId, Group = group,Index=idx });
idx = result.Index;
count = result.Count;
if (!result.Result) break;
Dictionary<int, Cdy.Tag.Tagbase> mRealTag = new Dictionary<int, Cdy.Tag.Tagbase>();
foreach (var vv in result.RealTag)
{
re.Add(vv.Key, new Tuple<Cdy.Tag.Tagbase, Cdy.Tag.HisTag>(mRealTag[vv.Key], mHisTag[vv.Key]));
var tag = GetTag((int)vv.TagType);
tag.Id = (int)vv.Id;
tag.LinkAddress = vv.LinkAddress;
tag.Name = vv.Name;
tag.Desc = vv.Desc;
tag.Group = vv.Group;
mRealTag.Add(tag.Id, tag);
}
else
Dictionary<int, Cdy.Tag.HisTag> mHisTag = new Dictionary<int, Cdy.Tag.HisTag>();
foreach (var vv in result.HisTag)
{
re.Add(vv.Key, new Tuple<Cdy.Tag.Tagbase, Cdy.Tag.HisTag>(mRealTag[vv.Key], null));
var tag = new Cdy.Tag.HisTag { Id = (int)vv.Id, TagType = (Cdy.Tag.TagType)vv.TagType, Type = (Cdy.Tag.RecordType)vv.Type, CompressType = (int)vv.CompressType };
if (vv.Parameter.Count > 0)
{
tag.Parameters = new Dictionary<string, double>();
foreach (var vvv in vv.Parameter)
{
tag.Parameters.Add(vvv.Name, vvv.Value);
}
}
mHisTag.Add(tag.Id, tag);
}
foreach (var vv in mRealTag)
{
if (mHisTag.ContainsKey(vv.Key))
{
re.Add(vv.Key, new Tuple<Cdy.Tag.Tagbase, Cdy.Tag.HisTag>(mRealTag[vv.Key], mHisTag[vv.Key]));
}
else
{
re.Add(vv.Key, new Tuple<Cdy.Tag.Tagbase, Cdy.Tag.HisTag>(mRealTag[vv.Key], null));
}
}
idx++;
}
while (idx < count);
}
return re;
}
......
......@@ -76,6 +76,7 @@ service DevelopServer {
//获取所有变量
rpc GetAllTag(GetTagByGroupRequest) returns (GetTagMessageReply);
//获取所有历史变量
rpc GetHisAllTag(GetRequest) returns (GetHistTagMessageReply);
......@@ -351,6 +352,7 @@ message GetTagByGroupRequest
string LoginId=1;
string Database=2;
string Group=3;
int32 Index=4;
}
//
......@@ -360,13 +362,17 @@ message BoolResultReplay
string ErroMessage=2;
}
//获取变量配置
message GetTagMessageReply
{
bool Result =1;
string ErroMessage=2;
repeated RealTagMessage realTag=3;
repeated HisTagMessage hisTag=4;
int32 Count=3;
int32 Index=4;
repeated RealTagMessage realTag=5;
repeated HisTagMessage hisTag=6;
}
message GetRealTagMessageReply
......
......@@ -6,6 +6,8 @@
<ApplicationIcon />
<OutputType>Library</OutputType>
<StartupObject />
<RunAnalyzersDuringBuild>false</RunAnalyzersDuringBuild>
<RunAnalyzersDuringLiveAnalysis>false</RunAnalyzersDuringLiveAnalysis>
</PropertyGroup>
<ItemGroup>
......
......@@ -76,6 +76,7 @@ service DevelopServer {
//获取所有变量
rpc GetAllTag(GetTagByGroupRequest) returns (GetTagMessageReply);
//获取所有历史变量
rpc GetHisAllTag(GetRequest) returns (GetHistTagMessageReply);
......@@ -351,6 +352,7 @@ message GetTagByGroupRequest
string LoginId=1;
string Database=2;
string Group=3;
int32 Index=4;
}
//
......@@ -360,13 +362,17 @@ message BoolResultReplay
string ErroMessage=2;
}
//获取变量配置
message GetTagMessageReply
{
bool Result =1;
string ErroMessage=2;
repeated RealTagMessage realTag=3;
repeated HisTagMessage hisTag=4;
int32 Count=3;
int32 Index=4;
repeated RealTagMessage realTag=5;
repeated HisTagMessage hisTag=6;
}
message GetRealTagMessageReply
......
......@@ -9,6 +9,8 @@ namespace DBDevelopService
{
public class DevelopServerService : DevelopServer.DevelopServerBase
{
public const int PageCount = 500;
/// <summary>
///
/// </summary>
......@@ -432,7 +434,7 @@ namespace DBDevelopService
{
foreach(var vv in db.RealDatabase.Groups)
{
re.Group.Add(new TagGroup() { Name = vv.Key, Parent = vv.Value.Parent.FullName });
re.Group.Add(new TagGroup() { Name = vv.Key, Parent = vv.Value.Parent!=null? vv.Value.Parent.FullName:"" });
}
}
return Task.FromResult(re);
......@@ -448,34 +450,47 @@ namespace DBDevelopService
{
if (!CheckLoginId(request.LoginId))
{
return Task.FromResult(new GetTagMessageReply() { Result = false });
return Task.FromResult(new GetTagMessageReply() { Result = false, Index = request.Index });
}
var db = DbManager.Instance.GetDatabase(request.Database);
List<RealTagMessage> rre = new List<RealTagMessage>();
List<HisTagMessage> re = new List<HisTagMessage>();
int totalpage = 0;
if (db != null)
{
foreach (var vv in db.RealDatabase.ListAllTags().Where(e=>e.Group == request.Group))
int from = request.Index * PageCount;
var res = db.RealDatabase.ListAllTags().Where(e => e.Group == request.Group);
var total = res.Count();
totalpage = total / PageCount;
totalpage = total % PageCount > 0 ? totalpage + 1 : totalpage;
int cc = 0;
foreach (var vv in res)
{
rre.Add(new RealTagMessage() { Id = (uint)vv.Id, Name = vv.Name, Desc = vv.Desc, Group = vv.Group, LinkAddress = vv.LinkAddress, TagType = (uint)vv.Type });
if(db.HisDatabase.HisTags.ContainsKey(vv.Id))
if (cc >= from && cc < (from + PageCount))
{
var vvv = db.HisDatabase.HisTags[vv.Id];
var vitem = new HisTagMessage() { Id = (uint)vv.Id, Type = (uint)vvv.Type, TagType = (uint)vvv.TagType, CompressType = (uint)vvv.CompressType,Circle=(ulong)vvv.Circle };
if (vvv.Parameters != null && vvv.Parameters.Count > 0)
rre.Add(new RealTagMessage() { Id = (uint)vv.Id, Name = vv.Name, Desc = vv.Desc, Group = vv.Group, LinkAddress = vv.LinkAddress, TagType = (uint)vv.Type });
if (db.HisDatabase.HisTags.ContainsKey(vv.Id))
{
foreach (var vvp in vvv.Parameters)
var vvv = db.HisDatabase.HisTags[vv.Id];
var vitem = new HisTagMessage() { Id = (uint)vv.Id, Type = (uint)vvv.Type, TagType = (uint)vvv.TagType, CompressType = (uint)vvv.CompressType, Circle = (ulong)vvv.Circle };
if (vvv.Parameters != null && vvv.Parameters.Count > 0)
{
vitem.Parameter.Add(new hisTagParameterItem() { Name = vvp.Key, Value = vvp.Value });
foreach (var vvp in vvv.Parameters)
{
vitem.Parameter.Add(new hisTagParameterItem() { Name = vvp.Key, Value = vvp.Value });
}
}
re.Add(vitem);
}
re.Add(vitem);
}
cc++;
}
}
var msg = new GetTagMessageReply() { Result = true };
var msg = new GetTagMessageReply() { Result = true,Count= totalpage, Index=request.Index };
msg.RealTag.AddRange(rre);
msg.HisTag.AddRange(re);
return Task.FromResult(msg);
......@@ -497,28 +512,41 @@ namespace DBDevelopService
List<RealTagMessage> rre = new List<RealTagMessage>();
List<HisTagMessage> re = new List<HisTagMessage>();
int totalpage = 0;
if (db != null)
{
foreach (var vv in db.RealDatabase.ListAllTags())
{
rre.Add(new RealTagMessage() { Id = (uint)vv.Id, Name = vv.Name, Desc = vv.Desc, Group = vv.Group, LinkAddress = vv.LinkAddress, TagType = (uint)vv.Type });
int from = request.Index * PageCount;
var res = db.RealDatabase.ListAllTags();
var total = res.Count();
totalpage = total / PageCount;
totalpage = total % PageCount > 0 ? totalpage + 1 : totalpage;
int cc = 0;
if (db.HisDatabase.HisTags.ContainsKey(vv.Id))
foreach (var vv in res)
{
if (cc >= from && cc < (from + PageCount))
{
var vvv = db.HisDatabase.HisTags[vv.Id];
var vitem = new HisTagMessage() { Id = (uint)vv.Id, Type = (uint)vv.Type, TagType = (uint)vvv.TagType, CompressType = (uint)vvv.CompressType, Circle = (ulong)vvv.Circle };
if (vvv.Parameters != null && vvv.Parameters.Count > 0)
rre.Add(new RealTagMessage() { Id = (uint)vv.Id, Name = vv.Name, Desc = vv.Desc, Group = vv.Group, LinkAddress = vv.LinkAddress, TagType = (uint)vv.Type });
if (db.HisDatabase.HisTags.ContainsKey(vv.Id))
{
foreach (var vvp in vvv.Parameters)
var vvv = db.HisDatabase.HisTags[vv.Id];
var vitem = new HisTagMessage() { Id = (uint)vv.Id, Type = (uint)vv.Type, TagType = (uint)vvv.TagType, CompressType = (uint)vvv.CompressType, Circle = (ulong)vvv.Circle };
if (vvv.Parameters != null && vvv.Parameters.Count > 0)
{
vitem.Parameter.Add(new hisTagParameterItem() { Name = vvp.Key, Value = vvp.Value });
foreach (var vvp in vvv.Parameters)
{
vitem.Parameter.Add(new hisTagParameterItem() { Name = vvp.Key, Value = vvp.Value });
}
}
re.Add(vitem);
}
re.Add(vitem);
}
cc++;
}
}
var msg = new GetTagMessageReply() { Result = true };
var msg = new GetTagMessageReply() { Result = true, Count = totalpage, Index = request.Index };
msg.RealTag.AddRange(rre);
msg.HisTag.AddRange(re);
return Task.FromResult(msg);
......@@ -779,7 +807,7 @@ namespace DBDevelopService
}
catch(Exception ex)
{
return Task.FromResult(new BoolResultReplay() { Result = true,ErroMessage = ex.Message });
return Task.FromResult(new BoolResultReplay() { Result = false,ErroMessage = ex.Message });
}
}
......@@ -804,11 +832,11 @@ namespace DBDevelopService
{
db.RealDatabase.AddOrUpdate(tag);
}
return Task.FromResult(new BoolResultReplay() { Result = false });
return Task.FromResult(new BoolResultReplay() { Result = true });
}
catch(Exception ex)
{
return Task.FromResult(new BoolResultReplay() { Result = true, ErroMessage = ex.Message });
return Task.FromResult(new BoolResultReplay() { Result = false, ErroMessage = ex.Message });
}
}
......@@ -889,33 +917,27 @@ namespace DBDevelopService
Cdy.Tag.Tagbase tag = GetRealTag(request.RealTag);
db.RealDatabase.Append(tag);
db.RealDatabase.AddOrUpdate(tag);
var vtag = request.HisTag;
if (vtag.Id != uint.MaxValue)
{
if (db.HisDatabase.HisTags.ContainsKey(tag.Id))
Cdy.Tag.HisTag hisTag = new Cdy.Tag.HisTag();
hisTag.Id = (int)vtag.Id;
hisTag.TagType = (Cdy.Tag.TagType)(vtag.TagType);
hisTag.Type = (Cdy.Tag.RecordType)(vtag.Type);
hisTag.CompressType = (int)(vtag.CompressType);
hisTag.Parameters = new Dictionary<string, double>();
if (vtag.Parameter != null)
{
Cdy.Tag.HisTag hisTag = new Cdy.Tag.HisTag();
hisTag.Id = (int)vtag.Id;
hisTag.TagType = (Cdy.Tag.TagType)(vtag.TagType);
hisTag.Type = (Cdy.Tag.RecordType)(vtag.Type);
hisTag.CompressType = (int)(vtag.CompressType);
hisTag.Parameters = new Dictionary<string, double>();
if (vtag.Parameter != null)
foreach (var vv in vtag.Parameter)
{
foreach (var vv in vtag.Parameter)
{
hisTag.Parameters.Add(vv.Name, vv.Value);
}
hisTag.Parameters.Add(vv.Name, vv.Value);
}
//hisTag.CompressParameter1 = vtag.CompressParameter1;
//hisTag.CompressParameter2 = vtag.CompressParameter2;
//hisTag.CompressParameter3 = vtag.CompressParameter3;
db.HisDatabase.AddOrUpdate(hisTag);
}
db.HisDatabase.AddOrUpdate(hisTag);
}
return Task.FromResult(new AddTagReplyMessage() { Result = true, TagId = tag.Id });
}
......
......@@ -96,7 +96,7 @@ namespace Cdy.Tag
public async Task Int()
{
await Scan(GetPrimaryHisDataPath());
await Scan(GetBackHisDataPath());
//await Scan(GetBackHisDataPath());
}
/// <summary>
......@@ -162,8 +162,7 @@ namespace Cdy.Tag
DateTime startTime = new DateTime(yy, mm, dd, hh, 0, 0);
YearTimeFile yt = new YearTimeFile() { TimeKey = yy };
yt.AddFile(startTime, new TimeSpan(hhspan, 0, 0), new DataFileInfo() { Duration = new TimeSpan(hhspan, 0, 0), StartTime = startTime, FileName = file.FullName } );
if(mTimeFileMaps.ContainsKey(id))
{
if (mTimeFileMaps[id].ContainsKey(yy))
......@@ -180,6 +179,7 @@ namespace Cdy.Tag
mTimeFileMaps.Add(id, new Dictionary<int, YearTimeFile>());
mTimeFileMaps[id].Add(yy, yt);
}
yt.AddFile(startTime, new TimeSpan(hhspan, 0, 0), new DataFileInfo() { Duration = new TimeSpan(hhspan, 0, 0), StartTime = startTime, FileName = file.FullName });
}
/// <summary>
......
......@@ -72,7 +72,7 @@ namespace Cdy.Tag
mPreFile = null;
mtime.Clear();
}
result.Add(false, vv.Key, (byte)QulityConst.Null);
result.Add(false, vv.Key, (byte)QualityConst.Null);
}
else if (vv.Value != mPreFile)
{
......@@ -117,7 +117,7 @@ namespace Cdy.Tag
mPreFile = null;
mtime.Clear();
}
result.Add((byte)0, vv.Key, (byte)QulityConst.Null);
result.Add((byte)0, vv.Key, (byte)QualityConst.Null);
}
else if (vv.Value != mPreFile)
{
......@@ -163,7 +163,7 @@ namespace Cdy.Tag
mPreFile = null;
mtime.Clear();
}
result.Add((short)0, vv.Key, (byte)QulityConst.Null);
result.Add((short)0, vv.Key, (byte)QualityConst.Null);
}
else if (vv.Value != mPreFile)
{
......@@ -208,7 +208,7 @@ namespace Cdy.Tag
mPreFile = null;
mtime.Clear();
}
result.Add((ushort)0, vv.Key, (byte)QulityConst.Null);
result.Add((ushort)0, vv.Key, (byte)QualityConst.Null);
}
else if (vv.Value != mPreFile)
{
......@@ -253,7 +253,7 @@ namespace Cdy.Tag
mPreFile = null;
mtime.Clear();
}
result.Add((int)0, vv.Key, (byte)QulityConst.Null);
result.Add((int)0, vv.Key, (byte)QualityConst.Null);
}
else if (vv.Value != mPreFile)
{
......@@ -298,7 +298,7 @@ namespace Cdy.Tag
mPreFile = null;
mtime.Clear();
}
result.Add((uint)0, vv.Key, (byte)QulityConst.Null);
result.Add((uint)0, vv.Key, (byte)QualityConst.Null);
}
else if (vv.Value != mPreFile)
{
......@@ -343,7 +343,7 @@ namespace Cdy.Tag
mPreFile = null;
mtime.Clear();
}
result.Add((ulong)0, vv.Key, (byte)QulityConst.Null);
result.Add((ulong)0, vv.Key, (byte)QualityConst.Null);
}
else if (vv.Value != mPreFile)
{
......@@ -389,7 +389,7 @@ namespace Cdy.Tag
mtime.Clear();
}
result.Add((long)0, vv.Key, (byte)QulityConst.Null);
result.Add((long)0, vv.Key, (byte)QualityConst.Null);
}
else if (vv.Value != mPreFile)
{
......@@ -436,7 +436,7 @@ namespace Cdy.Tag
mtime.Clear();
}
result.Add((float)0, vv.Key, (byte)QulityConst.Null);
result.Add((float)0, vv.Key, (byte)QualityConst.Null);
}
else if (vv.Value != mPreFile)
{
......@@ -482,7 +482,7 @@ namespace Cdy.Tag
mtime.Clear();
}
result.Add((double)0, vv.Key, (byte)QulityConst.Null);
result.Add((double)0, vv.Key, (byte)QualityConst.Null);
}
else if (vv.Value != mPreFile)
{
......@@ -527,7 +527,7 @@ namespace Cdy.Tag
mPreFile = null;
mtime.Clear();
}
result.Add(DateTime.Now, vv.Key, (byte)QulityConst.Null);
result.Add(DateTime.Now, vv.Key, (byte)QualityConst.Null);
}
else if (vv.Value != mPreFile)
{
......@@ -572,7 +572,7 @@ namespace Cdy.Tag
mPreFile = null;
mtime.Clear();
}
result.Add("", vv.Key, (byte)QulityConst.Null);
result.Add("", vv.Key, (byte)QualityConst.Null);
}
else if (vv.Value != mPreFile)
{
......
......@@ -1048,6 +1048,7 @@ namespace Cdy.Tag
foreach (var vv in times)
{
var ff = file.GetFileOffsets(vv);
if (ff <= 0) continue;
if (moffs.ContainsKey(ff))
{
moffs[ff].Add(vv);
......@@ -2554,6 +2555,17 @@ namespace Cdy.Tag
{
//Tag id 列表经过压缩,内容格式为:DataSize + Data
var dsize = datafile.ReadInt(dataoffset);
if (dsize <= 0)
{
tagCount = 0;
fileDuration = 0;
blockDuration = 0;
timetick = 0;
blockPointer = 0;
return new Dictionary<int, int>();
}
dataoffset += 4;
blockPointer = dataoffset + dsize - offset;
......@@ -2748,10 +2760,12 @@ namespace Cdy.Tag
int fileDuration, blockDuration = 0;
int tagCount = 0;
long blockpointer = 0;
var blockIndex = datafile.ReadTagIndexInDataPointer(tid, offset, out tagCount, out fileDuration, out blockDuration, out timetick,out blockpointer);
var tagIndex = datafile.ReadTagIndexInDataPointer(tid, offset, out tagCount, out fileDuration, out blockDuration, out timetick,out blockpointer);
int blockcount = fileDuration * 60 / blockDuration;
var startTime = datafile.ReadDateTime(16);
var startTime = datafile.ReadDateTime(0);
Dictionary<long, MarshalMemoryBlock> rtmp = new Dictionary<long, MarshalMemoryBlock>();
......@@ -2760,46 +2774,60 @@ namespace Cdy.Tag
foreach (var vdd in dataTimes)
{
var ttmp = (vdd - startTime).TotalMinutes;
int dindex = (int)(ttmp / blockDuration);
if (ttmp % blockDuration > 0)
{
dindex++;
}
int blockindex = (int)(ttmp / blockDuration);
//if (ttmp % blockDuration > 0)
//{
// blockindex++;
//}
if (dindex > blockcount)
if (blockindex > blockcount)
{
throw new Exception("DataPointer index is out of total block number");
}
var dataPointer = datafile.ReadLong(blockIndex * 8 + dindex * tagCount * 8); //读取DataBlock的地址
var datasize = datafile.ReadInt(dataPointer); //读取DataBlock 的大小
var dataPointer = datafile.ReadLong(offset + blockpointer + tagIndex * 8 + blockindex * tagCount * 8); //读取DataBlock的地址
if (!rtmp.ContainsKey(dataPointer))
{
var rmm = datafile.Read(dataPointer, datasize);
if (!re.ContainsKey(rmm))
{
re.Add(rmm, new List<DateTime>() { vdd });
}
else
{
re[rmm].Add(vdd);
}
rtmp.Add(dataPointer, rmm);
}
else
if (dataPointer > 0)
{
var rmm = rtmp[dataPointer];
if (!re.ContainsKey(rmm))
{
re.Add(rmm, new List<DateTime>() { vdd });
}
else
var datasize = datafile.ReadInt(dataPointer); //读取DataBlock 的大小
if (datasize > 0)
{
re[rmm].Add(vdd);
//var rmm = datafile.Read(dataPointer + 4, (int)datasize);
//if (!re.ContainsKey(rmm))
//{
// re.Add(rmm, new Tuple<DateTime, DateTime>(sstart, end));
//}
if (!rtmp.ContainsKey(dataPointer))
{
var rmm = datafile.Read(dataPointer + 4, datasize);
if (!re.ContainsKey(rmm))
{
re.Add(rmm, new List<DateTime>() { vdd });
}
else
{
re[rmm].Add(vdd);
}
rtmp.Add(dataPointer, rmm);
}
else
{
var rmm = rtmp[dataPointer];
if (!re.ContainsKey(rmm))
{
re.Add(rmm, new List<DateTime>() { vdd });
}
else
{
re[rmm].Add(vdd);
}
}
}
}
}
return re;
}
......@@ -2834,7 +2862,7 @@ namespace Cdy.Tag
while (sstart < end)
{
var ttmp = (sstart - startTime).TotalMinutes;
send = sstart.AddMinutes(blockDuration);
send = (sstart - new TimeSpan(0, 0, 0, sstart.Second, sstart.Millisecond)).AddMinutes(blockDuration);
if (send > end)
{
send = end;
......
......@@ -76,8 +76,15 @@ namespace Cdy.Tag
/// <param name="file"></param>
public MonthTimeFile AddMonth(int month, MonthTimeFile file)
{
file.Parent = this;
return this.AddTimefile(month, file) as MonthTimeFile;
if (this.ContainsKey(month))
{
return this[month] as MonthTimeFile;
}
else
{
file.Parent = this;
return this.AddTimefile(month, file) as MonthTimeFile;
}
}
/// <summary>
......
......@@ -119,14 +119,40 @@ namespace DBInRun
Cdy.Tag.RealDatabase test = db.RealDatabase;
db.RealDatabase = test;
string address = "";
for (int i=0;i<dcount;i++)
{
test.Append(new Cdy.Tag.DoubleTag() { Name = "Double" + i ,Group="Double",LinkAddress= "Sim:step" });
if(i%3==0)
{
address = "Sim:sin";
}
else if(i%3==1)
{
address = "Sim:cos";
}
else
{
address = "Sim:step";
}
test.Append(new Cdy.Tag.DoubleTag() { Name = "Double" + i ,Group="Double",LinkAddress= address });
}
for (int i = 0; i < fcount; i++)
{
test.Append(new Cdy.Tag.FloatTag() { Name = "Float" + i, Group = "Float", LinkAddress = "Sim:cos" });
if (i % 3 == 0)
{
address = "Sim:sin";
}
else if (i % 3 == 1)
{
address = "Sim:cos";
}
else
{
address = "Sim:step";
}
test.Append(new Cdy.Tag.FloatTag() { Name = "Float" + i, Group = "Float", LinkAddress = address });
}
for (int i = 0; i < lcount; i++)
......
{
"profiles": {
"DBInStudioServer": {
"commandName": "Executable",
"executablePath": "D:\\Project\\Galaxy\\Output\\DBInStudioServer.exe"
}
}
}
\ No newline at end of file
......@@ -1284,7 +1284,7 @@ namespace Cdy.Tag
}
else
{
result.Add(0, time1, (byte)QulityConst.Null);
result.Add(0, time1, (byte)QualityConst.Null);
}
resultCount++;
}
......
......@@ -521,7 +521,11 @@ namespace Cdy.Tag
/// </summary>
private void MemoryMerge(int count)
{
if (count == 0) mMergeMemory.CurrentDatetime = mWaitForMergeMemory.CurrentDatetime;
if (count == 0)
{
mMergeMemory.CurrentDatetime = mWaitForMergeMemory.CurrentDatetime;
LoggerService.Service.Info("HisEnginer", "MergeMemory 使用新的时间起点:" + mWaitForMergeMemory.Name + mMergeMemory.CurrentDatetime.ToString());
}
var mcc = mWaitForMergeMemory;
LoggerService.Service.Info("Record", "开始内存合并" + mcc.Name);
......@@ -591,9 +595,11 @@ namespace Cdy.Tag
CurrentMemory = mCachMemory1;
}
if(mMergeCount==0)
CurrentMemory.CurrentDatetime = dateTime;
if (mMergeCount==0)
{
CurrentMemory.CurrentDatetime = dateTime;
LoggerService.Service.Info("HisEnginer", "使用新的时间起点:" + CurrentMemory.Name + " " + CurrentMemory.CurrentDatetime.ToString());
HisRunTag.StartTime = dateTime;
}
//PrepareForReadyMemory();
......@@ -665,7 +671,7 @@ namespace Cdy.Tag
var tag = mHisTags[vv.Key];
long timeraddr = vv.Value.Item1 + vv.Value.Item2-4;
long timeraddr = vv.Value.Item1 + vv.Value.Item2-2;
long valueaddr = vv.Value.Item1 + vv.Value.Item3-tag.SizeOfValue;
long qaddr = vv.Value.Item1 + vv.Value.Item4-1;
......
......@@ -140,7 +140,7 @@ namespace Cdy.Tag
public void UpdateNone()
{
Count = ++Count > MaxCount ? MaxCount : Count;
HisAddr[HisQulityStartAddr + Count] = (byte)QulityConst.Tick;
HisAddr[HisQulityStartAddr + Count] = (byte)QualityConst.Tick;
}
/// <summary>
......
......@@ -90,6 +90,9 @@ namespace Cdy.Tag
}
}
/// <summary>
///
/// </summary>
public IntPtr MemoryHandle
{
get
......@@ -119,6 +122,7 @@ namespace Cdy.Tag
public void Init()
{
long msize = 0;
byte unknowQuality = (byte)QualityConst.Init;
mIdAndAddr.Clear();
foreach (var vv in mConfigDatabase.Tags)
{
......@@ -128,7 +132,7 @@ namespace Cdy.Tag
{
case TagType.Bool:
case TagType.Byte:
msize+=10;
msize +=10;
break;
case TagType.Short:
case TagType.UShort:
......@@ -153,6 +157,35 @@ namespace Cdy.Tag
mUsedSize = (long)(msize * 1.2);
mMemory = new byte[mUsedSize];
mMHandle = mMemory.AsMemory().Pin().Pointer;
foreach (var vv in mConfigDatabase.Tags)
{
switch (vv.Value.Type)
{
case TagType.Bool:
case TagType.Byte:
MemoryHelper.WriteByte(mMHandle, vv.Value.ValueAddress + 9, unknowQuality);
break;
case TagType.Short:
case TagType.UShort:
MemoryHelper.WriteByte(mMHandle, vv.Value.ValueAddress + 10, unknowQuality);
break;
case TagType.Int:
case TagType.UInt:
case TagType.Float:
MemoryHelper.WriteByte(mMHandle, vv.Value.ValueAddress + 12, unknowQuality);
break;
case TagType.Long:
case TagType.ULong:
case TagType.Double:
MemoryHelper.WriteByte(mMHandle, vv.Value.ValueAddress + 16, unknowQuality);
break;
case TagType.String:
MemoryHelper.WriteByte(mMHandle, vv.Value.ValueAddress + Const.StringSize + 8, unknowQuality);
break;
}
}
}
/// <summary>
......@@ -223,6 +256,7 @@ namespace Cdy.Tag
public void SetValueByAddr(long addr, byte value)
{
mMemory[addr] = value;
MemoryHelper.WriteByte(mMHandle, addr + 9, 0);
}
/// <summary>
......@@ -247,6 +281,7 @@ namespace Cdy.Tag
public void SetValueByAddr(long addr, short value)
{
MemoryHelper.WriteShort(mMHandle, addr, value);
MemoryHelper.WriteByte(mMHandle, addr + 10, 0);
}
/// <summary>
......@@ -271,6 +306,7 @@ namespace Cdy.Tag
public void SetValueByAddr(long addr, int value)
{
MemoryHelper.WriteInt32(mMHandle, addr, value);
MemoryHelper.WriteByte(mMHandle, addr + 12, 0);
}
/// <summary>
......@@ -295,6 +331,7 @@ namespace Cdy.Tag
public void SetValueByAddr(long addr, long value)
{
MemoryHelper.WriteInt64(mMHandle, addr, value);
MemoryHelper.WriteByte(mMHandle, addr + 16, 0);
}
/// <summary>
......@@ -308,7 +345,7 @@ namespace Cdy.Tag
{
MemoryHelper.WriteInt64(mMHandle, addr, value);
MemoryHelper.WriteDateTime(mMHandle, addr + 8, time);
MemoryHelper.WriteByte(mMHandle, addr + 16, qulity); ;
MemoryHelper.WriteByte(mMHandle, addr + 16, qulity);
}
......@@ -321,6 +358,7 @@ namespace Cdy.Tag
public void SetValueByAddr(long addr, float value)
{
MemoryHelper.WriteFloat(mMHandle, addr, value);
MemoryHelper.WriteByte(mMHandle, addr + 12, 0);
}
/// <summary>
......@@ -345,6 +383,7 @@ namespace Cdy.Tag
public void SetValueByAddr(long addr, double value)
{
MemoryHelper.WriteDouble(mMHandle, addr, value);
MemoryHelper.WriteByte(mMHandle, addr + 16, 0);
}
/// <summary>
......@@ -369,6 +408,7 @@ namespace Cdy.Tag
public void SetValueByAddr(long addr, DateTime value)
{
MemoryHelper.WriteDateTime(mMHandle, addr, value);
MemoryHelper.WriteByte(mMHandle, addr + 16, 0);
}
/// <summary>
......@@ -396,6 +436,7 @@ namespace Cdy.Tag
MemoryHelper.WriteByte(mMHandle, addr, (byte)value.Length);
System.Buffer.BlockCopy(value.ToCharArray(), 0, mMemory, (int)addr+1, value.Length);
MemoryHelper.WriteByte(mMHandle, Const.StringSize + 8, 0);
}
/// <summary>
......@@ -409,9 +450,14 @@ namespace Cdy.Tag
{
System.Buffer.BlockCopy(value.ToCharArray(), 0, mMemory, (int)addr, value.Length);
MemoryHelper.WriteDateTime(mMHandle, Const.StringSize, time);
MemoryHelper.WriteByte(mMHandle, Const.StringSize + 8, qulity); ;
MemoryHelper.WriteByte(mMHandle, Const.StringSize + 8, qulity);
}
/// <summary>
///
/// </summary>
/// <param name="id"></param>
/// <param name="value"></param>
public void SetValue(int id, bool value)
{
if (value)
......
......@@ -93,6 +93,26 @@
</DataTemplate>
</Button.ContentTemplate>
</Button>
<Button Style="{DynamicResource MenuButton}" Command="{Binding ExportCommand}" HorizontalAlignment="Left" Margin="10,0,0,0" Height="32" VerticalAlignment="Center" Width="80" >
<Button.ContentTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Image Source="/Image/export.png" Height="16" RenderOptions.BitmapScalingMode="NearestNeighbor" />
<TextBlock Text="{local:ResMarker Export}" VerticalAlignment="Center" Margin="5,0"/>
</StackPanel>
</DataTemplate>
</Button.ContentTemplate>
</Button>
<Button Style="{DynamicResource MenuButton}" Command="{Binding ImportCommand}" HorizontalAlignment="Left" Margin="10,0,0,0" Height="32" VerticalAlignment="Center" Width="80" >
<Button.ContentTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Image Source="/Image/import.png" Height="16" RenderOptions.BitmapScalingMode="NearestNeighbor" />
<TextBlock Text="{local:ResMarker Import}" VerticalAlignment="Center" Margin="5,0"/>
</StackPanel>
</DataTemplate>
</Button.ContentTemplate>
</Button>
</StackPanel>
</Border>
<Grid Grid.Row="1">
......
......@@ -60,6 +60,15 @@ namespace DBInStudio.Desktop.Properties {
}
}
/// <summary>
/// 查找类似 Value 的本地化字符串。
/// </summary>
internal static string AbsoluteValue {
get {
return ResourceManager.GetString("AbsoluteValue", resourceCulture);
}
}
/// <summary>
/// 查找类似 Add 的本地化字符串。
/// </summary>
......@@ -69,6 +78,15 @@ namespace DBInStudio.Desktop.Properties {
}
}
/// <summary>
/// 查找类似 Add tag {0} failed! 的本地化字符串。
/// </summary>
internal static string AddTagFail {
get {
return ResourceManager.GetString("AddTagFail", resourceCulture);
}
}
/// <summary>
/// 查找类似 Cancel 的本地化字符串。
/// </summary>
......@@ -114,6 +132,15 @@ namespace DBInStudio.Desktop.Properties {
}
}
/// <summary>
/// 查找类似 Type 的本地化字符串。
/// </summary>
internal static string DeadAreaType {
get {
return ResourceManager.GetString("DeadAreaType", resourceCulture);
}
}
/// <summary>
/// 查找类似 Dead zone 的本地化字符串。
/// </summary>
......@@ -141,6 +168,15 @@ namespace DBInStudio.Desktop.Properties {
}
}
/// <summary>
/// 查找类似 erro 的本地化字符串。
/// </summary>
internal static string erro {
get {
return ResourceManager.GetString("erro", resourceCulture);
}
}
/// <summary>
/// 查找类似 Export 的本地化字符串。
/// </summary>
......@@ -250,11 +286,11 @@ namespace DBInStudio.Desktop.Properties {
}
/// <summary>
/// 查找类似 Nome 的本地化字符串。
/// 查找类似 None 的本地化字符串。
/// </summary>
internal static string NomeCompress {
internal static string NoneCompress {
get {
return ResourceManager.GetString("NomeCompress", resourceCulture);
return ResourceManager.GetString("NoneCompress", resourceCulture);
}
}
......@@ -276,6 +312,15 @@ namespace DBInStudio.Desktop.Properties {
}
}
/// <summary>
/// 查找类似 Percent 的本地化字符串。
/// </summary>
internal static string PercentValue {
get {
return ResourceManager.GetString("PercentValue", resourceCulture);
}
}
/// <summary>
/// 查找类似 Record 的本地化字符串。
/// </summary>
......@@ -411,6 +456,15 @@ namespace DBInStudio.Desktop.Properties {
}
}
/// <summary>
/// 查找类似 Update tag {0} failed! 的本地化字符串。
/// </summary>
internal static string UpdateTagFail {
get {
return ResourceManager.GetString("UpdateTagFail", resourceCulture);
}
}
/// <summary>
/// 查找类似 UserName 的本地化字符串。
/// </summary>
......
......@@ -117,9 +117,15 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="AbsoluteValue" xml:space="preserve">
<value>Value</value>
</data>
<data name="Add" xml:space="preserve">
<value>Add</value>
</data>
<data name="AddTagFail" xml:space="preserve">
<value>Add tag {0} failed!</value>
</data>
<data name="Cancel" xml:space="preserve">
<value>Cancel</value>
</data>
......@@ -136,6 +142,9 @@
<data name="DeadAreaCompress" xml:space="preserve">
<value>Dead zone</value>
</data>
<data name="DeadAreaType" xml:space="preserve">
<value>Type</value>
</data>
<data name="DeadAreaValue" xml:space="preserve">
<value>Dead zone</value>
</data>
......@@ -145,6 +154,9 @@
<data name="Driver" xml:space="preserve">
<value>Driver</value>
</data>
<data name="erro" xml:space="preserve">
<value>erro</value>
</data>
<data name="Export" xml:space="preserve">
<value>Export</value>
</data>
......@@ -182,8 +194,8 @@
<data name="NewDatabaseFailed" xml:space="preserve">
<value>New database failed!</value>
</data>
<data name="NomeCompress" xml:space="preserve">
<value>Nome</value>
<data name="NoneCompress" xml:space="preserve">
<value>None</value>
</data>
<data name="OK" xml:space="preserve">
<value>OK</value>
......@@ -191,6 +203,9 @@
<data name="Password" xml:space="preserve">
<value>Password</value>
</data>
<data name="PercentValue" xml:space="preserve">
<value>Percent</value>
</data>
<data name="Record" xml:space="preserve">
<value>Record</value>
</data>
......@@ -237,6 +252,9 @@
<data name="Type" xml:space="preserve">
<value>Type</value>
</data>
<data name="UpdateTagFail" xml:space="preserve">
<value>Update tag {0} failed!</value>
</data>
<data name="UserName" xml:space="preserve">
<value>UserName</value>
</data>
......
{
"profiles": {
"DBInStudio.Desktop": {
"commandName": "Executable",
"executablePath": "D:\\Project\\Galaxy\\Output\\DBInStudio.exe"
}
}
}
\ No newline at end of file
......@@ -10,9 +10,16 @@
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="637*"/>
<ColumnDefinition Width="120"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock Text="{res:ResMarker DeadAreaValue,:}" Margin="5,0" VerticalAlignment="Center" />
<TextBox Width="100" HorizontalAlignment="Left" Margin="5,0" Text="{Binding DeadValue,Mode=TwoWay}" Grid.Column="1" VerticalAlignment="Center" />
<TextBlock Text="{res:ResMarker DeadAreaValue,:}" Margin="5,0,5,0" VerticalAlignment="Center" />
<TextBox Width="100" HorizontalAlignment="Left" Margin="5,0,0,0" Text="{Binding DeadValue,Mode=TwoWay}" Grid.Column="1" VerticalAlignment="Center" />
<TextBlock Grid.Column="2" Text="{res:ResMarker DeadAreaType,:}" Margin="5,0,5,0" VerticalAlignment="Center" />
<ComboBox SelectedIndex="{Binding Type,UpdateSourceTrigger=PropertyChanged}" Grid.Column="3" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="5,0" Width="80" >
<ComboBoxItem Content="{res:ResMarker AbsoluteValue}" />
<ComboBoxItem Content="{res:ResMarker PercentValue}" />
</ComboBox>
</Grid>
</UserControl>
......@@ -10,9 +10,16 @@
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="637*"/>
<ColumnDefinition Width="120"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock Text="{res:ResMarker SlopeAreaValue,:}" Margin="5,0" VerticalAlignment="Center" />
<TextBox Width="100" HorizontalAlignment="Left" Margin="5,0" Text="{Binding SlopeValue,Mode=TwoWay}" Grid.Column="1" VerticalAlignment="Center" />
<TextBlock Grid.Column="2" Text="{res:ResMarker DeadAreaType,:}" Margin="5,0,5,0" VerticalAlignment="Center" />
<ComboBox SelectedIndex="{Binding Type,UpdateSourceTrigger=PropertyChanged}" Grid.Column="3" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="5,0" Width="80" >
<ComboBoxItem Content="{res:ResMarker AbsoluteValue}" />
<ComboBoxItem Content="{res:ResMarker PercentValue}" />
</ComboBox>
</Grid>
</UserControl>
......@@ -107,29 +107,28 @@
</DataGrid.Columns>
<DataGrid.RowDetailsTemplate>
<DataTemplate>
<Grid Margin="4" Visibility="{Binding HasHisTag,Converter={StaticResource btv}}">
<Grid Margin="10,4" Visibility="{Binding HasHisTag,Converter={StaticResource btv}}" Height="36">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="30" />
<RowDefinition Height="30" />
</Grid.RowDefinitions>
<TextBlock Text="{local:ResMarker RecordType,:}" VerticalAlignment="Center" />
<ComboBox Margin="4,0" Grid.Column="1" Width="100" VerticalAlignment="Center" Text="{Binding RecordTypeString,Mode=OneWay}" SelectedIndex="{Binding RecordType,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" ItemsSource="{Binding RecordTypeList}"/>
<Grid Margin="4,0" Grid.Column="2" Visibility="{Binding IsTimerRecord,Converter={StaticResource btv}}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock Text="{local:ResMarker Circle,:}" VerticalAlignment="Center" />
<TextBox Margin="8,0" Grid.Column="1" Width="60" Text="{Binding CompressCircle,Mode=TwoWay}" VerticalAlignment="Center" />
</Grid>
<TextBlock Text="{local:ResMarker CompressType,:}" Grid.Row="1" VerticalAlignment="Center"/>
<ComboBox Margin="8,0" Width="100" Grid.Row="1" Grid.Column="1" VerticalAlignment="Center" ItemsSource="{Binding CompressTypeList}" SelectedIndex="{Binding CompressType,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"/>
<ContentControl Grid.Row="1" Grid.Column="2" VerticalAlignment="Center" Content="{Binding CompressParameterModel}" HorizontalAlignment="Stretch" />
<StackPanel Grid.Column="2" Orientation="Horizontal">
<Grid Margin="4,0" Visibility="{Binding IsTimerRecord,Converter={StaticResource btv}}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock Text="{local:ResMarker Circle,:}" VerticalAlignment="Center" />
<TextBox Margin="8,0" Grid.Column="1" Width="60" Text="{Binding CompressCircle,Mode=TwoWay}" VerticalAlignment="Center" />
</Grid>
<TextBlock Text="{local:ResMarker CompressType,:}" VerticalAlignment="Center"/>
<ComboBox Margin="8,0" Width="100" VerticalAlignment="Center" ItemsSource="{Binding CompressTypeList}" SelectedIndex="{Binding CompressType,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"/>
<ContentControl VerticalAlignment="Center" Content="{Binding CompressParameterModel}" HorizontalAlignment="Stretch" />
</StackPanel>
</Grid>
</DataTemplate>
</DataGrid.RowDetailsTemplate>
......
......@@ -82,6 +82,7 @@ namespace DBInStudio.Desktop.ViewModel
#region ... Variables ...
private double mDeadValue;
private int mDeadType;
#endregion ...Variables...
#region ... Events ...
......@@ -94,8 +95,8 @@ namespace DBInStudio.Desktop.ViewModel
#region ... Properties ...
/// <summary>
/// 死区值
/// </summary>
/// 死区值
/// </summary>
public double DeadValue
{
get
......@@ -112,6 +113,23 @@ namespace DBInStudio.Desktop.ViewModel
}
}
public int Type
{
get
{
return mDeadType;
}
set
{
mDeadType = value;
FillParameters();
OnPropertyChanged("Type");
}
}
#endregion ...Properties...
#region ... Methods ...
......@@ -129,6 +147,15 @@ namespace DBInStudio.Desktop.ViewModel
{
this.mDeadValue = 0;
}
if (Parameters.ContainsKey("DeadType"))
{
this.mDeadType = (int)(Parameters["DeadType"]);
}
else
{
this.mDeadType = 0;
}
}
/// <summary>
......@@ -144,6 +171,15 @@ namespace DBInStudio.Desktop.ViewModel
{
Parameters.Add("DeadValue", DeadValue);
}
if (Parameters.ContainsKey("DeadType"))
{
Parameters["DeadType"] = Type;
}
else
{
Parameters.Add("DeadType", Type);
}
}
#endregion ...Methods...
......@@ -158,6 +194,7 @@ namespace DBInStudio.Desktop.ViewModel
#region ... Variables ...
private double mSlopeValue;
private int mSlopeType;
#endregion ...Variables...
#region ... Events ...
......@@ -170,8 +207,8 @@ namespace DBInStudio.Desktop.ViewModel
#region ... Properties ...
/// <summary>
/// 斜率值
/// </summary>
/// 斜率值
/// </summary>
public double SlopeValue
{
get
......@@ -189,6 +226,21 @@ namespace DBInStudio.Desktop.ViewModel
}
}
public int Type
{
get
{
return mSlopeType;
}
set
{
mSlopeType = value;
FillParameters();
OnPropertyChanged("SlopeType");
}
}
#endregion ...Properties...
#region ... Methods ...
......@@ -198,14 +250,23 @@ namespace DBInStudio.Desktop.ViewModel
/// </summary>
public override void Init()
{
if (Parameters.ContainsKey("SlopeValue"))
if (Parameters.ContainsKey("SlopeArea"))
{
this.mSlopeValue = Parameters["SlopeValue"];
this.mSlopeValue = Parameters["SlopeArea"];
}
else
{
this.mSlopeValue = 0;
}
if (Parameters.ContainsKey("SlopeType"))
{
this.mSlopeType = (int)Parameters["SlopeType"];
}
else
{
this.mSlopeType = 0;
}
}
/// <summary>
......@@ -213,13 +274,22 @@ namespace DBInStudio.Desktop.ViewModel
/// </summary>
public override void FillParameters()
{
if (Parameters.ContainsKey("SlopeValue"))
if (Parameters.ContainsKey("SlopeArea"))
{
Parameters["SlopeArea"] = SlopeValue;
}
else
{
Parameters.Add("SlopeArea", SlopeValue);
}
if (Parameters.ContainsKey("SlopeType"))
{
Parameters["SlopeValue"] = SlopeValue;
Parameters["SlopeType"] = Type;
}
else
{
Parameters.Add("SlopeValue", SlopeValue);
Parameters.Add("SlopeType", Type);
}
}
......
......@@ -18,7 +18,7 @@ namespace DBInStudio.Desktop
{
#region ... Variables ...
private string mName;
internal string mName;
private bool mIsSelected = false;
private bool mIsExpanded = false;
private bool mIsEdit;
......
......@@ -143,7 +143,7 @@ namespace DBInStudio.Desktop.ViewModel
private void CheckLocalServerRun()
{
if(mServer=="127.0.0.1"&&mServer=="localhost")
if(mServer=="127.0.0.1"||mServer=="localhost")
{
var pps = Process.GetProcessesByName("DBInStudioServer");
if(pps==null||pps.Length==0)
......
......@@ -17,6 +17,8 @@ using System.Threading.Tasks;
using System.Threading;
using System.Windows;
using DBDevelopClientApi;
using Microsoft.Win32;
using System.IO;
namespace DBInStudio.Desktop
{
......@@ -36,6 +38,10 @@ namespace DBInStudio.Desktop
private ICommand mAddGroupCommand;
private ICommand mRemoveGroupCommand;
private ICommand mExportCommand;
private ICommand mImportCommand;
private TreeItemViewModel mCurrentSelectTreeItem;
......@@ -49,6 +55,8 @@ namespace DBInStudio.Desktop
private ViewModelBase mContentViewModel;
private bool mIsCanOperate = true;
#endregion ...Variables...
#region ... Events ...
......@@ -61,6 +69,63 @@ namespace DBInStudio.Desktop
#region ... Properties ...
/// <summary>
///
/// </summary>
public bool IsCanOperate
{
get
{
return mIsCanOperate;
}
set
{
if (mIsCanOperate != value)
{
mIsCanOperate = value;
OnPropertyChanged("IsCanOperate");
}
}
}
/// <summary>
///
/// </summary>
public ICommand ImportCommand
{
get
{
if(mImportCommand==null)
{
mImportCommand = new RelayCommand(() => {
ImportFromFile();
});
}
return mImportCommand;
}
}
/// <summary>
///
/// </summary>
public ICommand ExportCommand
{
get
{
if (mExportCommand == null)
{
mExportCommand = new RelayCommand(() => {
ExportToFile();
});
}
return mExportCommand;
}
}
/// <summary>
///
/// </summary>
public ViewModelBase ContentViewModel
{
get
......@@ -204,6 +269,78 @@ namespace DBInStudio.Desktop
#region ... Methods ...
/// <summary>
///
/// </summary>
private void ImportFromFile()
{
IsCanOperate = false;
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "csv|*.csv";
List<TagViewModel> ltmp = new List<TagViewModel>();
if (ofd.ShowDialog().Value)
{
var stream = new StreamReader(File.Open(ofd.FileName, FileMode.OpenOrCreate, FileAccess.ReadWrite));
while (!stream.EndOfStream)
{
string sval = stream.ReadLine();
if (!string.IsNullOrEmpty(sval))
{
TagViewModel tm = TagViewModel.LoadFromCSVString(sval);
ltmp.Add(tm);
}
}
stream.Close();
}
Task.Run(() => {
int id;
foreach (var vv in ltmp)
{
if (!DevelopServiceHelper.Helper.AddTag(this.mDatabase, new Tuple<Cdy.Tag.Tagbase, Cdy.Tag.HisTag>(vv.RealTagMode, vv.HisTagMode), out id))
{
MessageBox.Show(string.Format(Res.Get("UpdateTagFail"), vv.RealTagMode.Name), Res.Get("erro"), MessageBoxButton.OK, MessageBoxImage.Error);
break;
}
}
Application.Current.Dispatcher.BeginInvoke(new Action(() => {
IsCanOperate = true;
SelectContentModel();
}));
});
}
/// <summary>
///
/// </summary>
private void ExportToFile()
{
IsCanOperate = false;
SaveFileDialog ofd = new SaveFileDialog();
ofd.Filter = "csv|*.csv";
if (ofd.ShowDialog().Value)
{
var stream = new StreamWriter(File.Open(ofd.FileName, FileMode.OpenOrCreate, FileAccess.ReadWrite));
var res = DevelopServiceHelper.Helper.QueryAllTag(mDatabase);
foreach (var vv in res.Select(e=>new TagViewModel(e.Value.Item1,e.Value.Item2)))
{
stream.WriteLine(vv.SaveToCSVString());
}
stream.Close();
}
IsCanOperate = true;
}
/// <summary>
......@@ -305,7 +442,7 @@ namespace DBInStudio.Desktop
foreach(var vvv in vv.Where(e=>string.IsNullOrEmpty(e.Value)))
{
Application.Current.Dispatcher.Invoke(() => {
TagGroupViewModel groupViewModel = new TagGroupViewModel() { Name = vvv.Key,Database=mDatabase };
TagGroupViewModel groupViewModel = new TagGroupViewModel() { mName = vvv.Key,Database=mDatabase };
mRootTagGroupModel.Children.Add(groupViewModel);
groupViewModel.InitData(vv);
});
......
//==============================================================
// Copyright (C) 2020 Inc. All rights reserved.
//
//==============================================================
// Create by 种道洋 at 2020/4/7 11:28:35.
// Version 1.0
// 种道洋
//==============================================================
using System;
using System.Collections.Generic;
using System.Text;
using Cdy.Tag;
namespace DBInStudio.Desktop.ViewModel
{
/// <summary>
///
/// </summary>
public static class TagExportHelper
{
/// <summary>
///
/// </summary>
/// <param name="tags"></param>
/// <param name="file"></param>
public static void ExportToCSV(this List<TagViewModel> tags,string file)
{
System.IO.StreamWriter writer = new System.IO.StreamWriter(System.IO.File.Open(file, System.IO.FileMode.CreateNew,System.IO.FileAccess.ReadWrite,System.IO.FileShare.ReadWrite),Encoding.Unicode);
foreach(var vv in tags)
{
writer.WriteLine(vv.SaveToCSV());
}
writer.Flush();
writer.Close();
}
/// <summary>
///
/// </summary>
/// <param name="tag"></param>
/// <returns></returns>
public static string SaveToCSV(this TagViewModel tag)
{
string re = string.Empty;
re = tag.RealTagMode.Id + "," + tag.RealTagMode.Name + "," + tag.RealTagMode.Desc + "," + tag.RealTagMode.Type.ToString() + "," + tag.RealTagMode.LinkAddress + "," + tag.RealTagMode.Group;
if (tag.HisTagMode != null)
{
re += ";" + tag.HisTagMode.Type + "," + tag.HisTagMode.Circle + "," + tag.HisTagMode.CompressType;
if (tag.HisTagMode.Parameters != null && tag.HisTagMode.Parameters.Count > 0)
{
foreach (var vv in tag.HisTagMode.Parameters)
{
re += "," + vv.Key + "," + vv.Value;
}
}
}
return re;
}
/// <summary>
///
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
public static Tuple<Cdy.Tag.Tagbase, Cdy.Tag.HisTag> LoadFromCSV(string value)
{
Tuple<Cdy.Tag.Tagbase, Cdy.Tag.HisTag> re;
Cdy.Tag.Tagbase realtag = null;
Cdy.Tag.HisTag histag = null;
var strs = value.Split(new char[] { ';' });
string[] sval = strs[0].Split(new char[] { ',' });
realtag = Cdy.Tag.TagTypeExtends.GetTag((Cdy.Tag.TagType)Enum.Parse(typeof(Cdy.Tag.TagType), sval[3]));
realtag.Id = int.Parse(sval[0]);
realtag.Name = sval[1];
re = new Tuple<Cdy.Tag.Tagbase, Cdy.Tag.HisTag>(realtag, histag);
return re;
}
}
}
......@@ -8,8 +8,10 @@
//==============================================================
using DBDevelopClientApi;
using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows;
......@@ -90,7 +92,7 @@ namespace DBInStudio.Desktop.ViewModel
if (mExportCommand == null)
{
mExportCommand = new RelayCommand(() => {
ExportToFile();
});
}
return mExportCommand;
......@@ -107,7 +109,7 @@ namespace DBInStudio.Desktop.ViewModel
if (mImportCommand == null)
{
mImportCommand = new RelayCommand(() => {
ImportFromFile();
});
}
return mImportCommand;
......@@ -167,18 +169,99 @@ namespace DBInStudio.Desktop.ViewModel
{
return mSelectGroupTags;
}
set
{
mSelectGroupTags = value;
OnPropertyChanged("SelectGroupTags");
}
}
#endregion ...Properties...
#region ... Methods ...
/// <summary>
///
/// </summary>
private void ExportToFile()
{
SaveFileDialog ofd = new SaveFileDialog();
ofd.Filter = "csv|*.csv";
if(ofd.ShowDialog().Value)
{
var stream = new StreamWriter(File.Open(ofd.FileName, FileMode.OpenOrCreate, FileAccess.ReadWrite));
foreach(var vv in mSelectGroupTags)
{
stream.WriteLine(vv.SaveToCSVString());
}
stream.Close();
}
}
/// <summary>
///
/// </summary>
private void ImportFromFile()
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "csv|*.csv";
List<TagViewModel> ltmp = new List<TagViewModel>();
if (ofd.ShowDialog().Value)
{
var stream = new StreamReader(File.Open(ofd.FileName, FileMode.OpenOrCreate, FileAccess.ReadWrite));
while(!stream.EndOfStream)
{
string sval = stream.ReadLine();
if (!string.IsNullOrEmpty(sval))
{
TagViewModel tm = TagViewModel.LoadFromCSVString(sval);
ltmp.Add(tm);
}
}
stream.Close();
}
var tags = mSelectGroupTags.ToDictionary(e => e.RealTagMode.Id);
foreach(var vv in ltmp)
{
if(tags.ContainsKey(vv.RealTagMode.Id))
{
if(!DevelopServiceHelper.Helper.UpdateTag(GroupModel.Database, new Tuple<Cdy.Tag.Tagbase, Cdy.Tag.HisTag>(vv.RealTagMode, vv.HisTagMode)))
{
MessageBox.Show(string.Format(Res.Get("UpdateTagFail"), vv.RealTagMode.Name),Res.Get("erro"),MessageBoxButton.OK,MessageBoxImage.Error);
break;
}
}
else
{
int id;
if (!DevelopServiceHelper.Helper.AddTag(GroupModel.Database, new Tuple<Cdy.Tag.Tagbase, Cdy.Tag.HisTag>(vv.RealTagMode, vv.HisTagMode), out id))
{
MessageBox.Show(string.Format(Res.Get("AddTagFail"), vv.RealTagMode.Name), Res.Get("erro"), MessageBoxButton.OK, MessageBoxImage.Error);
break;
}
else
{
vv.RealTagMode.Id = id;
if (vv.HisTagMode != null) vv.HisTagMode.Id = id;
vv.IsChanged = false;
vv.IsNew = false;
}
}
}
System.Threading.Tasks.Task.Run(() => { QueryTags();});
}
/// <summary>
///
/// </summary>
private void QueryTags()
{
Application.Current.Dispatcher.Invoke(() => {
mSelectGroupTags.Clear();
});
var vtags = new System.Collections.ObjectModel.ObservableCollection<TagViewModel>();
var vv = DevelopServiceHelper.Helper.QueryTagByGroup(this.GroupModel.Database, this.GroupModel.FullName);
if (vv != null)
......@@ -187,11 +270,13 @@ namespace DBInStudio.Desktop.ViewModel
{
Application.Current.Dispatcher.BeginInvoke(new Action(() => {
TagViewModel model = new TagViewModel(vvv.Value.Item1, vvv.Value.Item2);
mSelectGroupTags.Add(model);
vtags.Add(model);
}));
}
}
SelectGroupTags = vtags;
}
......
......@@ -14,6 +14,7 @@ using System.Linq;
using System.Windows.Input;
using DBDevelopClientApi;
using DBInStudio.Desktop.ViewModel;
using Cdy.Tag;
namespace DBInStudio.Desktop
{
......@@ -60,7 +61,7 @@ namespace DBInStudio.Desktop
InitEnumType();
mCompressTypeList = new string[]
{
Res.Get("NomeCompress"),
Res.Get("NoneCompress"),
Res.Get("LosslessCompress"),
Res.Get("DeadAreaCompress"),
Res.Get("SlopeCompress")
......@@ -646,6 +647,9 @@ namespace DBInStudio.Desktop
IsChanged = true;
}
/// <summary>
///
/// </summary>
private void CheckRecordTypeParameterModel()
{
if(mHisTagMode==null)
......@@ -746,6 +750,87 @@ namespace DBInStudio.Desktop
return new TagViewModel(ntag,htag);
}
/// <summary>
///
/// </summary>
/// <returns></returns>
public string SaveToCSVString()
{
StringBuilder sb = new StringBuilder();
sb.Append(mRealTagMode.Id+",");
sb.Append(mRealTagMode.Name + ",");
sb.Append(mRealTagMode.Desc + ",");
sb.Append(mRealTagMode.Group + ",");
sb.Append(mRealTagMode.Type + ",");
sb.Append(mRealTagMode.LinkAddress + ",");
if(this.mHisTagMode!=null)
{
sb.Append(mHisTagMode.Type + ",");
sb.Append(mHisTagMode.Circle + ",");
sb.Append(mHisTagMode.CompressType + ",");
if(mHisTagMode.Parameters!=null)
{
foreach(var vv in mHisTagMode.Parameters)
{
sb.Append(vv.Key + ",");
sb.Append(vv.Value + ",");
}
}
}
sb.Length = sb.Length > 0 ? sb.Length - 1 : sb.Length;
return sb.ToString();
}
/// <summary>
///
/// </summary>
/// <param name="val"></param>
public static TagViewModel LoadFromCSVString(string val)
{
string[] stmp = val.Split(new char[] { ',' });
Cdy.Tag.TagType tp = (Cdy.Tag.TagType)Enum.Parse(typeof(Cdy.Tag.TagType),stmp[4]);
var realtag = TagTypeExtends.GetTag(tp);
realtag.Id = int.Parse(stmp[0]);
realtag.Name = stmp[1];
realtag.Desc = stmp[2];
realtag.Group = stmp[3];
realtag.LinkAddress = stmp[5];
if (stmp.Length > 6)
{
Cdy.Tag.HisTag histag = new HisTag();
histag.Type = (Cdy.Tag.RecordType)Enum.Parse(typeof(Cdy.Tag.RecordType), stmp[6]);
histag.Circle = long.Parse(stmp[7]);
histag.CompressType = int.Parse(stmp[8]);
histag.Parameters = new Dictionary<string, double>();
histag.TagType = realtag.Type;
histag.Id = realtag.Id;
for (int i=9;i<stmp.Length;i++)
{
string skey = stmp[i];
if(string.IsNullOrEmpty(skey))
{
break;
}
double dval = double.Parse(stmp[i + 1]);
if(!histag.Parameters.ContainsKey(skey))
{
histag.Parameters.Add(skey, dval);
}
i++;
}
return new TagViewModel(realtag, histag);
}
return new TagViewModel(realtag, null);
}
#endregion ...Methods...
......
......@@ -4,6 +4,6 @@
xmlns:local="clr-namespace:HisDataTools"
StartupUri="MainWindow.xaml">
<Application.Resources>
<ResourceDictionary Source="/HisDataTools;component/Chart/ChartGeneric.xaml" />
</Application.Resources>
</Application>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Media;
using System.Windows.Media.Imaging;
namespace HeBianGu.General.DrawingBrush.Bitmap
{
public class BitmapBase : IBitmap
{
public WriteableBitmap Source { get; set; }
public BitmapBase(int width,int height)
{
Source = new WriteableBitmap(width, height, 96, 96, PixelFormats.Bgr32, null);
this.Width = width;
this.Height = height;
}
public int Height { get; set; }
public int Width { get; }
public List<IBrush> Brushs { get; set; } = new List<IBrush>();
public IBitmap Draw()
{
Int32Rect rect = new Int32Rect(0, 0, (int)Width, Height);
byte[] pixels = new byte[(int)Width * Height * Source.Format.BitsPerPixel / 8];
for (int y = 0; y < Source.PixelHeight; y++)
{
for (int x = 0; x < Source.PixelWidth; x++)
{
int alpha = 0;
int red = 0;
int green = 0;
int blue = 0;
int weight = x;
int height = y;
//red = (int)((double)height / Source.PixelWidth * 255);
//green = rand.Next(100, 255);
//blue = (int)((double)weight / wb.PixelHeight * 255);
alpha = 50;
foreach (var item in this.Brushs)
{
item.Draw(weight, height, ref red, ref green, ref blue);
}
int pixelOffset = (x + y * Source.PixelWidth) * Source.Format.BitsPerPixel / 8;
pixels[pixelOffset] = (byte)blue;
pixels[pixelOffset + 1] = (byte)green;
pixels[pixelOffset + 2] = (byte)red;
pixels[pixelOffset + 3] = (byte)alpha;
}
int stride = (Source.PixelWidth * Source.Format.BitsPerPixel) / 8;
Source.WritePixels(rect, pixels, stride, 0);
}
return this;
}
public void GetColor(int x, int y, ref int red, ref int green, ref int blue)
{
foreach (var item in this.Brushs)
{
item.Draw(x, y, ref red, ref green, ref blue);
}
}
}
}
using System.Windows.Media.Imaging;
namespace HeBianGu.General.DrawingBrush
{
public interface IBitmap
{
WriteableBitmap Source { get; set; }
IBitmap Draw();
void GetColor(int x, int y, ref int red, ref int green, ref int blue);
}
}
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Media;
using System.Windows.Media.Imaging;
namespace HeBianGu.General.DrawingBrush
{
public class LinearBitmap : IBitmap
{
public WriteableBitmap Source { get; set; }
public LinearBitmap(int width)
{
Source = new WriteableBitmap((int)width, Height, 96, 96, PixelFormats.Bgr32, null);
this.Width = width;
}
public int Height { get; set; } = 1;
public int Width { get; }
public int Mosaic { get; set; } = 2;
public List<LinearBrush> LinearBrushs { get; set; } = new List<LinearBrush>();
public IBitmap Draw()
{
Int32Rect rect = new Int32Rect(0, 0, (int)Width, Height);
byte[] pixels = new byte[(int)Width * Height * Source.Format.BitsPerPixel / 8];
for (int y = 0; y < Source.PixelHeight; y++)
{
for (int x = 0; x < Source.PixelWidth; x++)
{
int alpha = 0;
int red = 0;
int green = 0;
int blue = 0;
int weight = x - x % Mosaic;
int height = y - y % Mosaic;
//red = (int)((double)height / Source.PixelWidth * 255);
//green = rand.Next(100, 255);
//blue = (int)((double)weight / wb.PixelHeight * 255);
alpha = 50;
foreach (var item in this.LinearBrushs)
{
item.Draw(weight, height, ref red, ref green, ref blue);
}
int pixelOffset = (x + y * Source.PixelWidth) * Source.Format.BitsPerPixel / 8;
pixels[pixelOffset] = (byte)blue;
pixels[pixelOffset + 1] = (byte)green;
pixels[pixelOffset + 2] = (byte)red;
pixels[pixelOffset + 3] = (byte)alpha;
}
int stride = (Source.PixelWidth * Source.Format.BitsPerPixel) / 8;
Source.WritePixels(rect, pixels, stride, 0);
}
return this;
}
public static LinearBitmap operator +(LinearBitmap b, LinearBitmap c)
{
int width = b.Width + c.Width;
LinearBitmap result = new LinearBitmap(width);
foreach (var item in b.LinearBrushs)
{
result.LinearBrushs.Add(item);
}
foreach (var item in c.LinearBrushs)
{
LinearBrush linearBrush = item.Clone();
linearBrush.Start = linearBrush.Start + b.Width;
linearBrush.End = linearBrush.End + b.Width;
result.LinearBrushs.Add(linearBrush);
}
result.Draw();
return result;
}
public static LinearBitmap operator -(LinearBitmap b, LinearBitmap c)
{
int width = b.Width - c.Width;
LinearBitmap result = new LinearBitmap(width);
var collection = b.LinearBrushs.Take(b.LinearBrushs.Count - c.LinearBrushs.Count);
foreach (var item in collection)
{
result.LinearBrushs.Add(item);
}
result.Draw();
return result;
}
public LinearBitmap RemoveLast()
{
var last = this.LinearBrushs.LastOrDefault();
if (last == null || this.LinearBrushs.Count == 1) return null;
int width = this.Width - last.End + last.Start;
LinearBitmap result = new LinearBitmap(width);
var collection = this.LinearBrushs.Take(this.LinearBrushs.Count - 1);
foreach (var item in collection)
{
result.LinearBrushs.Add(item);
}
result.Draw();
return result;
}
public void GetColor(int x, int y, ref int red, ref int green, ref int blue)
{
foreach (var item in this.LinearBrushs)
{
item.Draw(x, y, ref red, ref green, ref blue);
}
}
}
}
using HeBianGu.General.DrawingBrush.Bitmap;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media;
namespace HeBianGu.General.DrawingBrush
{
public class PlanarGridBitmap: BitmapBase
{
public PlanarGridBitmap(int width, int height):base(width, height)
{
}
}
}

namespace HeBianGu.General.DrawingBrush
{
public interface IBrush
{
void Draw(int x, int y, ref int r, ref int g, ref int b);
}
}
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media;
namespace HeBianGu.General.DrawingBrush
{
public class LinearBrush : IBrush
{
public GradientStopCollection GradientStops { get; set; } = new GradientStopCollection();
public int Start { get; set; }
public int End { get; set; }
List<Tuple<GradientStop, GradientStop>> _gradientStopTuple;
public List<Tuple<GradientStop, GradientStop>> GradientStopTuple
{
get
{
if (_gradientStopTuple == null)
{
_gradientStopTuple = this.BeginDraw();
}
return _gradientStopTuple;
}
}
public void Draw(int x, int y, ref int r, ref int g, ref int b)
{
if (x < Start || x > End) return;
var red = this.Get(x, (l, k) => k.Color.R - l.Color.R, l => l.Color.R);
if (red != null) r = red.Value;
var green = this.Get(x, (l, k) => k.Color.G - l.Color.G, l => l.Color.G);
if (green != null) g = green.Value;
var blue = this.Get(x, (l, k) => k.Color.B - l.Color.B, l => l.Color.B);
if (blue != null) b = blue.Value;
}
int? Get(int x, Func<GradientStop, GradientStop, int> func, Func<GradientStop, int> func1)
{
int lenght = this.End - this.Start;
foreach (var item in GradientStopTuple)
{
int s = (int)(item.Item1.Offset * lenght) + this.Start;
int e = (int)(item.Item2.Offset * lenght) + this.Start;
if (x < s || x > e) continue;
var ss = (double)(x - s) / (double)(e - s);
var sss = func(item.Item1, item.Item2);
return (int)((double)(x - s) / (double)(e - s) * func(item.Item1, item.Item2)) + func1(item.Item1);
}
return null;
}
List<Tuple<GradientStop, GradientStop>> BeginDraw()
{
List<Tuple<GradientStop, GradientStop>> tuples = new List<Tuple<GradientStop, GradientStop>>();
GradientStop last = null;
foreach (var item in GradientStops)
{
if (last != null)
{
tuples.Add(Tuple.Create(last, item));
}
last = item;
}
return tuples;
}
public LinearBrush Clone()
{
LinearBrush linearBrush = new LinearBrush();
foreach (var item in GradientStops)
{
linearBrush.GradientStops.Add(item);
}
linearBrush.Start = this.Start;
linearBrush.End = this.End;
return linearBrush;
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media;
namespace HeBianGu.General.DrawingBrush
{
public class PlanarGridBrush : IBrush
{
public double[,] Values;
public int Start { get; set; }
public int End { get; set; }
public int ItemWidth { get; set; }
public int ItemHeigh { get; set; }
public Color MaxColor { get; set; }
public Color MinColor { get; set; }
public double MaxValue { get; set; }
public double MinValue { get; set; }
public void Draw(int x, int y, ref int r, ref int g, ref int b)
{
int wIndex = x / ItemWidth;
int hIndex = y / ItemHeigh;
var value = Values[wIndex, hIndex];
r = this.GetColor(value, (l, k) => l.R - k.R, l => l.R);
g = this.GetColor(value, (l, k) => l.G - k.G, l => l.G);
b = this.GetColor(value, (l, k) => l.B - k.B, l => l.B);
}
int GetColor(double value, Func<Color, Color, int> func, Func<Color, int> func1)
{
double lenght = this.MaxValue - this.MinValue + 1;
double persent = (double)(value - this.MinValue) / lenght;
return (int)(persent * func(this.MaxColor, this.MinColor) + func1(this.MinColor));
}
}
}
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:HeBianGu.WPF.EChart">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/HisDataTools;component/Chart/Plotter/PlotterBaseStyle.xaml" />
<ResourceDictionary Source="/HisDataTools;component/Chart/Legend/LineLegendItem.xaml" />
<ResourceDictionary Source="/HisDataTools;component/Chart/Plotter/Common/LineLegendDetail.xaml" />
</ResourceDictionary.MergedDictionaries>
<SolidColorBrush Color="#FF7A7A7A" x:Key="split_backcolor"/>
</ResourceDictionary>
\ No newline at end of file
#region < >
/*
* ========================================================================
* Copyright(c) 四川*******公司, All Rights Reserved.
* ========================================================================
*
* 作者:[HeBianGu] 时间:2018/1/10 11:50:15
* 文件名:ICurveChart
* 说明:
*
*
* 修改者: 时间:
* 修改说明:
* ========================================================================
*/
#endregion
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;
namespace HeBianGu.WPF.EChart
{
public interface ICurveChart
{
double GetY(double value);
double GetX(double value);
Canvas ParallelCanvas { get; }
}
}
<UserControl x:Class="HeBianGu.WPF.EChart.Legend"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:HeBianGu.WPF.EChart"
mc:Ignorable="d" >
<Canvas>
<Grid Canvas.Top="{Binding Path=LegendTop, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type local:Legend}}}"
Canvas.Bottom="{Binding Path=LegendBottom, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type local:Legend}}}"
Canvas.Left="{Binding Path=LegendLeft, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type local:Legend}}}"
Canvas.Right="{Binding Path=LegendRight, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type local:Legend}}}"
>
<Rectangle RadiusX="5" RadiusY="5" Stroke="Black" StrokeThickness="1" Fill="White">
<!--<Rectangle.Effect>
<DropShadowEffect Direction="300" ShadowDepth="3" Opacity="0.4"/>
</Rectangle.Effect>-->
</Rectangle>
<StackPanel x:Name="stackPanel" Margin="3"/>
</Grid>
</Canvas>
</UserControl>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace HeBianGu.WPF.EChart
{
/// <summary>
/// Legend.xaml 的交互逻辑
/// </summary>
public partial class Legend : UserControl
{
public Legend()
{
InitializeComponent();
}
#region Position properties
public double LegendLeft
{
get { return (double)GetValue(LegendLeftProperty); }
set { SetValue(LegendLeftProperty, value); }
}
public static readonly DependencyProperty LegendLeftProperty = DependencyProperty.Register(
"LegendLeft",
typeof(double),
typeof(Legend),
new FrameworkPropertyMetadata(Double.NaN));
public double LegendRight
{
get { return (double)GetValue(LegendRightProperty); }
set { SetValue(LegendRightProperty, value); }
}
public static readonly DependencyProperty LegendRightProperty = DependencyProperty.Register(
"LegendRight",
typeof(double),
typeof(Legend),
new FrameworkPropertyMetadata(10.0));
public double LegendBottom
{
get { return (double)GetValue(LegendBottomProperty); }
set { SetValue(LegendBottomProperty, value); }
}
public static readonly DependencyProperty LegendBottomProperty = DependencyProperty.Register(
"LegendBottom",
typeof(double),
typeof(Legend),
new FrameworkPropertyMetadata(Double.NaN));
public double LegendTop
{
get { return (double)GetValue(LegendTopProperty); }
set { SetValue(LegendTopProperty, value); }
}
public static readonly DependencyProperty LegendTopProperty = DependencyProperty.Register(
"LegendTop",
typeof(double),
typeof(Legend),
new FrameworkPropertyMetadata(10.0));
#endregion
/// <summary>
/// Adds new legend item.
/// </summary>
/// <param name="legendItem">The legend item.</param>
public void AddLegendItem(LegendItem legendItem)
{
stackPanel.Children.Add(legendItem);
}
}
/// <summary>
/// <see cref="LegendItem"/> is a base class for item in legend, that represents some chart.
/// </summary>
public abstract class LegendItem : CheckBox
{
/// <summary>
/// Initializes a new instance of the <see cref="LegendItem"/> class.
/// </summary>
protected LegendItem() { }
/// <summary>
/// Initializes a new instance of the <see cref="LegendItem"/> class.
/// </summary>
/// <param name="description">The description.</param>
protected LegendItem(Description description)
{
Description = description;
}
private Description description;
/// <summary>
/// Gets or sets the description.
/// </summary>
/// <value>The description.</value>
public Description Description
{
get { return description; }
set
{
description = value;
//Content = description;
}
}
}
#region - Description -
public class ResolveLegendItemEventArgs : EventArgs
{
public ResolveLegendItemEventArgs(LegendItem legendItem)
{
LegendItem = legendItem;
}
public LegendItem LegendItem { get; set; }
}
public abstract class Description
{
private LegendItem legendItem;
public LegendItem LegendItem
{
get
{
if (legendItem == null)
{
legendItem = CreateLegendItem();
}
return legendItem;
}
}
private LegendItem CreateLegendItem()
{
LegendItem item = CreateLegendItemCore();
return RaiseResolveLegendItem(item);
}
protected virtual LegendItem CreateLegendItemCore()
{
return null;
}
public event EventHandler<ResolveLegendItemEventArgs> ResolveLegendItem;
private LegendItem RaiseResolveLegendItem(LegendItem uncustomizedLegendItem)
{
if (ResolveLegendItem != null)
{
ResolveLegendItemEventArgs e = new ResolveLegendItemEventArgs(uncustomizedLegendItem);
ResolveLegendItem(this, e);
return e.LegendItem;
}
else
{
return uncustomizedLegendItem;
}
}
private UIElement viewportElement;
public UIElement ViewportElement
{
get { return viewportElement; }
}
internal void Attach(UIElement element)
{
this.viewportElement = element;
AttachCore(element);
}
protected virtual void AttachCore(UIElement element) { }
internal void Detach()
{
viewportElement = null;
}
public abstract string Brief { get; }
public abstract string Full { get; }
public override string ToString()
{
return Brief;
}
}
public class StandardDescription : Description
{
public StandardDescription() { }
public StandardDescription(string description)
{
if (String.IsNullOrEmpty(description))
throw new ArgumentNullException("description");
this.description = description;
}
protected override void AttachCore(UIElement element)
{
if (description == null)
{
string str = element.GetType().Name;
description = str;
}
}
private string description;
public string DescriptionString
{
get { return description; }
set { description = value; }
}
public sealed override string Brief
{
get { return description; }
}
public sealed override string Full
{
get { return description; }
}
}
public sealed class PenDescription : StandardDescription
{
/// <summary>
/// Initializes a new instance of the <see cref="PenDescription"/> class.
/// </summary>
public PenDescription() { }
/// <summary>
/// Initializes a new instance of the <see cref="PenDescription"/> class.
/// </summary>
/// <param name="description">Custom description.</param>
public PenDescription(string description) : base(description) { }
//protected override LegendItem CreateLegendItemCore()
//{
// return new LineLegendItem(this);
//}
protected override void AttachCore(UIElement graph)
{
base.AttachCore(graph);
//LineGraph g = graph as LineGraph;
//if (g == null)
//{
// throw new ArgumentException("Pen description can only be attached to PointsGraph", "graph");
//}
//pen = g.LinePen;
pen = new Pen(Brushes.Red, 1);
}
private Pen pen;
public Pen Pen
{
get { return pen; }
}
}
#endregion
}
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:HeBianGu.WPF.EChart">
<ControlTemplate x:Key="DefaultLegendItemTemplate" TargetType="{x:Type local:LineLegendItem}">
<Viewbox Height="20" >
<Grid x:Name="g_all">
<Canvas x:Name="c_all" Height="30" Width="150" Background="{TemplateBinding Background}">
<Line X1="10" X2="40" Y1="15" Y2="15" StrokeThickness="3" Stroke="{TemplateBinding Color}"/>
<ContentControl Content="{TemplateBinding Marker}" Canvas.Left="25" Canvas.Top="15" />
<TextBlock Text="{TemplateBinding Text}" Canvas.Left="50" Canvas.Top="7"/>
</Canvas>
</Grid>
</Viewbox>
<ControlTemplate.Triggers>
<Trigger Property="IsChecked" Value="true">
<Setter Property="Opacity" Value="0.5" TargetName="g_all"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
<Style x:Key="DefaultLineLegendItem" TargetType="{x:Type local:LineLegendItem}">
<Setter Property="Template" Value="{StaticResource DefaultLegendItemTemplate}"/>
</Style>
</ResourceDictionary>
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace HeBianGu.WPF.EChart
{
/// <summary> 直线图例 </summary>
public partial class LineLegendItem : LegendItem
{
ICurveEntitySource _curve;
public LineLegendItem(ICurveEntitySource c)
{
_curve = c;
this.Color = c.Color;
this.Text = c.Text;
this.Marker = c.Marker.Clone();
this.Checked += LineLegendItem_Checked;
this.Unchecked += LineLegendItem_Checked;
}
private void LineLegendItem_Checked(object sender, RoutedEventArgs e)
{
Curve.Visibility = this.IsChecked.Value ? Visibility.Hidden : Visibility.Visible;
}
public Brush Color
{
get { return (Brush)GetValue(ColorProperty); }
set { SetValue(ColorProperty, value); }
}
// Using a DependencyProperty as the backing store for Color. This enables animation, styling, binding, etc...
public static readonly DependencyProperty ColorProperty =
DependencyProperty.Register("Color", typeof(Brush), typeof(LineLegendItem), new PropertyMetadata(Brushes.Black));
public string Text
{
get { return (string)GetValue(TextProperty); }
set { SetValue(TextProperty, value); }
}
// Using a DependencyProperty as the backing store for Text. This enables animation, styling, binding, etc...
public static readonly DependencyProperty TextProperty =
DependencyProperty.Register("Text", typeof(string), typeof(LineLegendItem), new PropertyMetadata(""));
public ShapePointMarker Marker
{
get { return (ShapePointMarker)GetValue(MarkerProperty); }
set { SetValue(MarkerProperty, value); }
}
public ICurveEntitySource Curve { get => _curve; set => _curve = value; }
// Using a DependencyProperty as the backing store for Marker. This enables animation, styling, binding, etc...
public static readonly DependencyProperty MarkerProperty =
DependencyProperty.Register("Marker", typeof(ShapePointMarker), typeof(LineLegendItem), new PropertyMetadata(null));
public void RefreshValue(string text)
{
//v.Text = text;
}
static LineLegendItem()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(LineLegendItem), new FrameworkPropertyMetadata(typeof(LineLegendItem)));
}
}
}
#region < >
/*
* ========================================================================
* Copyright(c) 四川*******公司, All Rights Reserved.
* ========================================================================
*
* 作者:[HeBianGu] 时间:2018/1/19 15:41:51
* 文件名:CardiogramCurveChartPlotter
* 说明:
*
*
* 修改者: 时间:
* 修改说明:
* ========================================================================
*/
#endregion
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media;
namespace HeBianGu.WPF.EChart
{
/// <summary> 心电图图表 </summary>
public class CardiogramCurveChartPlotter : CurveChartPlotter
{
public CardiogramCurveChartPlotter()
{
//this.InitData();
//this.RunDemo();
this.Loaded += CardiogramCurveChartPlotter_Loaded;
}
private void CardiogramCurveChartPlotter_Loaded(object sender, System.Windows.RoutedEventArgs e)
{
}
private Brush _gridLineColor = Brushes.Red;
/// <summary> 网格线颜色 </summary>
public Brush GridLineColor
{
get { return _gridLineColor; }
set { _gridLineColor = value; }
}
/// <summary> 此方法的说明 </summary>
public void RunDemo()
{
//CardiogramCurveEntitySource source = new CardiogramCurveEntitySource();
//source.Color = this.Foreground;
//Random r = new Random();
//// Todo :初始化X网线
//for (double i = this.MinValueX; i < this.MaxValueX; i = i + 0.1)
//{
// PointC p = new PointC();
// p.Y = r.Next(1800, 2500);
// p.X = i;
// source.Source.Add(p);
//}
//this.DataSource.Add(source);
}
private bool _isShowX;
/// <summary> 说明 </summary>
public bool IsShowX
{
get { return _isShowX; }
set { _isShowX = value; }
}
private bool _isShowY;
/// <summary> 说明 </summary>
public bool IsShowY
{
get { return _isShowY; }
set { _isShowY = value; }
}
private bool _isShowBaseLine;
/// <summary> 说明 </summary>
public bool IsShowBaseLine
{
get { return _isShowBaseLine; }
set { _isShowBaseLine = value; }
}
/// <summary> 初始化心电图表 </summary>
void InitData()
{
//this.FontSize = 12;
this.MaxValueY = 2448;
this.MinValueY = 1848;
this.MaxValueX = 11;
this.MinValueX = 0;
//this.Height = 150;
int tempIndex = 0;
// Todo :初始化X网线
for (double i = this.MinValueX; i <= this.MaxValueX; i = i + 0.25)
{
SplitItem s = new SplitItem();
s.Value = i;
s.Text = (i * 80).ToString();
s.Color = this._gridLineColor;
int param = (int)(tempIndex % 4);
s.SpliteType = param == 0 && this.IsShowX ? SplitItemType.Normal : SplitItemType.InnerOnly;
this.SlpitItemXs.Add(s);
tempIndex++;
}
// Todo :2048基准线
if (this.IsShowBaseLine)
{
SplitItem sbase = new SplitItem();
sbase.Value = 2048;
sbase.Text = (2048).ToString();
sbase.Color = this.Foreground;
sbase.SpliteType = SplitItemType.HeighLight;
this.SplitItemYs.Add(sbase);
}
tempIndex = 0;
// Todo :初始化Y网线
for (double i = this.MinValueY; i <= this.MaxValueY; i = i + 30)
{
SplitItem s = new SplitItem();
s.Value = i;
s.Text = i.ToString();
s.Color = this._gridLineColor;
int param = (int)(tempIndex % 4);
s.SpliteType = param == 0 && this.IsShowY ? SplitItemType.Normal : SplitItemType.InnerOnly;
this.SplitItemYs.Add(s);
tempIndex++;
}
}
}
}
#region < >
/*
* ========================================================================
* Copyright(c) 四川*******公司, All Rights Reserved.
* ========================================================================
*
* 作者:[HeBianGu] 时间:2018/1/18 11:30:25
* 文件名:StaticCurveChartPlotter
* 说明:
*
*
* 修改者: 时间:
* 修改说明:
* ========================================================================
*/
#endregion
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Shapes;
namespace HeBianGu.WPF.EChart
{
/// <summary> 静态曲线视图 </summary>
public class StaticCurveChartPlotter: CurveChartPlotter
{
public StaticCurveChartPlotter()
{
}
}
}
#region < >
/*
* ========================================================================
* Copyright(c) 四川*******公司, All Rights Reserved.
* ========================================================================
*
* 作者:[HeBianGu] 时间:2018/1/18 11:28:41
* 文件名:ChartPlotter
* 说明:
*
*
* 修改者: 时间:
* 修改说明:
* ========================================================================
*/
#endregion
using HeBianGu.WPF.EChart;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Media;
namespace HeBianGu.WPF.EChart
{
/// <summary> 图表基类 </summary>
public abstract class ChartPlotter : ViewPlotter
{
#region - 基础方法 -
/// <summary> 获取值对应Canvas的位置 </summary>
public double GetY(double value)
{
if ((this.MaxValueY - this.MinValueY) == 0) return 0;
var bottom = this.ParallelCanvas.ActualHeight - ((value - this.MinValueY) / (this.MaxValueY - this.MinValueY)) * this.ParallelCanvas.ActualHeight;
return bottom;
}
/// <summary> 获取值对应Canvas的位置 </summary>
public double GetX(double value)
{
if ((this.MaxValueX - this.MinValueX) == 0) return 0;
var bottom = ((value - this.MinValueX) / (this.MaxValueX - this.MinValueX)) * this.ParallelCanvas.ActualWidth;
return bottom;
}
/// <summary> 获取值对应Canvas的位置应有的 Y 值 </summary>
public double GetYValue(double value)
{
//var bottom = this.ParallelCanvas.ActualHeight - ((value - this.MinValueY) / (this.MaxValueY - this.MinValueY)) * this.ParallelCanvas.ActualHeight;
var bottom = (((this.ParallelCanvas.ActualHeight - value) / this.ParallelCanvas.ActualHeight) * (this.MaxValueY - this.MinValueY)) + this.MinValueY;
return bottom;
}
#endregion
#region - 控制参数 -
public double MinValueY
{
get { return (double)GetValue(MinValueYProperty); }
set { SetValue(MinValueYProperty, value); }
}
// Using a DependencyProperty as the backing store for MinValueX. This enables animation, styling, binding, etc...
public static readonly DependencyProperty MinValueYProperty =
DependencyProperty.Register("MinValueY", typeof(double), typeof(ChartPlotter), new PropertyMetadata(0.0));
public double MaxValueY
{
get { return (double)GetValue(MaxValueYProperty); }
set { SetValue(MaxValueYProperty, value); }
}
// Using a DependencyProperty as the backing store for MaxValueX. This enables animation, styling, binding, etc...
public static readonly DependencyProperty MaxValueYProperty =
DependencyProperty.Register("MaxValueY", typeof(double), typeof(ChartPlotter), new PropertyMetadata(0.0));
//private double _maxValueX;
///// <summary> 要显示的最大值 </summary>
//public double MaxValueX
//{
// get { return _maxValueX; }
// set { _maxValueX = value; }
//}
//private double _minValueX;
///// <summary> 要显示的最小值 </summary>
//public double MinValueX
//{
// get { return _minValueX; }
// set { _minValueX = value; }
//}
public double MinValueX
{
get { return (double)GetValue(MinValueXProperty); }
set { SetValue(MinValueXProperty, value); }
}
// Using a DependencyProperty as the backing store for MinValueX. This enables animation, styling, binding, etc...
public static readonly DependencyProperty MinValueXProperty =
DependencyProperty.Register("MinValueX", typeof(double), typeof(ChartPlotter), new PropertyMetadata(0.0));
public double MaxValueX
{
get { return (double)GetValue(MaxValueXProperty); }
set { SetValue(MaxValueXProperty, value); }
}
// Using a DependencyProperty as the backing store for MaxValueX. This enables animation, styling, binding, etc...
public static readonly DependencyProperty MaxValueXProperty =
DependencyProperty.Register("MaxValueX", typeof(double), typeof(ChartPlotter), new PropertyMetadata(0.0));
//private List<SplitItem> _splitItemYs = new List<SplitItem>();
///// <summary> Y范围分割线 </summary>
//public List<SplitItem> SplitItemYs
//{
// get { return _splitItemYs; }
// set { _splitItemYs = value; }
//}
public List<SplitItem> SplitItemYs
{
get { return (List<SplitItem>)GetValue(SplitItemYsProperty); }
set { SetValue(SplitItemYsProperty, value); }
}
// Using a DependencyProperty as the backing store for SplitItemYs. This enables animation, styling, binding, etc...
public static readonly DependencyProperty SplitItemYsProperty = DependencyProperty.Register("SplitItemYs", typeof(List<SplitItem>), typeof(ChartPlotter), new PropertyMetadata(null));
private List<SplitItem> _slpitItemXs = new List<SplitItem>();
/// <summary> 说明 </summary>
public List<SplitItem> SlpitItemXs
{
get { return _slpitItemXs; }
set { _slpitItemXs = value; }
}
//public List<SplitItem> SlpitItemXs
//{
// get { return (List<SplitItem>)GetValue(SlpitItemXsProperty); }
// set { SetValue(SlpitItemXsProperty, value); }
//}
//// Using a DependencyProperty as the backing store for SlpitItemXs. This enables animation, styling, binding, etc...
//public static readonly DependencyProperty SlpitItemXsProperty =
// DependencyProperty.Register("SlpitItemXs", typeof(List<SplitItem>), typeof(ChartPlotter), new PropertyMetadata(new List<SplitItem>()));
#endregion
}
}
<UserControl x:Class="HeBianGu.General.WpfChart.CursorGraphLine"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:HeBianGu.General.WpfChart"
mc:Ignorable="d" IsHitTestVisible="False">
<UserControl.Resources>
<Style x:Key="outerBorderStyle" TargetType="{x:Type Rectangle}" >
<Setter Property="RadiusX" Value="10"/>
<Setter Property="RadiusY" Value="10"/>
<Setter Property="Stroke" Value="Purple"/>
<Setter Property="StrokeThickness" Value="1"/>
<!--<Setter Property="Fill" Value="#88FFFFFF"/>-->
<Setter Property="Fill" Value="White"/>
<Setter Property="Opacity" Value="0.5"/>
</Style>
<Style x:Key="innerBorderStyle" TargetType="{x:Type Border}">
<Setter Property="CornerRadius" Value="4"/>
<Setter Property="Background" Value="White"/>
<!--<Setter Property="Opacity" Value="0.8"/>-->
<Setter Property="Margin" Value="8,4,8,4"/>
</Style>
<Style x:Key="textStyle" TargetType="{x:Type TextBlock}">
<Setter Property="Margin" Value="2,1,2,1"/>
</Style>
<Style x:Key="lineStyle" TargetType="{x:Type Line}">
<!--<Setter Property="Stroke" Value="{Binding
RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type local:CursorGraphLine}},
Path=LineStroke}"/>
<Setter Property="StrokeThickness" Value="{Binding
RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type local:CursorGraphLine}},
Path=LineStrokeThickness}"/>
<Setter Property="StrokeDashArray" Value="{Binding
RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type local:CursorGraphLine}},
Path=LineStrokeDashArray}"/>-->
<Setter Property="Stroke" Value="Purple"/>
<Setter Property="StrokeThickness" Value="0.5"/>
<Setter Property="StrokeDashArray" Value="5,5"/>
</Style>
</UserControl.Resources>
<Canvas Name="content" Cursor="None" Background="Transparent">
<Line Name="horizLine" Style="{StaticResource lineStyle}"/>
<Line Name="vertLine" Style="{StaticResource lineStyle}"/>
<!--<Grid Name="horizGrid" Canvas.Bottom="5">
<Rectangle Style="{StaticResource outerBorderStyle}"/>
<Border Style="{StaticResource innerBorderStyle}">
<TextBlock Name="horizTextBlock" Style="{StaticResource textStyle}"/>
</Border>
</Grid>
<Grid Name="vertGrid" Canvas.Left="5">
<Rectangle Style="{StaticResource outerBorderStyle}"/>
<Border Style="{StaticResource innerBorderStyle}">
<TextBlock Name="vertTextBlock" Style="{StaticResource textStyle}"/>
</Border>
</Grid>-->
<Grid Name="grid_center">
<Rectangle Style="{StaticResource outerBorderStyle}"/>
<StackPanel>
<Border Style="{StaticResource innerBorderStyle}"/>
<TextBlock x:Name="tb_title" FontWeight="Bold" Margin="3" HorizontalAlignment="Center" Text="2018-01-01"/>
<StackPanel x:Name="stackPanel" Margin="3"/>
</StackPanel>
</Grid>
</Canvas>
</UserControl>
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:HeBianGu.WPF.EChart">
<ControlTemplate x:Key="DefaultLineLegendDetailTemplate" TargetType="{x:Type local:LineLegendDetail}">
<Viewbox Height="20">
<Grid x:Name="g_all">
<Canvas x:Name="c_all" Height="30" Width="150">
<Line X1="10" X2="30" Y1="15" Y2="15" StrokeThickness="3" Stroke="{TemplateBinding Color}"/>
<ContentControl Content="{TemplateBinding Marker}" Canvas.Left="20" Canvas.Top="15" />
<StackPanel Orientation="Horizontal" Canvas.Left="35" Canvas.Top="7">
<TextBlock Text="{TemplateBinding Text}"/>
<TextBlock Text="{TemplateBinding Value}"/>
</StackPanel>
</Canvas>
</Grid>
</Viewbox>
<ControlTemplate.Triggers>
<Trigger Property="IsChecked" Value="true">
<Setter Property="Opacity" Value="0.5" TargetName="g_all"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
<Style x:Key="DefaultLineLegendDetail" TargetType="{x:Type local:LineLegendDetail}">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="Template" Value="{StaticResource DefaultLineLegendDetailTemplate}"/>
</Style>
</ResourceDictionary>
\ No newline at end of file
#region < >
/*
* ========================================================================
* Copyright(c) 四川*******公司, All Rights Reserved.
* ========================================================================
*
* 作者:[HeBianGu] 时间:2018/1/18 12:37:03
* 文件名:Class1
* 说明:
*
*
* 修改者: 时间:
* 修改说明:
* ========================================================================
*/
#endregion
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
namespace HeBianGu.WPF.EChart
{
/// <summary> 数据源点 </summary>
public class PointC : DependencyObject
{
private double _x;
/// <summary> 说明 </summary>
public double X
{
get { return _x; }
set { _x = value; }
}
private double _y;
/// <summary> 说明 </summary>
public double Y
{
get { return _y; }
set { _y = value; }
}
private string _text;
/// <summary> 说明 </summary>
public string Text
{
get { return _text; }
set { _text = value; }
}
public Point ToPoint()
{
return new Point(this.X, this.Y);
}
}
}
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
......@@ -4,6 +4,9 @@
xmlns:viewmodel="clr-namespace:HisDataTools.ViewModel"
xmlns:view="clr-namespace:HisDataTools.View"
>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/HisDataTools;component/Chart/ChartGeneric.xaml" />
</ResourceDictionary.MergedDictionaries>
<DataTemplate DataType="{x:Type viewmodel:ListDatabaseViewModel}">
<view:ListDatabaseView />
......
......@@ -38,7 +38,7 @@ namespace HisDataTools.ViewModel
Init();
DefaultHeight = 300;
DefaultWidth = 500;
Title = Res.Get("databaseSelect");
Title = Res.Get("DatabaseSelectTitle");
}
#endregion ...Constructor...
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册