Esempio n. 1
0
        private bool LoadConfigFile(string FileName)
        {
            StreamReader SRObj = new StreamReader(FileName, System.Text.Encoding.GetEncoding("GBK"));
            try
            {
                if (SRObj.EndOfStream == false)
                {
                    //悼念
                    string FontClass = SRObj.ReadLine();

                    if (String.IsNullOrEmpty(FontClass) == false && FontColorTitleObj.FontObj != null)
                    {
                        if (SetFont(FontClass) != null)
                        {
                            FontColorTitleObj.FontObj = SetFont(FontClass);
                            SetFontColor(TitleButton, FontColorTitleObj.FontObj, FontColorTitleObj.ColorObj);
                        }
                    }
                }

                if (SRObj.EndOfStream == false)
                {
                    //LIST字体
                    string FontClass = SRObj.ReadLine();
                    if (String.IsNullOrEmpty(FontClass) == false)
                    {
                        if (SetFont(FontClass) != null)
                        {
                            FontColorDefault = new FontColorClass();
                            FontColorDefault.FontObj = SetFont(FontClass);
                            FontColorDefault.ColorObj = Color.Black;
                        }

                        if (FontColorList != null && FontColorList.Count > 0)
                        {
                            for (int i = 0; i < FontColorList.Count; i++)
                            {
                                if (FontColorList[i] != null)
                                {
                                    if (((FontColorClass)FontColorList[i]) != null)
                                    {
                                        if (FontColorDefault != null)
                                        {
                                            FontColorList[i] = FontColorDefault;
                                            GridViewSetFont(i, GridViewControl.ColumnCount - 1, ((FontColorClass)FontColorList[i]).FontObj);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }

                if (SRObj.EndOfStream == false)
                {
                    //敬挽
                    string FontClass = SRObj.ReadLine();
                    if (String.IsNullOrEmpty(FontClass) == false && FontColorTailObj.FontObj != null)
                    {
                        if (SetFont(FontClass) != null)
                        {
                            FontColorTailObj.FontObj = SetFont(FontClass);
                            SetFontColor(TailButton, FontColorTailObj.FontObj, FontColorTailObj.ColorObj);
                        }
                    }
                }

                if (SRObj.EndOfStream == false)
                {
                    //死者
                    string FontClass = SRObj.ReadLine();
                    if (String.IsNullOrEmpty(FontClass) == false && FontColorDeadManObj.FontObj != null)
                    {
                        if (SetFont(FontClass) != null)
                        {
                            FontColorDeadManObj.FontObj = SetFont(FontClass);
                            SetFontColor(DeadManButton, FontColorDeadManObj.FontObj, FontColorDeadManObj.ColorObj);
                        }
                    }
                }

                if (SRObj.EndOfStream == false)
                {
                    //称谓前
                    string FontClass = SRObj.ReadLine();
                    if (String.IsNullOrEmpty(FontClass) == false && FontColorFObj.FontObj != null)
                    {
                        if (SetFont(FontClass) != null)
                        {
                            FontColorFObj.FontObj = SetFont(FontClass);
                            SetFontColor(DeadManFButton, FontColorFObj.FontObj, FontColorFObj.ColorObj);
                        }
                    }
                }

                if (SRObj.EndOfStream == false)
                {
                    //称谓后
                    string FontClass = SRObj.ReadLine();
                    if (String.IsNullOrEmpty(FontClass) == false && FontColorTObj.FontObj != null)
                    {
                        if (SetFont(FontClass) != null)
                        {
                            FontColorTObj.FontObj = SetFont(FontClass);
                            SetFontColor(DeadManTButton, FontColorTObj.FontObj, FontColorTObj.ColorObj);
                        }
                    }
                }

                //边距
                if (SRObj.EndOfStream == false)
                {
                    string FontClass = SRObj.ReadLine();
                    if (String.IsNullOrEmpty(FontClass) == false && (IsFloatNumber(FontClass) || IsIntegerNumber(FontClass)))
                    {
                        TopSizeText1.Text = FontClass;
                    }
                }

                if (SRObj.EndOfStream == false)
                {
                    string FontClass = SRObj.ReadLine();
                    if (String.IsNullOrEmpty(FontClass) == false && (IsFloatNumber(FontClass) || IsIntegerNumber(FontClass)))
                    {
                        TopSizeText2.Text = FontClass;
                    }
                }

                if (SRObj.EndOfStream == false)
                {
                    string FontClass = SRObj.ReadLine();
                    if (String.IsNullOrEmpty(FontClass) == false && (IsFloatNumber(FontClass) || IsIntegerNumber(FontClass)))
                    {
                        Name12SizeText.Text = FontClass;
                    }
                }

                //姓名之间距离
                if (SRObj.EndOfStream == false)
                {
                    string FontClass = SRObj.ReadLine();
                    if (String.IsNullOrEmpty(FontClass) == false && (IsFloatNumber(FontClass) || IsIntegerNumber(FontClass)))
                    {
                        Text_NameSize.Text = FontClass;
                    }
                }

                //单,双行字体
                if (SRObj.EndOfStream == false)
                {
                    string FontClass = SRObj.ReadLine();
                    if (String.IsNullOrEmpty(FontClass) == false && FontColorDSObj1.FontObj != null)
                    {
                        if (SetFont(FontClass) != null)
                        {
                            FontColorDSObj1.FontObj = SetFont(FontClass);
                            SetFontColor(Button_SetDSFont1, FontColorDSObj1.FontObj, FontColorDSObj1.ColorObj);
                        }
                    }
                }

                if (SRObj.EndOfStream == false)
                {
                    string FontClass = SRObj.ReadLine();
                    if (String.IsNullOrEmpty(FontClass) == false && FontColorDSObj2.FontObj != null)
                    {
                        if (SetFont(FontClass) != null)
                        {
                            FontColorDSObj2.FontObj = SetFont(FontClass);
                            SetFontColor(Button_SetDSFont2, FontColorDSObj2.FontObj, FontColorDSObj2.ColorObj);
                        }
                    }
                }

                //序号X,Y 字体
                if (SRObj.EndOfStream == false)
                {
                    string FontClass = SRObj.ReadLine();
                    if (String.IsNullOrEmpty(FontClass) == false && (IsFloatNumber(FontClass) || IsIntegerNumber(FontClass)))
                    {
                        Text_SequenceX.Text = FontClass;
                    }
                }

                if (SRObj.EndOfStream == false)
                {
                    string FontClass = SRObj.ReadLine();
                    if (String.IsNullOrEmpty(FontClass) == false && (IsFloatNumber(FontClass) || IsIntegerNumber(FontClass)))
                    {
                        Text_SequenceY.Text = FontClass;
                    }
                }

                if (SRObj.EndOfStream == false)
                {
                    string FontClass = SRObj.ReadLine();
                    if (String.IsNullOrEmpty(FontClass) == false && FontColorSequenceObj.FontObj != null)
                    {
                        if (SetFont(FontClass) != null)
                        {
                            FontColorSequenceObj.FontObj = SetFont(FontClass);
                            SetFontColor(Button_SequenceFontColor, FontColorSequenceObj.FontObj, FontColorSequenceObj.ColorObj);
                        }
                    }
                }

                //行距(单)
                if (SRObj.EndOfStream == false)
                {
                    string FontClass = SRObj.ReadLine();
                    if (String.IsNullOrEmpty(FontClass) == false && (IsFloatNumber(FontClass) || IsIntegerNumber(FontClass)))
                    {
                        Text_Spacing1.Text = FontClass;
                    }
                }

                //行距(双)
                if (SRObj.EndOfStream == false)
                {
                    string FontClass = SRObj.ReadLine();
                    if (String.IsNullOrEmpty(FontClass) == false && (IsFloatNumber(FontClass) || IsIntegerNumber(FontClass)))
                    {
                        Text_Spacing2.Text = FontClass;
                    }
                }

                SRObj.Close();
                return true;
            }
            catch (Exception ex)
            {
                SRObj.Close();
                MessageBox.Show(ex.Message, "载入设置错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return false;
            }
        }
Esempio n. 2
0
        public MainFrame()
        {
            InitializeComponent();

            FontControl = new FontDialog();
            ColorControl = new ColorDialog();

            DeadSexComBoBox.SelectedIndex = 0;
            DeadManTimeText.Text = DateTime.Now.ToShortDateString();

            PrintDialogControl = new PrintDialog();
            PrintDocumentControl = new PrintDocument();
            PrintDocumentControl.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(this.PrintDocumentControl_PrintPage);
            PrintPreviewDialogControl = new PrintPreviewDialog();

            FontControl.Font = new Font("隶书", (float)40, FontStyle.Bold);
            ColorControl.Color = Color.Black;

            FontColorTitleObj = new FontColorClass();
            FontColorTitleObj.FontObj = new Font("隶书", (float)48, FontStyle.Bold);
            FontColorTitleObj.ColorObj = Color.Black;

            FontColorDeadManObj = new FontColorClass();
            FontColorDeadManObj.FontObj = FontControl.Font;
            FontColorDeadManObj.ColorObj = ColorControl.Color;

            BodyList = new ArrayList();
            FontColorList = new ArrayList();
            PrintList = new ArrayList();

            FontColorTailObj = new FontColorClass();
            FontColorTailObj.FontObj = new Font("隶书", (float)40, FontStyle.Bold);
            FontColorTailObj.ColorObj = Color.Black;

            FontColorFObj = new FontColorClass();
            FontColorFObj.FontObj = new Font("隶书", (float)40, FontStyle.Bold);
            FontColorFObj.ColorObj = Color.Black;

            FontColorTObj = new FontColorClass();
            FontColorTObj.FontObj = new Font("隶书", (float)40, FontStyle.Bold);
            FontColorTObj.ColorObj = Color.Black;

            FontColorDSObj1 = new FontColorClass();
            FontColorDSObj1.FontObj = new Font("隶书", (float)40, FontStyle.Bold);
            FontColorDSObj1.ColorObj = Color.Black;

            FontColorDSObj2 = new FontColorClass();
            FontColorDSObj2.FontObj = new Font("隶书", (float)40, FontStyle.Bold);
            FontColorDSObj2.ColorObj = Color.Black;

            FontColorSequenceObj = new FontColorClass();
            FontColorSequenceObj.FontObj = new Font("宋体", (float)10, FontStyle.Regular);
            FontColorSequenceObj.ColorObj = Color.Black;

            SetFontColor(TitleButton, FontColorTitleObj.FontObj, FontColorTitleObj.ColorObj);
            SetFontColor(DeadManButton, FontColorDeadManObj.FontObj, FontColorDeadManObj.ColorObj);
            SetFontColor(TailButton, FontColorTailObj.FontObj, FontColorTailObj.ColorObj);
            SetFontColor(DeadManFButton, FontColorFObj.FontObj, FontColorFObj.ColorObj);
            SetFontColor(DeadManTButton, FontColorTObj.FontObj, FontColorTObj.ColorObj);
            SetFontColor(Button_SetDSFont1, FontColorDSObj1.FontObj, FontColorDSObj1.ColorObj);
            SetFontColor(Button_SetDSFont2, FontColorDSObj2.FontObj, FontColorDSObj2.ColorObj);
            SetFontColor(Button_SequenceFontColor, FontColorSequenceObj.FontObj, FontColorSequenceObj.ColorObj);

            TopSizeText1.Text = "100";
            TopSizeText2.Text = "100";
            Text_NameSize.Text = "10";
            Name12SizeText.Text = "20";
            Text_SequenceX.Text = SequenceX.ToString();
            Text_SequenceY.Text = SequenceY.ToString();
            Text_Spacing1.Text = Spacing1.ToString();
            Text_Spacing2.Text = Spacing2.ToString();

            if (File.Exists(Application.StartupPath + "\\" + "default.txt"))
                LoadConfigFile(Application.StartupPath + "\\" + "default.txt");
        }
Esempio n. 3
0
        private bool InToExcel(string ExcelFile)
        {
            Excel.Application ExcelObj = null;

            try
            {
                ExcelObj = new Excel.ApplicationClass();
                ExcelObj.Visible = false;
                Excel.Workbook ExcelBook = ExcelObj.Workbooks._Open(ExcelFile, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value);
                Excel.Worksheet ExcelSheet = (Excel.Worksheet)ExcelBook.Sheets[1];

                //死者
                DeadManText.Text = ExcelCellToString(ExcelSheet.get_Range("B1", Type.Missing));

                //性别
                if (ExcelCellToString(ExcelSheet.get_Range("G1", Type.Missing)) == "男")
                    DeadSexComBoBox.SelectedIndex = 0;
                else
                    DeadSexComBoBox.SelectedIndex = 1;

                //出殡时间
                DeadManTimeText.Text = ExcelCellToDate(ExcelSheet.get_Range("B2", Type.Missing));

                //告别厅
                DeadManAddressText.Text = ExcelCellToString(ExcelSheet.get_Range("F2", Type.Missing));

                //列表用户
                if (GridViewControl.RowCount > 1)
                    GridViewControl.Rows.Clear();

                int i = 4;
                int j = 0;
                while (true)
                {
                    string Cell1 = ExcelCellToString((Excel.Range)ExcelSheet.Cells[i, 1]);
                    if (String.IsNullOrEmpty(Cell1))
                    {
                        break;
                    }
                    else
                    {
                        GridViewControl.Rows.Add();
                        GridViewControl.Rows[j].Cells[0].Value = Cell1;

                        //称谓(前)
                        string Cell2 = ExcelCellToString((Excel.Range)ExcelSheet.Cells[i, 2]);
                        GridViewControl.Rows[j].Cells[1].Value = Cell2;

                        //称谓(后)
                        string Cell3 = ExcelCellToString((Excel.Range)ExcelSheet.Cells[i, 3]);
                        GridViewControl.Rows[j].Cells[2].Value = Cell3;

                        //姓名1
                        string Cell4 = ExcelCellToString((Excel.Range)ExcelSheet.Cells[i, 4]);
                        GridViewControl.Rows[j].Cells[3].Value = Cell4;

                        //姓名2
                        string Cell5 = ExcelCellToString((Excel.Range)ExcelSheet.Cells[i, 5]);
                        GridViewControl.Rows[j].Cells[4].Value = Cell5;

                        //项目
                        string Cell6 = ExcelCellToString((Excel.Range)ExcelSheet.Cells[i, 6]);
                        GridViewControl.Rows[j].Cells[5].Value = Cell6;

                        //价钱
                        string Cell7 = ExcelCellToString((Excel.Range)ExcelSheet.Cells[i, 7]);
                        GridViewControl.Rows[j].Cells[6].Value = Cell7;

                        FontColorClass FontColorObj = new FontColorClass();
                        if (FontColorDefault == null)
                        {
                            FontColorObj.FontObj = new Font("隶书", (float)40, FontStyle.Bold);
                            FontColorObj.ColorObj = Color.Black;
                        }
                        else
                        {
                            FontColorObj = FontColorDefault;
                        }

                        FontColorList.Add(FontColorObj);

                        GridViewSetFont(j, GridViewControl.ColumnCount - 1, FontColorObj.FontObj);

                        i++;
                        j++;
                    }
                }

                ExcelSheet = null;
                ExcelBook.Close(false, false, false);
                ExcelBook = null;

                ExcelObj.Quit();
                ExcelObj = null;

                //合计
                TotalPriceText.Text = SumCellPrice(6).ToString();

                return true;
            }
            catch (Exception ex)
            {
                ExcelObj.Quit();
                ExcelObj = null;

                MessageBox.Show(ex.Message, "导入错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return false;
            }
        }
Esempio n. 4
0
        private void GridViewControl_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == GridViewControl.ColumnCount - 2)
            {
                string PriceString = GridViewCellToString(GridViewControl[e.ColumnIndex, e.RowIndex]);
                if (String.IsNullOrEmpty(PriceString) == false)
                {
                    if (IsFloatNumber(PriceString))
                        TotalPriceText.Text = SumCellPrice(6).ToString();
                    else
                    {
                        MessageBox.Show("请输入正确的金额", "请输入正确的金额", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        GridViewControl[e.ColumnIndex, e.RowIndex].Value = "";

                        return;
                    }
                }
            }

            if (e.ColumnIndex != GridViewControl.ColumnCount - 1 && e.RowIndex == FontColorList.Count)
            {
                FontColorClass FontColorObj = new FontColorClass();

                if (FontColorDefault == null)
                {
                    FontColorObj.FontObj = FontControl.Font;
                    FontColorObj.ColorObj = ColorControl.Color;
                }
                else
                {
                    FontColorObj = FontColorDefault;
                }

                FontColorList.Add(FontColorObj);

                GridViewSetFont(e.RowIndex, GridViewControl.ColumnCount - 1, FontColorObj.FontObj);
            }
        }
Esempio n. 5
0
        private void GridViewControl_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e)
        {
            if (GridViewControl.Rows[e.RowIndex].Cells[0].Value == null || String.IsNullOrEmpty(GridViewControl.Rows[e.RowIndex].Cells[0].Value.ToString()))
                GridViewControl.Rows[e.RowIndex].Cells[0].Value = Convert.ToString(e.RowIndex + 1);

            if (e.ColumnIndex == GridViewControl.ColumnCount - 1)
            {
                if (FontColorList.Count > e.RowIndex)
                {
                    FontControl.Font = ((FontColorClass)FontColorList[e.RowIndex]).FontObj;
                    ColorControl.Color = ((FontColorClass)FontColorList[e.RowIndex]).ColorObj;

                    FontControl.ShowDialog();
                    ColorControl.ShowDialog();

                    FontColorClass FontColorObj = new FontColorClass();
                    FontColorObj.FontObj = FontControl.Font;
                    FontColorObj.ColorObj = ColorControl.Color;

                    FontColorList[e.RowIndex] = FontColorObj;

                    GridViewSetFont(e.RowIndex, GridViewControl.ColumnCount - 1, FontColorObj.FontObj);
                    e.Cancel = true;
                }
                else
                    e.Cancel = true;
            }
        }
Esempio n. 6
0
        //Right
        public SizeF Print_Content_Right(string PrintString, FontColorClass FontColorObj, float PostionLR, float PrintY, int SpacingType, PrintPageEventArgs e)
        {
            SizeF PrintWH = new SizeF();
            if (PrintString.IndexOf("\n") == -1)
            {
                PrintWH = e.Graphics.MeasureString(PrintString, FontColorObj.FontObj);
                e.Graphics.DrawString(PrintString, FontColorObj.FontObj, new SolidBrush(FontColorObj.ColorObj), e.PageBounds.Width / 2 + PostionLR, PrintY, new StringFormat());
                PrintWH.Height += PrintY;
            }
            else
            {
                float Width = 0, Height = 0;
                string[] PrintString_Array = PrintString.Split(new string[] { "\n" }, StringSplitOptions.RemoveEmptyEntries);
                for (int i = 0; i < PrintString_Array.Length; i++)
                {
                    PrintWH = e.Graphics.MeasureString(PrintString_Array[i], FontColorObj.FontObj);
                    e.Graphics.DrawString(PrintString_Array[i], FontColorObj.FontObj, new SolidBrush(FontColorObj.ColorObj), e.PageBounds.Width / 2 + PostionLR, PrintY, new StringFormat());

                    Width = PrintWH.Width;
                    Height = PrintY + PrintWH.Height;

                    if (i < PrintString_Array.Length - 1)
                    {
                        if (SpacingType == 1)
                            Height += Spacing1;
                        else
                            Height += Spacing2;

                        PrintY = Height;
                    }
                }

                PrintWH.Width = Width;
                PrintWH.Height = Height;
            }

            return PrintWH;
        }