------ #### RaUIV4 V4.0.2311.0701 - *.[全新]整合了MyDb、ryControls、MyDb_MySQL等dll文件到RaUI一个项目。 - *.[新增]新增ApkOp类,可以轻松获取APK信息。 - *.[新增]新增JsonExt扩展类,让Json操作更简单。 - *.[新增]新增WebP类,可以支持webp格式的图片。 - *.[改进]ryQuickSQL中的AddField方法改为自动替换已存在的同名值。 - *.[修复]ryQuickSQL中的AddFieldCalc方法无法正常计算的BUG。
175 lines
4.7 KiB
C#
175 lines
4.7 KiB
C#
using System;
|
|
using System.Windows.Forms;
|
|
using System.ComponentModel;
|
|
using System.Collections.Generic;
|
|
|
|
namespace WeifenLuo.WinFormsUI.Docking
|
|
{
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
[ProvideProperty("EnableVSStyle", typeof(ToolStrip))]
|
|
public partial class VisualStudioToolStripExtender : Component, IExtenderProvider
|
|
{
|
|
private class ToolStripProperties
|
|
{
|
|
private VsVersion version = VsVersion.Unknown;
|
|
private readonly ToolStrip strip;
|
|
private readonly Dictionary<ToolStripItem, string> menuText = new Dictionary<ToolStripItem, string>();
|
|
|
|
|
|
public ToolStripProperties(ToolStrip toolstrip)
|
|
{
|
|
if (toolstrip == null) throw new ArgumentNullException("toolstrip");
|
|
strip = toolstrip;
|
|
|
|
if (strip is MenuStrip)
|
|
SaveMenuStripText();
|
|
}
|
|
|
|
public VsVersion VsVersion
|
|
{
|
|
get { return this.version; }
|
|
set
|
|
{
|
|
this.version = value;
|
|
UpdateMenuText(this.version == VsVersion.Vs2012 || this.version == VsVersion.Vs2013);
|
|
}
|
|
}
|
|
|
|
private void SaveMenuStripText()
|
|
{
|
|
foreach (ToolStripItem item in strip.Items)
|
|
menuText.Add(item, item.Text);
|
|
}
|
|
|
|
public void UpdateMenuText(bool caps)
|
|
{
|
|
foreach (ToolStripItem item in menuText.Keys)
|
|
{
|
|
var text = menuText[item];
|
|
item.Text = caps ? text.ToUpper() : text;
|
|
}
|
|
}
|
|
}
|
|
|
|
private readonly Dictionary<ToolStrip, ToolStripProperties> strips = new Dictionary<ToolStrip, ToolStripProperties>();
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public VisualStudioToolStripExtender()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="container"></param>
|
|
public VisualStudioToolStripExtender(IContainer container)
|
|
{
|
|
container.Add(this);
|
|
|
|
InitializeComponent();
|
|
}
|
|
|
|
#region IExtenderProvider Members
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="extendee"></param>
|
|
/// <returns></returns>
|
|
public bool CanExtend(object extendee)
|
|
{
|
|
return extendee is ToolStrip;
|
|
}
|
|
|
|
#endregion
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public ToolStripRenderer DefaultRenderer { get; set; }
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="strip"></param>
|
|
/// <returns></returns>
|
|
[DefaultValue(false)]
|
|
public VsVersion GetStyle(ToolStrip strip)
|
|
{
|
|
if (strips.ContainsKey(strip))
|
|
return strips[strip].VsVersion;
|
|
|
|
return VsVersion.Unknown;
|
|
}
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="strip"></param>
|
|
/// <param name="version"></param>
|
|
/// <param name="theme"></param>
|
|
public void SetStyle(ToolStrip strip, VsVersion version, ThemeBase theme)
|
|
{
|
|
ToolStripProperties properties = null;
|
|
|
|
if (!strips.ContainsKey(strip))
|
|
{
|
|
properties = new ToolStripProperties(strip) { VsVersion = version };
|
|
strips.Add(strip, properties);
|
|
}
|
|
else
|
|
{
|
|
properties = strips[strip];
|
|
}
|
|
|
|
if (theme == null)
|
|
{
|
|
if (DefaultRenderer != null)
|
|
strip.Renderer = DefaultRenderer;
|
|
}
|
|
else
|
|
{
|
|
theme.ApplyTo(strip);
|
|
}
|
|
properties.VsVersion = version;
|
|
}
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public enum VsVersion
|
|
{
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
Unknown,
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
Vs2003,
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
Vs2005,
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
Vs2008,
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
Vs2010,
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
Vs2012,
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
Vs2013,
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
Vs2015
|
|
}
|
|
}
|
|
}
|