private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                PhotoURL.Text = "";
                DriverViewModel driver = DriverLogic.GetCurrentDriver();
                Currentdriver.Photo = driver.Photo;
                if (driver.Photo != null)
                {
                    borderImage.BorderBrush = Brushes.White;
                    ImageDriver.Source      = ImageLogic.ImageFromByte(driver.Photo);
                }

                Name.Text              = driver.Name;
                Phone.Text             = driver.Telephone;
                Mail.Text              = driver.Email;
                Passport.Text          = driver.Passport;
                DateBirth.SelectedDate = driver.DateBirth;
                Address.Text           = driver.FullAddress;
                AddressLife.Text       = driver.AddressLife;
                PostCode.Text          = driver.PostCode.ToString();
                Company.Text           = driver.Company;
                JobName.Text           = driver.JobName;
                Expirience.Text        = driver.DrivingExperience.ToString();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemple #2
0
        public ActionResult GuardarListaPDF(IEnumerable <HttpPostedFileBase> files, float ancho, float largo)
        {
            try
            {
                ZipFile zip = new ZipFile();

                if (files.Count() > 0)
                {
                    foreach (var file in files)
                    {
                        zip.AddEntry(file.FileName.Replace(".jpg", ".pdf"), ImageLogic.ImagenA4(file, ancho, largo).ToArray());
                    }
                }
                using (MemoryStream output = new MemoryStream())
                {
                    zip.Save(output);
                    zip.Dispose();
                    return(this.File(output.ToArray(), "application/zip", "ImagenesA4.zip"));
                }
            }
            catch
            {
                return(this.RedirectToAction("Index", "Imagen"));
            }
        }
Exemple #3
0
        public void SearchImages_SearchTextNull_ThrowsArgumentNullException2()
        {
            int count = 2;
            var logic = new ImageLogic(new DummyImageManager(count));

            Assert.ThrowsException <ArgumentNullException>(() => logic.SearchImages(null));
        }
Exemple #4
0
        public ActionResult SaveImage()
        {
            if (Request.Files.Count > 0)
            {
                try
                {
                    ApplicationDbContext db = new ApplicationDbContext();


                    int CurrentImageID;
                    int.TryParse(Request.Form["CurrentImageID"], out CurrentImageID);

                    HttpPostedFileBase file        = Request.Files[0];
                    MemoryStream       inputStream = new MemoryStream();
                    file?.InputStream.CopyTo(inputStream);

                    var NewImg = ImageLogic.ProcessImage(inputStream);
                    NewImg.Type = CalorieImage.ImageType.UserImage;
                    NewImg.ApplicationUser_Id = CurrentUser()?.Id;

                    db.Images.Add(NewImg);
                    db.SaveChanges();

                    return(Content(NewImg.CalorieImageID.ToString(), "text/xml"));
                }
                catch (Exception ex) {
                    Response.StatusCode = (int)HttpStatusCode.BadRequest;
                    return(Content(ex.ToString(), MediaTypeNames.Text.Plain));
                }
            }

            Response.StatusCode = (int)HttpStatusCode.BadRequest;
            return(Content("No File Found", MediaTypeNames.Text.Plain));
        }
Exemple #5
0
 public RenderingController(
     ImageLogic imageLogic,
     RenderingLogic renderingLogic)
 {
     _imageLogic     = imageLogic;
     _renderingLogic = renderingLogic;
 }
Exemple #6
0
        public ActionResult SaveImageFromURLWithDelete(string url, string idToDelete)
        {
            try
            {
                var idToDeleteInt = GenericLogic.GetInt(idToDelete);
                if (idToDeleteInt > 0)
                {
                    try
                    {
                        var CurrentImage = db.Images.FirstOrDefault(I => I.CalorieImageID == idToDeleteInt);
                        if (CurrentImage != null)
                        {
                            db.Images.Remove(CurrentImage);
                            db.SaveChanges();
                        }
                    }
                    catch
                    {
                        // ignored
                    }
                }


                var ID = ImageLogic.GetAndSaveImageFromURL(url, CalorieImage.ImageType.UserImage);
                return(Content(ID.ToString(), "text/xml"));
            }
            catch
            {
                Response.StatusCode = (int)HttpStatusCode.BadRequest;
                return(Content("", MediaTypeNames.Text.Plain));
            }
        }
