Skip to content

Commit

Permalink
Merge branch 'cherry-picks-niisaka-epg' into work-plus-s
Browse files Browse the repository at this point in the history
  • Loading branch information
xtne6f committed Jun 7, 2016
2 parents fe3038b + 98b796b commit 6bf8019
Show file tree
Hide file tree
Showing 18 changed files with 487 additions and 247 deletions.
44 changes: 44 additions & 0 deletions EpgTimer/EpgTimer/Common/ColorDefClass.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Text;
using System.Windows.Media;
using System.Reflection;
using System.Windows;

namespace EpgTimer
{
Expand Down Expand Up @@ -52,5 +53,48 @@ public Dictionary<string, SolidColorBrush> ColorTable
return colorTable;
}
}

public static Color ColorFromName(string name)
{
var colortype = typeof(Colors);
return (Color)colortype.GetProperty(name).GetValue(colortype, null);
}

public static LinearGradientBrush GradientBrush(Color color, double luminance = 0.94, double saturation = 1.2)
{
// 彩度を上げる
int[] numbers = {color.R, color.G, color.B};
double n1 = numbers.Max();
double n2 = numbers.Min();
double n3 = n1 / (n1 - n2);
double r = (color.R - n1) * saturation + n1;
double g = (color.G - n1) * saturation + n1;
double b = (color.B - n1) * saturation + n1;
r = Math.Max(r, 0);
g = Math.Max(g, 0);
b = Math.Max(b, 0);

// 明るさを下げる
double l1 = 0.298912 * color.R + 0.586611 * color.G + 0.114478 * color.B;
double l2 = 0.298912 * r + 0.586611 * g + 0.114478 * b;
double f = (l2 / l1) * luminance;
r *= f;
g *= f;
b *= f;
r = Math.Min(r, 255);
g = Math.Min(g, 255);
b = Math.Min(b, 255);

Color color2 = Color.FromRgb((byte)r, (byte)g, (byte)b);

LinearGradientBrush brush = new LinearGradientBrush();
brush.StartPoint = new Point(0, 0.5);
brush.EndPoint = new Point(0, 1);
brush.GradientStops.Add(new GradientStop(color, 0.0));
brush.GradientStops.Add(new GradientStop(color2, 1.0));
brush.Freeze();

return brush;
}
}
}
90 changes: 81 additions & 9 deletions EpgTimer/EpgTimer/Common/CommonManagerClass.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public NWConnect NW
get;
set;
}
public List<SolidColorBrush> CustContentColorList
public List<Brush> CustContentColorList
{
get;
set;
Expand All @@ -104,6 +104,16 @@ public SolidColorBrush CustTitle2Color
get;
set;
}
public List<Brush> CustTimeColorList
{
get;
set;
}
public Brush CustServiceColor
{
get;
set;
}

private static CommonManager _instance;
public static CommonManager Instance
Expand Down Expand Up @@ -450,7 +460,11 @@ public CommonManager()
}
if( CustContentColorList == null )
{
CustContentColorList = new List<SolidColorBrush>();
CustContentColorList = new List<Brush>();
}
if (CustTimeColorList == null)
{
CustTimeColorList = new List<Brush>();
}
}

