Beispiel #1
0
        public void AddNewNoteAccordionItem()
        {
            // Create a item with a note
            AccordionItem item = new AccordionItem(Lang.Get("note_new"), imgNote.Images[0]);

            item.Tag = new Note();             // New note

            // Setup the new text box
            RichTextBox text = new RichTextBox();

            text.LinkClicked += NoteLinkClicked;
            text.BorderStyle  = BorderStyle.None;
            text.Multiline    = true;
            text.WordWrap     = chkWordWrap.Checked;
            text.ScrollBars   = RichTextBoxScrollBars.Both;
            text.Font         = (chkMonospace.Checked ? new Font(notes_monospace_font, 10) : new Font(this.Font.FontFamily, 10));
            text.Validated   += delegate { try { ((Note)item.Tag).Text = text.Text; item.Text = ShortenString(((Note)item.Tag).Text, 50); } catch { } };
            item.Resize      += delegate { try { text.SetBounds(0, 1, item.SpaceAvailable.Width, item.SpaceAvailable.Height - 1); } catch {} };
            item.AddControl(text);

            // Add item to the accordion, select it
            accordion.AddAccordionItem(item);
            accordion.SelectItemWithAnimation(item);
            text.Focus();

            // Adjust scrolling
            RedrawNotesScroll();
        }
Beispiel #2
0
        void DrawNotesAccordion()
        {
            // Setup accordion
            panAccordion.Controls.Add(accordion);
            accordion.SetBounds(0, 0, panAccordion.Width - scrollAccordion.Width - 1, panAccordion.Height);
            accordion.MinimumContentHeight = 100;
            accordion.BackColor            = SystemColors.Control;

            // Add items, Note object as Tag
            ArrayList notes = task.GetNotes();

            foreach (Note note in notes)
            {
                AccordionItem item = new AccordionItem(ShortenString(note.Text, 50), imgNote.Images[note.Marked ? 1 : 0]);

                // Note marking on double click
                item.IconBox.Tag          = note;
                item.IconBox.DoubleClick += delegate(object sender, EventArgs e) {
                    Note note_w = (Note)(((PictureBox)sender).Tag);
                    note_w.Marked = !note_w.Marked;
                    note_w.Update();
                    item.Icon = imgNote.Images[note_w.Marked ? 1 : 0];
                };

                // Setup text box
                RichTextBox text = new RichTextBox();
                text.LinkClicked += NoteLinkClicked;
                text.BorderStyle  = BorderStyle.None;
                item.Tag          = note;
                text.Text         = note.Text;
                text.Multiline    = true;
                text.WordWrap     = chkWordWrap.Checked;
                text.ScrollBars   = RichTextBoxScrollBars.Both;
                text.Font         = (chkMonospace.Checked ? new Font(notes_monospace_font, 10) : new Font(this.Font.FontFamily, 10));
                text.Validated   += delegate { try { ((Note)item.Tag).Text = text.Text; item.Text = ShortenString(((Note)item.Tag).Text, 50); } catch { } };
                item.Resize      += delegate { try { text.SetBounds(0, 1, item.SpaceAvailable.Width, item.SpaceAvailable.Height - 1); } catch {} };
                item.AddControl(text);
                accordion.AddAccordionItem(item);
            }

            RedrawNotesScroll();
        }