Exemplo n.º 1
0
        public Form_Outline(VolumeService volumeService, Id currentCitation, int left, int top, int width, int height)
        {
            InitializeComponent();

            Left   = left;
            Top    = top;
            Width  = width;
            Height = height;

            if (m_DBService == null)
            {
                Mef.Compose(this);
            }

            References = m_VolumeService.GetAllReferences();

            CitationReferences = CreateCitationReferenceList(References, m_VolumeService.Citations);

            listBox1.DrawItem    += ListBox1_DrawItem;
            listBox1.MeasureItem += ListBox1_MeasureItem;
            listBox1.DataSource   = CitationReferencesFiltered;

            CitationReference sel = CitationReferences.SingleOrDefault(x => x.Citation?.Id == currentCitation);

            if (sel != null)
            {
                listBox1.SelectedItem = sel;
            }
        }
Exemplo n.º 2
0
        private void ListBox1_DrawItem(object sender, DrawItemEventArgs e)
        {
            e.DrawBackground();
            e.DrawFocusRectangle();

            //Rectangle rc = new Rectangle(e.Bounds.X + 1, e.Bounds.Y + 1, e.Bounds.Width - 5, e.Bounds.Height - 3);
            //e.Graphics.FillRectangle(new SolidBrush(Color.CornflowerBlue), rc);
            StringFormat sf = new StringFormat();

            sf.Alignment   = StringAlignment.Near;
            sf.Trimming    = StringTrimming.EllipsisCharacter;
            sf.FormatFlags = StringFormatFlags.NoWrap;

            CitationReference citRef = CitationReferences[e.Index];
            string            indent = "";

            Font theFont = Font;

            if (citRef.Reference is null)
            {
                indent = "       ";
            }
            else if (citRef.Reference is Book)
            {
                theFont = new Font(FontFamily.GenericSerif, 14, FontStyle.Bold | FontStyle.Underline);
            }
            else if (citRef.Reference is Chapter)
            {
                theFont = new Font(FontFamily.GenericSansSerif, 12, FontStyle.Bold);
                indent  = "  ";
            }
            else if (citRef.Reference is SubChapter)
            {
                theFont = new Font(FontFamily.GenericSansSerif, 12, FontStyle.Bold | FontStyle.Italic);
                indent  = "    ";
            }
            else if (citRef.Reference is Paragraph)
            {
                theFont = new Font(FontFamily.GenericSansSerif, 11, FontStyle.Bold);
                indent  = "      §";
            }

            e.Graphics.DrawString(indent + citRef.ToString().Replace("\n", " ").Replace("\r", " "),
                                  theFont,
                                  new SolidBrush(Color.Black),
                                  e.Bounds,
                                  sf);
        }
Exemplo n.º 3
0
        internal bool Filter(CitationReference x)
        {
            if (x.Citation == null)
            {
                return(true);
            }

            if (string.IsNullOrWhiteSpace(textBox_search.Text))
            {
                return(true);
            }

            string searchString = textBox_search.Text.Trim().ToLower();

            return
                (x.Citation.Citation2.ToLower().Contains(searchString) ||
                 x.Citation.Id.ToStringShort().StartsWith(searchString, StringComparison.OrdinalIgnoreCase));
        }