コード例 #1
0
        private void btnLoad_Click(object sender, EventArgs e)
        {
            try
            {
                Object sel = cbDBListstartupconf.SelectedItem;
                if (sel is DatabaseOfFiles) // That's the place holder
                {
                    DatabaseOfFiles db = (DatabaseOfFiles)sel;
                    // exclude everyone
                    foreach (ListViewItem item in listView1startupconf.Items)
                    {
                        item.Checked = false; // not loaded
                    }

                    // uncheck only files from the DB
                    foreach (string f in db._Files)
                    {
                        foreach (ListViewItem item in listView1startupconf.Items)
                        {
                            if (item.Tag.ToString() == f)
                            {
                                item.Checked = true; // to load
                                break;
                            }
                        }
                    }
                }
            }
            catch (Exception exc)
            {
                _daddy.ShowException("", "Loading files", exc);
            }
        }
コード例 #2
0
        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);
            }
        }
コード例 #3
0
        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);
            }
        }