public CategoriesListForm(MainForm parent)
        {
            InitializeComponent();

            foreach(string cat in parent.portfel.categories)
                this.AddToListView(cat);

            this.editButton.Enabled = false;
            this.deleteButton.Enabled = false;
        }
Beispiel #2
0
        public ConstForm(MainForm parent)
        {
            InitializeComponent();

            this.edit_button.Enabled = false;
            this.delete_button.Enabled = false;

            /*foreach(ConstExpense expense in parent.portfel.const_list)
            {
                ListViewItem item = new ListViewItem(expense.name);
                item.Tag = expense;
                this.listView.Items.Add(item);
            }*/
        }
Beispiel #3
0
        public ExpenseForm(MainForm parent, Expense selected, string accept)
        {
            InitializeComponent();

            this.parent = parent;
            this.acceptButton.Text = accept;

            this.categoriesComboBox.Items.Clear();
            foreach(string s in parent.portfel.categories)
                this.categoriesComboBox.Items.Add(s);
            this.categoriesComboBox.Items.Remove("stałe");
            this.categoriesComboBox.SelectedItem = this.categoriesComboBox.Items[0];

            if(selected != null)
            {
                this.groupBox.Text = "Edytuj";
                this.dateTimePicker.Value = selected.date;

                this.categoriesComboBox.Text = selected.category;
                foreach(object item in this.categoriesComboBox.Items)
                    if(item as string == selected.category)
                    {
                        this.categoriesComboBox.SelectedItem = item;
                        break;
                    }

                if(selected.value < 0)
                {
                    this.valueTextBox.Text = (selected.value * -1).ToString();
                    this.outcopmRadioButton.Checked = true;
                }
                else
                {
                    this.valueTextBox.Text = selected.value.ToString();
                    this.incomeRadioButton.Checked = true;
                }

                this.descTextBox.Text = selected.description;
            }
            else
            {
                this.groupBox.Text = "Dodaj";
                this.acceptButton.Enabled = false;
            }

            this.to_edit = selected;
            this.valueTextBox.Focus();
        }
Beispiel #4
0
        static void Main(string[] args)
        {
            try
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                MainForm form;
                if(args.Length > 0)
                    form = new MainForm(args[0]);
                else
                    form = new MainForm();

                Application.ThreadException += Program.HandleUnhandled;
                Application.Run(form);
            }
            catch(Exception e)
            {
                HandleUnhandled(null, new ThreadExceptionEventArgs(e));
            }
        }
Beispiel #5
0
        public ConstListForm(MainForm parent)
        {
            InitializeComponent();

            throw new NotImplementedException();
        }
Beispiel #6
0
        /// <summary>Wczytuje ustawienia okna aplikacji.</summary>
        /// <remarks>Próbuje wczytać z pliku konfiguracyjnego rozmiar, pozycję i stan okna.
        /// W przypadku niepowodzenia wprowadza domyślne ustawienia.</remarks>
        public void ReadSettings(MainForm form)
        {
            string file = this.FileName(form.portfel.profile);
            XmlTextReader reader = null;

            try
            {
                if(File.Exists(file))
                {
                    reader = new XmlTextReader(file);

                    XmlSerializer serializer = new XmlSerializer(typeof(ApplicationSettings));
                    ApplicationSettings settings = (ApplicationSettings)serializer.Deserialize(reader);

                    form.dateColumnHeader.Width = settings.DateColumn;
                    form.valueColumnHeader.Width = settings.ValueColumn;
                    form.categoryColumnHeader.Width = settings.CategoryColumn;
                    form.descriptionColumnHeader.Width = settings.DescriptionColumn;

                    form.StartPosition = FormStartPosition.Manual;

                    if(settings.WindowState == FormWindowState.Maximized)
                        form.WindowState = FormWindowState.Maximized;
                    else
                        form.WindowState = FormWindowState.Normal;

                    form.Size = new Size(settings.Width, settings.Height);
                    form.Location = new Point(settings.X, settings.Y);
                    reader.Close();
                }
                else
                {
            #if DEBUG
                    MessageBox.Show("brak pliku ustawien okna");
            #endif
                    form.StartPosition = FormStartPosition.CenterScreen;
                    form.dateColumnHeader.Width = 65;
                    form.valueColumnHeader.Width = 60;
                    form.categoryColumnHeader.Width = 67;
                    form.descriptionColumnHeader.Width = 69;
                }
            }
            catch(Exception ex)
            {
                string text = "Plik ustawień okna aplikacji wygląda na uszkodzony.\n";
                text += "Program portfel może spróbować rozwiązać problem.\n";
                text += "Jeśli jednak błąd mimo wszystko powtarza się, możesz wysłać do autora raport o błędzie.\n";
                text += "Czy spróbować naprawić problem?";
            #if DEBUG
                text += "\n\n" + ex.ToString();
            #endif

                if(MainForm.MessageBoxWrapper(text, MessageType.EYesNo) == DialogResult.Yes)
                {
                    reader.Close();
                    File.Delete(file);
                }
                else
                {
                    text = "Czy chcesz wysłac do autora raport o błędzie?";
                    if(MainForm.MessageBoxWrapper(text, MessageType.EYesNo) == DialogResult.Yes)
                        try
                        {
                            ErrorReporter.Send("Portfel v" + PortfelAboutBox.AssemblyVersion, ex.ToString(), null);
                        }
                        catch
                        {
                        }
                }
            }
        }
Beispiel #7
0
        /// <summary>Zapisuje ustawienia okna aplikacji.</summary>
        /// <remarks>Zapisuje pozycję rozmiar i stan okna w czasie zamykania programu.</remarks>
        public void SaveSettings(MainForm form)
        {
            string file = this.FileName(form.portfel.profile);
            XmlTextWriter writer = null;

            try
            {
                if(!Directory.Exists(this.UserSettingsFolder))
                    Directory.CreateDirectory(this.UserSettingsFolder);

                writer = new XmlTextWriter(file, Encoding.UTF8);
                writer.Formatting = Formatting.Indented;

                ApplicationSettings settings = new ApplicationSettings();

                if(form.WindowState == FormWindowState.Maximized)
                    settings.WindowState = form.WindowState;
                else
                    settings.WindowState = FormWindowState.Normal;

                form.WindowState = FormWindowState.Normal;
                settings.Width = form.Size.Width;
                settings.Height = form.Size.Height;
                settings.X = form.Location.X;
                settings.Y = form.Location.Y;

                settings.DateColumn = form.dateColumnHeader.Width;
                settings.ValueColumn = form.valueColumnHeader.Width;
                settings.CategoryColumn = form.categoryColumnHeader.Width;
                settings.DescriptionColumn = form.descriptionColumnHeader.Width;

                XmlSerializer serializer = new XmlSerializer(typeof(ApplicationSettings));
                serializer.Serialize(writer, settings);
                writer.Close();
            }
            catch(Exception ex)
            {
                string text = "Wystąpił nieznany problem z plikiem ustawień okna aplikacji.\n";
                text += "Możesz teraz wysłać do autora raport o błędzie.";
            #if DEBUG
                text += "\n\n" + ex.ToString();
            #endif

                if(MainForm.MessageBoxWrapper(text, MessageType.EYesNo) == DialogResult.Yes)
                {
                    try
                    {
                        ErrorReporter.Send("Portfel v" + PortfelAboutBox.AssemblyVersion, ex.ToString(), null);
                    }
                    catch
                    {
                    }
                }
            }
        }