Beispiel #1
0
 private void r1_CheckedChanged(object sender, EventArgs e)
 {
     try
     {
         if (this.printer_0 != null)
         {
             PrinterEventArgs args = new PrinterEventArgs {
                 Name        = ((this.object_0 == null) || (this.object_0.Length <= 0)) ? "user" : this.object_0[0].ToString(),
                 Left        = Common.ObjectToFloat(this.txt_left.Text),
                 Top         = Common.ObjectToFloat(this.txt_top.Text),
                 System      = "1",
                 PageLenght  = 0,
                 PrinterName = this.comboBox_DefaultPrinter.SelectedItem.ToString(),
                 IsQuanDa    = this.r1.Checked
             };
             this.printer_0.SaveUserPrinterEdge(args);
         }
     }
     catch (Exception exception)
     {
         this.loger.Error(exception.ToString());
     }
 }
Beispiel #2
0
 public Printer(object[] object_1)
 {
     this.UserPrinterArgs    = new PrinterEventArgs();
     this.DefaultPrinterArgs = new PrinterEventArgs();
     this.RealPrinterArgs    = new PrinterEventArgs();
     this.ilog_0             = LogUtil.GetLogger <Printer>();
     this.printDocument_0    = new PrintDocument();
     this.object_0           = object_1;
     if ((object_1 != null) && (object_1.Length > 0))
     {
         string str = object_1[0] as string;
         this.Name = "";
         this.Name = this.Name + str[0];
         if (object_1.Length >= 4)
         {
             this.Name = this.Name + object_1[3].ToString();
         }
     }
     else
     {
         this.Name = "user";
     }
 }
Beispiel #3
0
 public PrintSetUp(object[] object_1)
 {
     this.loger              = LogUtil.GetLogger <PrintSetUp>();
     this.list_0             = new List <string>();
     this.printDocument_0    = new PrintDocument();
     this.bool_0             = true;
     this.CurrentPrinterName = "";
     this.paperSize_0        = new PaperSize("航天信息纸张", 550, 850);
     this.paperSize_1        = new PaperSize("航天信息纸张", 700, 0x3b5);
     this.paperSize_2        = new PaperSize("航天信息纸张", 300, 0x2b9);
     this.paperSize_3        = new PaperSize("航天信息纸张", 300, 0x256);
     this.paperSize_4        = new PaperSize("航天信息纸张", 300, 500);
     this.paperSize_5        = new PaperSize("航天信息纸张", 0xe0, 0x2b9);
     this.paperSize_6        = new PaperSize("航天信息纸张", 0xe0, 0x256);
     this.paperSize_7        = new PaperSize("航天信息纸张", 0xe0, 500);
     this.InitializeComponent();
     try
     {
         this.txt_top.KeyPress         += new KeyPressEventHandler(this.txt_left_KeyPress);
         this.txt_top.MaxLength         = 8;
         this.txt_top.ImeMode           = ImeMode.Disable;
         this.txt_top.ShortcutsEnabled  = false;
         this.txt_left.KeyPress        += new KeyPressEventHandler(this.txt_left_KeyPress);
         this.txt_left.MaxLength        = 8;
         this.txt_left.ImeMode          = ImeMode.Disable;
         this.txt_left.ShortcutsEnabled = false;
         this.printer_0 = new Printer(object_1);
         PrinterEventArgs printerArgs = this.printer_0.GetPrinterArgs(IPrint.IsZjFlag);
         this.method_0(printerArgs.PrinterName);
         if (this.comboBox_DefaultPrinter.Items.Count == 0)
         {
             this.loger.Error("没有打印机,请设置打印机!");
         }
         else
         {
             this.object_0 = object_1;
             if ((printerArgs != null) && (object_1 != null))
             {
                 this.txt_top.Text          = printerArgs.Top.ToString();
                 this.txt_left.Text         = printerArgs.Left.ToString();
                 this.txt_left.TextChanged += new EventHandler(this.txt_left_TextChanged);
                 this.txt_top.TextChanged  += new EventHandler(this.txt_top_TextChanged);
                 this.CurrentPrinterName    = printerArgs.PrinterName;
                 if (((this.object_0 != null) && (this.object_0.Length > 3)) && (this.object_0[3].ToString() == "_QD"))
                 {
                     this.r1.Text        = "全打";
                     this.r2.Text        = "套打";
                     this.groupBox2.Text = "套打";
                     if (printerArgs.IsQuanDa)
                     {
                         this.r1.Checked = true;
                         this.r2.Checked = false;
                     }
                     else
                     {
                         this.r1.Checked = false;
                         this.r2.Checked = true;
                     }
                 }
                 else if (((this.object_0 != null) && (this.object_0.Length > 0)) && (this.object_0[0].ToString() == "q"))
                 {
                     this.r1.Text        = "横打";
                     this.r2.Text        = "竖打";
                     this.groupBox2.Text = "打印方式";
                     if (printerArgs.IsQuanDa)
                     {
                         this.r1.Checked = true;
                         this.r2.Checked = false;
                     }
                     else
                     {
                         this.r1.Checked = false;
                         this.r2.Checked = true;
                     }
                 }
                 this.method_1();
             }
         }
     }
     catch (Exception exception)
     {
         this.loger.Error(exception.ToString());
     }
 }
