[ui] update persistence size controls

* Also refactor ToggleImageOptions()
This commit is contained in:
Pete Batard 2018-07-18 12:22:37 +01:00
parent 0fa19d7019
commit 1004a6e066
7 changed files with 170 additions and 106 deletions

View File

@ -1,24 +1,18 @@
This file lists any change that has been applied to the en-US translation of
rufus.loc since its original version. Translators are expected to keep their
translations up to date by monitoring this file on regular basis and applying
the same changes.
rufus.loc since its original version.
When editing an existing translation, make sure you always follow:
When editing an existing translation, make sure to follow:
https://github.com/pbatard/rufus/wiki/Localization#Editing_a_translation
Remember to also update the version number for your translation ('v x.y.z')
once you have matched all the changes that occurred for the en-US translation.
!!IMPORTANT!! The changes below may NOT contain the full message and only tell
you WHERE, in the English translation, you should look to find the full message
content. PLEASE, do not just look at this Changelog when updating your
translation, but always use the English section of rufus.loc as your base.
For instance, MSG_114, that was introduced in v1.0.8 is MORE than one line!
o v3.2 (2018.??.??)
- *NEW* MSG_087
*NEW* MSG_123
*NEW* MSG_124
*NEW* MSG_125
*NEW* MSG_126
*NEW* MSG_127
- *NEW* MSG_172
- *NEW* MSG_199
- *NEW* MSG_240
- *NEW* MSG_306
o v3.0 (2018.03.27)
@ -80,7 +74,8 @@ o v2.16 (2017.07.17)
- *NEW* MSG_298 "The ISO file you have selected does not match its declared size: %s of data is missing!\n\nIf you obtained "
"this file from the Internet, you should try to download a new copy and verify that the MD5 or SHA checksums match the "
"official ones.\n\nNote that you can compute the MD5 or SHA in Rufus by clicking the '#' button."
Note: You can test MSG_297/MSG_298 using https://rufus.akeo.ie/testing/arch_trunc.iso (A truncated version of archlinux-2017.07.01-x86_64.iso)
Note: You can test MSG_297/MSG_298 using https://github.com/pbatard/rufus/raw/master/res/loc/test/arch_trunc.iso
A truncated version of archlinux-2017.07.01-x86_64.iso)
o v2.12 (2017.01.16)
- *NEW* MSG_288 "Missing elevated privileges"
@ -138,7 +133,7 @@ o v2.4 (2015.09.03)
Note: You can see the message above by hovering on the language button
- *NEW* MSG_274 "ISOHybrid image detected"
Note: You can test this message and the one below by downloading and trying to write the latest menu_c32_test.iso (120 KB) from:
https://github.com/pbatard/rufus/raw/master/res/localization/menu_c32_test.iso
https://github.com/pbatard/rufus/raw/master/res/loc/test/menu_c32_test.iso
- *NEW* MSG_275 "The image you have selected is..." [TRANSLATORS: Please refer to the English section of 'rufus.loc' for the FULL message]
For more info on the messages below, also see the comments in the English section of rufus.loc
- *NEW* MSG_276 "Write in %s mode (Recommended)"
@ -151,8 +146,8 @@ o v2.4 (2015.09.03)
o v2.0 (2015.02.04)
- *NEW CONTROL* IDC_WINDOWS_INSTALL "Standard Windows installation" (Main dialog)
- *NEW CONTROL* IDC_WINDOWS_TO_GO "Windows To Go" (Main dialog)
Note: to see the 2 controls above displayed, you will need to load the "Windows To Go.iso" image from
https://github.com/pbatard/rufus/raw/master/res/localization/Windows%20To%20Go.iso (356 KB)
Note: to see the 2 controls above displayed, you will need to load the "windows_to_go.iso" image from
https://github.com/pbatard/rufus/raw/master/res/loc/test/windows_to_go.iso (356 KB)
Also see the comment for IDC_WINDOWS_TO_GO in the English translation.
- *NEW* MSG_096 "The file system currently selected can not be used with this type of ISO (...)"
- *NEW* MSG_097 "'Windows To Go' can only be applied if the file system is NTFS."

