private void C_BtnCopy_Click(object sender, System.EventArgs e) { object item = this.C_ListSecFilters.SelectedItem; if (!(item is SectionFilter)) { return; } SectionFilter filter = new SectionFilter((item as SectionFilter).Filter); if (this._SaveFileDialog.ShowDialog(this) == DialogResult.OK) { filter.FilterName = this._SaveFileDialog.FileName; string strFile = this.GetSecFiltersFilePath(filter.FilterName); if (System.IO.File.Exists(strFile)) { if (MessageBox.Show(this, "The filter file is existed , do you want overwrite it?", "Warnning", MessageBoxButtons.YesNo) != DialogResult.Yes) { return; } } else { this.C_ListSecFilters.Items.Add(filter); } filter.Save(strFile); } }
//New private void C_BtnNew_Click(object sender, System.EventArgs e) { this.CreateSecFiltersFolder(); #region Old //SectionFilter filter = new SectionFilter(); //filter.FilterName = string.Empty; //_SaveFileDialog.FileName=string.Empty; //if(this._SaveFileDialog.ShowDialog(this) == DialogResult.OK) //{ // filter.FilterName = this._SaveFileDialog.FileName; // filter.Filter.IsCustomFilter=true; // string strFile = this.GetSecFiltersFilePath(filter.FilterName); // if(System.IO.File.Exists(strFile)) // { // if(MessageBox.Show(this,"The filter file is existed , do you want overwrite it?","Warnning",MessageBoxButtons.YesNo) == DialogResult.No) // { // return; // } // } // if(!System.IO.File.Exists(strFile)) // { // this.C_ListSecFilters.Items.Add(filter); // } // filter.Save(strFile); //} #endregion #region New EditSecFilterForm editSecForm = new EditSecFilterForm(this._WebbDBTypes); if (editSecForm.ShowDialog(this) == DialogResult.OK) { SectionFilter filter = editSecForm.Value; filter.Filter.IsCustomFilter = true; string strFile = this.GetSecFiltersFilePath(filter.FilterName); if (System.IO.File.Exists(strFile)) { if (MessageBox.Show(this, "The filter file is existed , do you want overwrite it?", "Warnning", MessageBoxButtons.YesNo) == DialogResult.No) { return; } } if (!System.IO.File.Exists(strFile)) { this.C_ListSecFilters.Items.Add(filter); } filter.Save(strFile); } #endregion }
//Custom... //private void C_BtnCustom_Click(object sender, System.EventArgs e) //{ // object item = null; // bool secAdd = false; // if (this.C_ListSecFilters.SelectedIndex >= 0) // { // item = this.C_ListSecFilters.SelectedItem; // secAdd = false; // } // else // { // item = this.C_ListSelectedSecFilters.SelectedItem; // secAdd = true; // } // if (!(item is SectionFilter)) return; // SectionFilter filter = item as SectionFilter; // filter.Filter.IsCustomFilter = true; // string strOldName = filter.FilterName; // this._PropertyForm.BindProperty(filter); // if (this._PropertyForm.ShowDialog(this) == DialogResult.OK) // { // if (strOldName != filter.FilterName) // { // if (System.IO.File.Exists(this.GetSecFiltersFilePath(filter.FilterName))) // { // MessageBox.Show(string.Format("[{0}] was exist.", filter.FilterName)); // filter.FilterName = strOldName; // return; // } // else // { // System.IO.File.Delete(this.GetSecFiltersFilePath(strOldName)); // filter.Filter.Name = string.Empty; // if (secAdd) // { // this.C_ListSelectedSecFilters.Items.Remove(filter); // this.C_ListSelectedSecFilters.Items.Add(filter); // } // else // { // this.C_ListSecFilters.Items.Remove(filter); // this.C_ListSecFilters.Items.Add(filter); // } // } // } // filter.Save(this.GetSecFiltersFilePath(filter.FilterName)); // } // filter.Load(this.GetSecFiltersFilePath(filter.FilterName)); //} #endregion private void C_BtnCustom_Click(object sender, System.EventArgs e) { object item = null; ListBox selectedItemListBox = null; if (this.C_ListSecFilters.SelectedIndex >= 0) { item = this.C_ListSecFilters.SelectedItem; selectedItemListBox = C_ListSecFilters; } else if (this.C_ListSelectedSecFilters.SelectedIndex >= 0) { item = this.C_ListSelectedSecFilters.SelectedItem; selectedItemListBox = C_ListSelectedSecFilters; } if (item == null || !(item is SectionFilter)) { return; } SectionFilter filter = item as SectionFilter; filter.Filter.IsCustomFilter = true; EditSecFilterForm editform = new EditSecFilterForm(filter, this._WebbDBTypes); if (editform.ShowDialog(this) == DialogResult.OK) { SectionFilter newFilter = editform.Value; if (newFilter.FilterName != filter.FilterName) { if (System.IO.File.Exists(this.GetSecFiltersFilePath(newFilter.FilterName))) { MessageBox.Show(string.Format("[{0}] was exist.", newFilter.FilterName)); return; } else { System.IO.File.Delete(this.GetSecFiltersFilePath(filter.FilterName)); selectedItemListBox.Items.Remove(filter); selectedItemListBox.Items.Add(newFilter); selectedItemListBox.SelectedItem = newFilter; } } else { filter.Apply(newFilter); } newFilter.Save(this.GetSecFiltersFilePath(newFilter.FilterName)); } }