예제 #1
0
파일: FrmMain.cs 프로젝트: sakpung/webstudy
        void DoSave(object data)
        {
            try
            {
                object[]  objects   = (object[])data;
                JobHolder jobHolder = (JobHolder)objects[0];
                int       nIndex    = (int)objects[1];

                jobHolder.Save();

                jobHolder.UninstallFonts();
                jobHolder.DeleteFonts();
                jobHolder.ClearFiles();

                EnableButton(_btnChange, true);
                EnableButton(_btnClear, true);

                //Check if Job has client custom data
                if (jobHolder._jobData != null)
                {
                    jobHolder._message = "( " + jobHolder._jobData.IPAddress + " )File saved to: " + jobHolder._fileSaved;
                }
                else
                {
                    jobHolder._message = "( No Extra Information )File saved to: " + jobHolder._fileSaved;
                }

                UpdateListbox(nIndex, jobHolder);
            }
            catch (Exception Ex)
            {
                MessageBox.Show(Ex.Message, FrmMain._strTittle, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
예제 #2
0
파일: FrmMain.cs 프로젝트: sakpung/webstudy
        private void _btnShow_Click(object sender, EventArgs e)
        {
            JobHolder jobHolder = (JobHolder)_btnShow.Tag;

            if (jobHolder != null && jobHolder._saved)
            {
                Process.Start(Path.GetDirectoryName(jobHolder._fileSaved));
            }
        }
예제 #3
0
파일: FrmMain.cs 프로젝트: sakpung/webstudy
 void UpdateListbox(int nIndex, JobHolder jobHolder)
 {
     if (_lstBoxLog.InvokeRequired)
     {
         UpdateListboxDelegate d = new UpdateListboxDelegate(UpdateListbox);
         this.Invoke(d, new object[] { nIndex, jobHolder });
     }
     else
     {
         this._lstBoxLog.Items[nIndex] = jobHolder;
     }
 }
예제 #4
0
파일: FrmMain.cs 프로젝트: sakpung/webstudy
        private void _lstBoxLog_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (_lstBoxLog.SelectedItem == null || _lstBoxLog.SelectedItem.GetType() != typeof(JobHolder))
            {
                _btnShow.Enabled = _btnOpen.Enabled = false;
                return;
            }

            JobHolder jobHolder = (JobHolder)_lstBoxLog.SelectedItem;

            if (jobHolder != null)
            {
                _btnShow.Enabled = jobHolder._saved && Directory.Exists(Path.GetDirectoryName(jobHolder._fileSaved));
                _btnOpen.Enabled = jobHolder._saved && File.Exists(jobHolder._fileSaved);
                _btnOpen.Tag     = _btnShow.Tag = jobHolder;
            }
        }
예제 #5
0
파일: FrmMain.cs 프로젝트: sakpung/webstudy
        bool CanClose()
        {
            bool bCanClose = true;

            foreach (object item in _lstBoxLog.Items)
            {
                if (item.GetType() != typeof(JobHolder))
                {
                    continue;
                }

                JobHolder holder = (JobHolder)item;
                if (holder._saving)
                {
                    bCanClose = false;
                    break;
                }
            }
            return(bCanClose);
        }
예제 #6
0
파일: FrmMain.cs 프로젝트: sakpung/webstudy
        private void _btnOpen_Click(object sender, EventArgs e)
        {
            JobHolder jobHolder = (JobHolder)_btnOpen.Tag;

            if (jobHolder != null && jobHolder._saved)
            {
                if (!File.Exists(jobHolder._fileSaved))
                {
                    MessageBox.Show("File not found.", FrmMain._strTittle, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    _btnOpen.Enabled = false;
                    return;
                }

                try
                {
                    Process.Start(jobHolder._fileSaved);
                }
                catch (System.Exception ex)
                {
                    MessageBox.Show(ex.Message, FrmMain._strTittle, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }
예제 #7
0
파일: FrmMain.cs 프로젝트: sakpung/webstudy
        public void _printer_JobEvent(object sender, JobEventArgs e)
        {
            if (e.JobEventState == EventState.JobStart)
            {
                _btnCancel.Enabled = true;
                _btnChange.Enabled = false;

                this.BringToFront();
                this.Focus();

                PrintJobData jobData = _printer.RemoteData;
                if (_printer.RemoteData != null)
                {
                    _jobHolder = new JobHolder(e.JobID, jobData.UserData, _codec, jobData, _fontPath);

                    _jobHolder._message = "( " + _jobHolder._jobData.IPAddress + " ) Job name " +
                                          jobData.PrintJobName + " Job ID " + jobData.JobID;

                    _nIndex = _lstBoxLog.Items.Add(_jobHolder);
                }
                else
                {
                    _jobHolder = new JobHolder(e.JobID, _codec, _fontPath);

                    _jobHolder._message = "Job Received With No Extra Information ( Job ID  " + e.JobID + " )";
                    _nIndex             = _lstBoxLog.Items.Add(_jobHolder);
                }
            }
            else if (e.JobEventState == EventState.JobEnd)
            {
                JobHolder tmpHolder = null;
                for (int i = 0; i < _lstBoxLog.Items.Count; i++)
                {
                    if (_lstBoxLog.Items[i].GetType() != typeof(JobHolder))
                    {
                        continue;
                    }

                    tmpHolder = (JobHolder)_lstBoxLog.Items[i];
                    if (tmpHolder._jobID == e.JobID)
                    {
                        _jobHolder = tmpHolder;
                        break;
                    }
                }

                if (_jobHolder != null)
                {
                    _btnCancel.Enabled = false;
                    this.BringToFront();
                    this.Focus();

                    string strMessage = "";

                    //Check if Job has client custom data
                    if (_jobHolder._jobData != null)
                    {
                        strMessage = "( " + _jobHolder._jobData.IPAddress + " ) Saving " + _jobHolder._format + " file, please wait ... ";
                    }
                    else
                    {
                        strMessage = "( No Extra Information ) Saving " + _jobHolder._format + " file, please wait ... ";
                    }

                    _jobHolder._message       = strMessage;
                    _lstBoxLog.Items[_nIndex] = _jobHolder;

                    //Get embedded fonts related to the Job ID
                    string[] arrFonts = _printer.GetEmbeddedFonts(_jobHolder._fontPath, e.JobID);
                    _jobHolder.SetFonts(arrFonts);

                    //Save on a different thread
                    ParameterizedThreadStart pStart = new ParameterizedThreadStart(DoSave);
                    Thread tSaving = new Thread(pStart);
                    tSaving.Start(new object[] { _jobHolder, _nIndex });
                    _jobHolder = null;
                }
            }
        }