private void frmAyarlar_Load(object sender, EventArgs e) { iniFilePath = System.IO.Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath) + "\\print3Ayarlar.ini"; try { IniFile ini = new IniFile(iniFilePath); btnLoadPrinters_Click(null, null); string PrintFileLocation = ini.ReadValue("Ayarlar", "PrintFileLocation"); if (PrintFileLocation != null) { txtPrintFileLocation.Text = PrintFileLocation.Trim(); } //-------------------------------------------------------------------- string keyName = @"Software\Microsoft\Internet Explorer\PageSetup"; using (RegistryKey key = Registry.CurrentUser.OpenSubKey(keyName, true)) { if (key != null) { string old_footer = key.GetValue("footer").ToString(); string old_header = key.GetValue("header").ToString(); string margin_bottom = key.GetValue("margin_bottom").ToString(); string margin_left = key.GetValue("margin_left").ToString(); string margin_right = key.GetValue("margin_right").ToString(); string margin_top = key.GetValue("margin_top").ToString(); txtSfAlt.Text = margin_bottom; txtSfSol.Text = margin_left; txtSfSag.Text = margin_right; txtSfUst.Text = margin_top; chkPrintHaderFooter.Checked = true; if (old_footer.Trim() == string.Empty) { chkPrintHaderFooter.Checked = false; } } } } catch { } }
private void cmbPrinters_SelectedIndexChanged(object sender, EventArgs e) { IniFile ini = new IniFile(iniFilePath); try { string printername = cmbPrinters.Text.Trim(); if (printername == string.Empty) { MessageBox.Show("Bir Yazıcı seçiniz veya bir yazıcı adı giriniz."); return; } string interval = ini.ReadValue(printername, "ShutdownInterval"); if (interval != null) { if (interval != string.Empty) { txtTimerShutdownInterval.Text = Convert.ToInt32(interval).ToString(); } } string printCount = ini.ReadValue(printername, "PrintCount"); if (printCount != null) { if (printCount != string.Empty) { txtPrintCount.Text = Convert.ToInt32(printCount).ToString(); } } string printNameIE = cmbPrinters.Text + "IE"; string margin_bottom = ini.ReadValue(printNameIE, "margin_bottom"); string margin_left = ini.ReadValue(printNameIE, "margin_left"); string margin_right = ini.ReadValue(printNameIE, "margin_right"); string margin_top = ini.ReadValue(printNameIE, "margin_top"); txtSfAlt.Text = margin_bottom; txtSfSol.Text = margin_left; txtSfSag.Text = margin_right; txtSfUst.Text = margin_top; } catch (Exception ex) { throw; } }
private void Form1_Load(object sender, EventArgs e) { try { //if (!IsBrowserEmulationSet()) //{ GetBrowserEmulationVersion(); SetBrowserEmulationVersion(); //} //------------------------------------------------------------------------------------------- iniFilePath = System.IO.Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath) + "\\print3Ayarlar.ini"; IniFile ini = new IniFile(iniFilePath); string PrintFileLocation = ini.ReadValue("Ayarlar", "PrintFileLocation"); if (PrintFileLocation != null) { printFileLocation = PrintFileLocation.Trim(); } //------------------------------------------------------------------------------------------- //this.Text = iniFilePath; this.Visible = false; String[] args = System.Environment.GetCommandLineArgs(); if (args != null) { if (args.Length > 0) { string cmd = ""; foreach (string s in args) { cmd += " " + s; } string[] cmdParam = cmd.Split('#'); int i = 0; foreach (string s in cmdParam) { switch (i) { case 1: printDocumentFileName = s.Trim(); break; case 2: printerIndex = Convert.ToInt32(s.Trim()); break; default: break; } ; cmd += " " + s; i++; } setAktifPrinterByIndex(printerIndex); timer1.Interval = aktifPrinter.interval; lblAktifYazici.Text = aktifPrinter.name; if (printDocumentFileName != null) { if (printDocumentFileName != string.Empty) { WebBrowser wb = new WebBrowser(); wb.DocumentCompleted += wb_DocumentCompleted; printDocumentFileName = printFileLocation + printDocumentFileName; txtPrintingFullFileName.Text = printDocumentFileName; wb.Navigate(printDocumentFileName); } } } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void setAktifPrinterByIndex(int index) { IniFile ini = new IniFile(iniFilePath); try { int px = -1; string printername = ""; string[] dvs = ini.ReadSection("Printers"); foreach (string dv in dvs) { if (dv == null) { continue; } string[] keys = dv.Split('='); if (keys == null) { continue; } if (keys.ToString() == string.Empty) { continue; } string key = keys[0]; px++; if (px == index) { printername = key; aktifPrinter.name = printername; string interval = ini.ReadValue(printername, "ShutdownInterval"); if (interval != null) { if (interval != string.Empty) { aktifPrinter.interval = Convert.ToInt32(interval); } } string printCount = ini.ReadValue(printername, "PrintCount"); if (printCount != null) { if (printCount != string.Empty) { aktifPrinter.printCount = Convert.ToInt32(printCount); } } string printNameIE = printername + "IE"; string margin_bottom = ini.ReadValue(printNameIE, "margin_bottom"); string margin_left = ini.ReadValue(printNameIE, "margin_left"); string margin_right = ini.ReadValue(printNameIE, "margin_right"); string margin_top = ini.ReadValue(printNameIE, "margin_top"); string keyName = @"Software\Microsoft\Internet Explorer\PageSetup"; using (RegistryKey ekey = Registry.CurrentUser.OpenSubKey(keyName, true)) { if (ekey != null) { ekey.SetValue("margin_bottom", margin_bottom); ekey.SetValue("margin_left", margin_left); ekey.SetValue("margin_right", margin_right); ekey.SetValue("margin_top", margin_top); } } } } } catch { } }