Exemplo n.º 1
0
        private void PopulateProfileList()
        {
            XMLProfileSettings profile = new XMLProfileSettings();

            int profileCount = profile.GetSetting("Profiles/ProfileCount", 0);

            if (profileCount == 0)
            {
                ProfileItem item = new ProfileItem();
                item.Name       = "Default";
                item.DataFolder = defaultFolder;
                comboBoxProfiles.Items.Add(item);
            }
            else
            {
                for (int i = 0; i < profileCount; i++)
                {
                    ProfileItem item = new ProfileItem();
                    item.Name       = profile.GetSetting("Profiles/" + "Profile" + i.ToString() + "/Name", "New Profile");
                    item.DataFolder = profile.GetSetting("Profiles/" + "Profile" + i.ToString() + "/DataFolder", defaultFolder);
                    comboBoxProfiles.Items.Add(item);
                }
            }
            comboBoxProfiles.SelectedIndex = 0;
        }
Exemplo n.º 2
0
        private void PopulateProfileList()
        {
            XMLProfileSettings profile = new XMLProfileSettings();

            listBoxProfiles.BeginUpdate();
            //Make sure we start with an empty listbox since we may repopulate after editing profiles
            listBoxProfiles.Items.Clear();
            int profileCount = profile.GetSetting(XMLProfileSettings.SettingType.Profiles, "ProfileCount", 0);

            for (int i = 0; i < profileCount; i++)
            {
                var dataFolder = profile.GetSetting(XMLProfileSettings.SettingType.Profiles, "Profile" + i.ToString() + "/DataFolder", string.Empty);
                // if (!VixenApplication.IsProfileLocked(dataFolder)) //Only add the profile if it is not locked.
                //{
                ProfileItem item = new ProfileItem();
                item.Name = profile.GetSetting(XMLProfileSettings.SettingType.Profiles, "Profile" + i.ToString() + "/Name",
                                               "New Profile");
                item.DataFolder = dataFolder;
                item.IsLocked   = VixenApplication.IsProfileLocked(dataFolder);
                listBoxProfiles.Items.Add(item);

                //}
            }

            listBoxProfiles.EndUpdate();
        }
Exemplo n.º 3
0
        private void PopulateProfileList()
        {
            XMLProfileSettings profile  = new XMLProfileSettings();
            List <ProfileItem> profiles = new List <ProfileItem>();


            listBoxProfiles.BeginUpdate();
            //Make sure we start with an empty listbox since we may repopulate after editing profiles
            listBoxProfiles.Items.Clear();
            int profileCount = profile.GetSetting(XMLProfileSettings.SettingType.Profiles, "ProfileCount", 0);

            for (int i = 0; i < profileCount; i++)
            {
                var dataFolder = profile.GetSetting(XMLProfileSettings.SettingType.Profiles, "Profile" + i.ToString() + "/DataFolder", string.Empty);
                // if (!VixenApplication.IsProfileLocked(dataFolder)) //Only add the profile if it is not locked.
                //{
                ProfileItem item = new ProfileItem
                {
                    Name = profile.GetSetting(XMLProfileSettings.SettingType.Profiles, "Profile" + i.ToString() + "/Name",
                                              "New Profile"),
                    DataFolder     = dataFolder,
                    IsLocked       = VixenApplication.IsProfileLocked(dataFolder),
                    DateLastLoaded = profile.GetSetting(XMLProfileSettings.SettingType.Profiles, "Profile" + i.ToString() + "/DateLastLoaded", DateTime.MinValue),
                    ProfileNumber  = i
                };

                profiles.Add(item);
                //}
            }

            profiles.Sort((x, y) => y.DateLastLoaded.CompareTo(x.DateLastLoaded));
            listBoxProfiles.DataSource = profiles;

            listBoxProfiles.EndUpdate();
        }
Exemplo n.º 4
0
        private void PopulateProfileList()
        {
            var profile = new XMLProfileSettings();

            int profileCount = profile.GetSetting(XMLProfileSettings.SettingType.Profiles, "ProfileCount", 0);

            if (profileCount == 0)
            {
                MessageBox.Show(@"Unable to locate any profiles.");
                return;
            }

            for (int i = 0; i < profileCount; i++)
            {
                var item = new ProfileItem
                {
                    Name       = profile.GetSetting(XMLProfileSettings.SettingType.Profiles, "Profile" + i.ToString() + "/Name", ""),
                    DataFolder =
                        profile.GetSetting(XMLProfileSettings.SettingType.Profiles, "Profile" + i.ToString() + "/DataFolder", "")
                };
                comboBoxProfiles.Items.Add(item);
            }
            comboBoxProfiles.SelectedIndex = 0;
            textBoxFileName.Text           = @"VixenProfile";
            textBoxSaveFolder.Text         = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
        }
Exemplo n.º 5
0
        private void ArchiveProfile(List <string> profileExclusions, bool includeLogs, bool includeUserSettings)
        {
            ProfileItem item = _item;

            string outPath = Path.Combine(textBoxSaveFolder.Text, textBoxFileName.Text + ".zip");

            String appDataFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), @"Vixen");
            String logDataFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), @"Vixen 3", @"logs");

            string folderFullPath = Path.GetFullPath(item.DataFolder);
            string parentFolder   = folderFullPath.Split(Path.DirectorySeparatorChar).Last();

            UpdateStatus("Zipping profile please wait...");
            var success = Archive(item.DataFolder, profileExclusions, parentFolder, outPath);

            if (success && includeLogs)
            {
                UpdateStatus("Zipping logs please wait...");
                success = Archive(logDataFolder, new List <string>(), Path.Combine(parentFolder, @"Core Logs"), outPath);
            }
            if (success && includeUserSettings)
            {
                UpdateStatus("Zipping user settings please wait...");
                Archive(appDataFolder, new List <string>(), Path.Combine(parentFolder, @"User Settings"), outPath);
            }
        }
Exemplo n.º 6
0
        private void PopulateProfileList()
        {
            var profile = new XMLProfileSettings();

            int profileCount = profile.GetSetting(XMLProfileSettings.SettingType.Profiles, "ProfileCount", 0);

            if (profileCount == 0)
            {
                var item = new ProfileItem
                {
                    Name       = "Default",
                    DataFolder = DataProfileForm.DefaultFolder
                };
                comboBoxProfiles.Items.Add(item);
            }
            else
            {
                for (int i = 0; i < profileCount; i++)
                {
                    var item = new ProfileItem
                    {
                        Name       = profile.GetSetting(XMLProfileSettings.SettingType.Profiles, "Profile" + i.ToString() + "/Name", ""),
                        DataFolder =
                            profile.GetSetting(XMLProfileSettings.SettingType.Profiles, "Profile" + i.ToString() + "/DataFolder", "")
                    };
                    comboBoxProfiles.Items.Add(item);
                }
            }
            comboBoxProfiles.SelectedIndex = 0;
            textBoxFileName.Text           = @"VixenProfile";
            textBoxSaveFolder.Text         = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
        }
