private DatabaseOfFiles GetDBFromName(String name) { ListTextCoord b = _daddy.GetBookmarks(); foreach (DatabaseOfFiles db in b._Databases) { if (db._Name == name) { return(db); } } return(null); }
/// <summary> /// Deserialize /// </summary> /// <param name="file">file to deserialize from</param> /// <returns>Deserialized instance</returns> static public ListTextCoord Deserialize(String file) { //Clear mp for further usage. ListTextCoord ltc = null; //Open the file written above and read values from it. Stream stream = File.Open(file, FileMode.Open); BinaryFormatter bformatter = new BinaryFormatter(); ltc = (ListTextCoord)bformatter.Deserialize(stream); stream.Close(); return(ltc); }
private void btnDelete_Click(object sender, EventArgs e) { try { Object sel = cbDBListstartupconf.SelectedItem; if (sel is DatabaseOfFiles) // That's the place holder { DatabaseOfFiles db = (DatabaseOfFiles)sel; DialogResult dialogResult = MessageBox.Show( String.Format(_daddy.GetTranslator().GetString("DlgDelDBTxt"), db._Name), _daddy.GetTranslator().GetString("DlgDelDBTitle"), MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dialogResult == DialogResult.Yes) { //do something // we look for existing DB ListTextCoord b = _daddy.GetBookmarks(); foreach (DatabaseOfFiles edb in b._Databases) { if (edb._Id == db._Id) { b._Databases.Remove(edb); break; } } _daddy.SaveBookmarks(b); // update cbbox int i = cbDBListstartupconf.SelectedIndex - 1; if (i < 0) { i = 0; } cbDBListstartupconf.Items.Remove(sel); cbDBListstartupconf.SelectedIndex = i; _daddy.UpdateMenuWithDB(); } } } catch (Exception exc) { _daddy.ShowException("", "Deleting files", exc); } }
/// <summary> /// Contructor /// </summary> /// <param name="daddy">Reference to main window (MainWindow instance), used for callback purposes</param> public FavManager(MainWindow daddy) { _daddy = daddy; InitializeComponent(); this.Text = _daddy.GetTranslator().GetString("DlgFavManager"); this.label1.Text = _daddy.GetTranslator().GetString("LblName"); this.label2.Text = _daddy.GetTranslator().GetString("LblLatLon"); this.favmgrbutton1.Text = _daddy.GetTranslator().GetString("BtnOk"); this.favmgrbutton2.Text = _daddy.GetTranslator().GetString("BtnCancel"); favmgrlistView1.Columns.Add(_daddy.GetTranslator().GetString("LblName"), 200); _daddy.TranslateTooltips(this, null); _bmarks = _daddy.GetBookmarks(); foreach (TextCoord crd in _bmarks._TextCoords) { ListViewItem item = favmgrlistView1.Items.Add(crd._Name); item.Tag = crd; } }
private void button1_Click(object sender, EventArgs e) { ListTextCoord bmarks = new ListTextCoord(); // copy database bmarks._Databases = _bmarks._Databases; // Now create new coords foreach (ListViewItem item in favmgrlistView1.Items) { TextCoord crd = item.Tag as TextCoord; bmarks._TextCoords.Add(crd); } // save _daddy.SaveBookmarks(bmarks); // Maj du pere _daddy.PostTreatmentLoadCache(); this.DialogResult = DialogResult.OK; this.Close(); }
/// <summary> /// Constructor /// </summary> /// <param name="daddy">Reference to main window (MainWindow instance), used for callback purposes</param> public StartupFilesConfig(MainWindow daddy) { _daddy = daddy; InitializeComponent(); this.Text = _daddy.GetTranslator().GetString("DlgStartupFilecfg"); label1.Text = _daddy.GetTranslator().GetString("LblCheckFileToLoad"); button1startupconf.Text = _daddy.GetTranslator().GetString("BtnOk"); button2startupconf.Text = _daddy.GetTranslator().GetString("BtnCancel"); button3startupconf.Text = _daddy.GetTranslator().GetString("BtnCheckAll"); button4startupconf.Text = _daddy.GetTranslator().GetString("BtnUncheckAll"); button5startupconf.Text = _daddy.GetTranslator().GetString("BtnLoadSelectedFiles"); label11.Text = _daddy.GetTranslator().GetString("LblDatabase"); // Init listview listView1startupconf.Columns.Add(_daddy.GetTranslator().GetString("ColFileName"), 250); listView1startupconf.Columns.Add(_daddy.GetTranslator().GetString("ColSizeMo") + " (" + _daddy.GetTranslator().GetString("LblMO") + ")", 50); listView1startupconf.Columns.Add(_daddy.GetTranslator().GetString("ColCreationDate"), 150); listView1startupconf.Columns.Add(_daddy.GetTranslator().GetString("ColFilePath"), 150); // Build list from configuration List <String> ignoredf; ignoredf = StartupFilesConfig.GetListOfExcludedFiles(); // And finally add all the files from the saved DB if they are missing // DB names ListTextCoord b = _daddy.GetBookmarks(); cbDBListstartupconf.Items.Add(_daddy.GetTranslator().GetString("CBNewDB")); cbDBListstartupconf.SelectedIndex = 0; foreach (DatabaseOfFiles db in b._Databases) { cbDBListstartupconf.Items.Add(db); } // Load files String pathdb = _daddy.GetUserDataPath() + Path.DirectorySeparatorChar + "GPX"; string[] filePaths = Directory.GetFiles(pathdb, "*.gpx", SearchOption.AllDirectories); foreach (string f in filePaths) { ListViewItem item = SetFileStats(ignoredf, f, pathdb); listView1startupconf.Items.Add(item); } filePaths = Directory.GetFiles(pathdb, "*.zip", SearchOption.AllDirectories); foreach (string f in filePaths) { ListViewItem item = SetFileStats(ignoredf, f, pathdb); listView1startupconf.Items.Add(item); } filePaths = Directory.GetFiles(pathdb, "*.ggz", SearchOption.AllDirectories); foreach (string f in filePaths) { ListViewItem item = SetFileStats(ignoredf, f, pathdb); listView1startupconf.Items.Add(item); } // now complete with non existing files if any foreach (String s in ignoredf) { bool bfound = false; foreach (ListViewItem item in listView1startupconf.Items) { if (item.Tag.ToString() == s) { bfound = true; break; } } if (!bfound) { // On ne l'ajoute pas !!!! /* * String cleaned = s; * int ipos = s.LastIndexOf('\\'); * if (ipos != -1) * cleaned = s.Substring(ipos + 1); * * ListViewItem item = new ListViewItem(cleaned); * item.SubItems.Add("?"); * item.SubItems.Add("?"); * item.SubItems.Add(s); * item.Tag = s; * item.Checked = false; // ignored = unchecked * listView1.Items.Add(item); */ } } // On resauve tout ça après le nettoyage, ça évite de se trainer les fichiers qui ont disparu SaveListOfExcludedFiles(); _FilesToload.Clear(); _daddy.TranslateTooltips(this, null); }
private void btnSave_Click(object sender, EventArgs e) { try { Object sel = cbDBListstartupconf.SelectedItem; if (sel is DatabaseOfFiles) // we overwrite existing DB { DatabaseOfFiles db = (DatabaseOfFiles)sel; foreach (ListViewItem item in listView1startupconf.Items) { if (item.Checked) // check = keep it { db._Files.Add(item.Tag.ToString()); } } // we look for existing DB ListTextCoord b = _daddy.GetBookmarks(); foreach (DatabaseOfFiles edb in b._Databases) { if (edb._Id == db._Id) { edb._Files = db._Files; break; } } _daddy.SaveBookmarks(b); } else // we create a new db { DatabaseOfFiles db = new DatabaseOfFiles(); foreach (ListViewItem item in listView1startupconf.Items) { if (item.Checked) // check = keep { db._Files.Add(item.Tag.ToString()); } } // and now the name List <ParameterObject> lst = new List <ParameterObject>(); lst.Add(new ParameterObject(ParameterObject.ParameterType.String, "", "name", _daddy.GetTranslator().GetString("LblName"))); ParametersChanger changer = new ParametersChanger(); changer.Title = _daddy.GetTranslator().GetString("LblDatabase"); changer.BtnCancel = _daddy.GetTranslator().GetString("BtnCancel"); changer.BtnOK = _daddy.GetTranslator().GetString("BtnOk"); changer.ErrorFormater = _daddy.GetTranslator().GetString("ErrWrongParameter"); changer.ErrorTitle = _daddy.GetTranslator().GetString("Error"); changer.Parameters = lst; changer.Font = this.Font; changer.Icon = this.Icon; if (changer.ShowDialog() == DialogResult.OK) { db._Name = lst[0].Value; ListTextCoord b = _daddy.GetBookmarks(); b._Databases.Add(db); _daddy.SaveBookmarks(b); int i = cbDBListstartupconf.Items.Add(db); cbDBListstartupconf.SelectedIndex = i; _daddy.UpdateMenuWithDB(); } } } catch (Exception exc) { _daddy.ShowException("", "Saving files", exc); } }