2009-03-27 11 views

答えて

3

はい、可能ですが、それほど壊れやすく、あまり簡単ではありません。

SplashScreenクラスは、AssemblyName + ".g"リソースファイルを検索します。作成するには、プロジェクトに "g.resx"ファイルを含める必要があります。プロジェクトプロパティで設定されているルート名前空間は、アセンブリ名と同じでなければなりません。

このリソースファイルには、System.Drawing.Bitmapではなく、MemoryStreamとしてイメージが含まれている必要があります。おそらく、もっと簡単な方法がありますが、私は単にファイルを含め、その後、手動でこのように見えるようにエントリを変更:

<data name="splash.png" type="System.Resources.ResXFileRef, System.Windows.Forms"> 
    <value>Splash.png;System.IO.MemoryStream, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> 
</data> 

は、それからちょうどあなたのMainメソッドに次の行が含ま:

var splash = new SplashScreen("Splash.png"); 
splash.Show(true); 

希望をその助けてください。

1

ジャチェッコの答えは正しいが、少しは指定されていない。

まず、WindowsBaseへの参照を追加します。具体的なコードは

var splash = new System.Windows.SplashScreen("guru_logo.png"); 
splash.Show(true); 

プロジェクトレベルではなく、[プロパティ]フォルダ内にある必要があり、これはあなたのg.resxファイルを機能させるためにあります。あなたのresxがデフォルトでProperties(私のような)にあった場合は、それをプロジェクトレベルまでドラッグする必要があります。

これは私のg.resxの関連セクションは、スプラッシュ画面が値、データ名をいない呼び出していること

<data name="guru_logo.png" type="System.Resources.ResXFileRef, System.Windows.Forms"> 
    <value>Resources\guru_logo.png;System.IO.MemoryStream, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> 
    </data> 

お知らせのように見えたものです。また、値に表されているパスに注意してください。

何らかの理由でこれがうまくいかない場合(例外はリソースを見つけることができません)、g.Designer.csの背後にあるコードを見てください。名前空間はアセンブリ名でなければなりません。そうでない場合は、正しい位置に移動したり、プロジェクトのプロパティをjachymkoの状態に変更したりする必要があります。このファイルのコードを変更すると、自動的に生成されたb/cが失われます。

1

これは、メイクファイルでコンパイルされた単純なコマンドラインプログラムから行いました。要約すると:

  • をg.resxファイル
  • を追加したコンテンツを使用すると、スプラッシュ画面に使用するグラフィック画像を引用しなければなりません。これは、より多くの中/ resをオプション

を使用して、csc.exeのためのコマンドラインで.resourceファイルが含まれますがresgen.exe

  • を使用しての.resxファイルをコンパイルする必要があります任意の画像タイプ
  • することができ詳細...

    1. です。

    <?xml version="1.0" encoding="utf-8"?> 
    <root> 
        <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> 
        <xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> 
        <xsd:element name="root" msdata:IsDataSet="true"> 
         <xsd:complexType> 
         <xsd:choice maxOccurs="unbounded"> 
          <xsd:element name="data"> 
          <xsd:complexType> 
           <xsd:sequence> 
           <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> 
           <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> 
           </xsd:sequence> 
           <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" /> 
           <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> 
           <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> 
           <xsd:attribute ref="xml:space" /> 
          </xsd:complexType> 
          </xsd:element> 
          <xsd:element name="resheader"> 
          <xsd:complexType> 
           <xsd:sequence> 
           <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> 
           </xsd:sequence> 
           <xsd:attribute name="name" type="xsd:string" use="required" /> 
          </xsd:complexType> 
          </xsd:element> 
         </xsd:choice> 
         </xsd:complexType> 
        </xsd:element> 
        </xsd:schema> 
        <resheader name="resmimetype"> 
        <value>text/microsoft-resx</value> 
        </resheader> 
        <resheader name="version"> 
        <value>2.0</value> 
        </resheader> 
        <resheader name="reader"> 
        <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> 
        </resheader> 
        <resheader name="writer"> 
        <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> 
        </resheader> 
        <data name="hourglass.jpg" type="System.Resources.ResXFileRef, System.Windows.Forms"> 
        <value>hourglass.jpg;System.IO.MemoryStream, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> 
    </data> 
    </root> 
    
    1. のWindows SDKに含まれてresgen.exe、でコンパイル:RESXファイルには、次のようになります。たとえば、次のよう

    c:\winsdk\bin\resgen.exe g.resx g.resources 
    

    1. csc.exeコマンドライン上の結果の.resourcesを指定します。たとえば、次のよう

    csc.exe /t:exe /debug+ /win32icon:MyApp.ico /res:g.resources,MyApp.g.resources /R:... ... 
    
  • 関連する問題