<?include Config.wxi?>

<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
  <Product Id="*" Name="$(var.ProductName)" Language="1031" Codepage="1252" Version="$(var.ProductVersion)" Manufacturer="$(var.Manufacturer)" UpgradeCode="$(var.UpgradeCode)">
    <Package
      Id="*"
      Keywords="Installer"
      Description="$(var.Description)"
      Comments="$(var.Comments)"
      Manufacturer="$(var.Manufacturer)"
      InstallerVersion="100"
      Languages="1031"
      Compressed="yes"
      SummaryCodepage="1252"
      InstallScope="perMachine"
    />

    <Property Id="APPLICATIONFOLDER">
      <RegistrySearch Key="Software\[Manufacturer]\[ProductName]" Root="HKCU" Type="raw" Id="APPLICATIONFOLDER_REGSEARCH" Name="Path" />
    </Property>
    
    <Media Id='1' Cabinet='$(var.ProgramName).cab' EmbedCab='yes' DiskPrompt='$(var.ProgramName)'  />
    <Property Id='DiskPrompt' Value="$(var.ProgramName) Install" />

    <MajorUpgrade
      AllowDowngrades="no"
      AllowSameVersionUpgrades="no"
      DowngradeErrorMessage="Eine neuere Version von [ProductName] ist bereits installiert. Das Setup wird beendet."
    />

    <Property Id="PREVIOUSVERSIONSINSTALLED" Secure="yes" />
    <Upgrade Id="$(var.UpgradeCode)">
      <UpgradeVersion
        Minimum="1.0.0.0" Maximum="99.0.0.0"
        Property="PREVIOUSVERSIONSINSTALLED"
        IncludeMinimum="yes" IncludeMaximum="no" />
    </Upgrade>

    <!-- Legt das Icon fest -->
    <Icon Id="AppIcon.exe" SourceFile="$(var.ProgramName).exe" />
    <!-- Zeige Icon in Systemsteuerung > Programme entfernen -->
    <Property Id="ARPPRODUCTICON" Value="AppIcon" />

    <Directory Id="TARGETDIR" Name="SourceDir">
      <Directory Id="ProgramFilesFolder">
        <Directory Id="DD" Name="$(var.Manufacturer)">
          <Directory Id="INSTALLDIR" Name="$(var.ProductName)"/>
        </Directory>
      </Directory>

      <Directory Id="ProgramMenuFolder">
        <Directory Id="ApplicationProgramsFolder" Name="$(var.ProductName)"/>
      </Directory>

      <Directory Id="DesktopFolder" />
    </Directory>

    <DirectoryRef Id="ApplicationProgramsFolder">
      <Component Id="ApplicationShortcut_StartMenu" Guid="459eecd2-6db7-4b30-97f5-63719879e4a9">
        <Shortcut Id="ApplicationStartMenuShortcut_StartMenu"
             Name="$(var.ProductName)"
             Target="[INSTALLDIR]$(var.ProgramName).exe"
             WorkingDirectory="INSTALLDIR"/>
        <RemoveFolder Id="ApplicationProgramsFolder_StartMenu" On="uninstall"/>
        <RegistryValue Root="HKCU" Key="Software\[Manufacturer]\[ProductName]" Name="installed" Type="integer" Value="1" KeyPath="yes"/>
      </Component>
    </DirectoryRef>

    <DirectoryRef Id="DesktopFolder">
      <Component Id="ApplicationShortcut_Desktop" Guid="1717d19a-4510-423f-93b1-671f280dcca3">
        <Shortcut Id="ApplicationStartMenuShortcut_Desktop"
             Name="$(var.ProductName)"
             Target="[INSTALLDIR]$(var.ProgramName).exe"
             WorkingDirectory="INSTALLDIR"/>
        <RemoveFolder Id="ApplicationProgramsFolder_Desktop" On="uninstall"/>
        <RegistryValue Root="HKCU" Key="Software\[Manufacturer]\[ProductName]" Name="installed" Type="integer" Value="1" KeyPath="yes"/>
      </Component>
    </DirectoryRef>

    <DirectoryRef Id="INSTALLDIR">
      <Component Id="MainApplicationExe" Guid="{BA4DC59A-6FCD-4672-9D58-456F255E5AAB}">
        <File Id="MainApplicationExe" Source="..\DD_Clipboard_Searcher\bin\$(var.Configuration)\$(var.ProgramName).exe" Name="$(var.ProgramName).exe" KeyPath="no" Checksum="yes" />
      </Component>

      <Component Id="MainApplicationExeConfig" Guid="{F40EA733-5734-4BF5-9668-63AC0D150DA7}">
        <File Id="MainApplicationExeConfig" Name="$(var.ProgramName).exe.config" KeyPath="yes" Checksum="yes"/>
      </Component>

      <Component Id="DDLibs" Guid="{13F5F24D-9D99-4783-B17B-5FFC9C42E261}">
        <File Id="DDLibStandarts" Name="DD_LIB_Standards.dll" KeyPath="yes" Checksum="yes"/>
        <File Id="DDLogging" Name="DigitalData.Modules.Logging.dll" KeyPath="no" Checksum="yes"/>
        <File Id="DDConfig" Name="DigitalData.Modules.Config.dll" KeyPath="no" Checksum="yes"/>
        <File Id="DDFilesystem" Name="DigitalData.Modules.Filesystem.dll" KeyPath="no" Checksum="yes"/>
        <File Id="DDDatabase" Name="DigitalData.Modules.Database.dll" KeyPath="no" Checksum="yes"/>
        <File Id="DDLanguage" Name="DigitalData.Modules.Language.dll" KeyPath="no" Checksum="yes"/>
        <File Id="DDRegexEditor" Name="DigitalData.Controls.RegexEditor.dll" KeyPath="no" Checksum="yes"/>
        <File Id="DDprotobuf" Name="protobuf-net.dll" KeyPath="no" Checksum="yes"/>
        <File Id="DDDocumentViewer" Name="DigitalData.Controls.DocumentViewer.dll" KeyPath="no" Checksum="yes"/>
        <File Id="DDCommon" Name="DigitalData.GUIs.Common.dll" KeyPath="no" Checksum="yes"/>
        <File Id="DDWindows" Name="DigitalData.Modules.Windows.dll" KeyPath="no" Checksum="yes"/>
        <File Id="DDPatterns" Name="DigitalData.Modules.Patterns.dll" KeyPath="no" Checksum="yes"/>
        <File Id="DDClipboardWatcher" Name="DigitalData.Modules.ClipboardWatcher.dll" KeyPath="no" Checksum="yes"/>
        <File Id="DDZooFlow" Name="DigitalData.Modules.ZooFlow.dll" KeyPath="no" Checksum="yes"/>
      </Component>
      
      <Component Id="NLog" Guid="{08903680-6b02-4ff0-b700-93209381fe1a}">
        <File Id="NLog" Name="NLog.dll" KeyPath="yes" Checksum="yes"/>
      </Component>

      <!-- DEVEXPRESS Bibliotheken -->
      <Component Id="DevExpressLibs" Guid="665D0AC8-93FC-4499-BA89-F660CAC6C577">
        <File Id="DevExpress.Data.v18.1" Name="DevExpress.Data.v18.1.dll" KeyPath="yes" />
        <File Id="DevExpress.Images.v18.1" Name="DevExpress.Images.v18.1.dll" />
        <File Id="DevExpress.Printing.v18.1.Core" Name="DevExpress.Printing.v18.1.Core.dll" />
        <File Id="DevExpress.Office.v18.1.Core" Name="DevExpress.Office.v18.1.Core.dll" />
        <File Id="DevExpress.Pdf.v18.1.Core" Name="DevExpress.Pdf.v18.1.Core.dll" />
        <File Id="DevExpress.Sparkline.v18.1.Core" Name="DevExpress.Sparkline.v18.1.Core.dll" />
        <File Id="DevExpress.Utils.v18.1" Name="DevExpress.Utils.v18.1.dll" />
        <File Id="DevExpress.XtraBars.v18.1" Name="DevExpress.XtraBars.v18.1.dll" />
        <File Id="DevExpress.XtraEditors.v18.1" Name="DevExpress.XtraEditors.v18.1.dll" />
        <File Id="DevExpress.XtraGauges.v18.1.Core" Name="DevExpress.XtraGauges.v18.1.Core.dll" />
        <File Id="DevExpress.XtraGauges.v18.1.Win" Name="DevExpress.XtraGauges.v18.1.Win.dll" />
        <File Id="DevExpress.XtraGrid.v18.1" Name="DevExpress.XtraGrid.v18.1.dll" />
        <File Id="DevExpress.XtraLayout.v18.1" Name="DevExpress.XtraLayout.v18.1.dll" />
        <File Id="DevExpress.XtraPrinting.v18.1" Name="DevExpress.XtraPrinting.v18.1.dll" />
        <File Id="DevExpress.XtraTreeList.v18.1" Name="DevExpress.XtraTreeList.v18.1.dll" />
        <File Id="DevExpress.XtraDialogs.v18.1" Name="DevExpress.XtraDialogs.v18.1.dll" />
        <File Id="DevExpress.Dialogs.v18.1.Core" Name="DevExpress.Dialogs.v18.1.Core.dll" />
        <File Id="DevExpress.RichEdit.v18.1.Core" Name="DevExpress.RichEdit.v18.1.Core.dll" />
      </Component>
      
      <Component Id="IndependentsoftLibs" Guid="136fd96d-3cae-4e50-b82b-423b5d695e7a">
        <File Id="Msg.Net" Name="Independentsoft.Msg.dll" Source="P:\Projekte DIGITAL DATA\DIGITAL DATA - Entwicklung\DLL_Bibliotheken\Independentsoft.Msg.dll" KeyPath="yes" />
      </Component>

      <Component Id="GDPictureLibs" Guid="9ea5ab43-58ff-4813-9a8b-f854784f0275">
        <File Id="GdPicture.NET.14" Name="GdPicture.NET.14.dll" Source="D:\ProgramFiles\GdPicture.NET 14\Redist\GdPicture.NET (.NET Framework 4.5)\GdPicture.NET.14.dll" KeyPath="yes" />
        <File Id="GdPicture.NET.14.filters" Name="GdPicture.NET.14.filters.dll" Source="D:\ProgramFiles\GdPicture.NET 14\Redist\GdPicture.NET.14.filters.dll" />
        <File Id="GdPicture.NET.14.image" Name="GdPicture.NET.14.image.gdimgplug.dll" Source="D:\ProgramFiles\GdPicture.NET 14\Redist\GdPicture.NET.14.image.gdimgplug.dll" />
        <File Id="GdPicture.NET.14.Imaging" Name="GdPicture.NET.14.Imaging.Rendering.Skia.dll" Source="D:\ProgramFiles\GdPicture.NET 14\Redist\GdPicture.NET.14.Imaging.Rendering.Skia.dll" />
      </Component>

      <Component Id="RegistryKeys" Guid="{72D6927F-8297-4D51-BF4A-813064089A4A}">
          <RegistryKey Root="HKLM" Key="Software">
            <RegistryKey Key="[Manufacturer]">
              <RegistryKey Key="[ProductName]" ForceCreateOnInstall="yes" ForceDeleteOnUninstall="yes" Id="REGKEYINSTALLDIR">
                <RegistryValue Type="string" Value="[INSTALLDIR]" Name="Path" />
              </RegistryKey>
            </RegistryKey>
          </RegistryKey>

          <util:RemoveFolderEx Id="RemoveApplicationFolder" On="uninstall" Property="APPLICATIONFOLDER" />
      </Component>
    </DirectoryRef>

    <Feature Id="MainApplication" Title="Main Application" Level="1">
      <ComponentRef Id="MainApplicationExe" />
      <ComponentRef Id="MainApplicationExeConfig"/>
      <ComponentRef Id="DDLibs"/>
      <ComponentRef Id="NLog"/>
      <ComponentRef Id="DevExpressLibs"/>
      <ComponentRef Id="IndependentsoftLibs"/>
      <ComponentRef Id="GDPictureLibs"/>
      <ComponentRef Id="RegistryKeys" />
    </Feature>

    <Feature Id="DesktopShortcut" Title="Desktop Shortcut">
      <Condition Level="0">DISABLE_DESKTOP_ICON</Condition>
      <ComponentRef Id="ApplicationShortcut_Desktop"/>
    </Feature>

    <Feature Id="StartmenuShortcut" Title="Startmenu Shortcut">
      <Condition Level="0">DISABLE_STARTMENU_ICON</Condition>
      <ComponentRef Id="ApplicationShortcut_StartMenu" />
    </Feature>

    <!-- Legt das Standard-Installationsverzeichnis fest-->
    <Property Id="WIXUI_INSTALLDIR" Value="INSTALLDIR" />
    <Property Id="_BrowseProperty" Value="INSTALLDIR" />

    <UI>
      <!--<UIRef Id="WixUI_InstallDir" />-->
      <UIRef Id="WixUI_FeatureTree"/>
      <UIRef Id="WixUI_ErrorProgressText" />
      <Publish Dialog="WelcomeDlg"
            Control="Next"
            Event="NewDialog"
            Value="InstallDirDlg"
            Order="2">1</Publish>
      <Publish Dialog="InstallDirDlg"
            Control="Back"
            Event="NewDialog"
            Value="WelcomeDlg"
            Order="2">1</Publish>
      <Publish Dialog="InstallDirDlg"
            Control="Next"
            Event="NewDialog"
            Value="FeaturesDlg"
            Order="2">1</Publish>
      <Publish Dialog="InstallDirDlg"
            Control="ChangeFolder"
            Event="NewDialog"
            Value="BrowseDlg"
            Order="2">1</Publish>
      <Publish Dialog="FeaturesDlg"
              Control="Back"
              Event="NewDialog"
              Value="InstallDirDlg"
              Order="2">1</Publish>
    </UI>
    
  </Product>
</Wix>