Exemplo n.º 7
0
        private void PopulateProfileList()
        {
            XMLProfileSettings profile = new XMLProfileSettings();

            int profileCount = profile.GetSetting(XMLProfileSettings.SettingType.Profiles, "ProfileCount", 0);

            if (profileCount == 0)
            {
                ProfileItem item = new ProfileItem {
                    Name = "Default", DataFolder = _defaultFolder
                };
                comboBoxProfiles.Items.Add(item);
            }
            else
            {
                for (int i = 0; i < profileCount; i++)
                {
                    ProfileItem item = new ProfileItem
                    {
                        Name       = profile.GetSetting(XMLProfileSettings.SettingType.Profiles, "Profile" + i + "/Name", "New Profile"),
                        DataFolder = profile.GetSetting(XMLProfileSettings.SettingType.Profiles, "Profile" + i + "/DataFolder", _defaultFolder)
                    };
                    comboBoxProfiles.Items.Add(item);
                }
            }
            comboBoxProfiles.SelectedIndex = 0;
        }
Exemplo n.º 8
0
        private void buttonDeleteProfile_Click(object sender, EventArgs e)
        {
            ProfileItem item = comboBoxProfiles.SelectedItem as ProfileItem;

            if (item == null)
            {
                return;
            }
            //messageBox Arguments are (Text, Title, No Button Visible, Cancel Button Visible)
            MessageBoxForm.msgIcon = SystemIcons.Warning;             //this is used if you want to add a system icon to the message form.
            var messageBox = new MessageBoxForm("Are you sure you want to delete this profile? The data folder and all its contents will remain and must be removed manually.",
                                                @"Delete a Profile", true, true);

            messageBox.ShowDialog();

            if (messageBox.DialogResult == DialogResult.OK)
            {
                comboBoxProfiles.Items.Remove(item);
                if (comboBoxProfiles.Items.Count > 0)
                {
                    comboBoxProfiles.SelectedIndex = 0;
                }

                PopulateLoadProfileSection(false);
            }
        }
Exemplo n.º 9
0
        private void buttonAddProfile_Click(object sender, EventArgs e)
        {
            SaveCurrentItem();

            TextDialog dialog = new TextDialog("Enter a name for the new profile","Profile Name","New Profile");

            while (dialog.ShowDialog() == DialogResult.OK)
            {
                if (dialog.Response == string.Empty)
                {
                    MessageBox.Show(@"Profile name can not be blank.");
                }

                if (comboBoxProfiles.Items.Cast<ProfileItem>().Any(items => items.Name == dialog.Response))
                {
                    MessageBox.Show(@"A profile with the name " + dialog.Response + @" already exists.");
                }

                if (dialog.Response != string.Empty && comboBoxProfiles.Items.Cast<ProfileItem>().All(items => items.Name != dialog.Response))
                {
                    break;
                }

            }

            if (dialog.DialogResult == DialogResult.Cancel)
                return;

            ProfileItem item = new ProfileItem { Name = dialog.Response, DataFolder = _defaultFolder + " " + dialog.Response };
            comboBoxProfiles.Items.Add(item);
            comboBoxProfiles.SelectedIndex = comboBoxProfiles.Items.Count - 1;
            PopulateLoadProfileSection(false);
        }
Exemplo n.º 10
0
        private void buttonOK_Click(object sender, EventArgs e)
        {
            XMLProfileSettings profile = new XMLProfileSettings();

            SaveCurrentItem();
            profile.PutSetting("Profiles/ProfileCount", comboBoxProfiles.Items.Count);
            for (int i = 0; i < comboBoxProfiles.Items.Count; i++)
            {
                ProfileItem item = comboBoxProfiles.Items[i] as ProfileItem;
                profile.PutSetting("Profiles/" + "Profile" + i.ToString() + "/Name", item.Name);
                profile.PutSetting("Profiles/" + "Profile" + i.ToString() + "/DataFolder", item.DataFolder);
            }

            if (radioButtonAskMe.Checked)
            {
                profile.PutSetting("Profiles/LoadAction", "Ask");
            }
            else
            {
                profile.PutSetting("Profiles/LoadAction", "LoadSelected");
            }

            if (comboBoxLoadThisProfile.SelectedIndex >= 0)
            {
                profile.PutSetting("Profiles/ProfileToLoad", comboBoxLoadThisProfile.SelectedIndex);
            }

            DialogResult = System.Windows.Forms.DialogResult.OK;

            Close();
        }
Exemplo n.º 11
0
 private void buttonAddProfile_Click(object sender, EventArgs e)
 {
     SaveCurrentItem();
     ProfileItem item = new ProfileItem();
     item.Name = "New Profile";
     item.DataFolder = defaultFolder;
     comboBoxProfiles.Items.Add(item);
     comboBoxProfiles.SelectedIndex = comboBoxProfiles.Items.Count - 1;
     PopulateLoadProfileSection(false);
 }
Exemplo n.º 12
0
 private void LoadSelectedProfile()
 {
     if (listBoxProfiles.SelectedIndex >= 0)
     {
         ProfileItem item = listBoxProfiles.SelectedItem as ProfileItem;
         DataFolder   = item.DataFolder;
         DialogResult = System.Windows.Forms.DialogResult.OK;
         Close();
     }
 }
Exemplo n.º 13
0
        private void buttonAddProfile_Click(object sender, EventArgs e)
        {
            SaveCurrentItem();
            ProfileItem item = new ProfileItem();

            item.Name       = "New Profile";
            item.DataFolder = defaultFolder;
            comboBoxProfiles.Items.Add(item);
            comboBoxProfiles.SelectedIndex = comboBoxProfiles.Items.Count - 1;
            PopulateLoadProfileSection(false);
        }
Exemplo n.º 14
0
        private void PopulateProfileSettings()
        {
            SaveCurrentItem();
            ProfileItem item = comboBoxProfiles.SelectedItem as ProfileItem;

            if (item != null)
            {
                textBoxProfileName.Text = item.Name;
                textBoxDataFolder.Text  = item.DataFolder;
            }
            _currentItem = item;
        }
Exemplo n.º 15
0
        private void SelectProfile_Load(object sender, EventArgs e)
        {
            XMLProfileSettings profile = new XMLProfileSettings();

            int profileCount = profile.GetSetting("Profiles/ProfileCount", 0);
            for (int i = 0; i < profileCount; i++) {
                ProfileItem item = new ProfileItem();
                item.Name = profile.GetSetting("Profiles/" + "Profile" + i.ToString() + "/Name", "New Profile");
                item.DataFolder = profile.GetSetting("Profiles/" + "Profile" + i.ToString() + "/DataFolder", string.Empty);
                listBoxProfiles.Items.Add(item);
            }
        }
Exemplo n.º 16
0
        private void SelectProfile_Load(object sender, EventArgs e)
        {
            XMLProfileSettings profile = new XMLProfileSettings();

            int profileCount = profile.GetSetting("Profiles/ProfileCount", 0);

            for (int i = 0; i < profileCount; i++)
            {
                ProfileItem item = new ProfileItem();
                item.Name       = profile.GetSetting("Profiles/" + "Profile" + i.ToString() + "/Name", "New Profile");
                item.DataFolder = profile.GetSetting("Profiles/" + "Profile" + i.ToString() + "/DataFolder", "");
                listBoxProfiles.Items.Add(item);
            }
        }
