//BACK-BURNER public static void Init(IPoderosaContainer container) { GConst.Init(); _frame = container; _textSelection = new TextSelection(); _connections = new Connections(); }
public CharacterDocumentViewer() { _enableAutoScrollBarAdjustment = true; _transientLines = new List<GLine>(); InitializeComponent(); //SetStyle(ControlStyles.UserPaint|ControlStyles.AllPaintingInWmPaint|ControlStyles.DoubleBuffer, true); this.DoubleBuffered = true; _caret = new Caret(); _splitMark = new SplitMarkSupport(this, this); Pen p = new Pen(SystemColors.ControlDark); p.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot; _splitMark.Pen = p; _textSelection = new TextSelection(this); _textSelection.AddSelectionListener(this); _mouseHandlerManager = new MouseHandlerManager(); _mouseHandlerManager.AddLastHandler(new TextSelectionUIHandler(this)); _mouseHandlerManager.AddLastHandler(new SplitMarkUIHandler(_splitMark)); _mouseHandlerManager.AttachControl(this); SetStyle(ControlStyles.SupportsTransparentBackColor, true); }
public override UIHandleResult OnMouseMove(MouseEventArgs args) { if (args.Button != MouseButtons.Left) { return(UIHandleResult.Pass); } TextSelection sel = _viewer.TextSelection; if (sel.State == SelectionState.Fixed || sel.State == SelectionState.Empty) { return(UIHandleResult.Pass); } //クリックだけでもなぜかMouseDownの直後にMouseMoveイベントが来るのでこのようにしてガード。でないと単発クリックでも選択状態になってしまう if (sel.StartX == args.X && sel.StartY == args.Y) { return(UIHandleResult.Capture); } CharacterDocument document = _viewer.CharacterDocument; lock (document) { int topline_id = _viewer.GetTopLine().ID; SizeF pitch = _viewer.GetRenderProfile().Pitch; int row, col; _viewer.MousePosToTextPos_AllowNegative(args.X, args.Y, out col, out row); int viewheight = (int)Math.Floor(_viewer.ClientSize.Height / pitch.Width); int target_id = topline_id + row; GLine target_line = document.FindLineOrEdge(target_id); TextSelection.TextPoint point = sel.ConvertSelectionPosition(target_line, col); point.Line = RuntimeUtil.AdjustIntRange(point.Line, document.FirstLineNumber, document.LastLineNumber); if (_viewer.VScrollBar.Enabled) //スクロール可能なときは { VScrollBar vsc = _viewer.VScrollBar; if (target_id < topline_id) //前方スクロール { vsc.Value = point.Line - document.FirstLineNumber; } else if (point.Line >= topline_id + vsc.LargeChange) //後方スクロール { int newval = point.Line - document.FirstLineNumber - vsc.LargeChange + 1; if (newval < 0) { newval = 0; } if (newval > vsc.Maximum - vsc.LargeChange) { newval = vsc.Maximum - vsc.LargeChange + 1; } vsc.Value = newval; } } else //スクロール不可能なときは見えている範囲で { point.Line = RuntimeUtil.AdjustIntRange(point.Line, topline_id, topline_id + viewheight - 1); } //ここさぼっている //Debug.WriteLine(String.Format("MouseMove {0} {1} {2}", sel.State, sel.PivotType, args.X)); RangeType rt = sel.PivotType; if ((Control.ModifierKeys & Keys.Control) != Keys.None) { rt = RangeType.Word; } else if ((Control.ModifierKeys & Keys.Shift) != Keys.None) { rt = RangeType.Line; } GLine tl = document.FindLine(point.Line); sel.ExpandTo(tl, point.Column, rt); } _viewer.Invalidate(); //TODO 選択状態に変化のあった行のみ更新するようにすればなおよし return(UIHandleResult.Capture); }