Exemple #7
0
        public MainWindow(ILogger <MainWindow> logger, MainViewModel viewModel, Connector connector, IRecorderLogic recorderLogic, ImageLogic imageLogic, ExportLogic exportLogic, ThrottleLogic drawingThrottleLogic, StateMachine stateMachine)
        {
            InitializeComponent();

            this.Loaded              += MainWindow_Loaded;
            this.logger               = logger;
            this.viewModel            = viewModel;
            this.connector            = connector;
            this.recorderLogic        = recorderLogic;
            this.imageLogic           = imageLogic;
            this.exportLogic          = exportLogic;
            this.drawingThrottleLogic = drawingThrottleLogic;
            this.stateMachine         = stateMachine;

            stateMachine.StateChanged += StateMachine_StateChanged;

            connector.AircraftPositionUpdated += Connector_AircraftPositionUpdated;
            connector.Frame  += Connector_Frame;
            connector.Closed += Connector_Closed;

            DataContext = viewModel;

            recorderLogic.RecordsUpdated      += RecorderLogic_RecordsUpdated;
            recorderLogic.CurrentFrameChanged += RecorderLogic_CurrentFrameChanged;
            recorderLogic.ReplayFinished      += RecorderLogic_ReplayFinished;

            currentVersion = Assembly.GetEntryAssembly().GetName().Version.ToString();
            Title         += " " + currentVersion;
        }
Exemple #8
0
 public MainWindow()
 {
     InitializeComponent();
     _imageLogic              = new ImageLogic();
     _computingLogic          = new ImageComputingLogic();
     _syncImageSearchResults  = new List <Rectangle>();
     _asyncImageSearchResults = new ConcurrentDictionary <int, Rectangle>();
 }
        public DrawingLogic(ILogger <DrawingLogic> logger, ImageLogic imageLogic, ThrottleLogic drawingThrottleLogic)
        {
            logger.LogDebug("Creating instance of {class}", nameof(DrawingLogic));

            this.logger               = logger;
            this.imageLogic           = imageLogic;
            this.drawingThrottleLogic = drawingThrottleLogic;
        }
Exemple #10
0
        public void SearchImages_SearchTextEmpty_ReturnsAllImages()
        {
            int count = 2;
            var logic = new ImageLogic(new DummyImageManager(count));

            var images = logic.SearchImages(string.Empty);

            Assert.AreEqual(count, images.Count());
        }
