コード例 #1
0
 /// <summary>
 /// Decide whether to update or ignore the row
 /// </summary>
 /// <param name="a"></param>
 /// <returns></returns>
 private String getAction(SessionAction.ACTION a)
 {
     switch (a)
     {
         case SessionAction.ACTION.DELETE: { return ACTION_UPDATE; }
         case SessionAction.ACTION.ADD:    { return ACTION_UPDATE; }
         case SessionAction.ACTION.UPDATE: { return ACTION_UPDATE; }
         case SessionAction.ACTION.RENAME: { return ACTION_UPDATE; }
         case SessionAction.ACTION.NONE:   { return ACTION_IGNORE; }
         default:                          { return ACTION_IGNORE; }
     }
 }
コード例 #2
0
        /// <summary>
        /// Get the values to populate each row of the table
        /// </summary>
        /// <param name="action">The session action to process</param>
        /// <returns>The row data</returns>
        private String[] getCellValues( SessionAction action )
        {
            string sessionName = "";
            string newSessionFolder = "";
            string existingSessionFolder = "";
            string newSessionHostname = "";
            string existingSessionHostname = "";
            string newProtocol = "";
            string existingProtocol = "";
            string newPort = "";
            string existingPort = "";

            if (action.NewSession != null)
            {
                sessionName = action.NewSession.SessionDisplayText;
                newSessionFolder = action.NewSession.FolderDisplayText;
                newSessionHostname = action.NewSession.Hostname;
                newProtocol = action.NewSession.Protocol;
                newPort = action.NewSession.Portnumber.ToString();
            }

            if (action.ExistingSession != null)
            {
                if (action.Action != SessionAction.ACTION.RENAME)
                {
                    sessionName = action.ExistingSession.SessionDisplayText;
                }
                else
                {
                    sessionName = action.NewSession.SessionDisplayText + " [" +
                                  action.ExistingSession.SessionDisplayText + "]";
                }
                existingSessionFolder = action.ExistingSession.FolderDisplayText;
                existingSessionHostname = action.ExistingSession.Hostname;
                existingProtocol = action.ExistingSession.Protocol;
                existingPort = action.ExistingSession.Portnumber.ToString();
            }

            String[] cellValues = new String[] {    sessionName
                                                  , existingSessionFolder
                                                  , newSessionFolder
                                                  , existingSessionHostname
                                                  , newSessionHostname
                                                  , existingProtocol
                                                  , newProtocol
                                                  , existingPort
                                                  , newPort
                                                  , action.getActionDescription()
                                                  , getAction(action.Action)
                                                };
            return cellValues;
        }
コード例 #3
0
        /// <summary>
        /// Load sessions into the table
        /// </summary>
        /// <param name="ea"></param>
        public void LoadSessions(SyncSessionsLoadedEventArgs ea)
        {
            DataGridViewRow dgvr = null;

            sessionList = ea.SessionList;
            templateSession = ea.SessionTemplate;
            ignoreExistingSessions = ea.IgnoreExistingSessions;

            Dictionary<String,Session> sessionsDictionary = new Dictionary<string,Session>();

            dataGridView1.SuspendLayout();
            dataGridView1.Rows.Clear();

            foreach (Session newSession in sessionList)
            {
                Session existingSession = sc.findSession(newSession);
                SessionAction action = new SessionAction(existingSession, newSession);

                // Make sure we skip over duplicate sessions
                if (!sessionsDictionary.ContainsKey(newSession.SessionKey))
                {
                    sessionsDictionary.Add(newSession.SessionKey, newSession);

                    dgvr = new DataGridViewRow();
                    dgvr.CreateCells(dataGridView1, getCellValues(action));
                    dgvr.Tag = action;
                    dataGridView1.Rows.Add(dgvr);
                }
            }

            if (ea.IgnoreExistingSessions == false)
            {
                foreach (Session existingSession in sc.getSessionList())
                {
                    if (!sessionsDictionary.ContainsKey(existingSession.SessionKey))
                    {
                        SessionAction action = new SessionAction(existingSession, null);

                        dgvr = new DataGridViewRow();
                        dgvr.CreateCells(dataGridView1, getCellValues(action));
                        dgvr.Tag = action;
                        dataGridView1.Rows.Add(dgvr);
                    }
                }
            }

            dataGridView1.ResumeLayout();
        }