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


C# ScrollViewer.BeginInit方法代码示例

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


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

示例1: GetMappedLayerWeights

        public ScrollViewer GetMappedLayerWeights()
        {
            WrapPanel panel = new WrapPanel();
            panel.BeginInit();
            panel.UseLayoutRounding = true;
            panel.SnapsToDevicePixels = true;
            panel.Orientation = Orientation.Horizontal;
            panel.HorizontalAlignment = HorizontalAlignment.Stretch;
            panel.VerticalAlignment = VerticalAlignment.Stretch;

            for (int map = 0; map < MapCount; map++)
            {
                Grid grid = new Grid();
                grid.SnapsToDevicePixels = true;
                grid.UseLayoutRounding = true;
                grid.Background = System.Windows.Media.Brushes.White;
                grid.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
                grid.VerticalAlignment = System.Windows.VerticalAlignment.Top;
                grid.Width = double.NaN;
                grid.Height = double.NaN;
                grid.Margin = new Thickness(4);

                for (int col = 0; col < MapWidth; col++)
                {
                    ColumnDefinition colDef = new ColumnDefinition();
                    colDef.Width = new GridLength(0, GridUnitType.Auto);
                    grid.ColumnDefinitions.Add(colDef);
                }
                for (int row = 0; row < MapHeight; row++)
                {
                    RowDefinition rowDef = new RowDefinition();
                    rowDef.Height = new GridLength(0, GridUnitType.Auto);
                    grid.RowDefinitions.Add(rowDef);
                }

                double weightMin = Weights.Min(weight => weight.Value);
                double weightMax = Weights.Max(weight => weight.Value);
                double range = GetRangeFactor(weightMin, weightMax);

                grid.BeginInit();
                for (int y = 0; y < ReceptiveFieldWidth; y++)
                {
                    for (int x = 0; x < ReceptiveFieldHeight; x++)
                    {
                        int index = x + (y * ReceptiveFieldWidth) + (map * ((ReceptiveFieldWidth * ReceptiveFieldHeight) + 1));
                        System.Windows.Shapes.Rectangle rectangle = new System.Windows.Shapes.Rectangle();
                        rectangle.BeginInit();
                        rectangle.SnapsToDevicePixels = true;
                        rectangle.UseLayoutRounding = true;
                        rectangle.HorizontalAlignment = HorizontalAlignment.Stretch;
                        ToolTip tip = new ToolTip();
                        tip.Content = Weights[index].Value.ToString("N17", CultureInfo.CurrentUICulture);
                        rectangle.ToolTip = tip;
                        rectangle.VerticalAlignment = VerticalAlignment.Stretch;
                        rectangle.Margin = new Thickness(0);
                        rectangle.Height = 8;
                        rectangle.Width = 8;
                        rectangle.Stretch = Stretch.Uniform;
                        rectangle.Fill = GetBrushFromRange(range, weightMin, weightMax, Weights[index].Value);
                        rectangle.EndInit();
                        Grid.SetColumn(rectangle, x);
                        Grid.SetRow(rectangle, y);
                        grid.Children.Add(rectangle);
                        tip = null;
                        rectangle = null;
                    }
                };

                grid.EndInit();
                panel.Children.Add(grid);
            }
            panel.EndInit();

            ScrollViewer scr = new ScrollViewer();
            scr.BeginInit();
            scr.SnapsToDevicePixels = true;
            scr.UseLayoutRounding = true;
            scr.VerticalScrollBarVisibility = ScrollBarVisibility.Visible;
            scr.HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled;
            scr.HorizontalContentAlignment = HorizontalAlignment.Left;
            scr.VerticalContentAlignment = VerticalAlignment.Top;
            scr.VerticalAlignment = VerticalAlignment.Stretch;
            scr.HorizontalAlignment = HorizontalAlignment.Stretch;
            scr.Content = panel;
            scr.Height = double.NaN;
            scr.Width = double.NaN;
            scr.EndInit();

            return (scr);
        }
