Пример #1
0
        public void update(List <IMAP4Account> pRecordList)
        {
            bool lIsLastLine    = false;
            int  lLastPosition  = -1;
            int  lLastRowIndex  = -1;
            int  lSelectedIndex = -1;

            lock (this)
            {
                /*
                 * Remember DGV positions
                 */
                if (DGV_Accounts.CurrentRow != null && DGV_Accounts.CurrentRow == DGV_Accounts.Rows[DGV_Accounts.Rows.Count - 1])
                {
                    lIsLastLine = true;
                }

                lLastPosition = DGV_Accounts.FirstDisplayedScrollingRowIndex;
                lLastRowIndex = DGV_Accounts.Rows.Count - 1;

                if (DGV_Accounts.CurrentCell != null)
                {
                    lSelectedIndex = DGV_Accounts.CurrentCell.RowIndex;
                }


                cAccounts.Clear();
                foreach (IMAP4Account lTmp in pRecordList)
                {
                    cAccounts.Add(new IMAP4Account(lTmp.SrcMAC, lTmp.SrcIP, lTmp.DstIP, lTmp.DstPort, lTmp.Username, lTmp.Password, lTmp.Server));
                }

                // Selected cell/row
                try
                {
                    if (lSelectedIndex >= 0)
                    {
                        DGV_Accounts.CurrentCell = DGV_Accounts.Rows[lSelectedIndex].Cells[0];
                    }
                }
                catch (Exception) { }


                // Reset position
                try
                {
                    if (lLastPosition >= 0)
                    {
                        DGV_Accounts.FirstDisplayedScrollingRowIndex = lLastPosition;
                    }
                }
                catch (Exception) { }

                DGV_Accounts.Refresh();
            } // lock (th...
        }
Пример #2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void DGV_Accounts_MouseUp(object sender, MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Right)
     {
         try
         {
             DataGridView.HitTestInfo hti = DGV_Accounts.HitTest(e.X, e.Y);
             if (hti.RowIndex >= 0)
             {
                 CMS_PasswordProxy.Show(DGV_Accounts, e.Location);
             }
         }
         catch (Exception lEx)
         {
             PluginParameters.HostApplication.LogMessage(String.Format("{0}: {1}", Config.PluginName, lEx.Message));
         }
     } // if (e.Button ...
 }
Пример #3
0
        public void updateRecords(List <Account> pHostnameIPPair)
        {
            bool lIsLastLine    = false;
            int  lLastPosition  = -1;
            int  lLastRowIndex  = -1;
            int  lSelectedIndex = -1;

            lock (this)
            {
                /*
                 * Remember DGV positions
                 */
                if (DGV_Accounts.CurrentRow != null && DGV_Accounts.CurrentRow == DGV_Accounts.Rows[DGV_Accounts.Rows.Count - 1])
                {
                    lIsLastLine = true;
                }

                lLastPosition = DGV_Accounts.FirstDisplayedScrollingRowIndex;
                lLastRowIndex = DGV_Accounts.Rows.Count - 1;

                if (DGV_Accounts.CurrentCell != null)
                {
                    lSelectedIndex = DGV_Accounts.CurrentCell.RowIndex;
                }


                cAccounts.Clear();
                foreach (Account lTmp in pHostnameIPPair)
                {
                    try
                    {
                        cAccounts.Add(new Account(lTmp.SrcMAC, lTmp.SrcIP, lTmp.DstIP, lTmp.DstPort, lTmp.Username, lTmp.Password));
                    }
                    catch (Exception lEx)
                    {
                        PluginParameters.HostApplication.LogMessage(String.Format("{0}: {1}", Config.PluginName, lEx.Message));
                    }
                }

                // Selected cell/row
                try
                {
                    if (lSelectedIndex >= 0)
                    {
                        DGV_Accounts.CurrentCell = DGV_Accounts.Rows[lSelectedIndex].Cells[0];
                    }
                }
                catch (Exception) { }


                // Reset position
                try
                {
                    if (lLastPosition >= 0)
                    {
                        DGV_Accounts.FirstDisplayedScrollingRowIndex = lLastPosition;
                    }
                }
                catch (Exception) { }


                DGV_Accounts.Refresh();
            } // lock (thi...
        }