public override bool Draw(IRichPane rp) { if (IsMasking) { var sr = rp.GetPaneRect(); rp.Graphics.DrawString("PAUSE", _font, Brushes.DarkGray, sr.LT.X + 48, sr.RB.Y - 42); } else { // Left side RED curtain var sr = rp.GetPaneRect(); var W = 240; var rc1 = ScreenRect.FromLTWH(sr.LT.X, sr.LT.Y, W, sr.Height); rp.Graphics.FillRectangle(new LinearGradientBrush(new Point(0, 0), new PointF(W, 0), Color.FromArgb(128, 255, 0, 0), Color.FromArgb(0, 255, 0, 0)), rc1); // Now pointer RED curtain var now = DateTime.Now; now = new DateTime(now.Year, now.Month, now.Day, now.Hour, now.Minute, now.Second); var rc2 = GetScRect(rp, CodeRect.FromLTRB((int)(now - Hot.FirstSpeech).TotalSeconds, 0, 0, 0)); rc2 = ScreenRect.FromLTRB(rc2.LT.X, sr.LT.Y, sr.RB.X, sr.RB.Y); rp.Graphics.FillRectangle(new LinearGradientBrush(new Point(rc2.LT.X, rc2.LT.Y), new PointF(rc2.RB.X, rc2.RB.Y), Color.FromArgb(8, 255, 0, 0), Color.FromArgb(96, 255, 0, 0)), rc2); // REC LABEL if (++_cnt % 2 == 0) { rp.Graphics.DrawString("REC", _font, Brushes.Yellow, sr.LT.X + 48, sr.RB.Y - 42); } } return(true); }
/// <summary> /// BMPキャッシュ機能を追加したレイヤー描画 /// </summary> /// <param name="pane"></param> /// <param name="layerid"></param> /// <param name="pts"></param> protected override void drawLayer(IRichPane pane, int layerid, IEnumerable <PartsBase> pts) { if (_enabledLayers.ContainsKey(layerid)) { if (bmps.ContainKeys(pane, layerid) == false) { var pr = MotherPane.GetPaneRect(); bmps[pane, layerid] = new Bitmap(pr.Width, pr.Height); } var bmp = bmps[pane, layerid]; if (EnableShot == false) { var rp = RichPaneCustomGraphicsBinder.CreateCopy(MotherPane, Graphics.FromImage(bmp)); rp.SetParent(MotherPane); rp.Graphics.Clear(Color.Transparent); base.drawLayer(rp, layerid, pts); var sr = pane.GetPaneRect(); MotherPane.Graphics.DrawImageUnscaledAndClipped(bmp, sr); panebak[pane, layerid] = rp; } else { var sr = pane.GetPaneRect(); var rpbak = panebak[pane, layerid]; // pane.Graphics.SetClip(sr); sr += ScreenPos.FromInt(pane.Scroll.X - rpbak.Scroll.X, pane.Scroll.Y - rpbak.Scroll.Y); MotherPane.Graphics.DrawImageUnscaledAndClipped(bmp, sr); } } else { base.drawLayer(pane, layerid, pts); } }
public void OnMouseMove(MouseState e) { _bar.MouseNow = e; // バーの位置だけ再描画 var br = _tarPane.GetPaneRect(); br.LT.X = br.RB.X - PartsScrollbarV.Width; Pane.Invalidate(br); if (_bar.IsOn) { var k = _speed * _bar.Acc; var ly = (_downPos.Y - e.Pos.Y) * k; ly = Math.Pow(Math.Abs(ly), 1.25) * (ly > 0 ? 1 : -1); // たくさん移動したら、加速度的に移動する Pane.Scroll = ScreenPos.FromInt(Pane.Scroll.X, _downScroll.Y + (int)ly); _bar.SetHighlight(false); Pane.Invalidate(null); } else { _bar.SetHighlight(true); } }
public void OnMouseMove(MouseState e) { _bar.MouseNow = e; // バーの位置だけ再描画 var br = _tarPane.GetPaneRect(); br.LT.Y = br.RB.Y - PartsScrollbarH.Height; Pane.Invalidate(br); if (_bar.IsOn) { var k = Pane.Zoom.X > 84 ? Pane.Zoom.X / 84 : 1.0; k *= _speed * _bar.Acc; var lx = (_downPos.X - e.Pos.X) * k; lx = Math.Pow(Math.Abs(lx), 1.25) * (lx > 0 ? 1 : -1); // たくさん移動したら、加速度的に移動する Pane.Scroll = ScreenPos.FromInt(_downScroll.X + (int)lx, Pane.Scroll.Y); _bar.SetHighlight(false); Pane.Invalidate(null); } else { _bar.SetHighlight(true); } }
/// <summary> /// ログの表示更新を試みる /// </summary> private void refresh() { if (LOG.CheckAndClearRequestFlag()) { var sr = _tarPane.GetPaneRect(); sr.LT.Y = sr.RB.Y - _lp.Rect.Height; Pane.Invalidate(sr); } Timer.AddTrigger(500, new GuiTimer.Proc0(refresh)); }
/// <summary> /// 指定座標が描画クリップ内かどうか識別する /// </summary> /// <param name="rp">ペーン</param> /// <returns>true = 調査範囲が描画クリップ内 / false = そうでない</returns> public bool isInClip(IRichPane rp) { var rect = GetScRect(rp, Rect); var r = rect & rp.GetPaneRect(); return(r != null); }
private void UpdateBoxValue() { if (!IsInput && !IsFormClosing) { try { var cpos = Hot.TimelineParts.GetCdPos(TarPane, TarPane.GetPaneRect().LT); var tartime = Hot.FirstSpeech + TimeSpan.FromSeconds(cpos.X); ThreadSafe.SetTextControl(Box, lastTimeText = tartime.ToString(TimeUtil.FormatHMS)); } catch { } } if (!IsFormClosing) { Timer.AddTrigger(500, UpdateBoxValue); } }
/// <summary> /// 指定ペーンのパーツを削除する /// </summary> public override void Clear(IRichPane targetPane) { lock (_data) { if (_data.TryGetValue(targetPane, out var ls)) { ls.Clear(); targetPane.Invalidate(targetPane.GetPaneRect()); // 削除した様子を再描画 } } }
/// <summary> /// 指定量のズームを行う /// </summary> /// <param name="value"></param> private void zoom(int x, int y) { // 選択ペーンの描画領域の中心をズームのセンターの設定 var _posDown = new ScreenPos { X = _tarPane.GetPaneRect().LT.X + _tarPane.GetPaneRect().Width / 2 - _tarPane.GetPaneRect().LT.X, Y = _tarPane.GetPaneRect().LT.Y + _tarPane.GetPaneRect().Height / 2 - _tarPane.GetPaneRect().LT.Y }; var _scrollDown = (ScreenPos)Pane.Scroll.Clone(); var _zoomDown = (XyBase)Pane.Zoom.Clone(); // 画面の拡大/縮小 XyBase zoomNow; if (_isX && !_isY) { zoomNow = Pane.Zoom + XyBase.FromInt(x, 0); // ズーム値の算出 } else if (!_isX && _isY) { zoomNow = Pane.Zoom + XyBase.FromInt(0, y); // ズーム値の算出 } else { zoomNow = Pane.Zoom + x; // ズーム値の算出 } // ズーム値を規定範囲内に収める if (zoomNow.X > 4000) { zoomNow.X = 4000; } if (zoomNow.Y > 4000) { zoomNow.Y = 4000; } if (zoomNow.X < 5) { zoomNow.X = 5; } if (zoomNow.Y < 5) { zoomNow.Y = 5; } Pane.Zoom = (XyBase)zoomNow.Clone(); // ズーム値の反映 // クリックした位置を基準にしてズームするように画面をスクロールする。 var ZoomRatioX = (double)zoomNow.X / _zoomDown.X; // X方向のズーム率の算出 var ZoomRatioY = (double)zoomNow.Y / _zoomDown.Y; // Y方向のズーム率の算出 var beforeDownPos = _posDown - _scrollDown - _tarPane.GetPaneRect().LT; // var afterDownPos = ScreenPos.FromInt((int)(ZoomRatioX * beforeDownPos.X), (int)(ZoomRatioY * beforeDownPos.Y)); Pane.Scroll = _scrollDown - (afterDownPos - beforeDownPos); Pane.Invalidate(null); }
/// <summary> /// オートスクロールする /// </summary> public void autoScroll() { try { var e = MouseState.Now; _timer = null; var pp = 0; if (e.Attr.IsButton) { var pr = _tarPane.GetPaneRect(); e.Pos = ThreadSafe.PointToClient(_tarPane.Control, e.Pos); if (e.Pos.Y > -24 && e.Pos.Y < pr.Height + 24) { if (e.Pos.X < 16) { pp = 20; } if (e.Pos.X > pr.Width - 32) { pp = -20; } } } if (pp != 0) { Pane.Scroll = ScreenPos.FromInt(Pane.Scroll.X + pp, Pane.Scroll.Y); Pane.Invalidate(null); _timer = Timer.AddTrigger(100, new GuiTimer.Proc0(autoScroll)); } else { _timer = null; } } catch (Exception) { } }
/// <summary> /// 指定座標が描画クリップ内かどうか識別する /// </summary> /// <param name="rp">ペーン</param> /// <param name="rect">調査範囲</param> /// <returns>true = 調査範囲が描画クリップ内 / false = そうでない</returns> //[DebuggerStepThrough] protected bool isInClip(IRichPane rp, ScreenRect rect0) { var rect = (ScreenRect)rect0.Clone(); if (rect.Width < 1) { rect.RB.X = rect0.LT.X + 1; } var r = rect & rp.GetPaintClipRect(); if (r == null) { return(false); } r = rect & rp.GetPaneRect(); if (r == null) { return(false); } return(true); }
/// <summary> /// 描画 /// </summary> /// <param name="rp"></param> /// <returns></returns> public override bool Draw(IRichPane rp) { if (Visible) { var sr = rp.GetPaneRect(); sr.LT.X += _margin.LT.X; sr.RB.X -= _margin.RB.X; sr.RB.Y -= _margin.RB.Y; if (Rect.Height < 1) { return(true); } #region 領域の矩形 var lgb = createLogPanelBG(sr); sr.LT.Y = sr.RB.Y - Rect.Height; rp.Graphics.DrawLine(_pRegionShadow, sr.RB.X, sr.LT.Y, sr.RB.X, sr.RB.Y); rp.Graphics.DrawLine(_pRegionShadow, sr.LT.X, sr.RB.Y, sr.RB.X, sr.RB.Y); rp.Graphics.FillRectangle(lgb, sr); lgb.Dispose(); #endregion #region タイトルボーダー Brush _bd = new SolidBrush(Color.FromArgb(64, 0, 0, 0)); var b = 8; var w3 = sr.Width / 4; var pst = new Point[] { new Point(sr.LT.X, sr.LT.Y + b + 16), new Point(sr.LT.X, sr.LT.Y), new Point(sr.RB.X, sr.LT.Y), }; var psb = new Point[] { new Point(sr.RB.X, sr.LT.Y + b), new Point(sr.RB.X - w3, sr.LT.Y + b + 2), new Point(sr.RB.X - w3 * 2, sr.LT.Y + b + 8), new Point(sr.RB.X - w3 * 3, sr.LT.Y + b + 16), new Point(sr.LT.X, sr.LT.Y + b + 16), }; var ps = new Point[pst.Length + psb.Length]; int i; for (i = 0; i < pst.Length; i++) { ps[i] = pst[i]; } for (var j = 0; j < psb.Length; j++) { ps[i++] = psb[j]; } rp.Graphics.FillPolygon(_bd, ps); _bd.Dispose(); // ハイライト using (var p = new Pen(Color.FromArgb(96, 255, 255, 255))) { rp.Graphics.DrawLines(p, pst); } // シャドウ using (var p = new Pen(Color.FromArgb(96, 0, 0, 0))) { rp.Graphics.DrawLines(p, psb); } #endregion // タイトルメッセージ var btr = sr.Clone() as ScreenRect; btr.RB.X = btr.LT.X + 24; btr.RB.Y = btr.LT.Y + 12; btr += XyBase.FromInt(4, 4); var titlestr = Mes.Current["LogGroupPanel", "Title"]; rp.Graphics.DrawString(titlestr, _fontTitle, new SolidBrush(Color.FromArgb(192, 192, 255)), btr.LT.X, btr.LT.Y); btr += XyBase.FromInt((int)rp.Graphics.MeasureString(titlestr, _fontTitle).Width + 8, 0); // 表示レベルボタン _clickArea.Clear(); ScreenPos pos; pos = savePos(LLV.ERR, btr.LT + XyBase.FromInt(0 - (int)(LOG.JumpErr.R / 2), LOG.JumpErr.Y)); rp.Graphics.DrawImage(LOG.ErrSw ? Properties.Resources.lp_Err_on : Properties.Resources.lp_Err_off, pos.X, pos.Y, (float)(LOG.JumpErr.R + Properties.Resources.lp_Err_on.Width), (float)(LOG.JumpErr.R + Properties.Resources.lp_Err_on.Height)); pos = savePos(LLV.WAR, btr.LT + XyBase.FromInt(22 - (int)(LOG.JumpWar.R / 2), LOG.JumpWar.Y)); rp.Graphics.DrawImage(LOG.WarSw ? Properties.Resources.lp_War_on : Properties.Resources.lp_War_off, pos.X, pos.Y, (float)(LOG.JumpWar.R + Properties.Resources.lp_War_on.Width), (float)(LOG.JumpWar.R + Properties.Resources.lp_War_on.Height)); pos = savePos(LLV.INF, btr.LT + XyBase.FromInt(44 - (int)(LOG.JumpInf.R / 2), LOG.JumpInf.Y)); rp.Graphics.DrawImage(LOG.InfSw ? Properties.Resources.lp_Inf_on : Properties.Resources.lp_Inf_off, pos.X, pos.Y, (float)(LOG.JumpInf.R + Properties.Resources.lp_Inf_on.Width), (float)(LOG.JumpInf.R + Properties.Resources.lp_Inf_on.Height)); pos = savePos(LLV.DEV, btr.LT + XyBase.FromInt(66 - (int)(LOG.JumpDev.R / 2), LOG.JumpDev.Y)); rp.Graphics.DrawImage(LOG.DevSw ? Properties.Resources.lp_Dev_on : Properties.Resources.lp_Dev_off, pos.X, pos.Y, (float)(LOG.JumpDev.R + Properties.Resources.lp_Dev_on.Width), (float)(LOG.JumpDev.R + Properties.Resources.lp_Dev_on.Height)); // クローズボタン pos = savePos(0, btr.LT + XyBase.FromInt(100 - (int)(LOG.JumpDev.R / 2), LOG.JumpDev.Y)); rp.Graphics.DrawImage(LOG.DevSw ? Properties.Resources.Cancel : Properties.Resources.Cancel, (float)pos.X, pos.Y, 16, 16); // テキスト表示領域のみ sr.Deflate(2); sr.LT.X += 16; sr.LT.Y += b + 16; // for test rp.Graphics.DrawLine(Pens.White, sr.LT, sr.RB); // メッセージ表示 var ms = rp.Graphics.MeasureString("AX08iIay", _font); float lm = 2; // 行間 var y1 = ms.Height + lm; var dispLineN = (int)(sr.Height / y1); float curN = LOG.GetCurrentCount(); float btY; if (curN < dispLineN) { btY = sr.RB.Y - (int)(dispLineN - curN + 1) * y1; } else { btY = sr.RB.Y - y1; } var lu = LOG.GetCurrentLast(); for (; ;) { if (btY < sr.LT.Y - 2 || lu == null) { break; } var br = _bInf; switch (lu.Value.Level) { case LLV.WAR: br = _bWar; break; case LLV.ERR: br = _bErr; break; case LLV.DEV: br = _bDev; break; case LLV.INF: br = _bInf; break; case LLV.TODO: br = _bTodo; break; } rp.Graphics.DrawString(lu.Value.Mes, _font, br, new PointF(sr.LT.X, btY)); rp.Graphics.DrawLine(_pLine, sr.LT.X, btY + y1 - 3, sr.RB.X, btY + y1 - 3); if (lu.Value.Icon != null) { rp.Graphics.DrawImageUnscaled(lu.Value.Icon, sr.LT.X - 17, (int)(btY - 1)); } btY -= y1; lu = lu.Previous; } } return(true); }
/// <summary> /// 指定パーツを再描画要求する /// </summary> /// <param name="parts">再描画するパーツの領域</param> /// <param name="rp">指定パーツに属すリッチペーン</param> public virtual void Invalidate(PartsBase parts, IRichPane rp) { var r = ((ScreenRect)parts.GetScRect(rp, parts.Rect).GetPpSize()) & rp.GetPaneRect(); rp.Invalidate(r); }
public override bool Draw(IRichPane rp) { var paneRect = rp.GetPaneRect(); var sr0 = GetScRect(rp); var sr = ScreenRect.FromLTRB(paneRect.LT.X, paneRect.LT.Y, paneRect.RB.X, paneRect.LT.Y + sr0.Height); rp.Graphics.SmoothingMode = SmoothingMode.HighQuality; rp.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(64, 0, 32, 64)), sr); // Background var nowr = GetScRect(rp, CodeRect.FromLTRB((int)(DateTime.Now - Hot.FirstSpeech).TotalSeconds, 0, 0, 0)); var span = GetSpan(rp); var sec1 = GetCdPos(rp, sr.LT).X; // Code.X --> Seconds from Hot.FirstSpeech var sec0 = sec1 / span * span; int sec; for (sec = sec0; ; sec += span) { var time = Hot.FirstSpeech + TimeSpan.FromSeconds(sec); if (time + TimeSpan.FromSeconds(1) > DateTime.Now) { break; } var r = GetScRect(rp, CodeRect.FromLTRB(sec, 0, 0, 0)); if (r.LT.X > sr.RB.X) { break; } // LINE if (Math.Abs(r.LT.X - nowr.LT.X) > 8) { rp.Graphics.DrawLine(new Pen(Color.FromArgb((time.Second % 10 == 0 ? 128 : 72), Color.SteelBlue), 0.5f), r.LT.X, sr.RB.Y - (time.Second == 0 ? 8 : 2), r.LT.X, paneRect.RB.Y); } // SECOND LABEL if (time.Second != 0 && Math.Abs(r.LT.X - nowr.LT.X) > 16) { rp.Graphics.DrawString(time.ToString("ss"), FontSec, Brushes.DarkGray, r.LT.X, sr.RB.Y - 6, new StringFormat { Alignment = StringAlignment.Center, Trimming = StringTrimming.None, }); } } span = Math.Max(span, 60); sec = sec / span * span; var x = paneRect.RB.X + 999; for (; ; sec -= span) { var time = Hot.FirstSpeech + TimeSpan.FromSeconds(sec); if (time >= DateTime.Now) { continue; } var r = GetScRect(rp, CodeRect.FromLTRB(sec, 0, 0, 0)); // TIME LABEL var a = (int)Math.Max(0.0, Math.Min((double)(x - 32) / 110 * 255, 255)); var br = a >= 255 ? Brushes.White : new SolidBrush(Color.FromArgb(a, Color.White)); x = Math.Max(r.LT.X, 16); if (Math.Abs(x - nowr.LT.X) > 36) { rp.Graphics.DrawString(time.ToString(TimeUtil.FormatHM), FontTime, br, x, sr.LT.Y + 2, new StringFormat { Alignment = StringAlignment.Center, Trimming = StringTrimming.None, }); } if (r.LT.X < 0) { break; } } // DRAW NOW { // LINE rp.Graphics.DrawLine(Pens.DarkGreen, nowr.LT.X, sr.RB.Y, nowr.LT.X, paneRect.RB.Y); // SECOND LABEL rp.Graphics.DrawString(DateTime.Now.ToString("ss"), FontSecNow, Brushes.LimeGreen, nowr.LT.X, sr.RB.Y - 8, new StringFormat { Alignment = StringAlignment.Center, Trimming = StringTrimming.None, }); // TIME LABEL rp.Graphics.DrawString(DateTime.Now.ToString(TimeUtil.FormatHM), FontTimeNow, Brushes.LimeGreen, nowr.LT.X, sr.LT.Y + 1, new StringFormat { Alignment = StringAlignment.Center, Trimming = StringTrimming.None, }); } // rp.Graphics.DrawLine(Pens.White, paneRect.RT, paneRect.LB); // for TEST return(true); }