Exemple #1
0
        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);
            }
        }
Exemple #2
0
        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
            {
            }
        }