Example #1
0
        public static DataTable ListViewToDataTable(ListViewEx list)
        {
            var dt = new DataTable("Data");

            list.Invoke(new Action(() =>
            {
                foreach (var listColumn in list.Columns)
                {
                    dt.Columns.Add((listColumn as ColumnHeader).Text);
                }
                int c = 0;

                foreach (var listItem in list.Items)
                {
                    var item   = listItem as ListViewItem;
                    var values = new object[dt.Columns.Count];
                    for (int i = 0; i < item.SubItems.Count; i++)
                    {
                        values[i] = item.SubItems[i].Text;
                    }


                    dt.Rows.Add(values);
                }
            }));
            return(dt);
        }
Example #2
0
        public static DataTable ListViewToDataTable(ListViewEx list, BackgroundWorker bw)
        {
            var dt = new DataTable("Data");

            list.Invoke(new Action(() =>
            {
                foreach (var listColumn in list.Columns)
                {
                    dt.Columns.Add((listColumn as ColumnHeader).Text);
                }
                int c = 0;

                foreach (var listItem in list.Items)
                {
                    bw.ReportProgress((int)((c / (double)list.Items.Count) * 100), "Converting...");
                    var item   = listItem as ListViewItem;
                    var values = new object[dt.Columns.Count];
                    for (int i = 0; i < item.SubItems.Count; i++)
                    {
                        values[i] = item.SubItems[i].Text;
                    }


                    dt.Rows.Add(values);
                }
            }));
            return(dt);
        }
Example #3
0
        public void LoadContentsadd(int archid, ListViewEx lsv, bool ch, int info)
        {
            if (archid <= 0)
            {
                return;
            }
            if (loadcon)
            {
                return;
            }
            loadcon = true;
            try {
                lsv.Items.Clear();
                PageCount.Clear();
                DataTable dt = Common.LoadContents(ContenTable, ContenCol,
                                                   ContenPages, Convert.ToInt32(ch), archid);
                if (dt == null || dt.Rows.Count <= 0)
                {
                    return;
                }
                int i = 1;
                foreach (DataRow dr in dt.Rows)
                {
                    ListViewItem lvi = new ListViewItem();
                    lvi.Text = i.ToString();
                    string id = dr["id"].ToString();
                    lvi.SubItems.AddRange(new string[] { id });
                    for (int t = 0; t < ContenCoList.Count; t++)
                    {
                        string str = dr[ContenCoList[t]].ToString();
                        if (t == PagesWz)
                        {
                            PageCount.Add(str);
                        }
                        lvi.SubItems.AddRange(new string[] { str });
                    }
                    lsv.Invoke(new Action(() => { lsv.Items.Add(lvi); }));
                    i++;
                }

                //if (info > 0) {
                //    if (lsv.Items.Count > 0) {
                //        lsv.Items[lsv.Items.Count - 1].Selected = true;
                //        lsv.Items[lsv.Items.Count - 1].EnsureVisible();
                //    }
                //}
            } catch {
            } finally {
                loadcon = false;
            }
        }
Example #4
0
 public void UpdateList()
 {
     if (m_lvUsers.InvokeRequired)
     {
         UpdateListCallback d = new UpdateListCallback(UpdateList);
         m_lvUsers.Invoke(d);
     }
     else
     {
         foreach (Peer item in Peers)
         {
             ListViewItem test = m_lvUsers.FindItemWithText(item.CallSign);
             if (test == null)
             {
                 int Status = 0;
                 if (item.Disabled)
                 {
                     Status = 4;
                 }
                 ListViewItem P = new ListViewItem(item.CallSign, Status);
                 P.SubItems.Add(new ListViewItem.ListViewSubItem(P, ""));
                 m_lvUsers.Items.Add(P);
                 m_lvUsers.Update();
             }
         }
         for (int i = m_lvUsers.Items.Count - 1; i >= 0; i--)
         {
             Peer test = Peers.Find(x => x.CallSign == m_lvUsers.Items[i].Text);
             if (test == null)
             {
                 m_lvUsers.Items.RemoveAt(i);
                 m_lvUsers.Update();
             }
         }
     }
 }
Example #5
0
 public void AddCMD(GigCommand cmd)
 {
     try
     {
         if (this.cur.InvokeRequired)
         {
             addMessageDelegate d = new addMessageDelegate(addMessageToList);
             cur.Invoke(d, cmd);
         }
         else
         {
             addMessageToList(cmd);
         }
     }
     catch (Exception ex)
     {
         //   GigSpace.LogError(ex);
     }
 }
