DataSet field Uuid is not really a uuid. Renamed to Id to avoid misunderstandings.

Signed-off-by: Konstantina Chremmou <konstantina.chremmou@citrix.com>
This commit is contained in:
Konstantina Chremmou 2021-07-16 17:21:48 +01:00
parent 5e7f18dcab
commit c2ea499057
6 changed files with 28 additions and 36 deletions

View File

@ -68,7 +68,7 @@ namespace XenAdmin.Controls.CustomDataGraph
set.Points.Sort();
var other = Sets.FirstOrDefault(s => s.Uuid == set.Uuid);
var other = Sets.FirstOrDefault(s => s.Id == set.Id);
if (other == null)
{
@ -110,7 +110,7 @@ namespace XenAdmin.Controls.CustomDataGraph
foreach (DataSet set in SetsAdded)
{
Palette.LoadSetColor(set);
DataSet copy = DataSet.Create(set.Uuid, set.XenObject, set.Show, set.TypeString);
DataSet copy = DataSet.Create(set.Id, set.XenObject, set.Show, set.TypeString);
foreach (DataPoint p in set.Points)
copy.AddPoint(new DataPoint(p.X,p.Y));

View File

@ -80,7 +80,7 @@ namespace XenAdmin.Controls.CustomDataGraph
lock (Palette.PaletteLock)
{
using (var thickPen = Palette.CreatePen(item.Sets[ArchiveInterval.FiveSecond].Uuid, Palette.PEN_THICKNESS_THICK))
using (var thickPen = Palette.CreatePen(item.Sets[ArchiveInterval.FiveSecond].Id, Palette.PEN_THICKNESS_THICK))
{
e.Graphics.DrawLine(thickPen,
new Point(e.Bounds.Left + 2, e.Bounds.Top + e.Bounds.Height / 2),
@ -116,7 +116,7 @@ namespace XenAdmin.Controls.CustomDataGraph
{
var wrapper = new DataSetCollectionWrapper();
if (!DataSourceUUIDsToShow.Contains(fivesecond.Uuid))
if (!DataSourceUUIDsToShow.Contains(fivesecond.Id))
continue;
wrapper.Sets.Add(ArchiveInterval.FiveSecond, fivesecond);
@ -124,7 +124,7 @@ namespace XenAdmin.Controls.CustomDataGraph
foreach (var interval in intervals)
{
var found = archives[interval].Sets.FirstOrDefault(s => s.Uuid == fivesecond.Uuid);
var found = archives[interval].Sets.FirstOrDefault(s => s.Id == fivesecond.Id);
if (found != null)
wrapper.Sets.Add(interval, found);
}
@ -263,15 +263,7 @@ namespace XenAdmin.Controls.CustomDataGraph
public void SelectDataSet(DataSet set)
{
SelectedItem = SelectWrapperFromUuid(set.Uuid);
}
public DataSetCollectionWrapper SelectWrapperFromUuid(string uuid)
{
return CurrentKeys.Find(new Predicate<DataSetCollectionWrapper>(delegate(DataSetCollectionWrapper item)
{
return item.Uuid == uuid;
}));
SelectedItem = CurrentKeys.Find(item => item.Id == set.Id);
}
protected override void OnPaint(PaintEventArgs e)
@ -346,14 +338,14 @@ namespace XenAdmin.Controls.CustomDataGraph
}
public string Uuid
public string Id
{
get
{
if (!Sets.ContainsKey(ArchiveInterval.FiveSecond))
return base.ToString();
return Sets[ArchiveInterval.FiveSecond].Uuid;
return Sets[ArchiveInterval.FiveSecond].Id;
}
}
@ -367,7 +359,7 @@ namespace XenAdmin.Controls.CustomDataGraph
public bool Equals(DataSetCollectionWrapper other)
{
return Uuid.Equals(other.Uuid);
return Id.Equals(other?.Id);
}
public int CompareTo(DataSetCollectionWrapper other)

View File

@ -280,7 +280,7 @@ namespace XenAdmin.Controls.CustomDataGraph
// Refresh all sets
foreach (DataSet set in DataPlotNav.CurrentArchive.Sets.ToArray())
{
if (!set.Draw || !DataKey.DataSourceUUIDsToShow.Contains(set.Uuid))
if (!set.Draw || !DataKey.DataSourceUUIDsToShow.Contains(set.Id))
continue;
List<DataPoint> todraw;
@ -363,16 +363,16 @@ namespace XenAdmin.Controls.CustomDataGraph
Array.Reverse(sets_to_show);
foreach (DataSet set in sets_to_show)
{
if (!set.Draw || DataKey == null || !DataKey.DataSourceUUIDsToShow.Contains(set.Uuid))
if (!set.Draw || DataKey == null || !DataKey.DataSourceUUIDsToShow.Contains(set.Id))
continue;
lock (Palette.PaletteLock)
{
using (var thickPen = Palette.CreatePen(set.Uuid, Palette.PEN_THICKNESS_THICK))
using (var thickPen = Palette.CreatePen(set.Id, Palette.PEN_THICKNESS_THICK))
{
using (var normalPen = Palette.CreatePen(set.Uuid, Palette.PEN_THICKNESS_NORMAL))
using (var normalPen = Palette.CreatePen(set.Id, Palette.PEN_THICKNESS_NORMAL))
{
using (var shadowBrush = Palette.CreateBrush(set.Uuid))
using (var shadowBrush = Palette.CreateBrush(set.Id))
{
LineRenderer.Render(paintEventArgs.Graphics, SlightlySmaller, DataPlotNav.XRange, set.CustomYRange ?? SelectedYRange, set.Selected ? thickPen : normalPen, shadowBrush, set.CurrentlyDisplayed, true);
}
@ -533,7 +533,7 @@ namespace XenAdmin.Controls.CustomDataGraph
{
foreach (DataSet set in DataPlotNav.CurrentArchive.Sets.ToArray())
{
if (!set.Draw || DataKey == null || !DataKey.DataSourceUUIDsToShow.Contains(set.Uuid))
if (!set.Draw || DataKey == null || !DataKey.DataSourceUUIDsToShow.Contains(set.Id))
continue;
if (set.OnMouseClick(new MouseActionArgs(e.Location, GraphRectangle(), DataPlotNav.XRange, SelectedYRange)))
{

View File

@ -479,7 +479,7 @@ namespace XenAdmin.Controls.CustomDataGraph
foreach (DataSet set in ScrollWideArchive.Sets.ToArray())
{
if (!set.Draw || !DisplayedUuids.Contains(set.Uuid))
if (!set.Draw || !DisplayedUuids.Contains(set.Id))
continue;
List<DataPoint> todraw;
@ -520,12 +520,12 @@ namespace XenAdmin.Controls.CustomDataGraph
foreach (DataSet set in ScrollWideArchive.Sets.ToArray())
{
if (!set.Draw || !DisplayedUuids.Contains(set.Uuid))
if (!set.Draw || !DisplayedUuids.Contains(set.Id))
continue;
lock (Palette.PaletteLock)
{
using (var normalPen = Palette.CreatePen(set.Uuid, Palette.PEN_THICKNESS_NORMAL))
using (var normalPen = Palette.CreatePen(set.Id, Palette.PEN_THICKNESS_NORMAL))
{
LineRenderer.Render(paintEventArgs.Graphics, ScrollViewRectangle, everything, set.CustomYRange, normalPen, null, set.CurrentlyDisplayed, false);
}

View File

@ -53,7 +53,7 @@ namespace XenAdmin.Controls.CustomDataGraph
public bool Selected;
public List<DataPoint> CurrentlyDisplayed = new List<DataPoint>();
public IXenObject XenObject;
public string Uuid;
public readonly string Id;
private bool _hide;
private bool _deselected;
@ -110,20 +110,20 @@ namespace XenAdmin.Controls.CustomDataGraph
public DataRange CustomYRange;
private DataSet(string uuid, IXenObject xo, bool show, string settype)
private DataSet(string id, IXenObject xo, bool show, string settype)
{
XenObject = xo;
_hide = !show;
Uuid = uuid;
Id = id;
TypeString = settype;
Name = Helpers.GetFriendlyDataSourceName(settype, XenObject);
}
#region Static methods
public static DataSet Create(string uuid, IXenObject xo, bool show, string settype)
public static DataSet Create(string id, IXenObject xo, bool show, string settype)
{
var dataSet = new DataSet(uuid, xo, show, settype);
var dataSet = new DataSet(id, xo, show, settype);
if(settype == "xapi_open_fds" || settype == "pool_task_count" || settype == "pool_session_count")
{
dataSet.NeverShow = true;
@ -684,14 +684,14 @@ namespace XenAdmin.Controls.CustomDataGraph
DataSet other = (DataSet)obj;
return Uuid == other.Uuid;
return Id == other.Id;
}
public override int GetHashCode()
{
if (string.IsNullOrEmpty(Uuid))
if (string.IsNullOrEmpty(Id))
return base.GetHashCode();
return Uuid.GetHashCode();
return Id.GetHashCode();
}
internal void InsertPointCollection(List<DataPoint> list)
@ -791,7 +791,7 @@ namespace XenAdmin.Controls.CustomDataGraph
public int CompareTo(DataSet other)
{
if (Uuid == other.Uuid)
if (Id == other.Id)
return 0;
int comp = DisplayArea.CompareTo(other.DisplayArea);

View File

@ -151,7 +151,7 @@ namespace XenAdmin.Controls.CustomDataGraph
if (!int.TryParse(gui_config[key], out argb))
return;
SetCustomColor(set.Uuid, Color.FromArgb(argb));
SetCustomColor(set.Id, Color.FromArgb(argb));
}
public static string GetColorKey(string ds_name, IXenObject xo)