<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
  xmlns:netfx="http://schemas.microsoft.com/wix/NetFxExtension">

  <!-- バージョンアップ時にはProductVersionとProductタグのId属性を更新すること -->
  <?define UpgradeCode = "64175075-B742-45ED-8D02-7BCFA1C385B4"?>
  <?define ProductVersion = "1.49.12.0"?>

  <Product Name="FooEditor"
           Id="4BADFEDF-2FAF-EFAB-9F52-FBBCB0C7FFB8"
           UpgradeCode="$(var.UpgradeCode)"
           Language="1041" Codepage="932"
           Version="$(var.ProductVersion)" Manufacturer="FooProject">

    <Package Id="*" Keywords="Installer"
             Description="FooEditorインストーラー"
             Comments="さまざまな言語に対応したテキストエディタです"
             Manufacturer="FooProject" InstallerVersion="300"
             Languages="1041" Compressed="yes" SummaryCodepage="932" />
    <Media Id="1" Cabinet="Product.cab" EmbedCab="yes" />

    <PropertyRef Id="NETFRAMEWORK40FULL"/>
    <Condition Message="このアプリケーションを実行するには.NET Framework4.0が必要です">
      <![CDATA[Installed OR NETFRAMEWORK40FULL]]>
    </Condition>

    <Directory Id="TARGETDIR" Name="SourceDir">
      <Directory Id="ProgramFilesFolder">
        <Directory Id="FooProject" Name="FooProject">
          <Directory Id="INSTALLDIR" Name="FooEditor">

              <Component Id="RegistryEntries" Guid="B8DAD322-9432-4767-A6AC-C551AE5D8677" KeyPath="yes">
                 <RegistryKey Root="HKLM"
                     Key="Software\Classes\FooEditor.Assoc\shell\open\command">
                  <RegistryValue Type="expandable" Value="&quot;[INSTALLDIR]FooEditor.Exe&quot; -open &quot;%1&quot;"/>
                </RegistryKey>
                <RegistryKey Root="HKLM"
                     Key="Software\FooEditor">
                   <RegistryValue Type="string" Name="LocalizedString" Value="FooEditor"/>
                </RegistryKey>
                <RegistryKey Root="HKLM"
                     Key="Software\FooEditor\Capabilities">
                   <RegistryValue Type="string" Name="ApplicationDescription" Value="さまざまな言語に対応したテキストエディタです"/>
                   <RegistryValue Type="string" Name="ApplicationName" Value="FooEditor"/>
                </RegistryKey>
                <RegistryKey Root="HKLM"
                     Key="Software\FooEditor\Capabilities\FileAssociations">
                   <RegistryValue Type="string" Name=".txt" Value="FooEditor.Assoc"/>
                   <RegistryValue Type="string" Name=".log" Value="FooEditor.Assoc"/>
                </RegistryKey>
                <RegistryKey Root="HKLM"
                     Key="Software\RegisteredApplications">
                   <RegistryValue Type="string" Name="FooEditor" Value="Software\FooEditor\Capabilities"/>
                </RegistryKey>
             </Component>

            <Component Id="Main"
                       Guid="98DAD322-9432-4767-A6AC-C551AE5D8677" KeyPath="yes">
              <File Id="File1" Name="AdminOperation.exe"
                DiskId="1" Source="dist\AdminOperation.exe"/>
              <File Id="File2" Name="DotNetTextStore.dll"
                DiskId="1" Source="dist\DotNetTextStore.dll"/>
              <File Id="File3" Name="EncodeDetect.dll"
                DiskId="1" Source="dist\EncodeDetect.dll"/>
              <File Id="File4" Name="FooEditEngine.WPF.dll"
                DiskId="1" Source="dist\FooEditEngine.WPF.dll"/>
              <File Id="File5" Name="FooEditor.chm"
                DiskId="1" Source="dist\FooEditor.chm"/>
              <File Id="File6" Name="FooEditor.exe"
                DiskId="1" Source="dist\FooEditor.exe"/>
              <File Id="File7" Name="FooGrep.exe"
                DiskId="1" Source="dist\FooGrep.exe"/>
              <File Id="File9" Name="Microsoft.WindowsAPICodePack.dll"
                DiskId="1" Source="dist\Microsoft.WindowsAPICodePack.dll"/>
              <File Id="File10" Name="Microsoft.WindowsAPICodePack.Shell.dll"
                DiskId="1" Source="dist\Microsoft.WindowsAPICodePack.Shell.dll"/>
              <File Id="File11" Name="Snipptes.xsd"
                DiskId="1" Source="dist\Snipptes.xsd"/>
              <File Id="File12" Name="SyntaxDefinition.xsd"
                DiskId="1" Source="dist\SyntaxDefinition.xsd"/>
              <File Id="File14" Name="FooEditor.exe.config"
                DiskId="1" Source="dist\FooEditor.exe.config"/>
              <File Id="File15" Name="Xceed.Wpf.AvalonDock.dll"
                DiskId="1" Source="dist\Xceed.Wpf.AvalonDock.dll"/>
              <File Id="File16" Name="Xceed.Wpf.Toolkit.dll"
                DiskId="1" Source="dist\Xceed.Wpf.Toolkit.dll"/>
              <File Id="File21" Name="SharpDX.Direct2D1.dll"
                DiskId="1" Source="dist\SharpDX.Direct2D1.dll"/>
              <File Id="File22" Name="SharpDX.Direct3D9.dll"
                DiskId="1" Source="dist\SharpDX.Direct3D9.dll"/>
              <File Id="File23" Name="SharpDX.Direct3D10.dll"
                DiskId="1" Source="dist\SharpDX.Direct3D10.dll"/>
              <File Id="File24" Name="SharpDX.dll"
                DiskId="1" Source="dist\SharpDX.dll"/>
              <File Id="File25" Name="SharpDX.DXGI.dll"
                DiskId="1" Source="dist\SharpDX.DXGI.dll"/>
            </Component>

           <Directory Id="Directory1" Name="Keywords">
             <Component Id="EmbbedKeywords"
                       Guid="A8DAD322-9432-4767-A6AC-C551AE5D8677" KeyPath="yes">
               <File Id="File26" Name="clang.xml"
                 DiskId="1" Source="dist\Keywords\clang.xml"/>
               <File Id="File27" Name="css.xml"
                 DiskId="1" Source="dist\Keywords\css.xml"/>
               <File Id="File28" Name="html.xml"
                 DiskId="1" Source="dist\Keywords\html.xml"/>
               <File Id="File29" Name="javascript.xml"
                 DiskId="1" Source="dist\Keywords\javascript.xml"/>
               <File Id="File30" Name="perl.xml"
                 DiskId="1" Source="dist\Keywords\perl.xml"/>
               <File Id="File31" Name="php.xml"
                 DiskId="1" Source="dist\Keywords\php.xml"/>
               <File Id="File32" Name="python.xml"
                 DiskId="1" Source="dist\Keywords\python.xml"/>
               <File Id="File33" Name="ruby.xml"
                 DiskId="1" Source="dist\Keywords\ruby.xml"/>
               <File Id="File34" Name="vb.xml"
                 DiskId="1" Source="dist\Keywords\vb.xml"/>
               <File Id="File35" Name="xml.xml"
                 DiskId="1" Source="dist\Keywords\xml.xml"/>
             </Component>
           </Directory>

           <Directory Id="Directory2" Name="Sinppets">
             <Component Id="EmbbedSinppets"
                       Guid="E8DAD322-9432-4767-A6AC-C551AE5D8677" KeyPath="yes">
               <File Id="File36" Name="Html.xml"
                 DiskId="1" Source="dist\Sinppets\Html.xml" />
             </Component>
          </Directory>

           <Directory Id="Directory3" Name="Plugin">
             <Component Id="StringFilter"
                       Guid="CADAD322-9432-4767-A6AC-C551AE5D8677" KeyPath="yes">
               <File Id="File37" Name="StringFilter.dll"
                 DiskId="1" Source="dist\Plugin\StringFilter.dll" />
             </Component>
             <Component Id="SinnpetPlugin"
                       Guid="6DC17AC5-BB88-4118-86ED-83455A797394" KeyPath="yes">
               <File Id="File38" Name="Snippet.dll"
                 DiskId="1" Source="dist\Plugin\Snippet.dll" />
             </Component>
             <Component Id="Outline"
                       Guid="6891A745-E7BC-4B74-9588-DD0FBBC5B778" KeyPath="yes">
               <File Id="File39" Name="Outline.dll"
                 DiskId="1" Source="dist\Plugin\Outline.dll" />
             </Component>
             <Component Id="AutoComplete"
                       Guid="EFDAD322-9432-4767-A6AC-C551AE5D8677" KeyPath="yes">
               <File Id="File40" Name="AutoComplete.dll"
                 DiskId="1" Source="dist\Plugin\AutoComplete.dll" />
             </Component>
             <Component Id="XmlCompleter"
                       Guid="68720885-814F-4CC2-BE3D-265AC013DDAD" KeyPath="yes">
               <File Id="File41" Name="XmlCompleter.dll"
                 DiskId="1" Source="dist\Plugin\XmlCompleter.dll" />
             </Component>
          </Directory>
 
         </Directory>
        </Directory>
      </Directory>

      <Directory Id="ProgramMenuFolder" Name="Programs">
        <Directory Id="ProgramMenuDir" Name="FooEditor">
          <Component Id="ProgramMenuDir"
                     Guid="BEF779B2-EC49-42B7-B3B4-9217D1DB0ACA">
            <RemoveFolder Id="ProgramMenuDir" On="uninstall" />
            <RegistryValue Root="HKCU"
                           Key="Software\[Manufacturer]\[ProductName]"
                           Type="string" Value='' KeyPath="yes" />
            <Shortcut Id="startmenuFooEditor" Directory="ProgramMenuDir"
                      Name="FooEditor" WorkingDirectory="INSTALLDIR" Target="[INSTALLDIR]FooEditor.exe"
                      Icon="FooEditor.exe" IconIndex="0" Advertise="no"/>
            <Shortcut Id="startmenuFooGrep" Directory="ProgramMenuDir"
                      Name="FooGrep" WorkingDirectory="INSTALLDIR" Target="[INSTALLDIR]FooGrep.exe"
                      Icon="FooGrep.exe" IconIndex="0" Advertise="no"/>
          </Component>
        </Directory>
      </Directory>

    </Directory>

    <Feature Id="Complete" Title="FooEditor" Description="テキストファイルを編集するためのプログラム"
      Display="expand" Level="1" ConfigurableDirectory="INSTALLDIR" AllowAdvertise="no">
      <ComponentRef Id="Main" />
      <ComponentRef Id="EmbbedKeywords" />
      <ComponentRef Id="EmbbedSinppets" />
      <ComponentRef Id="ProgramMenuDir" />
      <ComponentRef Id="RegistryEntries" />
      <Feature Id="StringFilter" Title="StringFilter"
         Description="文字列を加工するためのプラグイン" Level="1000" AllowAdvertise="no">
        <ComponentRef Id="StringFilter" />
      </Feature>
      <Feature Id="SinnpetPlugin" Title="SinnpetPlugin"
         Description="定型文を挿入するためのプラグイン" Level="1000" AllowAdvertise="no">
        <ComponentRef Id="SinnpetPlugin" />
      </Feature>
      <Feature Id="Outline" Title="Outline"
         Description="見出しを表示するためのプラグイン" Level="1000" AllowAdvertise="no">
        <ComponentRef Id="Outline" />
      </Feature>
      <Feature Id="AutoComplete" Title="AutoComplete"
         Description="オートコンプリートを行うためのプラグイン" Level="1000" AllowAdvertise="no">
        <ComponentRef Id="AutoComplete" />
      </Feature>
      <Feature Id="XmlCompleter" Title="XmlCompleter"
         Description="XML/HTMLドキュメント対応のインテリセンスを行うためのプラグイン" Level="1000" AllowAdvertise="no">
        <ComponentRef Id="XmlCompleter" />
      </Feature>
    </Feature>

    <UIRef Id="WixUI_Mondo" />
    <UIRef Id="WixUI_ErrorProgressText" />

    <Icon Id="FooEditor.exe" SourceFile="dist\FooEditor.exe" />
    <Icon Id="FooGrep.exe" SourceFile="dist\FooGrep.exe" />

    <WixVariable Id="WixUILicenseRtf" Value="License.rtf" />

    <Property Id="ARPHELPLINK">http://sourceforge.jp/projects/fooeditor/forums/</Property>
    <Property Id="ARPURLINFOABOUT">http://sourceforge.jp/projects/fooeditor/</Property>

    <InstallExecuteSequence>
        <RemoveExistingProducts After="InstallInitialize"/>
    </InstallExecuteSequence>

    <Condition Message="[ProductName]の最新バージョンは既にインストールされています">
      NOT NEWERVERSIONDETECTED OR Installed
    </Condition>

    <Upgrade Id="$(var.UpgradeCode)">
        <UpgradeVersion Minimum="1.0.0"
                        IncludeMinimum="yes"
                        Maximum="$(var.ProductVersion)"
                        Property="OLDERVERSIONBEINGUPGRADED" />
        <UpgradeVersion Minimum="$(var.ProductVersion)"
                        OnlyDetect="yes"
                        Property="NEWERVERSIONDETECTED" />
    </Upgrade>
  </Product>
</Wix>
