private void AddGraphDetails(DesignedGraph designedGraph, int index) { int y = (GRAPH_HEIGHT + CONTROL_PADDING) * index; if (VScroll) { y = y - VerticalScroll.Value; } DataPlot newplot = CreatePlot(new Point(CONTROL_LEFT - HorizontalScroll.Value, CONTROL_PADDING + y)); int left = ClientSize.Width - (KEY_WIDTH + (2 * CONTROL_PADDING)); if (left < GRAPH_MIN_WIDTH + (2 * CONTROL_PADDING)) { left = GRAPH_MIN_WIDTH + (2 * CONTROL_PADDING); } DataKey newkey = CreateKey(new Point(left - HorizontalScroll.Value, CONTROL_PADDING + y + GRAPH_PADDING)); foreach (DataSourceItem item in designedGraph.DataSources) { newkey.DataSourceUUIDsToShow.Add(item.Uuid); } newplot.DataKey = newkey; newkey.Enter += new EventHandler(dataKey_Enter); newkey.MouseDown += new MouseEventHandler(dataKey_MouseDown); newkey.MouseDoubleClick += new MouseEventHandler(dataKey_MouseDoubleClick); newkey.UpdateItems(); newplot.DisplayName = designedGraph.DisplayName; newplot.MouseDown += new MouseEventHandler(dataPlot_MouseDown); newplot.MouseDoubleClick += new MouseEventHandler(dataPlot_MouseDoubleClick); newplot.RefreshBuffer(); }
public void ReplaceGraphAt(int index, DesignedGraph newGraph) { if (!Graphs.IndexInRange(index)) { return; } SuspendLayout(); try { bool isSelected = (SelectedGraph == Graphs[index]); Graphs.RemoveAt(index); Graphs.Insert(index, newGraph); Plots[index].DisplayName = newGraph.DisplayName; Keys[index].DataSourceUUIDsToShow.Clear(); foreach (DataSourceItem item in newGraph.DataSources) { Keys[index].DataSourceUUIDsToShow.Add(item.Uuid); } Keys[index].UpdateItems(); if (isSelected) { SelectedGraph = newGraph; } showingDefaultGraphs = false; } finally { ResumeLayout(); } }
public void LoadGraphs(IXenObject xmo) { if (xmo == null) { return; } XenObject = xmo; List <string> dsuuids = new List <string>(); Pool pool = Helpers.GetPoolOfOne(xmo.Connection); if (pool != null) { List <DesignedGraph> dglist = new List <DesignedGraph>(); Dictionary <string, string> gui_config = Helpers.GetGuiConfig(pool); int i = 0; while (true) { string key = Palette.GetLayoutKey(i, xmo); if (!gui_config.ContainsKey(key)) { break; } DesignedGraph dg = new DesignedGraph(); string[] dslist = gui_config[key].Split(','); foreach (string ds in dslist) { AddDataSource(string.Format("{0}:{1}:{2}", xmo is Host ? "host" : "vm", Helpers.GetUuid(xmo), ds), dsuuids, dg); } key = Palette.GetGraphNameKey(i, xmo); if (gui_config.ContainsKey(key)) { dg.DisplayName = gui_config[key]; } dglist.Add(dg); i++; } showingDefaultGraphs = false; if (dglist.Count == 0) { LoadDefaultGraphs(); return; // return because loaddefaultgraphs sets the displayed uuids } SetGraphs(dglist); } DataPlotNav.DisplayedUuids = dsuuids; }
public void DeleteGraph(DesignedGraph graph) { if (graph == null) { return; } SuspendLayout(); try { int index = Graphs.IndexOf(graph); DesignedGraph newSelectedGraph = null; if (SelectedGraph == graph && Count > 1) { newSelectedGraph = SelectedGraphIndex == Count - 1 ? Graphs[SelectedGraphIndex - 1] : Graphs[SelectedGraphIndex + 1]; } Graphs.Remove(graph); DeleteGraphDetailsAt(index); if (newSelectedGraph != null) { SelectedGraph = newSelectedGraph; } showingDefaultGraphs = false; } finally { if (VScroll) { AdjustFormScrollbars(true); ScrollControlIntoView(Plots[SelectedGraphIndex]); } ResumeLayout(); RefreshBuffer(); } }
public void AddGraph(DesignedGraph graph) { SuspendLayout(); try { Graphs.Add(graph); AddGraphDetails(graph, Graphs.Count - 1); SelectedGraph = graph; showingDefaultGraphs = false; } finally { if (VScroll) { AdjustFormScrollbars(true); ScrollControlIntoView(Plots[SelectedGraphIndex]); } ResumeLayout(); RefreshBuffer(); } }
void AddDataSource(string uuid, List <string> dsuuids, DesignedGraph dg) { dsuuids.Add(uuid); dg.DataSources.Add(new DataSourceItem(new Data_source(), "", Palette.GetColour(uuid), uuid)); }
private void LoadDefaultGraphs() { List <string> dsuuids = new List <string>(); if (XenObject is Host) { List <DesignedGraph> dg = new List <DesignedGraph>(); Host host = (Host)XenObject; DesignedGraph cpudg = new DesignedGraph(); cpudg.DisplayName = Messages.GRAPHS_DEFAULT_NAME_CPU; foreach (Host_cpu cpu in host.Connection.ResolveAll <Host_cpu>(host.host_CPUs)) { AddDataSource(string.Format("host:{0}:cpu{1}", host.uuid, cpu.number), dsuuids, cpudg); } DesignedGraph memdg = new DesignedGraph(); memdg.DisplayName = Messages.GRAPHS_DEFAULT_NAME_MEMORY; AddDataSource(string.Format("host:{0}:memory_total_kib", host.uuid), dsuuids, memdg); AddDataSource(string.Format("host:{0}:memory_free_kib", host.uuid), dsuuids, memdg); DesignedGraph netdg = new DesignedGraph(); netdg.DisplayName = Messages.GRAPHS_DEFAULT_NAME_NETWORK; foreach (PIF pif in host.Connection.ResolveAll(host.PIFs)) { AddDataSource(string.Format("host:{0}:pif_{1}_tx", host.uuid, pif.device), dsuuids, netdg); AddDataSource(string.Format("host:{0}:pif_{1}_rx", host.uuid, pif.device), dsuuids, netdg); } dg.Add(cpudg); dg.Add(memdg); dg.Add(netdg); SetGraphs(dg); } if (XenObject is VM) { List <DesignedGraph> dg = new List <DesignedGraph>(); VM vm = (VM)XenObject; DesignedGraph cpudg = new DesignedGraph(); cpudg.DisplayName = Messages.GRAPHS_DEFAULT_NAME_CPU; for (int i = 0; i < vm.VCPUs_max; i++) { AddDataSource(string.Format("vm:{0}:cpu{1}", vm.uuid, i), dsuuids, cpudg); } DesignedGraph memdg = new DesignedGraph(); memdg.DisplayName = Messages.GRAPHS_DEFAULT_NAME_MEMORY; AddDataSource(string.Format("vm:{0}:memory", vm.uuid), dsuuids, memdg); AddDataSource(string.Format("vm:{0}:memory_internal_free", vm.uuid), dsuuids, memdg); DesignedGraph netdg = new DesignedGraph(); netdg.DisplayName = Messages.GRAPHS_DEFAULT_NAME_NETWORK; foreach (VIF vif in vm.Connection.ResolveAll <VIF>(vm.VIFs)) { AddDataSource(string.Format("vm:{0}:vif_{1}_tx", vm.uuid, vif.device), dsuuids, netdg); AddDataSource(string.Format("vm:{0}:vif_{1}_rx", vm.uuid, vif.device), dsuuids, netdg); } DesignedGraph diskdg = new DesignedGraph(); diskdg.DisplayName = Messages.GRAPHS_DEFAULT_NAME_DISK; foreach (VBD vbd in vm.Connection.ResolveAll <VBD>(vm.VBDs)) { AddDataSource(string.Format("vm:{0}:vbd_{1}_read", vm.uuid, vbd.device), dsuuids, diskdg); AddDataSource(string.Format("vm:{0}:vbd_{1}_write", vm.uuid, vbd.device), dsuuids, diskdg); } dg.Add(cpudg); dg.Add(memdg); dg.Add(netdg); dg.Add(diskdg); SetGraphs(dg); } DataPlotNav.DisplayedUuids = dsuuids; showingDefaultGraphs = true; }