private void DrawClippedCurrentNoteBar(Graphics gr, RectangleF rect, int currentNoteIndex) { rect.Inflate(_noteBarShapeInflateValue, _noteBarShapeInflateValue); if (_activeNoteBarFrameColor != Color.Empty) { rect.Inflate(-1, -1); } float rateHeight; RatingNote note = _ratings[currentNoteIndex]; if (_currentNoteValue == note.ToValue) { rateHeight = rect.Height; } else if (_currentNoteValue == note.FromValue) { rateHeight = 1; } else { rateHeight = rect.Height * (_currentNoteValue - note.FromValue) / (note.ToValue - note.FromValue); rateHeight = (float)Math.Round(rateHeight, 2); } using (GraphicsPath path = GetShapePath(rect)) { gr.SetClip(path); gr.FillRectangle(_activeNoteBarBrush.GetBrush(Rectangle.Round(rect)), new RectangleF(rect.Left, rect.Bottom - rateHeight, rect.Width, rateHeight)); gr.ResetClip(); } }
private void DrawNoteNameOrValue(Graphics gr, RatingNote note, RectangleF rect) { if ((_showNoteName || _showNoteValue) == false) { return; } string noteNameValueStr = string.Empty; if (_showNoteValue) { noteNameValueStr = (_showNoteName ? " (" : string.Empty) + note.FromValue.ToString() + " - " + note.ToValue.ToString() + (_showNoteName ? ")" : string.Empty); } if (_showNoteName) { noteNameValueStr = note.Name + noteNameValueStr; } StringFormat sf = new StringFormat(); sf.LineAlignment = StringAlignment.Center; sf.Alignment = _noteTextAlignment; gr.DrawString(noteNameValueStr, Font, new SolidBrush(ForeColor), rect, sf); }
public RatingNote AddRating(string ratingName, float fromValue, float toValue) { RatingNote rating = new RatingNote { Name = ratingName, FromValue = fromValue, ToValue = toValue }; _ratings.Add(rating); _ratings.Sort((x, y) => y.ToValue.CompareTo(x.ToValue)); ArrangeRowHeight(); return(rating); }