/// <summary> Takes the position and size from the model and applies them in the UI </summary> private static void SetCircleUiPosAndSizeFromCircleModel(MyCircle circleModel, RectTransform circleUi) { SetSizeOfCircleUi(circleUi, circleModel.diameter); // The canvas should have 0,0 at bottom left so that its is aligned with the input system coordinates: circleUi.SetAnchorsBottomLeft(); circleUi.localPosition = new Vector2(circleModel.x, circleModel.y); }
private void DrawABall(Tuple <int, int> tup) { var circleSize = 30; var circleNumber = tup.Item1; var circleColumn = tup.Item2; var circleRow = 2; Position circlePos = new Position(circleColumn, circleRow); MyCircle myCircle = new MyCircle(circleSize, circleNumber, circlePos); if (MyDict.ContainsKey(circleNumber) && MyDict[circleNumber] != myCircle) { if (circleColumn > 19) { EraseABall(circleNumber); return; } EraseABall(circleNumber); MyDict[circleNumber] = myCircle; } else { MyDict.Add(circleNumber, myCircle); } // Add Ellipse to the Grid. var index1 = CircleGrid.Children.Add(myCircle.Circle); Grid.SetColumn(myCircle.Circle, myCircle.Position.X); Grid.SetRow(myCircle.Circle, myCircle.Position.Y); var index2 = CircleGrid.Children.Add(myCircle.TextInside); Grid.SetColumn(myCircle.TextInside, myCircle.Position.X); Grid.SetRow(myCircle.TextInside, myCircle.Position.Y); }
private List <MyShape> parseStringDataToListShapeObject(string data) { List <MyShape> myShapes = new List <MyShape>(); string firstWord = null; string[] listShape = data.Split('\n'); for (int i = 0; i < listShape.Length; i++) { if (listShape[i] != "") { firstWord = listShape[i].Substring(0, listShape[i].IndexOf(" ")); } switch (firstWord) { case "Line": MyShape myLine = new MyLine(); myLine.Open(listShape[i]); myShapes.Add(myLine); break; case "Rectangle": MyShape myRectangle = new MyRectangle(); myRectangle.Open(listShape[i]); myShapes.Add(myRectangle); break; case "Circle": MyShape myCircle = new MyCircle(); myCircle.Open(listShape[i]); myShapes.Add(myCircle); break; case "Ellipse": MyShape myEllipse = new MyEllipse(); myEllipse.Open(listShape[i]); myShapes.Add(myEllipse); break; case "Polygon": MyShape myPolygon = new MyPolygon(); myPolygon.Open(listShape[i]); myShapes.Add(myPolygon); break; case "Bezier": MyShape myBezier = new MyBezier(); myBezier.Open(listShape[i]); myShapes.Add(myBezier); break; case "Polyline": MyShape myPolyline = new MyPolyline(); myPolyline.Open(listShape[i]); myShapes.Add(myPolyline); break; } firstWord = ""; } return(myShapes); }
public static MyCylinder CreateMyCylinderFromFace(Surface faceSurface, Face2 face) { //OSSERVAZIONE: CI POTREBBERO ESSERE EDGE CHIUSI CHE NON AVERE CENTRO SULL'ASSE //AD ESEMPIO EDGE CHIUSI CHE SI CREANO INTERSECANDO UN CILINDRO CON UNA SFERA //"INFILATA" SULLA SUA SUPERFICIE LATERALE. //DI QUESTI EDGE CHIUSI NON ME NE PREOCCUPO PERCHE' SONO A CONTATTO CON ALTRE FORME //DI CUI SPERO DI AVER CONTROLLATO (NEL CONTROLLO DELLA GEOMETRIA) IL GIUSTO //POSIZIONAMENTO. double[] myCylinderParameters = faceSurface.CylinderParams; double[] myCylinderOrigin = { (double)myCylinderParameters.GetValue(0), (double)myCylinderParameters.GetValue(1), (double)myCylinderParameters.GetValue(2) }; double[] myCylinderAxis = { (double)myCylinderParameters.GetValue(3), (double)myCylinderParameters.GetValue(4), (double)myCylinderParameters.GetValue(5) }; double myCylinderRadius = (double)myCylinderParameters.GetValue(6); var newMyCylinder = new MyCylinder(myCylinderOrigin, myCylinderAxis, myCylinderRadius); var faceEdges = (Array)face.GetEdges(); var numOfEdges = faceEdges.Length; int i = 0; var currentListOfBaseCircle = new List <MyCircle>(); var currentListOfBaseEllipse = new List <MyEllipse>(); while (i < numOfEdges) { Edge edge = (Edge)faceEdges.GetValue(i); Curve curveEdge = edge.GetCurve(); if (IsClosedEdge(edge)) { //is the closed edge a circle? if (curveEdge.IsCircle()) { double[] circleParam = curveEdge.CircleParams; var newBaseCircle = new MyCircle(circleParam); currentListOfBaseCircle.Add(newBaseCircle); } //is the closed edge an ellipse? if (curveEdge.IsEllipse()) { double[] ellipseParam = curveEdge.GetEllipseParams(); var newBaseEllipse = new MyEllipse(ellipseParam); currentListOfBaseEllipse.Add(newBaseEllipse); } } i++; } newMyCylinder.listOfBaseCircle = currentListOfBaseCircle; newMyCylinder.listOfBaseEllipse = currentListOfBaseEllipse; return(newMyCylinder); }
public void RemoveEverySecondResult1() { MyCircle circle = new MyCircle(1223); circle.RemoveEverySecond(); Assert.AreEqual(circle.Count, 1); }
public My1CustomShape() : base() { MyCircle circle = new MyCircle(new Point(50, 50), new Point(100, 100)); MyLine line = new MyLine(100, 0, 50, 100); listShape.Add(circle); listShape.Add(line); }
public override string ToString() { var builder = new StringBuilder(); builder.Append($"MyPicture with {MyCircle.ToString()} and {MySquare.ToString()}"); return($"MyPicture has {MyCircle.ToString()} and { MySquare.ToString()}."); }
private static MyCircle CircleReducer(MyCircle c, object action) { if (action is ChangeDiameterAction a && a.targetCircleId == c.id) { return(new MyCircle(c.id, c.x, c.y, a.newDiameter)); } return(c); }
public SweepMesh(MyCircle profile_, List <MyVector3> trajectory1_, List <MyVector3> trajectory2_) { this.profile = profile_.CirclePoints; this.trajectory1 = trajectory1_; this.trajectory2 = trajectory2_; //this.CreateMesh(); this.CreateSymmetryMesh(profile_.Normal, profile_.Radius); }
public void IsNearClick_VariousCoords_ChecksThem(int x, int y, bool excepted) { int[] circleCoords = new int[] { 100, 100 }; //arrange var myCircle = new MyCircle(circleCoords); bool result = myCircle.IsNearClick(new int[] { x, y }); //act Assert.AreEqual(excepted, result); //assert }
public MembershipInCategory(Canvas canvas) { MyCircle elementCategory = new MyCircle(canvas, 70, 0, Color.FromArgb(255, 30, 144, 255), 30, 80, setFill: true); MyCircle category = new MyCircle(canvas, 100, 0, Color.FromArgb(255, 50, 205, 50), 70, 30, setFill: true); MyLabel title = new MyLabel(canvas, "Przynależność", 120, 30, 14, 0, 0, Color.FromArgb(255, 47, 79, 79), Color.FromArgb(0, 0, 0, 0)); nameGroup = new MyLabel(canvas, "-", 90, 25, 10, 20, 102, Color.FromArgb(255, 47, 79, 79), Color.FromArgb(0, 0, 0, 0)); nameActivity = new MyLabel(canvas, "-", 120, 30, 12, 60, 65, Color.FromArgb(255, 47, 79, 79), Color.FromArgb(0, 0, 0, 0)); }
static void Main(string[] args) { Console.WriteLine("Введите радиус"); double r = Double.Parse(Console.ReadLine()); Console.WriteLine("Площадь круга = {0}", MyCircle.SqrCircle(r)); Console.WriteLine("Длинна окружности = {0}", MyCircle.LongCircle(r)); Console.ReadLine(); }
// Паттерн Прототип(Prototype) позволяет создавать объекты на основе уже ранее созданных объектов-прототипов. // То есть по сути данный паттерн предлагает технику клонирования объектов. //Когда использовать Прототип? //Когда конкретный тип создаваемого объекта должен определяться динамически во время выполнения //Когда нежелательно создание отдельной иерархии классов фабрик для создания объектов-продуктов //из параллельной иерархии классов (как это делается, например, при использовании паттерна Абстрактная фабрика) //Когда клонирование объекта является более предпочтительным вариантом нежели его создание и инициализация с помощью конструктора. // Особенно когда известно, что объект может принимать небольшое ограниченное число возможных состояний. private void Button_Click_1(object sender, RoutedEventArgs e) { MyCircle figure = new MyCircle(30, 50, 60); // применяем глубокое копирование MyCircle clonedFigure = figure.DeepCopy() as MyCircle; figure.Point.X = 100; figure.GetInfo(); clonedFigure.GetInfo(); }
public ServerForm() { InitializeComponent(); shapeRows.ReadXml("panel_data.xml"); foreach (var item in shapeRows) { Shape shape; if (item.Shape.Equals("Line")) { MyLine myLine = new MyLine(); myLine.setPoint(new Point(item.x1, item.y1), new Point(item.x2, item.y2), new Pen(Color.FromArgb(item.Color), item.thick)); shape = myLine; } else if (item.Shape.Equals("Circle")) { MyCircle myCircle = new MyCircle(); myCircle.setRectC(new Point(item.x1, item.y1), new Point(item.x1 + item.x2, item.y1 + item.y2), new Pen(Color.FromArgb(item.Color), item.thick), new SolidBrush(Color.FromArgb(item.Brush))); shape = myCircle; } else// if (item.Shape.Equals("Rectangle")) { MyRect myRect = new MyRect(); myRect.setRect(new Point(item.x1, item.y1), new Point(item.x1 + item.x2, item.y1 + item.y2), new Pen(Color.FromArgb(item.Color), item.thick), new SolidBrush(Color.FromArgb(item.Brush))); shape = myRect; } shapes.Add(shape); } //shapeRows.Rows.Add(dr); //txt_Chat.AppendText(shapeRows.Last().Shape); //shapeRows.Rows.Add(dr); //txt_Chat.AppendText(shapeRows[0].Shape); //txt_Chat.AppendText(shapeRows[0].x1.ToString()); ConnectModal connectModal = new ConnectModal(); connectModal.ShowDialog(); for (int i = 0; i < 10; i++) { serverThreads[i] = new ServerThread(this); } this.m_thServer = new Thread(new ThreadStart(ServerStart)); this.m_thServer.Start(); }
public void CreateAnimatedClock(Canvas canvas) { this.canvas = canvas; CreateClockFace(); MyCircle myCircle = new MyCircle(canvas, 110, 2, Color.FromArgb(255, 128, 128, 128), (this.canvas.Width / 2) - 53, (this.canvas.Height / 2) - 43, 0.5); circleBar = new CircleBar(this.canvas, 0.08, Color.FromArgb(255, 255, 99, 71), 4, 0, 10, 55, false); CreateHandOfClock(); timerAnimation.Start(); UpdateLookAnimatedClock(); }
public void Run() { MyCircle mycircle = new MyCircle(); mycircle.SizeChanged += new EventHandler(Circle_SizeChanged); var newSize = new Size(11, 11); mycircle.Size = newSize; var new2Size = new Size(12, 12); mycircle.Size = new2Size; }
// Increase the size of the ball if the cursor position is inside the circle position public void Grow(Point cursorLocation) { CursorInsideCircle = false; if (Container.Contains(MyCircle)) { if (MyCircle.Contains(cursorLocation)) { CursorInsideCircle = true; Size newSize = new Size(MyCircle.Size.Width + 1, MyCircle.Size.Height + 1); MyCircle = new Rectangle(MyCircle.Location, newSize); tempscore += 0.20; Score = (int)Math.Floor(tempscore); } } }
public MyCircle CreateCircle(int number, MyPoint point, double radius) { MyCircle newCircle = new MyCircle(number, point, radius); this.parent.currentFullModel.geometryModel.Circles.Add(newCircle); parent.visualizer.DrawCircle(newCircle, Color.Blue); this.parent.currentFullModel.geometryModel.NumOfCircles++; this.number.Text = (parent.currentFullModel.geometryModel.NumOfLines + 1).ToString(); this.centerPoint.Text = ""; this.radius.Text = ""; this.centerPoint.Select(); return(newCircle); }
private void DrawABall(MyCircle myCircle) { var index1 = CircleGrid.Children.Add(myCircle.Circle); Grid.SetColumn(myCircle.Circle, myCircle.Position.X); Grid.SetRow(myCircle.Circle, myCircle.Position.Y); var index2 = CircleGrid.Children.Add(myCircle.TextInside); Grid.SetColumn(myCircle.TextInside, myCircle.Position.X); Grid.SetRow(myCircle.TextInside, myCircle.Position.Y); // for observing var tup = new Tuple <int, int>(myCircle.Number, myCircle.Position.X); drawBallEventSpotted.OnNext(tup); }
public static Entity ConverToCustomEntity(ObjectId CurrentEntityOI, int ProductCode, int ProductType) { Entity ent = Atend.Global.Acad.UAcad.GetEntityByObjectID(CurrentEntityOI); MyCircle c = ent as MyCircle; if (c != null) { #region Convert to mycircle c.AdditionalDictionary.Add("ProductType", ProductType); c.AdditionalDictionary.Add("ProductCode", ProductCode); ent = c; #endregion } else { MyPolyline p = ent as MyPolyline; if (p != null) { #region convert to polyline p.AdditionalDictionary.Add("ProductType", ProductType); p.AdditionalDictionary.Add("ProductCode", ProductCode); ent = p; #endregion } else { MyLine l = ent as MyLine; if (l != null) { #region convert to line l.AdditionalDictionary.Add("ProductType", ProductType); l.AdditionalDictionary.Add("ProductCode", ProductCode); ent = l; #endregion } else { // it was nothing } } } return(ent); }
private MyCircle CiriFixTopCircle(MyCircle topCircle, List <MyVector3> boundary3) { MyVector3 boundary_mean = new MyVector3(0, 0, 0); foreach (var p in boundary3) { boundary_mean += p; } boundary_mean /= boundary3.Count; if (topCircle.Normal.Dot(boundary_mean - topCircle.Center) > 0) { return(topCircle); } else { return(new MyCircle(topCircle.Center, topCircle.Radius, -1.0 * topCircle.Normal)); } }
private void pictureBox1_MouseDown(object sender, MouseEventArgs e) { if (isNode.Checked) { if (e.Button != MouseButtons.Left) return; drawingCircle = false; draggingCircle = false; activeCircle = CheckIfCircleClicked(e.Location); if (activeCircle == null) { activeCircle = new MyCircle(e.Location, 0, numberOfCircles, Color.Blue); numberOfCircles++; drawingCircle = true; } else { draggingCircle = true; dragOffset = new Point(activeCircle.Point.X - e.Location.X, activeCircle.Point.Y - e.Location.Y); } } else if(isVertecie.Checked) { if (e.Button != MouseButtons.Left) return; drawingLine = false; activeCircle = CheckIfCircleClicked(e.Location); if (activeCircle == null) { MessageBox.Show("gfy"); } else { MessageBox.Show((activeCircle.Number).ToString()); activeCircle.Color = Color.Red; } } }
private async Task AddAnEllipse(int number) { var circleSize = 30; var circleNumber = number; for (int i = 0; i < MaxCol; i++) { Position circlePos = new Position(i, 1); MyCircle myCircle = new MyCircle(circleSize, circleNumber, circlePos); // Add Ellipse to the Grid. NewBall = myCircle; CurrentBalls.Add(NewBall); var td = number * 100; await Task.Delay(td); OldBall = myCircle; CurrentBalls.Remove(OldBall); } }
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 CircleBar(Canvas canvas, double increaseAngle, Color color, int widthBar, int xCenter, int yCenter, int radiusBar, bool drawCloseCircle = true) { progressBar = new MyCircle[Convert.ToInt32((6.28 / increaseAngle) + 1)]; double angle = 0; value = 1; if (drawCloseCircle == true) { MyCircle circle = new MyCircle(canvas, radiusBar * 2, 2, Color.FromArgb(255, 128, 128, 128), (canvas.Width / 2) - 48, (canvas.Height / 2) - 33, 0.5); } for (int i = 0; i < progressBar.Length; i++) { double x = Math.Cos(angle - 1.55) * radiusBar + canvas.Width / 2 + xCenter; double y = Math.Sin(angle - 1.55) * radiusBar + canvas.Height / 2 + yCenter; progressBar[i] = new MyCircle(canvas, widthBar, 2, color, x, y, 1); angle = angle + increaseAngle; } }
public void ReOptimize() { double[] bndl = new double[] { -5, -5, 0 }; double[] x = new double[] { topCircle.Center.x, topCircle.Center.y, topCircle.Center.z }; //add center double[] bndu = new double[] { 5, 5, 20 }; int paramsNum = 3; int funNum = 1; double diffstep = 0.00001; double epsg = 0.000000000001; double epsf = 0; double epsx = 0; int maxits = 0; alglib.minlmstate state; alglib.minlmreport rep; //set timer System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch(); stopwatch.Start(); // Do the optima alglib.minlmcreatev(funNum, x, diffstep, out state); alglib.minlmsetbc(state, bndl, bndu); alglib.minlmsetcond(state, epsg, epsf, epsx, maxits); alglib.minlmoptimize(state, function_withcenter, null, null); alglib.minlmresults(state, out x, out rep); stopwatch.Stop(); Console.WriteLine("Stop Type: {0}, Total time: {1}s", rep.terminationtype, stopwatch.ElapsedMilliseconds / 1000.0); // Update Circle MyVector3 center = new MyVector3(x[0], x[1], x[2]); MyVector3 normal = topCircle.Normal; double radius = topCircle.Radius; topCircle = new MyCircle(center, radius, new MyPlane(center, normal)); CirclePoints_2d = GetProjectionPoints_2D(topCircle.CirclePoints); this.view.Refresh(); }
/// <summary> Creates a new UI circle based on the circle values in the model </summary> private GameObject CreateNewCircleUi(MyCircle circle) { Log.MethodEnteredWith(circle); var newCircleUi = ResourcesV2.LoadPrefab("CircleUi"); var map = newCircleUi.GetLinkMap(); CircleUi circleUi = map.Get <CircleUi>("CircleUi"); circleUi.circleId = circle.id; circleUi.OnCircleClicked = (string clickedCircleId, bool wasRightClick) => { store.Dispatch(new SelectCicleAction() { selectedCircleId = clickedCircleId }); if (wasRightClick) { ShowDiameterEditUi(); } }; circleUi.VisualizeCircleAsSelected(circle.id.Equals(store.GetState().selectedCircle)); SetCircleUiPosAndSizeFromCircleModel(circle, circleUi.GetComponent <RectTransform>()); return(newCircleUi); }
private void pictureBox1_MouseDown(object sender, MouseEventArgs e) { if (e.Button != MouseButtons.Left) { return; } drawing = false; dragging = false; activeCircle = CheckIfCircleClicked(e.Location); if (activeCircle == null) { activeCircle = new MyCircle(e.Location, 0); drawing = true; } else { dragging = true; dragOffset = new Point(activeCircle.Point.X - e.Location.X, activeCircle.Point.Y - e.Location.Y); } }
private void UpdateListOfAddedApps() { CommandParameters parameters = new CommandParameters(); parameters.Name.Add(namesActivity[index]); List <ActiveApplication> activeApplication = ActiveApplication_db.GetActiveApplication(parameters); if (activeApplication.Count > 100) { activeApplication.RemoveRange(0, activeApplication.Count - 100); } applicationInActivity.Children.Clear(); string titleApplication = string.Empty; applicationInActivity.Height = 0; for (int i = 0; i < activeApplication.Count; i++) { titleApplication = (activeApplication[i].Title.Length > 16) ? activeApplication[i].Title.Remove(16, activeApplication[i].Title.Length - 16) : activeApplication[i].Title; MyLabel l = new MyLabel(applicationInActivity, titleApplication, 140, 30, 12, 0, 29 * i, Color.FromArgb(255, 155, 155, 155), Color.FromArgb(200, 255, 255, 255), 0, HorizontalAlignment.Left); l.ToolTip(activeApplication[i].Title); new MyRectangle(applicationInActivity, 140, 1, Color.FromArgb(30, 150, 150, 150), 0, 30 + (29 * i)); MyCircle circle = new MyCircle(applicationInActivity, 15, 1, (Color.FromArgb(155, 255, 93, 93)), 115, 8 + (29 * i), 1, true); Label buttonDeleteApplication = ButtonCreator.CreateButton(applicationInActivity, "x", 25, 25, 8, 110, 3 + (29 * i), Color.FromArgb(255, 255, 255, 255), Color.FromArgb(200, 255, 0, 0), 0, fontWeight: FontWeights.ExtraBold); buttonDeleteApplication.Background = new SolidColorBrush(Color.FromArgb(155, 236, 236, 236)); buttonDeleteApplication.MouseEnter += buttonDeleteApplication_MouseEnter; buttonDeleteApplication.MouseLeave += buttonDeleteApplication_MouseLeave; buttonDeleteApplication.MouseLeftButtonDown += buttonDeleteApplication_MouseLeftButtonDown; buttonDeleteApplication.Name = "ID_" + activeApplication[i].ID; ButtonCreator.SetToolTip(buttonDeleteApplication, "Usuń aplikacje z aktywności"); applicationInActivity.Height += 29; } applicationInActivity.Height = ((applicationInActivity.Height - 146) < 146) ? 146 : applicationInActivity.Height - 145; }
public void DrawCircle(MyCircle circle, Color color, bool drawId = false, double width = 2.0) { int count = 100; float[] pts = new float[count * 2]; double[] colorCash = colorArray(color); double h = 2 * Math.PI / (count - 1); double alpha; for (int i = 0; i < count; i++) { alpha = h * i; pts[i * 2] = (float)(circle.CenterPoint.X + circle.Radius * Math.Cos(alpha)); pts[i * 2 + 1] = (float)(circle.CenterPoint.Y + circle.Radius * Math.Sin(alpha)); } int list = Gl.glGenLists(1); Gl.glNewList(list, Gl.GL_COMPILE); Gl.glColor3dv(colorCash); Gl.glLineWidth((float)width); Gl.glEndList(); drawBuffer.Add(new DrawingOperation(Gl.GL_LINE_STRIP, pts, list)); }
private void Panel_board_MouseDown(object sender, MouseEventArgs e) { pen = new Pen(btn_lineColor.BackColor, lineSize); if (btn_Fill.BackColor == Color.Gray) { brush = new SolidBrush(btn_faceColor.BackColor); } else { brush = new SolidBrush(Color.Transparent); } isholding = true; switch (drawTool) { case 0: //Hand break; case 1: //Pencil break; case 2: //Line myLine = new MyLine(); shape = myLine; break; case 3: //Circle myCircle = new MyCircle(); shape = myCircle; break; case 4: //Rectangle myRect = new MyRect(); shape = myRect; break; } point = e.Location; }