Esempio n. 1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="WordEventArgs"/> class.
 /// </summary>
 /// <param name="word">Word associated with this event arguments.</param>
 public WordEventArgs(WordGlyph word)
 {
     if (word != null)
     {
         _wordGlyph = word;
     }
 }
Esempio n. 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="WordEventArgs"/> class.
        /// </summary>
        /// <param name="word">Word associated with this event arguments.</param>
        /// <param name="e">Mouse event.</param>
        public WordEventArgs(WordGlyph word, MouseEventArgs e)
        {
            if (e == null)
            {
                throw new ArgumentNullException("e");
            }

            if (word != null)
            {
                _wordGlyph = word;
            }

            _mouseEventArgs = e;
        }
Esempio n. 3
0
        /// <summary>
        /// Build shown node lattice view.
        /// </summary>
        /// <param name="shownRouteCount">How many routes would be shown.</param>
        public void BuildShownNodeLattice(int shownRouteCount)
        {
            _dataReady = false;

            if (Utterance == null)
            {
                return;
            }

            if (Utterance.Viterbi == null)
            {
                return;
            }

            if (Utterance.Viterbi.NodeRoutes == null)
            {
                return;
            }

            int routeCount = Utterance.Viterbi.NodeRoutes.Count;
            if (routeCount == 0)
            {
                return;
            }

            // build word glyphs
            _wordGlyphs = new Collection<WordGlyph>();
            foreach (ScriptWord word in Utterance.Script.Words)
            {
                if (word.WordType == WordType.Normal)
                {
                    WordGlyph wordGlyph = new WordGlyph();
                    wordGlyph.Word = word;
                    _wordGlyphs.Add(wordGlyph);
                }
            }

            _shownRouteCount = shownRouteCount;
            _shownRouteCount = Math.Abs(_shownRouteCount)
                < routeCount ? _shownRouteCount : routeCount;
            _shownRouteCount = Math.Abs(_shownRouteCount) < 1 ?
                1 : _shownRouteCount;

            // build shown clusters
            BuildShownClusters();

            // build show nodes
            foreach (NodeRoute route in Utterance.Viterbi.NodeRoutes)
            {
                route.Visible = false;
            }

            // build shown routes
            BuildShownRoutes(routeCount);

            // build cost node glyphs
            foreach (CostNodeClusterGlyph cluster in CostNodeClusterGlyphs)
            {
                cluster.BuildGlyphs(_shownNodeGlyphs, NodeFolded);
            }

            // hood events
            int lastClusterIndex = Utterance.Viterbi.CostNodeClusters.Count - 1;
            CostNodeClusterGlyph lastCluster = CostNodeClusterGlyphs[lastClusterIndex];
            foreach (CostNodeGlyph costNodeGlyph in lastCluster.CostNodeGlyphs)
            {
                costNodeGlyph.OnRequestRate += 
                    new EventHandler<RequestRateEventArgs>(NeedCostRateNode_OnRequestRate);
            }

            if (Utterance.Viterbi != null
                && Utterance.Viterbi.SelectedRoute != null)
            {
                int lastNodeIndex = Utterance.Viterbi.SelectedRoute.CostNodes.Count - 1;
                CostNode lastNode = Utterance.Viterbi.SelectedRoute.CostNodes[lastNodeIndex];
                SelectedNode = CostNodeClusterGlyphs[lastNode.ClusterIndex].CostNodeGlyphs[lastNode.Index];
                OnShowNode(this, new NodeEventArgs(SelectedNode));
            }

            DoResize();
            _dataReady = true;
            Invalidate();
        }