當前位置: 首頁>>代碼示例>>C#>>正文


C# ResourceSet.MoveNext方法代碼示例

本文整理匯總了C#中System.Resources.ResourceSet.MoveNext方法的典型用法代碼示例。如果您正苦於以下問題:C# ResourceSet.MoveNext方法的具體用法?C# ResourceSet.MoveNext怎麽用?C# ResourceSet.MoveNext使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Resources.ResourceSet的用法示例。


在下文中一共展示了ResourceSet.MoveNext方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: ShowInfo

        private void ShowInfo( Assembly asm )
        {
            tvResources.Nodes.Clear();
            pbValue.Visible = false;
            tbValue.Visible = false;
            btnExport.Enabled = false;

            if( asm != null )
            {
                try
                {
                    lblStatus.Text = "Loaded: " + asm.FullName;

                    foreach( string resourceName in asm.GetManifestResourceNames() )
                    {
                        TreeNode root = new TreeNode( resourceName );
                        root.ImageIndex = 1;
                        root.SelectedImageIndex = 1;
                        tvResources.Nodes.Add( root );

                        using( Stream resourceStream = asm.GetManifestResourceStream( resourceName ) )
                        {
                            try
                            {
                                IDictionaryEnumerator enu = new ResourceSet( resourceStream ).GetEnumerator();

                                while( enu.MoveNext() )
                                {
                                    TreeNode node = new TreeNode( enu.Key.ToString() );
                                    root.Nodes.Add( node );
                                    node.ImageIndex = 0;
                                    node.SelectedImageIndex = 0;

                                    if( enu.Value is Icon || enu.Value is Bitmap )
                                    {
                                        node.Tag = enu.Value;
                                        node.ImageIndex = 2;
                                        node.SelectedImageIndex = 2;
                                    }
                                    else if( enu.Value is String )
                                    {
                                        node.Tag = enu.Value;
                                        node.ImageIndex = 3;
                                        node.SelectedImageIndex = 3;
                                    }
                                    else if( enu.Value is ImageListStreamer )
                                    {
                                        ImageList il = new ImageList();
                                        il.ImageStream = (ImageListStreamer)enu.Value;
                                        node.ImageIndex = 1;
                                        node.SelectedImageIndex = 1;

                                        for( int i = 0; i < il.Images.Count; i++ )
                                        {
                                            TreeNode imgNode = new TreeNode( i.ToString() );
                                            imgNode.Tag = il.Images[i];
                                            imgNode.ImageIndex = 2;
                                            imgNode.SelectedImageIndex = 2;

                                            node.Nodes.Add( imgNode );
                                        }
                                    }
                                }
                            }
                            catch
                            {
                                try
                                {
                                    //------------------------------------------------------
                                    //  Try treating stream as a single image.
                                    //------------------------------------------------------
                                    root.Tag = new Bitmap( resourceStream );
                                    root.ImageIndex = 2;
                                    root.SelectedImageIndex = 2;
                                }
                                catch
                                {
                                    try
                                    {
                                        //------------------------------------------------------
                                        //  Try treating stream as plain text.
                                        //------------------------------------------------------
                                        using( TextReader tr = new StreamReader( resourceStream ) )
                                        {
                                            root.Tag = tr.ReadToEnd();
                                            root.ImageIndex = 0;
                                            root.SelectedImageIndex = 0;
                                        }
                                    }
                                    catch
                                    {
                                        lblStatus.Text = "Error reading resource file.";
                                    }
                                }
                            }
                        }
                    }
                }
                catch( Exception ex )
                {
//.........這裏部分代碼省略.........
開發者ID:jcranendonk,項目名稱:ResourceBrowser,代碼行數:101,代碼來源:ResourceBrowser.cs


注:本文中的System.Resources.ResourceSet.MoveNext方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。