예제 #1
0
        async void SaverInterface.SaveToExcel(EntityCords entity)
        {
            await Task.Run(() =>
            {
                Microsoft.Office.Interop.Excel.Application excelApp = new Microsoft.Office.Interop.Excel.Application();
                Workbook excelWorkBook   = excelApp.Workbooks.Add();
                Worksheet excelWorkSheet = excelWorkBook.Worksheets.Add();

                List <double> CordsY = entity.GetListY();
                List <double> CordsT = entity.GetListT();

                int length = CordsT.Count();

                excelWorkSheet.Columns[1].Rows[1] = "Step";
                excelWorkSheet.Columns[2].Rows[1] = "T";
                excelWorkSheet.Columns[3].Rows[1] = "Y (T)";

                AddT(CordsT, excelWorkSheet);
                AddY(CordsY, excelWorkSheet);
                AddStep(length, excelWorkSheet);
                CreateChart(length, excelWorkSheet);


                excelWorkSheet.SaveAs(@"E:\courseWork\CourseProject\CourseWork\CourseWork\exports\excel.xlsx");
                excelApp.Quit();

                PlayDoneSound();
            });
        }
예제 #2
0
        private String CreateInfo(EntityCords entity)
        {
            String info = " R0 = " + entity.GetR() + "\n P = " + entity.GetP() + "\n b = " + entity.GetB() + "\n h = " + entity.GetH() +
                          "\n l = " + entity.GetL() + "\n E = " + entity.GetE() + "\n t0 = " + entity.GetT0() + "\n th = " + entity.GetTH() + "\n tk = " +
                          entity.GetTK();

            return(info);
        }
예제 #3
0
        //////////////////////////BUTTON CALCULATE/////////////////////////


        private void button1_Click(object sender, EventArgs e)
        {
            PlayClickSound();

            try
            {
                toolStripButton1.Enabled           = true;
                contextMenuStrip1.Enabled          = true;
                contextMenuStrip1.Items[0].Enabled = true;
                button2.Enabled = true;

                double r0 = ReadInfoFromTextBox(textBox1);
                double P  = ReadInfoFromTextBox(textBox2);
                double b  = ReadInfoFromTextBox(textBox3);
                double h  = ReadInfoFromTextBox(textBox4);
                double l  = ReadInfoFromTextBox(textBox5);
                double E  = ReadInfoFromTextBox(textBox6) * 10e10;
                double t0 = ReadInfoFromTextBox(textBox7);
                double tk = ReadInfoFromTextBox(textBox8);
                double th = ReadInfoFromTextBox(textBox9);

                entity = new EntityCords(r0, P, b, h, l, E, t0, tk, th);

                chart1.Series[0].Points.Clear();
                dataGridView1.Rows.Clear();
                entity.Clear();

                Calculate();

                button5.Enabled                    = true;
                toolStrip1.Items[2].Enabled        = true;
                contextMenuStrip1.Items[1].Enabled = true;
            }
            catch (Exception exception)
            {
                PlayExceptionSound();
                MessageBox.Show("Something wrong with \nyour input data.");
            }
        }
예제 #4
0
        async void SaverInterface.SaveToWord(EntityCords entity, System.Windows.Forms.DataVisualization.Charting.Chart chart)
        {
            SaveImage(chart);

            await Task.Run(() =>
            {
                Microsoft.Office.Interop.Word.Application oneWord = new Microsoft.Office.Interop.Word.Application();

                var oneDoc = oneWord.Documents.Add();

                var paragraphone = oneDoc.Content.Paragraphs.Add();

                String info             = CreateInfo(entity);
                paragraphone.Range.Text = info;

                oneWord.ActiveDocument.Sections[1].Headers[Microsoft.Office.Interop.Word.WdHeaderFooterIndex.wdHeaderFooterPrimary].Range.InlineShapes.AddPicture(@"E:\courseWork\CourseProject\CourseWork\CourseWork\pictures\graphic.png");

                oneDoc.SaveAs2(@"E:\courseWork\CourseProject\CourseWork\CourseWork\exports\word.docx");
                oneWord.Quit();

                PlayDoneSound();
            });
        }