2009-03-27 3 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에 대한 참조를 추가하십시오. 특정 코드가없는 속성 폴더, 프로젝트 레벨에 있어야합니다 귀하의 g.resx 파일을 작업이 위해서는

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

입니다. resx가 기본적으로 Properties (내 것 같은)에 있었던 경우 프로젝트 레벨까지 끌어다 놓아야합니다.

이 내 g.resx의 관련 섹션

SplashScreen로 데이터 이름이 아닌 값을 호출하는 것을
<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

나는 makefile로 컴파일 된 간단한 명령 줄 프로그램에서이 작업을 수행했습니다. 요약하면 :

  • 는 내용이 당신이 시작 화면에 사용할 그래픽 이미지를 인용해야 g.resx 파일
  • 를 추가합니다. 그것은 당신이 더에서/입술 옵션

를 사용하여, resgen.exe는

  • 가에는 Csc.exe에 대한 명령 줄에 .resource 파일을 포함 사용 된 .resx 파일을 컴파일해야하는 이미지 유형
  • 될 수 있습니다 세부 사항 ...

    1. 입니다.RESX 파일은 다음과 같다 :

    <?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. 컴파일을 윈도우 SDK에 포함되어 resgen.exe와 함께. 예를 들어 :

    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:... ... 
    
    : 예를 들어,
  • 관련 문제