Beispiel #4
0
        private void method_1()
        {
            string str3;

            if ((pageSetupDialog == null) || (this.comboBox_DefaultPrinter.SelectedItem == null))
            {
                this.loger.Error("SetCurPrinter函数:当前pageSetupDialog为空");
                return;
            }
            pageSetupDialog.Document.PrinterSettings             = new PrinterSettings();
            pageSetupDialog.Document.PrinterSettings.PrinterName = this.comboBox_DefaultPrinter.SelectedItem.ToString();
            PrinterSettings.PaperSizeCollection paperSizes = pageSetupDialog.Document.PrinterSettings.PaperSizes;
            this.CurrentPrinterName = pageSetupDialog.Document.PrinterSettings.PrinterName;
            if (((this.object_0 != null) && (this.object_0.Length > 0)) && ((str3 = this.object_0[0].ToString()) != null))
            {
                if ((str3 == "c") || (str3 == "s"))
                {
                    pageSetupDialog.Document.PrinterSettings.DefaultPageSettings.PaperSize = this.paperSize_0;
                }
                else if ((str3 == "j") || (str3 == "f"))
                {
                    pageSetupDialog.Document.PrinterSettings.DefaultPageSettings.PaperSize = this.paperSize_1;
                }
                else if ((str3 == "q") && (this.object_0.Length >= 5))
                {
                    int    num  = Common.ObjectToInt(this.object_0[4].ToString());
                    string str2 = "NEW76mmX177mm";
                    Dictionary <string, int> jsPrintTemplate = ToolUtil.GetJsPrintTemplate();
                    if (jsPrintTemplate.Count > 0)
                    {
                        foreach (string str in jsPrintTemplate.Keys)
                        {
                            if (jsPrintTemplate[str] == num)
                            {
                                str2 = str;
                            }
                        }
                        if (str2.IndexOf("76mmX177mm") != -1)
                        {
                            pageSetupDialog.Document.PrinterSettings.DefaultPageSettings.PaperSize = this.paperSize_2;
                        }
                        else if (str2.IndexOf("76mmX152mm") != -1)
                        {
                            pageSetupDialog.Document.PrinterSettings.DefaultPageSettings.PaperSize = this.paperSize_3;
                        }
                        else if (str2.IndexOf("76mmX127mm") != -1)
                        {
                            pageSetupDialog.Document.PrinterSettings.DefaultPageSettings.PaperSize = this.paperSize_4;
                        }
                        else if (str2.IndexOf("57mmX177mm") != -1)
                        {
                            pageSetupDialog.Document.PrinterSettings.DefaultPageSettings.PaperSize = this.paperSize_5;
                        }
                        else if (str2.IndexOf("57mmX152mm") != -1)
                        {
                            pageSetupDialog.Document.PrinterSettings.DefaultPageSettings.PaperSize = this.paperSize_6;
                        }
                        else if (str2.IndexOf("57mmX127mm") != -1)
                        {
                            pageSetupDialog.Document.PrinterSettings.DefaultPageSettings.PaperSize = this.paperSize_7;
                        }
                        else
                        {
                            pageSetupDialog.Document.PrinterSettings.DefaultPageSettings.PaperSize = this.paperSize_2;
                        }
                    }
                    else
                    {
                        pageSetupDialog.Document.PrinterSettings.DefaultPageSettings.PaperSize = this.paperSize_2;
                    }
                }
            }
            this.bool_0 = false;
            IEnumerator enumerator2 = pageSetupDialog.Document.PrinterSettings.PrinterResolutions.GetEnumerator();

            {
                PrinterResolution current;
                while (enumerator2.MoveNext())
                {
                    current = (PrinterResolution)enumerator2.Current;
                    if ((current.X == 180) && (current.Y == 180))
                    {
                        goto Label_038B;
                    }
                }
                goto Label_03BF;
Label_038B:
                pageSetupDialog.Document.DefaultPageSettings.PrinterResolution = current;
                this.bool_0 = true;
            }
Label_03BF:
            if ((this.printer_0 != null) && !IPrint.IsZjFlag)
            {
                PrinterEventArgs args = new PrinterEventArgs {
                    Name        = ((this.object_0 == null) || (this.object_0.Length <= 0)) ? "user" : this.object_0[0].ToString(),
                    Left        = Common.ObjectToFloat(this.txt_left.Text),
                    Top         = Common.ObjectToFloat(this.txt_top.Text),
                    System      = "1",
                    PageLenght  = 0,
                    PrinterName = this.comboBox_DefaultPrinter.SelectedItem.ToString(),
                    IsQuanDa    = this.r1.Checked
                };
                this.printer_0.SaveUserPrinterEdge(args);
            }
        }
