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


C# ContentControl.Arrange方法代码示例

本文整理汇总了C#中System.Windows.Controls.ContentControl.Arrange方法的典型用法代码示例。如果您正苦于以下问题:C# ContentControl.Arrange方法的具体用法?C# ContentControl.Arrange怎么用?C# ContentControl.Arrange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Controls.ContentControl的用法示例。


在下文中一共展示了ContentControl.Arrange方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetNewMessagesNotificationOverlay

		public static ImageSource GetNewMessagesNotificationOverlay(Window window, DataTemplate template, int count = 0)
		{
			if (window == null)
				return null;

			var presentation = PresentationSource.FromVisual(window);
			if (presentation == null)
				return null;
			Matrix m = presentation.CompositionTarget.TransformToDevice;
			double dx = m.M11;
			double dy = m.M22;

			double iconWidth = 16.0 * dx;
			double iconHeight = 16.0 * dy;

			string countText = count.ToString();

			RenderTargetBitmap bmp = new RenderTargetBitmap((int) iconWidth, (int) iconHeight, 96, 96, PixelFormats.Default);

			ContentControl root = new ContentControl
			{
				ContentTemplate = template,
				Content = count > 99 ? "…" : countText
			};

			root.Arrange(new Rect(0, 0, iconWidth, iconHeight));

			bmp.Render(root);

			return bmp;
		}
开发者ID:kveretennicov,项目名称:kato,代码行数:31,代码来源:Taskbarhelper.cs

示例2: OnPropertyChanged

        private static void OnPropertyChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e)
        {
            var taskbarItemInfo = (TaskbarItemInfo) dependencyObject;
            object content = GetContent(taskbarItemInfo);
            DataTemplate template = GetTemplate(taskbarItemInfo);

            if (template == null || content == null)
            {
                taskbarItemInfo.Overlay = null;
                return;
            }

            const int ICON_WIDTH = 32;
            const int ICON_HEIGHT = 32;

            var bmp =
                new RenderTargetBitmap(ICON_WIDTH, ICON_HEIGHT, 96, 96, PixelFormats.Default);
            var root = new ContentControl
            {
                ContentTemplate = template,
                Content = content
            };
            root.Arrange(new Rect(0, 0, ICON_WIDTH, ICON_HEIGHT));
            bmp.Render(root);

            taskbarItemInfo.Overlay = bmp;
        }
开发者ID:benneeh,项目名称:wScreenshot,代码行数:27,代码来源:TaskBarItemOverlay.cs

示例3: PageBuilder

        public PageBuilder(double width, double height, int marginsLeft, int marginsTop, int marginsRight, int marginsBottom, ContentControl frame)
        {
            _page = new PageContent();
              _fixedPage = new FixedPage {Background = Brushes.White, Width = width, Height = height};

              _repeater = new Repeater();
              var repeatContainer = new Grid {Margin = new Thickness(marginsLeft, marginsTop, marginsRight, marginsBottom)};
              repeatContainer.Children.Add(_repeater);

              frame.SetValue(FixedPage.LeftProperty, 0.00);
              frame.SetValue(FixedPage.TopProperty, 0.00);
              frame.SetValue(FrameworkElement.WidthProperty, _fixedPage.Width);
              frame.SetValue(FrameworkElement.HeightProperty, _fixedPage.Height);

              _fixedPage.Children.Add(frame);
              ((IAddChild)_page).AddChild(_fixedPage);

              frame.Content = repeatContainer;

              frame.Measure(new Size(width, height));
              frame.Arrange(new Rect(0, 0, width, height));

              _repeater.Width = repeatContainer.ActualWidth;
              _repeater.Height = repeatContainer.ActualHeight;
        }
开发者ID:frederiksen,项目名称:Task-Card-Creator,代码行数:25,代码来源:PageBuilder.cs

示例4: RenderVector

        /// <summary>
        /// Renders the vector icon with the specified resource key, as an image of the specified size, and returns an URI for tile icons.
        /// </summary>
        /// <remarks>
        /// The key is for a ControlTemplate, it's the easiest way to store a path in resources.
        /// </remarks>
        private static Uri RenderVector( string templateKey, double size )
        {
            size = Math.Round( size );
            string fileName = string.Format( "Shared/ShellContent/{0}_{1}.png", templateKey, size );

            var control = new ContentControl();
            control.Template = (ControlTemplate) Application.Current.Resources[templateKey];
            control.Measure( new Size( size, size ) );
            control.Arrange( new Rect( 0, 0, size, size ) );

            var bitmap = new WriteableBitmap( (int) size, (int) size );
            bitmap.Render( control, null );
            bitmap.Invalidate();

            using ( var store = IsolatedStorageFile.GetUserStoreForApplication() )
            {
                if ( store.FileExists( fileName ) )
                {
                    store.DeleteFile( fileName );
                }

                using ( var stream = store.CreateFile( fileName ) )
                {
                    new PngWriter( stream, bitmap ).Write();
                }
            }

            return new Uri( "isostore:/" + fileName, UriKind.Absolute );
        }
开发者ID:accandme,项目名称:pocketcampus,代码行数:35,代码来源:TileService.cs

示例5: OnTaskbarOverlayPropertyChanged

        /// <summary>
        /// Called when the task bar overlay property is changed.
        /// </summary>
        /// <param name="dependencyObject">The dependency object.</param>
        /// <param name="e">The <see cref="DependencyPropertyChangedEventArgs"/> instance containing the event data.</param>
        private static void OnTaskbarOverlayPropertyChanged(
            DependencyObject dependencyObject,
            DependencyPropertyChangedEventArgs e)
        {
            Window window = (Window)dependencyObject;

            if ((window.TaskbarOverlay == null) && (window.TaskbarOverlayTemplate == null))
            {
                window.GetTaskbarItemInfoSafely().Overlay = null;
            }
            else if ((window.TaskbarOverlay != null) && (window.TaskbarOverlay is ImageSource) && (window.TaskbarOverlayTemplate == null))
            {
                window.GetTaskbarItemInfoSafely().Overlay = (ImageSource)window.TaskbarOverlay;
            }

            RenderTargetBitmap renderTargetBitmap = new RenderTargetBitmap(
                OVERLAY_ICON_WIDTH,
                OVERLAY_ICON_HEIGHT,
                96,
                96,
                PixelFormats.Default);
            ContentControl contentControl = new ContentControl()
            {
                Content = window.TaskbarOverlay,
                ContentTemplate = window.TaskbarOverlayTemplate
            };
            contentControl.Arrange(new Rect(0, 0, OVERLAY_ICON_WIDTH, OVERLAY_ICON_HEIGHT));
            renderTargetBitmap.Render(contentControl);

            window.GetTaskbarItemInfoSafely().Overlay = renderTargetBitmap;
        }
开发者ID:Krisscut,项目名称:InvolvedRCON,代码行数:36,代码来源:Window.cs


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