Exemplo n.º 17
0
        private void LoadSelectedProfile()
        {
            if (listBoxProfiles.SelectedIndex >= 0)
            {
                ProfileItem item = listBoxProfiles.SelectedItem as ProfileItem;
                DataFolder    = item.DataFolder;
                ProfileName   = item.Name;
                ProfileNumber = item.ProfileNumber;

                XMLProfileSettings profile = new XMLProfileSettings();
                profile.PutSetting(XMLProfileSettings.SettingType.Profiles, "Profile" + ProfileNumber.ToString() + "/DateLastLoaded", DateTime.Now);
                DialogResult = System.Windows.Forms.DialogResult.OK;
                Close();
            }
        }
Exemplo n.º 18
0
        private void PopulateProfileList()
        {
            XMLProfileSettings profile = new XMLProfileSettings();

            //Make sure we start with an empty listbox since we may repopulate after editing profiles
            listBoxProfiles.Items.Clear();
            int profileCount = profile.GetSetting(XMLProfileSettings.SettingType.Profiles, "ProfileCount", 0);
            for (int i = 0; i < profileCount; i++)
            {
                ProfileItem item = new ProfileItem();
                item.Name = profile.GetSetting(XMLProfileSettings.SettingType.Profiles, "Profile" + i.ToString() + "/Name", "New Profile");
                item.DataFolder = profile.GetSetting(XMLProfileSettings.SettingType.Profiles, "Profile" + i.ToString() + "/DataFolder", string.Empty);
                listBoxProfiles.Items.Add(item);
            }
        }
Exemplo n.º 19
0
        // ComboBox Items don't update themselves when they're changed in the list.
        // This is my simple work-around. Just drawing the thing myself!
        private void comboBox_DrawItem(object sender, DrawItemEventArgs e)
        {
            ComboBox c = sender as ComboBox;

            if (e.Index > -1)
            {
                ProfileItem item = c.Items[e.Index] as ProfileItem;
                e.Graphics.FillRectangle(e.State == DrawItemState.Focus ? Brushes.Blue : new SolidBrush(e.BackColor), e.Bounds);
                e.Graphics.DrawString(item.Name, SystemFonts.DefaultFont, Brushes.Black, e.Bounds);
            }
            else
            {
                e.Graphics.FillRectangle(new SolidBrush(c.BackColor), e.Bounds);
            }
        }
Exemplo n.º 20
0
        private void PopulateProfileList()
        {
            XMLProfileSettings profile = new XMLProfileSettings();

            //Make sure we start with an empty listbox since we may repopulate after editing profiles
            listBoxProfiles.Items.Clear();
            int profileCount = profile.GetSetting(XMLProfileSettings.SettingType.Profiles, "ProfileCount", 0);

            for (int i = 0; i < profileCount; i++)
            {
                ProfileItem item = new ProfileItem();
                item.Name       = profile.GetSetting(XMLProfileSettings.SettingType.Profiles, "Profile" + i.ToString() + "/Name", "New Profile");
                item.DataFolder = profile.GetSetting(XMLProfileSettings.SettingType.Profiles, "Profile" + i.ToString() + "/DataFolder", string.Empty);
                listBoxProfiles.Items.Add(item);
            }
        }
Exemplo n.º 21
0
        private void buttonDeleteProfile_Click(object sender, EventArgs e)
        {
            ProfileItem item = comboBoxProfiles.SelectedItem as ProfileItem;

            if (item != null)
            {
                if (MessageBox.Show("Are you sure you want to delete this profile? The data folder and all its contents will remain and must be removed manually.", "Delete a Profile", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning) == System.Windows.Forms.DialogResult.Yes)
                {
                    comboBoxProfiles.Items.Remove(item);
                    if (comboBoxProfiles.Items.Count > 0)
                    {
                        comboBoxProfiles.SelectedIndex = 0;
                    }
                    PopulateLoadProfileSection(false);
                }
            }
        }
Exemplo n.º 22
0
        private void buttonAddProfile_Click(object sender, EventArgs e)
        {
            SaveCurrentItem();

            TextDialog dialog = new TextDialog("Enter a name for the new profile", "Profile Name", "New Profile");

            while (dialog.ShowDialog() == DialogResult.OK)
            {
                if (dialog.Response == string.Empty)
                {
                    //messageBox Arguments are (Text, Title, No Button Visible, Cancel Button Visible)
                    MessageBoxForm.msgIcon = SystemIcons.Error;                     //this is used if you want to add a system icon to the message form.
                    var messageBox = new MessageBoxForm("Profile name can not be blank.",
                                                        "Error", false, false);
                    messageBox.ShowDialog();
                }

                if (comboBoxProfiles.Items.Cast <ProfileItem>().Any(items => items.Name == dialog.Response))
                {
                    //messageBox Arguments are (Text, Title, No Button Visible, Cancel Button Visible)
                    MessageBoxForm.msgIcon = SystemIcons.Warning;                     //this is used if you want to add a system icon to the message form.
                    var messageBox = new MessageBoxForm("A profile with the name " + dialog.Response + @" already exists.", "", false, false);
                    messageBox.ShowDialog();
                }

                if (dialog.Response != string.Empty && comboBoxProfiles.Items.Cast <ProfileItem>().All(items => items.Name != dialog.Response))
                {
                    break;
                }
            }

            if (dialog.DialogResult == DialogResult.Cancel)
            {
                return;
            }

            ProfileItem item = new ProfileItem {
                Name = dialog.Response, DataFolder = _defaultFolder + " " + dialog.Response
            };

            comboBoxProfiles.Items.Add(item);
            comboBoxProfiles.SelectedIndex = comboBoxProfiles.Items.Count - 1;
            PopulateLoadProfileSection(false);
        }
Exemplo n.º 23
0
        private void buttonAddProfile_Click(object sender, EventArgs e)
        {
            SaveCurrentItem();

            TextDialog dialog = new TextDialog("Enter a name for the new profile","Profile Name","New Profile");

            while (dialog.ShowDialog() == DialogResult.OK)
            {
                if (dialog.Response == string.Empty)
                {
                    //messageBox Arguments are (Text, Title, No Button Visible, Cancel Button Visible)
                    MessageBoxForm.msgIcon = SystemIcons.Error; //this is used if you want to add a system icon to the message form.
                    var messageBox = new MessageBoxForm("Profile name can not be blank.",
                        "Error", false, false);
                    messageBox.ShowDialog();
                }

                if (comboBoxProfiles.Items.Cast<ProfileItem>().Any(items => items.Name == dialog.Response))
                {
                    //messageBox Arguments are (Text, Title, No Button Visible, Cancel Button Visible)
                    MessageBoxForm.msgIcon = SystemIcons.Warning; //this is used if you want to add a system icon to the message form.
                    var messageBox = new MessageBoxForm("A profile with the name " + dialog.Response + @" already exists.", "", false, false);
                    messageBox.ShowDialog();
                }

                if (dialog.Response != string.Empty && comboBoxProfiles.Items.Cast<ProfileItem>().All(items => items.Name != dialog.Response))
                {
                    break;
                }

            }

            if (dialog.DialogResult == DialogResult.Cancel)
                return;

            ProfileItem item = new ProfileItem { Name = dialog.Response, DataFolder = _defaultFolder + " " + dialog.Response };
            comboBoxProfiles.Items.Add(item);
            comboBoxProfiles.SelectedIndex = comboBoxProfiles.Items.Count - 1;
            PopulateLoadProfileSection(false);
        }
