Exemplo n.º 1
0
        private void AddGCNToList(GCNotification gcn, String keyIcon, List <GCNotification> lst, bool special = false, int index = -1)
        {
            String sLat2  = CoordConvHMI.ConvertDegreesToDDMM(gcn.dlat, true);
            String sLon2  = CoordConvHMI.ConvertDegreesToDDMM(gcn.dlon, false);
            String coord  = /*"DD° MM.MMM: " + */ sLat2 + " " + sLon2 + "\r\n";
            String radius = gcn.distance.ToString() + " Km";

            String lbl = gcn.name;

            if (special)
            {
                lbl = gcn.GetTypeKeyInEnglish();
            }

            EXImageListViewItem lvi = null;

            if (special)
            {
                lvi = new EXImageListViewItem(lbl, _daddy.GetImageSized("Nothing"));
                EXImageListViewSubItem svi2 = new EXImageListViewSubItem(_daddy.GetImageSized(keyIcon));
                lvi.SubItems.Add(svi2);
            }
            else
            {
                lvi = new EXImageListViewItem(lbl, _daddy.GetImageSized(keyIcon));
                EXImageListViewSubItem svi2 = new EXImageListViewSubItem("");
                lvi.SubItems.Add(svi2);
            }
            if (lst.Count != 1)
            {
                lvi.Font = MyTools.ChangeFontStyle(lvi.Font, true, false);

                EXImageListViewSubItem svi2 = new EXImageListViewSubItem("");
                lvi.SubItems.Add(svi2);
            }
            else
            {
                if (gcn.checknotif)
                {
                    EXImageListViewSubItem svi2 = new EXImageListViewSubItem(_daddy.GetImageSized("bulletgreen"));
                    lvi.SubItems.Add(svi2);
                }
                else
                {
                    EXImageListViewSubItem svi2 = new EXImageListViewSubItem(_daddy.GetImageSized("bulletred"));
                    lvi.SubItems.Add(svi2);
                }
            }

            EXListViewSubItem svi = null;

            if (special)
            {
                svi = new EXListViewSubItem("");
                lvi.SubItems.Add(svi);
                svi = new EXListViewSubItem("");
                lvi.SubItems.Add(svi);
            }
            else
            {
                svi = new EXListViewSubItem(coord);
                lvi.SubItems.Add(svi);
                svi = new EXListViewSubItem(radius);
                lvi.SubItems.Add(svi);
            }
            String kind = "";

            if (lst.Count == 1)
            {
                foreach (String k in gcn.kindofnotifnames)
                {
                    kind += k + " - ";
                }
            }
            svi = new EXListViewSubItem(kind);
            lvi.SubItems.Add(svi);

            if (special)
            {
                lvGCNListGroup.Items.Insert(index + 1, lvi);
            }
            else
            {
                lvGCNListGroup.Items.Add(lvi);
            }

            _dicoItemGCs.Add(lvi, lst);
        }
Exemplo n.º 2
0
        private void PopulateWithTSI(ListView lv, ToolStripMenuItem tsi, bool labelonly = false)
        {
            if ((tsi != null) && (tsi.Name != ""))             // Si on a un nom vide, de toute façon on ne sait rien faire
            {
                // On regarde si on est dans les golds et que nous ne sommes pas gold
                bool special = SpecialFeatures.SpecialFeaturesMgt.AreSpecialFeaturesEnabled();
                if (!special)
                {
                    foreach (var o in _daddy._menuEntriesRequiringSpecialFeatures)
                    {
                        if (o == tsi)
                        {
                            return;                     // Pas d'ajout de ce truc !
                        }
                    }
                }


                if ((tsi.DropDownItems.Count != 0) && (!labelonly))
                {
                    AddSeparator(lv);
                }

                // Et lui même
                String       lbl  = tsi.Text.Replace("&", "");
                ListViewItem item = lv.Items.Add(lbl);
                if (_daddy._imgMenus.ContainsKey(tsi.Name))
                {
                    item.ImageKey = tsi.Name;             // on a une icone
                }
                else
                {
                    _imageList.Images.Add(tsi.Name, MyTools.CreateToolbarImage(lbl, (_colorandpen[_indexColor].Item2)?Color.White:Color.Black, Color.FromName(_colorandpen[_indexColor].Item1)));
                    item.ImageKey = tsi.Name;             // on a créé une icone "nomenuicon";
                    _indexColor   = (_indexColor + 1) % (_colorandpen.Count);
                }

                if (!labelonly)
                {
                    item.Tag = tsi.Name;
                }
                else
                {
                    // Une tête de menu
                    item.Font = MyTools.ChangeFontStyle(item.Font, true, true);
                    //item.BackColor = Color.LightGreen;
                }

                if ((tsi.DropDownItems.Count != 0) && (!labelonly))
                {
                    item.Font = MyTools.ChangeFontStyle(item.Font, false, true);
                    item.Tag  = null;                    // Les menus ne sont pas ajoutables dans la toolbar
                }

                // Les entrées du menu
                foreach (var sub in tsi.DropDownItems)
                {
                    ToolStripMenuItem tsis = sub as ToolStripMenuItem;
                    if (tsis != null)
                    {
                        PopulateWithTSI(lv, tsis);
                    }
                    else
                    {
                        ToolStripSeparator tsp = sub as ToolStripSeparator;
                        if (tsp != null)
                        {
                            AddSeparator(lv);
                        }
                        else
                        {
                            // Un label ?
                            ToolStripLabel tsl = sub as ToolStripLabel;
                            if (tsl != null)
                            {
                                var tsli = lv.Items.Add(tsl.Text);
                                tsli.ImageKey = tsl.Name;
                                tsli.Font     = MyTools.ChangeFontStyle(tsli.Font, true, false);
                            }
                        }
                    }
                }
                // On ajoute un séparateur après pour isoler le menu
                if (tsi.DropDownItems.Count != 0)
                {
                    AddSeparator(lv);
                }
            }
        }