Beispiel #1
0
        private void comboBox_SaveLoc_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            ComboBoxItem cbi_Sel       = (ComboBoxItem)comboBox_SaveLoc.SelectedItem;
            int          selectedIndex = comboBox_SaveLoc.SelectedIndex;

            if (cbi_Sel == null)
            {
                return;
            }

            string new_loc = null;

            if (projectItem != null && cbi_Sel.Tag.ToString() == projectItem.Tag.ToString() && selectedIndex == posProject)
            {
                System.Windows.Forms.FolderBrowserDialog browse = new System.Windows.Forms.FolderBrowserDialog();
                browse.ShowNewFolderButton = false;
                browse.Description         = "Please select a heading";
                //
                bSkipModifyConfirmation    = true;
                browse.RootFolder          = Environment.SpecialFolder.Desktop;
                browse.SelectedPath        = StartProcess.START_PATH;
                browse.ShowNewFolderButton = true;

                if (browse.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    string path = browse.SelectedPath;
                    new_loc = path + System.IO.Path.DirectorySeparatorChar;
                }
                else
                {
                    comboBox_SaveLoc.SelectedIndex = 0;
                }
                bSkipModifyConfirmation = false;
            }

            if (journalItem != null && cbi_Sel.Tag.ToString() == journalItem.Tag.ToString() && selectedIndex == posJournal)
            {
                bSkipModifyConfirmation = true;
                DatePickerWindow_QC dpw = new DatePickerWindow_QC();
                if (dpw.ShowDialog().Value == true)
                {
                    DateTime selDate   = dpw.SelectedDate;
                    string   date_path = JournalControl.GetJournalPath(selDate);
                    if (date_path != null)
                    {
                        new_loc = date_path + System.IO.Path.DirectorySeparatorChar;
                    }
                    else
                    {
                        System.Windows.MessageBox.Show("Selected date folder doesn't exist!");
                        comboBox_SaveLoc.SelectedIndex = 0;
                    }
                }
                else
                {
                    comboBox_SaveLoc.SelectedIndex = 0;
                }
                bSkipModifyConfirmation = false;
            }

            if (new_loc != null)
            {
                bool bUpdate = false;
                for (int i = 0; i < posProject; i++)
                {
                    ComboBoxItem cbi = (ComboBoxItem)comboBox_SaveLoc.Items[i];
                    if (cbi.Tag.ToString() == new_loc)
                    {
                        comboBox_SaveLoc.SelectedIndex = i;
                        bUpdate = true;
                    }
                }

                if (bUpdate == false && !selectedLocCache.Contains(new_loc))
                {
                    selectedLocCache.Enqueue(new_loc);

                    while (selectedLocCache.Count > MAX_SELECTEDLOC_COUNT)
                    {
                        selectedLocCache.Dequeue();
                    }
                    updateComboBox_SaveLoc();
                    comboBox_SaveLoc.SelectedIndex = posSel;
                }

                bSkipModifyConfirmation = false;
                this.Visibility         = Visibility.Visible;
                this.Focus();
                this.Topmost = true;
            }
            selectedItem = (ComboBoxItem)comboBox_SaveLoc.SelectedItem;
        }
        private void comboBox_SaveLoc_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            ComboBoxItem cbi_Sel = (ComboBoxItem) comboBox_SaveLoc.SelectedItem;
            int selectedIndex = comboBox_SaveLoc.SelectedIndex;

            if (cbi_Sel == null)
                return;

            string new_loc = null;
            if (projectItem!=null && cbi_Sel.Tag.ToString() == projectItem.Tag.ToString() && selectedIndex == posProject)
            {
                System.Windows.Forms.FolderBrowserDialog browse = new System.Windows.Forms.FolderBrowserDialog();
                browse.ShowNewFolderButton = false;
                browse.Description = "Please select a heading";
                //
                bSkipModifyConfirmation = true;
                browse.RootFolder = Environment.SpecialFolder.Desktop;
                browse.SelectedPath = StartProcess.START_PATH;
                browse.ShowNewFolderButton = true;

                if (browse.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    string path = browse.SelectedPath;
                    new_loc = path + System.IO.Path.DirectorySeparatorChar;
                }
                else
                    comboBox_SaveLoc.SelectedIndex = 0;
                bSkipModifyConfirmation = false;
            }

            if (journalItem!=null && cbi_Sel.Tag.ToString() == journalItem.Tag.ToString() && selectedIndex == posJournal)
            {
                bSkipModifyConfirmation = true;
                DatePickerWindow_QC dpw = new DatePickerWindow_QC();
                if (dpw.ShowDialog().Value == true)
                {
                    DateTime selDate = dpw.SelectedDate;
                    string date_path = JournalControl.GetJournalPath(selDate);
                    if(date_path!=null)
                       new_loc = date_path +System.IO.Path.DirectorySeparatorChar;
                    else
                    {
                        System.Windows.MessageBox.Show("Selected date folder doesn't exist!");
                        comboBox_SaveLoc.SelectedIndex = 0;
                    }
                }
                else
                    comboBox_SaveLoc.SelectedIndex = 0;
                bSkipModifyConfirmation = false;
            }

            if (new_loc != null)
            {
                bool bUpdate = false;
                for (int i = 0; i < posProject; i++)
                {
                    ComboBoxItem cbi = (ComboBoxItem)comboBox_SaveLoc.Items[i];
                    if (cbi.Tag.ToString() == new_loc)
                    {
                        comboBox_SaveLoc.SelectedIndex = i;
                        bUpdate = true;
                    }
                }

                if (bUpdate == false && !selectedLocCache.Contains(new_loc))
                {
                    selectedLocCache.Enqueue(new_loc);

                    while (selectedLocCache.Count > MAX_SELECTEDLOC_COUNT)
                        selectedLocCache.Dequeue();
                    updateComboBox_SaveLoc();
                    comboBox_SaveLoc.SelectedIndex = posSel;
                }

                bSkipModifyConfirmation = false;
                this.Visibility = Visibility.Visible;
                this.Focus();
                this.Topmost = true;
            }
            selectedItem = (ComboBoxItem) comboBox_SaveLoc.SelectedItem;
        }