~palango/sterling/nocriticals

« back to all changes in this revision

Viewing changes to Sterling/MainWindow.cs

  • Committer: Paul Lange
  • Date: 2008-08-21 15:39:03 UTC
  • Revision ID: palango@gmx.de-20080821153903-dcqul2hpebls7rtk
Make UI working correctly. Added ChartDialog.

Show diffs side-by-side

added added

removed removed

Lines of Context:
44
44
                        initializeGUI();
45
45
                        
46
46
                        loadData();
 
47
                        
 
48
                        balanceLabel.Markup = String.Format("<big>Current balance: <b>{0:N2} €</b></big>", _data.Balance);
 
49
                        this.Title = "Sterling - " + _data.Name;
47
50
                }
48
51
                
49
52
                private void loadData()
50
53
                {
51
54
                        _data = Account.Load();
52
 
                        System.Console.WriteLine(_data.Name);
53
55
                        
54
56
                        Transaction start = new Transaction(_data.StartBalance, "start balancing", DateTime.MinValue);
55
57
                        insertListItem(start, start.Amount, 0);
57
59
                        int i = 1;
58
60
                        foreach (Transaction t in _data.Transactions)
59
61
                        {
60
 
                                insertListItem(t, 1d, i++);
 
62
                                insertListItem(t, _data.GetBalanceAtIndex(i -1), i++);
61
63
                        }
62
64
                }
63
65
                
66
68
                        TreeIter iter = _store.Insert(position);
67
69
                        _store.SetValue(iter, 0, trans);
68
70
                        _store.SetValue(iter, 1, balance);
 
71
                        
 
72
                        resetBalanceLabels();
69
73
                }
70
74
                
71
75
                private void removeListItem(Transaction item)
77
81
                        _store.Remove(ref storeiter);
78
82
                        
79
83
                        _data.Transactions.Remove(item);
 
84
                        
 
85
                        resetBalanceLabels();
 
86
                }
 
87
                
 
88
                private void resetBalanceLabels()
 
89
                {
 
90
                        for (int i = 1; i <= _data.Transactions.Count; i++) 
 
91
                        {
 
92
                                TreeIter storeiter;
 
93
                                _store.GetIter(out storeiter, new TreePath(i.ToString()));
 
94
                                _store.SetValue(storeiter, 1, _data.GetBalanceAtIndex(i - 1));
 
95
                        }
 
96
                        
 
97
                        balanceLabel.Markup = String.Format("<big>Current balance: <b>{0:N2} €</b></big>", _data.Balance);
80
98
                }
81
99
                
82
100
#region UI stuff
211
229
                        if (x == 0 && y == 0)
212
230
                            pos_menu_func = PositionContextMenu;
213
231
 
214
 
                        menu.Popup (null, null, pos_menu_func, 0, Gtk.Global.CurrentEventTime);
 
232
                        menu.Popup (null, null, pos_menu_func, 0, Gtk.Global.CurrentEventTime);
215
233
                }
216
234
                
217
235
                // This is needed for when the user opens
335
353
                        dialog.Icon = Gdk.Pixbuf.LoadFromResource("hicolor_apps_16x16_sterling.png");
336
354
                        
337
355
                        dialog.Run();
338
 
                        dialog.Destroy();                               
 
356
                        dialog.Destroy();
339
357
                }
340
358
 
341
359
                protected virtual void OnNewTransactionActivated (object sender, EventArgs e)
369
387
                        {
370
388
                                _data.Name = dialog.TransactionName;
371
389
                                _data.StartBalance = dialog.StartBalance;
 
390
                                
 
391
                                resetBalanceLabels();
 
392
                                this.Title = "Sterling - " + _data.Name;
372
393
                        }
373
394
                        
374
395
                        dialog.Destroy();
394
415
                        TreeIter iter;
395
416
                        
396
417
                        if (filter.GetActiveIter(out iter))
397
 
                        {                               
 
418
                        {
398
419
                                string key = (string) filter.Model.GetPath(iter).ToString();
399
420
                                
400
421
                                int filterKey = 0;
409
430
                protected virtual void OnSearchEntryChanged (object sender, System.EventArgs e)
410
431
                {
411
432
                        _filter.Refilter();
412
 
                }       
 
433
                }
413
434
                
414
435
                private bool searchAndFilter(TreeModel model, TreeIter iter)
415
436
                {
443
464
                }
444
465
                
445
466
                private bool searchItems(Transaction trans)
446
 
                {                       
 
467
                {
447
468
                        string searchText = searchEntry.Text;
448
469
                        
449
470
                        if (searchText == "")
453
474
                                return true;
454
475
                        
455
476
                        if (trans.Amount.ToString().Contains(searchText))
456
 
                                return true;                    
 
477
                                return true;
457
478
                        
458
479
                        return trans.Description.Contains(searchText);
459
480
                }