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


C# Label.SetCurrentValue方法代码示例

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


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

示例1: AssociatedDocListBoxItem

        public AssociatedDocListBoxItem(String labeltext, String imageUri, String _scatteruri, ArtworkModeWindow lb, string description)
        {
            _helpers = new Helpers();
            _description = description;
            scatteruri = _scatteruri;
            _lb = lb;
            opened = false;
            dp = new DockPanel();
            this.Content = dp;
            //if image
            if (_helpers.IsImageFile(_scatteruri))
            {
                image = new Image();
                _helpers = new Helpers();

                FileStream stream = new FileStream(imageUri, FileMode.Open);

                System.Drawing.Image dImage = System.Drawing.Image.FromStream(stream);
                System.Windows.Controls.Image wpfImage = _helpers.ConvertDrawingImageToWPFImage(dImage);
                stream.Close();

                wpfImage.SetCurrentValue(DockPanel.DockProperty, Dock.Left);

                wpfImage.SetCurrentValue(HeightProperty, 50.0);
                wpfImage.SetCurrentValue(WidthProperty, 50 * wpfImage.Source.Width / wpfImage.Source.Height);

                dp.Children.Add(wpfImage);

                label = new Label();
                label.Content = labeltext;
                label.FontSize = 18;
                label.SetCurrentValue(DockPanel.DockProperty, Dock.Right);
                dp.Children.Add(label);
                this.PreviewTouchDown += new EventHandler<TouchEventArgs>(onTouch);
                this.PreviewMouseDown += new MouseButtonEventHandler(onTouch);
                lb.getAssociatedDocToolBar().Items.Add(this);
            }

            //equivalent for videos
            else if (_helpers.IsVideoFile(_scatteruri))
            {
                if (_helpers.IsDirShowFile(_scatteruri)) //can easily create nice thumbnails of the video using DirectShow
                {
                    image = new Image();

                    imageUri = System.IO.Path.GetFullPath(imageUri);
                    int decrement = System.IO.Path.GetExtension(imageUri).Length;
                    imageUri = imageUri.Remove(imageUri.Length - decrement, decrement);
                    imageUri += ".bmp";
                    FileStream stream = new FileStream(imageUri, FileMode.Open);

                    System.Drawing.Image dImage = System.Drawing.Image.FromStream(stream);
                    System.Windows.Controls.Image wpfImage = _helpers.ConvertDrawingImageToWPFImage(dImage);
                    stream.Close();

                    wpfImage.SetCurrentValue(DockPanel.DockProperty, Dock.Left);
                    wpfImage.SetCurrentValue(HeightProperty, 50.0);
                    wpfImage.SetCurrentValue(WidthProperty, 50 * wpfImage.Source.Width / wpfImage.Source.Height);

                    dp.Children.Add(wpfImage);

                    label = new Label();
                    label.Content = labeltext;
                    label.FontSize = 18;
                    label.SetCurrentValue(DockPanel.DockProperty, Dock.Right);
                    dp.Children.Add(label);
                    this.PreviewTouchDown += new EventHandler<TouchEventArgs>(onTouch);
                    this.PreviewMouseDown += new MouseButtonEventHandler(onTouch);
                    lb.getAssociatedDocToolBar().Items.Add(this);
                }
                //Code for not actually creating thumbnails of videos, but instead creating paused, unplayable media elements to act as thumbnails
                else
                {
                    MediaElement thumVid = new MediaElement();
                    thumVid.Source = new Uri(scatteruri, UriKind.RelativeOrAbsolute);

                    thumVid.LoadedBehavior = MediaState.Manual;
                    thumVid.ScrubbingEnabled = true;
                    thumVid.Play();
                    thumVid.Pause();

                    thumVid.Position = new TimeSpan(0, 0, 0, 0);
                    thumVid.SetCurrentValue(DockPanel.DockProperty, Dock.Left);
                    thumVid.SetCurrentValue(HeightProperty, 50.0);
                    thumVid.SetCurrentValue(WidthProperty, 50 * thumVid.Width / thumVid.Height);

                    dp.Children.Add(thumVid);

                    label = new Label();
                    label.Content = labeltext;
                    label.FontSize = 18;
                    label.SetCurrentValue(DockPanel.DockProperty, Dock.Right);
                    dp.Children.Add(label);
                    this.PreviewTouchDown += new EventHandler<TouchEventArgs>(onTouch);
                    this.PreviewMouseDown += new MouseButtonEventHandler(onTouch);
                    lb.getAssociatedDocToolBar().Items.Add(this);
                }
            }
        }
开发者ID:huylu,项目名称:brownuniversitylads,代码行数:99,代码来源:DockableItem.cs


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