Example #6
0
        private void RempliTableau()
        {
            if (m_lvDonneesFS.InvokeRequired)
            {
                RempliTableauCallback d = new RempliTableauCallback(RempliTableau);
                m_lvDonneesFS.Invoke(d);
            }
            else
            {
                // On rempli la ligne correspondante dans la listview
                foreach (ListViewItem Item in m_lvDonneesFS.Items)
                {
                    if (Item.SubItems.Count < 1)
                    {
                        continue;
                    }
                    ListViewItem.ListViewSubItem Sub = Item.SubItems[1];
                    switch (Item.Text)
                    {
                    case "Titre Avion":
                        Sub.Text = GetLastState().Title;
                        break;

                    case "Type Avion":
                        Sub.Text = GetLastState().Type;
                        break;

                    case "Model Avion":
                        Sub.Text = GetLastState().Model;
                        break;

                    case "Catégorie":
                        Sub.Text = GetLastState().Category;
                        break;

                    case "Altitude Avion":
                        Sub.Text = string.Format("{0:0.} ft", GetLastState().Altitude);
                        break;

                    case "Altitude Sol":
                        Sub.Text = string.Format("{0:0.} ft", GetLastState().Altitude - GetLastState().AltitudeSol);
                        break;

                    case "Vario":
                        Sub.Text = string.Format("{0:0.} ft/min", GetLastState().Vario);
                        break;

                    case "Direction":
                        Sub.Text = string.Format("{0:0.} °", GetLastState().Heading);
                        break;

                    case "Delta Altitude":
                        Sub.Text = string.Format("{0:0.} ft", GetLastState().AltitudeSol);
                        break;

                    case "Facteur Temps":
                        Sub.Text = string.Format("{0:0}X", GetLastState().TimeFactor);
                        break;

                    case "Longitude":
                        Sub.Text = string.Format("{0:0.000}°", GetLastState().Longitude);
                        break;

                    case "Latitude":
                        Sub.Text = string.Format("{0:0.000}°", GetLastState().Latitude);
                        break;

                    case "Vitesse Sol":
                        Sub.Text = string.Format("{0:0.}Kts", GetLastState().GSpeed);
                        break;

                    case "Vitesse TAS":
                        Sub.Text = string.Format("{0:0.}Kts", GetLastState().TASSpeed);
                        break;

                    case "Carburant":
                        Sub.Text = string.Format("{0:0.}Lbs", GetLastState().Fuel);
                        break;

                    case "Cabrage Avion":
                        Sub.Text = string.Format("{0:0.0}°", GetLastState().Pitch);
                        break;

                    case "Roulis Avion":
                        Sub.Text = string.Format("{0:0.0}°", GetLastState().Bank);
                        break;

                    case "G Force":
                        Sub.Text = string.Format("{0:0.0} G", GetLastState().GForce);
                        break;

                    case "Poids Avion":
                        Sub.Text = string.Format("{0:0.}Lbs", GetLastState().PoidsAvion);
                        break;

                    case "Total Fuel Capacity":
                        Sub.Text = string.Format("{0:0} Lbs", GetLastState().TotalFuelCapacity);
                        break;

                    case "Vitesse du vent":
                        Sub.Text = string.Format("{0:0} Kts", GetLastState().AmbiantWindVelocity);
                        break;

                    case "Direction du vent":
                        Sub.Text = string.Format("{0:0} °", GetLastState().AmbiantWindDirection);
                        break;

                    case "Précipitation":
                        Sub.Text = string.Format("{0:0}", GetLastState().AmbiantPrecipState);
                        break;

                    case "Pression Atm":
                        Sub.Text = string.Format("{0:0} mBar", GetLastState().AltimeterSetting);
                        break;

                    case "Pression MSL":
                        Sub.Text = string.Format("{0:0} mBar", GetLastState().SeaLevelPressure);
                        break;

                    case "Profondeur":
                        Sub.Text = string.Format("{0:0.000}", GetLastState().ElevatorPos);
                        break;

                    case "Ailerons":
                        Sub.Text = string.Format("{0:0.000}", GetLastState().AileronPos);
                        break;

                    case "Derive":
                        Sub.Text = string.Format("{0:0.000}", GetLastState().RudderPos);
                        break;

                    case "Aerofreins":
                        Sub.Text = string.Format("{0:0.000}", GetLastState().SpoilerPos);
                        break;

                    case "Frein de parking":
                        Sub.Text = string.Format("{0:0.000}", GetLastState().ParkingBrakePos);
                        break;

                    case "Squawk":
                        Sub.Text = string.Format("{0:0}", Outils.ConvertToBinaryCodedDecimal(GetLastState().Squawk));
                        break;

                    default:
                        break;
                    }
                }
            }
        }