View File

@ -308,6 +308,11 @@ t MSG_119 "advanced drive properties"
t MSG_120 "advanced format options"
t MSG_121 "Show %s"
t MSG_122 "Hide %s"
t MSG_123 "Persistent partition size"
t MSG_124 "No persistence"
t MSG_125 "Use this slider to set the size of the persistent partition. Setting the size to 0 disables the persistent partition."
t MSG_126 "Use this field to enter the size of the persistent partition. Setting the size to 0 disables the persistent partition."
t MSG_127 "Set the persistent partition size unit."
t MSG_150 "Type of computer you plan to use this bootable drive with. It is your responsibility to determine whether "
"your target is of BIOS or UEFI type before you start creating the drive, as it may fail to boot otherwise."
# You shouldn't translate 'Legacy Mode' as this is an option that usually appears in English in the UEFI settings.
@ -372,7 +377,6 @@ t MSG_196 "IMPORTANT: THIS DRIVE USES A NONSTANDARD SECTOR SIZE!\n\n"
t MSG_197 "Nonstandard sector size detected"
t MSG_198 "'Windows To Go' can only be installed on a GPT partitioned drive if it has "
"the FIXED attribute set. The current drive was not detected as FIXED."
t MSG_199 "Persistent partition size"
t MSG_201 "Cancelling - Please wait..."
t MSG_202 "Scanning image..."

View File

