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


C# ToggleButton.SetResourceReference方法代码示例

本文整理汇总了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);
        }
开发者ID:SmartEncounter,项目名称:SmartLCT-V2.0,代码行数:40,代码来源:ScreenPropertyPanel.cs

示例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;
        }
开发者ID:SmartEncounter,项目名称:SmartLCT-V2.0,代码行数:51,代码来源:ScreenPropertyPanel.cs


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