本文整理汇总了C#中System.Windows.Controls.Primitives.ToggleButton.SetResourceReference方法的典型用法代码示例。如果您正苦于以下问题:C# ToggleButton.SetResourceReference方法的具体用法?C# ToggleButton.SetResourceReference怎么用?C# ToggleButton.SetResourceReference使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Controls.Primitives.ToggleButton
的用法示例。
在下文中一共展示了ToggleButton.SetResourceReference方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddPortIndex
private void AddPortIndex(int portIndex)
{
if (_portCanvas == null)
{
return;
}
ToggleButton togBut = new ToggleButton();
togBut.Width = 30;
togBut.Height = 30;
togBut.Content = (portIndex + 1).ToString();
togBut.Command = new RelayCommand<ToggleButton>(OnToggleButtonWithPortCmd);
togBut.SetResourceReference(ToggleButton.StyleProperty, "MyToggleButtonStyle");
togBut.CommandParameter = togBut;
Thickness margin = new Thickness();
margin.Left = 10 + (togBut.Width + 15) * portIndex;
margin.Top = 15;
togBut.Margin = margin;
//给网口加载图片
int senderIndex =ScreenRealParams.ScreenLayer.CurrentSenderIndex;
if (senderIndex == -1)
{
senderIndex = 0;
}
int colorIndex = 4 * senderIndex + portIndex+1;
if (SenderAndPortPicCollection != null && SenderAndPortPicCollection.Count != 0)
{
if (!SenderAndPortPicCollection.Keys.Contains(colorIndex))
{
colorIndex = 0;
}
ImageBrush imageBrush = new ImageBrush();
imageBrush.ImageSource = new BitmapImage(new Uri(SenderAndPortPicCollection[colorIndex].NoSelectedPicPath, UriKind.Absolute));
imageBrush.Stretch = Stretch.Fill;//设置图像的显示格式
togBut.Background = imageBrush;
}
_portCanvas.Children.Add(togBut);
}
示例2: AddSenderIndex
private void AddSenderIndex(int senderIndex)
{
if (_senderCanvas == null)
{
return;
}
ToggleButton togBut = new ToggleButton();
togBut.Width = 35;
togBut.Height = 35;
togBut.Content = (senderIndex + 1).ToString();
togBut.Command = new RelayCommand<ToggleButton>(OnToggleButtonWithSenderCmd);
togBut.SetResourceReference(ToggleButton.StyleProperty, "MyToggleButtonStyle");
togBut.CommandParameter = togBut;
Thickness margin = new Thickness();
int iColumnNum = senderIndex / 5;
int iRowNum = senderIndex%5;
margin.Left = 10 + (togBut.Width + 15) * iRowNum;
margin.Top = 15 + 35 * iColumnNum;
//if (senderIndex < 5)
//{
// margin.Left = 10 + (togBut.Width + 15) * senderIndex;
// margin.Top = 15;
//}
//else
//{
// margin.Left = 10 + (togBut.Width + 15) * (senderIndex - 5);
// margin.Top = 50;
//}
togBut.Margin = margin;
if (SenderAndPortPicCollection != null && SenderAndPortPicCollection.Count != 0)
{
ImageBrush imageBrush = new ImageBrush();
imageBrush.ImageSource = new BitmapImage(new Uri(SenderAndPortPicCollection[0].NoSelectedPicPath, UriKind.Absolute));
imageBrush.Stretch = Stretch.Fill;//设置图像的显示格式
togBut.Background = imageBrush;
}
_senderCanvas.Children.Add(togBut);
//int oldPortIndex = -1;
//ClearPortIndex(out oldPortIndex);
//for (int index = 0; index < CurrentSenderConfigInfo.PortCount; index++)
//{
// AddPortIndex(index);
//}
//_currentPortIndex = oldPortIndex;
//ScreenRealParams.ScreenLayer.CurrentPortIndex = _currentPortIndex;
}