Exemple #1
0
        private bool CheckEveSystem()
        {
            if (curImage == null)
            {
                return(false);
            }
            var sp = new System.Drawing.Point();
            var dp = new System.Drawing.Point();

            sp.X     = sLeft;
            sp.Y     = sTop;
            dp.X     = sWidth + sLeft;
            dp.Y     = sHeight + sTop;
            curImage = sc.Capture(sp, dp);
            int currentEveSystemBid = 0;

            curBitmap = (Bitmap)curImage;

            for (int x = 0; x < sWidth; x++)
            {
                for (int y = 0; y < sHeight; y++)
                {
                    var pixel = curBitmap.GetPixel(x, y);
                    if (pixel.R == 0xFF && pixel.B == 0xFF && pixel.G == 0xFF)
                    {
                        currentEveSystemBid++;
                    }
                }
            }
            if (eveSystemBid != currentEveSystemBid)
            {
                eveSystemBid = currentEveSystemBid;
                if (isOutPathValid)
                {
                    SaveEveSystemBMP();  //If EveSystem bitmap white bits are different, we are likely in a new system.
                }
                return(true);
            }
            return(false);
        }
Exemple #2
0
        private void SaveEveSystemBMP()
        {
            if (outFolder.Text == null || outFolder.Text.Length < 2)
            {
                return;
            }
            sHeight = (int)gcwSystem.Height;
            sWidth  = (int)gcwSystem.Width;
            sTop    = (int)gcwSystem.Top;
            sLeft   = (int)gcwSystem.Left;
            Properties.Settings.Default.sLeft   = sLeft;
            Properties.Settings.Default.sTop    = sTop;
            Properties.Settings.Default.sWidth  = sWidth;
            Properties.Settings.Default.sHeight = sHeight;
            Properties.Settings.Default.Save();
            var sp = new System.Drawing.Point(sLeft, sTop);
            var dp = new System.Drawing.Point(sLeft + sWidth, sTop + sHeight);

            curImage = sc.Capture(sp, dp);

            curBitmap = (Bitmap)curImage;
            Bitmap resized = new Bitmap(curBitmap, new System.Drawing.Size(curBitmap.Width * 2, curBitmap.Height * 2));
            string fname   = outFolder.Text + "\\system.bmp";

            if (isOutPathValid)
            {
                resized.Save(fname);
            }
            resized.Dispose();
            if (gcwShowing)
            {
                gcwLocal.Hide();
                gcwSystem.Hide();
            }
            if (File.Exists(outFolder.Text + "\\system.txt"))
            {
                File.Delete(outFolder.Text + "\\system.txt");
            }
        }
        public static void SetImage(Image control, System.Drawing.Image image)
        {
            Func <System.Drawing.Image, ImageSource> convert = delegate(System.Drawing.Image s)
            {
                using (var memory = new MemoryStream())
                {
                    s.Save(memory, System.Drawing.Imaging.ImageFormat.Bmp);
                    memory.Position = 0;
                    var bitmapimage = new BitmapImage();
                    bitmapimage.BeginInit();
                    bitmapimage.StreamSource = memory;
                    bitmapimage.CacheOption  = BitmapCacheOption.OnLoad;
                    bitmapimage.EndInit();

                    var toReturn = bitmapimage;
                    return(toReturn);
                }
            };

            Application.Current.Dispatcher.Invoke(
                DispatcherPriority.Normal,
                new Action(() => control.Source = convert(image)));
        }
