本文整理汇总了C#中System.Windows.Shapes.Rectangle.SetResourceReference方法的典型用法代码示例。如果您正苦于以下问题:C# Rectangle.SetResourceReference方法的具体用法?C# Rectangle.SetResourceReference怎么用?C# Rectangle.SetResourceReference使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Shapes.Rectangle
的用法示例。
在下文中一共展示了Rectangle.SetResourceReference方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShowRectanglesInCanvas
//在画布上显示一个矩形
private void ShowRectanglesInCanvas(Rectangle rect, int i,int j)
{
rect.Width = rectWidth;
rect.Height = rectHeight;
rect.Fill = new SolidColorBrush(Colors.LightBlue);
rect.SetValue(Canvas.TopProperty, (double)((i+1) * rectsTopSpace));//j
rect.SetValue(Canvas.LeftProperty, (double)((j+1) * rectsLeftSpace));//i
//后台设置style
rect.SetResourceReference(Rectangle.StyleProperty, "myRectangle");
MainWindow.owner.canvas.Children.Add(rect);
}
示例2: ListSystemBrushes
// Demonstrates using system colors to fill rectangles and buttons.
private void ListSystemBrushes()
{
// The window style (defined in Window1.xaml) is used to
// specify the height and width of each of the System.Windows.Shapes.Rectangles.
var t = new TextBlock {Text = "ActiveBorder"};
var r = new Rectangle
{
Fill = SystemColors.ActiveBorderBrush
};
systemBrushesPanel.Children.Add(t);
systemBrushesPanel.Children.Add(r);
t = new TextBlock {Text = "ActiveCaption"};
r = new Rectangle {Fill = SystemColors.ActiveCaptionBrush};
systemBrushesPanel.Children.Add(t);
systemBrushesPanel.Children.Add(r);
t = new TextBlock {Text = "ActiveCaptionText"};
r = new Rectangle {Fill = SystemColors.ActiveCaptionTextBrush};
systemBrushesPanel.Children.Add(t);
systemBrushesPanel.Children.Add(r);
t = new TextBlock {Text = "AppWorkspace"};
r = new Rectangle {Fill = SystemColors.AppWorkspaceBrush};
systemBrushesPanel.Children.Add(t);
systemBrushesPanel.Children.Add(r);
t = new TextBlock {Text = "Control"};
r = new Rectangle {Fill = SystemColors.ControlBrush};
systemBrushesPanel.Children.Add(t);
systemBrushesPanel.Children.Add(r);
t = new TextBlock {Text = "ControlDark"};
r = new Rectangle {Fill = SystemColors.ControlDarkBrush};
systemBrushesPanel.Children.Add(t);
systemBrushesPanel.Children.Add(r);
t = new TextBlock {Text = "ControlDarkDark"};
r = new Rectangle {Fill = SystemColors.ControlDarkDarkBrush};
systemBrushesPanel.Children.Add(t);
systemBrushesPanel.Children.Add(r);
t = new TextBlock {Text = "ControlLight"};
r = new Rectangle {Fill = SystemColors.ControlLightBrush};
systemBrushesPanel.Children.Add(t);
systemBrushesPanel.Children.Add(r);
t = new TextBlock {Text = "ControlLightLight"};
r = new Rectangle {Fill = SystemColors.ControlLightLightBrush};
systemBrushesPanel.Children.Add(t);
systemBrushesPanel.Children.Add(r);
t = new TextBlock {Text = "ControlText"};
r = new Rectangle {Fill = SystemColors.ControlTextBrush};
systemBrushesPanel.Children.Add(t);
systemBrushesPanel.Children.Add(r);
t = new TextBlock {Text = "Desktop"};
r = new Rectangle();
//r.Fill = SystemColors.DesktopBrush;
r.SetResourceReference(Shape.FillProperty, SystemColors.DesktopBrushKey);
systemBrushesPanel.Children.Add(t);
systemBrushesPanel.Children.Add(r);
t = new TextBlock {Text = "GradientActiveCaption"};
r = new Rectangle {Fill = SystemColors.GradientActiveCaptionBrush};
systemBrushesPanel.Children.Add(t);
systemBrushesPanel.Children.Add(r);
t = new TextBlock {Text = "GradientInactiveCaption"};
r = new Rectangle {Fill = SystemColors.GradientInactiveCaptionBrush};
systemBrushesPanel.Children.Add(t);
systemBrushesPanel.Children.Add(r);
t = new TextBlock {Text = "GrayText"};
r = new Rectangle {Fill = SystemColors.GrayTextBrush};
systemBrushesPanel.Children.Add(t);
systemBrushesPanel.Children.Add(r);
t = new TextBlock {Text = "Highlight"};
r = new Rectangle {Fill = SystemColors.HighlightBrush};
systemBrushesPanel.Children.Add(t);
systemBrushesPanel.Children.Add(r);
t = new TextBlock {Text = "HighlightText"};
r = new Rectangle {Fill = SystemColors.HighlightTextBrush};
systemBrushesPanel.Children.Add(t);
systemBrushesPanel.Children.Add(r);
t = new TextBlock {Text = "HotTrack"};
r = new Rectangle {Fill = SystemColors.HotTrackBrush};
systemBrushesPanel.Children.Add(t);
systemBrushesPanel.Children.Add(r);
t = new TextBlock {Text = "InactiveBorder"};
r = new Rectangle {Fill = SystemColors.InactiveBorderBrush};
systemBrushesPanel.Children.Add(t);
systemBrushesPanel.Children.Add(r);
//.........这里部分代码省略.........
示例3: OpenView
/// <summary>
/// This method is invoked when a view is opened
/// </summary>
/// <param name="context">Request context (contains information about the view)</param>
/// <returns>
/// True if handled successfully
/// </returns>
public bool OpenView(RequestContext context)
{
if (context.Result is StatusMessageResult) return HandleStatusMessage(context);
if (context.Result is NotificationMessageResult)
{
var result = context.Result as NotificationMessageResult;
return HandleNotificationMessage(context, result.Model.OverrideTimeout);
}
var viewResult = context.Result as ViewResult;
if (viewResult != null && viewResult.ForceNewShell)
if ((viewResult.ViewLevel == ViewLevel.Normal && NormalViewCount > 0) || (viewResult.ViewLevel == ViewLevel.TopLevel && TopLevelViewCount > 0))
{
// A new shell should be opened, so we try to create another shell and then hand off view opening duties to it, rather than handling it directly
var shellLauncher = Controller.GetShellLauncher() as WindowShellLauncher<Shell>;
if (shellLauncher != null)
if (shellLauncher.OpenAnotherShellInstance())
return Current.OpenView(context);
}
var messageBoxResult = context.Result as MessageBoxResult;
if (messageBoxResult != null)
{
if (messageBoxResult.View == null)
{
var messageBoxViewModel = messageBoxResult.Model as MessageBoxViewModel;
if (messageBoxViewModel != null)
{
var textBlock = new TextBlock {TextWrapping = TextWrapping.Wrap, Text = messageBoxViewModel.Text};
textBlock.SetResourceReference(StyleProperty, "CODE.Framework.Wpf.Mvvm.Shell-MessageBox-Text");
if (!string.IsNullOrEmpty(messageBoxViewModel.IconResourceKey))
{
var grid = new Grid();
grid.ColumnDefinitions.Clear();
grid.ColumnDefinitions.Add(new ColumnDefinition {Width = GridLength.Auto});
grid.ColumnDefinitions.Add(new ColumnDefinition {Width = new GridLength(1, GridUnitType.Star)});
var rect = new Rectangle {Fill = messageBoxViewModel.IconBrush};
rect.SetResourceReference(StyleProperty, "CODE.Framework.Wpf.Mvvm.Shell-MessageBox-Image");
grid.Children.Add(rect);
grid.Children.Add(textBlock);
Grid.SetColumn(textBlock, 1);
SimpleView.SetSizeStrategy(grid, ViewSizeStrategies.UseMinimumSizeRequired);
messageBoxResult.View = grid;
}
else messageBoxResult.View = textBlock;
}
}
if (messageBoxResult.View != null)
{
var messageBoxModelAction = messageBoxResult.Model as IHaveActions;
if (messageBoxModelAction != null)
{
messageBoxResult.View.InputBindings.Clear();
foreach (var action in messageBoxModelAction.Actions)
if (action.ShortcutKey != Key.None)
messageBoxResult.View.InputBindings.Add(new KeyBinding(action, action.ShortcutKey, action.ShortcutModifiers));
}
}
}
if (viewResult != null && viewResult.View != null && !viewResult.IsPartial)
{
if (viewResult.ViewLevel == ViewLevel.Popup || viewResult.ViewLevel == ViewLevel.StandAlone || viewResult.ViewLevel == ViewLevel.TopLevel)
return OpenTopLevelView(context, messageBoxResult, viewResult);
// This is an normal (main) view
// Need to make sure we do not open more than allowed
if (MaximumNormalViewCount > -1)
{
var inplaceNormalViews = NormalViews.Where(v => v.TopLevelWindow == null).ToList();
while (inplaceNormalViews.Count + 1 > MaximumNormalViewCount)
{
CloseViewForModel(inplaceNormalViews[0].Model);
inplaceNormalViews.RemoveAt(0);
}
}
NormalViews.Add(viewResult);
if (viewResult.MakeViewVisibleOnLaunch)
{
FocusManager.SetFocusedElement(this, viewResult.View);
SelectedNormalView = NormalViews.Count - 1;
SelectedNormalViewResult = SelectedNormalView > -1 ? NormalViews[SelectedNormalView] : null;
}
NormalViewCount = NormalViews.Count;
if (NormalViewLaunchMode == ViewLaunchMode.Popup)
OpenNormalViewInWindow(context, viewResult);
return true;
//.........这里部分代码省略.........