protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { labelFileNamelbl.Text = _dymoAddin.FileName; // init mru string str = _dymoAddin.GetMRULabelFiles(); foreach (string name in str.Split(new char[] { '|' })) { mruCmb.Items.Add(Path.GetFileNameWithoutExtension(name)); } // init printer list trayCmb.Enabled = false; printersCmb.Items.Clear(); str = _dymoAddin.GetDymoPrinters(); foreach (string name in str.Split(new char[] { '|' })) { printersCmb.Items.Add(name); if (_dymoAddin.IsTwinTurboPrinter(name)) { trayCmb.Enabled = true; } } if (printersCmb.Items.Count > 0) { printersCmb.SelectedIndex = 0; } if (trayCmb.Enabled) { trayCmb.SelectedIndex = 0; } InitLabelObjects(); } }
private void SetupLabelWriterSelection(bool InitCmb) { // get the objects on the label if (InitCmb) { // clear all items first LabelWriterCmb.Items.Clear(); string PrtNames = DymoAddIn.GetDymoPrinters(); if (PrtNames != null) { // parse the result int i = PrtNames.IndexOf('|'); while (i >= 0) { LabelWriterCmb.Items.Add(PrtNames.Substring(0, i)); PrtNames = PrtNames.Remove(0, i + 1); i = PrtNames.IndexOf('|'); } if (PrtNames.Length > 0) { LabelWriterCmb.Items.Add(PrtNames); } PrtNames = DymoAddIn.GetCurrentPrinterName(); if (PrtNames != null) { LabelWriterCmb.SelectedIndex = LabelWriterCmb.Items.IndexOf(PrtNames); } else { LabelWriterCmb.SelectedIndex = 0; } } } // check if selected/current printer is a twin turbo printer TrayCmb.Enabled = DymoAddIn.IsTwinTurboPrinter(LabelWriterCmb.Text); if (TrayCmb.Enabled) { // show the current tray selection if the printer // is a twin turbo switch (DymoAddIn.GetCurrentPaperTray()) { case 0: // left tray TrayCmb.SelectedIndex = 0; break; case 1: // right tray TrayCmb.SelectedIndex = 1; break; case 2: // auto switch TrayCmb.SelectedIndex = 2; break; default: // tray selection not set, so default to auto switch TrayCmb.SelectedIndex = 2; break; } } }