JD2022-TU1/main/tools/framework/JD.Timeline/Dance/MoveExampleClipWidget.cs

148 lines
4.5 KiB
C#

using System;
using System.Drawing;
using JD.Serialization;
using System.Windows.Forms;
using JD.Timeline.View.SnipeView;
namespace JD.Timeline.View.ClipView.Widgets
{
/// <summary>
/// A Widget class for showing Scores
/// </summary>
internal class MoveExampleClipWidget : ScoreClipWidget
{
#region Static Member Variables
protected static Bitmap PositiveLabelBitmap = Properties.Resources.Icon_24x24_Positive;
protected static Bitmap NegativeLabelBitmap = Properties.Resources.Icon_24x24_Negative;
protected static Bitmap IgnoredLabelBitmap = Properties.Resources.Icon_24x24_Ignored;
private static readonly Font ClipFont = new Font(FontFamily.GenericSansSerif, 8);
private static readonly StringFormat StringFormat = new StringFormat
{
Alignment = StringAlignment.Center,
LineAlignment = StringAlignment.Center
};
#endregion
#region Properties
public override bool IsResizeAllowed => false;
public override bool CanDrag => false;
public override string ToolTipText
{
get
{
if (Model != null)
{
var scoreClip = (MoveExampleClip)Model;
if (Math.Abs(scoreClip.ScoreValue - (-2)) < float.Epsilon)
{
if (scoreClip.MoveScoreData.IsSniped)
{
return "This file is sniped during sniping process : " + scoreClip.MoveScoreData.FileLocation;
}
else
{
return "An error occurred while evaluating file " + scoreClip.MoveScoreData.FileLocation;
}
}
}
return base.ToolTipText;
}
}
#endregion
#region Constructor-Destructor
public MoveExampleClipWidget(ScoreClip model)
: base(model)
{
UseGradient = true;
IsMoveAllowed = false;
}
#endregion
#region Methods
private void DrawLabel(SnipeLabel label, Graphics graphics)
{
Bitmap icon;
Color fillColor = Color.DarkGray;
switch (label)
{
case SnipeLabel.Positive:
icon = (Bitmap)PositiveLabelBitmap.Clone();
fillColor = Color.DarkGreen;
break;
case SnipeLabel.Negative:
icon = (Bitmap)NegativeLabelBitmap.Clone();
fillColor = Color.DarkRed;
break;
case SnipeLabel.Ignored:
icon = (Bitmap)IgnoredLabelBitmap.Clone();
fillColor = Color.DarkGray;
break;
default:
throw new ArgumentException(label.ToString());
}
Rectangle imageBounds = new Rectangle(Bounds.X + Bounds.Width / 2, Bounds.Y + Bounds.Height / 4, Bounds.Height / 2, Bounds.Height / 2);
var units = GraphicsUnit.Pixel;
FillBackground(graphics, Bounds, fillColor);
graphics.DrawImage(icon, imageBounds, icon.GetBounds(ref units), units);
}
#endregion
#region Event Handlers
protected override void OnPaint(PaintEventArgs e)
{
SetupBounds();
var graphics = e.Graphics;
DrawClipType(Model.Type, graphics);
FillBackground(graphics, Bounds, BackgroundFillColor);
DrawLabel((SnipeLabel)(((MoveExampleClip)Model).CurrentSnipeStatus), graphics);
if (Selected)
{
DrawRectangle(graphics, Bounds, SelectionBorderPen);
graphics.DrawString(Text, ClipFont, StyleSheet.Brushes[Color.FromArgb(255, 255, 255)], Bounds,
StringFormat);
}
else
{
DrawEdge(graphics, Bounds);
}
if (((MoveExampleClip)Model).CurrentSnipeStatus != MoveExampleClip.CurrentSnipeStatus_Enum.Ignored && ((MoveExampleClip)Model).IsExampleLoaded != null)
{
if (!(((MoveExampleClip)Model).IsExampleLoaded.Value &&
((MoveExampleClip)Model).IsValidExample))
{
DrawClipWithWarning(graphics);
}
}
OnPaintChildControls(e);
}
#endregion
}
}