Expand Down Expand Up @@ -1067,6 +1081,7 @@ public void ReloadCustContentColorList()
for (int i = 0; i < Settings.Instance.ContentColorList.Count; i++)
{
String name = Settings.Instance.ContentColorList[i];
Color color;
if (String.Compare(name, "カスタム") == 0)
{
UInt32 argb = Settings.Instance.ContentCustColorList[i];
Expand All @@ -1075,16 +1090,20 @@ public void ReloadCustContentColorList()
byte g = (byte)((argb & 0x0000FF00) >> 8);
byte b = (byte)(argb & 0x000000FF);

Color item = Color.FromArgb(0xFF, r, g, b);
SolidColorBrush backColor = new SolidColorBrush();
backColor.Color = item;
backColor.Freeze();

CustContentColorList.Add(backColor);
color = Color.FromArgb(0xFF, r, g, b);
}
else
{
CustContentColorList.Add(ColorDef.Instance.ColorTable[name]);
color = ColorDef.ColorFromName(name);
}
if (Settings.Instance.EpgGradation == false)
{
CustContentColorList.Add(new SolidColorBrush(color));
CustContentColorList[CustContentColorList.Count - 1].Freeze();
}
else
{
CustContentColorList.Add(ColorDef.GradientBrush(color));
}
}
if (String.Compare(Settings.Instance.ReserveRectColorNormal, "カスタム") == 0)
Expand Down Expand Up @@ -1202,6 +1221,59 @@ public void ReloadCustContentColorList()
{
CustTitle2Color = ColorDef.Instance.ColorTable[Settings.Instance.TitleColor2];
}
CustTimeColorList.Clear();
for (int i = 0; i < Settings.Instance.TimeColorList.Count; i++)
{
String name = Settings.Instance.TimeColorList[i];
Color color;
if (String.Compare(name, "カスタム") == 0)
{
UInt32 argb = Settings.Instance.TimeCustColorList[i];

byte r = (byte)((argb & 0x00FF0000) >> 16);
byte g = (byte)((argb & 0x0000FF00) >> 8);
byte b = (byte)(argb & 0x000000FF);

color = Color.FromArgb(0xFF, r, g, b);
}
else
{
color = ColorDef.ColorFromName(name);
}
if (Settings.Instance.EpgGradationHeader == false)
{
CustTimeColorList.Add(new SolidColorBrush(color));
CustTimeColorList[CustTimeColorList.Count - 1].Freeze();
}
else
{
CustTimeColorList.Add(ColorDef.GradientBrush(color, 0.9, 1.1));
}
}
Color serviceColor;
if (String.Compare(Settings.Instance.ServiceColor, "カスタム") == 0)
{
UInt32 argb = Settings.Instance.ServiceCustColor;

byte r = (byte)((argb & 0x00FF0000) >> 16);
byte g = (byte)((argb & 0x0000FF00) >> 8);
byte b = (byte)(argb & 0x000000FF);

serviceColor = Color.FromArgb(0xFF, r, g, b);
}
else
{
serviceColor = ColorDef.ColorFromName(Settings.Instance.ServiceColor);
}
if (Settings.Instance.EpgGradationHeader == false)
{
CustServiceColor = new SolidColorBrush(serviceColor);
CustServiceColor.Freeze();
}
else
{
CustServiceColor = ColorDef.GradientBrush(serviceColor, 1.0, 2.0);
}
}
catch (Exception ex)
{
Expand Down
89 changes: 74 additions & 15 deletions EpgTimer/EpgTimer/Common/SettingClass.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ public class Settings
private double dragScroll;
private List<string> contentColorList;
private List<UInt32> contentCustColorList;
private List<string> timeColorList;
private List<UInt32> timeCustColorList;
private string reserveRectColorNormal;
private string reserveRectColorNo;
private string reserveRectColorNoTuner;
Expand All @@ -134,11 +136,13 @@ public class Settings
private string titleColor2;
private UInt32 titleCustColor1;
private UInt32 titleCustColor2;
private string serviceColor;
private UInt32 serviceCustColor;
private bool reserveRectBackground;
private bool epgToolTip;
private bool epgTitleIndent;
private bool epgToolTipNoViewOnly;
private int epgToolTipViewWait;
private bool epgPopup;
private bool epgGradation;
private bool epgGradationHeader;
private double resColumnWidth0;
private double resColumnWidth1;
private double resColumnWidth2;
Expand Down Expand Up @@ -340,6 +344,16 @@ public List<UInt32> ContentCustColorList
get { return contentCustColorList; }
set { contentCustColorList = value; }
}
public List<string> TimeColorList
{
get { return timeColorList; }
set { timeColorList = value; }
}
public List<UInt32> TimeCustColorList
{
get { return timeCustColorList; }
set { timeCustColorList = value; }
}
public string ReserveRectColorNormal
{
get { return reserveRectColorNormal; }
Expand Down Expand Up @@ -385,25 +399,35 @@ public UInt32 TitleCustColor2
get { return titleCustColor2; }
set { titleCustColor2 = value; }
}
public bool EpgToolTip
public string ServiceColor
{
get { return serviceColor; }
set { serviceColor = value; }
}
public UInt32 ServiceCustColor
{
get { return epgToolTip; }
set { epgToolTip = value; }
get { return serviceCustColor; }
set { serviceCustColor = value; }
}
public bool EpgTitleIndent
{
get { return epgTitleIndent; }
set { epgTitleIndent = value; }
}
public bool EpgToolTipNoViewOnly
public bool EpgPopup
{
get { return epgToolTipNoViewOnly; }
set { epgToolTipNoViewOnly = value; }
get { return epgPopup; }
set { epgPopup = value; }
}
public int EpgToolTipViewWait
public bool EpgGradation
{
get { return epgToolTipViewWait; }
set { epgToolTipViewWait = value; }
get { return epgGradation; }
set { epgGradation = value; }
}
public bool EpgGradationHeader
{
get { return epgGradationHeader; }
set { epgGradationHeader = value; }
}
public double ResColumnWidth0
{
Expand Down Expand Up @@ -998,6 +1022,8 @@ public Settings()
dragScroll = 1.5;
contentColorList = new List<string>();
contentCustColorList = new List<uint>();
timeColorList = new List<string>();
timeCustColorList = new List<uint>();
reserveRectColorNormal = "Lime";
reserveRectColorNo = "Black";
reserveRectColorNoTuner = "Red";
Expand All @@ -1006,11 +1032,13 @@ public Settings()
titleColor2 = "Black";
titleCustColor1 = 0xFFFFFFFF;
titleCustColor2 = 0xFFFFFFFF;
serviceColor = "LightSlateGray";
serviceCustColor = 0xFFFFFFFF;
reserveRectBackground = false;
epgToolTip = false;
epgTitleIndent = true;
epgToolTipNoViewOnly = true;
epgToolTipViewWait = 1500;
epgPopup = true;
epgGradation = true;
epgGradationHeader = true;
resColumnHead = "";
resSortDirection = ListSortDirection.Ascending;
lastWindowState = System.Windows.WindowState.Normal;
Expand Down Expand Up @@ -1144,6 +1172,15 @@ private static void DefaultcontentColorList()
Instance.contentColorList.Add("White");
}

