Esempio n. 1
0
 public static WordDocument MergeDocuments(WordDocument[] documents)
 {
     WordDocument result = new WordDocument();
     for (int i = 0; i < documents.Length; i++)
     {
         documents[i].doc.ActiveWindow.Selection.WholeStory();
         documents[i].doc.ActiveWindow.Selection.Copy();
         result.doc.ActiveWindow.Selection.Paste();
     }
     return result;
 }
Esempio n. 2
0
        public void WriteWordDoc(string fileName, TrackView trackView)
        {
            try
            {
                trackView.Lock();
                Track track = trackView.GetTrack();
                string templateName = Path.Combine(Path.GetDirectoryName(this.GetType().Assembly.Location), "docTemplate.dotx");

                List<TrackPointExt> points = track.GetTrackPoints();
                List<List<TrackPointExt>> pointsInFiles = new List<List<TrackPointExt>>();

                for (int i = 0; i * pointsPerFile < points.Count; i++)
                {
                    int count = (points.Count - (i + 1) * pointsPerFile >= 0) ? pointsPerFile : points.Count - i * pointsPerFile;
                    pointsInFiles.Add(points.GetRange(i * pointsPerFile, count));
                }

                int currentPercent = -1;
                for (int i = 0; i < pointsInFiles.Count; i++)
                {
                    WordDocument document = new WordDocument(templateName, false);
                    List<TrackPointExt> tempPoints = pointsInFiles[i];
                    for (int j = 0; j < tempPoints.Count; j++)
                    {
                        // событие изменения процентов
                        int processPointsCount = 0;
                        for (int k = 0; k < i; i++)
                        {
                            processPointsCount += pointsInFiles[i].Count;
                        }

                            processPointsCount = (j + processPointsCount) * 100 / points.Count;
                            if (processPointsCount > currentPercent)
                            {
                                OnChanged(processPointsCount);
                                currentPercent = processPointsCount;

                            }

                        //
                        string[] row = new string[6];
                        row[0] = j.ToString();
                        row[1] = tempPoints[j].Point.Y.ToString();
                        row[2] = tempPoints[j].Point.X.ToString();
                        row[3] = tempPoints[j].H.ToString();
                        row[4] = track.GetSpeed(j + i * pointsPerFile).ToString();
                        row[5] = tempPoints[j].Time.ToString();
                        document.AddDataToTable(1, row);
                    }
                    document.Save(fileName + i + ".doc");
                    document.CloseDocument();
                    document.Close();
                }
                trackView.Unlock();
            }
            catch (Exception ex)
            {
                trackView.Unlock();
                throw ex;
            }
        }
Esempio n. 3
0
 public void AddDocument(WordDocument document)
 {
     document.doc.ActiveWindow.Selection.WholeStory();
     document.doc.ActiveWindow.Selection.Copy();
     this.doc.ActiveWindow.Selection.Paste();
 }