当前位置: 首页>>代码示例>>C#>>正文


C# Rectangle.SetResourceReference方法代码示例

本文整理汇总了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);
 }
开发者ID:ForeverSc,项目名称:MyProject,代码行数:12,代码来源:NewSettingsViewModel.cs

示例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);
//.........这里部分代码省略.........
开发者ID:ClemensT,项目名称:WPF-Samples,代码行数:101,代码来源:MainWindow.cs

示例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;
//.........这里部分代码省略.........
开发者ID:sat1582,项目名称:CODEFramework,代码行数:101,代码来源:Shell.cs


注:本文中的System.Windows.Shapes.Rectangle.SetResourceReference方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。