Example #1
0
        private void UpdateImagesList()
        {
            imageList = PrinterImage.ReadPrinterImagesFromDB();

            listView1.Items.Clear();
            foreach (var image in imageList)
            {
                string[]     arr = new string[4];
                ListViewItem itm;

                //add items to ListView
                arr[0] = image.id.ToString();
                arr[1] = image.description;
                arr[2] = image.fullPath;

                switch (image.onPrinter)
                {
                case PrinterImage.ImageStatus.Loaded:
                    arr[3] = "On Printer; ";
                    break;

                case PrinterImage.ImageStatus.NotLoaded:
                    arr[3] = "Not loaded; ";
                    break;

                case PrinterImage.ImageStatus.Unknown:
                    arr[3] = "Unable to query printer; ";
                    break;
                }
                if (image.locked)
                {
                    arr[3] += "Image Locked!";
                }

                itm = new ListViewItem(arr);
                listView1.Items.Add(itm);

                if (image.locked)
                {
                    listView1.Items[listView1.Items.Count - 1].ForeColor = Color.Red;
                }
            }
        }
Example #2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (txtDescription.Text.Length < 3)
            {
                MessageBox.Show("Please enter a decription for the image.", "Desription Missing", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (txtFileName.Text.Length < 3)
            {
                MessageBox.Show("Please enter a File Name.", "File Name Missing", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            bool   ok;
            string opr;

            if (myImage == null)
            {
                // Creating a new image definition
                myImage = new PrinterImage(txtDescription.Text, txtFileName.Text);
                ok      = myImage.CreateInDB();
                opr     = "created";
            }
            else
            {
                // Updating an existing image definition
                ok  = myImage.UpdateOnDB(txtDescription.Text, txtFileName.Text);
                opr = "updated";
            }

            if (ok)
            {
                MessageLogger.Add(string.Format("Image definition {0} filename {1} {2} on DB by {3}", myImage.description, myImage.fullPath, opr, ThisApp.user.name),
                                  MessageLogger.MsgLevel.permanent);

                MessageBox.Show(string.Format("Image Definition '{0}' saved to DB", myImage.description), "New Image Created", MessageBoxButtons.OK, MessageBoxIcon.Information);
                Close();
            }
            else
            {
                MessageBox.Show("Error saving image definition to DB", "New Image Created", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Example #3
0
 public EditImageDialog(PrinterImage img)
 {
     InitializeComponent();
     myImage = img;
 }