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


C# StackPanel.AddHandler方法代码示例

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


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

示例1: FillDrives

 public void FillDrives()
 {
     foreach (var di in System.IO.DriveInfo.GetDrives())
     {
         if (!di.IsReady) continue;
         var hPanel = new StackPanel {Orientation = Orientation.Horizontal};
         var vPanel = new StackPanel {Orientation = Orientation.Vertical};
         var label = new TextBlock
         {
             Text = (string.IsNullOrWhiteSpace(di.VolumeLabel) || string.IsNullOrEmpty(di.VolumeLabel) ? "Local Disk " + di.Name : di.VolumeLabel),
             FontSize = 22
         };
         //quick hack TODO: add images?
         Debug.WriteLine(di.VolumeLabel  + " - " + di.Name.Length);
         var name = new TextBlock
         {
             Text = di.Name,
             FontSize = 40,
             Width = 60,
             Margin = new Thickness {Right = 10},
             Name = "Path"
         };
         hPanel.Children.Add(name);
         var space = new TextBlock
         {
             Text = $"{Helpers.PrettyByte(di.AvailableFreeSpace)} free of {Helpers.PrettyByte(di.TotalSize)}"
         };
         var driveFilled = new ProgressBar
         {
             Minimum = 0,
             Maximum = di.TotalSize,
             Value = (di.TotalSize - di.AvailableFreeSpace),
             Height = 8,
             Foreground = new SolidColorBrush(Color.FromArgb(0xFF, 0x30, 0x91, 0xDD))
         };
         var convertFromString = ColorConverter.ConvertFromString("White");
         if (convertFromString != null)
             driveFilled.Background = new SolidColorBrush((Color) convertFromString);
                 //it really shouldn't be this hard
         vPanel.Children.Add(label);
         vPanel.Children.Add(driveFilled);
         vPanel.Children.Add(space);
         hPanel.Children.Add(vPanel);
         hPanel.VerticalAlignment = VerticalAlignment.Stretch;
         //hPanel.Width = 200;
         hPanel.Height = 50;
         hPanel.AddHandler(MouseDownEvent, new MouseButtonEventHandler(OpenDrive));
         hPanel.Margin = new Thickness(10);
         Drives.Items.Add(hPanel);
     }
 }
开发者ID:Toyz,项目名称:Explore10,代码行数:51,代码来源:StartPage.xaml.cs

示例2: FillDrives

 public void FillDrives()
 {
     foreach (System.IO.DriveInfo di in System.IO.DriveInfo.GetDrives())
     {
         if (di.IsReady)
         {
             StackPanel hPanel = new StackPanel();
             hPanel.Orientation = Orientation.Horizontal;
             StackPanel vPanel = new StackPanel();
             vPanel.Orientation = Orientation.Vertical;
             TextBlock Label = new TextBlock();
             Label.Text = di.VolumeLabel;
             Label.FontSize = 22; //quick hack TODO: add images?
             TextBlock Name = new TextBlock();
             Name.Text = di.Name;
             Name.FontSize = 40;
             Name.Width = 60;
             Name.Margin = new Thickness { Right = 10 };
             Name.Name = "Path";
             hPanel.Children.Add(Name);
             TextBlock Space = new TextBlock();
             Space.Text = string.Format("{0} free of {1}", PrettyByte(di.AvailableFreeSpace), PrettyByte(di.TotalSize));
             ProgressBar DriveFilled = new ProgressBar();
             DriveFilled.Minimum = 0;
             DriveFilled.Maximum = di.TotalSize;
             DriveFilled.Value = (di.TotalSize - di.AvailableFreeSpace);
             DriveFilled.Height = 8;
             DriveFilled.Foreground = new SolidColorBrush(Color.FromArgb(0xFF, 0x30, 0x91, 0xDD));
             DriveFilled.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("White")); //it really shouldn't be this hard
             vPanel.Children.Add(Label);
             vPanel.Children.Add(DriveFilled);
             vPanel.Children.Add(Space);
             hPanel.Children.Add(vPanel);
             hPanel.Width = 200;
             hPanel.Height = 50;
             hPanel.AddHandler(StackPanel.MouseDownEvent, new MouseButtonEventHandler(OpenDrive));
             hPanel.Margin = new Thickness(10);
             Drives.Items.Add(hPanel);
         }
     }
 }
开发者ID:PFCKrutonium,项目名称:Explore10,代码行数:41,代码来源:StartPage.xaml.cs


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