public ImagePreview(Control parent, MouseEventHandler parentmouse, MouseEventHandler parentclick, MouseEventHandler parentdoubleclick, InternetImage img)
        {
            InitializeComponent();
            m_random = new Random().Next(256);

            //this.BackColor = System.Drawing.Color.Black;
            //this.Location = new System.Drawing.Point(positionx*(128+8)+4, positiony*(128+16+4+8)+4);
            //this.Bounds = new Rectangle(new System.Drawing.Point(positionx * (128 + 8) + 4, positiony * (128 + 16 + 4 + 8) + 4), Size);
            this.MouseMove                     += new MouseEventHandler(parentmouse);
            this.MouseClick                    += new MouseEventHandler(parentclick);
            this.MouseDoubleClick              += new MouseEventHandler(parentdoubleclick);
            this.MouseOverPanel.MouseMove      += new System.Windows.Forms.MouseEventHandler(parentmouse);
            this.ImagePanel.MouseMove          += new System.Windows.Forms.MouseEventHandler(parentmouse);
            this.ImagePanel.MouseClick         += new MouseEventHandler(parentclick);
            this.ImagePanel.MouseDoubleClick   += new MouseEventHandler(parentdoubleclick);
            this.Description.MouseClick        += new MouseEventHandler(parentclick);
            this.Description.MouseDoubleClick  += new MouseEventHandler(parentdoubleclick);
            this.Description2.MouseClick       += new MouseEventHandler(parentclick);
            this.Description2.MouseDoubleClick += new MouseEventHandler(parentdoubleclick);
            this.SaveFile.Click                += new EventHandler(SaveFile_Click);
            this.DoubleBuffered                 = true;

            Image    = img;
            Selected = false;

            parent.Controls.Add(this);
        }
        public ImagePreview(Control parent, MouseEventHandler parentmouse, MouseEventHandler parentclick, MouseEventHandler parentdoubleclick, InternetImage img)
        {
            InitializeComponent();
            m_random = new Random().Next(256);

            //this.BackColor = System.Drawing.Color.Black;
            //this.Location = new System.Drawing.Point(positionx*(128+8)+4, positiony*(128+16+4+8)+4);
            //this.Bounds = new Rectangle(new System.Drawing.Point(positionx * (128 + 8) + 4, positiony * (128 + 16 + 4 + 8) + 4), Size);
            this.MouseMove += new MouseEventHandler(parentmouse);
            this.MouseClick += new MouseEventHandler(parentclick);
            this.MouseDoubleClick += new MouseEventHandler(parentdoubleclick);
            this.MouseOverPanel.MouseMove += new System.Windows.Forms.MouseEventHandler(parentmouse);
            this.ImagePanel.MouseMove += new System.Windows.Forms.MouseEventHandler(parentmouse);
            this.ImagePanel.MouseClick += new MouseEventHandler(parentclick);
            this.ImagePanel.MouseDoubleClick += new MouseEventHandler(parentdoubleclick);
            this.Description.MouseClick +=new MouseEventHandler(parentclick);
            this.Description.MouseDoubleClick += new MouseEventHandler(parentdoubleclick);
            this.Description2.MouseClick += new MouseEventHandler(parentclick);
            this.Description2.MouseDoubleClick += new MouseEventHandler(parentdoubleclick);
            this.SaveFile.Click += new EventHandler(SaveFile_Click);
            this.DoubleBuffered = true;

            Image = img;
            Selected = false;
            
            parent.Controls.Add(this);
        }
Exemple #3
0
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            ServicePointManager.SecurityProtocol = (SecurityProtocolType)Enum.ToObject(typeof(SecurityProtocolType), 3072); // Use TLS 1.2
#if DEBUG
            string server = "db.cuetools.net";
#else
            string server = null;
#endif
            this.ctdb.ContactDB(server, this.agent, null, false, false,
                                AudioDataPlugIn.Options.MetadataSearch);
            if (this.cdinfo)
            {
                foreach (var metadata in ctdb.Metadata)
                {
                    backgroundWorker1.ReportProgress(0, metadata);
                }
            }
            var knownUrls = new List <string>();
            foreach (var metadata in ctdb.Metadata)
            {
                if (metadata.coverart == null || !this.cover)
                {
                    continue;
                }
                if (!this.cdinfo)
                {
                    backgroundWorker1.ReportProgress(0, metadata);
                }
                if (backgroundWorker1.CancellationPending)
                {
                    throw new Exception();
                }
                foreach (var coverart in metadata.coverart)
                {
                    var uri = Options.CoversSize == CTDBCoversSize.Large ?
                              coverart.uri : coverart.uri150 ?? coverart.uri;
                    if (knownUrls.Contains(uri) ||
                        (Options.CoversSearch == CTDBCoversSearch.Primary && !coverart.primary))
                    {
                        continue;
                    }
                    var ms = new MemoryStream();
                    if (!this.ctdb.FetchFile(uri, ms))
                    {
                        continue;
                    }
                    var img = new InternetImage();
                    img.URL   = uri;
                    img.Data  = ms.ToArray();
                    img.Image = new Bitmap(ms);
                    knownUrls.Add(uri);
                    backgroundWorker1.ReportProgress(0, img);
                }
            }
        }
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
#if DEBUG
            string server = "hq.cuetools.net";
#else
            string server = null;
#endif
            this.ctdb.ContactDB(server, this.agent, null, false, false,
                AudioDataPlugIn.Options.MetadataSearch);
            if (this.cdinfo)
            {
                foreach (var metadata in ctdb.Metadata)
                {
                    backgroundWorker1.ReportProgress(0, metadata);
                }
            }
            var knownUrls = new List<string>();
            foreach (var metadata in ctdb.Metadata)
            {
                if (metadata.coverart == null || !this.cover)
                    continue;
                if (!this.cdinfo)
                {
                    backgroundWorker1.ReportProgress(0, metadata);
                }
                if (backgroundWorker1.CancellationPending)
                {
                    throw new Exception();
                }
                foreach (var coverart in metadata.coverart)
                {
                    var uri = Options.CoversSearch == CTDBCoversSearch.Large ?
                        coverart.uri : coverart.uri150 ?? coverart.uri;
                    if (knownUrls.Contains(uri) || !coverart.primary)
                        continue;
                    var ms = new MemoryStream();
                    if (!this.ctdb.FetchFile(uri, ms))
                        continue;
                    var img = new InternetImage();
                    img.URL = uri;
                    img.Data = ms.ToArray();
                    img.Image = new Bitmap(ms);
                    knownUrls.Add(uri);
                    backgroundWorker1.ReportProgress(0, img);
                }
            }
        }