//番組表の時間軸のデフォルトの背景色
private static void DefaulttimeColorList()
{
Instance.timeColorList.Add("MediumPurple");
Instance.timeColorList.Add("LightSeaGreen");
Instance.timeColorList.Add("LightSalmon");
Instance.timeColorList.Add("CornflowerBlue");
}

/// <summary>
/// EpgTimer用設定ファイルロード関数
/// </summary>
Expand Down Expand Up @@ -1215,6 +1252,17 @@ public static void LoadFromXmlFile()
Instance.ContentCustColorList.Add(0xFFFFFFFF);
}
}
if (Instance.timeColorList.Count == 0)
{
DefaulttimeColorList();
}
if (Instance.TimeCustColorList.Count == 0)
{
for (int i = 0; i < 4; i++)
{
Instance.TimeCustColorList.Add(0xFFFFFFFF);
}
}
if (Instance.viewButtonList.Count == 0)
{
Instance.viewButtonList.Add("設定");
Expand Down Expand Up @@ -1356,6 +1404,17 @@ public static void LoadFromXmlFileNW()
Instance.ContentCustColorList.Add(0xFFFFFFFF);
}
}
if (Instance.timeColorList.Count == 0)
{
DefaulttimeColorList();
}
if (Instance.TimeCustColorList.Count == 0)
{
for (int i = 0; i < 4; i++)
{
Instance.TimeCustColorList.Add(0xFFFFFFFF);
}
}
if (Instance.viewButtonList.Count == 0)
{
Instance.viewButtonList.Add("設定");
Expand Down
4 changes: 2 additions & 2 deletions EpgTimer/EpgTimer/DefineClass/EpgAutoDataItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -624,11 +624,11 @@ public String SearchInfoText
}
}

public SolidColorBrush BorderBrush
public Brush BorderBrush
{
get
{
SolidColorBrush color1 = Brushes.Gainsboro;
Brush color1 = Brushes.Gainsboro;
if (this.EpgAutoAddInfo.searchInfo.contentList.Count > 0)
{
byte content_nibble_level_1 = this.EpgAutoAddInfo.searchInfo.contentList[0].content_nibble_level_1;
Expand Down
4 changes: 2 additions & 2 deletions EpgTimer/EpgTimer/DefineClass/ProgramViewItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,12 @@ public bool TitleDrawErr
set;
}

public SolidColorBrush ContentColor
public Brush ContentColor
{
get
{
//return null;
SolidColorBrush color = Brushes.White;
Brush color = Brushes.White;
if (EventInfo != null)
{
if (EventInfo.ContentInfo != null)
Expand Down
Loading

0 comments on commit 6bf8019

Please sign in to comment.