public Resource GetResource()
        {
            Resource res = new Resource();

            res.ID          = txtId.Text;
            res.Name        = txtName.Text;
            res.Description = txtDescription.Text;
            res.Important   = chbImportant.Checked;
            res.Renewable   = chbRenewable.Checked;
            res.Exploatable = chbExploatable.Checked;
            res.Unit        = Resource.StringToUnit(cmbUnit.Text);
            if (rbtFrequent.Checked)
            {
                res.Frequency = Frequency.FREQUENT;
            }
            else if (rbtRare.Checked)
            {
                res.Frequency = Frequency.RARE;
            }
            else
            {
                res.Frequency = Frequency.UNIVERSAL;
            }
            res.Cost = double.Parse(txtCost.Text);
            if (rbtDate.Checked)
            {
                res.Discovered       = dateTimePicker.Value;
                res.ApproxDiscovered = null;
            }
            else
            {
                res.Discovered       = DateTime.MaxValue;
                res.ApproxDiscovered = approxDate;
            }
            //res.Discovered = dateTimePicker.Value;
            //res.ApproxDiscovered = approxDate;
            res.Tags = tags;
            if (!fname.Equals(""))
            {
                try
                {
                    File.Copy(fullFileName, "..\\..\\images\\" + fname);
                }
                catch
                {
                    Console.WriteLine("File allready exists");
                }
                res.IconFileName = "..\\..\\images\\" + fname;
            }
            else
            {
                res.IconFileName = fullFileName;
            }
            res.Type = type;
            if (cmbType.SelectedItem != null)
            {
                string typeID = cmbType.SelectedItem.ToString();
                foreach (Type t in MainForm.types.Values)
                {
                    if (t.ID == typeID)
                    {
                        res.Type = t;
                    }
                }
            }

            return(res);
        }
        public EditResourceForm(Resource res)
        {
            InitializeComponent();
            ofd.Filter = "Image Files(*.BMP;*.JPG;*.PNG)|*.BMP;*.JPG;*.PNG";
            this.cmbUnit.DropDownStyle = ComboBoxStyle.DropDownList;
            this.cmbType.DropDownStyle = ComboBoxStyle.DropDownList;

            tags = res.Tags;
            type = res.Type;

            txtId.Text          = res.ID;
            txtId.ReadOnly      = true;
            txtName.Text        = res.Name;
            txtDescription.Text = res.Description;
            lblIconName.Text    = res.IconFileName;
            if (res.Renewable)
            {
                chbRenewable.Checked = true;
            }
            if (res.Important)
            {
                chbImportant.Checked = true;
            }
            if (res.Exploatable)
            {
                chbExploatable.Checked = true;
            }
            cmbUnit.Text = Resource.UnitToString(res.Unit);
            switch (res.Frequency)
            {
            case Frequency.FREQUENT:
                rbtFrequent.Checked = true;
                break;

            case Frequency.RARE:
                rbtRare.Checked = true;
                break;

            case Frequency.UNIVERSAL:
                rbtUniversal.Checked = true;
                break;
            }
            txtCost.Text         = res.Cost.ToString();
            dateTimePicker.Value = res.Discovered;
            lblTag.Text          = res.Tags.Count.ToString();
            fullFileName         = res.IconFileName;
            lblIconName.Text     = fullFileName;
            if (res.ApproxDiscovered != null)
            {
                approxDate         = res.ApproxDiscovered;
                lblApproxDate.Text = res.ApproxDiscovered.ToString();
            }


            foreach (Type t in MainForm.types.Values)
            {
                cmbType.Items.Add(t.ID);
            }
            cmbType.SelectedItem = res.Type.ID;

            ToolTip tt = new ToolTip();

            tt.SetToolTip(btnDate, "Izbor okvirnog datuma");

            lblApproxDate.Enabled  = rbtApproxDate.Checked;
            btnDate.Enabled        = rbtApproxDate.Checked;
            dateTimePicker.Enabled = rbtDate.Checked;
        }