Beispiel #1
0
 private void DisposeStuff()
 {
     if (store != null)
     {
         store.Close();
         store = null;
     }
     fontBrush.Dispose();
     editForm.Dispose();
     categoryNodes.Clear();
 }
Beispiel #2
0
        private void OrganizerForm_Load(object sender, EventArgs e)
        {
            Version appVersion = Assembly.GetExecutingAssembly().GetName().Version;

            lblVersion.Text = string.Format(lblVersion.Text, appVersion.Major, appVersion.Minor);

            checker = new UpdateChecker("founderio", "emoticorg");
            checker.CheckUpdate(UpdateType.Major).ContinueWith(continuation =>
            {
                Invoke(new Action(() =>
                {
                    if (continuation.Result != UpdateType.None)
                    {
                        var result = new UpdateNotifyDialog(checker).ShowDialog();
                        if (result == DialogResult.Yes)
                        {
                            checker.DownloadAsset("Emoticorg.zip");
                        }
                    }
                }));
            });

            string appdata = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
            string dataDir = Path.Combine(appdata, "Emoticorg");

            try
            {
                Directory.CreateDirectory(dataDir);
                store = EmoticonStore.openStore(Path.Combine(dataDir, "store.sqlite"));
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error loading database:\n" + ex.ToString(), "Error Loading Database", MessageBoxButtons.OK, MessageBoxIcon.Error);
                store = null;
                Application.Exit();
            }

            if (!store.IsReadable)
            {
                MessageBox.Show("This Emoticon store was created by a different application version and cannot be converted.\nSupported Version: " + EmoticonStore.VERSION + " Loaded Version: " + store.LoadedVersionString, "Error Loading Database", MessageBoxButtons.OK, MessageBoxIcon.Error);
                store = null;
                Application.Exit();
            }
            else if (store.NeedsUpgrade)
            {
                DialogResult result = MessageBox.Show("This Emoticon store needs be converted before usage.\nWARNING: This may break compatibility with lower application versions!\nTarget Version: " + EmoticonStore.VERSION + " Loaded Version: " + store.LoadedVersionString + "\n\nDo you want to convert?", "Conversion Needed", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (result == System.Windows.Forms.DialogResult.Yes)
                {
                    try
                    {
                        store.Upgrade();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Error upgrading database:\n" + ex.ToString(), "Error Upgrading Database", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        store = null;
                        Application.Exit();
                    }
                }
            }

            if (treeView1.Nodes.Count > 0)
            {
                treeView1.SelectedNode = treeView1.Nodes[0];
            }
            RefreshCategories();
        }