Ejemplo n.º 1
0
        private void SetupAll()
        {
            m_AllTypes = new CompleteTypes();

            m_AllTypes.Type1 = new SelectedType {
                Name = "壓", IsChecked = false, Number = "0"
            };
            m_AllTypes.Type2 = new SelectedType {
                Name = "角", IsChecked = false, Number = "0"
            };
            m_AllTypes.Type3 = new SelectedType {
                Name = "平", IsChecked = false, Number = "0"
            };
            m_AllTypes.Type4 = new SelectedType {
                Name = "花", IsChecked = false, Number = "0"
            };
            m_AllTypes.Type5 = new SelectedType {
                Name = "連体", IsChecked = false, Number = "0"
            };
            m_AllTypes.Type6 = new SelectedType {
                Name = "串", IsChecked = false, Number = "0"
            };
            m_AllTypes.Type7 = new SelectedType {
                Name = string.Empty, IsChecked = false, Number = "0"
            };
        }
Ejemplo n.º 2
0
        public bool GenerateForAllUsedIncomplete()
        {
            var allAssemblyTypes = new Dictionary<string, Type>();

            foreach (Type t in TargetAssembly.GetTypes().Where(t => t.IsPublic))
            {
                if (!allAssemblyTypes.ContainsKey(t.Name))
                    allAssemblyTypes.Add(t.Name, t);
            }

            bool added = false;

            foreach (Type type in UsedTypes.ToArray())
            {
                if (!TypeIsWrapped(type))
                    throw new InvalidOperationException();

                if (!CompleteTypes.ContainsKey(type))
                {
                    var wci = new WrapperClassInfo(type, this);
                    CompleteTypes.Add(type, wci);

                    foreach (
                        Type inheritedType in
                            allAssemblyTypes.Values.Where(t => t.IsSubclassOf(wci.WrappedType) && t.IsPublic)
                                .Where(TypeIsWrapped))
                    {
                        if (inheritedType.GetCustomAttributes(typeof(ObsoleteAttribute), true).Count() == 0
                            && !UsedTypes.Contains(inheritedType))
                            UsedTypes.Add(inheritedType);
                    }

                    var sb = new StringBuilder();

                    if (wci.IsInterface)
                        wci.GenerateInterfaceCode(sb);
                    else
                        wci.GenerateClassCode(sb);

                    if (wci.FilePathBase.IndexOfAny(new[] { '\\', '/' }) != -1)
                        Directory.CreateDirectory(Path.GetDirectoryName(wci.FilePathBase));

                    WriteTextToFile(wci.FilePathBase + ".cs", sb.ToString(), true);

                    wci.GenerateUserClassFile();

                    added = true;
                }
            }

            return added;
        }
Ejemplo n.º 3
0
        public PrintingPage(string companyname, CompleteTypes alltypes, PrintSetting printersetting)
        {
            InitializeComponent();

            CompanyName = companyname;
            AllTypes    = alltypes;

            int heightindex = AllTypes.GetTypesNumber();

            this.Height = (heightindex + 1) * 58 + 72;

            this.DataContext = this;

            //Setup Print
            m_PrinterSetting = printersetting;
            string printerName = printersetting.PrinterName;


            if (AllTypes.Type1.IsChecked && int.Parse(AllTypes.Type1.Number) > 0)
            {
                m_Pd1            = new PrintDocument();
                m_Pd1.PrintPage += pd1_PrintPage;
                m_Pd1.PrinterSettings.Copies = short.Parse(AllTypes.Type1.Number);
                if (printerName != string.Empty)
                {
                    m_Pd1.PrinterSettings.PrinterName = printerName;
                }
            }

            if (AllTypes.Type2.IsChecked && int.Parse(AllTypes.Type2.Number) > 0)
            {
                m_Pd2            = new PrintDocument();
                m_Pd2.PrintPage += pd2_PrintPage;
                m_Pd2.PrinterSettings.Copies = short.Parse(AllTypes.Type2.Number);
                if (printerName != string.Empty)
                {
                    m_Pd2.PrinterSettings.PrinterName = printerName;
                }
            }

            if (AllTypes.Type3.IsChecked && int.Parse(AllTypes.Type3.Number) > 0)
            {
                m_Pd3            = new PrintDocument();
                m_Pd3.PrintPage += pd3_PrintPage;
                m_Pd3.PrinterSettings.Copies = short.Parse(AllTypes.Type3.Number);
                if (printerName != string.Empty)
                {
                    m_Pd3.PrinterSettings.PrinterName = printerName;
                }
            }

            if (AllTypes.Type4.IsChecked && int.Parse(AllTypes.Type4.Number) > 0)
            {
                m_Pd4            = new PrintDocument();
                m_Pd4.PrintPage += pd4_PrintPage;
                m_Pd4.PrinterSettings.Copies = short.Parse(AllTypes.Type4.Number);
                if (printerName != string.Empty)
                {
                    m_Pd4.PrinterSettings.PrinterName = printerName;
                }
            }

            if (AllTypes.Type5.IsChecked && int.Parse(AllTypes.Type5.Number) > 0)
            {
                m_Pd5            = new PrintDocument();
                m_Pd5.PrintPage += pd5_PrintPage;
                m_Pd5.PrinterSettings.Copies = short.Parse(AllTypes.Type5.Number);
                if (printerName != string.Empty)
                {
                    m_Pd5.PrinterSettings.PrinterName = printerName;
                }
            }

            if (AllTypes.Type6.IsChecked && int.Parse(AllTypes.Type6.Number) > 0)
            {
                m_Pd6            = new PrintDocument();
                m_Pd6.PrintPage += pd6_PrintPage;
                m_Pd6.PrinterSettings.Copies = short.Parse(AllTypes.Type6.Number);
                if (printerName != string.Empty)
                {
                    m_Pd6.PrinterSettings.PrinterName = printerName;
                }
            }

            if (AllTypes.Type7.IsChecked && AllTypes.Type7.Name != string.Empty && int.Parse(AllTypes.Type7.Number) > 0)
            {
                m_Pd7            = new PrintDocument();
                m_Pd7.PrintPage += pd7_PrintPage;
                m_Pd7.PrinterSettings.Copies = short.Parse(AllTypes.Type7.Number);
                if (printerName != string.Empty)
                {
                    m_Pd7.PrinterSettings.PrinterName = printerName;
                }
            }

            if (AllTypes.Addone)
            {
                m_PdOneMore            = new PrintDocument();
                m_PdOneMore.PrintPage += pdOneMore_PrintPage;
                m_PdOneMore.PrinterSettings.Copies = 1;
                if (printerName != string.Empty)
                {
                    m_PdOneMore.PrinterSettings.PrinterName = printerName;
                }
            }
        }