Пример #1
0
 public void populateDefaultCdatItems()
 {
     CDATselect.Items.Add(foscam.Name + " (default)");
     CDATselect.Items.Add(sineoji.Name + " (default)");
     pubDataList.Add(foscam);
     pubDataList.Add(sineoji);
     setCamData = foscam;
     CDATselect.SetItemChecked(0, true);
 }
Пример #2
0
 private void CDATselect_ItemCheck(object sender, ItemCheckEventArgs e)
 {
     for (int ix = 0; ix < CDATselect.Items.Count; ++ix)
     {
         if (ix != e.Index)
         {
             CDATselect.SetItemChecked(ix, false);
         }
     }
     setCamData = pubDataList[e.Index];
 }
Пример #3
0
 public viewer(entryViewerLink enl)
 {
     InitializeComponent();
     this.showing       = enl.showing;
     this.threadCount   = enl.threadCount;
     this.setCamData    = enl.cdat;
     this.imgdir        = enl.imgdir;
     this.outdir        = enl.outdir;
     this.console       = enl.console;
     this.ipTag         = enl.ipTag;
     this.style         = enl.style;
     this.luc           = enl.luc;
     this.normalising   = enl.normaliseImage;
     this.setAR         = enl.setAR;
     this.ipAddrs       = enl.ips;
     this.timestamp     = enl.timestamp;
     this.anonFileNames = enl.anonFileNames;
 }
Пример #4
0
 public void readCamConf()
 {
     if (!Directory.Exists(confDir))
     {
         Directory.CreateDirectory(confDir);
     }
     if (!File.Exists(confFile))
     {
         File.Create(confFile);
     }
     else
     {
         string[] rawConfData = File.ReadAllLines(confFile);
         foreach (string s in rawConfData)
         {
             string[] splitCurrent = s.Split(':');
             camData  cdTemp       = new camData(splitCurrent[1], splitCurrent[0], new NetworkCredential(splitCurrent[2], splitCurrent[3]), false);
             CDATselect.Items.Add(cdTemp.Name);
             pubDataList.Add(cdTemp);
         }
     }
 }
