private void UpdateLine(Line line) { var index = MyLines.IndexOf(line); MyLines.Remove(line); MyLines.Insert(index, line); }
//set default parameters for myline private void setDefaultParametersForMyLine(MyLines myLinesComp) { myLinesComp.maxLineZ = this.maxLineZ; myLinesComp.currentLineZ = this.currentLineZ; myLinesComp.cameraZPostition = middleCam.transform.localPosition.z; myLinesComp.farClipPlane = middleCam.farClipPlane; }
public void Handle(NodeUpdate message) { Draw(); //System.Threading.Thread.Sleep(10); if (message.From != null) { var actualNode = MyNodes.FirstOrDefault(x => x.Id == message.NodeId); actualNode.Height += 5; actualNode.Width += 5; var nodeFrom = MyNodes.FirstOrDefault(x => x.Name == Convert.ToString(message.From.Value)); var nodeTo = MyNodes.FirstOrDefault(x => x.Name == Convert.ToString(message.NodeId)); LineModel line = new LineModel { Stroke = Brushes.Gray, X1 = nodeFrom.X + (nodeFrom.Width / 2), Y1 = nodeFrom.Y + (nodeFrom.Height / 2), X2 = nodeTo.X + (nodeTo.Width / 2), Y2 = nodeTo.Y + (nodeTo.Height / 2), StrokeThickness = 3 }; path.Add(line); MyLines.Add(line); } }
//load the lines of the current shape IEnumerator LoadLinesCorouine() { GameObject linesGroups = GameObject.Find("LinesGroups"); int childCount = linesGroups.transform.childCount; for (int i = 0; i < childCount; i++) { GameObject childob = linesGroups.transform.GetChild(i).gameObject; MyLines myLinesComp = childob.GetComponent <MyLines> (); //get MyLines component if (childob.name == "Lines" + Shape.selectedShapeId) //if these are the lines of the current shape { this.maxLineZ = myLinesComp.maxLineZ; this.currentLineZ = myLinesComp.currentLineZ; Vector3 middleCampos = middleCam.transform.localPosition; middleCam.transform.localPosition = new Vector3(middleCampos.x, middleCampos.y, myLinesComp.cameraZPostition); middleCam.farClipPlane = myLinesComp.farClipPlane; childob.SetActive(true); } else { childob.SetActive(false); } } yield return(0); }
private BoardStateBase Clone() { var myLinesClone = new List <Line>(MyLines.Select(l => l.Clone())); var oppLinesClone = new List <Line>(OppLines.Select(l => l.Clone())); return(new BoardStateBase(myLinesClone, oppLinesClone, MyCellType, (BoardCell[, ])Board.Clone())); }
// Use this for initialization void Start() { MyRect = transform.GetComponent <RectTransform> (); MyLines.Add(CreateNewLine()); MyLines.Add(CreateNewLine()); MyLines.Add(CreateNewLine()); MyLines.Add(CreateNewLine()); }
private void SetupMine() { for (int i = 0; i < 100; i++) { mypencil[i] = new MyPencil(); } for (int i = 0; i < 100; i++) { mylines[i] = new MyLines(); } for (int i = 0; i < 100; i++) { myrect[i] = new MyRect(); } for (int i = 0; i < 100; i++) { mycircle[i] = new MyCircle(); } }
public static void AddCall(int hours, int minutes, int seconds, String line) { CounterCalls++; MyCalls.Add(new Call(hours, minutes, seconds, line)); MessageCalls += MyCalls[MyCalls.Count - 1].getCallString(CounterCalls); int index = MyLines.FindIndex(item => item.Telephone == line); if (index == -1) { MyLines.Add(new TelephoneEntry(line, MyCalls[MyCalls.Count - 1].Duration)); } else { MyLines[index].AddCall(MyCalls[MyCalls.Count - 1].Duration); } }
private void SetupMine() { for (int i = 0; i < 100; i++) { mypencil[i] = new MyPencil(); } for (int i = 0; i < 100; i++) { mylines[i] = new MyLines(); } for (int i = 0; i < 100; i++) { myrect[i] = new MyRect(); } for (int i = 0; i < 100; i++) { mycircle[i] = new MyCircle(); } parentForm.Init(); // Make Thread to process Panel Receive thread = new Thread(new ThreadStart(parentForm.ReceiveFromServer)); thread.Start(); }
public StoreShape() { mypencil = new MyPencil[100]; mylines = new MyLines[100]; myrect = new MyRect[100]; mycircle = new MyCircle[100]; for (int i = 0; i < 100; i++) { mypencil[i] = new MyPencil(); } for (int i = 0; i < 100; i++) { mylines[i] = new MyLines(); } for (int i = 0; i < 100; i++) { myrect[i] = new MyRect(); } for (int i = 0; i < 100; i++) { mycircle[i] = new MyCircle(); } }
//set default parameters for myline private void setDefaultParametersForMyLine (MyLines myLinesComp) { myLinesComp.maxLineZ = this.maxLineZ; myLinesComp.currentLineZ = this.currentLineZ; myLinesComp.cameraZPostition = middleCam.transform.localPosition.z; myLinesComp.farClipPlane = middleCam.farClipPlane; }
//draw lines private void MakeDrawing() { GameObject ob; Vector3 mousePos = Input.mousePosition; //get mouse position Vector3 wantedPos = middleCam.ScreenToWorldPoint(new Vector3(mousePos.x, mousePos.y, 0 - middleCam.transform.position.z)); RaycastHit2D hit2d = Physics2D.Raycast(wantedPos, Vector2.zero); if (hit2d.collider != null) { ob = hit2d.transform.gameObject; if (!(ob.tag == "DrawingArea" || ob.tag == "DrawingShape")) { return; } } else { return; } if (currentLineRender == null) //there current line rendere is null , then instanitae new one { GameObject currentLines = GameObject.Find("Lines" + Shape.selectedShapeId); currentLineRender = Instantiate(lineRenderPrefab) as GameObject; //instaiate object currentLineRender.transform.parent = currentLines.transform; LineRenderer lineRenderComp = currentLineRender.GetComponent <LineRenderer> (); lineRenderComp.SetWidth(lineRenderWidth, lineRenderWidth); lineRenderComp.material = drawingMaterial; MyLines myLinesComp = currentLines.GetComponent <MyLines> (); this.currentLineZ -= 0.0001f; myLinesComp.currentLineZ = this.currentLineZ; } Vector3 MousePos = Input.mousePosition; Vector3 worldpos = middleCam.ScreenToWorldPoint(MousePos); worldpos.z = currentLineZ; if (Mathf.Abs(currentLineZ) >= Mathf.Abs(maxLineZ)) //if current line z >= maxlinez ,then set the next attributes { this.maxLineZ -= 33; //decrease maxlineZ middleCam.transform.Translate(new Vector3(0, 0, -40)); //translate middleCamera in the z-position middleCam.farClipPlane += 40; //increase middleCamera far clip plane //Save status into current MyLines MyLines myLinesComp = GameObject.Find("Lines" + Shape.selectedShapeId).GetComponent <MyLines> (); myLinesComp.maxLineZ = this.maxLineZ; myLinesComp.currentLineZ = this.currentLineZ; Vector3 middleCampos = middleCam.transform.localPosition; myLinesComp.cameraZPostition = middleCampos.z; myLinesComp.farClipPlane = middleCam.farClipPlane; } float distance = Vector3.Distance(worldpos, prevPoint); prevPoint = worldpos; if (distance >= 0.03f) { LineRenderer ln = currentLineRender.GetComponent <LineRenderer> (); LineRenderAttribites line_attributes = currentLineRender.GetComponent <LineRenderAttribites> (); int numberOfPoints = line_attributes.NumberOfPoints; numberOfPoints++; line_attributes.NumberOfPoints = numberOfPoints; ln.SetVertexCount(numberOfPoints); ln.SetPosition(numberOfPoints - 1, worldpos); } }
private void drawingBoard_Paint(object sender, PaintEventArgs e) { e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; for (int i = 0; i <= md.nShape; i++) { try { switch (md.myshapes[i].type) { case ShapeType.PENCIL: { if (md.myshapes[i].GetPen() == null) { break; } List <Point> draw = new List <Point>(); Pen monami = md.myshapes[i].GetPen(); monami.Width = md.myshapes[i].GetThick(); monami.Color = md.myshapes[i].GetOutter(); try { foreach (Point paint in ((MyPencil)md.myshapes[i]).GetList()) { Point tmp = paint; tmp.X = zoomPoint.X - (int)Math.Round((zoomPoint.X - paint.X) * ratio); tmp.Y = zoomPoint.Y - (int)Math.Round((zoomPoint.Y - paint.Y) * ratio); draw.Add(tmp); } e.Graphics.DrawLines(monami, draw.ToArray()); } catch { } break; } case ShapeType.LINE: { if (md.myshapes[i].GetPen() == null) { break; } MyLines line = (MyLines)md.myshapes[i]; line.LPen.Width = line.GetThick(); line.LPen.Color = line.GetOutter(); Point p1 = line.getPoint1(); p1.X = zoomPoint.X - (int)Math.Round((zoomPoint.X - p1.X) * ratio); p1.Y = zoomPoint.Y - (int)Math.Round((zoomPoint.Y - p1.Y) * ratio); Point p2 = line.getPoint2(); p2.X = zoomPoint.X - (int)Math.Round((zoomPoint.X - p2.X) * ratio); p2.Y = zoomPoint.Y - (int)Math.Round((zoomPoint.Y - p2.Y) * ratio); e.Graphics.DrawLine(((MyLines)md.myshapes[i]).LPen, p1, p2); break; } case ShapeType.RECT: { if (md.myshapes[i].GetPen() == null) { break; } Rectangle myrect = ((MyRect)md.myshapes[i]).GetRect(); myrect.X = zoomPoint.X - (int)Math.Round((zoomPoint.X - myrect.X) * ratio); myrect.Y = zoomPoint.Y - (int)Math.Round((zoomPoint.Y - myrect.Y) * ratio); myrect.Width = (int)Math.Round(myrect.Width * ratio); myrect.Height = (int)Math.Round(myrect.Height * ratio); if (!md.myrect[i].IsColored()) { SolidBrush brush = new SolidBrush(md.myshapes[i].GetInner()); brush.Color = md.myshapes[i].GetInner(); e.Graphics.FillRectangle(brush, myrect); } Pen tmpPen = md.myshapes[i].GetPen(); tmpPen.Width = md.myshapes[i].GetThick(); tmpPen.Color = md.myshapes[i].GetOutter(); e.Graphics.DrawRectangle(tmpPen, myrect); break; } case ShapeType.CIRCLE: { if (md.myshapes[i].GetPen() == null) { break; } Rectangle mycircle = ((MyCircle)md.myshapes[i]).getRectC(); mycircle.X = zoomPoint.X - (int)Math.Round((zoomPoint.X - mycircle.X) * ratio); mycircle.Y = zoomPoint.Y - (int)Math.Round((zoomPoint.Y - mycircle.Y) * ratio); mycircle.Width = (int)Math.Round(mycircle.Width * ratio); mycircle.Height = (int)Math.Round(mycircle.Height * ratio); if (!md.myshapes[i].IsColored()) { SolidBrush brush = new SolidBrush(md.myshapes[i].GetInner()); brush.Color = md.myshapes[i].GetInner(); e.Graphics.FillEllipse(brush, mycircle); } Pen tmpPen2 = md.myshapes[i].GetPen(); tmpPen2.Width = md.myshapes[i].GetThick(); tmpPen2.Color = md.myshapes[i].GetOutter(); e.Graphics.DrawEllipse(tmpPen2, mycircle); break; } default: { break; } } } catch (Exception ex) { chatting.Text += ex.Message; } } }