private void button1_Click(object sender, EventArgs e) { List<DictionaryEntry> list = new List<DictionaryEntry>(); DataSet dsData = new DataSet(); dsData.ReadXml(@"..\..\..\..\..\..\Data\Orders.xml"); //Create word document Document document = new Document(); document.LoadFromFile(@"..\..\..\..\..\..\Data\Invoice.doc"); DictionaryEntry dictionaryEntry = new DictionaryEntry("Customer", string.Empty); list.Add(dictionaryEntry); dictionaryEntry = new DictionaryEntry("Order", "Customer_Id = %Customer.Customer_Id%"); list.Add(dictionaryEntry); document.MailMerge.ExecuteWidthNestedRegion(dsData, list); //Save doc file. document.SaveToFile("Sample.doc", FileFormat.Doc); //Launching the MS Word file. WordDocViewer("Sample.doc"); }
/// <summary> /// Basic setup -- stores references to the active document and PerformanceAdviser for later use /// </summary> /// <param name="performanceAdviser">The revit PerformanceAdviser class</param> /// <param name="document">The active document</param> public TestDisplayDialog(PerformanceAdviser performanceAdviser, Document document) { m_PerformanceAdviser = performanceAdviser; m_document = document; InitializeComponent(); this.FormBorderStyle = FormBorderStyle.Fixed3D; }
public DetectionForm(Document document, VSProject2 vsProject2, DTE2 dte, IAssemblyDetectionProvider assemblyDetectionProvider) { _vsProject2 = vsProject2; DocumentDetetionService = new DocumentDetetionService(document, vsProject2, dte, assemblyDetectionProvider); InitializeComponent(); }
public void AddDocument(Document d) { if (d == null) return; try { SampleGenericDelegate2<DocumentType[]> del = new SampleGenericDelegate2<DocumentType[]>(serverClient.GetAllDocumentType); IAsyncResult result = del.BeginInvoke(null, null); DocumentType[] list = del.EndInvoke(result); d.Type.Name = list.First(doc => doc.Id == d.Type.Id).Name; } catch (Exception e) { var info = new InfoForm(); info.Add(e.Message); info.ShowDialog(this); info.Dispose(); } int row = dataGridView1.Rows.Add(new object[] { d.id, d.code, d.emission_date.ToShortDateString(), d.expiration_date.ToShortDateString(), d.Type.Name, d.emission_local }); }
public DiagramControl() : base() { //double-buffering SetStyle(ControlStyles.AllPaintingInWmPaint, true); SetStyle(ControlStyles.DoubleBuffer, true); SetStyle(ControlStyles.UserPaint, true); SetStyle(ControlStyles.ResizeRedraw, true); //init the MVC Controller = new Controller(this);//the controller will create the model Controller.OnHistoryChange += new EventHandler<HistoryChangeEventArgs>(mController_OnHistoryChange); Controller.OnShowSelectionProperties += new EventHandler<SelectionEventArgs>(Controller_OnShowSelectionProperties); Controller.OnEntityAdded += new EventHandler<EntityEventArgs>(Controller_OnEntityAdded); Controller.OnEntityRemoved += new EventHandler<EntityEventArgs>(Controller_OnEntityRemoved); View = Controller.View; //the diagram document is the total serializable package Document = new Document(View.Model); TextEditor.Init(this); //menu menu = new ContextMenu(); View.OnCursorChange += new EventHandler<CursorEventArgs>(mView_OnCursorChange); this.AllowDrop = true; }
public Window() { InitializeComponent(); // // document // _document = new Document(this); _document.Width = _innerWidth; _document.Height = _innerHeight; this.Children.Add(_document); element = new Canvas(); //LineGeometry myLineGeometry = new LineGeometry(); //myLineGeometry.StartPoint = new Point(10, 20); //myLineGeometry.EndPoint = new Point(100, 130); //Path myPath = new Path(); //myPath.Stroke = Brushes.Black; //myPath.StrokeThickness = 1; //myPath.Data = myLineGeometry; //element.Children.Add(myPath); //this.Children.Add(element); this.Loaded += new RoutedEventHandler(Window_Loaded); //MouseUp += new MouseButtonEventHandler(Window_MouseUp); }
/// <summary> /// Recursively retrieve entire linked document /// hierarchy and return the resulting TreeNode /// structure. /// </summary> void GetChildren( Document mainDoc, ICollection<ElementId> ids, TreeNode parentNode ) { int level = parentNode.Level; foreach( ElementId id in ids ) { // Get the child information. RevitLinkType type = mainDoc.GetElement( id ) as RevitLinkType; string label = LinkLabel( type, level ); TreeNode subNode = new TreeNode( label ); Debug.Print( "{0}{1}", Indent( 2 * level ), label ); parentNode.Nodes.Add( subNode ); // Go to the next level. GetChildren( mainDoc, type.GetChildIds(), subNode ); } }
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { //setup class variables _dbDoc = commandData.Application.ActiveUIDocument.Document; _uiDoc = commandData.Application.ActiveUIDocument; //setup ScoreKeeper _scoreKeeper = new ScoreKeeper(_dbDoc); //Find out which game to play NewGameMenu menu = new NewGameMenu(); DialogResult result = menu.ShowDialog(); //check if they want to reset the scores //using a dialog result of No to trigger this. if (result == DialogResult.No) { _scoreKeeper.ResetScores(); return Result.Succeeded; } if (result != DialogResult.OK) return Result.Cancelled; //setup the game IGame game = SetupGame(menu.IsOnlineGame()); //run the game game.StartGame(); return Result.Succeeded; }
public async Task< IEnumerable<ICodeRegion>> GetRegions(Document document) { _documentText = getDocumentText(document); if (_documentText == null) return null; return GetRegions(_documentText); }
private void button1_Click(object sender, EventArgs e) { string fileName = OpenFile(); string fileMerge = OpenFile(); if ((!string.IsNullOrEmpty(fileName)) && (!string.IsNullOrEmpty(fileMerge))) { //Create word document Document document = new Document(); document.LoadFromFile(fileName,FileFormat.Doc); Document documentMerge = new Document(); documentMerge.LoadFromFile(fileMerge, FileFormat.Doc); foreach( Section sec in documentMerge.Sections) { document.Sections.Add(sec.Clone()); } //Save doc file. document.SaveToFile("Sample.doc", FileFormat.Doc); //Launching the MS Word file. WordDocViewer("Sample.doc"); } }
public static void AddDocument(Document doc) { _documents.Enqueue(doc); Debug.WriteLine($"Number of Documents: {_documents.Count}"); if (_hhook == IntPtr.Zero) SetEventHook(); }
/// <summary> /// Implement this method as an external command for Revit. /// </summary> /// <param name="commandData">An object that is passed to the external application /// which contains data related to the command, /// such as the application object and active view.</param> /// <param name="message">A message that can be set by the external application /// which will be displayed if a failure or cancellation is returned by /// the external command.</param> /// <param name="elements">A set of elements to which the external application /// can add elements that are to be highlighted in case of failure or cancellation.</param> /// <returns>Return the status of the external command. /// A result of Succeeded means that the API external method functioned as expected. /// Cancelled can be used to signify that the user cancelled the external operation /// at some point. Failure should be returned if the application is unable to proceed with /// the operation.</returns> public Autodesk.Revit.UI.Result Execute(Autodesk.Revit.UI.ExternalCommandData commandData, ref string message, Autodesk.Revit.DB.ElementSet elements) { Autodesk.Revit.UI.UIApplication application = commandData.Application; m_docment = application.ActiveUIDocument.Document; try { // user should select one slab firstly. if(application.ActiveUIDocument.Selection.Elements.Size == 0) { MessageBox.Show("Please select one slab firstly.", "Revit", MessageBoxButtons.OK, MessageBoxIcon.Warning); return Autodesk.Revit.UI.Result.Cancelled; } // get the selected slab and show its span direction ElementSet elementSet = application.ActiveUIDocument.Selection.Elements; ElementSetIterator elemIter = elementSet.ForwardIterator(); elemIter.Reset(); while (elemIter.MoveNext()) { Floor floor = elemIter.Current as Floor; if (floor != null) { GetSpanDirectionAndSymobls(floor); } } } catch(Exception ex) { message = ex.ToString(); return Autodesk.Revit.UI.Result.Failed; } return Autodesk.Revit.UI.Result.Succeeded; }
private void btnOK_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(this.txtSaveDir.Text) && !string.IsNullOrEmpty(this.txtProjectName.Text)) { string selectDir = this.txtSaveDir.Text.Trim(); string projectName = this.txtProjectName.Text.Trim(); string path = System.IO.Path.Combine(selectDir, this.txtProjectName.Text.Trim()); System.IO.Directory.CreateDirectory(path); DBGlobalService.ProjectFile = System.IO.Path.Combine(path, projectName+".xml"); //doc.SetSchemaLocation(GlobalService.ConfigXsd); if (!System.IO.File.Exists(DBGlobalService.ProjectFile)) { var stream = System.IO.File.Create(DBGlobalService.ProjectFile); stream.Close(); } var doc = new Document(); DBGlobalService.CurrentProjectDoc = doc; //doc.Load(GlobalService.ProjectFile); var prj = doc.CreateNode<ProjectType>(); doc.Root = prj; DBGlobalService.CurrentProject = prj; DBGlobalService.CurrentProject.Name = projectName ; doc.Save(DBGlobalService.ProjectFile); this.DialogResult = System.Windows.Forms.DialogResult.OK; this.Close(); } }
public void AddNodeFor(Document.DocumentPart part, bool refreshParent) { if (part is Document.Alert) { AddAlert(part as Document.Alert, null, refreshParent); } else if (part is Document.TestParameter) { AddTestParameter(part as Document.TestParameter, null, refreshParent); } else if (part is Document.AutomatedTest) { AddTest(part as Document.AutomatedTest, null, refreshParent); } else if (part is Document.Target) { AddTarget(part as Document.Target, null, refreshParent); } else if (part is Document.Project) { AddProject(part as Document.Project); } else throw new ApplicationException("Internal error: Invalid document part type: " + part.GetType().ToString()); }
public Dictionary<string, List<TermContainer>> getTestSpecificationDocTOC(Document doc, ApplicationClass app) { generateTOC(doc, app); Range tocRange = doc.TablesOfContents[1].Range; string[] tocContents = delimiterTOC(tocRange.Text); Dictionary<string, List<TermContainer>> dict = new Dictionary<string, List<TermContainer>>(); string chapter = ""; foreach (string s in tocContents) { if (isLevel1(s)) { chapter = s; dict.Add(s, new List<TermContainer>()); } else { if (isLevel2(s)) { TermContainer term = new TermContainer("", s, null); dict[chapter].Add(term); } } } return dict; }
protected override void New(Document doc) { eduBindingSource.AddNew(); var editForm = new XtraDictionaryEditEduForm(this, (List<municipality>)this.municipalityBindingSource.List, (List<edu_kind>)this.eduKindBindingSource.List, (edu)eduBindingSource.Current); editForm.Show(this.ParentForm); }
private void button1_Click(object sender, EventArgs e) { //Create word document Document document = new Document(); Section section = document.AddSection(); //page setup SetPage(section); //insert header and footer InsertHeaderAndFooter(section); //add content InsertContent(section); //encrypt document with password specified by textBox1 document.Encrypt(this.textBox1.Text); //Save doc file. document.SaveToFile("Sample.doc",FileFormat.Doc); //Launching the MS Word file. WordDocViewer("Sample.doc"); }
public static void beginCommand(Document doc, string strDomain, bool bForAllSystems = false, bool bFitlerUnCalculationSystems = false) { PressureLossReportHelper helper = PressureLossReportHelper.instance; UIDocument uiDocument = new UIDocument(doc); if (bFitlerUnCalculationSystems) { ElementSet calculationOnElems = new ElementSet(); int nTotalCount = getCalculationElemSet(doc, strDomain, calculationOnElems, uiDocument.Selection.Elements); if (calculationOnElems.Size == 0) {//No item can be calculated popupWarning(ReportResource.allItemsCaculationOff, TaskDialogCommonButtons.Close, TaskDialogResult.Close); return; } else if (calculationOnElems.Size < nTotalCount) {//Part of them can be calculated if (popupWarning(ReportResource.partOfItemsCaculationOff, TaskDialogCommonButtons.No | TaskDialogCommonButtons.Yes, TaskDialogResult.Yes) == TaskDialogResult.No) return; } helper.initialize(doc, calculationOnElems, strDomain); invokeCommand(doc, helper, bForAllSystems); } else { helper.initialize(doc, uiDocument.Selection.Elements, strDomain); invokeCommand(doc, helper, bForAllSystems); } }
public void changeFamiliesNames(Document doc) { //Gets the families Family familyNames = null; FilteredElementCollector collector = new FilteredElementCollector(doc); ICollection<Element> collection = collector.OfClass(typeof(Family)).ToElements(); ValueDictionary dictionaryList = new ValueDictionary(); var dictionary = dictionaryList.GetRenameFamilies(); using (Transaction t = new Transaction(doc)) { t.Start("new name"); foreach (Element e in collection) { familyNames = e as Family; string familyName = familyNames.Name; //Checks the dictionary and if found renames the family if (dictionary.ContainsKey(familyName)) { string value = dictionary[familyName]; familyNames.Name = value; count++; } } t.Commit(); string message = "Number of Families Renamed: "; MessageBox.Show(message + count.ToString()); } }
protected override void Save(Document doc) { if (this.CanSave(doc)) { this.munitEditControl.Save(); } }
public DocumentViewModel(Document document, IDocumentService documentService) { this.service = documentService; this.Model = document; this.mode = DocumentMode.Edit; this.IsBusy = false; }
public static void SaveShapeTemplates(ShapeTemplatesSet templates, string filepath) { string folder = Directory.GetParent(filepath).FullName; Document document = new Document("root"); DataElement templatesEl = document.RootElement.CreateChild("templates"); foreach(ShapeTemplate template in templates) { if(template is CircleTemplate) { SaveTemplate(templatesEl.CreateChild("circle"), folder, (CircleTemplate)template); } else if(template is ImageTemplate) { SaveTemplate(templatesEl.CreateChild("image"), folder, (ImageTemplate)template); } else if(template is RectTemplate) { SaveTemplate(templatesEl.CreateChild("rect"), folder, (RectTemplate)template); } else { throw new ArgumentException(); } } document.Save(filepath); }
private void button1_Click(object sender, EventArgs e) { //Create word document Document document = new Document(); Section section = document.AddSection(); //page setup SetPage(section); //insert header and footer InsertHeaderAndFooter(section); //add cover InsertCover(section); //insert a break code section = document.AddSection(); section.BreakCode = SectionBreakType.NewPage; //add content InsertContent(section); //Save doc file. document.SaveToFile("Sample.doc", FileFormat.Doc); //Launching the MS Word file. WordDocViewer("Sample.doc"); }
private void button1_Click(object sender, EventArgs e) { //Create word document Document document = new Document(); Section section = document.AddSection(); //the unit of all measures below is point, 1point = 0.3528 mm section.PageSetup.PageSize = PageSize.A4; section.PageSetup.Margins.Top = 72f; section.PageSetup.Margins.Bottom = 72f; section.PageSetup.Margins.Left = 89.85f; section.PageSetup.Margins.Right = 89.85f; //insert header and footer InsertHeaderAndFooter(section); addTable(section); //Save doc file. document.SaveToFile("Sample.doc",FileFormat.Doc); //Launching the MS Word file. WordDocViewer("Sample.doc"); }
private void button1_Click(object sender, EventArgs e) { //Create word document Document document = new Document(); Section section = document.AddSection(); section.PageSetup.PageSize = PageSize.A4; section.PageSetup.Margins.Top = 72f; section.PageSetup.Margins.Bottom = 72f; section.PageSetup.Margins.Left = 89.85f; section.PageSetup.Margins.Right = 89.85f; Paragraph paragraph = section.AddParagraph(); paragraph.Format.HorizontalAlignment = Spire.Doc.Documents.HorizontalAlignment.Left; paragraph.AppendPicture(ToPDF.Properties.Resources.Word); String p1 = "Microsoft Word is a word processor designed by Microsoft. " + "It was first released in 1983 under the name Multi-Tool Word for Xenix systems. " + "Subsequent versions were later written for several other platforms including " + "IBM PCs running DOS (1983), the Apple Macintosh (1984), the AT&T Unix PC (1985), " + "Atari ST (1986), SCO UNIX, OS/2, and Microsoft Windows (1989). "; String p2 = "Microsoft Office Word instead of merely Microsoft Word. " + "The 2010 version appears to be branded as Microsoft Word, " + "once again. The current versions are Microsoft Word 2010 for Windows and 2008 for Mac."; section.AddParagraph().AppendText(p1).CharacterFormat.FontSize = 14; section.AddParagraph().AppendText(p2).CharacterFormat.FontSize = 14; //Save doc file to pdf. document.SaveToFile("Sample.pdf", FileFormat.PDF); //Launching the pdf reader to open. FileViewer("Sample.pdf"); }
public static Document ResizeDocument(Document document, Size newSize, AnchorEdge edge, ColorBgra background) { Document newDoc = new Document(newSize.Width, newSize.Height); newDoc.ReplaceMetaDataFrom(document); for (int i = 0; i < document.Layers.Count; ++i) { Layer layer = (Layer)document.Layers[i]; if (layer is BitmapLayer) { Layer newLayer; try { newLayer = ResizeLayer((BitmapLayer)layer, newSize, edge, background); } catch (OutOfMemoryException) { newDoc.Dispose(); throw; } newDoc.Layers.Add(newLayer); } else { throw new InvalidOperationException("Canvas Size does not support Layers that are not BitmapLayers"); } } return newDoc; }
public PlaceInstancesForm( Document doc ) { InitializeComponent(); _doc = doc; _pts = null; }
private void InsertTemplate(Document document, string toInsert) { var textDocument = document.Object() as TextDocument; textDocument.StartPoint.CreateEditPoint(); textDocument.Selection.Insert(toInsert); }
/// <summary> /// A utility method to print preview and print an Aspose.Words document. /// </summary> internal static void Execute(Document document) { // This operation can take some time (for the first page) so we set the Cursor to WaitCursor. Cursor cursor = Cursor.Current; Cursor.Current = Cursors.WaitCursor; PrintPreviewDialog previewDlg = new PrintPreviewDialog(); // Initialize the Print Dialog with the number of pages in the document. PrintDialog printDlg = new PrintDialog(); printDlg.AllowSomePages = true; printDlg.PrinterSettings = new PrinterSettings(); printDlg.PrinterSettings.MinimumPage = 1; printDlg.PrinterSettings.MaximumPage = document.PageCount; printDlg.PrinterSettings.FromPage = 1; printDlg.PrinterSettings.ToPage = document.PageCount; // Restore cursor. Cursor.Current = cursor; // Interesting, but PrintDialog will not show and will always return cancel // if you run this application in 64-bit mode. if (!printDlg.ShowDialog().Equals(DialogResult.OK)) return; // Create the Aspose.Words' implementation of the .NET print document // and pass the printer settings from the dialog to the print document. AsposeWordsPrintDocument awPrintDoc = new AsposeWordsPrintDocument(document); awPrintDoc.PrinterSettings = printDlg.PrinterSettings; // Pass the Aspose.Words' print document to the .NET Print Preview dialog. previewDlg.Document = awPrintDoc; previewDlg.ShowDialog(); }
private void button1_Click(object sender, EventArgs e) { //Open a blank word document as template Document document = new Document(@"..\..\..\..\..\..\Data\Blank.doc"); //Get the first secition Section section = document.Sections[0]; //Create a new paragraph or get the first paragraph Paragraph paragraph = section.Paragraphs.Count > 0 ? section.Paragraphs[0] : section.AddParagraph(); //Append Text paragraph.AppendText("Builtin Style:"); foreach (BuiltinStyle builtinStyle in Enum.GetValues(typeof(BuiltinStyle))) { paragraph = section.AddParagraph(); //Append Text paragraph.AppendText(builtinStyle.ToString()); //Apply Style paragraph.ApplyStyle(builtinStyle); } //Save doc file. document.SaveToFile("Sample.doc",FileFormat.Doc); //Launching the MS Word file. WordDocViewer("Sample.doc"); }
public TextPatternTextSelectionChangedEvent(FragmentControlProvider provider) : base(provider, TextPatternIdentifiers.TextSelectionChangedEvent) { SWF.Document document = TextBoxBase.Document; selectionVisible = document.selection_visible; selectionStart = document.selection_start; selectionEnd = document.selection_end; }
private void OnSelectionChangedEvent(object sender, EventArgs args) { SWF.Document document = TextBoxBase.Document; if (!selectionVisible && !document.selection_visible) return; if (document.selection_visible != selectionVisible || document.selection_start != selectionStart || document.selection_end != selectionEnd) { RaiseAutomationEvent (); selectionVisible = document.selection_visible; selectionStart = document.selection_start; selectionEnd = document.selection_end; } }
public bool SetCaretOffset(int offset) { if (offset < 0) { return(false); } SWF.Document document = Document; int curPos = 0; SWF.Line line = null; for (int i = 1; i <= document.Lines; i++) { line = document.GetLine(i); int length = line.Text.ToString().Length; if (curPos + length >= offset) { document.PositionCaret(line, offset - curPos); return(true); } curPos += length; } return(false); }