Exemplo n.º 24
0
        private void PopulateLoadProfileSection(bool firstTime)
        {
            XMLProfileSettings profile = new XMLProfileSettings();

            radioButtonAskMe.Checked           = (profile.GetSetting(XMLProfileSettings.SettingType.Profiles, "LoadAction", "LoadSelected") == "Ask");
            radioButtonLoadThisProfile.Checked = (!radioButtonAskMe.Checked);

            ProfileItem selectedItem = comboBoxLoadThisProfile.SelectedItem as ProfileItem;

            comboBoxLoadThisProfile.Items.Clear();

            if (comboBoxProfiles.Items.Count == 0)
            {
                return;
            }

            foreach (ProfileItem item in comboBoxProfiles.Items)
            {
                comboBoxLoadThisProfile.Items.Add(item);
            }

            if (firstTime)
            {
                if (radioButtonLoadThisProfile.Checked)
                {
                    int loadItemNum = profile.GetSetting(XMLProfileSettings.SettingType.Profiles, "ProfileToLoad", 0);
                    if (loadItemNum < comboBoxLoadThisProfile.Items.Count)
                    {
                        comboBoxLoadThisProfile.SelectedIndex = loadItemNum;
                    }
                }
            }
            else
            // If the combo box was already populated, we want to select the same item.
            if (selectedItem != null && comboBoxLoadThisProfile.Items.Contains(selectedItem))
            {
                comboBoxLoadThisProfile.SelectedItem = selectedItem;
            }
        }
Exemplo n.º 25
0
        private void PopulateProfileList()
        {
            XMLProfileSettings profile = new XMLProfileSettings();

            int profileCount = profile.GetSetting("Profiles/ProfileCount", 0);

            if (profileCount == 0)
            {
                MessageBox.Show("Unable to locate any profiles.");
                return;
            }
            else
            {
                for (int i = 0; i < profileCount; i++)
                {
                    ProfileItem item = new ProfileItem();
                    item.Name       = profile.GetSetting("Profiles/" + "Profile" + i.ToString() + "/Name", "");
                    item.DataFolder = profile.GetSetting("Profiles/" + "Profile" + i.ToString() + "/DataFolder", "");
                    comboBoxProfiles.Items.Add(item);
                }
            }
            comboBoxProfiles.SelectedIndex = 0;
        }
Exemplo n.º 26
0
        private void buttonAddProfile_Click(object sender, EventArgs e)
        {
            SaveCurrentItem();

            TextDialog dialog = new TextDialog("Enter a name for the new profile", "Profile Name", "New Profile");

            while (dialog.ShowDialog() == DialogResult.OK)
            {
                if (dialog.Response == string.Empty)
                {
                    MessageBox.Show(@"Profile name can not be blank.");
                }

                if (comboBoxProfiles.Items.Cast <ProfileItem>().Any(items => items.Name == dialog.Response))
                {
                    MessageBox.Show(@"A profile with the name " + dialog.Response + @" already exists.");
                }

                if (dialog.Response != string.Empty && comboBoxProfiles.Items.Cast <ProfileItem>().All(items => items.Name != dialog.Response))
                {
                    break;
                }
            }

            if (dialog.DialogResult == DialogResult.Cancel)
            {
                return;
            }

            ProfileItem item = new ProfileItem {
                Name = dialog.Response, DataFolder = _defaultFolder + " " + dialog.Response
            };

            comboBoxProfiles.Items.Add(item);
            comboBoxProfiles.SelectedIndex = comboBoxProfiles.Items.Count - 1;
            PopulateLoadProfileSection(false);
        }
Exemplo n.º 27
0
        private void buttonCreateZip_Click(object sender, EventArgs e)
        {
            if (textBoxSaveFolder.Text == "")
            {
                MessageBox.Show("Please choose a folder to create the zip file in.", "Missing save folder");
                return;
            }
            if (textBoxFileName.Text == "")
            {
                MessageBox.Show("Please choose a filename for the zip file.", "Missing Zip file name");
                return;
            }
            ProfileItem item = comboBoxProfiles.SelectedItem as ProfileItem;

            if (item == null)
            {
                //Oops.. Get outta here
                MessageBox.Show("Unable to find datafolder for that profile.", "Error");
                return;
            }

            string profileName = item.Name;
            string folderName  = item.DataFolder;
            string outPath     = textBoxSaveFolder.Text + "\\" + textBoxFileName.Text + ".zip";

            if (System.IO.File.Exists(outPath))
            {
                if (MessageBox.Show("The file name you have enter already exists, do you wish to overwrite it ?", "File exists", MessageBoxButtons.YesNo) == DialogResult.No)
                {
                    return;
                }
            }

            if (!Directory.Exists(textBoxSaveFolder.Text))
            {
                if (MessageBox.Show("The destination folder does not exists, would you like to create it ?", "Folder not found", MessageBoxButtons.YesNo) == DialogResult.No)
                {
                    return;
                }
                else
                {
                    Directory.CreateDirectory(textBoxSaveFolder.Text);
                }
            }

            toolStripStatusLabel.Text    = "Zipping Data please wait...";
            Cursor.Current               = Cursors.WaitCursor;
            toolStripProgressBar.Visible = true;
            buttonCreateZip.Enabled      = false;
            Application.DoEvents();

            FileStream      fsOut     = File.Create(outPath);
            ZipOutputStream zipStream = new ZipOutputStream(fsOut);

            zipStream.SetLevel(3);
            //zipStream.Password = "******";
            int    folderOffset    = folderName.Length + (folderName.EndsWith("\\") ? 0 : 1);
            String AppDataFolder   = System.Environment.GetFolderPath(System.Environment.SpecialFolder.ApplicationData) + "\\Vixen";
            int    AppFolderOffSet = AppDataFolder.Length + (AppDataFolder.EndsWith("\\") ? 0 : 1);
            String LogDataFolder   = System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments) + "\\Vixen 3\\logs";
            int    LogFolderOffSet = LogDataFolder.Length + (LogDataFolder.EndsWith("\\") ? 0 : 1);

            if (radioButtonZipEverything.Checked)
            {
                CompressFolder(folderName, zipStream, folderOffset);
                //Now Get the files from the AppData Folder
                CompressFolder(AppDataFolder, zipStream, AppFolderOffSet - 7, false);
                //Now Get the files from the Log folder
                CompressFolder(LogDataFolder, zipStream, LogFolderOffSet - 6, false);
            }
            else
            {
                if (checkBoxApplication.Checked)
                {
                    folderName = item.DataFolder;
                    CompressFolder(folderName, zipStream, folderOffset, false);
                    //Now Get the files from the AppData Folder
                    CompressFolder(AppDataFolder, zipStream, AppFolderOffSet - 7, false);
                    //Now Get the files from the Log folder
                    CompressFolder(LogDataFolder, zipStream, LogFolderOffSet - 6, false);
                }
                if (checkBoxModule.Checked)
                {
                    folderName = item.DataFolder + "\\Module Data Files";
                    CompressFolder(folderName, zipStream, folderOffset);
                }
                if (checkBoxProgram.Checked)
                {
                    folderName = item.DataFolder + "\\Program";
                    CompressFolder(folderName, zipStream, folderOffset);
                }
                if (checkBoxSequence.Checked)
                {
                    folderName = item.DataFolder + "\\Sequence";
                    CompressFolder(folderName, zipStream, folderOffset);
                }
                if (checkBoxSystem.Checked)
                {
                    folderName = item.DataFolder + "\\SystemData";
                    CompressFolder(folderName, zipStream, folderOffset);
                }
                if (checkBoxSystem.Checked)
                {
                    folderName = item.DataFolder + "\\Template";
                    CompressFolder(folderName, zipStream, folderOffset);
                }
            }

            zipStream.IsStreamOwner = true;
            zipStream.Close();
            toolStripStatusLabel.Text    = "Zip File Created";
            Cursor.Current               = Cursors.Default;
            toolStripProgressBar.Visible = false;
            buttonCreateZip.Enabled      = true;
        }