@ -90,7 +90,7 @@ RUFUS_UPDATE update = { { 0,0,0 },{ 0,0 }, NULL, NULL };
HINSTANCE hMainInstance;
HWND hMainDialog, hMultiToolbar, hSaveToolbar, hHashToolbar, hAdvancedDeviceToolbar, hAdvancedFormatToolbar, hUpdatesDlg = NULL;
HFONT hInfoFont;
uint8_t image_options = 0x00;
uint8_t image_options = IMOP_WINTOGO;
uint16_t rufus_version[3], embedded_sl_version[2];
uint32_t dur_mins, dur_secs, DrivePort[MAX_DRIVES];;
loc_cmd* selected_locale = NULL;
@ -102,8 +102,9 @@ BOOL use_own_c32[NB_OLD_C32] = { FALSE, FALSE }, mbr_selected_by_user = FALSE;
BOOL iso_op_in_progress = FALSE, format_op_in_progress = FALSE, right_to_left_mode = FALSE, has_uefi_csm;
BOOL enable_HDDs = FALSE, force_update = FALSE, enable_ntfs_compression = FALSE, no_confirmation_on_cancel = FALSE, lock_drive = TRUE;
BOOL advanced_mode_device, advanced_mode_format, allow_dual_uefi_bios, detect_fakes, enable_vmdk, force_large_fat32, usb_debug;
BOOL use_fake_units, preserve_timestamps = FALSE, fast_zeroing = FALSE;
BOOL use_fake_units, preserve_timestamps = FALSE, fast_zeroing = FALSE, app_changed_size = FALSE;
BOOL zero_drive = FALSE, list_non_usb_removable_drives = FALSE, enable_file_indexing, large_drive = FALSE, write_as_image = FALSE;
uint64_t persistence_size = 0;
float fScale = 1.0f;
int dialog_showing = 0, selection_default = BT_IMAGE, windows_to_go_selection = 0, persistence_unit_selection = -1;
int default_fs, fs, bt, pt, tt; // file system, boot type, partition type, target type
@ -112,6 +113,7 @@ char embedded_sl_version_str[2][12] = { "?.??", "?.??" };
char embedded_sl_version_ext[2][32];
char ClusterSizeLabel[MAX_CLUSTER_SIZES][64];
char msgbox[1024], msgbox_title[32], *ini_file = NULL, *image_path = NULL, *short_image_path;
char image_option_txt[128];
StrArray DriveID, DriveLabel, DriveHub, BlockingProcess, ImageList;
// Number of steps for each FS for FCC_STRUCTURE_PROGRESS
const int nb_steps[FS_MAX] = { 5, 5, 12, 1, 10 };
@ -600,26 +602,6 @@ static void SetMBRProps(void)
IGNORE_RETVAL(ComboBox_SetCurSel(hDiskID, needs_masquerading?1:0));
}
static void SetImageOptions(void)
{
if ((bt != BT_IMAGE) || (image_path == NULL)) {
if (image_options & IMOP_WINTOGO)
ToggleImageOption(IMOP_WINTOGO);
if (image_options & IMOP_PERSISTENCE)
ToggleImageOption(IMOP_PERSISTENCE);
return;
}
if ( (!HAS_WINTOGO(img_report) && ( (image_options & IMOP_WINTOGO))) ||
( HAS_WINTOGO(img_report) && (!(image_options & IMOP_WINTOGO))) ) {
ToggleImageOption(IMOP_WINTOGO);
}
if ( (!HAS_PERSISTENCE(img_report) && ( (image_options & IMOP_PERSISTENCE))) ||
( HAS_PERSISTENCE(img_report) && (!(image_options & IMOP_PERSISTENCE))) ) {
ToggleImageOption(IMOP_PERSISTENCE);
}
}
static void SetProposedLabel(int ComboIndex)
{
const char no_label[] = STR_NO_LABEL, empty[] = "";
@ -731,8 +713,8 @@ static void EnableBootOptions(BOOL enable, BOOL remove_checkboxes)
EnableWindow(GetDlgItem(hMainDialog, IDC_IMAGE_OPTION), actual_enable);
EnableWindow(GetDlgItem(hMainDialog, IDC_PERSISTENCE_SLIDER), actual_enable);
EnableWindow(GetDlgItem(hMainDialog, IDC_PERSISTENCE_SIZE), actual_enable);
EnableWindow(GetDlgItem(hMainDialog, IDC_PERSISTENCE_UNITS), actual_enable);
EnableWindow(GetDlgItem(hMainDialog, IDC_PERSISTENCE_SIZE), (persistence_size != 0) && actual_enable);
EnableWindow(GetDlgItem(hMainDialog, IDC_PERSISTENCE_UNITS), (persistence_size != 0) && actual_enable);
EnableMBRBootOptions(actual_enable, remove_checkboxes);
EnableWindow(GetDlgItem(hMainDialog, IDC_LABEL), actual_enable);
@ -1001,8 +983,6 @@ static void DisplayISOProps(void)
}
PRINT_ISO_PROP(img_report.has_symlinks, " Note: This ISO uses symbolic links, which will not be replicated due to file system limitations.");
PRINT_ISO_PROP(img_report.has_symlinks, " Because of this, some features from this image may not work...");
SetImageOptions();
}
// Insert the image name into the Boot selection dropdown
@ -1084,6 +1064,7 @@ DWORD WINAPI ISOScanThread(LPVOID param)
UpdateImage();
uprintf("Using image: %s (%s)", short_image_path, SizeToHumanReadable(img_report.image_size, FALSE, FALSE));
}
ToggleImageOptions();
EnableControls(TRUE);
// Set Target and FS accordingly
if (img_report.is_iso) {
@ -1643,12 +1624,15 @@ static void InitDialog(HWND hDlg)
CreateTooltip(hTargetSystem, lmprintf(MSG_150), 30000);
CreateTooltip(GetDlgItem(hDlg, IDS_CSM_HELP_TXT), lmprintf(MSG_151), 30000);
CreateTooltip(GetDlgItem(hDlg, IDC_IMAGE_OPTION), lmprintf(MSG_305), 30000);
CreateTooltip(GetDlgItem(hDlg, IDC_PERSISTENCE_SLIDER), lmprintf(MSG_125), 30000);
CreateTooltip(GetDlgItem(hDlg, IDC_PERSISTENCE_SIZE), lmprintf(MSG_126), 30000);
CreateTooltip(GetDlgItem(hDlg, IDC_PERSISTENCE_UNITS), lmprintf(MSG_127), 30000);
if (!advanced_mode_device) // Hide as needed, since we display the advanced controls by default
ToggleAdvancedDeviceOptions(FALSE);
if (!advanced_mode_format)
ToggleAdvancedFormatOptions(FALSE);
ToggleImageOption(0);
ToggleImageOptions();
// Process commandline parameters
if (iso_provided) {
@ -1860,14 +1844,14 @@ out:
static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
static DWORD DeviceNum = 0;
static uint64_t LastRefresh = 0, pos;
static uint64_t LastRefresh = 0;
static BOOL first_log_display = TRUE, isMarquee = FALSE, queued_hotplug_event = FALSE;
static ULONG ulRegister = 0;
static LONG lPos;
static LPITEMIDLIST pidlDesktop = NULL;
static SHChangeNotifyEntry NotifyEntry;
static DWORD_PTR thread_affinity[4];
static HFONT hyperlink_font = NULL;
LONG lPos;
BOOL set_selected_fs;
DRAWITEMSTRUCT* pDI;
LPTOOLTIPTEXT lpttt;
@ -2044,18 +2028,52 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
SetFileSystemAndClusterSize(NULL);
windows_to_go_selection = ComboBox_GetCurSel(GetDlgItem(hDlg, IDC_IMAGE_OPTION));
break;
case IDC_PERSISTENCE_SIZE:
if (HIWORD(wParam) == EN_CHANGE) {
uint64_t pos;
// We get EN_CHANGE when we change the size automatically, so we need to detect that
if (app_changed_size) {
app_changed_size = FALSE;
break;
}
GetWindowTextA(GetDlgItem(hDlg, IDC_PERSISTENCE_SIZE), tmp, sizeof(tmp));
lPos = atol(tmp);
persistence_unit_selection = ComboBox_GetCurSel(GetDlgItem(hDlg, IDC_PERSISTENCE_UNITS));
persistence_size = lPos * MB;
for (i = 0; i < persistence_unit_selection; i++)
persistence_size *= 1024;
if (persistence_size > SelectedDrive.DiskSize - img_report.projected_size)
persistence_size = SelectedDrive.DiskSize - img_report.projected_size;
pos = persistence_size / MB;
for (i = 0; i < persistence_unit_selection; i++)
pos /= 1024;
lPos = (LONG)pos;
SendMessage(GetDlgItem(hMainDialog, IDC_PERSISTENCE_SLIDER), TBM_SETPOS, TRUE, lPos);
if (persistence_size >= (SelectedDrive.DiskSize - img_report.projected_size)) {
static_sprintf(tmp, "%d", lPos);
app_changed_size = TRUE;
SetWindowTextU(GetDlgItem(hMainDialog, IDC_PERSISTENCE_SIZE), tmp);
}
} else if (HIWORD(wParam) == EN_KILLFOCUS) {
if (persistence_size == 0) {
TogglePersistenceControls(FALSE);
static_sprintf(tmp, "0 (%s)", lmprintf(MSG_124));
app_changed_size = TRUE;
SetWindowTextU(GetDlgItem(hMainDialog, IDC_PERSISTENCE_SIZE), tmp);
}
}
break;
case IDC_PERSISTENCE_UNITS:
if (HIWORD(wParam) != CBN_SELCHANGE)
break;
if (ComboBox_GetCurSel(GetDlgItem(hDlg, IDC_PERSISTENCE_UNITS)) == persistence_unit_selection)
break;
GetWindowTextA(GetDlgItem(hMainDialog, IDC_PERSISTENCE_SIZE), tmp, sizeof(tmp));
pos = atol(tmp) * MB;
persistence_size = atol(tmp) * MB;
for (i = 0; i < persistence_unit_selection; i++)
pos *= 1024;
persistence_size *= 1024;
persistence_unit_selection = ComboBox_GetCurSel(GetDlgItem(hDlg, IDC_PERSISTENCE_UNITS));
// TODO: Use projected size. For now force the selected ISO to a 4 GB size
SetPersistenceSize(pos, SelectedDrive.DiskSize - 4 * GB);
SetPersistenceSize(persistence_size, SelectedDrive.DiskSize - img_report.projected_size);
break;
case IDC_NB_PASSES:
if (HIWORD(wParam) != CBN_SELCHANGE)
@ -2115,7 +2133,7 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
if ((selected_fs == -1) && (SelectedDrive.DeviceNumber != 0))
GetDrivePartitionData(SelectedDrive.DeviceNumber, tmp, sizeof(tmp), TRUE);
SetFileSystemAndClusterSize(tmp);
SetImageOptions();
ToggleImageOptions();
SetProposedLabel(ComboBox_GetCurSel(hDeviceList));
EnableControls(TRUE);
tt = (int)ComboBox_GetItemData(hPartitionScheme, ComboBox_GetCurSel(hPartitionScheme));
@ -2399,8 +2417,19 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
case WM_HSCROLL:
lPos = (LONG)SendMessage(GetDlgItem(hMainDialog, IDC_PERSISTENCE_SLIDER), TBM_GETPOS, 0, 0);
sprintf(tmp, "%ld", lPos);
SetWindowTextA(GetDlgItem(hMainDialog, IDC_PERSISTENCE_SIZE), tmp);
if (lPos != 0) {
if (persistence_size == 0)
TogglePersistenceControls(TRUE);
sprintf(tmp, "%ld", lPos);
} else {
TogglePersistenceControls(FALSE);
static_sprintf(tmp, "0 (%s)", lmprintf(MSG_124));
}
persistence_size = lPos * MB;
for (i = 0; i < persistence_unit_selection; i++)
persistence_size *= 1024;
app_changed_size = TRUE;
SetWindowTextU(GetDlgItem(hMainDialog, IDC_PERSISTENCE_SIZE), tmp);
break;
case WM_DROPFILES:
@ -3012,6 +3041,9 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
relaunch:
ubprintf("Localization set to '%s'", selected_locale->txt[0]);
right_to_left_mode = ((selected_locale->ctrl_id) & LOC_RIGHT_TO_LEFT);
// We always launch with the image options displaying
image_options = IMOP_WINTOGO;
image_option_txt[0] = 0;
SetProcessDefaultLayout(right_to_left_mode?LAYOUT_RTL:0);
if (get_loc_data_file(loc_file, selected_locale))
WriteSettingStr(SETTING_LOCALE, selected_locale->txt[0]);

View File

@ -230,7 +230,8 @@ enum fs_type {
};
enum boot_type {
BT_MSDOS = 0,
BT_NON_BOOTABLE = 0,
BT_MSDOS,
BT_FREEDOS,
BT_IMAGE,
BT_SYSLINUX_V4, // Start of indexes that only display in advanced mode
@ -239,7 +240,6 @@ enum boot_type {
BT_GRUB4DOS,
BT_GRUB2,
BT_UEFI_NTFS,
BT_NON_BOOTABLE,
BT_MAX
};

View File

@ -33,7 +33,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
IDD_DIALOG DIALOGEX 12, 12, 232, 326
STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_ACCEPTFILES
CAPTION "Rufus 3.2.1341"
CAPTION "Rufus 3.2.1342"
FONT 9, "Segoe UI Symbol", 400, 0, 0x0
BEGIN
LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP
@ -392,8 +392,8 @@ END
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 3,2,1341,0
PRODUCTVERSION 3,2,1341,0
FILEVERSION 3,2,1342,0
PRODUCTVERSION 3,2,1342,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@ -411,13 +411,13 @@ BEGIN
VALUE "Comments", "https://akeo.ie"
VALUE "CompanyName", "Akeo Consulting"
VALUE "FileDescription", "Rufus"
VALUE "FileVersion", "3.2.1341"
VALUE "FileVersion", "3.2.1342"
VALUE "InternalName", "Rufus"
VALUE "LegalCopyright", "© 2011-2018 Pete Batard (GPL v3)"
VALUE "LegalTrademarks", "https://www.gnu.org/copyleft/gpl.html"
VALUE "OriginalFilename", "rufus-3.2.exe"
VALUE "ProductName", "Rufus"
VALUE "ProductVersion", "3.2.1341"
VALUE "ProductVersion", "3.2.1342"
END
END
BLOCK "VarFileInfo"

113
src/ui.c
View File

@ -237,7 +237,7 @@ void GetFullWidth(HWND hDlg)
bsw = max(bsw, GetTextSize(hBootType, lmprintf(MSG_281, lmprintf(MSG_280))).cx + ddw);
// Initialize full width to the UI's default size
GetWindowRect(GetDlgItem(hDlg, IDC_IMAGE_OPTION), &rc);
GetWindowRect(GetDlgItem(hDlg, IDS_DEVICE_TXT), &rc);
MapWindowPoints(NULL, hDlg, (POINT*)&rc, 2);
fw = rc.right - rc.left - ddw;
@ -399,20 +399,22 @@ void PositionMainControls(HWND hDlg)
hCtrl = GetDlgItem(hDlg, IDC_PERSISTENCE_SLIDER);
GetWindowRect(hCtrl, &rc);
MapWindowPoints(NULL, hDlg, (POINT*)&rc, 2);
SetWindowPos(hCtrl, hTargetSystem, mw, rc.top, bsw, rc.bottom - rc.top, 0);
SetWindowPos(hCtrl, GetDlgItem(hDlg, IDC_IMAGE_OPTION), mw, rc.top, bsw, rc.bottom - rc.top, 0);
// Reposition the Persistence Units dropdown (no need to resize)
hCtrl = GetDlgItem(hDlg, IDC_PERSISTENCE_UNITS);
GetWindowRect(hCtrl, &rc);
MapWindowPoints(NULL, hDlg, (POINT*)&rc, 2);
sz.cx = fw - (rc.right - rc.left);
SetWindowPos(hCtrl, hTargetSystem, mw + sz.cx, rc.top, rc.right - rc.left, rc.bottom - rc.top, 0);
SetWindowPos(hCtrl, GetDlgItem(hDlg, IDC_PERSISTENCE_SIZE), mw + sz.cx, rc.top, rc.right - rc.left, rc.bottom - rc.top, 0);
ShowWindow(hCtrl, SW_HIDE);
// Reposition and resize the Persistence Size edit
hCtrl = GetDlgItem(hDlg, IDC_PERSISTENCE_SIZE);
GetWindowRect(hCtrl, &rc);
MapWindowPoints(NULL, hDlg, (POINT*)&rc, 2);
SetWindowPos(hCtrl, hTargetSystem, mw + bsw + ssw, rc.top, sz.cx - bsw - 2*ssw, rc.bottom - rc.top, 0);
SetWindowPos(hCtrl, GetDlgItem(hDlg, IDC_PERSISTENCE_SLIDER), mw + bsw + ssw, rc.top, fw - bsw - ssw, rc.bottom - rc.top, 0);
EnableWindow(hCtrl, FALSE);
// Reposition the CSM help tip
hCtrl = GetDlgItem(hDlg, IDS_CSM_HELP_TXT);
@ -635,9 +637,40 @@ void ToggleAdvancedFormatOptions(BOOL enable)
InvalidateRect(hMainDialog, NULL, TRUE);
}
// Toggle the display of peristence unit dropdown and resize the size field
void TogglePersistenceControls(BOOL display)
{
RECT rc;
HWND hSize, hUnits;
LONG style, width = fw - bsw - ssw;
hSize = GetDlgItem(hMainDialog, IDC_PERSISTENCE_SIZE);
hUnits = GetDlgItem(hMainDialog, IDC_PERSISTENCE_UNITS);
style = GetWindowLong(hSize, GWL_EXSTYLE);
if (display)
style |= WS_EX_RIGHT;
else
style &= ~WS_EX_RIGHT;
SetWindowLong(hSize, GWL_EXSTYLE, style);
if (display) {
GetWindowRect(hUnits, &rc);
MapWindowPoints(NULL, hMainDialog, (POINT*)&rc, 2);
width -= (rc.right - rc.left) + ssw;
}
GetWindowRect(hSize, &rc);
MapWindowPoints(NULL, hMainDialog, (POINT*)&rc, 2);
SetWindowPos(hSize, GetDlgItem(hMainDialog, IDC_PERSISTENCE_SLIDER), mw + bsw + ssw, rc.top, width, rc.bottom - rc.top, 0);
EnableWindow(hSize, display ? TRUE : FALSE);
EnableWindow(hUnits, display ? TRUE : FALSE);
ShowWindow(hUnits, display ? SW_SHOW : SW_HIDE);
}
void SetPersistenceSize(uint64_t pos, uint64_t max)
{
char tmp[12];
char tmp[64];
int i, proposed_unit_selection = 0;
LONGLONG base_unit = MB;
HWND hCtrl;
@ -670,61 +703,60 @@ void SetPersistenceSize(uint64_t pos, uint64_t max)
SendMessage(hCtrl, TBM_SETRANGEMIN, (WPARAM)FALSE, (LPARAM)0);
SendMessage(hCtrl, TBM_SETRANGEMAX, (WPARAM)FALSE, (LPARAM)max);
SendMessage(hCtrl, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)pos);
static_sprintf(tmp, "%ld", (LONG)pos);
SetWindowTextA(GetDlgItem(hMainDialog, IDC_PERSISTENCE_SIZE), tmp);
if (pos != 0) {
static_sprintf(tmp, "%ld", (LONG)pos);
} else {
static_sprintf(tmp, "0 (%s)", lmprintf(MSG_124));
}
app_changed_size = TRUE;
SetWindowTextU(GetDlgItem(hMainDialog, IDC_PERSISTENCE_SIZE), tmp);
}
// Toggle the Image Option dropdown (Windows To Go or persistence settings)
void ToggleImageOption(uint8_t mask)
void ToggleImageOptions(void)
{
static BOOL relaunch = FALSE;
static char image_option_txt[128] = "";
int i, shift = (popcnt8(image_options) >= 2) ? 0 : rh;
BOOL has_wintogo, has_persistence;
uint8_t entry_image_options = image_options;
int i, shift = rh;
assert(popcnt8(mask) <= 1);
has_wintogo = ((bt == BT_IMAGE) && (image_path != NULL) && (img_report.is_iso) && (nWindowsVersion >= WINDOWS_8) && (HAS_WINTOGO(img_report)));
has_persistence = ((bt == BT_IMAGE) && (image_path != NULL) && (img_report.is_iso) && (HAS_PERSISTENCE(img_report)));
// mask is set to 0 when called during (re)init
if (mask == 0) {
if (relaunch) {
if ((selection_default == BT_IMAGE) && (image_path != NULL))
goto skip;
} else {
relaunch = TRUE;
// Keep a copy of the original image option translation, as it'll be easier to toggle
GetWindowTextU(GetDlgItem(hMainDialog, IDS_IMAGE_OPTION_TXT), image_option_txt, sizeof(image_option_txt));
}
}
assert(popcnt8(image_options) <= 1);
if (mask & IMOP_WINTOGO) {
if (nWindowsVersion < WINDOWS_8)
return;
// Keep a copy of the "Image Option" text (so that we don't have to duplicate its transation in the .loc)
if (image_option_txt[0] == 0)
GetWindowTextU(GetDlgItem(hMainDialog, IDS_IMAGE_OPTION_TXT), image_option_txt, sizeof(image_option_txt));
if ( ((has_wintogo) && !(image_options & IMOP_WINTOGO)) ||
((!has_wintogo) && (image_options & IMOP_WINTOGO)) ) {
image_options ^= IMOP_WINTOGO;
// Set the Windows To Go selection in the dropdown
IGNORE_RETVAL(ComboBox_SetCurSel(GetDlgItem(hMainDialog, IDC_IMAGE_OPTION), windows_to_go_selection));
} else if (mask & IMOP_PERSISTENCE) {
}
if (((has_persistence) && !(image_options & IMOP_PERSISTENCE)) ||
((!has_persistence) && (image_options & IMOP_PERSISTENCE))) {
image_options ^= IMOP_PERSISTENCE;
}
if (popcnt8(image_options) >= 2)
if ( ((entry_image_options != 0) && (has_wintogo || has_persistence)) ||
((entry_image_options == 0) && !(has_wintogo || has_persistence)) )
shift = 0;
if (shift != 0) {
if ((mask == 0) || (image_options == 0))
if (entry_image_options != 0)
shift = -shift;
section_vpos[1] += shift;
section_vpos[2] += shift;
if (popcnt8(image_options) <= 1) {
// Move the controls up or down
for (i = 0; i < ARRAYSIZE(image_option_move_ids); i++)
MoveCtrlY(hMainDialog, image_option_move_ids[i], shift);
for (i = 0; i < ARRAYSIZE(image_option_move_ids); i++)
MoveCtrlY(hMainDialog, image_option_move_ids[i], shift);
// Resize the main dialog and log window
ResizeDialogs(shift);
}
// Resize the main dialog and log window
ResizeDialogs(shift);
}
skip:
// Hide or show the boot options
for (i = 0; i < ARRAYSIZE(image_option_toggle_ids); i++) {
ShowWindow(GetDlgItem(hMainDialog, image_option_toggle_ids[i][0]),
@ -735,10 +767,9 @@ skip:
SetWindowTextU(GetDlgItem(hMainDialog, IDS_IMAGE_OPTION_TXT), image_option_txt);
IGNORE_RETVAL(ComboBox_SetCurSel(GetDlgItem(hMainDialog, IDC_IMAGE_OPTION), windows_to_go_selection));
} else if (image_options & IMOP_PERSISTENCE) {
SetWindowTextU(GetDlgItem(hMainDialog, IDS_IMAGE_OPTION_TXT), lmprintf(MSG_199));
// TODO: Use projected size and reuse existing pos. For now force the selected ISO to a 4 GB size
uint64_t max_size = SelectedDrive.DiskSize - 4 * GB;
SetPersistenceSize(max_size / 2, max_size);
SetWindowTextU(GetDlgItem(hMainDialog, IDS_IMAGE_OPTION_TXT), lmprintf(MSG_123));
TogglePersistenceControls(persistence_size != 0);
SetPersistenceSize(persistence_size, SelectedDrive.DiskSize - img_report.projected_size);
}
// If you don't force a redraw here, all kind of bad UI artifacts happen...
InvalidateRect(hMainDialog, NULL, TRUE);

View File

@ -46,10 +46,11 @@
extern HWND hMultiToolbar, hSaveToolbar, hHashToolbar, hAdvancedDeviceToolbar, hAdvancedFormatToolbar;
extern HFONT hInfoFont;
extern UINT_PTR UM_LANGUAGE_MENU_MAX;
extern BOOL advanced_mode_device, advanced_mode_format, force_large_fat32;
extern BOOL advanced_mode_device, advanced_mode_format, force_large_fat32, app_changed_size;
extern loc_cmd* selected_locale;
extern uint64_t persistence_size;
extern const char *sfd_name, *flash_type[BADLOCKS_PATTERN_TYPES];
extern char *short_image_path;
extern char *short_image_path, image_option_txt[128];
extern int advanced_device_section_height, advanced_format_section_height;
extern int windows_to_go_selection, persistence_unit_selection;
extern int selection_default, cbw, ddw, ddbh, bh;
@ -63,9 +64,10 @@ extern void PositionMainControls(HWND hDlg);
extern void AdjustForLowDPI(HWND hDlg);
extern void SetSectionHeaders(HWND hDlg);
extern void SetPersistenceSize(uint64_t pos, uint64_t max);
extern void TogglePersistenceControls(BOOL display);
extern void ToggleAdvancedDeviceOptions(BOOL enable);
extern void ToggleAdvancedFormatOptions(BOOL enable);
extern void ToggleImageOption(uint8_t mask);
extern void ToggleImageOptions(void);
extern void CreateSmallButtons(HWND hDlg);
extern void CreateAdditionalControls(HWND hDlg);
extern void InitProgress(BOOL bOnlyFormat);