public void CopyMultiSelected(int dx, int dy) { ArrayList tmpList = new ArrayList(); foreach (Ele elem in List) { if (elem.selected) { Ele eL = elem.Copy(); elem.selected = false; eL.Move(dx, dy); tmpList.Add(eL); // sRec = new SelRect(eL); selEle = eL; selEle.EndMoveRedim(); } } foreach (Ele tmpElem in tmpList) { List.Add(tmpElem); // Uloz operaci do undo/redo bufferu StoreDo("I", tmpElem); } }
// Do Listu prida Elipsu public void AddElipse(int x, int y, int x1, int y1, Color penC, Color fillC, float penW, bool colorFilled, bool textureFilled, TextureBrush textura) { if (x1 - minDim <= x) { x1 = x + minDim; } if (y1 - minDim <= y) { y1 = y + minDim; } DeSelect(); Ellipse r = new Ellipse(x, y, x1, y1); r.Pero_barva = penC; r.Pero_šířka = penW; r.FillColor = fillC; r.ColorFilled = colorFilled; r.TextureFilled = textureFilled; r.FillTexture = textura; List.Add(r); StoreDo("I", r); sRec = new SelRect(r); selEle = r; selEle.Select(); }
/// <summary> /// Kopirovani standardnich vlastnosti, ktere jsou platne pro vsechny Elementy /// </summary> protected void CopyStdProp(Ele from, Ele to) { to.X = from.X; to.X1 = from.X1; to.Y = from.Y; to.Y1 = from.Y1; to.start = from.start; to.startX = from.startX; to.startX1 = from.startX1; to.startY = from.startY; to.startY1 = from.startY1; to.iAmAline = from.iAmAline; to.dashstyle = from.dashstyle; to._onGroupX1Res = from._onGroupX1Res; to._onGroupXRes = from._onGroupXRes; to._onGroupY1Res = from._onGroupY1Res; to._onGroupYRes = from._onGroupYRes; to.Alpha = from.Alpha; to.FillColor = from.FillColor; to.ColorFilled = from.ColorFilled; to.Pero_barva = from.Pero_barva; to.Pero_šířka = from.Pero_šířka; to.Ohraničení = from.Ohraničení; }
// Vybere posledni shape obsahujici souradnice x,y public void ClickOnShape(int x, int y, RichTextBox r) { sRec = null; selEle = null; foreach (Ele obj in this.List) { obj.selected = false; obj.DeSelect(); if (obj.Contains(x, y)) { selEle = obj; // ulozi referenci nalezeneho objektu // break; // nedelej break - pro prekryvajici se objekty beru posledni pridany objekt } } if (selEle != null) { selEle.selected = true; selEle.Select(); selEle.Select(r); // nyni vytvorim uchopovy objekt if (selEle is PointSet) { sRec = new SelPoly(selEle); //vytvori uchopovy obdelnik typu polygonovy vyber } else { sRec = new SelRect(selEle); //vytvori uchopovy obdelnik typu obdelnikovy vyber } } }
// Do Listu prida Jednoduchy text public void AddSimpleTextBox(int x, int y, int x1, int y1, RichTextBox t, Color penC, Color fillC, float penW, bool filled, bool textureFilled, TextureBrush textura) { if (x1 - minDim <= x) { x1 = x + minDim; } if (y1 - minDim <= y) { y1 = y + minDim; } DeSelect(); Stext r = new Stext(x, y, x1, y1); r.Text = t.Text; r.CharFont = t.SelectionFont; //t.Font; r.Pero_barva = penC; r.Pero_šířka = penW; r.FillColor = fillC; r.ColorFilled = filled; r.TextureFilled = textureFilled; r.FillTexture = textura; List.Add(r); StoreDo("I", r); sRec = new SelRect(r); selEle = r; selEle.Select(); }
// Do Listu prida Polygon - vseobecny public void AddPoly(int x, int y, int x1, int y1, Color penC, Color fillC, float penW, bool filled, ArrayList aa, bool curv, bool closed, bool textureFilled, TextureBrush textura) { /*if (x1 - minDim <= x) * x1 = x + minDim; * if (y1 - minDim <= y) * y1 = y + minDim;*/ DeSelect(); PointSet r = new PointSet(x, y, x1, y1, aa); r.Closed = closed; r.Pero_barva = penC; r.Pero_šířka = penW; r.FillColor = fillC; r.ColorFilled = filled; r.Zakřivení = curv; r.TextureFilled = textureFilled; r.FillTexture = textura; List.Add(r); StoreDo("I", r); // uloz do undo/redo bufferu sRec = new SelPoly(r); selEle = r; selEle.Select(); }
// Seskupi oznacene objekty public void GroupSelected() { ArrayList tmpList = new ArrayList(); foreach (Ele elem in List) { if (elem.selected) { tmpList.Add(elem); } } if (selEle != null) { selEle = null; sRec = null; } foreach (Ele tmpElem in tmpList) { List.Remove(tmpElem); } Group g = new Group(tmpList); List.Add(g); sRec = new SelRect(g); selEle = g; selEle.Select(); // kdyz seskupuji/rusim seskupeni musim resetovat UndoBuffer undoB = new UndoBuffer(20); }
// Zrus vyber vsech elementu public void DeSelect() { foreach (Ele obj in List) { obj.selected = false; } selEle = null; sRec = null; }
//Vraci kopii vybraneho elementu public Ele CpSelected() { if (selEle != null) { Ele l = selEle.Copy(); return(l); } return(null); }
public void StoreDo(string option, Ele e) { Ele olde = null; if (e.undoEle != null) { olde = e.undoEle.Copy(); } Ele newe = e.Copy(); BufferedElement buff = new BufferedElement(e, newe, olde, option); undoB.Add2Buff(buff); e.undoEle = e.Copy(); }
// Do Listu prida Caru public void AddLine(int x, int y, int x1, int y1, Color penC, float penW) { DeSelect(); Line r = new Line(x, y, x1, y1); r.Pero_barva = penC; r.Pero_šířka = penW; List.Add(r); StoreDo("I", r); sRec = new SelRect(r); selEle = r; selEle.Select(); }
// Vraci pole s vybranymi elementy. Pouziti je pro Property Grid public Ele[] GetSelectedArray() { Ele[] myArray = new Ele[CountSelected()]; int i = 0; foreach (Ele e in List) { if (e.selected) { myArray[i] = e; i++; } } return(myArray); }
// Vybere vsechny elementy (objekty) ve Vyberovem obdelniku public void MultiSelect(int startX, int startY, int endX, int endY, RichTextBox r) { sRec = null; selEle = null; foreach (Ele obj in List) { obj.selected = false; obj.DeSelect(); // pouziti pro deselekci bodu v polygonech int x = obj.GetX; int x1 = obj.GetX1; int y = obj.GetY; int y1 = obj.GetY1; int c = 0; if (x > x1) { c = x; x = x1; x1 = c; } if (y > y1) { c = y; y = y1; y1 = c; } if (x <= endX & x1 >= startX & y <= endY & y1 >= startY) { selEle = obj; //ulozi referenci nalezeneho objektu obj.selected = true; //oznaci objekt jako vybrany obj.Select(); obj.Select(r); obj.Select(startX, startY, endX, endY); } } if (selEle != null) { if (selEle is PointSet) { sRec = new SelPoly(selEle); //vytvori uchopovy obdelnik typu polygonovy vyber } else { sRec = new SelRect(selEle); //vytvori uchopovy obdelnik typu obdlenikovy vyber } } }
// Kopiruje oznaceny objekt, oznaci ho jako vybrany public void CopySelected(int dx, int dy) { if (selEle != null) { Ele L = CpSelected(); L.Move(dx, dy); DeSelect(); List.Add(L); // uklada operaci do undo/redo bufferu StoreDo("I", L); sRec = new SelRect(L); //sRec.sonoUnaLinea = L.sonoUnaLinea; selEle = L; selEle.EndMoveRedim(); } }
// Rozlozi skupinu elementu public void DeGroupSelected() { ArrayList tmpList = new ArrayList(); foreach (Ele elem in List) { if (elem.selected) { tmpList.Add(elem); } } if (selEle != null) { selEle = null; sRec = null; } bool found = false; foreach (Ele tmpElem in tmpList) { ArrayList tmpL = tmpElem.DeGroup(); if (tmpL != null) { foreach (Ele e1 in tmpL) { List.Add(e1); } List.Remove(tmpElem); found = true; } } if (found) { // kdyyz seskupuji / rozkladam Group musim resetovat UndoBuffer undoB = new UndoBuffer(20); } }
// Do Listu prida ImageBox - obrazek = zahradni prvek public void AddImageBox(int x, int y, int x1, int y1, string st, Color penC, float penW) { if (x1 - (minDim * 10) <= x) { x1 = x + (minDim * 10); } if (y1 - (minDim + 10) <= y) { y1 = y + (minDim * 10); } DeSelect(); ImageBox r = new ImageBox(x, y, x1, y1); r.Pero_barva = penC; r.Pero_šířka = penW; List.Add(r); StoreDo("I", r); if (!(st == null)) { try { Bitmap loadTexture = new Bitmap(st); r.Prvek = loadTexture; } catch { } } sRec = new SelRect(r); selEle = r; selEle.Select(); }
// Smaze vybrany objekt public void RmSelected() { ArrayList tmpList = new ArrayList(); foreach (Ele elem in List) { if (elem.selected) { tmpList.Add(elem); } } if (selEle != null) { selEle = null; sRec = null; } foreach (Ele tmpElem in tmpList) { List.Remove(tmpElem); StoreDo("D", tmpElem); } }
/// <summary> /// Zkopiruj vlastnosti z jineho Elementu /// </summary> public virtual void CopyFrom(Ele ele) { }