Exemplo n.º 28
0
        private void buttonOK_Click(object sender, EventArgs e)
        {
            XMLProfileSettings profile         = new XMLProfileSettings();
            List <string>      checkName       = new List <string>();
            List <string>      checkDataFolder = new List <string>();
            List <string>      duplicateItems  = new List <string>();
            List <string>      checkDataPath   = new List <string>();
            bool duplicateName       = false;
            bool duplicateDataFolder = false;
            bool invalidDataPath     = false;

            //Check for null values, duplicate profile name or datapath and non rooted datapath
            foreach (ProfileItem item in comboBoxProfiles.Items)
            {
                if (item.Name == null || item.DataFolder == null)
                {
                    //messageBox Arguments are (Text, Title, No Button Visible, Cancel Button Visible)
                    MessageBoxForm.msgIcon = SystemIcons.Warning;                     //this is used if you want to add a system icon to the message form.
                    var messageBox = new MessageBoxForm("One or more of your profile entries has a blank name or data folder. You must correct this before continuing.",
                                                        @"Warning - Blank Entries", false, false);
                    messageBox.ShowDialog();
                }

                if (checkName.Contains(item.Name))
                {
                    duplicateName = true;
                    duplicateItems.Add(item.Name + ":\t " + item.DataFolder);
                }
                checkName.Add(item.Name);

                if (checkDataFolder.Contains(item.DataFolder))
                {
                    duplicateDataFolder = true;
                    duplicateItems.Add(item.Name + ":\t " + item.DataFolder);
                }

                checkDataFolder.Add(item.DataFolder);

                if (!Path.IsPathRooted(item.DataFolder) || !item.DataFolder.Contains(@"\"))
                {
                    invalidDataPath = true;
                    checkDataPath.Add(item.Name + ":\t " + item.DataFolder);
                }
            }

            if (duplicateName || duplicateDataFolder)
            {
                //Not pretty here, but works well on the dialog
                //messageBox Arguments are (Text, Title, No Button Visible, Cancel Button Visible)
                MessageBoxForm.msgIcon = SystemIcons.Warning;                 //this is used if you want to add a system icon to the message form.
                var messageBox = new MessageBoxForm("A duplicate profile name, or data path exists." + Environment.NewLine + Environment.NewLine +
                                                    @"The duplicate items found were:" + Environment.NewLine + Environment.NewLine + string.Join(Environment.NewLine, duplicateItems) + Environment.NewLine + Environment.NewLine +
                                                    @"Click OK to accept and contine, or Cancel to go back and edit.",
                                                    @"Warning - Duplicate Entries", false, true);
                messageBox.ShowDialog();

                if (messageBox.DialogResult != DialogResult.OK)
                {
                    DialogResult = DialogResult.None;
                    return;
                }
            }

            if (invalidDataPath)
            {
                //messageBox Arguments are (Text, Title, No Button Visible, Cancel Button Visible)
                MessageBoxForm.msgIcon = SystemIcons.Warning;                 //this is used if you want to add a system icon to the message form.
                var messageBox = new MessageBoxForm("An invalid profile data folder exists." + Environment.NewLine + Environment.NewLine +
                                                    @"The items with invalid paths were:" + Environment.NewLine + Environment.NewLine + string.Join(Environment.NewLine, checkDataPath) + Environment.NewLine + Environment.NewLine +
                                                    @"Click OK to accept and contine, or Cancel to go back and edit.",
                                                    @"Warning - Invalid Data Path", false, true);
                messageBox.ShowDialog();

                if (messageBox.DialogResult != DialogResult.OK)
                {
                    DialogResult = DialogResult.None;
                    return;
                }
            }

            SaveCurrentItem();
            profile.PutSetting(XMLProfileSettings.SettingType.Profiles, "ProfileCount", comboBoxProfiles.Items.Count);
            for (int i = 0; i < comboBoxProfiles.Items.Count; i++)
            {
                ProfileItem item = comboBoxProfiles.Items[i] as ProfileItem;
                profile.PutSetting(XMLProfileSettings.SettingType.Profiles, "Profile" + i + "/Name", item.Name);
                profile.PutSetting(XMLProfileSettings.SettingType.Profiles, "Profile" + i + "/DataFolder", item.DataFolder);
                if (!Directory.Exists(item.DataFolder))
                {
                    //messageBox Arguments are (Text, Title, No Button Visible, Cancel Button Visible)
                    MessageBoxForm.msgIcon = SystemIcons.Exclamation;                     //this is used if you want to add a system icon to the message form.
                    var messageBox = new MessageBoxForm("The data directory '" + item.DataFolder + "' for profile '" + item.Name + "' does not exist.  Would you like to create it?",
                                                        Application.ProductName, true, false);
                    messageBox.ShowDialog();
                    if (messageBox.DialogResult == DialogResult.OK)
                    {
                        try
                        {
                            Directory.CreateDirectory(item.DataFolder);
                        }
                        catch (Exception)
                        {
                            //messageBox Arguments are (Text, Title, No Button Visible, Cancel Button Visible)
                            MessageBoxForm.msgIcon = SystemIcons.Error;                             //this is used if you want to add a system icon to the message form.
                            messageBox             = new MessageBoxForm("Could not create new profile directory: " + item.DataFolder + Environment.NewLine + Environment.NewLine +
                                                                        "Click OK to ignore and continue, or Cancel to go back and edit.",
                                                                        "Error", false, true);
                            messageBox.ShowDialog();
                            if (messageBox.DialogResult == DialogResult.Cancel)
                            {
                                DialogResult = DialogResult.None;
                                return;
                            }
                        }
                    }
                }
            }

            profile.PutSetting(XMLProfileSettings.SettingType.Profiles, "LoadAction",
                               radioButtonAskMe.Checked ? "Ask" : "LoadSelected");

            if (comboBoxLoadThisProfile.SelectedIndex >= 0)
            {
                profile.PutSetting(XMLProfileSettings.SettingType.Profiles, "ProfileToLoad", comboBoxLoadThisProfile.SelectedIndex);
            }

            DialogResult = DialogResult.OK;
            Close();
        }
Exemplo n.º 29
0
        private void PopulateProfileList()
        {
            XMLProfileSettings profile = new XMLProfileSettings();

            int profileCount = profile.GetSetting("Profiles/ProfileCount", 0);
            if (profileCount == 0) {
                ProfileItem item = new ProfileItem();
                item.Name = "Default";
                item.DataFolder = defaultFolder;
                comboBoxProfiles.Items.Add(item);
            }
            else {
                for (int i = 0; i < profileCount; i++) {
                    ProfileItem item = new ProfileItem();
                    item.Name = profile.GetSetting("Profiles/" + "Profile" + i.ToString() + "/Name", "New Profile");
                    item.DataFolder = profile.GetSetting("Profiles/" + "Profile" + i.ToString() + "/DataFolder", defaultFolder);
                    comboBoxProfiles.Items.Add(item);
                }
            }
            comboBoxProfiles.SelectedIndex = 0;
        }
Exemplo n.º 30
0
        private void PopulateProfileList()
        {
            var profile = new XMLProfileSettings();

            int profileCount = profile.GetSetting(XMLProfileSettings.SettingType.Profiles, "ProfileCount", 0);
            if (profileCount == 0)
            {
                var item = new ProfileItem
                {
                    Name = "Default",
                    DataFolder = DataProfileForm.DefaultFolder
                };
                comboBoxProfiles.Items.Add(item);
            }
            else
            {
                for (int i = 0; i < profileCount; i++)
                {
                    var item = new ProfileItem
                    {
                        Name = profile.GetSetting(XMLProfileSettings.SettingType.Profiles, "Profile" + i.ToString() + "/Name", ""),
                        DataFolder =
                            profile.GetSetting(XMLProfileSettings.SettingType.Profiles, "Profile" + i.ToString() + "/DataFolder", "")
                    };
                    comboBoxProfiles.Items.Add(item);
                }
            }
            comboBoxProfiles.SelectedIndex = 0;
            textBoxFileName.Text=@"VixenProfile";
            textBoxSaveFolder.Text = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
        }
Exemplo n.º 31
0
        private void PopulateProfileList()
        {
            XMLProfileSettings profile = new XMLProfileSettings();

            //Make sure we start with an empty listbox since we may repopulate after editing profiles
            listBoxProfiles.Items.Clear();
            int profileCount = profile.GetSetting(XMLProfileSettings.SettingType.Profiles, "ProfileCount", 0);
            for (int i = 0; i < profileCount; i++)
            {
                var dataFolder = profile.GetSetting(XMLProfileSettings.SettingType.Profiles, "Profile" + i.ToString() + "/DataFolder", string.Empty);
                if (!VixenApplication.IsProfileLocked(dataFolder)) //Only add the profile if it is not locked.
                {
                    ProfileItem item = new ProfileItem();
                    item.Name = profile.GetSetting(XMLProfileSettings.SettingType.Profiles, "Profile" + i.ToString() + "/Name",
                        "New Profile");
                    item.DataFolder = dataFolder;
                    listBoxProfiles.Items.Add(item);
                }
            }
        }
Exemplo n.º 32
0
		private void PopulateProfileList()
		{
			var profile = new XMLProfileSettings();

			int profileCount = profile.GetSetting(XMLProfileSettings.SettingType.Profiles, "ProfileCount", 0);
			if (profileCount == 0)
			{
				MessageBox.Show(@"Unable to locate any profiles.");
				return;
			}

			for (int i = 0; i < profileCount; i++)
			{
				var item = new ProfileItem
				{
					Name = profile.GetSetting(XMLProfileSettings.SettingType.Profiles, "Profile" + i.ToString() + "/Name", ""),
					DataFolder =
						profile.GetSetting(XMLProfileSettings.SettingType.Profiles, "Profile" + i.ToString() + "/DataFolder", "")
				};
				comboBoxProfiles.Items.Add(item);
			}
			comboBoxProfiles.SelectedIndex = 0;
			textBoxFileName.Text=@"VixenProfile";
			textBoxSaveFolder.Text = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
		}
Exemplo n.º 33
0
        private void buttonStartCancel_Click(object sender, EventArgs e)
        {
            if (_working)
            {
                _bw.CancelAsync();
                return;
            }
            _item = comboBoxProfiles.SelectedItem as ProfileItem;
            if (_item == null)
            {
                //Oops.. Get outta here
                //messageBox Arguments are (Text, Title, No Button Visible, Cancel Button Visible)
                MessageBoxForm.msgIcon = SystemIcons.Error;                 //this is used if you want to add a system icon to the message form.
                var messageBox = new MessageBoxForm("Unable to find datafolder for that profile.", @"Error", false, false);
                messageBox.ShowDialog();
                return;
            }

            if (textBoxSaveFolder.Text == "")
            {
                //messageBox Arguments are (Text, Title, No Button Visible, Cancel Button Visible)
                MessageBoxForm.msgIcon = SystemIcons.Error;                 //this is used if you want to add a system icon to the message form.
                var messageBox = new MessageBoxForm("Please choose a folder to create the zip file in.", @"Missing save folder", false, false);
                messageBox.ShowDialog();
                return;
            }

            var invalidChars = Path.GetInvalidPathChars();

            if (textBoxSaveFolder.Text.Any(s => invalidChars.Contains(s)))
            {
                var messageBox = new MessageBoxForm("The folder path for the zip file contains invalid characters.", @"Invalid Folder Path.", MessageBoxButtons.OK, SystemIcons.Error);
                messageBox.ShowDialog();
                return;
            }

            if (textBoxFileName.Text == "")
            {
                //messageBox Arguments are (Text, Title, No Button Visible, Cancel Button Visible)
                MessageBoxForm.msgIcon = SystemIcons.Information;                 //this is used if you want to add a system icon to the message form.
                var messageBox = new MessageBoxForm("Please choose a filename for the zip file.", @"Missing Zip file name", false, false);
                messageBox.ShowDialog();
                return;
            }

            invalidChars = Path.GetInvalidFileNameChars();
            if (textBoxFileName.Text.Any(s => invalidChars.Contains(s)))
            {
                var messageBox = new MessageBoxForm("The filename for the zip file contains invalid characters.", @"Invalid Zip file name", MessageBoxButtons.OK, SystemIcons.Error);
                messageBox.ShowDialog();
                return;
            }

            if (".zip".Equals(Path.GetExtension(textBoxFileName.Text)))
            {
                textBoxFileName.Text = Path.GetFileNameWithoutExtension(textBoxFileName.Text);
            }

            string outPath = Path.Combine(textBoxSaveFolder.Text, textBoxFileName.Text + ".zip");

            if (!Directory.Exists(textBoxSaveFolder.Text))
            {
                //messageBox Arguments are (Text, Title, No Button Visible, Cancel Button Visible)
                MessageBoxForm.msgIcon = SystemIcons.Question;                 //this is used if you want to add a system icon to the message form.
                var messageBox = new MessageBoxForm("The destination folder does not exist, would you like to create it ?", @"Folder not found", true, false);
                messageBox.ShowDialog();
                if (messageBox.DialogResult == DialogResult.No)
                {
                    return;
                }

                Directory.CreateDirectory(textBoxSaveFolder.Text);
            }
            else if (File.Exists(outPath))
            {
                //messageBox Arguments are (Text, Title, No Button Visible, Cancel Button Visible)
                MessageBoxForm.msgIcon = SystemIcons.Question;                 //this is used if you want to add a system icon to the message form.
                var messageBox = new MessageBoxForm("The file name you have enter already exists, do you wish to overwrite it ?", @"File exists", true, false);
                messageBox.ShowDialog();
                if (messageBox.DialogResult == DialogResult.OK)
                {
                    File.Delete(outPath);
                }
                else
                {
                    return;
                }
            }

            buttonStartCancel.Text = "Stop";
            buttonClose.Enabled    = false;
            _bw.RunWorkerAsync();
        }
Exemplo n.º 34
0
        private void buttonOK_Click(object sender, EventArgs e)
        {
            XMLProfileSettings profile         = new XMLProfileSettings();
            List <string>      checkName       = new List <string>();
            List <string>      checkDataFolder = new List <string>();
            bool duplicateName       = false;
            bool duplicateDataFolder = false;

            SaveCurrentItem();
            profile.PutSetting("Profiles/ProfileCount", comboBoxProfiles.Items.Count);
            for (int i = 0; i < comboBoxProfiles.Items.Count; i++)
            {
                ProfileItem item = comboBoxProfiles.Items[i] as ProfileItem;
                profile.PutSetting("Profiles/" + "Profile" + i.ToString() + "/Name", item.Name);
                profile.PutSetting("Profiles/" + "Profile" + i.ToString() + "/DataFolder", item.DataFolder);
                //We're getting out of here and expect a restart by user, if the specified DataFolder doesn't exist, we should create it.

                if (item.DataFolder != string.Empty)
                {
                    if (!System.IO.Directory.Exists(item.DataFolder))
                    {
                        System.IO.Directory.CreateDirectory(item.DataFolder);
                    }
                }
                if (checkName.Contains(item.Name))
                {
                    duplicateName = true;
                }
                checkName.Add(item.Name);
                if (checkDataFolder.Contains(item.DataFolder))
                {
                    duplicateDataFolder = true;
                }
                checkDataFolder.Add(item.DataFolder);
            }

            if (radioButtonAskMe.Checked)
            {
                profile.PutSetting("Profiles/LoadAction", "Ask");
            }
            else
            {
                profile.PutSetting("Profiles/LoadAction", "LoadSelected");
            }

            if (comboBoxLoadThisProfile.SelectedIndex >= 0)
            {
                profile.PutSetting("Profiles/ProfileToLoad", comboBoxLoadThisProfile.SelectedIndex);
            }

            //If a duplicate entry is found, we will prompt the user to contine on, or cancel and edit. This could be done with one bool, but in the event that we want to
            //be more specific about things in the future, Ill leave it the way it is for now.
            if (duplicateName || duplicateDataFolder)
            {
                if (MessageBox.Show("Duplicate profile entries were found. A duplicate profile name, or data path exists. Click OK to accept and contine, or Cancel to go back and edit.", "Warning", MessageBoxButtons.OKCancel) == DialogResult.OK)
                {
                    DialogResult = System.Windows.Forms.DialogResult.OK;
                    Close();
                }
                else
                {
                    //Too late to cancel without changes, lets not give false hope.
                    buttonCancel.Enabled = false;
                    DialogResult         = System.Windows.Forms.DialogResult.None;
                }
            }
            else
            {
                DialogResult = System.Windows.Forms.DialogResult.OK;
                Close();
            }
        }
Exemplo n.º 35
0
        private void PopulateProfileList()
        {
            XMLProfileSettings profile = new XMLProfileSettings();

            int profileCount = profile.GetSetting(XMLProfileSettings.SettingType.Profiles, "ProfileCount", 0);
            if (profileCount == 0)
            {
                ProfileItem item = new ProfileItem {Name = "Default", DataFolder = _defaultFolder};
                comboBoxProfiles.Items.Add(item);
            }
            else
            {
                for (int i = 0; i < profileCount; i++)
                {
                    ProfileItem item = new ProfileItem
                    {
                        Name = profile.GetSetting(XMLProfileSettings.SettingType.Profiles, "Profile" + i + "/Name", "New Profile"),
                        DataFolder = profile.GetSetting(XMLProfileSettings.SettingType.Profiles, "Profile" + i + "/DataFolder", _defaultFolder)
                    };
                    comboBoxProfiles.Items.Add(item);
                }
            }
            comboBoxProfiles.SelectedIndex = 0;
        }
Exemplo n.º 36
0
        private void buttonStartCancel_Click(object sender, EventArgs e)
        {
            if (_working)
            {
                _bw.CancelAsync();
                return;
            }
            _item = comboBoxProfiles.SelectedItem as ProfileItem;
            if (_item == null)
            {
                //Oops.. Get outta here
                //messageBox Arguments are (Text, Title, No Button Visible, Cancel Button Visible)
                MessageBoxForm.msgIcon = SystemIcons.Error; //this is used if you want to add a system icon to the message form.
                var messageBox = new MessageBoxForm("Unable to find datafolder for that profile.", @"Error", false, false);
                messageBox.ShowDialog();
                return;
            }

            if (textBoxSaveFolder.Text == "")
            {
                //messageBox Arguments are (Text, Title, No Button Visible, Cancel Button Visible)
                MessageBoxForm.msgIcon = SystemIcons.Error; //this is used if you want to add a system icon to the message form.
                var messageBox = new MessageBoxForm("Please choose a folder to create the zip file in.", @"Missing save folder", false, false);
                messageBox.ShowDialog();
                return;
            }
            if (textBoxFileName.Text == "")
            {
                //messageBox Arguments are (Text, Title, No Button Visible, Cancel Button Visible)
                MessageBoxForm.msgIcon = SystemIcons.Information; //this is used if you want to add a system icon to the message form.
                var messageBox = new MessageBoxForm("Please choose a filename for the zip file.", @"Missing Zip file name", false, false);
                messageBox.ShowDialog();
                return;
            }

            if (".zip".Equals(Path.GetExtension(textBoxFileName.Text)))
            {
                textBoxFileName.Text = Path.GetFileNameWithoutExtension(textBoxFileName.Text);
            }

            string outPath = Path.Combine(textBoxSaveFolder.Text, textBoxFileName.Text + ".zip");

            if (!Directory.Exists(textBoxSaveFolder.Text))
            {
                //messageBox Arguments are (Text, Title, No Button Visible, Cancel Button Visible)
                MessageBoxForm.msgIcon = SystemIcons.Question; //this is used if you want to add a system icon to the message form.
                var messageBox = new MessageBoxForm("The destination folder does not exist, would you like to create it ?", @"Folder not found", true, false);
                messageBox.ShowDialog();
                if (messageBox.DialogResult == DialogResult.No)
                {
                    return;
                }

                Directory.CreateDirectory(textBoxSaveFolder.Text);
            }
            else if (File.Exists(outPath))
            {
                //messageBox Arguments are (Text, Title, No Button Visible, Cancel Button Visible)
                MessageBoxForm.msgIcon = SystemIcons.Question; //this is used if you want to add a system icon to the message form.
                var messageBox = new MessageBoxForm("The file name you have enter already exists, do you wish to overwrite it ?", @"File exists", true, false);
                messageBox.ShowDialog();
                if (messageBox.DialogResult == DialogResult.OK)
                {
                    File.Delete(outPath);
                }
                else
                {
                    return;
                }
            }

            buttonStartCancel.Text = "Stop";
            buttonClose.Enabled = false;
            _bw.RunWorkerAsync();
        }
Exemplo n.º 37
0
 private void PopulateProfileSettings()
 {
     SaveCurrentItem();
     ProfileItem item = comboBoxProfiles.SelectedItem as ProfileItem;
     if (item != null)
     {
         textBoxProfileName.Text = item.Name;
         textBoxDataFolder.Text = item.DataFolder;
     }
     _currentItem = item;
 }
Exemplo n.º 38
0
        private void PopulateProfileList()
        {
            XMLProfileSettings profile = new XMLProfileSettings();

            int profileCount = profile.GetSetting(XMLProfileSettings.SettingType.Profiles, "ProfileCount", 0);
            if (profileCount == 0)
            {
                MessageBox.Show("Unable to locate any profiles.");
                return;
            }
            else
            {
                for (int i = 0; i < profileCount; i++)
                {
                    ProfileItem item = new ProfileItem();
                    item.Name = profile.GetSetting(XMLProfileSettings.SettingType.Profiles, "Profile" + i.ToString() + "/Name", "");
                    item.DataFolder = profile.GetSetting(XMLProfileSettings.SettingType.Profiles, "Profile" + i.ToString() + "/DataFolder", "");
                    comboBoxProfiles.Items.Add(item);
                }
            }
            comboBoxProfiles.SelectedIndex = 0;
        }
Exemplo n.º 39
0
        private void buttonOK_Click(object sender, EventArgs e)
        {
            XMLProfileSettings profile         = new XMLProfileSettings();
            List <string>      checkName       = new List <string>();
            List <string>      checkDataFolder = new List <string>();
            List <string>      duplicateItems  = new List <string>();
            List <string>      checkDataPath   = new List <string>();
            bool duplicateName       = false;
            bool duplicateDataFolder = false;
            bool invalidDataPath     = false;

            //Check for null values, duplicate profile name or datapath and non rooted datapath
            foreach (ProfileItem item in comboBoxProfiles.Items)
            {
                if (item.Name == null || item.DataFolder == null)
                {
                    MessageBox.Show(
                        @"One or more of your profile entries has a blank name or data folder. You must correct this before continuing.",
                        @"Warning - Blank Entries", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }

                if (checkName.Contains(item.Name))
                {
                    duplicateName = true;
                    duplicateItems.Add(item.Name + ":\t " + item.DataFolder);
                }
                checkName.Add(item.Name);

                if (checkDataFolder.Contains(item.DataFolder))
                {
                    duplicateDataFolder = true;
                    duplicateItems.Add(item.Name + ":\t " + item.DataFolder);
                }

                checkDataFolder.Add(item.DataFolder);

                if (!Path.IsPathRooted(item.DataFolder) || !item.DataFolder.Contains(@"\"))
                {
                    invalidDataPath = true;
                    checkDataPath.Add(item.Name + ":\t " + item.DataFolder);
                }
            }

            if (duplicateName || duplicateDataFolder)
            {
                //Not pretty here, but works well on the dialog
                var result =
                    MessageBox.Show(
                        @"A duplicate profile name, or data path exists." + Environment.NewLine + Environment.NewLine +
                        @"The duplicate items found were:" + Environment.NewLine + Environment.NewLine + string.Join(Environment.NewLine, duplicateItems) + Environment.NewLine + Environment.NewLine +
                        @"Click OK to accept and contine, or Cancel to go back and edit.",
                        @"Warning - Duplicate Entries", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);

                if (result != DialogResult.OK)
                {
                    DialogResult = DialogResult.None;
                    return;
                }
            }

            if (invalidDataPath)
            {
                var result =
                    MessageBox.Show(
                        @"An invalid profile data folder exists." + Environment.NewLine + Environment.NewLine +
                        @"The items with invalid paths were:" + Environment.NewLine + Environment.NewLine + string.Join(Environment.NewLine, checkDataPath) + Environment.NewLine + Environment.NewLine +
                        @"Click OK to accept and contine, or Cancel to go back and edit.",
                        @"Warning - Invalid Data Path", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);

                if (result != DialogResult.OK)
                {
                    DialogResult = DialogResult.None;
                    return;
                }
            }

            SaveCurrentItem();
            profile.PutSetting(XMLProfileSettings.SettingType.Profiles, "ProfileCount", comboBoxProfiles.Items.Count);
            for (int i = 0; i < comboBoxProfiles.Items.Count; i++)
            {
                ProfileItem item = comboBoxProfiles.Items[i] as ProfileItem;
                profile.PutSetting(XMLProfileSettings.SettingType.Profiles, "Profile" + i + "/Name", item.Name);
                profile.PutSetting(XMLProfileSettings.SettingType.Profiles, "Profile" + i + "/DataFolder", item.DataFolder);
                //We're getting out of here and expect a restart by user, if the specified DataFolder doesn't exist, we should create it.

                if (item.DataFolder != string.Empty)
                {
                    if (!Directory.Exists(item.DataFolder))
                    {
                        Directory.CreateDirectory(item.DataFolder);
                    }
                }
            }

            profile.PutSetting(XMLProfileSettings.SettingType.Profiles, "LoadAction",
                               radioButtonAskMe.Checked ? "Ask" : "LoadSelected");

            if (comboBoxLoadThisProfile.SelectedIndex >= 0)
            {
                profile.PutSetting(XMLProfileSettings.SettingType.Profiles, "ProfileToLoad", comboBoxLoadThisProfile.SelectedIndex);
            }

            DialogResult = DialogResult.OK;
            Close();
        }