private void Save(string fileName, string userName, string password, string LastFilePath) { this.securedFile.Cars.Clear(); foreach (UserControl userControl in this.panelList.Controls) { if (userControl is UserControlKfz) { UserControlKfz ucKfz = (UserControlKfz)userControl; this.securedFile.Cars.Add(ucKfz.Car); } } this.securedFile.LastUpdate = DateTime.Now; if (!String.IsNullOrEmpty(userName)) { this.securedFile.Owner = userName; } this.securedFile.Save(fileName, password); StatusLabelSave.Visible = true; StatusLabelSave.Text = "Speichern erfolgreich durchgeführt."; pictureBoxAvatar.Visible = true; statusLabelUser.Visible = true; statusLabelUser.Text = this.securedFile.Owner; this.timerSave.Enabled = true; // timer for fade out SetPropertiesSettings(LastFilePath); // save new Usersettings }
private void LoadUserControl(Car car) { UserControl userControl = null; userControl = new UserControlKfz(car); // Styling & Positioning int ucTop = 0; if (this.panelList.Controls.Count > 0) { ucTop = this.panelList.Controls[this.panelList.Controls.Count - 1].Location.Y + this.panelList.Controls[this.panelList.Controls.Count - 1].Size.Height; } userControl.Location = new Point(5, ucTop + 5); userControl.Width = this.panelList.ClientRectangle.Width - 10; userControl.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; userControl.BackColor = Color.FromArgb(180, 193, 204); this.panelList.Controls.Add(userControl); }