Esempio n. 1
0
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            Printer printer1 = new Printer(host, "lp", username);

            int count = 0;
            foreach (String s in files)
            {
                backgroundWorker1.ReportProgress(count, s);
                count++;
                printer1.ProcessLPR(s);
            }

            if (!printer1.ErrorMsg.Equals(""))
            {
                notifyicon.ShowBalloonTip(2000, "Error while spooling", printer1.ErrorMsg, ToolTipIcon.Error);
            }
            else
            {
                notifyicon.ShowBalloonTip(2000, "Added Music", "Done...", ToolTipIcon.Info);
            }
        }
Esempio n. 2
0
 private void removeTracks()
 {
     Printer printer1 = new Printer(Properties.Settings.Default.SpoolerIp, "lp", username);
     foreach (ListViewItem s in this.listView1.SelectedItems)
     {
         printer1.LPRM((string)s.Tag);
         notifyIcon1.ShowBalloonTip(2000, "Removed", s.Text + " (" + s.Tag + ")", ToolTipIcon.Info);
     }
 }
Esempio n. 3
0
        private Boolean parseLpq()
        {
            Printer printer1 = new Printer(Properties.Settings.Default.SpoolerIp, "lp", username);
            if (!printer1.ErrorMsg.Equals(""))
            {
                notifyIcon1.ShowBalloonTip(2000, "Error while spooling", printer1.ErrorMsg, ToolTipIcon.Error);
                return false;
            }

            String lines = printer1.LPQ(false).Trim().Replace("\0", string.Empty);

            Boolean newElement = false;

            lock (Jobs)
            {
                MatchCollection matches = multiLine.Matches(lines);

                if (matches.Count != Jobs.Count())
                {
                    newElement = true;
                }

                Jobs = new List<ListViewItem>();
                _jobs = new List<MusicJob>();
                foreach (Match m in matches)
                {
                    String user = m.Result("${user}").Trim();
                    String status = m.Result("${status}").Trim();
                    String jobid = m.Result("${jobid}").Trim();
                    String details = m.Result("${details}").Trim();
                    String title = m.Result("${title}").Trim();
                    String size = m.Result("${size}").Trim();

                    ListViewItem item = new ListViewItem();
                    item.Tag = jobid;
                    int bytes = 0;
                    Int32.TryParse(size, out bytes);
                    item.Text = String.Format("{0,-8} {1,-15} {2,-6}MB {3}", status, user, ConvertIntToMegabytes(bytes).ToString("0.00"), title);
                    item.ImageIndex = 0;
                    Jobs.Add(item);
                    _jobs.Add(new MusicJob(user, status, details, title, size));
                }

            }

            List<MusicJob> activeJobs = _jobs.Where(a => a.status == "active").ToList<MusicJob>();

            if (activeJobs.Count() > 0)
            {
                if (ActiveJob == null || activeJobs.First().title != ActiveJob.title)
                {
                    notifyIcon1.ShowBalloonTip(2000, "Currently Playing", activeJobs.First().title, ToolTipIcon.Info);
                    ActiveJob = activeJobs.First();
                    newElement = true;
                }
            }
            else
            {
                ActiveJob = null;
            }
            return newElement;
        }
Esempio n. 4
0
        private void printBtn_Click(object sender, EventArgs e)
        {
            if ((Properties.Settings.Default.SpoolerIp == ""))
            {
                MessageBox.Show("Please fill in host");
                return;
            }

            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                Printer printer1 = new Printer(Properties.Settings.Default.SpoolerIp, "lp", username);
                string fname = openFileDialog1.FileName;
                if (!checkFilename(fname))
                    return;
                printer1.LPR(fname, false);
                if (!printer1.ErrorMsg.Equals(""))
                {
                    notifyIcon1.ShowBalloonTip(2000, "Error while spooling", printer1.ErrorMsg, ToolTipIcon.Error);
                }
            }
        }
Esempio n. 5
0
        private void Form1_KeyUp(object sender, KeyEventArgs e)
        {
            e.Handled = true;
            if (e.KeyCode == Keys.F11)
            {
                if (fullscreen == false)
                {
                    lock (this.restore)
                    {
                        this.restore.location = this.Location;
                        this.restore.width = this.Width;
                        this.restore.height = this.Height;
                        this.restore.windowState = this.WindowState;
                        this.restore.formBorderStyle = this.FormBorderStyle;
                    }
                    this.WindowState = FormWindowState.Normal; // Hack to get a Maximized Window to fullscreen
                    this.Location = new Point(0, 0);
                    this.FormBorderStyle = FormBorderStyle.None;
                    this.Width = Screen.PrimaryScreen.Bounds.Width;
                    this.Height = Screen.PrimaryScreen.Bounds.Height;
                    this.TopMost = true;
                    fullscreen = true;
                }
                else
                {
                    this.TopMost = false;
                    lock (this.restore)
                    {
                        this.WindowState = this.restore.windowState;
                        this.FormBorderStyle = this.restore.formBorderStyle;
                        if (this.restore.windowState != FormWindowState.Maximized)
                        {
                            this.Width = this.restore.width;
                            this.Height = this.restore.height;
                            this.Location = this.restore.location;
                        }
                    }
                    fullscreen = false;
                }
            }

            if (fullscreen && e.KeyCode == Keys.Escape)
            {
                this.TopMost = false;
                lock (this.restore)
                {
                    this.WindowState = this.restore.windowState;
                    this.FormBorderStyle = this.restore.formBorderStyle;
                    if (this.restore.windowState != FormWindowState.Maximized)
                    {
                        this.Width = this.restore.width;
                        this.Height = this.restore.height;
                        this.Location = this.restore.location;
                    }
                }
                fullscreen = false;
            }

            if (e.KeyCode == Keys.Delete && listView1.SelectedItems.Count > 0)
            {
                Printer printer1 = new Printer(Properties.Settings.Default.SpoolerIp, "lp", username);
                foreach (ListViewItem s in this.listView1.SelectedItems)
                {
                    printer1.LPRM((string)s.Tag);
                    notifyIcon1.ShowBalloonTip(2000, "Removed", s.Text + " (" + s.Tag + ")", ToolTipIcon.Info);
                }
            }

            if (e.Control && e.KeyCode == Keys.S)
            {
                Properties.Settings.Default.SpoolerIp = ipTextBox.Text;
                Properties.Settings.Default.Save();
                notifyIcon1.ShowBalloonTip(2000, "Applied Settings", "Settings have been saved and applied", ToolTipIcon.Info);
            }
        }