Esempio n. 1
0
        public AccountOverviewWindow(Database db, string dbPath, int account, DatabaseOverviewWindow parent) : this(new Builder("AccountOverviewWindow.glade"))
        {
            this.db     = db;
            this.dbPath = dbPath;
            this.parent = parent;
            this.ac     = account;

            parent.GetSize(out int w, out int h);
            this.Resize(800, h);

            PrepareTransactionList();
            PrepareScheduledTransactionList();

            UpdateUI();

            System.Timers.Timer uiUpdateCheck = new System.Timers.Timer(200);
            uiUpdateCheck.Elapsed += (delegate {
                if (updateUi)
                {
                    updateUi = false;
                    UpdateUI();
                }
            });
            uiUpdateCheck.Start();


            this.SetPosition(WindowPosition.Center);
            this.Move(Screen.GetMonitorGeometry(Screen.PrimaryMonitor).Right - (Screen.GetMonitorGeometry(Screen.PrimaryMonitor).Width / 2) - 396 + 8, y: 200);
        }
Esempio n. 2
0
        private void browseBtn_Clicked(object sender, EventArgs e)
        {
            FileChooserDialog ofDialog = new FileChooserDialog("Choose the file to open",
                                                               this,
                                                               FileChooserAction.Open,
                                                               "Cancel", ResponseType.Cancel,
                                                               "Open", ResponseType.Accept);

            ofDialog.Filter      = new FileFilter();
            ofDialog.Filter.Name = "Money Datbase files *.mdb";
            ofDialog.Filter.AddPattern("*.mdb");
            ofDialog.SelectMultiple = false;

            if (ofDialog.Run() == (int)ResponseType.Accept)
            {
                dbPath = ofDialog.Filename;
                db     = new Database(dbPath);

                if (history.Contains(new KeyValuePair <string, string>(db.name, dbPath)))
                {
                    List <KeyValuePair <string, string> > historyCopy = new List <KeyValuePair <string, string> >(history);
                    historyCopy = historyCopy.ToList();
                    history     = new List <KeyValuePair <string, string> >();

                    history.Add(historyCopy[historyCopy.IndexOf(new KeyValuePair <string, string>(db.name, dbPath))]);
                    historyCopy.Remove(new KeyValuePair <string, string>(db.name, dbPath));

                    history.AddRange(historyCopy);
                    File.WriteAllText(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location) + "/history.json", JsonConvert.SerializeObject(history, Formatting.Indented));
                }
                else
                {
                    history.Add(new KeyValuePair <string, string>(db.name, dbPath));
                    File.WriteAllText(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location) + "/history.json", JsonConvert.SerializeObject(history, Formatting.Indented));
                }

                this.Hide();
                DatabaseOverviewWindow dbo = new DatabaseOverviewWindow(db, dbPath);
                dbo.Show();
            }
            ofDialog.Hide();
        }
Esempio n. 3
0
        private void recentDbList_ButtonPress(object o, ButtonPressEventArgs e)
        {
            if (e.Event.Button == 3)
            {
                Menu     m          = new Menu();
                MenuItem deleteItem = new MenuItem("Remove");
                deleteItem.ButtonPressEvent += new ButtonPressEventHandler(OnDeleteItemButtonPressed);
                m.Add(deleteItem);
                m.ShowAll();
                m.Popup();
            }
            else if (((Gdk.EventButton)e.Event).Type == Gdk.EventType.TwoButtonPress)
            {
                Gtk.TreeIter selected;
                if (recentDbList.Selection.GetSelected(out selected))
                {
                    dbPath = (string)recentDbListStore.GetValue(selected, 1);
                }

                if (!File.Exists(dbPath))
                {
                    MessageDialog msdSame  = new MessageDialog(this, DialogFlags.Modal, MessageType.Warning, ButtonsType.YesNo, false, "The selected database could not be found, delete it from recents?");
                    ResponseType  response = (ResponseType)msdSame.Run();
                    if (response == ResponseType.Yes)
                    {
                        msdSame.Destroy();
                        history.Remove(new KeyValuePair <string, string>((string)recentDbListStore.GetValue(selected, 0), (string)recentDbListStore.GetValue(selected, 1)));
                        File.WriteAllText(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location) + "/history.json", JsonConvert.SerializeObject(history, Formatting.Indented));
                    }
                    else if (response == ResponseType.No || response == ResponseType.DeleteEvent)
                    {
                        msdSame.Destroy();
                        return;
                    }

                    recentDbListStore.Clear();

                    history = new List <KeyValuePair <string, string> >();

                    if (File.Exists(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location) + "/history.json"))
                    {
                        history = JsonConvert.DeserializeObject <List <KeyValuePair <string, string> > >(File.ReadAllText(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location) + "/history.json"));

                        foreach (KeyValuePair <string, string> pair in history)
                        {
                            recentDbListStore.AppendValues(pair.Key, pair.Value);
                        }
                    }

                    return;
                }

                db = new Database(dbPath);

                if (history.Contains(new KeyValuePair <string, string>(db.name, dbPath)))
                {
                    List <KeyValuePair <string, string> > historyCopy = new List <KeyValuePair <string, string> >(history);
                    historyCopy = historyCopy.ToList();
                    history     = new List <KeyValuePair <string, string> >();

                    history.Add(historyCopy[historyCopy.IndexOf(new KeyValuePair <string, string>(db.name, dbPath))]);
                    historyCopy.Remove(new KeyValuePair <string, string>(db.name, dbPath));

                    history.AddRange(historyCopy);
                    File.WriteAllText(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location) + "/history.json", JsonConvert.SerializeObject(history, Formatting.Indented));
                }
                else
                {
                    history.Add(new KeyValuePair <string, string>(db.name, dbPath));
                    File.WriteAllText(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location) + "/history.json", JsonConvert.SerializeObject(history, Formatting.Indented));
                }

                this.Hide();
                DatabaseOverviewWindow dbo = new DatabaseOverviewWindow(db, dbPath);
                dbo.Show();
            }
        }