當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。