Example #1
0
        private void frmMain_Load(object sender, EventArgs e)
        {
            //System.Diagnostics.Debugger.Launch();

            if (Directory.Exists(@MainPath.path + @"\config\" + passedDirec))
            {
                ControlList = new List <ucShortcut>();

                this.SetStyle(ControlStyles.SupportsTransparentBackColor, true);
                ThisCategory   = new Category($"config\\{passedDirec}");
                this.BackColor = ImageFunctions.FromString(ThisCategory.ColorString);
                Opacity        = (1 - (ThisCategory.Opacity / 100));

                if (BackColor.R * 0.2126 + BackColor.G * 0.7152 + BackColor.B * 0.0722 > 255 / 2)
                {
                    //if backcolor is light, set hover color as darker
                    HoverColor = Color.FromArgb(BackColor.A, (BackColor.R - 50), (BackColor.G - 50), (BackColor.B - 50));
                }
                else
                {
                    //light backcolor is light, set hover color as darker
                    HoverColor = Color.FromArgb(BackColor.A, (BackColor.R + 50), (BackColor.G + 50), (BackColor.B + 50));
                }

                LoadCategory();
                SetLocation();
            }
            else
            {
                Application.Exit();
            }
        }
Example #2
0
 /// <summary>
 /// Event Handler for BtnBrowseForPictureFile.Click event.
 /// Browse for Picture file and set pictureBoxPhoto Image and Tag(byte array).
 /// </summary>
 /// <param name="sender">Sender of event</param>
 /// <param name="e">Event arguments</param>
 private void BtnBrowseForPictureFile_Click(object sender, EventArgs e)
 {
     using (OpenFileDialog ofd = new OpenFileDialog())
     {
         ofd.Multiselect = false;
         ofd.Title       = "Browse for a Picture File";
         // browse for the file
         if (ofd.ShowDialog() == DialogResult.OK)
         {
             try
             {
                 // get image from file
                 Image img = Image.FromFile(ofd.FileName);
                 // resize image so that height=100
                 pictureBoxPhoto.Image = ImageFunctions.ResizeImage(img, (int)(100.0m * img.Width / img.Height), 100);
                 // set tag to byte array of image in bitmap format
                 pictureBoxPhoto.Tag = ImageFunctions.GetByteArrayFromBitMapImage(pictureBoxPhoto.Image);
             }
             catch (Exception ex)
             {
                 LogFunctions.LogException(ex);
                 _ = MessageBox.Show("A problem occurred while loading the photo from the file.",
                                     "Invalid Photo File",
                                     MessageBoxButtons.OK);
             }
         }
     }
 }
        public void TestLeftToRightRGB()
        {
            var bun = ImageFactory.GenerateRgb(BunnyPath);

            ImageFunctions.LeftToRight(bun, bun, bun)
            .WriteImage(Path.Combine(WorkingDirectory, "LeftToRightRGB"));
        }
        private static List <InvoiceAttachment> ConvertAttachments(string filePath, string folderPath)
        {
            var extension        = Path.GetExtension(filePath);
            var attachmentImages = new List <InvoiceAttachment>();

            switch (extension.ToLower())
            {
            case @".msg":
                attachmentImages = ImageFunctions.ConvertMsgToPng(filePath, folderPath);
                break;

            case @".pdf":
                attachmentImages = ImageFunctions.ConvertPdfToPng(filePath, folderPath);
                break;

            case @".tif":
            case @".tiff":
            case @".jpg":
            case @".jpeg":
            case @".png":
            case @".bmp":
                attachmentImages = ImageFunctions.ConvertToPng(filePath, folderPath);
                break;
            }
            return(attachmentImages);
        }
Example #5
0
 public ActionResult PredictMnist(string imageRaw)
 {
     try
     {
         var image = ImageFunctions.Base64ToImage(imageRaw);
         image = ImageFunctions.Resize(image, 28, 28);
         var    directory       = AppDomain.CurrentDomain.BaseDirectory;
         var    path            = Path.Combine(directory, "CNNModel");
         string outputModelPath = Path.Combine(path, "model.mod");
         var    label           = CNNManager.TestItems(outputModelPath, image);
         return(new JsonResult()
         {
             Data = new { Status = "Success", Message = "Complete", Label = label },
             JsonRequestBehavior = JsonRequestBehavior.DenyGet
         });
     }
     catch (Exception ex)
     {
         return(new JsonResult()
         {
             Data = new { Status = "Failure", Message = "Error making prediction." },
             JsonRequestBehavior = JsonRequestBehavior.DenyGet
         });
     }
 }
        public void TestTopToBottomRGB()
        {
            var bun = ImageFactory.GenerateRgb(BunnyPath);

            ImageFunctions.TopToBottom(bun, bun, bun)
            .WriteImage(Path.Combine(WorkingDirectory, "TopToBottomRGB"));
        }
Example #7
0
        public static List <UserProfileEmployeeProfile> SetPhotoByEmployeeID(DataTable EmployeeProfileDataTable)
        {
            try
            {
                List <UserProfileEmployeeProfile> EmployeeList = new List <UserProfileEmployeeProfile>();
                foreach (DataRow dr in EmployeeProfileDataTable.Rows)
                {
                    UserProfileEmployeeProfile theEmployeeProfile = new UserProfileEmployeeProfile();
                    theEmployeeProfile.EmployeeID      = int.Parse(dr["EmployeeID"].ToString());
                    theEmployeeProfile.SettingKeyValue = ImageFunctions.ByteToImage((Byte[])(dr["SettingKeyValue"]));

                    //theWebForm.ModuleID = int.Parse(dr["ModuleID"].ToString());
                    //theWebForm.WebFormName = dr["WebFormName"].ToString();
                    //theWebForm.WebFormURL = dr["WebFormURL"].ToString();
                    //theWebForm.WebFormImageURL = dr["WebFormImageURL"].ToString();
                    //theWebForm.ModuleName = dr["ModuleName"].ToString();
                    //theWebForm.CompanyCode = dr["CompanyCode"].ToString();
                    //theWebForm.IsActive = bool.Parse(dr["IsActive"].ToString());
                    //theWebForm.IsDeleted = bool.Parse(dr["IsDeleted"].ToString());
                    //theWebForm.WebFormDescription = dr["WebFormDescription"].ToString();

                    EmployeeList.Add(theEmployeeProfile);
                }
                return(EmployeeList);
            }

            catch (Exception ex)
            {
                throw (new Exception(MethodBase.GetCurrentMethod().DeclaringType.ToString() + "." + (new System.Diagnostics.StackFrame()).GetMethod().Name, ex));
            }
        }
Example #8
0
        private void InitTrayIcon()
        {
            // Create Tray icon
            //AppData.notifyIcon = new TaskbarIcon();
            AppData.notifyIcon = (TaskbarIcon)FindResource("NotifyIcon");
            if (AppData.notifyIcon == null)
            {
                throw new ArgumentNullException("Resource: NotifyIcon");
            }

            AppData.notifyIcon.TrayRightMouseUp += AppData.MenuOpen;
            AppData.notifyIcon.ToolTipText       = StringsFunctions.ResourceString("resVersion");

            // Icons.
            AppData.imageSources[0] = ImageFunctions.GetIconFromResource("init");
            AppData.imageSources[1] = ImageFunctions.GetIconFromResource("enabled");
            AppData.imageSources[2] = ImageFunctions.GetIconFromResource("disabled");
            AppData.imageSources[3] = ImageFunctions.GetIconFromResource("notset");

            // Set INIT icon
            this.Dispatcher.Invoke(() =>
            {
                AppData.notifyIcon.IconSource = AppData.imageSources[0];
            });

            // Show Welcome Note
            AppData.notifyIcon.ShowBalloonTip(
                StringsFunctions.ResourceString("resWelcome"),
                StringsFunctions.ResourceString("resVersion"),
                BalloonIcon.Info
                );

            // AdHock
            new RegistryMonitorCore().LoadDataFromRegistry(false);
        }
Example #9
0
 internal ImageStats(Bitmap vBMP)
 {
     Brightness    = ImageFunctions.GetAverageBrightness(vBMP);
     AverageColour = ImageFunctions.GetAverageColor(vBMP);
     Aspect        = vBMP.Width / vBMP.Height;
     Width         = vBMP.Width;
     Height        = vBMP.Height;
 }
Example #10
0
        public void AddSubtractRgb()
        {
            IImage <RGB> bunny    = ImageFactory.GenerateRgb(BunnyPath);
            IImage <RGB> added    = ImageFunctions.Add(bunny, bunny);
            IImage <RGB> original = ImageFunctions.Subtract(added, bunny);

            // bunny + bunny - bunny == bunny
            Assert.IsTrue(ImagesEqual(bunny, original));
        }
Example #11
0
        public async Task <ImageLabel> GetOneImageRandom(CloudBlobContainer container)
        {
            ImageLabel image = await _imageStore.GetARandomImage();

            image.Container_url = ImageFunctions.GetImage(container, image.FileName);

            image.Bbox = await _imageStore.GetBBoxForOneImage(image.Id);

            return(image);
        }
        private void setWallpaperPreview()
        {
            Bitmap preview;

            preview = (Bitmap)ImageFunctions.LoadImage(fullPathCurrent, Setting.getSettingsFullPath(Properties.Settings.Default.Portable));
            if (preview != null)
            {
                this.pbPreviewImage.Image.Dispose();
                this.pbPreviewImage.Image = (Image)preview.Clone();
                preview.Dispose();
            }
        }
Example #13
0
        /// <summary>
        /// Event Handler for btnTakePhotoWithCamera.Click event.
        /// Get Webcam Image. Set pictureBoxPhoto Image and Tag to bytearray of Image.
        /// </summary>
        /// <param name="sender">Sender of event</param>
        /// <param name="e">Event arguments</param>
        private void BtnTakePhotoWithCamera_Click(object sender, EventArgs e)
        {
            Bitmap webcamBitmap = ImageFunctions.GetBitmapFromWebcam();

            // if null, there was a problem getting webcamBitmap
            // if not null, set pictureBoxPhoto Image and Tag
            if (webcamBitmap != null)
            {
                pictureBoxPhoto.Image = webcamBitmap;
                pictureBoxPhoto.Tag   = ImageFunctions.GetByteArrayFromBitMapImage(webcamBitmap);
            }
        }
        private static List <InvoiceAttachment> ProcessAttachments(int id, List <InvoiceAttachment> attachments)
        {
            var folderPath = ImageFunctions.CreateFolder(id);

            //list to store new file names
            var attachmentImages = new List <InvoiceAttachment>();

            foreach (var remoteFilePath in attachments)
            {
                attachmentImages.AddRange(ConvertAttachments(remoteFilePath.DocumentPath, folderPath));
            }
            return(attachmentImages);
        }
Example #15
0
        // CTOR for editing an existing group
        public frmGroup(frmClient client, Category category)
        {
            // Setting form profile
            System.Runtime.ProfileOptimization.StartProfile("frmGroup.Profile");

            InitializeComponent();

            // Setting properties
            Category = category;
            Client   = client;
            IsNew    = false;

            // Setting control values from loaded group
            this.Text                       = "Edit group";
            txtGroupName.Text               = Regex.Replace(Category.Name, @"(_)+", " ");
            pnlAllowOpenAll.Checked         = category.allowOpenAll;
            cmdAddGroupIcon.BackgroundImage = Category.LoadIconImage();
            lblNum.Text                     = Category.Width.ToString();
            lblOpacity.Text                 = Category.Opacity.ToString();

            if (Category.ColorString == null)  // Handles if groups is created from earlier releas w/o ColorString property
            {
                Category.ColorString = System.Drawing.ColorTranslator.ToHtml(Color.FromArgb(31, 31, 31));
            }

            Color categoryColor = ImageFunctions.FromString(Category.ColorString);

            if (categoryColor == Color.FromArgb(31, 31, 31))
            {
                radioDark.Checked = true;
            }
            else if (categoryColor == Color.FromArgb(230, 230, 230))
            {
                radioLight.Checked = true;
            }
            else
            {
                radioCustom.Checked      = true;
                pnlCustomColor.Visible   = true;
                pnlCustomColor.BackColor = categoryColor;
            }

            // Loading existing shortcutpanels
            int position = 0;

            foreach (ProgramShortcut psc in category.ShortcutList)
            {
                LoadShortcut(psc, position);
                position++;
            }
        }
        public void ApplyFiler()
        {
            var filter = Filters.MakeFilter(512, 512, Filters.Gaussian(256.0));

            IImage <Complex> bun = ImageFactory
                                   .Generate(ImageTests.BunnyPath)
                                   .Crop(0, 0, 512, 512)
                                   .Fft();

            ImageFunctions
            .Multiply(bun, filter.ToComplexImage())
            .InverseFft()
            .WriteImage(WorkingDirectory, "Apply Filter");
        }
Example #17
0
        private Image constructIcons()
        {
            List <Image> iconImages = new List <Image>();

            if (pnlShortcuts.Controls.Count >= 4)
            {
                for (int i = 0; i < 4; i++)
                {
                    iconImages.Insert(0, ((ucProgramShortcut)pnlShortcuts.Controls[i]).logo);
                }
            }
            else
            {
                foreach (ucProgramShortcut controlItem in pnlShortcuts.Controls)
                {
                    iconImages.Insert(0, controlItem.logo);
                }
            }

            var image = new Bitmap(256, 256, PixelFormat.Format32bppArgb);

            using (var g = Graphics.FromImage(image))
            {
                g.Clear(Color.Transparent);

                PointF drawLocation = new PointF(0, 0);
                int    counter      = 0;

                foreach (Image iconImage in iconImages)
                {
                    if (counter == 2)
                    {
                        counter         = 0;
                        drawLocation.Y += 128;
                        drawLocation.X  = 0;
                    }

                    g.DrawImage(ImageFunctions.ResizeImage(iconImage, 128, 128), drawLocation);

                    drawLocation.X += 128;
                    counter        += 1;
                }
                g.Dispose();
            }
            return(image);
        }
Example #18
0
        public void CreateConfig(Image groupImage)
        {
            string path     = @"config\" + this.Name;
            string filePath = path + @"\" + this.Name + "Group.exe";

            //
            // Directory and .exe
            //
            System.IO.Directory.CreateDirectory(@path);
            System.IO.File.Copy(@"config\config.exe", @filePath);
            //
            // XML config
            //
            System.Xml.Serialization.XmlSerializer writer =
                new System.Xml.Serialization.XmlSerializer(typeof(Category));

            using (FileStream file = System.IO.File.Create(@path + @"\ObjectData.xml"))
                writer.Serialize(file, this);
            //
            // Create .ico
            //

            Image img = ImageFunctions.ResizeImage(groupImage, 1024, 1024); // Resize img if too big

            img.Save(path + @"\GroupImage.png");

            using (FileStream fs = new FileStream(path + @"\GroupIcon.ico", FileMode.Create))
                ImageFunctions.IconFromImage(img).Save(fs);  // saving as icon
                                                             //
                                                             // Create .lnk shortcut
                                                             //
            var wsh = new IWshShell_Class();

            IWshRuntimeLibrary.IWshShortcut shortcut = wsh.CreateShortcut(
                path + "\\" + this.Name + ".lnk") as IWshRuntimeLibrary.IWshShortcut;
            shortcut.Arguments        = "";
            shortcut.TargetPath       = Path.GetFullPath(@filePath);
            shortcut.WindowStyle      = 1;
            shortcut.Description      = path + " shortcut";
            shortcut.WorkingDirectory = Path.GetFullPath(@path);
            shortcut.IconLocation     = Path.GetFullPath(path + @"\GroupIcon.ico");
            shortcut.Save();
            System.IO.File.Move(@path + "\\" + this.Name + ".lnk",
                                Path.GetFullPath(@"Shortcuts\" + this.Name + ".lnk")); // moving .lnk to correct directory
        }
Example #19
0
        public async Task AddImage_SavesAndReturnsResponse()
        {
            // Arrange

            TestLambdaContext       context;
            APIGatewayProxyRequest  request;
            APIGatewayProxyResponse response;

            var imageFunctions = new ImageFunctions(_ddbClient, _s3Client, _tableName, _bucketName);

            var testImageRequest = new AddImageRequestModel
            {
                ImageType   = "phone",
                FileName    = $"my-image.png",
                ContentType = "image/png"
            };

            request = new APIGatewayProxyRequest
            {
                Body = JsonSerializer.Serialize(testImageRequest)
            };

            context = new TestLambdaContext();

            // Act
            response = await imageFunctions.AddImageAsync(request, context);

            // Assert
            Assert.Equal(201, response.StatusCode);
            Assert.NotEmpty(response.Body);

            var testResponse = JsonSerializer.Deserialize <AddImageResponseModel>(response.Body);

            Assert.NotNull(testResponse);

            Assert.NotEmpty(testResponse.Id);
            Assert.NotEmpty(testResponse.Key);
            Assert.NotEmpty(testResponse.UploadUrl);

            // Clean up after the test
            // Note: We don't need to create a bucket to test getting a pre-signed URL
            var deleteTableResponse = await _ddbClient.DeleteTableAsync(_tableName);

            Console.WriteLine($"Delete DDB table response: {deleteTableResponse.HttpStatusCode}");
        }
        // editing an existing group
        public GroupEditor(GroupOverview groupOverview, Border tab, Group group)
        {
            // Setting from profile
            ProfileOptimization.StartProfile("GroupEditor.Profile");

            InitializeComponent();

            // Setting properties
            GroupOverview = groupOverview;
            Tab           = tab;
            Group         = group;
            IsNew         = false;

            // DropHandler
            DataContext = new ViewModel(this);

            // Setting control values from loaded group
            InpGroupName.Text   = Group.Name;
            ImgGroupIcon.Source = Group.LoadGroupImage();
            LblWidth.Content    = Group.Width.ToString();
            Color groupBackgroundColor = ImageFunctions.FromString(Group.BackgroundColor);

            ClrCustomColor.SelectedColor = groupBackgroundColor;
            SldOpacity.Value             = Group.Opacity;
            if (Group.SelectedBackgroundOption == BackgroundOption.Dark)
            {
                RadDark.IsChecked = true;
            }
            else if (Group.SelectedBackgroundOption == BackgroundOption.WindowsTheme)
            {
                RadWindowsTheme.IsChecked = true;
            }
            else if (Group.SelectedBackgroundOption == BackgroundOption.WindowsAccentColor)
            {
                RadWindowsAccentColor.IsChecked = true;
            }
            else if (Group.SelectedBackgroundOption == BackgroundOption.Custom)
            {
                RadCustom.IsChecked      = true;
                ClrCustomColor.IsEnabled = true;
            }
            LoadShortcuts();
        }
        public int UpdateFieldForceProfile(int theFieldForceId)
        {
            byte[] data = null;
            if (lbl_FileName.Text.Trim().Length > 0)
            {
                data = File.ReadAllBytes(lbl_FileName.Text);
            }
            int ProcReturnValue = 0;

            if (data != null)
            {
                UserProfileFieldForceProfile TheFieldForceProfile = new UserProfileFieldForceProfile();
                TheFieldForceProfile.FieldForceID    = Connection.LoggedOnUser.UserReferenceID;
                TheFieldForceProfile.SettingKeyValue = ImageFunctions.ByteToImage(data);
                ProcReturnValue = UserProfileFieldForceProfileManagement.GetInstance.UpdateUserProfileFieldForceProfile(TheFieldForceProfile);
            }

            return(ProcReturnValue);
        }
        public CtlGroup(GroupOverview groupOverview, Group group, MainWindow mainWindow)
        {
            InitializeComponent();
            GroupOverview = groupOverview;
            Group         = group;
            MainWindow    = mainWindow;

            LblBackgroundColor.Background = new SolidColorBrush(ImageFunctions.FromString(Group.BackgroundColor));
            ImgGroupIcon.Source           = Group.LoadGroupImage();
            LblGroupname.Text             = Group.Name;

            if (!Directory.Exists($@"{Paths.GroupsPath}\{Group.Name}\Icons\"))
            {
                Group.CacheImages();
            }

            foreach (Shortcut shortcut in Group.ShortcutList)
            {
                CreateShortcut(shortcut);
            }
        }
Example #23
0
 /// <summary>
 /// Constructor for frmAddEditEmployee.
 /// Set EmployeeToAddOrEdit and all fields.
 /// </summary>
 /// <param name="employeeIn">The employee to Add or Edit.</param>
 public frmAddEditEmployee(Employee employeeIn)
 {
     try
     {
         InitializeComponent();
         // set EmployeeToAddOrEdit property
         this.EmployeeToAddOrEdit = employeeIn;
         // set all text fields
         txtFirstName.Text     = this.EmployeeToAddOrEdit.FirstName;
         txtMiddleName.Text    = this.EmployeeToAddOrEdit.MiddleName;
         txtLastName.Text      = this.EmployeeToAddOrEdit.LastName;
         txtJobTitle.Text      = this.EmployeeToAddOrEdit.JobTitle;
         txtPhone.Text         = this.EmployeeToAddOrEdit.Phone;
         txtEmail.Text         = this.EmployeeToAddOrEdit.Email;
         pictureBoxPhoto.Image = ImageFunctions.GetImageFromByteArray(this.EmployeeToAddOrEdit.Photo);
         // store the byte array of the photo in the tag of pictureBoxPhoto
         pictureBoxPhoto.Tag = this.EmployeeToAddOrEdit.Photo;
     }
     catch (Exception ex)
     {
         LogFunctions.LogException(ex);
     }
 }
Example #24
0
        //------------------------------------------------------------------------------------
        // CTOR AND LOAD
        //
        public frmMain(string passedDirectory, int cursorPosX, int cursorPosY)
        {
            InitializeComponent();

            System.Runtime.ProfileOptimization.StartProfile("frmMain.Profile");
            mouseClick      = new Point(cursorPosX, cursorPosY); // Consstruct point p based on passed x y mouse values
            passedDirec     = passedDirectory;
            FormBorderStyle = FormBorderStyle.None;

            using (MemoryStream ms = new MemoryStream(System.IO.File.ReadAllBytes(MainPath.path + "\\config\\" + passedDirec + "\\GroupIcon.ico")))
                this.Icon = new Icon(ms);

            if (Directory.Exists(@MainPath.path + @"\config\" + passedDirec))
            {
                ControlList = new List <ucShortcut>();

                this.SetStyle(ControlStyles.SupportsTransparentBackColor, true);
                ThisCategory   = new Category($"config\\{passedDirec}");
                this.BackColor = ImageFunctions.FromString(ThisCategory.ColorString);
                Opacity        = (1 - (ThisCategory.Opacity / 100));

                if (BackColor.R * 0.2126 + BackColor.G * 0.7152 + BackColor.B * 0.0722 > 255 / 2)
                {
                    //if backcolor is light, set hover color as darker
                    HoverColor = Color.FromArgb(BackColor.A, (BackColor.R - 50), (BackColor.G - 50), (BackColor.B - 50));
                }
                else
                {
                    //light backcolor is light, set hover color as darker
                    HoverColor = Color.FromArgb(BackColor.A, (BackColor.R + 50), (BackColor.G + 50), (BackColor.B + 50));
                }
            }
            else
            {
                Application.Exit();
            }
        }
Example #25
0
        protected void btnPostAd_ServerClick(object sender, EventArgs e)
        {
            Boolean postad = true;

            //string adultResponse = "NOINFO";
            //string spoofResponse = "NOINFO";


            if (txtGameTitle.Value.Equals("") || txtPrice.Value == null || PlatformDrop.Items[PlatformDrop.SelectedIndex].Text.Equals("Platform") || txtGameDesc.Value.Equals(""))
            {
                InvlaidPostAd.InnerHtml = "<p>Please fill in all the fields</p>";
                postad = false;
                return;
            }
            else
            {
                try
                {
                    int temp = Int32.Parse(txtPrice.Value);
                }
                catch (FormatException ex)
                {
                    txtPrice.Value          = "";
                    InvlaidPostAd.InnerHtml = "<p>Please fill in a price</p>";
                    postad = false;
                    return;
                }
                catch (OverflowException ex)
                {
                    txtPrice.Value          = "";
                    InvlaidPostAd.InnerHtml = "<p>It seems the price you entered is two high.</p>";
                    postad = false;
                    return;
                }
            }

            if (pic1files.PostedFile.ContentLength == 0 && pic2files.PostedFile.ContentLength == 0 && pic3files.PostedFile.ContentLength == 0)
            {
                InvlaidPostAd.InnerHtml = "<p>Please add at least one picture</p>";
                postad = false;
                return;
            }



            if (postad)
            {
                int negChecked       = 0;
                int ShowPhoneChecked = 0;
                if (NegotiableCheck.Checked)
                {
                    negChecked = 1;
                }
                if (ShowPhone.Checked)
                {
                    ShowPhoneChecked = 1;
                }



                //--------------------------------------------------------------------IMAGES

                //create service
                //var visionCredentails = CreateCredentials("C:\\Users\\James McGuire\\Desktop\\IMF third year project-46cd5c28569b.json");
                //var visionService = CreateService("twoGames", visionCredentails);


                //**************Check files exist********************
                string base64String1 = "";
                string base64String2 = "";
                string base64String3 = "";


                //----------------Check if there is PIC 1
                if (pic1files.PostedFile.ContentLength != 0)
                {
                    base64String1 = ImageFunctions.validateImage(new BinaryReader(pic1files.PostedFile.InputStream).ReadBytes(pic1files.PostedFile.ContentLength));
                    if (base64String1.Equals("NOPIC"))
                    {
                        InvlaidPostAd.InnerHtml = "<p>Picture 1 is an invalid image. Please attach only the pictures you took of your game.</p>";
                        return;
                    }
                }
                else
                {
                    base64String1 = "NOPIC";
                }


                //Check if there is a file 2
                if (pic2files.PostedFile.ContentLength != 0)
                {
                    base64String2 = ImageFunctions.validateImage(new BinaryReader(pic2files.PostedFile.InputStream).ReadBytes(pic2files.PostedFile.ContentLength));
                    if (base64String2.Equals("NOPIC"))
                    {
                        InvlaidPostAd.InnerHtml = "<p>Picture 2 is an invalid image. Please attach only the pictures you took of your game.</p>";
                        return;
                    }

                    /*
                     * //convert pic 2 to byte[]
                     * byte[] pic2Data = null;
                     * using (var binaryReader = new BinaryReader(pic2files.PostedFile.InputStream))
                     * {
                     *  pic2Data = binaryReader.ReadBytes(pic2files.PostedFile.ContentLength);
                     *  byte[] temp = pic2Data;
                     *
                     *  if (IsValidImage(pic2Data) && checkVision(pic2Data))
                     *  {
                     *      pic2Data = CompressImage(temp);
                     *      base64String2 = Convert.ToBase64String(pic2Data);
                     *  }
                     *  else
                     *  {
                     *      InvlaidPostAd.InnerHtml = "<p>Picture 2 is invalid</p>";
                     *      return;
                     *  }
                     * }*/
                }
                else
                {
                    base64String2 = "NOPIC";
                }


                //Check if there is a file 3
                if (pic3files.PostedFile.ContentLength != 0)
                {
                    base64String3 = ImageFunctions.validateImage(new BinaryReader(pic3files.PostedFile.InputStream).ReadBytes(pic3files.PostedFile.ContentLength));
                    if (base64String3.Equals("NOPIC"))
                    {
                        InvlaidPostAd.InnerHtml = "<p>Picture 3 is an invalid image. Please attach only the pictures you took of your game.</p>";
                        return;
                    }

                    /*
                     * //convert pic 3 to byte[]
                     * byte[] pic3Data = null;
                     * using (var binaryReader = new BinaryReader(pic3files.PostedFile.InputStream))
                     * {
                     *  pic3Data = binaryReader.ReadBytes(pic3files.PostedFile.ContentLength);
                     *  byte[] temp = pic3Data;
                     *
                     *  if (IsValidImage(pic3Data) && checkVision(pic3Data))
                     *  {
                     *      pic3Data = CompressImage(temp);
                     *      base64String3 = Convert.ToBase64String(pic3Data);
                     *  }
                     *  else
                     *  {
                     *      InvlaidPostAd.InnerHtml = "<p>Picture 3 is invalid</p>";
                     *      return;
                     *  }
                     * }*/
                }
                else
                {
                    base64String3 = "NOPIC";
                }



                //byte[][] sendPics = new byte[3][];
                // sendPics[0] = pic1Data;
                // sendPics[1] = pic2Data;
                //sendPics[2] = pic3Data;

                //--------------------------------------------------------------------------

                UserData user = (UserData)Session["User"];
                AdService.AdCRUDClient service = new AdService.AdCRUDClient();
                service.Open();


                //Inserting ad
                int success = 0;
                success = service.insertAd(txtGameTitle.Value, PlatformDrop.Items[PlatformDrop.SelectedIndex].Text, DateTime.Today, txtGameDesc.Value, txtLocation.Value, Convert.ToDouble(txtPrice.Value), negChecked, ShowPhoneChecked, base64String1, base64String2, base64String3, user.isPrem(), user.getID());
                service.Close();

                //string Title, string Platform, DateTime CreatedDate, string Description, string Location, Double Price, int Negotiable, int ShowNumber, String Pic1Path, String Pic2Path, String Pic3Path, int PremiumAd, int UserID
                if (success == 1)
                {
                    //remember variable in code bellow
                    postAdDiv.InnerHtml  = "<div class='col s12 m6 push-m3'>";
                    postAdDiv.InnerHtml += "<div class='card white'>";
                    postAdDiv.InnerHtml += "<div class='card-content Black-text'>";
                    postAdDiv.InnerHtml += "<span class='card-title bold'>Ad Created Successfully</span>";
                    postAdDiv.InnerHtml += "<p>You have successfully created your ad. To view your ad, proceeed to the My Ads page.</p>";

                    postAdDiv.InnerHtml += "</div>";
                    postAdDiv.InnerHtml += "<div class='card-action'> ";
                    postAdDiv.InnerHtml += "<a href='Index.aspx' class='btn waves-effect waves-light'>Continue</a> ";
                    postAdDiv.InnerHtml += "<a href='MyAds.aspx' class='btn waves-effect waves-light orange lighten-2'>My Ads</a> ";
                    postAdDiv.InnerHtml += "</div>";
                    postAdDiv.InnerHtml += "</div>";
                    postAdDiv.InnerHtml += "</div>";


                    //Object[] temp = service.getAdDetails("25");
                    //byte[][] temp = service.getPictures(1);
                    //string base64String1 = Convert.ToBase64String(temp[0], 0, temp[0].Length);
                    //temp1.Attributes["src"] = "data:image/jpeg;base64," + temp[9];
                    //string base64String2 = Convert.ToBase64String(temp[1], 0, temp[1].Length);
                    //temp2.Attributes["src"] = "data:image/jpeg;base64," + temp[10];
                    //string base64String3 = Convert.ToBase64String(temp[2], 0, temp[2].Length);
                    //temp3.Attributes["src"] = "data:image/jpeg;base64," + temp[11];
                }
                else
                {
                    postAdDiv.InnerHtml  = "<div class='col s12 m6 push-m3'>";
                    postAdDiv.InnerHtml += "<div class='card white'>";
                    postAdDiv.InnerHtml += "<div class='card-content Black-text'>";
                    postAdDiv.InnerHtml += "<span class='card-title bold'>Oh No...An Error Occured</span>";
                    postAdDiv.InnerHtml += "<p>Unfortunately we were unable to create your ad. Please try again or come back later.<br/>To view your current ads, proceeed to the My Ads page.</p>";

                    postAdDiv.InnerHtml += "</div>";
                    postAdDiv.InnerHtml += "<div class='card-action'> ";
                    postAdDiv.InnerHtml += "<a href='Index.aspx' class='btn waves-effect waves-light'>Continue</a> ";
                    postAdDiv.InnerHtml += "<a href='MyAds.aspx' runat='server' class='btn waves-effect waves-light'>My Ads</a> ";
                    postAdDiv.InnerHtml += "</div>";
                    postAdDiv.InnerHtml += "</div>";
                    postAdDiv.InnerHtml += "</div>";
                }
            }
        }
Example #26
0
        protected void btnUpdateAd_ServerClick(object sender, EventArgs e)
        {
            Boolean postad = true;



            if (txtGameTile.Value.Equals("") || txtGamePrice.Value == null || drpGamePlatform.Items[drpGamePlatform.SelectedIndex].Text.Equals("Platform") || txtGameDescription.Value.Equals(""))
            {
                InvlaidPostAd.InnerHtml = "<p>Please fill in all the fields</p>";
                postad = false;
            }
            else
            {
                try
                {
                    int temp = Int32.Parse(txtGamePrice.Value);
                }
                catch (FormatException ex)
                {
                    txtGamePrice.Value      = "";
                    InvlaidPostAd.InnerHtml = "<p>Please fill in a price</p>";
                    postad = false;
                }
            }



            if (postad)
            {
                int negChecked       = 0;
                int ShowPhoneChecked = 0;
                if (NegotiableCheck.Checked)
                {
                    negChecked = 1;
                }
                if (ShowPhone.Checked)
                {
                    ShowPhoneChecked = 1;
                }


                //**************Check files exist********************
                //string base64String1 = "";
                //string base64String2 = "";
                //string base64String3 = "";

                //Check if there is a file 1
                if (pic1files.PostedFile.ContentLength != 0)
                {
                    string base64String1 = ImageFunctions.validateImage(new BinaryReader(pic1files.PostedFile.InputStream).ReadBytes(pic1files.PostedFile.ContentLength));
                    if (base64String1.Equals("NOPIC"))
                    {
                        InvlaidPostAd.InnerHtml = "<p>Picture 1 is an invalid image. Please attach only the pictures you took of your game.</p>";
                        return;
                    }
                    Session["pic1"] = base64String1;

                    /*
                     * //convert pic 1 to byte[]
                     * byte[] pic1Data = null;
                     * using (var binaryReader = new BinaryReader(pic1files.PostedFile.InputStream))
                     * {
                     *  pic1Data = CompressImage(binaryReader.ReadBytes(pic1files.PostedFile.ContentLength));
                     * }
                     *
                     * /*base64String1 this.pic1server Session["pic1"] = Convert.ToBase64String(pic1Data);*/
                }

                /*else
                 *  base64String1 = "NOPIC";*/

                //Check if there is a file 2
                if (pic2files.PostedFile.ContentLength != 0)
                {
                    string base64String2 = ImageFunctions.validateImage(new BinaryReader(pic2files.PostedFile.InputStream).ReadBytes(pic2files.PostedFile.ContentLength));
                    if (base64String2.Equals("NOPIC"))
                    {
                        InvlaidPostAd.InnerHtml = "<p>Picture 2 is an invalid image. Please attach only the pictures you took of your game.</p>";
                        return;
                    }
                    Session["pic2"] = base64String2;

                    /*
                     * //convert pic 2 to byte[]
                     * byte[] pic2Data = null;
                     * using (var binaryReader = new BinaryReader(pic2files.PostedFile.InputStream))
                     * {
                     *  pic2Data = CompressImage(binaryReader.ReadBytes(pic2files.PostedFile.ContentLength));
                     * }
                     * base64String2 this.pic2server Session["pic2"] = Convert.ToBase64String(pic2Data);*/
                }

                /*else
                 *  base64String2 = "NOPIC";*/

                //Check if there is a file 3
                if (pic3files.PostedFile.ContentLength != 0)
                {
                    string base64String3 = ImageFunctions.validateImage(new BinaryReader(pic3files.PostedFile.InputStream).ReadBytes(pic3files.PostedFile.ContentLength));
                    if (base64String3.Equals("NOPIC"))
                    {
                        InvlaidPostAd.InnerHtml = "<p>Picture 3 is an invalid image. Please attach only the pictures you took of your game.</p>";
                        return;
                    }
                    Session["pic3"] = base64String3;

                    /*
                     * //convert pic 3 to byte[]
                     * byte[] pic3Data = null;
                     * using (var binaryReader = new BinaryReader(pic3files.PostedFile.InputStream))
                     * {
                     *  pic3Data = CompressImage(binaryReader.ReadBytes(pic3files.PostedFile.ContentLength));
                     * }
                     * base64String3 this.pic3server
                     * Session["pic3"] = Convert.ToBase64String(pic3Data);*/
                }

                /*else
                 *  base64String3 = "NOPIC";*/



                /*if (base64String1.Equals("NOPIC"))
                 * {
                 *  if (!pic1server.Equals("NOPIC"))
                 *      base64String1 = pic1server;
                 * }
                 * if (base64String2.Equals("NOPIC"))
                 * {
                 *  if (!pic2server.Equals("NOPIC"))
                 *      base64String2 = pic2server;
                 * }
                 * if (base64String3.Equals("NOPIC"))
                 * {
                 *  if (!pic3server.Equals("NOPIC"))
                 *      base64String3 = pic3server;
                 * }*/



                //byte[][] sendPics = new byte[3][];
                // sendPics[0] = pic1Data;
                // sendPics[1] = pic2Data;
                //sendPics[2] = pic3Data;

                //--------------------------------------------------------------------------

                UserData user = (UserData)Session["User"];
                AdService.AdCRUDClient service = new AdService.AdCRUDClient();
                service.Open();

                string adID = Request.QueryString.Get("ad");

                int success = service.updateAd(Convert.ToInt32(adID), txtGameTile.Value, drpGamePlatform.Items[drpGamePlatform.SelectedIndex].Text, txtGameDescription.Value, txtGameLocation.Value, Convert.ToDouble(txtGamePrice.Value), negChecked, ShowPhoneChecked, /*base64String1 this.pic1server*/ (string)Session["pic1"], /*base64String2 this.pic2server*/ (string)Session["pic2"], /*base64String3 this.pic3server*/ (string)Session["pic3"], user.isPrem());

                if (success == 1)
                {
                    editAdDiv.InnerHtml  = "<div class='col s12 m6 push-m3'>";
                    editAdDiv.InnerHtml += "<div class='card white'>";
                    editAdDiv.InnerHtml += "<div class='card-content Black-text'>";
                    editAdDiv.InnerHtml += "<span class='card-title bold'>Ad Updated Successfully</span>";
                    editAdDiv.InnerHtml += "<p>You have successfully Updated your ad. To view your ad, proceeed to the My Ads page.</p>";

                    editAdDiv.InnerHtml += "</div>";
                    editAdDiv.InnerHtml += "<div class='card-action'>";
                    editAdDiv.InnerHtml += "<a href='MyAds.aspx' runat='server' class='btn waves-effect waves-light'>My Ads</a>";
                    editAdDiv.InnerHtml += "</div>";
                    editAdDiv.InnerHtml += "</div>";
                    editAdDiv.InnerHtml += "</div>";
                }
                else
                {
                    editAdDiv.InnerHtml  = "<div class='col s12 m6 push-m3'>";
                    editAdDiv.InnerHtml += "<div class='card white'>";
                    editAdDiv.InnerHtml += "<div class='card-content Black-text'>";
                    editAdDiv.InnerHtml += "<span class='card-title bold'>Ad Update Unsuccessfully</span>";
                    editAdDiv.InnerHtml += "<p>We where unable to update your add. Please try again and if the problem persists pleas contact us <a href='ContactUs.aspx'>here</a>.</p>";

                    editAdDiv.InnerHtml += "</div>";
                    editAdDiv.InnerHtml += "<div class='card-action'>";
                    editAdDiv.InnerHtml += "<a href='MyAds.aspx' runat='server' class='btn waves-effect waves-light'>Continue</a>";
                    editAdDiv.InnerHtml += "</div>";
                    editAdDiv.InnerHtml += "</div>";
                    editAdDiv.InnerHtml += "</div>";
                }
                service.Close();

                Session["pic1"] = null;
                Session["pic2"] = null;
                Session["pic3"] = null;
            }
        }
Example #27
0
        public int GetEmployeePhotoByUserID(UserProfileEmployeeProfile objUserProfileEmployeeProfile)
        {
            try
            {
                int        ReturnValue = 0;
                SqlCommand SqlCmd      = new SqlCommand();
                SqlCmd.CommandType = CommandType.StoredProcedure;
                SqlCmd.Parameters.Add(GetParameter("ReturnValue", SqlDbType.Int, ReturnValue)).Direction = ParameterDirection.Output;
                SqlCmd.Parameters.Add(GetParameter("EmployeeID", SqlDbType.Int, objUserProfileEmployeeProfile.EmployeeID));

                SqlCmd.Parameters.Add(GetParameter("SettingKeyValue", SqlDbType.VarBinary, ImageFunctions.ImageToByte(objUserProfileEmployeeProfile.SettingKeyValue)));

                SqlCmd.CommandText = "pHRM_EmployeePhoto_Select";
                ExecuteStoredProcedure(SqlCmd);

                ReturnValue = int.Parse(SqlCmd.Parameters[0].Value.ToString());
                return(ReturnValue);
            }
            catch (Exception ex)
            {
                throw (new Exception(MethodBase.GetCurrentMethod().DeclaringType.ToString() + "." + (new System.Diagnostics.StackFrame()).GetMethod().Name, ex));
            }
        }
Example #28
0
        public int UpdateUserProfileFieldForceProfile(UserProfileFieldForceProfile objUserProfileFieldForceProfile)
        {
            try
            {
                int        ReturnValue = 0;
                SqlCommand SqlCmd      = new SqlCommand();
                SqlCmd.CommandType = CommandType.StoredProcedure;

                SqlCmd.Parameters.Add(GetParameter("ReturnValue", SqlDbType.Int, ReturnValue)).Direction = ParameterDirection.Output;

                SqlCmd.Parameters.Add(GetParameter("FieldForceID", SqlDbType.Int, objUserProfileFieldForceProfile.FieldForceID));
                //SqlCmd.Parameters.Add(GetParameter("SettingKeyID", SqlDbType.Int, objUserProfileFieldForceProfile.SettingKeyID));
                SqlCmd.Parameters.Add(GetParameter("SettingKeyValue", SqlDbType.VarBinary, ImageFunctions.ImageToByte(objUserProfileFieldForceProfile.SettingKeyValue)));
                SqlCmd.Parameters.Add(GetParameter("SettingKeyDescription", SqlDbType.VarChar, objUserProfileFieldForceProfile.SettingKeyDescription));
                //SqlCmd.Parameters.Add(GetParameter("DateModified", SqlDbType.DateTime, objUserProfileEmployeeProfile.DateModified));
                SqlCmd.Parameters.Add(GetParameter("ModifiedBy", SqlDbType.Int, Micro.Commons.Connection.LoggedOnUser.UserID));
                SqlCmd.CommandText = "pCRM_UserProfile_FieldForceProfiles_Update";
                ExecuteStoredProcedure(SqlCmd);

                ReturnValue = int.Parse(SqlCmd.Parameters[0].Value.ToString());
                return(ReturnValue);
            }
            catch (Exception ex)
            {
                throw (new Exception(MethodBase.GetCurrentMethod().DeclaringType.ToString() + "." + (new System.Diagnostics.StackFrame()).GetMethod().Name, ex));
            }
        }
Example #29
0
    public void SaveImageDataExercise()
    {
        ImageFunctions img_crud = new ImageFunctions();

        List <Images> img_collections = new List <Images>();

        int  selection = 0, counter = 0;
        bool loop_control = true;


        while (loop_control)
        {
            WriteLine("***Bienvenido al gestor de imagenes***\n");

            WriteLine($"Numero de imagenes: {counter}\n");

            WriteLine("1. Agregar ficha");
            WriteLine("2. Ver fichas existentes");
            WriteLine("3. Buscar ficha");
            WriteLine("4. Salir");

            Write("Seleccione una opcion: ");
            selection = int.Parse(ReadLine());

            Clear();

            switch (selection)
            {
            case 1:

                if (counter <= 700)
                {
                    try{
                        img_collections.Add(img_crud.AddImages(img_collections));
                        counter++;
                    }
                    catch {
                        WriteLine("\nHa ingresado un valor incorrecto");
                    }
                }
                else
                {
                    WriteLine("Se ha excedido el limite de imagenes");
                }

                break;

            case 2:

                WriteLine(img_crud.WatchImages(img_collections));
                break;

            case 3:

                WriteLine(img_crud.SearchImages(img_collections));
                break;

            case 4:

                loop_control = false;
                break;

            default:

                WriteLine("No se ha seleccionado un valor correcto");
                break;
            }

            ex_prac04.StopConsole();
            Clear();
        }
    }