Exemple #1
0
        /**********************************************************************************/

        public MainForm(AppManager _am)
        {
            m_app_manager = _am;
            InitializeComponent();

            m_app_manager.ComputerInfoUpdated += UpdateSysInfoLabel;

            UpdateSysInfoLabel();

            App new_app1 = new App("app_name", "producer");
            App new_app2 = new App("app_name2", "producer2");

            new_app1.InstallationDate = DateTime.Today;
            new_app2.InstallationDate = DateTime.Today;

            m_app_manager.AddApplication(new_app1);
            m_app_manager.AddApplication(new_app2);


            //m_bs_apps = new BindingSource(m_app_manager.Apps, null);
            //listBoxApps.DataSource = m_bs_apps;
            //listBoxApps.DisplayMember = "Key";
            //listBoxApps.ValueMember = "Key";

            UpdateListBoxApps();

            m_app_manager.AddUser(new User("username1", "passwd"));

            //m_bs_users = new BindingSource(m_app_manager.Users, null);
            //listBoxUsers.DataSource = m_bs_users;
            //listBoxUsers.DisplayMember = "Key";
            //listBoxUsers.ValueMember = "Key";

            UpdateListBoxUsers();

            m_app_manager.NewUserAdded += ListBoxAddUser;
            m_app_manager.NewAppAdded  += ListBoxAddApp;
        }
Exemple #2
0
        /**********************************************************************************/

        private void buttonApply_Click(object sender, EventArgs e)
        {
            string   app_name           = textBoxAppName.Text;
            string   app_producer       = textBoxProducer.Text;
            string   app_version_text   = textBoxVersion.Text;
            DateTime app_date_installed = dateTimePickerDateInstalled.Value;

            Version app_version;

            try
            {
                app_version = new Version(app_version_text);
            }
            catch (ArgumentException ex)
            {
                MessageBox.Show(ex.Message, "Invalid version format");

                return;
            }

            try
            {
                if (m_app_full_name == null)
                {
                    m_temp_app = new App(app_name, app_producer, app_version, app_date_installed, m_temp_ci);
                    m_app_manager.AddApplication(m_temp_app);
                }
                else
                {
                    m_temp_app                  = m_app_manager.GetApplication(m_app_full_name);
                    m_temp_app.Name             = app_name;
                    m_temp_app.Producer         = app_producer;
                    m_temp_app.AppVersion       = app_version;
                    m_temp_app.InstallationDate = app_date_installed;
                    m_temp_app.MinRequirements  = m_temp_ci;
                }
            }
            catch (ArgumentException ex)
            {
                MessageBox.Show(ex.Message, "invalid value");
                return;
            }

            Close();
        }