Пример #5
0
        public void mainTestThread(int thrid, List <String> ips, camData cdat, string dir, bool DoIpTag)
        {
            string thridAsText = "[" + thrid + "] ";

            cPrint(Color.Black, thridAsText + "Starting thread");

            List <String> goodIps = new List <String> {
            };
            TimeWebClient wc      = new TimeWebClient();

            wc.Credentials = cdat.Creds;

            foreach (string ip in ips)
            {
                //if the viewer form doesnt exist, exit the thread#
                if (killSwitch)
                {
                    //cPrint(Color.Red, thridAsText + "Close given! Killing myself!");
                    //break;
                }
                if (!this.IsHandleCreated)
                {
                    cPrint(Color.Red, thridAsText + "Handle lost! Killing myself!");
                    break;
                }

                remoteTestcounter++;
                this.Invoke(new MethodInvoker(delegate()
                {
                    BarMain.Value = remoteTestcounter;
                    this.Text     = "Viewer | Progress: " + remoteTestcounter + "/" + ipaCount;
                }));
                try
                {
                    string intIp = ip;

                    if (intIp.EndsWith(":"))
                    {
                        intIp = intIp.Substring(0, intIp.Length - 1);
                    }

                    byte[] dlData = wc.DownloadData("http://" + intIp + cdat.Path);
                    cPrint(Color.DarkGreen, thridAsText + ip + " | 200");

                    Bitmap   bmp;
                    Graphics g;
                    using (var ms = new MemoryStream(dlData))
                    {
                        bmp = new Bitmap(ms);
                    }


                    if (normalising)
                    {
                        Bitmap tmp = new Bitmap(bmp, setAR.width, setAR.height);
                        bmp = new Bitmap(tmp);
                        tmp.Dispose();
                    }

                    g = Graphics.FromImage(bmp);

                    String combinedCredsPT = cdat.Creds.UserName + " : " + cdat.Creds.Password;
                    SizeF  sizeOfIp        = g.MeasureString(intIp, luc);
                    SizeF  sizeOfCreds     = g.MeasureString(combinedCredsPT, luc);
                    int    totalheight     = (int)sizeOfIp.Height + (int)sizeOfCreds.Height;
                    int    largerWidth;
                    if (sizeOfIp.Width > sizeOfCreds.Width)
                    {
                        largerWidth = (int)sizeOfIp.Width;
                    }
                    else
                    {
                        largerWidth = (int)sizeOfCreds.Width;
                    }
                    totalheight += 3;
                    largerWidth += 3;

                    if (DoIpTag)
                    {
                        if (style == ipStyle.fancy || style == ipStyle.basic)
                        {
                            g.DrawImage(gHandle.generateStamp(intIp, combinedCredsPT, luc, bmp.Width, timestamp, style), 2, 2);
                        }
                        else if (style == ipStyle.barTop)
                        {
                            Bitmap   stamp = gHandle.generateStamp(intIp, combinedCredsPT, luc, bmp.Width, timestamp, style);
                            Bitmap   temp  = new Bitmap(bmp.Width, bmp.Height + stamp.Height);
                            Graphics gtemp = Graphics.FromImage(temp);
                            gtemp.DrawImage(stamp, 0, 0);
                            gtemp.DrawImage(bmp, 0, stamp.Height);

                            bmp = new Bitmap(temp);

                            stamp.Dispose();
                            temp.Dispose();
                            gtemp.Dispose();
                            GC.Collect();
                        }
                        else if (style == ipStyle.barBottom)
                        {
                            Bitmap   stamp = gHandle.generateStamp(intIp, combinedCredsPT, luc, bmp.Width, timestamp, style);
                            Bitmap   temp  = new Bitmap(bmp.Width, bmp.Height + stamp.Height);
                            Graphics gtemp = Graphics.FromImage(temp);
                            gtemp.DrawImage(bmp, 0, 0);
                            gtemp.DrawImage(stamp, 0, bmp.Height);

                            bmp = new Bitmap(temp);

                            stamp.Dispose();
                            temp.Dispose();
                            gtemp.Dispose();
                            GC.Collect();
                        }

                        gHandle.tidy();
                    }
                    else
                    {
                        //not using the graphics object causes System.Runtime.InteropServices.ExternalException
                        g.FillRectangle(Brushes.Black, -1, -1, 1, 1);
                    }

                    remoteSaveCounter++;
                    workingIps.Add(ip);
                    int rscLen = remoteSaveCounter.ToString().Length;

                    string ipSafe = ip.Replace(".", "-");
                    ipSafe = ipSafe.Replace(":", "-");

                    Console.WriteLine(bmp.GetType().Name);

                    string saveName = "";

                    if (anonFileNames)
                    {
                        saveName = RandomString(15) + ".jpg";
                    }
                    else
                    {
                        saveName = RandomString(5) + "-" + ipSafe + ".jpg";
                    }

                    if (useOutDir)
                    {
                        File.WriteAllLines(outdir, workingIps);
                    }

                    shiftReg.Insert(0, new shiftItem(bmp.Clone(new Rectangle(0, 0, bmp.Width, bmp.Height), PixelFormat.DontCare), saveName, intIp));
                    mainPB.Image     = shiftReg[0].img;
                    subPBone.Image   = shiftReg[1].img;
                    subPBtwo.Image   = shiftReg[2].img;
                    subPBthree.Image = shiftReg[3].img;
                    subPBfour.Image  = shiftReg[4].img;
                    subPBfive.Image  = shiftReg[5].img;
                    subPBsix.Image   = shiftReg[6].img;

                    Bitmap save = bmp.Clone(new Rectangle(0, 0, bmp.Width, bmp.Height), PixelFormat.DontCare);
                    save.Save(dir + "/" + saveName, ImageFormat.Jpeg);
                    cPrint(Color.DarkGreen, thridAsText + "Wrote " + new FileInfo(dir + "/" + saveName).Length + " bytes to disk");

                    if (shiftReg.Count > 8)
                    {
                        shiftReg.RemoveRange(8, shiftReg.Count - 8);
                    }

                    save.Dispose();
                    bmp.Dispose();
                    g.Dispose();
                    GC.Collect();
                }
                catch (WebException ex)
                {
                    if (ex.Status == WebExceptionStatus.ProtocolError)
                    {
                        var response = ex.Response as HttpWebResponse;
                        if (response != null)
                        {
                            cPrint(Color.Gray, thridAsText + ip + " | " + (int)response.StatusCode);
                        }
                        else
                        {
                            cPrint(Color.Gray, thridAsText + ip + " | Null");
                        }
                    }
                    else
                    {
                        cPrint(Color.Gray, thridAsText + ip + " | Down");
                    }
                }
                catch
                {
                    //sometimes ThreadAbortException is thrown when killing threads, dont show any errors after killswitch is triggered.
                    if (!killSwitch)
                    {
                        cPrint(Color.Red, thridAsText + ip + " | Internal error");
                    }
                }
            }
            deadThreads++;
            cPrint(Color.Black, thridAsText + "Reaching end. Thread will exit.");
        }
Пример #6
0
 public viewCdatValues(camData cd, int index)
 {
     InitializeComponent();
     this.cd    = cd;
     this.index = index;
 }