private void btnconvert_Click(object sender, EventArgs e)
        {
            if (lblsavepath.Text == "" || lblpath.Text == "")
            {
                MessageBox.Show("Please choose path relevant it", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            if (lstfiles.Items.Count == 0)
            {
                MessageBox.Show("There are no any bal files in choosen path", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            System.Windows.Forms.ListBox.ObjectCollection d1 = lstfiles.Items;

            file_list = new string[d1.Count];

            for (int i = 0; i < d1.Count; i++)
            {
                // MyListBoxItem ob = d1[i] as MyListBoxItem;
                //file_list[i] = ob.Message;
                file_list[i] = d1[i].ToString();
            }

            Convert();
        }
        void Gamilt(int k, ref System.Windows.Forms.ListBox.ObjectCollection Items)
        {
            int y  = Lib.arrPath[k - 1];
            int LL = 0;

            if (Nodes[y].Edge != null)
            {
                LL = Nodes[y].Edge.Length;
                for (int i = 0; i < LL; i++)
                {
                    int u = Nodes[y].Edge[i].numNode;
                    if (k == Nodes.Length + 1)
                    {
                        Lib.arrPath[k] = u;
                        Items.Add(SetPath(0)); // вывести путь
                    }
                    else
                    if (!Nodes[u].visit)
                    {
                        Lib.arrPath[k] = u;
                        Nodes[u].visit = true;     // отметить посещенный
                        Gamilt(k + 1, ref Items);
                        Nodes[u].visit = false;    // отметить посещенный
                    }
                }
            }
        }
        public static List <string> CheckSimiliarityInIModels(System.Windows.Forms.ListBox.ObjectCollection extractedModel, string modelsDirectoryPath)
        {
            List <string> similiariesList = new List <string>();

            try
            {
                string extractedModelStr = "";
                foreach (var value in extractedModel)
                {
                    extractedModelStr += Environment.NewLine + value.ToString();
                }
                DirectoryInfo md    = new DirectoryInfo(modelsDirectoryPath); //Assuming models' directory
                FileInfo[]    Files = md.GetFiles("*.ini");                   //Getting ini model files
                foreach (FileInfo model in Files)
                {
                    var    OpenFile     = new System.IO.StreamReader(model.FullName);
                    string learnedModel = OpenFile.ReadToEnd();

                    double similiariyPercentage = CheckSimiliarityIModel(extractedModelStr, learnedModel);
                    similiariesList.Add(similiariyPercentage.ToString() + ">>" + ExtractIModelNamefromINIData(learnedModel));
                }
            }
            catch { }

            return(similiariesList);
        }
        PopulateSourceColumnsCheckedListBox()
        {
            AssertValid();

            System.Windows.Forms.ListBox.ObjectCollection oItems =
                clbSourceColumns.Items;

            oItems.Clear();

            // Attempt to get the non-empty range of the active worksheet of the
            // selected source workbook.

            Range oNonEmptyRange;

            if (!TryGetSourceWorkbookNonEmptyRange(out oNonEmptyRange))
            {
                return;
            }

            Boolean bSourceColumnsHaveHeaders =
                cbxSourceColumnsHaveHeaders.Checked;

            // Get the first row and column of the non-empty range.

            Range oFirstRow = oNonEmptyRange.get_Resize(1, Missing.Value);
            Range oColumn   = oNonEmptyRange.get_Resize(Missing.Value, 1);

            Object [,] oFirstRowValues = ExcelUtil.GetRangeValues(oFirstRow);

            // Loop through the columns.

            Int32 iNonEmptyColumns = oNonEmptyRange.Columns.Count;
            Int32 iColumnOneBased  = oColumn.Column;

            for (Int32 i = 1; i <= iNonEmptyColumns; i++, iColumnOneBased++)
            {
                String sColumnLetter = ExcelUtil.GetColumnLetter(
                    ExcelUtil.GetRangeAddress((Range)oColumn.Cells[1, 1]));

                // Get the value of the column's first cell, if there is one.

                String sFirstCellValue;

                if (!ExcelUtil.TryGetNonEmptyStringFromCell(oFirstRowValues, 1,
                                                            i, out sFirstCellValue))
                {
                    sFirstCellValue = null;
                }

                String sItemText = GetSourceColumnItemText(sFirstCellValue,
                                                           sColumnLetter, bSourceColumnsHaveHeaders);

                oItems.Add(new ObjectWithText(iColumnOneBased, sItemText));

                // Move to the next column.

                oColumn = oColumn.get_Offset(0, 1);
            }
        }
Exemple #5
0
 public static System.Windows.Forms.ListBox.ObjectCollection get_ItemsTSS(
     System.Windows.Forms.ListBox target)
 {
     System.Windows.Forms.ListBox.ObjectCollection objColl = new System.Windows.Forms.ListBox.ObjectCollection(target);
     objColl.Add("Testing");
     objColl.Add("Testing1");
     objColl.Add("Testing2");
     return(objColl);
 }
 public static void writeCollectionToFile(string filePath, System.Windows.Forms.ListBox.ObjectCollection objectCollection)
 {
     using (StreamWriter file = new StreamWriter(@filePath))
     {
         foreach (var item in objectCollection)
         {
             file.WriteLine(item);
         }
     }
 }
 private void Shafle(System.Windows.Forms.ListBox.ObjectCollection Shaf)
 {
     for (int i = 0; i < Shaf.Count - 1; i++)
     {
         int    j    = Random.Next(i + 1, Shaf.Count);
         Object temp = Shaf[i];
         Shaf[i] = Shaf[j];
         Shaf[j] = temp;
     }
 }
Exemple #8
0
        void GamiltC(int k, ref System.Windows.Forms.ListBox.ObjectCollection Items)
        {
            int sum   = 0;
            int count = 0;
            int y     = Lib.arrPath[k - 1]; // номер узла
            int LL    = 0;

            if (Nodes[y].Edge != null)
            {
                LL = Nodes[y].Edge.Length;
                for (int i = 0; i < LL; i++)
                {
                    sum = Nodes[y].Edge[i].A;

                    int u = Nodes[y].Edge[i].numNode; // номер соседнего узла
                    if (k == Nodes.Length + 1)        // прошли по всем узлам
                    {
                        Lib.arrPath[k] = u;
                        int m = Test(y); // у узла "y" есть ребро, показыающее на begNode
                        if (m != -1)     // если цикл замкнут
                        {
                            sumDist += Nodes[y].Edge[m].A;
                            Items.Add(SetPath(sumDist)); // вывести путь

                            count++;
                            Program.formListBox.progressBar1.Value = count;
                            Program.formListBox.progressBar1.Refresh();

                            PathGam p = new PathGam();
                            p.sum = sumDist;
                            for (int j = 1; j < k; j++)
                            {
                                p.path.Add(Lib.arrPath[j]);
                            }
                            Lib.pathsGam.Add(p);

                            sumDist -= Nodes[y].Edge[m].A;
                            return;
                        }
                    }
                    else
                    if (!Nodes[u].visit)
                    {
                        Lib.arrPath[k] = u;
                        sumDist       += sum;
                        Nodes[u].visit = true;     // отметить посещенный

                        GamiltC(k + 1, ref Items);

                        sumDist       -= sum;
                        Nodes[u].visit = false;    // отменить посещенный
                    }
                }
            }
        }
        private MeasureData[] toArray(System.Windows.Forms.ListBox.ObjectCollection collection)
        {
            MeasureData[] data = new MeasureData[collection.Count];
            int           i    = 0;

            foreach (object o in collection)
            {
                data[i++] = o as MeasureData;
            }
            return(data);
        }
 public static IEnumerable <T> ToEnumerable <T>(this System.Windows.Forms.ListBox.ObjectCollection collection)
 {
     if (collection == null)
     {
         yield break;
     }
     foreach (var item in collection)
     {
         yield return((T)item);
     }
 }
Exemple #11
0
        /// <summary>
        /// 开始输出数据
        /// </summary>
        /// <remarks></remarks>
        public void btnExport_Click(object sender, EventArgs e)
        {
            if (!this.BackgroundWorker1.IsBusy)
            {
                //打开进行数据操作的Excel程序
                if (this.F_ExcelApp == null)
                {
                    this.F_ExcelApp = new Microsoft.Office.Interop.Excel.Application();
                }
                this.F_ExcelApp.DisplayAlerts = false;
                //一般情况下,默认是隐藏的,如果原来是打开的,则手动隐藏
                this.F_ExcelApp.Visible = false;
                //初始化错误列表
                this.F_ErrorList = new List <string>();

                //---------- 打开保存数据的工作簿,并提取其中的所有工作表 ----------------
                string strWorkBook_ExportedTo = this.txtbxSavePath.Text;
                try
                {
                    //If Me.F_WorkBook_ExportedTo Is Nothing Then
                    if (File.Exists(strWorkBook_ExportedTo))
                    {
                        F_WorkBook_ExportedTo = this.F_ExcelApp.Workbooks.Open(Filename:  strWorkBook_ExportedTo, UpdateLinks: false, ReadOnly: false);
                    }
                    else
                    {
                        F_WorkBook_ExportedTo = this.F_ExcelApp.Workbooks.Add();
                        F_WorkBook_ExportedTo.SaveAs(Filename:  strWorkBook_ExportedTo, FileFormat:
                                                     Microsoft.Office.Interop.Excel.XlFileFormat.xlOpenXMLWorkbook, CreateBackup:
                                                     false);
                    }
                }
                catch (Exception)
                {
                    MessageBox.Show("保存数据的工作簿打开出错,请检查或者关闭此工作簿。", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                listSheetNameInWkbk = new List <string>();
                foreach (Worksheet shtInWorkbook in F_WorkBook_ExportedTo.Worksheets)
                {
                    listSheetNameInWkbk.Add(shtInWorkbook.Name);
                }
                // -----------进行数据提取的工作簿对象数组------------------------
                System.Windows.Forms.ListBox.ObjectCollection WkbkItems = this.ListBoxDocuments.Items;
                int WorkbooksCount = WkbkItems.Count;
                arrDocPaths = new string[WorkbooksCount - 1 + 1];
                for (int i = 0; i <= WorkbooksCount - 1; i++)
                {
                    arrDocPaths[i] = WkbkItems[i].ToString();
                }
                StartExportData();
            }
        }
        internal void AddProcedureCodes(System.Windows.Forms.ListBox.ObjectCollection objectCollection)
        {
            apex_rules_procedure_codes arpc;

            foreach (string toAdd in objectCollection)
            {
                arpc                = new apex_rules_procedure_codes();
                arpc.rule_id        = id;
                arpc.procedure_code = toAdd;
                arpc.Save();
            }
        }
        public void AddInsuranceCompanyFilter(System.Windows.Forms.ListBox.ObjectCollection companyFilters)
        {
            apex_rules_companies arc;

            foreach (string toAdd in companyFilters)
            {
                arc              = new apex_rules_companies();
                arc.rule_id      = id;
                arc.company_info = toAdd;
                arc.Save();
            }
        }
        public void Gamilton(System.Windows.Forms.ListBox.ObjectCollection Items)
        {
            ClearVisit();
            int N  = Nodes.Length;
            int v0 = 0;

            Lib.arrPath[1] = v0;
            begNode        = v0;
            sumDist        = 0;
            VisitTrue(v0);                    // отметить посещенный
            Lib.pathsGam.Clear();
            GamiltC(2, ref Items);
        }
        internal void SaveFilters(System.Windows.Forms.ListBox.ObjectCollection filters)
        {
            // Clear the existing filters then add the new ones
            ExecuteNonQuery("DELETE FROM provider_eligibility_companies WHERE per_id = " + id);

            foreach (string aFilter in filters)
            {
                provider_eligibility_companies pec = new provider_eligibility_companies();
                pec.per_id           = id;
                pec.restriction_text = aFilter;
                pec.Save();
            }
        }
Exemple #16
0
        public Ark_Launch()
        {
            InitializeComponent();
            profiles = dummyBox.Items;
            int tmp = 0;

            profiles.AddRange(API.LoadProfile(ref tmp));
            foreach (string item in profiles)
            {
                profileSelector.Items.Add(item);
            }
            profileSelector.SelectedIndex = tmp;
        }
        internal void SaveFilters(System.Windows.Forms.ListBox.ObjectCollection filters)
        {
            // Clear the existing filters then add the new ones
            ExecuteNonQuery("DELETE FROM insurance_company_groups_filters WHERE icg_id = " + id);

            foreach (string aFilter in filters)
            {
                insurance_company_groups_filters icg = new insurance_company_groups_filters();
                icg.icg_id      = id;
                icg.filter_text = aFilter;
                icg.Save();
            }
        }
Exemple #18
0
        public Importer(IBaseWindow baseWin, ILangMan langMan, System.Windows.Forms.ListBox.ObjectCollection aLog)
        {
            fBase    = baseWin;
            fTree    = baseWin.Context.Tree;
            fLog     = aLog;
            fLangMan = langMan;

            NumbersType         = PersonNumbersType.pnKonovalov;
            CanNumbersType      = PersonNumbersType.pnUndefined;
            PersonLineSeparator = (char)0;
            SurnamesNormalize   = false;

            fPersonsList = new Dictionary <string, GEDCOMIndividualRecord>();
            fRawContents = new StringList();
        }
Exemple #19
0
 internal void InitExts(System.Windows.Forms.ListBox.ObjectCollection objectCollection)
 {
     this.FileExts.Clear();
     foreach (string ss in objectCollection)
     {
         string s = ss.Trim();
         if (this.FileExts.Contains(s))
         {
             continue;
         }
         else
         {
             this.FileExts.Add(s);
         }
     }
 }
        CheckAllSourceColumns
        (
            Boolean bSelect
        )
        {
            AssertValid();

            System.Windows.Forms.ListBox.ObjectCollection oItems =
                clbSourceColumns.Items;

            Int32 iItems = oItems.Count;

            for (Int32 i = 0; i < iItems; i++)
            {
                clbSourceColumns.SetItemChecked(i, bSelect);
            }
        }
Exemple #21
0
        private void editProfiles_Click(object sender, EventArgs e)
        {
            editor = new ProfileEditor();
            if (this.profiles != null)
            {
                editor.profiles.Items.AddRange(this.profiles);
            }
            editor.ShowDialog();
            this.profiles = editor.profiles.Items;
            profileSelector.Items.Clear();
            List <string> l = new List <string>();

            foreach (string item in profiles)
            {
                profileSelector.Items.Add(item);
                l.Add(item);
            }
            API.SaveData(l.ToArray(), 0);
        }
        btnRemoveSelected_Click
        (
            object sender,
            EventArgs e
        )
        {
            AssertValid();

            System.Windows.Forms.ListBox.ObjectCollection oItems =
                lbxMinimumValues.Items;

            System.Windows.Forms.ListBox.SelectedIndexCollection oSelectedIndices =
                lbxMinimumValues.SelectedIndices;

            Int32 iSelectedIndices = oSelectedIndices.Count;

            for (Int32 i = iSelectedIndices - 1; i >= 0; i--)
            {
                oItems.RemoveAt(oSelectedIndices[i]);
            }
        }
Exemple #23
0
 public static void AddRange <T>(this System.Windows.Forms.ListBox.ObjectCollection objectCollection, IEnumerable <T> collection)
 => objectCollection.AddRange(collection.Select(x => x as object).ToArray());
Exemple #24
0
        //---------------------------------------------------
        //-------------------Methodes------------------------
        //---------------------------------------------------

        public Boolean Init(String _ProjectName, String _ProjectPath,
                            CoronaGameProject.OrientationScreen _orientation,
                            int _width, int _height, String _scale, String _xAlign, String _yAlign, System.Windows.Forms.ListBox.ObjectCollection _imageSuffix, int _fps, Boolean _antialias,
                            String _AndroidVersionCode, System.Windows.Forms.ListBox.ObjectCollection _SupportedOrientation, System.Windows.Forms.ListBox.ObjectCollection _AndroidPermissions, String _CustomBuildName, Image _icon)
        {
            if (_ProjectName == "" || _ProjectPath == "")
            {
                return(false);
            }

            if (this.ProjectPath != null && this.ProjectName != null)
            {
                if (!(this.ProjectPath + "\\" + this.ProjectName + ".krp").Equals(this.ProjectPath + "\\" + _ProjectName.Replace(" ", "_") + ".krp"))
                {
                    if (File.Exists(this.ProjectPath + "\\" + this.ProjectName + ".krp"))
                    {
                        File.Move(this.ProjectPath + "\\" + this.ProjectName + ".krp", this.ProjectPath + "\\" + _ProjectName.Replace(" ", "_") + ".krp");
                    }

                    //Renommer le projet de ressource correspondant
                    string assetProjectsDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\Native-Software\\Asset Manager";
                    if (!Directory.Exists(assetProjectsDirectory))
                    {
                        Directory.CreateDirectory(assetProjectsDirectory);
                    }


                    if (File.Exists(assetProjectsDirectory + "\\" + this.ProjectName + "\\" + this.ProjectName + ".kres"))
                    {
                        File.Move(assetProjectsDirectory + "\\" + this.ProjectName + "\\" + this.ProjectName + ".kres",
                                  assetProjectsDirectory + "\\" + this.ProjectName + "\\" + _ProjectName.Replace(" ", "_") + ".kres");
                    }

                    if (Directory.Exists(assetProjectsDirectory + "\\" + this.ProjectName))
                    {
                        Directory.Move(assetProjectsDirectory + "\\" + this.ProjectName, assetProjectsDirectory + "\\" + _ProjectName.Replace(" ", "_"));
                    }
                }
            }

            this.ProjectName = _ProjectName.Replace(" ", "_");

            if (this.BuildFolderPath != null)
            {
                if (!this.BuildFolderPath.Equals(this.ProjectPath + "\\" + this.ProjectName))
                {
                    if (Directory.Exists(this.BuildFolderPath))
                    {
                        Directory.Move(this.BuildFolderPath, this.ProjectPath + "\\" + this.ProjectName);
                    }
                }
            }

            if (this.ProjectPath != null)
            {
                if (!this.ProjectPath.Equals(_ProjectPath))
                {
                    if (Directory.Exists(this.ProjectPath))
                    {
                        Directory.Move(this.ProjectPath, _ProjectPath);
                    }
                }
            }



            this.ProjectPath        = _ProjectPath;
            this.BuildFolderPath    = this.ProjectPath + "\\" + this.ProjectName;
            this.SourceFolderPath   = this.ProjectPath + "\\Sources";
            this.CgeProjectFilename = this.ProjectPath + "\\" + this.ProjectName + ".krp";
            this.Orientation        = _orientation;

            this.Icone = _icon;
            if (this.Icone == null)
            {
                this.Icone = Properties.Resources.Icon;
            }

            this.width  = _width;
            this.height = _height;
            this.scale  = _scale;

            if (_xAlign.Equals("center"))
            {
                this.ScreenXAlign = XScreenAlignment.center;
            }
            else if (_xAlign.Equals("left"))
            {
                this.ScreenXAlign = XScreenAlignment.left;
            }
            else if (_xAlign.Equals("right"))
            {
                this.ScreenXAlign = XScreenAlignment.right;
            }

            if (_yAlign.Equals("center"))
            {
                this.ScreenYAlign = YScreenAlignment.center;
            }
            else if (_yAlign.Equals("top"))
            {
                this.ScreenYAlign = YScreenAlignment.top;
            }
            else if (_yAlign.Equals("bottom"))
            {
                this.ScreenYAlign = YScreenAlignment.bottom;
            }

            if (_imageSuffix != null)
            {
                this.ImageSuffix.Clear();
                for (int i = 0; i < _imageSuffix.Count; i++)
                {
                    this.ImageSuffix.Add(_imageSuffix[i].ToString());
                }
            }

            this.fps                = _fps;
            this.antialias          = _antialias;
            this.AndroidVersionCode = _AndroidVersionCode;

            if (_SupportedOrientation != null)
            {
                this.SupportedOrientation.Clear();
                for (int i = 0; i < _SupportedOrientation.Count; i++)
                {
                    this.SupportedOrientation.Add(_SupportedOrientation[i].ToString());
                }
            }

            if (_AndroidPermissions != null)
            {
                this.AndroidPermissions.Clear();
                for (int i = 0; i < _AndroidPermissions.Count; i++)
                {
                    this.AndroidPermissions.Add(_AndroidPermissions[i].ToString());
                }
            }

            this.CustomBuildName = _CustomBuildName;


            return(true);
        }
        ///Version 1(I) model handling methods and algorithm
        #region MV1
        //ExtractIModelfromData
        //CheckSimiliarityInIModels
        //AddNewIModel
        public static List <string> ExtractIModelfromData(System.Windows.Forms.ListBox.ObjectCollection rawDataList)
        {
            List <string> Model = new List <string>();

            if (rawDataList.Count > 1)
            {
                Model.Add(">>Recogeometries prj data model version 1");
                //Model.Add(">>" + DateTime.UtcNow.ToLongDateString() + " " + DateTime.UtcNow.ToShortTimeString());
                string data0 = rawDataList[0].ToString();
                //Model.Add(data0);
                double lastChanges = 0;
                foreach (var rDdata1 in rawDataList)
                {
                    string data1 = rDdata1.ToString();
                    ///Modeling by changes
                    //>> -x : decreasing changes
                    //>> +x : increasing changes

                    ///Modeling by values
                    //>> .5 .6 .5 .5 .3 0 >> + - = - --
                    //>> .9 .9 .5 .3 .3 .9>> = -- -- = ++

                    try
                    {
                        double ddata0  = Convert.ToDouble(data0);
                        double ddata1  = Convert.ToDouble(data1);
                        double changes = 0;
                        if (ddata0 == -1)
                        {
                            changes = ddata1;
                        }
                        else if (ddata1 == -1)
                        {
                            changes = ddata0;
                        }
                        else
                        {
                            changes = (ddata0 - ddata1);
                        }

                        if (changes == 0)
                        {
                            Model.Add("=");
                        }
                        else if ((changes > 0) && changes == lastChanges)
                        {
                            Model.Add("+");
                        }
                        else if ((changes < 0) && changes == lastChanges)
                        {
                            Model.Add("-");
                        }
                        else if (changes > 0.1)
                        {
                            Model.Add("++");
                        }
                        else if (changes < -0.1)
                        {
                            Model.Add("--");
                        }
                        //else
                        //    Model.Add("?");

                        data0       = data1;
                        lastChanges = changes;
                    }
                    catch { }
                }
            }

            List <string> revisedModel = new List <string>();

            if (Model.Count > 1)
            {
                for (int i = 1; i < Model.Count - 1; i++)
                {
                    if (Model[i] != Model[i - 1])
                    {
                        revisedModel.Add(Model[i]);
                    }
                }
            }
            return(revisedModel);
        }
        /// <summary>
        /// 开始输出数据
        /// </summary>
        /// <remarks></remarks>
        public void btnExport_Click(object sender, EventArgs e)
        {
            if (!this.BkgWk_Extract.IsBusy)
            {
                //
                this.blnIsBeingExtracting = true;
                //打开进行数据操作的Excel程序
                if (this.F_ExcelApp == null)
                {
                    this.F_ExcelApp = new Microsoft.Office.Interop.Excel.Application();
                    this.F_ExcelApp.WorkbookBeforeClose += this.F_ExcelApp_WorkbookBeforeClose;
                    this.F_ExcelApp.DisplayAlerts        = false;
                    //一般情况下,默认是隐藏的,如果原来是打开的,则手动隐藏
                    this.F_ExcelApp.Visible = false;
                }

                //打开进行数据提取的Word程序
                if (this.F_WordApp == null)
                {
                    this.F_WordApp = new Microsoft.Office.Interop.Word.Application();
                    this.F_WordApp.DocumentBeforeClose += this.F_WordApp_DocumentBeforeClose;
                    this.F_WordApp.Visible              = false;
                }


                //初始化错误列表
                this.F_ErrorList = new List <string>();
                //
                string strWorkBook_ExportedTo = this.txtbxSavePath.Text;


                //---------- 打开保存数据的工作簿,并提取其中的所有工作表 ----------------
                List <string> listPointsTag       = new List <string>();
                List <string> listSheetNameInWkbk = new List <string>();
                try
                {
                    if (File.Exists(strWorkBook_ExportedTo))
                    {
                        F_WorkBook_ExportedTo = this.F_ExcelApp.Workbooks.Open(Filename:  strWorkBook_ExportedTo, UpdateLinks: false, ReadOnly: false);
                    }
                    else
                    {
                        F_WorkBook_ExportedTo = this.F_ExcelApp.Workbooks.Add();
                        F_WorkBook_ExportedTo.SaveAs(Filename:  strWorkBook_ExportedTo, FileFormat:
                                                     Microsoft.Office.Interop.Excel.XlFileFormat.xlOpenXMLWorkbook, CreateBackup:
                                                     false);
                    }
                    this.F_BufferSheet = this.F_WorkBook_ExportedTo.Worksheets.Add() as Worksheet;
                    //
                    object AllSheets = F_WorkBook_ExportedTo.Worksheets;
                    foreach (Worksheet shtInWorkbook in (IEnumerable)AllSheets)
                    {
                        listSheetNameInWkbk.Add(shtInWorkbook.Name);
                    }
                }
                catch (Exception)
                {
                    MessageBox.Show("保存数据的Word文档打开出错,请检查或者关闭此文档。", "Error",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                // ------------- 提取每一个工作表与Range范围的格式 -------------并返回DataGridView中的所有数据
                this.F_DicPointsInfo = SearchPointsInfo(this.F_WorkBook_ExportedTo);
                if (F_DicPointsInfo == null)
                {
                    return;
                }


                // -----------进行数据提取的Document对象数组------------------------
                System.Windows.Forms.ListBox.ObjectCollection DocItems = this.ListBoxDocuments.Items;
                int DocsCount = DocItems.Count;
                //记录DataGridView控件中所有数据的数组
                string[] arrDocsPath = new string[DocsCount - 1 + 1];
                for (int i = 0; i <= DocsCount - 1; i++)
                {
                    arrDocsPath[i] = DocItems[i].ToString();
                }

                // -----------------------------------
                //是否要分析出提取数据的工作簿中的日期数据
                bool blnParseDateFromFilePath = false;
                if (this.ChkboxParseDate.Checked)
                {
                    blnParseDateFromFilePath = true;
                }
                //不允许再更改提取日期的正则表达式
                this.ChkboxParseDate.Checked = false;
                // ---------------------- 开始提取数据 ---------------------
                ExportToWorksheet Export = new ExportToWorksheet(F_WorkBook_ExportedTo, arrDocsPath, blnParseDateFromFilePath, this.F_BufferSheet);
                this.BkgWk_Extract.RunWorkerAsync(Export);
            }
        }
Exemple #27
0
        public void imprimir(System.Drawing.Image imagem, string output, Conexao con, System.Windows.Forms.ListBox.ObjectCollection itens, Document doc)
        {
            doc = new Document(PageSize.A4);
            int  i      = 0;
            Font fonte  = FontFactory.GetFont("Arial", 10);
            Font fonteB = FontFactory.GetFont("Arial", 12, Font.BOLD);


            try
            {
                using (var fileStream = new System.IO.FileStream(output, System.IO.FileMode.Create, System.IO.FileAccess.Write, System.IO.FileShare.None))
                {
                    PdfWriter writer = PdfWriter.GetInstance(doc, fileStream);


                    using (NpgsqlConnection conn = new NpgsqlConnection(con.getConn()))
                    {
                        conn.Open();
                        doc.Open();
                        try
                        {
                            //Image.GetInstance(cabecalho, System.Drawing.Imaging.ImageFormat.Png);
                            Image pdfImage = Image.GetInstance(imagem, System.Drawing.Imaging.ImageFormat.Png);

                            pdfImage.ScaleToFit(510, 240);
                            //   pdfImage.SetAbsolutePosition(0,842);
                            doc.Add(pdfImage);
                        }
                        catch { MessageBox.Show("Sem cabeçalho"); }

                        //                 pdfImage.SetAbsolutePosition(Top);

                        foreach (Questao item in itens)
                        {
                            using (NpgsqlCommand cmd = new NpgsqlCommand("SELECT enunciado, resposta FROM questoes WHERE id = @id", conn))
                            {
                                cmd.Parameters.AddWithValue("id", Convert.ToInt32(itens[i].ToString()));

                                using (NpgsqlDataReader reader = cmd.ExecuteReader())
                                {
                                    while (reader.Read())
                                    {
                                        string titulo  = Convert.ToString(i + 1) + " - " + reader.GetString(0) + "\n\n";
                                        string questao = " \t\t " + reader.GetString(1) + "\n\n";

                                        Paragraph a = new Paragraph(titulo);
                                        Paragraph b = new Paragraph(questao);

                                        a.Font = fonteB;
                                        b.Font = fonte;

                                        doc.Add(a);
                                        doc.Add(b);
                                    }
                                }
                            }

                            i++;
                        }
                        doc.Close();
                    }
                }
            }
            catch { MessageBox.Show("Alguma coisa deu de errado"); }
        }