Exemple #11
0
        public void SearchImages_ValidSearchText_ReturnsCorrectResult(string searchText, int expectedResults)
        {
            int count = 20;
            var logic = new ImageLogic(new DummyImageManager(count));

            var images = logic.SearchImages(searchText);

            Assert.AreEqual(expectedResults, images.Count());
        }
        private void AddDriver_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                DriverModel newDriver = new DriverModel()
                {
                    FirstName         = FirstName.Text,
                    LastName          = LastName.Text,
                    Patronymic        = Patronymic.Text,
                    SerialPasp        = PaspSeries.Text,
                    NumberPasp        = PaspNumber.Text,
                    DateBirth         = DateBirth.SelectedDate.Value,
                    FullAddressLife   = CityLife.Text + " " + AddressLife.Text,
                    FullAddress       = City.Text + " " + AddressLife.Text,
                    Telephone         = Phone.Text,
                    DrivingExperience = int.Parse(Expirience.Text),
                    PostCode          = int.Parse(PostCode.Text),
                    Company           = Company.Text,
                    JobName           = JobName.Text,
                    Email             = Email.Text
                };
                if (ImageURL.Text == "")
                {
                    newDriver.Photo = null;
                }
                else
                {
                    newDriver.Photo = ImageLogic.ByteFromImage(ImageURL.Text);
                }
                DriverLogic.AddDriver(newDriver);

                MessageBox.Show("Водитель успешно добавлен!");

                switch (SecurityContext.CurrentWindow)
                {
                case Logic.Enums.EnumWindow.AddLicense:
                    this.Close();
                    break;

                case Logic.Enums.EnumWindow.AddTransport:
                    this.Close();
                    break;

                case Logic.Enums.EnumWindow.DriverList:
                    DriverList driverList = new DriverList();
                    driverList.Show();
                    this.Close();
                    break;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemple #13
0
 public AwardController(IWebHostEnvironment env,
                        AwardLogic awardLogic,
                        ImageLogic imageLogic,
                        UserLogic userLogic,
                        UserAwardLogic userAwardLogic)
 {
     _env            = env;
     _awardLogic     = awardLogic;
     _imageLogic     = imageLogic;
     _userLogic      = userLogic;
     _userAwardLogic = userAwardLogic;
 }
Exemple #14
0
        public ActionResult GuardarPDF(HttpPostedFileBase files, float ancho, float largo)

        {
            try
            {
                return(this.File(ImageLogic.ImagenA4(files, ancho, largo).ToArray(), "application/pdf"));
            }
            catch
            {
                return(this.RedirectToAction("Index", "Imagen"));
            }
        }
Exemple #15
0
 public UserController(IWebHostEnvironment env,
                       UserLogic userLogic,
                       ImageLogic imageLogic,
                       RoleLogic roleLogic,
                       DepartmentLogic departmentLogic)
 {
     _env             = env;
     _userLogic       = userLogic;
     _imageLogic      = imageLogic;
     _roleLogic       = roleLogic;
     _departmentLogic = departmentLogic;
 }
Exemple #16
0
 public ActionResult SaveImageFromURL(string url)
 {
     try
     {
         var ID = ImageLogic.GetAndSaveImageFromURL(url, CalorieImage.ImageType.UserImage);
         return(Content(ID.ToString(), "text/xml"));
     }
     catch
     {
         Response.StatusCode = (int)HttpStatusCode.BadRequest;
         return(Content("", MediaTypeNames.Text.Plain));
     }
 }
        public void GetHorizonImageBoundaryTest()
        {
            ImageLogic images = new ImageLogic();

            images.GetHorizonImage(-1000, 20, 359);
            images.GetHorizonImage(1000, 20, 359);

            images.GetHorizonImage(-10, 2000, 359);
            images.GetHorizonImage(10, -2000, 359);

            images.GetHorizonImage(-10, 20, 3000);
            images.GetHorizonImage(10, -20, -3000);
        }
Exemple #18
0
        // Событие на клик добавить постер
        private void AddPoster_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Filter = "Файлы изображений (*.jpg, *.png)|*.jpg;*.png";

            if (openFileDialog.ShowDialog() == true)
            {
                FilePath = openFileDialog.FileName;               // Путь файла изображения

                ImageBytes = ImageLogic.GetImageBinary(FilePath); // Изображение в бинарном формате
                img.Source = ImageLogic.ByteToImage(ImageBytes);  // Визуализация изображения
            }
        }
        public void GetCustomImageTest_NoCoordinateRangeError()
        {
            ImageLogic images   = new ImageLogic();
            bool       hitError = false;

            try
            {
                images.GetCustomGaugeImage("T", "B", 2000, -2000, 1, 1, "F2", false, new string[] { "100:green" }, 5, 3, false, false, false);
            }
            catch (Exception e)
            {
                hitError = e.Message == "Coordinate outside allowed range";
            }

            Assert.IsFalse(hitError, "we should not have  hit a ClipperLib.ClipperException");
        }
 private void Photo_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         OpenFileDialog file = new OpenFileDialog
         {
             Filter = "Изображение |*.jpg;*.png;*.jpeg;*.bmp"
         };
         if (file.ShowDialog() == true)
         {
             PhotoURL.Text      = file.FileName;
             ImageDriver.Source = ImageLogic.ImageFromByte(File.ReadAllBytes(file.FileName));
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Exemple #21
0
        public void GetGaugeImageTest()
        {
            ImageLogic images = new ImageLogic();

            string result = images.GetGaugeImage("TRQ", 50, 0, 100);

            var path = @"Images\gauge.png";

            if (File.Exists(path))
            {
                File.Delete(path);
            }

            using (FileStream fs = File.Create(path))
            {
                var bytes = Convert.FromBase64String(result.Substring(23));
                fs.Write(bytes, 0, bytes.Length);
            }
        }
Exemple #22
0
        public void GetHorizonImageTest()
        {
            ImageLogic images = new ImageLogic();

            string result = images.GetHorizonImage(-10, 20, 359);

            var path = @"Images\horizon.png";

            if (File.Exists(path))
            {
                File.Delete(path);
            }

            using (FileStream fs = File.Create(path))
            {
                var bytes = Convert.FromBase64String(result.Substring(23));
                fs.Write(bytes, 0, bytes.Length);
            }
        }
Exemple #23
0
        public async Task <IActionResult> PostImageToWord([FromRoute] string contentType, int contentId, string hotLink = null)
        {
            var findImage = _context.Images.Where(x => x.ContentId == contentId && x.ContentType == contentType).FirstOrDefault();

            if (!string.IsNullOrEmpty(hotLink))
            {
                CreateImageFromHotlink(contentType, contentId, hotLink, findImage);
            }
            else
            {
                var filesUploaded = HttpContext.Request.Form.Files;

                if (filesUploaded != null)
                {
                    var imageLogic = new ImageLogic();

                    imageLogic.CreateImage(contentType, contentId, filesUploaded, findImage);
                }
            }
            return(Ok());
        }
        List <Ratings> listrating; // Рейтинги фильма

        #endregion

        #region Вспомогательные методы

        private async void InitializationData(int idFilm)
        {
            logic = new CommonLogic();


            film = await logic.GetOneFilmAsync(idFilm);

            myrating = await logic.LogicRatings.GetMyRatingFilm(idFilm, user.IdUser); //  Мой рейтинг

            listrating = await logic.LogicRatings.GetRatingsOnFilm(idFilm);           // Получаем списки рейтингов

            // Инициализация компонентов
            FilmName.Content        = film.Name;
            producer.Content        = film.Producers.GetProducerFIO;
            imgposter.Source        = ImageLogic.ByteToImage(film.Poster); // Визуализация изображения
            aboutfilm.Text          = film.AboutFilm;
            year.Content            = film.DateFilm;
            country.Content         = film.Country;
            genree.Content          = film.Genres.GenreName;
            actorslist.ItemsSource  = film.ActorsFilm;
            ratingslist.ItemsSource = listrating;
            rating.Content          = listrating.Average(i => i.Rating);
        }
Exemple #25
0
 public ImageController(ImageLogic imageLogic)
 {
     this.ImageLogic = imageLogic;
 }
 public ResultDetailsWindow()
 {
     InitializeComponent();
     _imageLogic = new ImageLogic();
 }
Exemple #27
0
        public void SearchImages_SearchTextNull_ThrowsArgumentNullException()
        {
            var logic = new ImageLogic(new DummyImageManager(2));

            logic.SearchImages(null);
        }
        //public IActionResult Index()
        //{
        //    return View();
        //}

        public IActionResult UploadImage(IFormFile file)
        {
            (string jsonRows, string jsonCols) = ImageLogic.UploadFile(file);

            return(Json("OK"));
        }