/// <summary>
 /// Gets the updated line and the line that needs to update and merge with the properties.
 /// </summary>
 /// <param name="dbLine"> The database line </param>
 /// <param name="line"> The incoming line </param>
 private void UpdateTheLineProperties(DbLine dbLine, Line line)
 {
     dbLine.ClientId  = line.ClientId;
     dbLine.Id        = line.Id;
     dbLine.Number    = line.Number;
     dbLine.PackageId = line.PackageId;
     dbLine.Status    = line.Status;
 }
        public void DrawFace()
        {
            DbCircle body = new DbCircle();

            body.Center = new Point3d(200, 200, 0);
            body.Radius = 105;
            body.DbEntity.AddToCurrentDocument();
            DbCircle eye1 = new DbCircle();

            eye1.Center = new Point3d(150, 255, 0);
            eye1.Radius = 8;
            eye1.DbEntity.AddToCurrentDocument();

            DbCircle pupil1 = new DbCircle();

            pupil1.Center = new Point3d(148, 254, 0);
            pupil1.Radius = 2;
            pupil1.DbEntity.AddToCurrentDocument();

            DbCircle eye2 = new DbCircle();

            eye2.Center = new Point3d(250, 260, 0);
            eye2.Radius = 8;
            eye2.DbEntity.AddToCurrentDocument();
            DbCircle pupil2 = new DbCircle();

            pupil2.Center = new Point3d(252, 258, 0);
            pupil2.Radius = 2;
            pupil2.DbEntity.AddToCurrentDocument();

            DbLine hand1 = new DbLine();

            hand1.StartPoint = new Point3d(102, 239, 0);
            hand1.EndPoint   = new Point3d(72, 183, 0);
            hand1.DbEntity.AddToCurrentDocument();

            DbLine hand2 = new DbLine();

            hand2.StartPoint = new Point3d(298, 236, 0);
            hand2.EndPoint   = new Point3d(325, 192, 0);
            hand2.DbEntity.AddToCurrentDocument();

            DbPolyline     nose       = new DbPolyline();
            List <Point3d> nosePoints = new List <Point3d>()
            {
                new Point3d(171, 222, 0), new Point3d(198, 177, 0), new Point3d(231, 222, 0)
            };

            nose.Polyline = new Polyline3d(nosePoints);
            nose.Polyline.SetClosed(false);
            nose.DbEntity.Transform(McDocumentsManager.GetActiveDoc().UCS); //change coordinates from UCS to WCS for BD
            nose.DbEntity.AddToCurrentDocument();

            DbText spech = new DbText();

            spech.Text = new TextGeom("Hello Habr!", new Point3d(310, 55, 0), Vector3d.XAxis, "Standard", 25);
            spech.DbEntity.AddToCurrentDocument();
        }
示例#3
0
        internal static Line DbToCommon(this DbLine dbLine)
        {
            Line line = new Line()
            {
                Id        = dbLine.Id,
                Number    = dbLine.Number,
                PackageId = dbLine.PackageId,
                Status    = dbLine.Status,
                ClientId  = dbLine.ClientId
            };

            return(line);
        }
示例#4
0
        internal static DbLine CommonToDb(this Line line)
        {
            DbLine dbLine = new DbLine()
            {
                Id        = line.Id,
                Number    = line.Number,
                PackageId = line.PackageId,
                Status    = line.Status,
                ClientId  = line.ClientId
            };

            return(dbLine);
        }
示例#5
0
        public void DbToCommon_GetLine_Convert()
        {
            //Arrange
            var commonLine = new Line();
            var dbLine     = new DbLine();

            var fake = A.Fake <Line>(o => o.Wrapping(commonLine));
            //Act
            var results = dbLine.DbToCommon();

            A.CallTo(() => fake.Equals(A <object> ._)).ReturnsLazily(
                call =>
            {
                var other = call.GetArgument <Line>(0);
                return(results.Id == other.Id);
            });
            //Assert
            Assert.AreEqual(fake, results);
        }
 /// <summary>
 /// This method get an updated line and replace it with line that matchs with the lineId.
 /// </summary>
 /// <param name="line"> The updated line. </param>
 public void UpdateLine(Line line)
 {
     try
     {
         using (PhoneCompanyContext context = new PhoneCompanyContext())
         {
             DbLine dbLine = context.Lines.FirstOrDefault(x => x.Id == line.Id);
             UpdateTheLineProperties(dbLine, line);
             context.SaveChanges();
         }
     }
     catch (ArgumentNullException ex)
     {
         Services.WriteExceptionsToLogger(ex);
         throw new GetFromDatabaseException(ex.Message);
     }
     catch (Exception ex)
     {
         Services.WriteExceptionsToLogger(ex);
         throw new DataProcedureException(ex.Message);
     }
 }
示例#7
0
        public void DrawFace()
        {
            //We draw half of face

            // Draw eye
            DbCircle eye = new DbCircle();

            eye.Radius = 100;
            eye.Center = new Point3d(200, 500, 0);
            eye.DbEntity.AddToCurrentDocument();

            //Draw nose
            DbLine nose = new DbLine();

            nose.StartPoint = new Point3d(350, 400, 0);
            nose.EndPoint   = new Point3d(350, 200, 0);
            nose.DbEntity.AddToCurrentDocument();

            //Draw mouth
            DbPolyline     mouth       = new DbPolyline();
            List <Point3d> mouthPoints = new List <Point3d>()
            {
                new Point3d(100, 150, 0), new Point3d(200, 100, 0), new Point3d(350, 100, 0)
            };

            mouth.Polyline = new Polyline3d(mouthPoints);
            mouth.Polyline.SetClosed(false);
            mouth.DbEntity.Transform(McDocumentsManager.GetActiveDoc().UCS); //change coordinates from UCS to WCS for BD
            mouth.DbEntity.AddToCurrentDocument();

            //draw mirror half the face (2nd half)

            DbCircle eye2 = new DbCircle();

            eye2.Radius = 100;
            eye2.Center = new Point3d(500, 500, 0);
            eye2.DbEntity.AddToCurrentDocument();

            DbPolyline mouth2 = new DbPolyline();

            mouth2.Polyline = mouth.Polyline.Mirror(new Plane3d(new Point3d(350, 100, 0), new Vector3d(200, 0, 0))) as Polyline3d;
            mouth2.DbEntity.AddToCurrentDocument();

            //Get notification in command line
            McContext.ShowNotification("You need to enter data into the console");


            //Get uaser input
            InputJig editorInput = new InputJig();
            string   name        = editorInput.GetText("Input your name and press Enter");

            //Drawing face's text
            DbText spech = new DbText();

            spech.Text = new TextGeom("Oh Master! Why I'm so ugly? Please remove me!", new Point3d(510, 15, 0), Vector3d.XAxis, "Standard", 15);
            spech.DbEntity.AddToCurrentDocument();


            //Get windows message box
            MessageBox.Show("Congratulation " + name + " you did it! But look, it want, to say something to you...");

            //Get popup help
            McContext.PopupNotification("Delete command has activated");

            //Activate another command (Delete)
            McContext.ExecuteCommand("Delete");
        }