Пример #1
0
 private void Form1_Load(object sender, EventArgs e)
 {
     settFR           = new FirstRunSetting();
     sett             = new Settings();
     exsett           = new ExportSettings();
     notifyIcon1.Text = "Insetcia - Menu";
     if (settFR.FirstRun)
     {
         Nastavení    oknoNastavení = new Nastavení();
         DialogResult Ans           = oknoNastavení.ShowDialog();
         if (Ans == DialogResult.OK)
         {
             if (sett.cestaKSouboru == String.Empty)
             {
                 dataToolStripMenuItem1.Enabled = false;
             }
             else
             {
                 dataToolStripMenuItem1.Enabled = true;
                 exsett.Reload();
                 sett.Reload();
             }
         }
         else
         {
             dataToolStripMenuItem1.Enabled = false;
         }
     }
     else
     {
         if (sett.cestaKSouboru == String.Empty)
         {
             dataToolStripMenuItem1.Enabled = false;
         }
         else
         {
             dataToolStripMenuItem1.Enabled = true;
         }
     }
     Text = "Insectia";
     notifyIcon1.ContextMenuStrip = DataContextMenuStrip;
     poleObsah.BorderStyle        = BorderStyle.None;
     if (sett.Database)
     {
         _50P.Software.Connect.MySql.ConnectMySQL connect = new _50P.Software.Connect.MySql.ConnectMySQL(sett.server, sett.username, SecurePass.GetUnprotectedPassword(sett.password));
         connect.setDatabase(sett.dbname);
         db = new Database(connect.Connection);
     }
     if (sett.přípona == ".csv")
     {
         csvFile = new CSV(sett.cestaKSouboru);
     }
     else if (sett.přípona == ".xml")
     {
         xmlFile = new XML(sett.cestaKSouboru);
     }
     upravitPoložkyToolStripMenuItem1.Enabled = smazatPoložkyToolStripMenuItem.Enabled = uložitToolStripMenuItem1.Enabled = ExportToolStripMenuItem.Enabled = !items.GetItemsList().Count.Equals(0);
     uložitToolStripMenuItem1.Visible         = !sett.Database;
     ExportToolStripMenuItem.Visible          = exsett.remember;
 }
Пример #2
0
        private void nastaveníToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            comboBox1.Items.Clear();
            listBoxNázev.Items.Clear();
            poleObsah.Text = comboBox1.Text = String.Empty;
            Nastavení    oknoNastavení = new Nastavení();
            DialogResult odp           = oknoNastavení.ShowDialog();

            if (odp == DialogResult.OK)
            {
                items.Clear();
                if (sett.cestaKSouboru == String.Empty)
                {
                    dataToolStripMenuItem1.Enabled = false;
                }
                else
                {
                    sett.Reload();
                    exsett.Reload();
                    dataToolStripMenuItem1.Enabled  = true;
                    ExportToolStripMenuItem.Visible = exsett.remember;
                    if (!sett.Database)
                    {
                        if (sett.přípona == ".csv")
                        {
                            if (csvFile == null)
                            {
                                csvFile = new CSV(sett.cestaKSouboru);
                            }
                            else
                            {
                                csvFile.SetFilename(sett.cestaKSouboru);
                            }
                        }
                        else if (sett.přípona == ".xml")
                        {
                            if (xmlFile == null)
                            {
                                xmlFile = new XML(sett.cestaKSouboru);
                            }
                            else
                            {
                                xmlFile.SetFilename(sett.cestaKSouboru);
                            }
                        }
                    }
                    else
                    {
                        _50P.Software.Connect.MySql.ConnectMySQL connect = new _50P.Software.Connect.MySql.ConnectMySQL(sett.server, sett.username, SecurePass.GetUnprotectedPassword(sett.password));
                        connect.setDatabase(sett.dbname);
                        if (db == null)
                        {
                            db = new Database();
                        }
                        db.SetConnectionString(connect.Connection);
                    }
                }
            }
            else if (odp == DialogResult.Abort || odp == DialogResult.Retry)
            {
                dataToolStripMenuItem1.Enabled = false;
            }
            ReloadItems();
        }