public void ScrollTo( VPos vp ){ // 横フォーカス int dx=0; if( vp.vx < hScrollBar.Value ){ dx = vp.vx - hScrollBar.Value; } else{ int W = cvs_.getPainter().W(); if (hScrollBar.Value + (hScrollBar.nPage - W) <= vp.vx) dx = vp.vx - (hScrollBar.Value + hScrollBar.nPage) + W; } // 縦フォーカス int dy=0; if (vp.vl < vScrollBar.Value) dy = vp.vl - vScrollBar.Value; else if (vScrollBar.Value + (vScrollBar.nPage - 1) <= vp.vl) dy = vp.vl - (vScrollBar.Value + vScrollBar.nPage) + 2; // スクロール if( dy!=0 ) //UpDown( dy, dx==0 ); //TODO scroll UpDown(dy, false); if( dx!=0 ) ScrollView( dx, 0, true ); }
public override int GetHashCode() { var hashCode = 674255106; hashCode = hashCode * -1521134295 + HPos.GetHashCode(); hashCode = hashCode * -1521134295 + VPos.GetHashCode(); hashCode = hashCode * -1521134295 + HSize.GetHashCode(); hashCode = hashCode * -1521134295 + VSize.GetHashCode(); return(hashCode); }
private void CorrectPos(ref VPos s, ref VPos e) { // 必ずs<=eになるように修正 if (s > e) { int tmp; tmp = s.ad; s.ad = e.ad; e.ad = tmp; tmp = s.tl; s.tl = e.tl; e.tl = tmp; } }
public bool LoadPostData(String postDataKey, System.Collections.Specialized.NameValueCollection values) { bool _returnV; bool _returnH; string Val = values[this.ClientID].Trim(); char Eperluette = Char.Parse("&"); string[] _Val = Val.Split(Eperluette); if (_Val.Length > 1) { if (!HPos.ToString().Equals(_Val[0]) && _Val[0].Trim() != null) { HPos = Int32.Parse(_Val[0]); _returnH = true; } else { _returnH = false; } if (!VPos.ToString().Equals(_Val[1]) && _Val[1].Trim() != null) { VPos = Int32.Parse(_Val[1]); _returnV = true; } else { _returnV = false; } } else { HPos = 0; VPos = 0; return(false); } //_______return_________ if (_returnV || _returnH) { return(false); } else { return(false); } }
public Point GetPointFromDPos(DPos dp) { int x, y; if (dp == this.cur_.Cur) { x = this.cur_.Cur.rx; y = this.cur_.Cur.vl * fnt().H(); } else { VPos vp = new VPos(); this.ConvDPosToVPos(dp, ref vp); x = vp.rx; y = vp.vl * fnt().H(); } return(new Point(x, y)); }
public override void Update(float time_elapsed) { HashTagLifeGoal?.Process(); Vector2D steeringForce = SteeringBehaviours.Calculate(); Vector2D acceleration = steeringForce.Divide(DMass); VVelocity.Add(acceleration.Multiply(time_elapsed)); VVelocity.Truncate(DMaxSpeed); VPos.Add(VVelocity.Multiply(time_elapsed)); if (VVelocity.LengthSquared() > 0.00000001) { VHeading = VVelocity.Clone().Normalize(); VSide = VHeading.Perpendicular(); } }
private string getLinkFromPositon(int x, int y) { string link = null; VPos vp = new VPos(); GetVPos(x, y, ref vp, false); var rules = doc_.Rules(vp.tl); foreach (var rule in rules) { if (((rule.attr.type & AttrType.Link) == AttrType.Link) && (vp.ad >= rule.ad && vp.ad <= (rule.ad + rule.len))) { link = doc_.tl(vp.tl).Substring(rule.ad, rule.len).ToString(); break; } } return(link); }
//private Point pp = new Point(); private void DrawTXT3(Graphics g, VDrawInfo v, Painter p) { //doc_.line(0).Block.pa //g.FillRectangle(bb, v.rc); // 定数1 // const int TAB = p.T(); int H = p.H(); int TLM = doc_.tln() - 1; int tmpYMIN = 0; int tmpTLMIN = 0; //if (DrawEventHandler == null) { // tmpYMIN = v.YMIN; // tmpTLMIN = v.TLMIN; //} //else { // var tuple = l(udScr_tl_, udScr_vrl_); // tmpYMIN = -(tuple.t2 + udScr_vrl_) * H; // tmpTLMIN = tuple.t1; //} //if (DrawEventHandler != null && v.YMIN<=0) { if (DrawEventHandler != null) { var tuple = l(udScr_tl_, udScr_vrl_); tmpYMIN = -(tuple.t2 + udScr_vrl_) * H; tmpTLMIN = tuple.t1; } else { tmpYMIN = v.YMIN; tmpTLMIN = v.TLMIN; } //var tuple = l(udScr_tl_, udScr_vrl_); //int tmpYMIN = -(tuple.t2 + udScr_vrl_) * H; //int tmpTLMIN = tuple.t1; //int testYMIN = -(tuple.t2 + udScr_vrl_) * H; //int testTLMIN = tuple.t1; // 作業用変数1 //Win32API.RECT a = new Win32API.RECT { left = 0, top = v.YMIN, right = 0, bottom = v.YMIN + p.H() }; Win32API.RECT a = new Win32API.RECT { left = 0, top = tmpYMIN, right = 0, bottom = tmpYMIN + p.H() }; //Rectangle a = new Rectangle( 0, v.YMIN, 0, v.YMIN+p.H() ); //Rectangle a = new Rectangle(0, 0,,v.YMIN); //int clr = -1; int x = 0; int xbk = 0; int i = 0; Color color = Color.Empty; Token token = null; Action <IText> draw = (itext) => { string s = itext.ToString(); int ci = s.IndexOfAny(cs, 0); if (ci < 0) { //p.DrawText(g, s, color, x + v.XBASE, a.top); p.DrawText(g, s, token.attr, x + v.XBASE, a.top); if (((token.attr.type & AttrType.Image) == AttrType.Image) && i == token.ad && DrawEventHandler != null) { //DrawEventHandler(g, s.Substring(token.ad, token.len), x + v.XBASE, a.top + H); DrawEventHandler(g, s, x + v.XBASE, a.top + H); } x += p.CalcStringWidth(s); i += itext.Length; } else { foreach (var ps in Painter.parse(s, cs)) { switch (ps[0]) { case ' ': if (ShowWhiteSpace) { p.DrawHSP(g, x + v.XBASE, a.top, ps.Length); } x += p.CalcStringWidth(ps); break; case '\x3000': //' ': if (ShowZenWhiteSpace) { p.DrawZen(g, x + v.XBASE, a.top, ps.Length); } x += p.CalcStringWidth(ps); break; case '\t': if (ShowTab) { for (int i2 = 0; i2 < ps.Length; ++i2) { int ntx = p.nextTab(x); p.DrawTab(g, x + v.XBASE, a.top, ntx - x); x = ntx; } } break; default: //p.DrawText(g, ps, color, x + v.XBASE, a.top); p.DrawText(g, ps, token.attr, x + v.XBASE, a.top); if (((token.attr.type & AttrType.Image) == AttrType.Image) && i == token.ad && DrawEventHandler != null) { DrawEventHandler(g, ps.Substring(token.ad, token.len), x + v.XBASE, a.top + H); } x += p.CalcStringWidth(ps); break; } i += ps.Length; } } p.DrawAttribute(g, token.attr, v.XBASE + xbk, a.top - 1, v.XBASE + x, a.top - 1); }; //int aTop = a.Top; //int aBottom = a.Bottom; // 論理行単位のLoop //for (int tl = tmpTLMIN; a.top < v.YMAX && tl < doc_.tln(); ++tl) { for (int tl = tmpTLMIN; a.top < v.YMAX; ++tl) { //for (int tl = tmpTLMIN; a.top < v.YMAX; ++tl) { //TODO test //string pa = doc_.line(tl).Block.PartID; // 定数2 //string str = doc_.tl(tl).ToString(); IText str = doc_.tl(tl); //if (str.Length == 0) break; //const uchar* flg = doc_.pl(tl); int rYMAX = Math.Min(v.YMAX, a.top + rln(tl) * H); // 作業用変数2 int stt = 0, end; int index = 0; int nextlen = 0; var rules = doc_.Rules(tl); if (rules.Count == 0) { return; } token = rules[index]; int tokenad = token.ad; int tokenlen = token.len; color = token.attr.color; // 表示行単位のLoop for (int rl = 0; a.top < rYMAX; ++rl, a.top += H, a.bottom += H, stt = end) { // 作業用変数3 end = rlend(tl, rl); if (a.bottom <= tmpYMIN) { continue; } ////TODO test //if (pa != Document.DEFAULT_ID) { // p.DrawFill(g, 0, a.top, v.XMAX + v.XBASE, H); //} // テキストデータ描画 for (x = 0, i = stt; x <= v.XMAX && i < end;) { xbk = x; nextlen = end - (tokenad + tokenlen); //nextlen = end - attrindex; if (nextlen >= 0) { var text = str.Substring(tokenad, tokenlen); //draw(str, tokenad, tokenlen); draw(text); stt = i; if (nextlen > 0) { index++; token = rules[index]; tokenad = token.ad; tokenlen = token.len; color = token.attr.color; } if (rln(tl) > 0 && nextlen == 0 && i == end && index < rules.Count - 1) { index++; token = rules[index]; tokenad = token.ad; tokenlen = token.len; color = token.attr.color; } } else { //over var text = str.Substring(tokenad, end - tokenad); draw(text); //draw(str, tokenad, end - tokenad); stt = i; tokenlen -= text.Length; //(end - attrindex); tokenad = end; } } // 選択範囲だったら反転 //if( v.SYB<=a.top && a.top<=v.SYE ) // Inv( a.top, a.top==v.SYB?v.SXB:(v.XBASE), // a.top==v.SYE?v.SXE:(v.XBASE+x), p ); if (v.SYB <= a.top && a.top <= v.SYE) { //TODO Rectangle if (cur_.Selection == SelectionType.Rectangle) { int cx = cur_.caret.GetPos().X; if (cur_.Cur.tl == tl && cur_.Cur.rl == rl) { for (int selY = v.SYB; selY <= v.SYE; selY += H) { //VPos vpb = new VPos(); //GetVPos(v.SXB, selY, ref vpb, false); VPos vpe = new VPos(); GetVPos(cx, selY, ref vpe, false); //int w = CalcLineWidth(doc_.tl(vpe.tl).ToString(), doc_.tl(vpe.tl).Length); if (CalcLineWidth(doc_.tl(vpe.tl).ToString(), doc_.tl(vpe.tl).Length) + v.XBASE < cx) { Inv(g, selY, Math.Min(v.XBASE + cur_.Sel.vx, cx), Math.Max(v.XBASE + cur_.Sel.vx, cx), p); } else { Inv(g, selY, Math.Min(v.XBASE + cur_.Sel.vx, v.XBASE + vpe.vx), Math.Max(v.XBASE + cur_.Sel.vx, v.XBASE + vpe.vx), p); } //Inv(g, selY, Math.Min(v.XBASE + cur_.Sel.vx, cx), // Math.Max(v.XBASE + cur_.Sel.vx, cx), p); } } } else { Inv(g, a.top, a.top == v.SYB ? v.SXB : (v.XBASE), a.top == v.SYE ? v.SXE : (v.XBASE + x), p); } } // 行末より後ろの余白を背景色塗 if (x < v.XMAX) { a.left = v.XBASE + Math.Max(v.XMIN, x); a.right = v.XBASE + v.XMAX; //p.Fill( a ); //g.FillRectangle(bb, a.left, a.top, a.right - a.left, a.bottom - a.top); } } //// 行末記号描画反転 //SpecialChars sc = (tl==TLM ? scEOF : scEOL); //if( i==doc_.len(tl) && -32768<x+v.XBASE ) //{ // if( p.sc(sc) ) // { // static const unicode* const sstr[] = { L"[EOF]", L"/" }; // static const int slen[] = { 5, 1 }; // p.SetColor( clr=CTL ); // p.StringOut( sstr[sc], slen[sc], x+v.XBASE, a.top-H ); // } // if( v.SYB<a.top && a.top<=v.SYE && sc==scEOL ) // Inv( a.top-H, x+v.XBASE, x+v.XBASE+p.Wc('/'), p ); //} if (i == doc_.len(tl) && -32768 < x + v.XBASE) { if (ShowReturn && tl != TLM) { p.DrawReturn(g, x + v.XBASE, a.top - H); } if (cur_.Selection == SelectionType.Normal && v.SYB < a.top && a.top <= v.SYE && ShowReturn) { Inv(g, a.top - H, x + v.XBASE, x + v.XBASE + p.W(), p); } } } // EOF後余白を背景色塗 if (a.top < v.rc.Bottom) { a.left = v.rc.Left; a.right = v.rc.Right; a.bottom = v.rc.Bottom; //p.Fill( a ); //g.FillRectangle(bb, a.left, a.top, a.right - a.left, a.bottom - a.top); } //v.YMIN = tmpYMIN; //v.TLMIN = tmpTLMIN; }
// public void GetVPos(int x, int y, ref VPos vp, bool linemode) { // x座標補正 x = x - lna() + hScrollBar.Value; // まず行番号計算 int tl = udScr_tl_; int vl = vScrollBar.Value - udScr_vrl_; int rl = y / fnt().H() + udScr_vrl_; if (rl >= 0) // View上端より下の場合、下方向を調べる { while (tl < doc_.tln() && rln(tl) <= rl) { vl += rln(tl); rl -= rln(tl); ++tl; } } else // View上端より上の場合、上方向を調べる { while (0 <= tl && rl < 0) { vl -= rln(tl); rl += rln(tl); --tl; } } if (tl == doc_.tln()) // EOFより下に行ってしまう場合の補正 { --tl; vl -= rln(tl); rl = rln(tl) - 1; } else if (tl == -1) // ファイル頭より上に行ってしまう場合の補正 { tl = vl = rl = 0; } else { if (linemode) { if (tl == (int)doc_.tln() - 1) { rl = rln(tl) - 1; x = 0x4fffffff; } else { vl += rln(tl); rl = 0; ++tl; x = 0; } } } vp.tl = tl; vp.vl = vl + rl; vp.rl = rl; // 次に、横位置を計算 if (rl < wrap_[tl].rln()) { IText buf = doc_.tl(tl); int adend = rlend(tl, rl); int ad = (rl == 0 ? 0 : rlend(tl, rl - 1)); int vx = (rl == 0 ? 0 : fnt().CalcStringWidth(buf.Substring(ad++, 1).ToString())); while (ad < adend) { //int nvx = (str[ad]==L'\t' //? fnt().nextTab(vx) //: vx + fnt().W(&str[ad]) //); //int nvx = vx + fnt().CalcStringWidth(buf.Substring(ad, 1).ToString()); int nvx = (buf[ad] == '\t' ? fnt().nextTab(vx) : vx + fnt().CalcStringWidth(buf.Substring(ad, 1).ToString())); if (x + 2 < nvx) { break; } vx = nvx; ++ad; } vp.ad = ad; vp.rx = vp.vx = vx; } else { vp.ad = vp.rx = vp.vx = 0; } }
private void CorrectPos(ref VPos pos) { // 正常範囲に収まるように修正 pos.tl = Math.Min(pos.tl, tln() - 1); pos.ad = Math.Min(pos.ad, len(pos.tl)); }
public VPosContext(VPos vpos) { this._vpos = vpos; }
// internal void ConvDPosToVPos(DPos dp, ref VPos vp, ref VPos basevp) { // 補正 dp.tl = Math.Min(dp.tl, doc_.tln() - 1); dp.ad = Math.Min(dp.ad, doc_.len(dp.tl)); VPos topPos = new VPos(); //if (basevp == null) { if (basevp.ad < 0) { basevp = topPos; } // とりあえずbase行頭の値を入れておく int vl = basevp.vl - basevp.rl; int rl = 0; int vx; // 違う行だった場合 // vlを合わせる int tl = basevp.tl; if (tl > dp.tl) // 目的地が基準より上にある場合 { do { vl -= rln(--tl); } while (tl > dp.tl); } else if (tl < dp.tl) // 目的地が基準より下にある場合 { do { vl += rln(tl++);// wrapList[tl++].wrap.Count; } while (tl < dp.tl); } // rlを合わせる int stt = 0; //while (wrapList[tl].wrap[rl] < dp.ad) // stt = wrapList[tl].wrap[rl++]; while (wrap_[tl][rl + 1] < dp.ad) { stt = wrap_[tl][++rl]; } vl += rl; // x座標計算 ///vx = CalcStringWidth(doc.LineList[tl].Text, stt, dp.ad - stt); //vx = fnt().CalcStringWidth(doc_.tl(tl), stt, (dp.ad - stt)); vx = stt == (dp.ad - stt)?0:fnt().CalcStringWidth(doc_.tl(tl).Substring(stt, (dp.ad - stt)).ToString()); //TODO //vx = CalcLineWidth(doc_.tl(tl), stt, dp.ad - stt); vp.tl = dp.tl; vp.ad = dp.ad; vp.vl = vl; vp.rl = rl; vp.rx = vp.vx = vx; }
internal void ConvDPosToVPos(DPos dp, ref VPos vp) { dummyVPos.ad = -1; ConvDPosToVPos(dp, ref vp, ref dummyVPos); }
public static VPos Min(VPos x, VPos y) { return(x < y ? x : y); }
public static VPos Max(VPos x, VPos y) { return(y < x ? x : y); }