Exemple #4
0
        public static Bitmap ResizeImage(System.Drawing.Image image, int width, int height)
        {
            var destRect  = new Rectangle(0, 0, width, height);
            var destImage = new Bitmap(width, height);

            destImage.SetResolution(image.HorizontalResolution, image.VerticalResolution);

            using (var graphics = Graphics.FromImage(destImage))
            {
                graphics.CompositingMode    = CompositingMode.SourceCopy;
                graphics.CompositingQuality = CompositingQuality.HighQuality;
                graphics.InterpolationMode  = InterpolationMode.HighQualityBicubic;
                graphics.SmoothingMode      = SmoothingMode.HighQuality;
                graphics.PixelOffsetMode    = PixelOffsetMode.HighQuality;

                using (var imageAttr = new ImageAttributes())
                {
                    imageAttr.SetWrapMode(WrapMode.TileFlipXY);
                    graphics.DrawImage(image, destRect, 0, 0, image.Width, image.Height, GraphicsUnit.Pixel, imageAttr);
                }
            }
            //destImage
            return(destImage);
        }
Exemple #5
0
        private void Capturando(object sender, NewFrameEventArgs eventArgs)
        {
            try
            {
                System.Drawing.Image img = (Bitmap)eventArgs.Frame.Clone();

                MemoryStream ms = new MemoryStream();
                img.Save(ms, ImageFormat.Bmp);
                ms.Seek(0, SeekOrigin.Begin);
                BitmapImage bi = new BitmapImage();
                bi.BeginInit();
                bi.StreamSource = ms;
                bi.EndInit();

                bi.Freeze();
                Dispatcher.BeginInvoke(new ThreadStart(delegate
                {
                    img1.Source = bi;
                }));
            }
            catch (Exception ex)
            {
            }
        }
        public GetInput(GetInputFromUser getInputFromUser)
        {
            InitializeComponent();

            GetInputFromUser = getInputFromUser;

            Timer timeOutTimer = new Timer();

            timeOutTimer.Interval = 100;
            timeOutTimer.Elapsed += delegate(object sender, ElapsedEventArgs args)
            {
                timeOutTimer.Stop();
                bool startAgain = true;
                if (CefBrowserControl.Timeout.ShouldBreakDueTimeout(((BaseObject)getInputFromUser)))
                {
                    try
                    {
                        //this.BeginInvoke((MethodInvoker)delegate ()
                        //{
                        Dispatcher.BeginInvoke(new Action(delegate
                        {
                            timer.Stop();
                            Close();
                        }));


                        //});
                        startAgain = false;
                    }
                    catch (Exception)
                    {
                        startAgain = false;
                    }
                }
                if (startAgain)
                {
                    timeOutTimer.Start();
                }
            };
            timeOutTimer.Start();

            StackPanelInsecureObjects.Children.Clear();

            foreach (var displayObject in GetInputFromUser.InsecureDisplayObjects)
            {
                if (displayObject is CefBrowserControl.Resources.InsecureText)
                {
                    CefBrowserControl.Resources.InsecureText text = (InsecureText)displayObject;

                    //<TextBox Text="asdfasd&#xA;asdfasdf&#xA;dasdfasdf&#xA;asdsadfasdf&#xD;&#xA;asdfasd" Width="350" Margin="0,5" IsReadOnly="True" />

                    //ScrollViewer scrollViewer = new ScrollViewer();
                    //scrollViewer.Margin = new Thickness(0, 5, 0, 5);
                    //scrollViewer.HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled;
                    //scrollViewer.VerticalScrollBarVisibility = ScrollBarVisibility.Visible;

                    TextBox textBox = new TextBox();
                    textBox.Text         = GetInputFromUser.TranslatePlaceholderStringToSingleString(text.Value);
                    textBox.Width        = 350;
                    textBox.Height       = 80;
                    textBox.IsReadOnly   = true;
                    textBox.TextWrapping = TextWrapping.Wrap;
                    textBox.VerticalScrollBarVisibility   = ScrollBarVisibility.Visible;
                    textBox.HorizontalScrollBarVisibility = ScrollBarVisibility.Hidden;

                    //scrollViewer.Content = textBox;
                    StackPanelInsecureObjects.Children.Add(textBox);
                }
                else if (displayObject is CefBrowserControl.Resources.InsecureImage)
                {
                    CefBrowserControl.Resources.InsecureImage encodedImage = (InsecureImage)displayObject;

                    //< Image Margin = "0,5" Height = "80" Width = "350" Source = "earth.ico" />

                    string base64String = GetInputFromUser.TranslatePlaceholderStringToSingleString(encodedImage.Base64EncodedImage);
                    System.Drawing.Image imageObject = EncodingEx.Base64.Decoder.DecodeImage(base64String);

                    Image image = new Image();
                    image.Margin = new Thickness(0, 5, 0, 5);
                    image.Width  = 350;
                    image.Height = 80;
                    image.Source = DecodeImageToBitmapImage(base64String);

                    StackPanelInsecureObjects.Children.Add(image);
                }
                else
                {
                    ExceptionHandling.Handling.GetException("Unexpected", new Exception("Element does not exist!"));
                }
            }

            if (GetInputFromUser.InputNeeded.Value)
            {
                //groupBoxInput.Location = new System.Drawing.Point(groupBoxInput.Location.X, _currentY);
                ////groupBoxInput.Width = Width - 2 * HorizontalSpace;
                //_currentY += groupBoxInput.Height + VerticalSpace;
            }
            else
            {
                StackPanelInput.Visibility = Visibility.Hidden;
            }

            //Height = _currentY;

            timer.Interval  = 100;
            timer.AutoReset = false;
            timer.Elapsed  += delegate(object sender, ElapsedEventArgs args)
            {
                timer.Stop();
                try
                {
                    if (!GetInputFromUser.KeepInFront.Value && !alreadyBrougthToFront)
                    {
                        Dispatcher.BeginInvoke(new Action(delegate
                        {
                            Activate();
                            Focus();
                            IntPtr windowHandle = new WindowInteropHelper(this).Handle;
                            //SetForegroundWindow(windowHandle);
                        }));
                        //this.BeginInvoke((MethodInvoker)delegate ()
                        //{

                        //});
                    }
                    if (!GetInputFromUser.KeepInFront.Value)
                    {
                        alreadyBrougthToFront = true;
                    }
                }
                catch (Exception)
                {
                }
                timer.Start();
            };
            timer.Start();

            Show();
        }
        private void SubmitButton_Click(object sender, RoutedEventArgs e)
        {
            string        mylist    = (" ");
            List <string> uriResult = new List <string>();
            int           iterator;
            List <string> boldTexts = new List <string>();

            foreach (Paragraph p in rchTextbox.Document.Blocks)
            {
                foreach (var inline in p.Inlines)
                {
                    if (inline.FontWeight == FontWeights.Bold)
                    {
                        var textRange = new TextRange(inline.ContentStart, inline.ContentEnd);
                        boldTexts.Add(textRange.Text);
                        //MessageBox.Show(textRange.Text);
                        mylist += (textRange.Text + " ");
                    }
                    myWeb.Source = new Uri("https://www.google.com/search?tbm=isch&q=" + titleWord.Text + mylist);

                    string urls = (" ");
                    //create web client
                    WebClient googleImages = new WebClient();
                    //This regex searches for image urls in the html from google
                    Regex googleRegex = new Regex(@"""https://[^""]*""", RegexOptions.Compiled | RegexOptions.IgnoreCase);

                    //get google html for image search
                    string          html          = googleImages.DownloadString("https://www.google.com/search?tbm=isch&q=" + titleWord.Text + mylist);
                    MatchCollection googleMatches = googleRegex.Matches(html);

                    //MessageBox.Show("" + googleMatches.Count);
                    foreach (Match m in googleMatches)
                    {
                        //add the match to the arraylist
                        urls += (m.Value + " ");
                    }

                    string[] imgInfo = urls.Split(' ');

                    foreach (string info in imgInfo.Where((info => !string.IsNullOrEmpty(info))))
                    {
                        //create the image and add it to the List
                        foreach (string s in info.Split(' '))
                        {
                            if (!String.IsNullOrEmpty(s))
                            {
                                uriResult.Add(s);
                            }
                        }
                    }
                    iterator = 1;
                    string bmp         = uriResult.ElementAt(iterator);
                    Image  googleImage = new Image();
                    googleImage.Name   = "image";
                    googleImage.Source = new BitmapImage(new Uri(bmp.Substring(1, bmp.Length - 5)));



                    if (iterator < 7)
                    {
                        iterator++;
                    }
                    ;


                    string bnmp1 = uriResult.ElementAt(1);
                    button1.Content = new Image

                    {
                        Source = new BitmapImage(new Uri(bnmp1.Substring(1, bnmp1.Length - 5)))
                    };

                    string bnmp2 = uriResult.ElementAt(2);
                    button2.Content = new Image
                    {
                        Source = new BitmapImage(new Uri(bnmp2.Substring(1, bnmp2.Length - 5)))
                    };


                    string bnmp3 = uriResult.ElementAt(3);
                    button3.Content = new Image
                    {
                        Source = new BitmapImage(new Uri(bnmp3.Substring(1, bnmp3.Length - 5)))
                    };


                    string bnmp4 = uriResult.ElementAt(4);
                    button4.Content = new Image
                    {
                        Source = new BitmapImage(new Uri(bnmp4.Substring(1, bnmp4.Length - 5)))
                    };


                    string bnmp5 = uriResult.ElementAt(5);
                    button5.Content = new Image
                    {
                        Source = new BitmapImage(new Uri(bnmp5.Substring(1, bnmp5.Length - 5)))
                    };


                    string bnmp6 = uriResult.ElementAt(6);
                    button6.Content = new Image
                    {
                        Source = new BitmapImage(new Uri(bnmp6.Substring(1, bnmp6.Length - 5)))
                    };

                    System.Drawing.Image image = DownloadImageFromUrl(bnmp1.Substring(1, bnmp1.Length - 5));
                    string rootPath            = @"C:/ImagesForPowerPoint/ImagesForPowerPoint/Images/";
                    string fileName            = System.IO.Path.Combine(rootPath, "image1.png");
                    image.Save(fileName);
                    image.Dispose();

                    System.Drawing.Image image2 = DownloadImageFromUrl(bnmp2.Substring(1, bnmp2.Length - 5));
                    string rootPath2            = @"C:/ImagesForPowerPoint/ImagesForPowerPoint/Images/";
                    string fileName2            = System.IO.Path.Combine(rootPath2, "image2.png");
                    image2.Save(fileName2);
                    image2.Dispose();

                    System.Drawing.Image image3 = DownloadImageFromUrl(bnmp3.Substring(1, bnmp3.Length - 5));
                    string rootPath3            = @"C:/ImagesForPowerPoint/ImagesForPowerPoint/Images/";
                    string fileName3            = System.IO.Path.Combine(rootPath3, "image3.png");
                    image3.Save(fileName3);
                    image3.Dispose();

                    System.Drawing.Image image4 = DownloadImageFromUrl(bnmp4.Substring(1, bnmp4.Length - 5));
                    string rootPath4            = @"C:/ImagesForPowerPoint/ImagesForPowerPoint/Images/";
                    string fileName4            = System.IO.Path.Combine(rootPath4, "image4.png");
                    image4.Save(fileName4);
                    image4.Dispose();

                    System.Drawing.Image image5 = DownloadImageFromUrl(bnmp5.Substring(1, bnmp5.Length - 5));
                    string rootPath5            = @"C:/ImagesForPowerPoint/ImagesForPowerPoint/Images/";
                    string fileName5            = System.IO.Path.Combine(rootPath5, "image5.png");
                    image5.Save(fileName5);
                    image5.Dispose();

                    System.Drawing.Image image6 = DownloadImageFromUrl(bnmp6.Substring(1, bnmp6.Length - 5));
                    string rootPath6            = @"C:/ImagesForPowerPoint/ImagesForPowerPoint/Images/";
                    string fileName6            = System.IO.Path.Combine(rootPath6, "image6.png");
                    image6.Save(fileName6);
                    image6.Dispose();
                }
            }
        }