Matrix <double> FindFundamentalMatrix(CameraModel cam1, CameraModel cam2)
        {
            IntPtr points1Ptr = CvHelper.CreatePointListPointer(CvHelper.NormalizePoints(cam1.Calibration.ObjectPointsProjected, cam1.Calibration.IntrinsicParameters));
            IntPtr points2Ptr = CvHelper.CreatePointListPointer(CvHelper.NormalizePoints(cam2.Calibration.ObjectPointsProjected, cam1.Calibration.IntrinsicParameters));

            Matrix <double> fundamentalMatrix = new Matrix <double>(3, 3);

            IntPtr fundamentalMatrixPtr = CvInvoke.cvCreateMat(3, 3, MAT_DEPTH.CV_32F);

            CvInvoke.cvFindFundamentalMat(points1Ptr, points2Ptr, fundamentalMatrix.Ptr, CV_FM.CV_FM_RANSAC, 3, 0.99, IntPtr.Zero);

            return(fundamentalMatrix);
        }
Beispiel #2
0
        public static void Start(Worker worker, Database.Database db)
        {
            var logger = new Logger.ConsoleLogger();

            var seeAdsLoop = true;

            var             mainVacancies = db.GetVacancies();
            IList <Vacancy> vacancies     = mainVacancies;

            while (seeAdsLoop)
            {
                Console.Clear();

                ExceptionHandle.Handle(VacancyHelper.SeeAds, vacancies);

                ConsoleScreen.PrintMenu(ConsoleScreen.FilterMenu, ConsoleColor.Blue);

                var filterMenuChoice = (FilterMenuEnum)ConsoleScreen.Input(ConsoleScreen.FilterMenu.Count);

                switch (filterMenuChoice)
                {
                case FilterMenuEnum.Select:
                {
                    var loop2 = true;
                    while (loop2)
                    {
                        Console.Clear();
                        if (!ExceptionHandle.Handle(VacancyHelper.SeeAds, vacancies))
                        {
                            break;
                        }
                        Console.WriteLine("Vacancy id: ");
                        var vacId = UserHelper.InputGuid();

                        try
                        {
                            var vacancy = VacancyHelper.GetVacancy(vacId, vacancies);

                            while (true)
                            {
                                var requestFromWorker = vacancy.CheckWorkerRequest(worker.Guid);
                                Console.Clear();
                                Console.WriteLine(vacancy++);     // increase vacancy view count and print
                                Database.Database.Changes = true;

                                Console.WriteLine();
                                Console.WriteLine($"1. {(requestFromWorker ? "Cancel" : "Request")}");;
                                Console.WriteLine("2. Back");
                                var choice = ConsoleScreen.Input(2);

                                if (choice == 1)
                                {
                                    if (requestFromWorker)
                                    {
                                        vacancy.RemoveRequest(worker.Guid);
                                    }
                                    else
                                    {
                                        Cv cv = null;
                                        while (true)
                                        {
                                            Console.Clear();
                                            if (!ExceptionHandle.Handle(worker.ShowAllCv, true))
                                            {
                                                LoggerPublisher.OnLogInfo("Please add public Cv!");
                                                ConsoleScreen.Clear();
                                                break;
                                            }

                                            var cvId = UserHelper.InputGuid();

                                            try
                                            {
                                                cv = CvHelper.GetCv(cvId, worker.Cvs);
                                                break;
                                            }
                                            catch (Exception e)
                                            {
                                                LoggerPublisher.OnLogError(e.Message);
                                                ConsoleScreen.Clear();
                                            }
                                        }

                                        if (cv != null)
                                        {
                                            vacancy.SendRequest(worker.Guid, cv.Guid);
                                        }
                                    }
                                }
                                else if (choice == 2)
                                {
                                    if (ConsoleScreen.DisplayMessageBox("Info", "Do you want to see other Ads?",
                                                                        MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.No)
                                    {
                                        loop2 = false;
                                    }
                                    break;
                                }
                            }

                            if (loop2)
                            {
                                continue;
                            }
                        }
                        catch (Exception e)
                        {
                            LoggerPublisher.OnLogError(e.Message);
                            ConsoleScreen.Clear();
                        }

                        if (!loop2 || ConsoleScreen.DisplayMessageBox("Info", "Do you want to try again?",
                                                                      MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.No)
                        {
                            break;
                        }
                    }
                    break;
                }

                case FilterMenuEnum.ByCategory:
                {
                    Console.Clear();

                    vacancies = ExceptionHandle.Handle(VacancyFilter.FilterByCategory, UserHelper.InputCategory(),
                                                       vacancies);

                    break;
                }

                case FilterMenuEnum.ByEducation:
                {
                    Console.Clear();

                    vacancies = ExceptionHandle.Handle(VacancyFilter.FilterByEducation, UserHelper.InputEducation(), vacancies);
                    break;
                }

                case FilterMenuEnum.ByExperience:
                {
                    Console.Clear();

                    vacancies = ExceptionHandle.Handle(VacancyFilter.FilterByExperience, UserHelper.InputExperience(), vacancies);
                    break;
                }

                case FilterMenuEnum.ByRegion:
                {
                    Console.Clear();

                    vacancies = ExceptionHandle.Handle(VacancyFilter.FilterByRegion, UserHelper.InputRegion(), vacancies);
                    break;
                }

                case FilterMenuEnum.BySalary:
                {
                    Console.Clear();
                    var input  = UserHelper.InputSalary();
                    var salary = UserHelper.ParseSalary(input);

                    vacancies = ExceptionHandle.Handle(VacancyFilter.FilterBySalary, salary, vacancies);
                    break;
                }

                case FilterMenuEnum.Reset:
                {
                    vacancies = mainVacancies;
                    break;
                }

                case FilterMenuEnum.Back:
                {
                    seeAdsLoop = false;
                    break;
                }
                }
            }
        }
Beispiel #3
0
        public void ApplyInput()
        {
            _helixItems.Clear();

            InitializeHelix();

            if (Cameras.Count == 4 && !InputAnglesManually)
            {
                {
                    double a     = Math.Abs(GetCamera(0).Calibration.TranslationToWorld[0, 0]) + Math.Abs(GetCamera(2).Calibration.TranslationToWorld[0, 0]);
                    double b     = Math.Abs(GetCamera(0).Calibration.TranslationToWorld[2, 0]) + Math.Abs(GetCamera(2).Calibration.TranslationToWorld[2, 0]);
                    double c     = Math.Sqrt(a * a + b * b);
                    double q     = (a * a) / c;
                    double p     = c - q;
                    double h     = Math.Sqrt(p * q);
                    double alpha = (180 / Math.PI) * Math.Atan(h / p);
                    double beta  = 90 - alpha;

                    GetCamera(0).Calibration.YAngle = (float)alpha;
                    GetCamera(1).Calibration.YAngle = (float)-alpha;
                    GetCamera(2).Calibration.YAngle = (float)(-180 + alpha);
                    GetCamera(3).Calibration.YAngle = (float)(180 - alpha);

                    GetCamera(0).Calibration.RotationToWorld = CvHelper.GetYRotationMatrix(GetCamera(0).Calibration.YAngle);
                    GetCamera(1).Calibration.RotationToWorld = CvHelper.GetYRotationMatrix(GetCamera(1).Calibration.YAngle);
                    GetCamera(2).Calibration.RotationToWorld = CvHelper.GetYRotationMatrix(GetCamera(2).Calibration.YAngle);
                    GetCamera(3).Calibration.RotationToWorld = CvHelper.GetYRotationMatrix(GetCamera(3).Calibration.YAngle);
                }
                {
                    double a     = GetCamera(0).Calibration.TranslationToWorld[1, 0] - GetCamera(2).Calibration.TranslationToWorld[1, 0];
                    double ax    = Math.Abs(GetCamera(0).Calibration.TranslationToWorld[0, 0]) + Math.Abs(GetCamera(2).Calibration.TranslationToWorld[0, 0]);
                    double az    = Math.Abs(GetCamera(0).Calibration.TranslationToWorld[2, 0]) + Math.Abs(GetCamera(2).Calibration.TranslationToWorld[2, 0]);
                    double c     = Math.Sqrt(ax * ax + az * az);
                    double q     = (a * a) / c;
                    double p     = c - q;
                    double h     = Math.Sqrt(p * q);
                    double alpha = (180 / Math.PI) * Math.Atan(h / p);
                    double beta  = 90 - alpha;

                    if (GetCamera(0).Calibration.TranslationToWorld[1, 0] < GetCamera(2).Calibration.TranslationToWorld[1, 0])
                    {
                        GetCamera(0).Calibration.XAngle = (float)alpha;
                        GetCamera(2).Calibration.XAngle = (float)-alpha;
                    }
                    else
                    {
                        GetCamera(0).Calibration.XAngle = (float)-alpha;
                        GetCamera(2).Calibration.XAngle = (float)alpha;
                    }
                }
                {
                    double a     = GetCamera(1).Calibration.TranslationToWorld[1, 0] - GetCamera(3).Calibration.TranslationToWorld[1, 0];
                    double ax    = Math.Abs(GetCamera(1).Calibration.TranslationToWorld[0, 0]) + Math.Abs(GetCamera(3).Calibration.TranslationToWorld[0, 0]);
                    double az    = Math.Abs(GetCamera(1).Calibration.TranslationToWorld[2, 0]) + Math.Abs(GetCamera(3).Calibration.TranslationToWorld[2, 0]);
                    double c     = Math.Sqrt(ax * ax + az * az);
                    double q     = (a * a) / c;
                    double p     = c - q;
                    double h     = Math.Sqrt(p * q);
                    double alpha = (180 / Math.PI) * Math.Atan(h / p);
                    double beta  = 90 - alpha;


                    if (GetCamera(1).Calibration.TranslationToWorld[1, 0] < GetCamera(3).Calibration.TranslationToWorld[1, 0])
                    {
                        GetCamera(1).Calibration.XAngle = (float)alpha;
                        GetCamera(3).Calibration.XAngle = (float)-alpha;
                    }
                    else
                    {
                        GetCamera(1).Calibration.XAngle = (float)-alpha;
                        GetCamera(3).Calibration.XAngle = (float)alpha;
                    }
                }
            }
        }
Beispiel #4
0
        public static void Start(Entities.Employer employer, Database.Database db)
        {
            var logger = new Logger.ConsoleLogger();

            var seeCvsLoop = true;


            var mainCvs = db.GetCvs();

            IList <Cv> cvs = mainCvs;


            while (seeCvsLoop)
            {
                Console.Clear();

                ExceptionHandle.Handle(CvHelper.SeeCvs, cvs);

                ConsoleScreen.PrintMenu(ConsoleScreen.FilterMenu, ConsoleColor.Blue);

                var filterMenuChoice = (FilterMenuEnum)ConsoleScreen.Input(ConsoleScreen.FilterMenu.Count);

                switch (filterMenuChoice)
                {
                case FilterMenuEnum.Select:
                {
                    var loop3 = true;
                    while (loop3)
                    {
                        Console.Clear();
                        if (!ExceptionHandle.Handle(CvHelper.SeeCvs, cvs))
                        {
                            break;
                        }
                        Console.WriteLine("Cv id: ");

                        var cvId = UserHelper.InputGuid();

                        try
                        {
                            var cv = CvHelper.GetCv(cvId, cvs);

                            Console.Clear();

                            while (true)
                            {
                                var requestFromEmployer = cv.CheckEmployerRequest(employer.Guid);

                                Console.Clear();

                                Console.WriteLine(cv++);     // increase view count and print.

                                Database.Database.Changes = true;

                                Console.WriteLine();

                                Console.WriteLine($"1. {(requestFromEmployer ? "Cancel" : "Request")}");

                                Console.WriteLine("2. Back");

                                var choice = ConsoleScreen.Input(2);

                                if (choice == 1)
                                {
                                    if (requestFromEmployer)
                                    {
                                        cv.RemoveRequest(employer.Guid);
                                    }
                                    else
                                    {
                                        Vacancy vacancy = null;

                                        while (true)
                                        {
                                            Console.Clear();
                                            if (!ExceptionHandle.Handle(employer.ShowAllAds, true))
                                            {
                                                LoggerPublisher.OnLogInfo("Please add public Vacancy!");
                                                ConsoleScreen.Clear();
                                                break;
                                            }

                                            var vacancyId = UserHelper.InputGuid();


                                            try
                                            {
                                                vacancy = VacancyHelper.GetVacancy(vacancyId, employer.Vacancies);
                                                break;
                                            }
                                            catch (Exception e)
                                            {
                                                LoggerPublisher.OnLogError(e.Message);
                                                ConsoleScreen.Clear();
                                            }
                                        }

                                        if (vacancy != null)
                                        {
                                            cv.SendRequest(employer.Guid, vacancy.Guid);
                                        }
                                    }
                                }
                                else if (choice == 2)
                                {
                                    if (ConsoleScreen.DisplayMessageBox("Info", "Do you want to see other Cvs?",
                                                                        MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.No)
                                    {
                                        loop3 = false;
                                    }
                                    break;
                                }
                            }

                            if (loop3)
                            {
                                continue;
                            }
                        }
                        catch (Exception e)
                        {
                            LoggerPublisher.OnLogError(e.Message);
                        }
                    }
                    break;
                }

                case FilterMenuEnum.ByCategory:
                {
                    Console.Clear();

                    cvs = ExceptionHandle.Handle(CvFilter.FilterByCategory, UserHelper.InputCategory(), cvs);
                    break;
                }

                case FilterMenuEnum.ByEducation:
                {
                    Console.Clear();

                    cvs = ExceptionHandle.Handle(CvFilter.FilterByEducation, UserHelper.InputEducation(), cvs);
                    break;
                }

                case FilterMenuEnum.ByExperience:
                {
                    Console.Clear();

                    cvs = ExceptionHandle.Handle(CvFilter.FilterByExperience, UserHelper.InputExperience(), cvs);
                    break;
                }

                case FilterMenuEnum.ByRegion:
                {
                    Console.Clear();

                    cvs = ExceptionHandle.Handle(CvFilter.FilterByRegion, UserHelper.InputRegion(), cvs);
                    break;
                }

                case FilterMenuEnum.BySalary:
                {
                    Console.Clear();

                    var input  = UserHelper.InputSalary();
                    var salary = UserHelper.ParseSalary(input);
                    cvs = ExceptionHandle.Handle(CvFilter.FilterBySalary, salary, cvs);
                    break;
                }

                case FilterMenuEnum.Reset:
                {
                    cvs = mainCvs;
                    break;
                }

                case FilterMenuEnum.Back:
                {
                    seeCvsLoop = false;
                    break;
                }
                }
            }
        }
        private void TrackerService_OnImageReady(object sender, EventArgs e)
        {
            OnImageReadyEventArgs args = (OnImageReadyEventArgs)e;

            IEnumerable <CameraModel> orderedCameras = _cameras.Cameras.OrderBy(camera => camera.Calibration.Index);

            foreach (CameraModel cameraModel1 in orderedCameras)
            {
                foreach (CameraModel cameraModel2 in orderedCameras)
                {
                    if (cameraModel1.Calibration.ObjectPointsProjected == null ||
                        cameraModel2.Calibration.ObjectPointsProjected == null)
                    {
                        continue;
                    }
                    if (cameraModel1.Calibration.Index == cameraModel2.Calibration.Index)
                    {
                        continue;
                    }
                    if (cameraModel1.Calibration.Index > 1)
                    {
                        continue;
                    }

                    IntPtr points1Ptr = CvHelper.CreatePointListPointer(cameraModel1.Calibration.ObjectPointsProjected);
                    IntPtr points2Ptr = CvHelper.CreatePointListPointer(cameraModel2.Calibration.ObjectPointsProjected);

                    Matrix <double> fundamentalMatrix = new Matrix <double>(3, 3);

                    IntPtr fundamentalMatrixPtr = CvInvoke.cvCreateMat(3, 3, MAT_DEPTH.CV_32F);
                    CvInvoke.cvFindFundamentalMat(points1Ptr, points2Ptr, fundamentalMatrix, CV_FM.CV_FM_RANSAC, 3,
                                                  0.99, IntPtr.Zero);

                    Matrix <double> lines1 = new Matrix <double>(8, 3);
                    CvInvoke.cvComputeCorrespondEpilines(points2Ptr, 2, fundamentalMatrix, lines1);

                    Matrix <double> lines2 = new Matrix <double>(8, 3);
                    CvInvoke.cvComputeCorrespondEpilines(points1Ptr, 1, fundamentalMatrix, lines2);

                    for (int i = 0; i < cameraModel1.Calibration.ObjectPointsProjected.Length; i++)
                    {
                        {
                            Point[] points = new Point[2]
                            {
                                new Point(0, (int)-(lines2[i, 2] / lines2[i, 1])),
                                new Point(args.Image.Cols,
                                          (int)(-(lines2[i, 2] + lines2[i, 0] * args.Image.Cols) / lines2[i, 1]))
                            };
                            args.Image.DrawPolyline(points, false, new Bgr(255, 255, 0), 1);
                        }

                        //{
                        //    System.Drawing.Point[] points = new System.Drawing.Point[2]
                        //    {
                        //        new System.Drawing.Point(0, (int) -(lines1[i, 2]/lines1[i, 1])),
                        //        new System.Drawing.Point(img.Cols, (int) (-(lines1[i, 2] + lines1[i, 0] * img.Cols) / lines1[i, 1]))
                        //    };
                        //    img.DrawPolyline(points, false, new Bgr(255, 0, 255), 1);
                        //}
                    }
                }
            }
        }
        public void ProcessData(MotionControllerModel mc)
        {
            if (_camera.Handle != IntPtr.Zero)
            {
                Vector3             rawPosition    = Vector3.zero;
                Vector3             fusionPosition = Vector3.zero;
                PSMoveTrackerStatus trackerStatus  = mc.TrackerStatus[_camera];

                if (!mc.Design)
                {
                    trackerStatus = PsMoveApi.psmove_tracker_get_status(_camera.Handle, mc.Handle);
                }

                if (trackerStatus == PSMoveTrackerStatus.Tracking)
                {
                    float rx, ry, rrad;
                    float fx, fy, fz;
                    PsMoveApi.psmove_tracker_get_position(_camera.Handle, mc.Handle, out rx, out ry, out rrad);
                    PsMoveApi.psmove_fusion_get_position(_camera.Fusion, mc.Handle, out fx, out fy, out fz);
                    rx = (int)(rx + 0.5);
                    ry = (int)(ry + 0.5);

                    rawPosition    = new Vector3(rx, ry, rrad);
                    fusionPosition = new Vector3(fx, fy, fz);
                }
                else if (mc.Design)
                {
                    switch (_camera.Calibration.Index)
                    {
                    case 0:
                        rawPosition = new Vector3(129, 280, 8.970074f);
                        break;

                    case 1:
                        rawPosition = new Vector3(180, 293, 11.9714022f);
                        break;

                    case 2:
                        rawPosition = new Vector3(528, 286, 9.038924f);
                        break;

                    case 3:
                        rawPosition = new Vector3(389, 275, 6.530668f);
                        break;
                    }
                }
                mc.TrackerStatus[_camera]  = trackerStatus;
                mc.RawPosition[_camera]    = rawPosition;
                mc.FusionPosition[_camera] = fusionPosition;

                if (trackerStatus == PSMoveTrackerStatus.Tracking || mc.Design)
                {
                    // controller position -> rectangle in surrounding the sphere in image coordinates
                    PointF[] imgPts = CvHelper.GetImagePointsF(mc.RawPosition[_camera]);

                    ExtrinsicCameraParameters ex = CameraCalibration.FindExtrinsicCameraParams2(
                        _camera.Calibration.ObjectPoints2D,
                        imgPts,
                        _camera.Calibration.IntrinsicParameters);

                    Matrix <double> coordinatesInCameraSpace_homo = new Matrix <double>(new double[]
                    {
                        ex.TranslationVector[0, 0],
                        ex.TranslationVector[1, 0],
                        ex.TranslationVector[2, 0],
                        1
                    });
                    mc.CameraPosition[_camera] = new Vector3(
                        (float)coordinatesInCameraSpace_homo[0, 0],
                        (float)coordinatesInCameraSpace_homo[1, 0],
                        (float)coordinatesInCameraSpace_homo[2, 0]);


                    ex.RotationVector[0, 0] += (Math.PI / 180) * (_camera.Calibration.RotX + _camera.Calibration.XAngle);
                    ex.RotationVector[1, 0] += (Math.PI / 180) * (_camera.Calibration.RotY + _camera.Calibration.YAngle);
                    ex.RotationVector[2, 0] += (Math.PI / 180) * (_camera.Calibration.RotZ + _camera.Calibration.ZAngle);

                    _camera.Calibration.ExtrinsicParameters[mc.Id] = ex;
                    Matrix <double> minusRotation = new Matrix <double>(3, 3);
                    minusRotation = CvHelper.Rotate(
                        -_camera.Calibration.RotX - _camera.Calibration.XAngle,
                        -_camera.Calibration.RotY - _camera.Calibration.YAngle,
                        -_camera.Calibration.RotZ - _camera.Calibration.ZAngle);

                    Matrix <double> R3x3_cameraToWorld = new Matrix <double>(3, 3);
                    R3x3_cameraToWorld = CvHelper.Rotate(
                        _camera.Calibration.RotX,
                        _camera.Calibration.RotY + _camera.Calibration.YAngle,
                        _camera.Calibration.RotZ);

                    Matrix <double> rotInv = new Matrix <double>(3, 3);
                    CvInvoke.cvInvert(ex.RotationVector.RotationMatrix.Ptr, rotInv, SOLVE_METHOD.CV_LU);

                    Matrix <double> test = CvHelper.ConvertToHomogenous(-1 * R3x3_cameraToWorld);

                    _camera.Calibration.ObjectPointsProjected = CameraCalibration.ProjectPoints(
                        _camera.Calibration.ObjectPoints3D,
                        _camera.Calibration.ExtrinsicParameters[mc.Id],
                        _camera.Calibration.IntrinsicParameters);

                    Matrix <double> cameraPositionInWorldSpace4x4 = new Matrix <double>(new double[, ]
                    {
                        { 1, 0, 0, _camera.Calibration.TranslationToWorld[0, 0] },
                        { 0, 1, 0, _camera.Calibration.TranslationToWorld[1, 0] },
                        { 0, 0, 1, _camera.Calibration.TranslationToWorld[2, 0] },
                        { 0, 0, 0, 1 },
                    });

                    Matrix <double> Rt_homo      = CvHelper.ConvertToHomogenous(R3x3_cameraToWorld);
                    Matrix <double> x_world_homo = CvHelper.ConvertToHomogenous(minusRotation) * coordinatesInCameraSpace_homo;
                    Rt_homo[0, 3] = x_world_homo[0, 0];
                    Rt_homo[1, 3] = x_world_homo[1, 0];
                    Rt_homo[2, 3] = x_world_homo[2, 0];
                    x_world_homo  = cameraPositionInWorldSpace4x4 * x_world_homo;
                    Vector3 v3world = new Vector3((float)x_world_homo[0, 0], (float)x_world_homo[1, 0],
                                                  (float)x_world_homo[2, 0]);
                    mc.WorldPosition[_camera] = v3world;

                    for (int i = mc.PositionHistory[_camera].Length - 1; i > 0; --i)
                    {
                        mc.PositionHistory[_camera][i] = mc.PositionHistory[_camera][i - 1];
                    }
                    mc.PositionHistory[_camera][0] = v3world;
                }
            }
        } // ProcessData
Beispiel #7
0
        private static void CvUpdateSideStart(Cv cv)
        {
            while (true)
            {
                Console.Clear();

                Console.WriteLine(cv);
                Console.WriteLine();

                ConsoleScreen.PrintMenu(ConsoleScreen.CvUpdateMenu, ConsoleColor.Blue);

                var updateChoice =
                    (CvUpdateChoices)ConsoleScreen.Input(ConsoleScreen.CvUpdateMenu.Count);

                if (updateChoice == CvUpdateChoices.Back)
                {
                    break;
                }

                switch (updateChoice)
                {
                case CvUpdateChoices.ChangeVisibility:
                {
                    cv.IsPublic = !cv.IsPublic;
                    LoggerPublisher.OnLogInfo($"Visibility changed to {(cv.IsPublic ? "Public":"Private")}");
                    break;
                }

                case CvUpdateChoices.Name:
                {
                    Console.Clear();

                    cv.Name = CvHelper.InputData("Name");
                    LoggerPublisher.OnLogInfo("Name updated!");
                    break;
                }

                case CvUpdateChoices.Surname:
                {
                    Console.Clear();

                    cv.Surname = CvHelper.InputData("Surname");
                    LoggerPublisher.OnLogInfo("Surname updated!");
                    break;
                }

                case CvUpdateChoices.Category:
                {
                    cv.Category = UserHelper.InputCategory();

                    LoggerPublisher.OnLogInfo("Category updated!");
                    break;
                }

                case CvUpdateChoices.Region:
                {
                    cv.Region = UserHelper.InputRegion();
                    LoggerPublisher.OnLogInfo("Region updated!");
                    break;
                }

                case CvUpdateChoices.Salary:
                {
                    Console.Clear();
                    Console.WriteLine("Salary: ");
                    cv.Salary = UserHelper.GetNumeric(NumericTypes.INT);
                    LoggerPublisher.OnLogInfo("Salary updated!");
                    break;
                }

                case CvUpdateChoices.Education:
                {
                    cv.Education = UserHelper.InputEducation();

                    LoggerPublisher.OnLogInfo("Education updated");
                    break;
                }

                case CvUpdateChoices.Experience:
                {
                    cv.Experience = UserHelper.InputExperience();

                    LoggerPublisher.OnLogInfo("Experience updated!");
                    break;
                }

                case CvUpdateChoices.WorkPlaces:
                {
                    if (ConsoleScreen.DisplayMessageBox("Info", "Do you want to add workplace or delete?",
                                                        MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
                    {
                        Console.WriteLine("Add workplaces: ");
                        while (true)
                        {
                            var companyName = CvHelper.InputData("Company");

                            var timeline = new Timeline()
                            {
                                Start = CvHelper.InputDateTime("Start time(ex mm/dd/yyyy): "),
                            };

                            while (true)
                            {
                                var endTime = CvHelper.InputDateTime("End time(ex mm/dd/yyyy): ");

                                if (timeline.Start < endTime)
                                {
                                    timeline.End = endTime;
                                    break;
                                }

                                LoggerPublisher.OnLogError("End time must be greater than start time!");
                            }

                            cv.WorkPlaces.Add(new WorkPlace()
                                {
                                    Company  = companyName,
                                    Timeline = timeline
                                });

                            LoggerPublisher.OnLogInfo("Workplace added");
                            if (ConsoleScreen.DisplayMessageBox("Info", "Do you want to add more WorkPlaces?",
                                                                MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.No)
                            {
                                break;
                            }
                            Database.Database.Changes = true;
                        }
                    }
                    else
                    {
                        if (cv.WorkPlaces.Count > 0)
                        {
                            while (true)
                            {
                                Console.Clear();
                                Console.WriteLine("Delete workplace: ");
                                foreach (var workPlace in cv.WorkPlaces)
                                {
                                    Console.WriteLine(workPlace);
                                }

                                var workplaceId = UserHelper.InputGuid();

                                if (ExceptionHandle.Handle(cv.DeleteWorkplace, workplaceId))
                                {
                                    LoggerPublisher.OnLogInfo("Workplace deleted");


                                    if (cv.WorkPlaces.Count == 0 || ConsoleScreen.DisplayMessageBox("Info", "Do you want to delete more WorkPlaces?",
                                                                                                    MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.No)
                                    {
                                        break;
                                    }
                                }
                            }
                        }
                    }
                    break;
                }

                case CvUpdateChoices.Skills:
                {
                    if (ConsoleScreen.DisplayMessageBox("Info", "Do you want to add skill or delete?",
                                                        MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
                    {
                        Console.WriteLine("Add skill: ");
                        while (true)
                        {
                            cv.Skills.Add(new Skill()
                                {
                                    Name  = CvHelper.InputData("Name"),
                                    Level = CvHelper.InputSkillLevel(),
                                });

                            LoggerPublisher.OnLogInfo("Skill added");
                            if (ConsoleScreen.DisplayMessageBox("Info", "Do you want to add more Skills?",
                                                                MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.No)
                            {
                                break;
                            }
                        }
                    }
                    else
                    {
                        if (cv.Skills.Count > 0)
                        {
                            while (true)
                            {
                                Console.Clear();
                                Console.WriteLine("Delete skill: ");
                                foreach (var skill in cv.Skills)
                                {
                                    Console.WriteLine(skill);
                                }

                                var skillId = UserHelper.InputGuid();

                                if (ExceptionHandle.Handle(cv.DeleteSkill, skillId))
                                {
                                    LoggerPublisher.OnLogInfo("Skill deleted");


                                    if (cv.Skills.Count == 0 || ConsoleScreen.DisplayMessageBox("Info", "Do you want to delete more Skill?",
                                                                                                MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.No)
                                    {
                                        break;
                                    }
                                }
                            }
                        }
                    }
                    break;
                }

                case CvUpdateChoices.Languages:
                {
                    if (ConsoleScreen.DisplayMessageBox("Info", "Do you want to add language or delete?",
                                                        MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
                    {
                        Console.WriteLine("Add languages: ");
                        while (true)
                        {
                            cv.Languages.Add(new Language()
                                {
                                    Name  = CvHelper.InputData("Name"),
                                    Level = CvHelper.InputSkillLevel(),
                                });

                            LoggerPublisher.OnLogInfo("Language added");
                            if (ConsoleScreen.DisplayMessageBox("Info", "Do you want to add more Languages?",
                                                                MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.No)
                            {
                                break;
                            }
                        }
                    }
                    else
                    {
                        if (cv.Languages.Count > 0)
                        {
                            while (true)
                            {
                                Console.Clear();
                                Console.WriteLine("Delete language: ");
                                foreach (var language in cv.Languages)
                                {
                                    Console.WriteLine(language);
                                }

                                var skillId = UserHelper.InputGuid();

                                if (ExceptionHandle.Handle(cv.DeleteLanguage, skillId))
                                {
                                    LoggerPublisher.OnLogInfo("Language deleted");


                                    if (cv.Languages.Count == 0 || ConsoleScreen.DisplayMessageBox("Info", "Do you want to delete more Language?",
                                                                                                   MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.No)
                                    {
                                        break;
                                    }
                                }
                            }
                        }
                    }
                    break;
                }

                case CvUpdateChoices.HonorsDiploma:
                {
                    cv.HonorsDiploma = CvHelper.InputHonorsDiplomaStatus();

                    LoggerPublisher.OnLogInfo("Honors diploma updated!");
                    break;
                }

                case CvUpdateChoices.Socials:
                {
                    if (ConsoleScreen.DisplayMessageBox("Info", "Do you want to add Social or delete?",
                                                        MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
                    {
                        Console.WriteLine("Add socials: ");
                        while (true)
                        {
                            cv.Socials.Add(new Social()
                                {
                                    Name = CvHelper.InputData("Name"),
                                    Link = CvHelper.InputLink()
                                });

                            LoggerPublisher.OnLogInfo("Social added");
                            if (ConsoleScreen.DisplayMessageBox("Info", "Do you want to add more Socials?",
                                                                MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.No)
                            {
                                break;
                            }
                        }
                    }
                    else
                    {
                        if (cv.Socials.Count > 0)
                        {
                            while (true)
                            {
                                Console.Clear();
                                Console.WriteLine("Delete social: ");
                                foreach (var social in cv.Socials)
                                {
                                    Console.WriteLine(social);
                                }

                                var socialId = UserHelper.InputGuid();

                                if (ExceptionHandle.Handle(cv.DeleteSocial, socialId))
                                {
                                    LoggerPublisher.OnLogInfo("Social deleted");


                                    if (cv.Socials.Count == 0 || ConsoleScreen.DisplayMessageBox("Info", "Do you want to delete more Social?",
                                                                                                 MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.No)
                                    {
                                        break;
                                    }
                                }
                            }
                        }
                    }
                    break;
                }
                }
                Database.Database.Changes = true;
                ConsoleScreen.Clear();
            }
        }
Beispiel #8
0
        private static Cv CreateNewCv()
        {
            var newCv = new Cv();


            newCv.Name    = CvHelper.InputData("Name");
            newCv.Surname = CvHelper.InputData("Surname: ");

            newCv.Category = UserHelper.InputCategory();


            newCv.Region = UserHelper.InputRegion();

            Console.Clear();
            Console.WriteLine("Salary: ");
            newCv.Salary = UserHelper.GetNumeric(NumericTypes.INT);


            newCv.Education = UserHelper.InputEducation();


            newCv.Experience = UserHelper.InputExperience();


            newCv.HonorsDiploma = CvHelper.InputHonorsDiplomaStatus();

            if (ConsoleScreen.DisplayMessageBox("Info", "Do you want to add skill?",
                                                MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
            {
                Console.WriteLine("Add skill: ");
                while (true)
                {
                    newCv.Skills.Add(new Skill()
                    {
                        Name  = CvHelper.InputData("Skill"),
                        Level = CvHelper.InputSkillLevel()
                    });

                    if (ConsoleScreen.DisplayMessageBox("Info", "Do you want to add more skill?",
                                                        MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.No)
                    {
                        break;
                    }
                }
            }


            if (ConsoleScreen.DisplayMessageBox("Info", "Do you want to add Workplace?",
                                                MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
            {
                Console.WriteLine("Add workplaces: ");
                while (true)
                {
                    var companyName = CvHelper.InputData("Company");

                    var timeline = new Timeline()
                    {
                        Start = CvHelper.InputDateTime("Start time(ex mm/dd/yyyy): "),
                    };

                    while (true)
                    {
                        var endTime = CvHelper.InputDateTime("End time(ex mm/dd/yyyy): ");

                        if (timeline.Start < endTime)
                        {
                            timeline.End = endTime;
                            break;
                        }

                        LoggerPublisher.OnLogError("End time must be greater than start time!");
                    }

                    newCv.WorkPlaces.Add(new WorkPlace()
                    {
                        Company  = companyName,
                        Timeline = timeline
                    });


                    if (ConsoleScreen.DisplayMessageBox("Info", "Do you want to add more WorkPlaces?",
                                                        MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.No)
                    {
                        break;
                    }
                }
            }

            if (ConsoleScreen.DisplayMessageBox("Info", "Do you want to add language?",
                                                MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
            {
                Console.WriteLine("Add Language");

                while (true)
                {
                    newCv.Languages.Add(new Language()
                    {
                        Name  = CvHelper.InputData("Name"),
                        Level = CvHelper.InputSkillLevel(),
                    });

                    if (ConsoleScreen.DisplayMessageBox("Info", "Do you want to add more language?",
                                                        MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.No)
                    {
                        break;
                    }
                }
            }

            if (ConsoleScreen.DisplayMessageBox("Info", "Do you want to add social?",
                                                MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
            {
                Console.WriteLine("Add social: ");

                while (true)
                {
                    newCv.Socials.Add(new Social()
                    {
                        Name = CvHelper.InputData("Name"),
                        Link = CvHelper.InputLink()
                    });

                    if (ConsoleScreen.DisplayMessageBox("Info", "Do you want to add more social?",
                                                        MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.No)
                    {
                        break;
                    }
                }
            }

            return(newCv);
        }