System.Windows.Application.GetResourceStream C# (CSharp) Method

GetResourceStream() public static method

public static GetResourceStream ( System.Windows.Resources.StreamResourceInfo zipPackageStreamResourceInfo, Uri uriResource ) : System.Windows.Resources.StreamResourceInfo
zipPackageStreamResourceInfo System.Windows.Resources.StreamResourceInfo
uriResource Uri
return System.Windows.Resources.StreamResourceInfo
		public static StreamResourceInfo GetResourceStream (StreamResourceInfo zipPackageStreamResourceInfo, Uri uriResource)
		{
			if (zipPackageStreamResourceInfo == null)
				throw new ArgumentNullException ("zipPackageStreamResourceInfo");
			if (uriResource == null)
				throw new ArgumentNullException ("resourceUri");
			
			MemoryStream ms = new MemoryStream ();
			ManagedStreamCallbacks source_cb;
			ManagedStreamCallbacks dest_cb;
			StreamWrapper source_wrapper;
			StreamWrapper dest_wrapper;
			Stream source;

			source = zipPackageStreamResourceInfo.Stream;

			source_wrapper = new StreamWrapper (source);
			dest_wrapper = new StreamWrapper (ms);

			source_cb = source_wrapper.GetCallbacks ();
			dest_cb = dest_wrapper.GetCallbacks ();

			if (NativeMethods.managed_unzip_stream_to_stream (ref source_cb, ref dest_cb, uriResource.ToString ())) {
				if (source.CanSeek)
					source.Seek (0, SeekOrigin.Begin);
				ms.Seek (0, SeekOrigin.Begin);
				return new StreamResourceInfo (ms, null);
			}

			return null;
		}

Same methods

Application::GetResourceStream ( Uri uriResource ) : System.Windows.Resources.StreamResourceInfo

Usage Example

示例#1
0
        private static void SetThumbnailTitleAndIcon(UIElement content, IControlView activeView)
        {
            if (!_initialized)
            {
                throw new Exception("Not initialized");
            }
            TabbedThumbnail thumbnail = TaskbarManager.Instance.TabbedThumbnail.GetThumbnailPreview(content);

            if (thumbnail != null && activeView != null)
            {
                if (thumbnail.Title != activeView.Header)  //Title is not set yet or sth has changed
                {
                    thumbnail.Title   = activeView.Header;
                    thumbnail.Tooltip = activeView.HeaderToolTip;
                    var streamResourceInfo = Application.GetResourceStream(activeView.HeaderIcon);
                    if (streamResourceInfo != null)
                    {
                        Stream iconStream = streamResourceInfo.Stream;
                        var    bitmap     = new Bitmap(iconStream);
                        var    iconHandle = bitmap.GetHicon();
                        var    icon       = Icon.FromHandle(iconHandle);
                        thumbnail.SetWindowIcon(icon);
                    }
                    RefreshPreview((Frame)content);
                }
            }
        }
All Usage Examples Of System.Windows.Application::GetResourceStream