本文整理汇总了C#中GradientStopCollection.Freeze方法的典型用法代码示例。如果您正苦于以下问题:C# GradientStopCollection.Freeze方法的具体用法?C# GradientStopCollection.Freeze怎么用?C# GradientStopCollection.Freeze使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GradientStopCollection
的用法示例。
在下文中一共展示了GradientStopCollection.Freeze方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateBrushes
// *** Private static methods ***
private static void CreateBrushes()
{
// Get the colors for the shadow
Color shadowColor = Color.FromArgb(128, 0, 0, 0);
Color transparentColor = Color.FromArgb(16, 0, 0, 0);
// Create a GradientStopCollection from these
GradientStopCollection gradient = new GradientStopCollection(2);
gradient.Add(new GradientStop(shadowColor, 0.5));
gradient.Add(new GradientStop(transparentColor, 1.0));
gradient.Freeze();
// Create the background brush
backgroundBrush = new SolidColorBrush(shadowColor);
backgroundBrush.Freeze();
// Create the LinearGradientBrushes
rightBrush = new LinearGradientBrush(gradient, new Point(0.0, 0.0), new Point(1.0, 0.0)); rightBrush.Freeze();
bottomBrush = new LinearGradientBrush(gradient, new Point(0.0, 0.0), new Point(0.0, 1.0)); bottomBrush.Freeze();
// Create the RadialGradientBrushes
bottomRightBrush = new RadialGradientBrush(gradient);
bottomRightBrush.GradientOrigin = new Point(0.0, 0.0);
bottomRightBrush.Center = new Point(0.0, 0.0);
bottomRightBrush.RadiusX = 1.0;
bottomRightBrush.RadiusY = 1.0;
bottomRightBrush.Freeze();
topRightBrush = new RadialGradientBrush(gradient);
topRightBrush.GradientOrigin = new Point(0.0, 1.0);
topRightBrush.Center = new Point(0.0, 1.0);
topRightBrush.RadiusX = 1.0;
topRightBrush.RadiusY = 1.0;
topRightBrush.Freeze();
bottomLeftBrush = new RadialGradientBrush(gradient);
bottomLeftBrush.GradientOrigin = new Point(1.0, 0.0);
bottomLeftBrush.Center = new Point(1.0, 0.0);
bottomLeftBrush.RadiusX = 1.0;
bottomLeftBrush.RadiusY = 1.0;
bottomLeftBrush.Freeze();
}
示例2: CreateStops
static GradientStopCollection CreateStops(Color c)
{
GradientStopCollection stops = new GradientStopCollection();
Color stopColor = c;
stopColor.A = (byte)(.45 * c.A);
stops.Add(new GradientStop(stopColor, 0));
stopColor.A = (byte)(.40 * c.A);
stops.Add(new GradientStop(stopColor, .2));
stopColor.A = (byte)(.25 * c.A);
stops.Add(new GradientStop(stopColor, .45));
stopColor.A = (byte)(.10 * c.A);
stops.Add(new GradientStop(stopColor, .7));
stopColor.A = (byte)(.05 * c.A);
stops.Add(new GradientStop(stopColor, .85));
stopColor.A = 0;
stops.Add(new GradientStop(stopColor, 1));
stops.Freeze();
return stops;
}
示例3: CreateStops
// Create common gradient stop collection for gradient brushes
private static GradientStopCollection CreateStops(Color c, double cornerRadius)
{
// Scale stops to lie within 0 and 1
double gradientScale = 1 / (cornerRadius + ShadowDepth);
GradientStopCollection gsc = new GradientStopCollection();
gsc.Add(new GradientStop(c, (0.5 + cornerRadius) * gradientScale));
// Create gradient stops based on the Win32 dropshadow fall off
Color stopColor = c;
stopColor.A = (byte)(.74336 * c.A);
gsc.Add(new GradientStop(stopColor, (1.5 + cornerRadius) * gradientScale));
stopColor.A = (byte)(.38053 * c.A);
gsc.Add(new GradientStop(stopColor, (2.5 + cornerRadius)* gradientScale));
stopColor.A = (byte)(.12389 * c.A);
gsc.Add(new GradientStop(stopColor, (3.5 + cornerRadius) * gradientScale));
stopColor.A = (byte)(.02654 * c.A);
gsc.Add(new GradientStop(stopColor, (4.5 + cornerRadius) * gradientScale));
stopColor.A = 0;
gsc.Add(new GradientStop(stopColor, (5 + cornerRadius) * gradientScale));
gsc.Freeze();
return gsc;
}
示例4: CreateStops
private static GradientStopCollection CreateStops(System.Windows.Media.Color c, double cornerRadius)
{
double num = 1.0 / (cornerRadius + 5.0);
GradientStopCollection stops = new GradientStopCollection {
new GradientStop(c, (0.5 + cornerRadius) * num)
};
System.Windows.Media.Color color = c;
color.A = (byte)(0.74336 * c.A);
stops.Add(new GradientStop(color, (1.5 + cornerRadius) * num));
color.A = (byte)(0.38053 * c.A);
stops.Add(new GradientStop(color, (2.5 + cornerRadius) * num));
color.A = (byte)(0.12389 * c.A);
stops.Add(new GradientStop(color, (3.5 + cornerRadius) * num));
color.A = (byte)(0.02654 * c.A);
stops.Add(new GradientStop(color, (4.5 + cornerRadius) * num));
color.A = 0;
stops.Add(new GradientStop(color, (5.0 + cornerRadius) * num));
stops.Freeze();
return stops;
}
示例5: AcceptGame
//.........这里部分代码省略.........
DockPanel.SetDock(iHeader, Dock.Left);
switch (player.PlayerType)
{
case DominionBase.Players.PlayerType.Human:
iHeader.Source = (BitmapImage)this.Resources["imHuman"];
break;
case DominionBase.Players.PlayerType.Computer:
iHeader.Source = (BitmapImage)this.Resources["imComputer"];
break;
}
dpHeader.Children.Add(iHeader);
TextBlock tbHeader = new TextBlock();
tbHeader.Text = player.Name;
dpHeader.Children.Add(tbHeader);
tiPlayer.Header = dpHeader;
tcAreas.Items.Add(tiPlayer);
Controls.ucPlayerDisplay ucpdPlayer = new Controls.ucPlayerDisplay();
tiPlayer.Content = ucpdPlayer;
ucpdPlayer.IsUIPlayer = (player.PlayerType == DominionBase.Players.PlayerType.Human);
ucpdPlayer.Player = player;
PlayerSettings playerSettings = _Settings.PlayerSettings.FirstOrDefault(ps => ps.Name == player.Name);
if (playerSettings != null)
{
ColorHls hlsValue = HLSColor.RgbToHls(playerSettings.UIColor);
Color cPlayer = HLSColor.HlsToRgb(hlsValue.H, Math.Min(1d, hlsValue.L * 1.125), hlsValue.S * 0.95, hlsValue.A);
GradientStopCollection gsc = new GradientStopCollection();
gsc.Add(new GradientStop(cPlayer, 0));
gsc.Add(new GradientStop(playerSettings.UIColor, 0.25));
gsc.Add(new GradientStop(playerSettings.UIColor, 0.75));
gsc.Add(new GradientStop(cPlayer, 1));
gsc.Freeze();
tiPlayer.Background = new LinearGradientBrush(gsc, 0);
//tiPlayer.Background = new SolidColorBrush(playerSettings.UIColor);
ucpdPlayer.ColorFocus = playerSettings.UIColor;
}
ToolTip tt = new System.Windows.Controls.ToolTip();
Controls.ucPlayerOverview ucpo = new Controls.ucPlayerOverview();
ucpo.Player = player;
tt.Content = ucpo;
ToolTipService.SetToolTip(dpHeader, tt);
if (Settings.ToolTipShowDuration == ToolTipShowDuration.Off)
ToolTipService.SetIsEnabled(dpHeader, false);
else
{
ToolTipService.SetIsEnabled(dpHeader, true);
ToolTipService.SetShowDuration(dpHeader, (int)Settings.ToolTipShowDuration);
}
dpHeader.MouseDown += new MouseButtonEventHandler(tiPlayer_MouseDown);
dpHeader.MouseUp += new MouseButtonEventHandler(tiPlayer_MouseUp);
player.Revealed.PileChanged += new DominionBase.Piles.Pile.PileChangedEventHandler(Revealed_PileChanged);
player.BenefitReceiving += new DominionBase.Players.Player.BenefitReceivingEventHandler(player_BenefitReceiving);
//player.DiscardPile.PileChanged += new DominionBase.Pile.PileChangedEventHandler(DiscardPile_PileChanged);
player.CardPlaying += new DominionBase.Players.Player.CardPlayingEventHandler(player_CardPlaying);
player.CardPlayed += new DominionBase.Players.Player.CardPlayedEventHandler(player_CardPlayed);
player.CardUndoPlaying += new DominionBase.Players.Player.CardUndoPlayingEventHandler(player_CardUndoPlaying);
player.CardUndoPlayed += new DominionBase.Players.Player.CardUndoPlayedEventHandler(player_CardUndoPlayed);
player.CardBuying += new DominionBase.Players.Player.CardBuyingEventHandler(player_CardBuying);
player.CardBought += new DominionBase.Players.Player.CardBoughtEventHandler(player_CardBought);
player.CardBuyFinished += new DominionBase.Players.Player.CardBuyFinishedEventHandler(player_CardBuyFinished);
player.CardGaining += new DominionBase.Players.Player.CardGainingEventHandler(player_CardGaining);
player.CardGainedInto += new DominionBase.Players.Player.CardGainedIntoEventHandler(player_CardGainedInto);
示例6: Game_Load_Click
//.........这里部分代码省略.........
DockPanel.SetDock(iHeader, Dock.Left);
switch (player.PlayerType)
{
case DominionBase.Players.PlayerType.Human:
iHeader.Source = (BitmapImage)this.Resources["imHuman"];
break;
case DominionBase.Players.PlayerType.Computer:
iHeader.Source = (BitmapImage)this.Resources["imComputer"];
break;
}
dpHeader.Children.Add(iHeader);
TextBlock tbHeader = new TextBlock();
tbHeader.Text = player.Name;
dpHeader.Children.Add(tbHeader);
tiPlayer.Header = dpHeader;
tcAreas.Items.Add(tiPlayer);
Controls.ucPlayerDisplay ucpdPlayer = new Controls.ucPlayerDisplay();
tiPlayer.Content = ucpdPlayer;
ucpdPlayer.IsUIPlayer = (player == _Player);
ucpdPlayer.Player = player;
PlayerSettings playerSettings = _Settings.PlayerSettings.FirstOrDefault(ps => ps.Name == player.Name);
if (playerSettings != null)
{
ColorHls hlsValue = HLSColor.RgbToHls(playerSettings.UIColor);
Color cPlayer = HLSColor.HlsToRgb(hlsValue.H, Math.Min(1d, hlsValue.L * 1.125), hlsValue.S * 0.95, hlsValue.A);
GradientStopCollection gsc = new GradientStopCollection();
gsc.Add(new GradientStop(cPlayer, 0));
gsc.Add(new GradientStop(playerSettings.UIColor, 0.25));
gsc.Add(new GradientStop(playerSettings.UIColor, 0.75));
gsc.Add(new GradientStop(cPlayer, 1));
gsc.Freeze();
tiPlayer.Background = new LinearGradientBrush(gsc, 0);
//tiPlayer.Background = new SolidColorBrush(playerSettings.UIColor);
ucpdPlayer.ColorFocus = playerSettings.UIColor;
}
ToolTip tt = new System.Windows.Controls.ToolTip();
Controls.ucPlayerOverview ucpo = new Controls.ucPlayerOverview();
ucpo.Player = player;
tt.Content = ucpo;
ToolTipService.SetToolTip(dpHeader, tt);
if (Settings.ToolTipShowDuration == ToolTipShowDuration.Off)
ToolTipService.SetIsEnabled(dpHeader, false);
else
{
ToolTipService.SetIsEnabled(dpHeader, true);
ToolTipService.SetShowDuration(dpHeader, (int)Settings.ToolTipShowDuration);
}
dpHeader.MouseDown += new MouseButtonEventHandler(tiPlayer_MouseDown);
dpHeader.MouseUp += new MouseButtonEventHandler(tiPlayer_MouseUp);
player.Revealed.PileChanged += new DominionBase.Piles.Pile.PileChangedEventHandler(Revealed_PileChanged);
player.BenefitReceiving += new DominionBase.Players.Player.BenefitReceivingEventHandler(player_BenefitReceiving);
//player.DiscardPile.PileChanged += new DominionBase.Pile.PileChangedEventHandler(DiscardPile_PileChanged);
player.CardPlaying += new DominionBase.Players.Player.CardPlayingEventHandler(player_CardPlaying);
player.CardPlayed += new DominionBase.Players.Player.CardPlayedEventHandler(player_CardPlayed);
player.CardUndoPlaying += new DominionBase.Players.Player.CardUndoPlayingEventHandler(player_CardUndoPlaying);
player.CardUndoPlayed += new DominionBase.Players.Player.CardUndoPlayedEventHandler(player_CardUndoPlayed);
player.CardBuying += new DominionBase.Players.Player.CardBuyingEventHandler(player_CardBuying);
player.CardBought += new DominionBase.Players.Player.CardBoughtEventHandler(player_CardBought);
player.CardBuyFinished += new DominionBase.Players.Player.CardBuyFinishedEventHandler(player_CardBuyFinished);
player.CardGaining += new DominionBase.Players.Player.CardGainingEventHandler(player_CardGaining);
player.CardGainedInto += new DominionBase.Players.Player.CardGainedIntoEventHandler(player_CardGainedInto);
示例7: _getGradientStops
private GradientStopCollection _getGradientStops(double radius) {
if (!_gradientStops.ContainsKey(radius)) {
var stops = new GradientStopCollection();
var color = Color;
var delta = 1.0 / (radius + (7.5 - Softness*5.0));
for (int i=0; i < _gradientOpacities.Length; i++) {
color.A = (byte)(_gradientOpacities[i] * color.A);
stops.Add(new GradientStop(color, (_gradientDistribution[i]+radius)*delta));
}
stops.Freeze();
lock (_lock) {
_gradientStops[radius] = stops;
}
}
return _gradientStops[radius];
}
示例8: CreateStops
private GradientStopCollection CreateStops(Color c, double cornerRadius)
{
double stopPoint = 1.0 / (cornerRadius + ShadowDepth);
var stops = new GradientStopCollection
{
new GradientStop(c, (ShadowDepth + cornerRadius) * stopPoint)
};
Color color = c;
color.A = (byte)(0.74336 * c.A);
stops.Add(new GradientStop(color, (1.5 + cornerRadius) * stopPoint));
color.A = (byte)(0.38053 * c.A);
stops.Add(new GradientStop(color, (2.5 + cornerRadius) * stopPoint));
color.A = (byte)(0.12389 * c.A);
stops.Add(new GradientStop(color, (3.5 + cornerRadius) * stopPoint));
color.A = (byte)(0.02654 * c.A);
stops.Add(new GradientStop(color, (4.5 + cornerRadius) * stopPoint));
color.A = 0;
stops.Add(new GradientStop(color, (5.0 + cornerRadius) * stopPoint));
stops.Freeze();
return stops;
}