コード例 #1
0
ファイル: MainForm.cs プロジェクト: SeriousM/MarkdownOutline
        private void MoveBlockUpDown(OutlineBlock selectedBlock, Direction direction)
        {
            var oldBlockIndex = _outlineBlocks.IndexOf(selectedBlock);
            int newBlockIndex;

            if (direction == Direction.Up && oldBlockIndex == 0 || direction == Direction.Down && oldBlockIndex == _outlineBlocks.Count - 1)
            {
                // no up/down movement allowed because the list's border is reached
                return;
            }
            if (direction == Direction.Up)
            {
                newBlockIndex = oldBlockIndex - 1;
            }
            else if (direction == Direction.Down)
            {
                newBlockIndex = oldBlockIndex + 1;
            }
            else
            {
                return;
            }

            _outlineBlocks.Remove(selectedBlock);
            _outlineBlocks.Insert(newBlockIndex, selectedBlock);

            ReorderListViewItems(oldBlockIndex, newBlockIndex);
        }
コード例 #2
0
        public static List<OutlineBlock> ParseOutline(string[] fileContent)
        {
            var blocks = new List<OutlineBlock>();

            if (fileContent.Length == 0)
            {
                return blocks;
            }

            var block = new OutlineBlock();

            foreach (var line in fileContent)
            {
                var level = CountHash(line);
                if (level == 0)
                {
                    // nothing special, it's just a simple line
                    block.Lines.Add(line);
                }
                else if (block.Lines.Count == 0)
                {
                    block.Level = level;
                    block.Lines.Add(line.TrimStart());
                }
                else
                {
                    blocks.Add(block);
                    block = new OutlineBlock();
                    block.Level = level;
                    block.Lines.Add(line.TrimStart());
                }
            }
            blocks.Add(block);

            return blocks;
        }
コード例 #3
0
ファイル: MainForm.cs プロジェクト: SeriousM/MarkdownOutline
        private void SetItemFontSize(ListViewItem item, OutlineBlock outlineBlock)
        {
            var treeFont = OutlineListView.Font;

            var multiplicator = Math.Max(0, Math.Min(6 - outlineBlock.Level, 6));

            item.Font = new Font(treeFont.FontFamily, treeFont.Size + 0.8f * multiplicator);
        }
コード例 #4
0
ファイル: MainForm.cs プロジェクト: SeriousM/MarkdownOutline
        private void RenameItem(OutlineBlock selectedBlock, int itemIndex)
        {
            var item = OutlineListView.Items[itemIndex];
            SetItemFontSize(item, selectedBlock);
            item.Text = selectedBlock.Lines[0];

            nameHeader.AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent);
        }