示例#1
0
 public bool Do(VirtPackage virtPackage, ref bool dirty)
 {
     String oldValue = virtPackage.GetProperty("BaseDirName");
     String newValue;
     propertyLocalStorageCustomDir.Text = "";
     if (oldValue == "")
         propertyLocalStorageDefault.Checked = true;
     else if (oldValue.Equals("%ExeDir%\\%AppID%.cameyo.data", StringComparison.InvariantCultureIgnoreCase))
         propertyLocalStorageExeDir.Checked = true;
     else
     {
         propertyLocalStorageCustom.Checked = true;
         propertyLocalStorageCustomDir.Text = oldValue;
     }
     if (ShowDialog() == DialogResult.OK)
     {
         if (propertyLocalStorageDefault.Checked)
             newValue = "";
         else if (propertyLocalStorageExeDir.Checked)
             newValue = "%ExeDir%\\%AppID%.cameyo.data";
         else
             newValue = propertyLocalStorageCustomDir.Text;
         if (newValue != oldValue)
         {
             virtPackage.SetProperty("BaseDirName", newValue);
             dirty = true;
         }
         return true;
     }
     else
         return false;
 }
示例#2
0
        public bool Do(VirtPackage virtPackage, ref bool dirty)
        {
            String oldValue = virtPackage.GetProperty("BaseDirName");
            String newValue;

            // BaseDirName
            //propertyLocalStorageCustomDir.Text = "";
            propertyLocalStorageCustomDir.Text = DefaultBaseDir;   // Shows user how to build this path
            if (oldValue == "")
                propertyLocalStorageDefault.Checked = true;
            else if (oldValue.Equals("%ExeDir%\\%AppID%.cameyo.files", StringComparison.InvariantCultureIgnoreCase))
                propertyLocalStorageExeDir.Checked = true;
            else
            {
                propertyLocalStorageCustom.Checked = true;
                propertyLocalStorageCustomDir.Text = oldValue;
            }

            // DataDirName
            string DefaultDataDirName = System.IO.Path.Combine(propertyLocalStorageCustomDir.Text, "CHANGES");
            propertyDataDirName.Text = virtPackage.GetProperty("DataDirName").Trim();
            propertyDataDir.Checked = !string.IsNullOrEmpty(propertyDataDirName.Text);
            if (propertyDataDirName.Text == "")
                propertyDataDirName.Text = DefaultDataDirName;   // Show user how to build this path
            propertyDataDir_CheckedChanged(null, null);
            propertyLocalStorageCustom_CheckedChanged(null, null);

            retry:
            if (ShowDialog() == DialogResult.OK)
            {
                propertyLocalStorageCustomDir.Text = propertyLocalStorageCustomDir.Text.Trim();
                propertyDataDirName.Text = propertyDataDirName.Text.Trim();

                // Validate
                if (propertyLocalStorageCustom.Checked && propertyLocalStorageCustomDir.Text.Trim('\\').IndexOf('\\') == -1 &&
                    MessageBox.Show(PackageEditor.Messages.Messages.storageDirSubdirWarning + "\n" + propertyLocalStorageCustomDir.Text,
                    "", MessageBoxButtons.YesNo) != System.Windows.Forms.DialogResult.Yes)
                    goto retry;
                if (propertyDataDir.Checked && propertyDataDirName.Text.Trim('\\').IndexOf('\\') == -1 &&
                    MessageBox.Show(PackageEditor.Messages.Messages.storageDirSubdirWarning + "\n" + propertyDataDirName.Text,
                    "", MessageBoxButtons.YesNo) != System.Windows.Forms.DialogResult.Yes)
                    goto retry;

                // BaseDirName
                if (propertyLocalStorageCustomDir.Text.Equals(DefaultBaseDir, StringComparison.InvariantCultureIgnoreCase))
                    propertyLocalStorageCustomDir.Text = "";
                if (propertyLocalStorageDefault.Checked)
                    newValue = "";
                else if (propertyLocalStorageExeDir.Checked)
                    newValue = "%ExeDir%\\%AppID%.cameyo.files";
                else
                    newValue = propertyLocalStorageCustomDir.Text;
                if (newValue != oldValue)
                {
                    virtPackage.SetProperty("BaseDirName", newValue);
                    dirty = true;
                }

                // DataDirName
                if (!propertyDataDir.Checked) // Causes bug (Tom Ferratt case): || propertyDataDirName.Text.Equals(DefaultDataDirName, StringComparison.InvariantCultureIgnoreCase))
                    propertyDataDirName.Text = "";
                virtPackage.SetProperty("DataDirName", propertyDataDirName.Text);

                return true;
            }
            else
                return false;
        }