开发者ID:PkuRainBow,项目名称:leafasis,代码行数:90,代码来源:NeuralNetworks.cs

示例2: GetMappedLayerOutputs

        public ScrollViewer GetMappedLayerOutputs()
        {
            WrapPanel panel = new WrapPanel();
            panel.BeginInit();
            panel.UseLayoutRounding = true;
            panel.SnapsToDevicePixels = true;
            panel.Orientation = Orientation.Horizontal;
            panel.HorizontalAlignment = HorizontalAlignment.Stretch;
            panel.VerticalAlignment = VerticalAlignment.Stretch;

            for (int map = 0; map < MapCount; ++map)
            {
                Grid grid = new Grid();
                grid.SnapsToDevicePixels = true;
                grid.UseLayoutRounding = true;
                grid.Background = System.Windows.Media.Brushes.White;
                grid.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
                grid.VerticalAlignment = System.Windows.VerticalAlignment.Top;
                grid.Width = double.NaN;
                grid.Height = double.NaN;
                grid.Margin = new Thickness(4);

                for (int col = 0; col < MapWidth; col++)
                {
                    ColumnDefinition colDef = new ColumnDefinition();
                    colDef.Width = new GridLength(0, GridUnitType.Auto);
                    grid.ColumnDefinitions.Add(colDef);
                }
                for (int row = 0; row < MapHeight; row++)
                {
                    RowDefinition rowDef = new RowDefinition();
                    rowDef.Height = new GridLength(0, GridUnitType.Auto);
                    grid.RowDefinitions.Add(rowDef);
                }

                grid.BeginInit();

                for (int y = 0; y < MapHeight; y++)
                {
                    for (int x = 0; x < MapWidth; x++)
                    {
                        int index = x + (y * MapWidth) + (map * MapWidth * MapHeight);
                        byte color = (byte)(255 - ((Neurons[index].Output + 1D) * 127D));
                        System.Windows.Media.SolidColorBrush brush = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromRgb(color, color, color));
                        brush.Freeze();
                        System.Windows.Shapes.Rectangle rectangle = new System.Windows.Shapes.Rectangle();
                        rectangle.BeginInit();
                        rectangle.SnapsToDevicePixels = true;
                        rectangle.UseLayoutRounding = true;
                        rectangle.HorizontalAlignment = HorizontalAlignment.Stretch;
                        ToolTip tip = new ToolTip();
                        tip.Content = Neurons[index].Output.ToString("N17", CultureInfo.CurrentUICulture);
                        rectangle.ToolTip = tip;
                        rectangle.VerticalAlignment = VerticalAlignment.Stretch;
                        rectangle.Margin = new Thickness(0);
                        rectangle.Height = 8;
                        rectangle.Width = 8;
                        rectangle.Stretch = Stretch.Uniform;
                        rectangle.Fill = brush;
                        rectangle.EndInit();
                        Grid.SetColumn(rectangle, x);
                        Grid.SetRow(rectangle, y);
                        grid.Children.Add(rectangle);
                        brush = null;
                        tip = null;
                        rectangle = null;
                    }
                }
                grid.EndInit();
                panel.Children.Add(grid);
            }
            panel.EndInit();

            ScrollViewer scr = new ScrollViewer();
            scr.BeginInit();
            scr.SnapsToDevicePixels = true;
            scr.UseLayoutRounding = true;
            scr.VerticalScrollBarVisibility = ScrollBarVisibility.Visible;
            scr.HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled;
            scr.HorizontalContentAlignment = HorizontalAlignment.Left;
            scr.VerticalContentAlignment = VerticalAlignment.Top;
            scr.VerticalAlignment = VerticalAlignment.Stretch;
            scr.HorizontalAlignment = HorizontalAlignment.Stretch;
            scr.Content = panel;
            scr.Height = double.NaN;
            scr.Width = double.NaN;
            scr.EndInit();

            return (scr);
        }
开发者ID:PkuRainBow,项目名称:leafasis,代码行数:90,代码来源:NeuralNetworks.cs


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