コード例 #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
        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...
        }