Пример #1
0
        public void Fill(IEnumerable <RunConfiguration> configurations)
        {
            var currentRow = list.SelectedRow;

            listStore.Clear();
            foreach (var c in configurations)
            {
                var r    = listStore.AddRow();
                var txt  = "<b>" + c.Name + "</b>\n" + c.Summary;
                var icon = !string.IsNullOrEmpty(c.IconId) ? ImageService.GetIcon(c.IconId) : ImageService.GetIcon("md-prefs-play", Gtk.IconSize.Dnd);
                listStore.SetValues(r, configCol, c, configNameCol, txt, configIconCol, icon, accessibleCol, c.Name + " " + c.Summary);
            }
            if (currentRow != -1)
            {
                if (currentRow < listStore.RowCount)
                {
                    list.SelectRow(currentRow);
                }
                else
                {
                    list.SelectRow(listStore.RowCount - 1);
                }
            }
            else if (listStore.RowCount > 0)
            {
                list.SelectRow(0);
            }
        }
Пример #2
0
        public override IScrollableWidget CreateScrollableWidget()
        {
            DataField <string> text = new DataField <string> ();
            ListStore          s    = new ListStore(text);
            var list = new ListView(s);

            list.Columns.Add("Hi", text);

            for (int n = 0; n < 100; n++)
            {
                var r = s.AddRow();
                s.SetValue(r, text, n + new string ('.', 100));
            }
            return(list);
        }
Пример #3
0
        void UpdateFaceList(Font font)
        {
            storeFace.Clear();
            int row = -1;

            foreach (var face in font.GetAvailableFontFaces())
            {
                row = storeFace.AddRow();
                storeFace.SetValues(row, dfaceName, face.Name, dfaceFont, face.Font, dfaceMarkup, "<span font=\"" + face.Font.WithSize(listFace.Font.Size) + "\">" + face.Name + "</span>");
            }
            if (row >= 0)
            {
                listFace.SelectRow(0);
            }
            listFace.QueueForReallocate();
        }
Пример #4
0
        public DefaultFontSelectorBackend()
        {
            families = Font.AvailableFontFamilies.ToList();
            families.Sort();

            storeFonts               = new ListStore(dfamily, dfamilymarkup);
            listFonts.DataSource     = storeFonts;
            listFonts.HeadersVisible = false;
            listFonts.Columns.Add("Font", new TextCellView()
            {
                TextField = dfamily, MarkupField = dfamilymarkup
            });
            listFonts.MinWidth = 150;

            foreach (var family in families)
            {
                var row = storeFonts.AddRow();
                storeFonts.SetValues(row, dfamily, family, dfamilymarkup, "<span font=\"" + family + " " + (listFonts.Font.Size) + "\">" + family + "</span>");
            }

            storeFace               = new ListStore(dfaceName, dfaceMarkup, dfaceFont);
            listFace.DataSource     = storeFace;
            listFace.HeadersVisible = false;
            listFace.Columns.Add("Style", new TextCellView()
            {
                TextField = dfaceName, MarkupField = dfaceMarkup
            });
            listFace.MinWidth = 60;
            //listFace.HorizontalScrollPolicy = ScrollPolicy.Never;

            foreach (var size in DefaultFontSizes)
            {
                listSize.Items.Add(size);
            }

            spnSize.Digits         = 1;
            spnSize.MinimumValue   = 1;
            spnSize.MaximumValue   = 800;
            spnSize.IncrementValue = 1;
            PreviewText            = "The quick brown fox jumps over the lazy dog.";

            spnSize.ValueChanged += (sender, e) => {
                if (DefaultFontSizes.Contains(spnSize.Value))
                {
                    var row = Array.IndexOf(DefaultFontSizes, spnSize.Value);
                    listSize.ScrollToRow(row);
                    listSize.SelectRow(row);
                }
                else
                {
                    listSize.UnselectAll();
                }
                SetFont(selectedFont.WithSize(spnSize.Value));
            };

            SelectedFont = Font.SystemFont;
            UpdateFaceList(selectedFont);              // family change not connected at this point, update manually


            listFonts.SelectionChanged += (sender, e) => {
                if (listFonts.SelectedRow >= 0)
                {
                    var newFont = selectedFont.WithFamily(storeFonts.GetValue(listFonts.SelectedRow, dfamily));
                    UpdateFaceList(newFont);
                    SetFont(newFont);
                }
            };

            listFace.SelectionChanged += (sender, e) => {
                if (listFace.SelectedRow >= 0)
                {
                    SetFont(storeFace.GetValue(listFace.SelectedRow, dfaceFont).WithSize(selectedFont.Size));
                }
            };

            listSize.SelectionChanged += (sender, e) => {
                if (listSize.SelectedRow >= 0 && Math.Abs(DefaultFontSizes [listSize.SelectedRow] - spnSize.Value) > double.Epsilon)
                {
                    spnSize.Value = DefaultFontSizes[listSize.SelectedRow];
                }
            };

            VBox familyBox = new VBox();

            familyBox.PackStart(new Label("Font:"));
            familyBox.PackStart(listFonts, true);

            VBox styleBox = new VBox();

            styleBox.PackStart(new Label("Style:"));
            styleBox.PackStart(listFace, true);

            VBox sizeBox = new VBox();

            sizeBox.PackStart(new Label("Size:"));
            sizeBox.PackStart(spnSize);
            sizeBox.PackStart(listSize, true);

            HBox fontBox = new HBox();

            fontBox.PackStart(familyBox, true);
            fontBox.PackStart(styleBox, true);
            fontBox.PackStart(sizeBox);

            VBox mainBox = new VBox();

            mainBox.MinWidth  = 350;
            mainBox.MinHeight = 300;
            mainBox.PackStart(fontBox, true);
            mainBox.PackStart(new Label("Preview:"));
            mainBox.PackStart(previewText);

            Content = mainBox;
        }