public StorageEditForm(RPN_API_Web web, int storage_id)
        {
            InitializeComponent();
            Icon = Resources.RPN_Sharp;

            if (Program.IsFullscreen)
            {
                WindowState = FormWindowState.Maximized;
            }

            storageFormSkin.FlatColor = Program.UIColor;

            storageTypeFlatComboBox.HoverColor = Program.UIColor;
            ownerFlatComboBox.HoverColor       = Program.UIColor;

            this.web        = web;
            this.storage_id = storage_id;

            try
            {
                foreach (RPN_API_Json.InternalData data in web.GetAllUsers())
                {
                    ownerFlatComboBox.Items.Add(data.Username);
                }
            }
            catch
            {
                MessageBox.Show("Impossible de charger les membres du groupe !");
            }

            try
            {
                foreach (RPN_API_Json.StorageTypeData data in web.GetStorageType())
                {
                    storageTypeFlatComboBox.Items.Add(data.Name);
                }
            }
            catch
            {
                MessageBox.Show("Impossible de charger les types de stockages !");
            }

            if (storage_id != -1)
            {
                RPN_API_Json.Storage storage = web.GetStorageFromId(storage_id);
                nameFlatTextBox.Text         = storage.Name;
                ownerFlatComboBox.Text       = storage.Owner;
                storageTypeFlatComboBox.Text = web.GetStorageTypeFromId(storage.StorageTypeId).Name;
                locationFlatTextBox.Text     = storage.Location;
            }
        }
示例#2
0
        private void ReloadStorageDetailData(int storage_id)
        {
            storageDetailDataGridView.Rows.Clear();

            if (storage_id != -1)
            {
                int space_used = 0;
                int pc_used;
                foreach (RPN_API_Json.StorageData storageData in web.GetStorageDataFromStorageId(storage_id))
                {
                    RPN_API_Json.RessourceTypeData ressourceTypeData = web.GetRessourceTypeFromId(storageData.RessourceType);
                    storageDetailDataGridView.Rows.Add(storageData.Id, ressourceTypeData.Name, storageData.Quantity, storageData.Quantity * ressourceTypeData.Mass);;
                    space_used += ressourceTypeData.Mass * storageData.Quantity;
                }

                RPN_API_Json.Storage         storage     = web.GetStorageFromId(storage_id);
                RPN_API_Json.StorageTypeData storageType = web.GetStorageTypeFromId(storage.StorageTypeId);

                storageTypeFlatLabel.Text = "Type : " + storageType.Name;
                pc_used = (int)(((float)space_used / (float)storageType.Size) * 100);
                storageSizeflatLabel.Text = "Taille : " + space_used.ToString("N0") + "/" + storageType.Size.ToString("N0") + " (Soit " + pc_used + "%)";
                if (pc_used >= 100)
                {
                    flatProgressBar1.Value = 100;
                }
                else if (pc_used <= 0)
                {
                    flatProgressBar1.Value = 0;
                }
                else
                {
                    flatProgressBar1.Value = pc_used;
                }
                ownerFlatLabel.Text = storage.Owner;
            }
            else
            {
                storageTypeFlatLabel.Text = "Type : X";
                storageSizeflatLabel.Text = "Taille : X/X (Soit XX%)";
                flatProgressBar1.Value    = 100;
                quantityFlatLabel.Text    = "Quantité : X";
                unitPriceFlatLabel.Text   = "Prix Unitaire : X€";
                rentFlatLabel.Text        = "X€";
            }

            storageDetailDataGridView.Refresh();
        }