Esempio n. 1
0
        private void listSessions_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            bool hasItemSelected = listSessions.SelectedIndices != null &&
                                   listSessions.SelectedIndices.Count > 0;

            bttOK.Enabled = listSessions.Items.Count > 0 && hasItemSelected;

            // and update items on the right side of the form:
            listItems.Items.Clear();
            if (hasItemSelected)
            {
                _selectedSession = listSessions.SelectedItems[0].Tag as EnvironmentSession;

                if (_selectedSession != null)
                {
                    foreach (EnvironmentSessionItem item in _selectedSession.Items)
                    {
                        ListViewItem i = new ListViewItem(item.Name);
                        i.SubItems.Add(item.Action);
                        i.SubItems.Add(item.Value);
                        listItems.Items.Add(i);
                    }
                }
            }
            else
            {
                _selectedSession = null;
            }

            bttDelete.Enabled = _selectedSession != null && !string.IsNullOrEmpty(_selectedSession.FileName);
        }
Esempio n. 2
0
        public void LoadSessions(IEnumerable <EnvironmentSession> sessions)
        {
            cmbTarget.SelectedIndex = 2;
            _selectedSession        = null;
            listSessions.Items.Clear();

            if (sessions != null)
            {
                foreach (EnvironmentSession s in sessions)
                {
                    ListViewItem v = new ListViewItem(s.Name);
                    v.Tag         = s;
                    v.ToolTipText = s.FileName;

                    listSessions.Items.Add(v);
                }
            }
        }
        /// <summary>
        /// Setups UI to show given session.
        /// </summary>
        public void LoadSession(EnvironmentSession session)
        {
            _session     = session;
            txtName.Text = session.Name;

            listItems.Items.Clear();
            foreach (EnvironmentSessionItem item in session.Items)
            {
                ListViewItem i = new ListViewItem(item.Name);
                i.Checked = true;
                i.SubItems.Add(item.Action);
                i.SubItems.Add(item.Value);
                i.Tag = item;

                listItems.Items.Add(i);
            }

            chkAll.Checked = true;
        }
        public void SetSession(EnvironmentSession session)
        {
            if (session == null)
            {
                throw new ArgumentNullException("session");
            }

            // update the view:
            listVariables.Items.Clear();
            foreach (EnvironmentSessionItem i in session.Items)
            {
                ListViewItem listItem = new ListViewItem(i.Target.ToString());
                listItem.SubItems.Add(i.Name);
                listItem.SubItems.Add(i.Action);
                listItem.SubItems.Add(i.Value);
                listItem.SubItems.Add(i.PrimaryValue);
                listVariables.Items.Add(listItem);
            }
        }
Esempio n. 5
0
        private void toolStripSaveSession_Click(object sender, EventArgs e)
        {
            EnvironmentSessionSaveForm dlgSave = new EnvironmentSessionSaveForm(_session);

            if (dlgSave.ShowDialog() == DialogResult.OK)
            {
                EnvironmentSession sessionToStore = dlgSave.Session;

                EnvironmentSessionProvider.SaveSession(sessionToStore.Name, sessionToStore);

                // remove all stored items from current session, if requested:
                if (dlgSave.ClearCurrentSession)
                {
                    foreach (EnvironmentSessionItem item in sessionToStore.Items)
                    {
                        _session.Remove(item.Name);
                    }
                }
            }
        }
 public EnvironmentSessionSaveForm(EnvironmentSession session)
 {
     InitializeComponent();
     LoadSession(session);
 }
 public EnvironmentSessionItemsForm(EnvironmentSession session)
 {
     InitializeComponent();
     SetSession(session);
 }