Esempio n. 1
0
        /// <summary>
        /// Draw this instance on the Graphics.
        /// </summary>
        /// <param name="g">Graphics to draw with.</param>
        /// <param name="rect">Boundary to draw on.</param>
        /// <param name="font">Font to draw with.</param>
        /// <param name="brush">Brush to draw with.</param>
        /// <param name="selected">Is in selected mode.</param>
        public void Draw(Graphics g, Rectangle rect, Font font,
            Brush brush, bool selected)
        {
            if (g == null)
            {
                throw new ArgumentNullException("g");
            }

            // draw page border and shadow
            rect.Inflate(-2, -2);
            g.DrawRectangle(Pens.Purple, rect);
            g.FillRectangle(brush, rect);
            if (_mouseState == MouseState.Enter || _selected)
            {
                using (Pen pen = new Pen(Color.DarkBlue, 2))
                {
                    g.DrawRectangle(pen, rect);
                }
            }

            RequestRateEventArgs rateEvent = new RequestRateEventArgs(this, 0);

            OnRequestRate(this, rateEvent);
            if (rateEvent.Rate > 0)
            {
                using (Font fnt = new Font("Microsoft Sans Serif", 7.5F,
                    FontStyle.Bold, GraphicsUnit.Point))
                {
                    string label = rateEvent.Rate.ToString(CultureInfo.InvariantCulture);
                    SizeF sz = g.MeasureString(label, fnt);
                    g.DrawString(label, fnt, Brushes.White,
                        this.X + ((this.Size.Width - sz.Width) / 2),
                        this.Y + ((this.Size.Height - sz.Height) / 2));
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Hanlde OnRequestRate event of needCostRateNode.
        /// </summary>
        /// <param name="sender">Event sender.</param>
        /// <param name="e">Event arguments.</param>
        private void NeedCostRateNode_OnRequestRate(object sender, RequestRateEventArgs e)
        {
            NodeRoute route = Utterance.Viterbi.FindRoute(e.CostNodeGlyph.CostNode);
            if (route == null)
            {
                e.Rate = 0;
                return;
            }

            e.Rate = Utterance.Viterbi.NodeRoutes.IndexOf(route);
            e.Rate = e.Rate + 1;
        }