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


C# BitmapImage.EndInit方法代码示例

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


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

示例1: Create

        public Model3DGroup Create(Color modelColor,string pictureName, Point3D startPos, double maxHigh)
        {
            try
            {
                Uri inpuri = new Uri(@pictureName, UriKind.Relative);
                BitmapImage bi = new BitmapImage();
                bi.BeginInit();
                bi.UriSource = inpuri;
                bi.EndInit();
                ImageBrush imagebrush = new ImageBrush(bi);
                imagebrush.Opacity = 100;
                imagebrush.Freeze();

                Point[] ptexture0 = { new Point(0, 0), new Point(0, 1), new Point(1, 0) };
                Point[] ptexture1 = { new Point(1, 0), new Point(0, 1), new Point(1, 1) };

                SolidColorBrush modelbrush = new SolidColorBrush(modelColor);
                Model3DGroup cube = new Model3DGroup();
                Point3D uppercircle = startPos;
                modelbrush.Freeze();
                uppercircle.Y = startPos.Y + maxHigh;
                cube.Children.Add(CreateEllipse2D(modelbrush, uppercircle, _EllipseHigh, new Vector3D(0, 1, 0)));
                cube.Children.Add(CreateEllipse2D(modelbrush, startPos, _EllipseHigh, new Vector3D(0, -1, 0)));
                cube.Children.Add(CreateEllipse3D(imagebrush, startPos, _EllipseHigh, maxHigh, ptexture0));
                return cube;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
开发者ID:kse-jp,项目名称:RM-3000,代码行数:31,代码来源:EllipseModel.cs

示例2: DeviceView

        //-------------------------------------------------------------------------------------
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="device">ref NodeController</param>
        /// <param name="deviceType">type of device</param>
        public DeviceView(DeviceController device, DeviceType deviceType)
        {
            InitializeComponent();
            this.deviceController = device;

            BitmapImage bi3 = new BitmapImage();

            if (deviceType == DeviceType.dPc)
            {
                bi3.BeginInit();
                bi3.UriSource = new Uri("/GEditor;component/Resources/screen_zoom_in_ch.png", UriKind.Relative);
                bi3.EndInit();
            }
            else
            {
                if (deviceType == DeviceType.dSwitch)
                {
                    bi3.BeginInit();
                    bi3.UriSource = new Uri("/GEditor;component/Resources/switch_ch.png", UriKind.Relative);
                    bi3.EndInit();
                }
                else
                {
                    bi3.BeginInit();
                    bi3.UriSource = new Uri("/GEditor;component/Resources/password_ch.png", UriKind.Relative);
                    bi3.EndInit();
                }
            }
            this.point.Source = bi3;
            Canvas.SetZIndex(this, 2);
            this.point.Width = this.point.Height = radiusView;
        }
开发者ID:boddichegTest,项目名称:testRepo,代码行数:38,代码来源:DeviceView.xaml.cs

示例3: Play

        private void Play(object sender, RoutedEventArgs e)
        {
            BitmapImage logo = new BitmapImage();

            logo.BeginInit();
            if (MediaPlayer.Source != null)
            {
                if (!isPause)
                {
                    logo.UriSource = new Uri(@"Images\Play.png", UriKind.Relative);
                    logo.EndInit();
                    PlayButton.Source = logo;
                    MediaPlayer.Pause();
                    _timer.Stop();
                    isPause = true;
                }
                else
                {
                    logo.UriSource = new Uri(@"Images\Pause.png", UriKind.Relative);
                    logo.EndInit();
                    PlayButton.Source = logo;
                    MediaPlayer.Visibility = System.Windows.Visibility.Visible;
                    MediaPlayer.Play();
                    _timer.Start();
                    isPlaying = true;
                    isPause = false;
                }
            }
            else if (_LastVideoSource != null)
            {
                MediaPlayer.Source = _LastVideoSource;
                Play(sender, e);
            }
        }
开发者ID:Haseo,项目名称:project-WMP,代码行数:34,代码来源:MainWindowButton.cs

示例4: GetHeadIcon

 public BitmapImage GetHeadIcon(string dir)
 {
     BitmapImage headBit = new BitmapImage();
     if (File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/" + dir + "/" + "logindata"))
     {
         headBit.BeginInit();
         string line1;
         string line2;
         string line3;
         using (StreamReader reader = new StreamReader(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/" + dir + "/" + "logindata"))
         {
             line1 = reader.ReadLine();
             line2 = reader.ReadLine();
             line3 = reader.ReadLine();
         }
         headBit.UriSource = new Uri("https://minotar.net/avatar/" + line3);
         headBit.EndInit();
         return headBit;
     }
     else
     {
         headBit.BeginInit();
         headBit.UriSource = new Uri("https://minotar.net/avatar/char");
         headBit.EndInit();
         return headBit;
     }
 }
开发者ID:wisesascha,项目名称:XYLauncher,代码行数:27,代码来源:LoginManager.cs

示例5: Convert

        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            var imageParameter = value as string;
            if (imageParameter == null)
                imageParameter = parameter as string;

            if (!string.IsNullOrEmpty(imageParameter as string))
            {
                System.Drawing.Bitmap bitmap = null;
                var bitmapImage = new BitmapImage();

                // Application Resource - File Build Action is marked as None, but stored in Resources.resx
                // parameter= myresourceimagename
                try
                {
                    bitmap = Properties.Resources.ResourceManager.GetObject(imageParameter) as System.Drawing.Bitmap;
                }
                catch { }

                if (bitmap != null)
                {
                    using (var ms = new MemoryStream())
                    {
                        bitmap.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
                        bitmapImage.BeginInit();
                        bitmapImage.StreamSource = ms;
                        bitmapImage.CacheOption = BitmapCacheOption.OnLoad;
                        bitmapImage.EndInit();
                    }
                    return bitmapImage;
                }

                // Embedded Resource - File Build Action is marked as Embedded Resource
                // parameter= MyWpfApplication.EmbeddedResource.myotherimage.png
                var asm = Assembly.GetExecutingAssembly();
                var stream = asm.GetManifestResourceStream(imageParameter);
                if (stream != null)
                {
                    bitmapImage.BeginInit();
                    bitmapImage.StreamSource = stream;
                    bitmapImage.EndInit();
                    return bitmapImage;
                }

                // This is the standard way of using Image.SourceDependancyProperty.  You shouldn't need to use a converter to to this.
                //// Resource - File Build Action is marked as Resource
                //// parameter= pack://application:,,,/MyWpfApplication;component/Images/myfunkyimage.png
                //Uri imageUriSource = null;
                //if (Uri.TryCreate(imageParameter, UriKind.RelativeOrAbsolute, out imageUriSource))
                //{
                //    bitmapImage.BeginInit();
                //    bitmapImage.UriSource = imageUriSource;
                //    bitmapImage.EndInit();
                //    return bitmapImage;
                //}
            }
            return null;
        }
开发者ID:midspace,项目名称:SEToolbox,代码行数:58,代码来源:ResouceToImageConverter.cs

示例6: ButtonEnter

        private void ButtonEnter(object sender, EventArgs e)
        {
            BitmapImage logo = new BitmapImage();

            logo.BeginInit();
            if (sender == PlayButton)
            {
                if (isPause)
                    logo.UriSource = new Uri(@"Images\PlayOver.png", UriKind.Relative);
                else
                    logo.UriSource = new Uri(@"Images\PauseOver.png", UriKind.Relative);
                logo.EndInit();
                PlayButton.Source = logo;
            }
            if (sender == StopButton)
            {
                logo.UriSource = new Uri(@"Images\StopOver.png", UriKind.Relative);
                logo.EndInit();
                StopButton.Source = logo;
            }
            if (sender == VolumeButton)
            {
                if (MediaPlayer.Volume == 0)
                    logo.UriSource = new Uri(@"Images\SoundOffOver.png", UriKind.Relative);
                else
                    logo.UriSource = new Uri(@"Images\SoundOnOver.png", UriKind.Relative);
                logo.EndInit();
                VolumeButton.Source = logo;
            }
            if (sender == FullScreenButton)
            {
                if (this.WindowState == WindowState.Maximized)
                    logo.UriSource = new Uri(@"Images\LowScreenOver.png", UriKind.Relative);
                else
                    logo.UriSource = new Uri(@"Images\FullScreenOver.png", UriKind.Relative);
                logo.EndInit();
                FullScreenButton.Source = logo;
            }
            if (sender == ShowPannelButton)
            {
                if (!isPannelShow)
                    logo.UriSource = new Uri(@"Images\ShowPannelOver.png", UriKind.Relative);
                else
                    logo.UriSource = new Uri(@"Images\HidePannelOver.png", UriKind.Relative);
                logo.EndInit();
                ShowPannelButton.Source = logo;
            }
        }
开发者ID:Haseo,项目名称:project-WMP,代码行数:48,代码来源:MainWindowButtonSource.cs

示例7: DownloadPicture

      public async Task<ImageSource> DownloadPicture(string imageUri)
      {
         var request = (HttpWebRequest)WebRequest.Create(imageUri);
         if (string.IsNullOrEmpty(Configuration.SessionCookies) == false)
         {
            request.CookieContainer = new CookieContainer();
            request.CookieContainer.SetCookies(request.RequestUri, Configuration.SessionCookies);
         }

         var response = (HttpWebResponse)(await request.GetResponseAsync());

         using (Stream inputStream = response.GetResponseStream())
         using (Stream outputStream = new MemoryStream())
         {
            var buffer = new byte[4096];
            int bytesRead;
            do
            {
               bytesRead = await inputStream.ReadAsync(buffer, 0, buffer.Length);
               outputStream.Write(buffer, 0, bytesRead);
            } while (bytesRead != 0);

            var bitmapImage = new BitmapImage();
            bitmapImage.BeginInit();
            bitmapImage.CacheOption = BitmapCacheOption.OnLoad;
            bitmapImage.StreamSource = outputStream;
            bitmapImage.EndInit();
            bitmapImage.Freeze();

            return bitmapImage;
         }
      }
开发者ID:sceeter89,项目名称:jira-client,代码行数:32,代码来源:ResourceDownloader.cs

示例8: ShowImage

        //TODO filter by mimetype
        public void ShowImage(MemoryStream stream)
        {
            try
            {
                stream.Position = 0;
                var bitmapImage = new BitmapImage();
                bitmapImage.BeginInit();
                bitmapImage.StreamSource = stream;
                bitmapImage.EndInit();

                image1.Width = bitmapImage.Width;
                image1.Height = bitmapImage.Height;

                var screenInfo = GetScreenInfo();

                image1.Height = screenInfo.Height - 150;
                image1.Width = (image1.Height * bitmapImage.Width) / bitmapImage.Height;

                Height = image1.Height + 3;
                Width = image1.Width + 3;

                image1.Source = bitmapImage;
            }
            catch (NotSupportedException)
            { }
        }
开发者ID:siderevs,项目名称:ZippedImageViewer,代码行数:27,代码来源:ImageCanvas.xaml.cs

示例9: ExtTreeNode

        public ExtTreeNode(Image icon, string title)
            : this()
        {
            if (icon != null)
            {
                this.icon = icon;
            }
            else//test inti icon
            {
                this.icon = new Image();
                BitmapImage bitmapImage = new BitmapImage();
                bitmapImage.BeginInit();
                bitmapImage.UriSource = new Uri(@"pack://application:,,,/ATNET;component/icons/add.png", UriKind.RelativeOrAbsolute);
                //bitmapImage.UriSource = new Uri(@"../../icons/add.png", UriKind.RelativeOrAbsolute);
                bitmapImage.EndInit();
                this.icon.Source = bitmapImage;
            }

            this.icon.Width = 16;
            this.icon.Height = 16;

            this.title = title;

            TextBlock tb = new TextBlock();
            tb.Text = title;
            Grid grid = new Grid();
            grid.ColumnDefinitions.Add(new ColumnDefinition());
            grid.ColumnDefinitions.Add(new ColumnDefinition());
            grid.Children.Add(this.icon);
            grid.Children.Add(tb);
            Grid.SetColumn(this.icon, 0);
            Grid.SetColumn(tb, 1);
            this.Header = grid;
        }
开发者ID:ichengzi,项目名称:atnets,代码行数:34,代码来源:ExtTreeNode.cs

示例10: MainWindow

        public MainWindow()
        {
            InitializeComponent();

                // initialize tabItem array
                _tabItems = new List<TabItem>();

                // add a tabItem with + in header
                _tabAdd = new TabItem();
                //get image for header and setup add button
                _tabAdd.Style = new Style();
                _tabAdd.Background = new SolidColorBrush(Color.FromArgb(0xFF, 0x30, 0x30, 0x30));
                _tabAdd.BorderBrush = new SolidColorBrush(Color.FromArgb(0xFF, 0x30, 0x30, 0x30));
                BitmapImage bitmap = new BitmapImage();
                bitmap.BeginInit();
                bitmap.UriSource = new Uri(@"pack://application:,,,/Explore10;component/Images/appbar.add.png");
                bitmap.EndInit();
                Image plus = new Image();
                plus.Source = bitmap;
                plus.Width = 25;
                plus.Height = 25;
                _tabAdd.Width = 35;
                _tabAdd.Header = plus;
                _tabAdd.MouseLeftButtonUp += new MouseButtonEventHandler(tabAdd_MouseLeftButtonUp);
                _tabItems.Add(_tabAdd);

                // add first tab
                //this.AddTabItem();

                // bind tab control
                tabDynamic.DataContext = _tabItems;

                tabDynamic.SelectedIndex = 0;
        }
开发者ID:PFCKrutonium,项目名称:Explore10,代码行数:34,代码来源:MainWindow.xaml.cs

示例11: GetCharacterPortrait

        public static BitmapImage GetCharacterPortrait(Player player)
        {
            if (player == null || player.CharacterID == 0)
                return null;

            int Size = 64;
            string filePath = string.Format("{0}\\{1}.jpg", Utils.PortraitDir, player.CharacterID);

            BitmapImage image = null;
            try
            {
                if (!File.Exists(filePath))
                {

                    WebClient wc = new WebClient();
                    wc.DownloadFile(
                        string.Format("http://img.eve.is/serv.asp?s={0}&c={1}", Size, player.CharacterID),
                        filePath);
                }

                image = new BitmapImage();
                image.BeginInit();
                image.UriSource = new Uri(filePath,
                                          UriKind.Absolute);
                image.EndInit();

            }
            catch (Exception)
            {
            }

            return image;
        }
开发者ID:FredrikL,项目名称:EVEIntel,代码行数:33,代码来源:Character.cs

示例12: FileListItem

        public FileListItem(string captionText, string imagePath)
            : base()
        {
            Margin = new Thickness(13);

            var panel = new StackPanel();
            var imageSource = new BitmapImage();
            var image = new Image();
            var caption = new TextBlock();

            imageSource.BeginInit();
            imageSource.UriSource = new Uri(imagePath, UriKind.Relative);
            imageSource.EndInit();

            image.VerticalAlignment = System.Windows.VerticalAlignment.Center;
            image.Source = imageSource;
            image.Height = 64;
            image.Width = 64;
            image.ToolTip = "Select & click on 'Table' for data view.";

            caption.TextAlignment = TextAlignment.Center;
            caption.TextWrapping = TextWrapping.Wrap;
            caption.Text = captionText;

            Caption = captionText;

            if (caption.Text.Length <= 18)
                caption.Text += "\n ";

            panel.Children.Add(image);
            panel.Children.Add(caption);

            Child = panel;
        }
开发者ID:aceindy,项目名称:ArctiumTools,代码行数:34,代码来源:FileListItem.cs

示例13: MainWindow

        public MainWindow()
        {
            InitializeComponent();
            Window w = new DBItems();
            VkRepository.ImageReady += () =>
            {
                UserAvatar.Children.Clear();

                Image i = new Image();
                BitmapImage src = new BitmapImage();
                src.BeginInit();
                src.UriSource = new Uri(string.Format("{0}avatar.jpg", VkRepository.counter.ToString()), UriKind.Relative);
                src.CacheOption = BitmapCacheOption.OnLoad;
                src.EndInit();
                i.Source = src;
                i.Stretch = Stretch.Uniform;
                UserAvatar.Children.Add(i);
            };
            AuthWindow.OnLoggedIn += (c) =>
                {
                    AuthInfo.Text = VkRepository.GetUserInfo(c).ToString();
                };
            VkRepository.UserDbLoaded += (users) =>
            {
                w.Show();
            };
        }
开发者ID:menovikov,项目名称:VKAnalyzer,代码行数:27,代码来源:MainWindow.xaml.cs

示例14: ComposerToThumbnail

        public static BitmapImage ComposerToThumbnail(Composer composer)
        {
            var thumbnail = (BitmapImage)null;

            if (_thumbnailCache.TryGetValue(composer.ComposerId, out thumbnail))
            {
                return _thumbnailCache[composer.ComposerId];
            }

            var directoryPath = [email protected]"{Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData, Environment.SpecialFolderOption.Create)}\Music Timeline\Resources\Thumbnails\";

            if (!Directory.Exists(directoryPath))
            {
                Directory.CreateDirectory(directoryPath);
            }

            var thumbnailPath = [email protected]"{Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData, Environment.SpecialFolderOption.Create)}\Music Timeline\Resources\Thumbnails\{composer.ComposerId}.jpg";
            var thumbnailUri = new Uri(thumbnailPath, UriKind.Absolute);

            if (File.Exists(thumbnailPath))
            {
                thumbnail = new BitmapImage();
                thumbnail.BeginInit();
                thumbnail.DecodePixelHeight = 50;
                thumbnail.StreamSource = new MemoryStream(File.ReadAllBytes(thumbnailPath));
                thumbnail.EndInit();
                thumbnail.Freeze();

                _thumbnailCache[composer.ComposerId] = thumbnail;

                return thumbnail;
            }

            return CreateThumbnail(composer);
        }
开发者ID:nharren,项目名称:MusicTimeline,代码行数:35,代码来源:ComposerToThumbnailConverter.cs

示例15: CreateImageSource2

		static ImageSource CreateImageSource2(byte[] data) {
			var bimg = new BitmapImage();
			bimg.BeginInit();
			bimg.StreamSource = new MemoryStream(data);
			bimg.EndInit();
			return bimg;
		}
开发者ID:manojdjoshi,项目名称:dnSpy,代码行数:7,代码来源:ImageResourceUtilities.cs


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