Beispiel #5
0
        public void SaveUserPrinterEdge(PrinterEventArgs printerEventArgs_0)
        {
            string      path     = Path.Combine(PropertyUtil.GetValue("MAIN_PATH"), @"Config\Print\PrinterManager.xml");
            XmlDocument document = new XmlDocument();

            try
            {
                byte[] sourceArray      = Convert.FromBase64String("FZoo0+wH8AgXWEjMAFRnOVt+ZImrQik1jiVirx3SQzoTTc8H/D9o32mIm2Fb6CnC");
                byte[] destinationArray = new byte[0x20];
                Array.Copy(sourceArray, 0, destinationArray, 0, 0x20);
                byte[] buffer3 = new byte[0x10];
                Array.Copy(sourceArray, 0x20, buffer3, 0, 0x10);
                byte[] buffer4 = AES_Crypt.Decrypt(Convert.FromBase64String("FkC25FGxr7ANG8kSXdMQ1dc1q5h2nMtkTSy90S2NQks6FTRmwMwaGUhrgVdlpMrhTSdJ9l7s5jbUyGMhyCd26w=="), destinationArray, buffer3, null);
                byte[] buffer5 = new byte[0x20];
                Array.Copy(buffer4, 0, buffer5, 0, 0x20);
                byte[] buffer6 = new byte[0x10];
                Array.Copy(buffer4, 0x20, buffer6, 0, 0x10);
                FileStream stream = new FileStream(path, FileMode.Open);
                byte[]     buffer = new byte[stream.Length];
                stream.Read(buffer, 0, buffer.Length);
                stream.Close();
                byte[] buffer8 = AES_Crypt.Decrypt(buffer, buffer5, buffer6, null);
                if (buffer8 != null)
                {
                    document.Load(new XmlTextReader(new MemoryStream(buffer8)));
                    XmlNode node = document.SelectSingleNode("/PrintConfig");
                    new PrintDocument();
                    if (this.Name == null)
                    {
                        this.Name = "user";
                    }
                    bool flag  = (((this.object_0 != null) && (this.object_0.Length >= 4)) && (this.object_0[1].ToString() == "1100053620")) && (this.object_0[2].ToString() == "593803");
                    bool flag2 = false;
                    if ((node.ChildNodes != null) || (node.ChildNodes.Count > 0))
                    {
                        for (int i = 0; i < node.ChildNodes.Count; i++)
                        {
                            XmlNode    oldChild = node.ChildNodes[i];
                            XmlElement element  = oldChild as XmlElement;
                            if (element.GetAttribute("name") == this.Name)
                            {
                                node.RemoveChild(oldChild);
                                i--;
                            }
                            else if (element.GetAttribute("name") == "_QD")
                            {
                                node.RemoveChild(oldChild);
                                i--;
                                flag2 = true;
                            }
                            else if ((element.GetAttribute("name") == "c_QD") && flag)
                            {
                                node.RemoveChild(oldChild);
                                i--;
                            }
                        }
                    }
                    if ((flag && (this.Name == "s_QD")) || flag2)
                    {
                        XmlElement newChild = document.CreateElement("Printer");
                        newChild.SetAttribute("name", "c_QD");
                        newChild.SetAttribute("left", printerEventArgs_0.Left.ToString());
                        newChild.SetAttribute("top", printerEventArgs_0.Top.ToString());
                        newChild.SetAttribute("system", "1");
                        newChild.SetAttribute("pagelenght", printerEventArgs_0.PageLenght.ToString());
                        newChild.SetAttribute("PrinterName", printerEventArgs_0.PrinterName);
                        newChild.SetAttribute("IsQuanDa", printerEventArgs_0.IsQuanDa.ToString());
                        node.AppendChild(newChild);
                        XmlElement element3 = document.CreateElement("Printer");
                        element3.SetAttribute("name", "s_QD");
                        element3.SetAttribute("left", printerEventArgs_0.Left.ToString());
                        element3.SetAttribute("top", printerEventArgs_0.Top.ToString());
                        element3.SetAttribute("system", "1");
                        element3.SetAttribute("pagelenght", printerEventArgs_0.PageLenght.ToString());
                        element3.SetAttribute("PrinterName", printerEventArgs_0.PrinterName);
                        element3.SetAttribute("IsQuanDa", printerEventArgs_0.IsQuanDa.ToString());
                        node.AppendChild(element3);
                    }
                    else
                    {
                        XmlElement element4 = document.CreateElement("Printer");
                        element4.SetAttribute("name", this.Name);
                        element4.SetAttribute("left", printerEventArgs_0.Left.ToString());
                        element4.SetAttribute("top", printerEventArgs_0.Top.ToString());
                        element4.SetAttribute("system", "1");
                        element4.SetAttribute("pagelenght", printerEventArgs_0.PageLenght.ToString());
                        element4.SetAttribute("PrinterName", printerEventArgs_0.PrinterName);
                        element4.SetAttribute("IsQuanDa", printerEventArgs_0.IsQuanDa.ToString());
                        node.AppendChild(element4);
                    }
                    document.Save(path);
                }
            }
            catch (Exception exception)
            {
                XmlDeclaration declaration = document.CreateXmlDeclaration("1.0", "UTF-8", "");
                document.AppendChild(declaration);
                XmlElement element5 = document.CreateElement("PrintConfig");
                element5.SetAttribute("Name", "user");
                document.AppendChild(element5);
                document.Save(path);
                this.UserPrinterArgs.PrinterName = this.printDocument_0.PrinterSettings.PrinterName;
                this.UserPrinterArgs.System      = "1";
                this.UserPrinterArgs.PageLenght  = 0;
                this.UserPrinterArgs.Name        = "user";
                this.UserPrinterArgs.IsQuanDa    = true;
                this.ilog_0.Error(exception.ToString());
            }
            finally
            {
                string   str3 = "ikAJxQPU3bNUWK0fMgeHxMFk5wjhSQPYnARPgkVEKVU4yjA7KoD3eo7c6tLP745I";
                FileInfo info = new FileInfo(path);
                Common.Encrypt(new FileInfo[] { info }, str3);
            }
        }