/// <summary> /// Initializes a new instance of the <see cref="ClusterEventArgs"/> class. /// </summary> /// <param name="cluster">Cluster glyph associated with this event argments.</param> public ClusterEventArgs(CostNodeClusterGlyph cluster) { if (cluster != null) { _costNodeClusterGlyph = cluster; } }
/// <summary> /// Build shown clusters. /// </summary> private void BuildShownClusters() { _shownNodeGlyphs = new Dictionary<string, CostNodeGlyph>(); _costNodeClusterGlyphs = new Collection<CostNodeClusterGlyph>(); foreach (CostNodeCluster cluster in Utterance.Viterbi.CostNodeClusters) { CostNodeClusterGlyph clusterGlyph = new CostNodeClusterGlyph(); clusterGlyph.CostNodeCluster = cluster; clusterGlyph.CostNodeGlyphs.Clear(); foreach (CostNode node in cluster.CostNodes) { CostNodeGlyph nodeGlyph = new CostNodeGlyph(); nodeGlyph.CostNode = node; clusterGlyph.AddNode(nodeGlyph); } _costNodeClusterGlyphs.Add(clusterGlyph); } }
/// <summary> /// Performance select a cluster. /// </summary> /// <param name="cluster">Cluster to select.</param> public void Select(CostNodeClusterGlyph cluster) { try { using (Graphics g = Graphics.FromHwnd(this.Handle)) { g.TranslateTransform(AutoScrollPosition.X, AutoScrollPosition.Y); for (int i = 0; i < CostNodeClusterGlyphs.Count; i++) { CostNodeClusterGlyph cnc = CostNodeClusterGlyphs[i]; if (cluster != cnc) { cnc.Selected = false; } else { cnc.Selected = true; } cnc.Draw(g, cnc.Rectangle, this.Font, Brushes.LightSalmon, cnc.Selected); } } } catch (ObjectDisposedException) { return; } }