public void SetPageOrientation(TargetPages targetpages, Models.PageOrientation orientation) { if (orientation != VisioScripting.Models.PageOrientation.Landscape && orientation != VisioScripting.Models.PageOrientation.Portrait) { throw new System.ArgumentOutOfRangeException(nameof(orientation), "must be either Portrait or Landscape"); } targetpages = targetpages.ResolveToPages(this._client); using (var undoscope = this._client.Undo.NewUndoScope(nameof(SetPageOrientation))) { foreach (var page in targetpages.Pages) { var old_orientation = PageCommands._get_page_orientation(page); if (old_orientation == orientation) { // don't need to do anything return; } var old_size = VisioAutomation.Pages.PageHelper.GetSize(page); double new_height = old_size.Width; double new_width = old_size.Height; var writer = new VisioAutomation.ShapeSheet.Writers.SrcWriter(); writer.SetValue(VisioAutomation.ShapeSheet.SrcConstants.PageWidth, new_width); writer.SetValue(VisioAutomation.ShapeSheet.SrcConstants.PageHeight, new_height); writer.SetValue(VisioAutomation.ShapeSheet.SrcConstants.PrintPageOrientation, (int)orientation); writer.Commit(page.PageSheet, CellValueType.Formula); } } }
public IVisio.Page NewPage(VisioScripting.TargetDocument targetdoc, VisioAutomation.Geometry.Size?size, bool isbackgroundpage) { targetdoc = targetdoc.ResolveToDocument(this._client); var pages = targetdoc.Document.Pages; IVisio.Page new_page; using (var undoscope = this._client.Undo.NewUndoScope(nameof(NewPage))) { new_page = pages.Add(); if (size.HasValue) { var targetpages = new TargetPages(new_page); this.SetPageSize(targetpages, size.Value); } if (isbackgroundpage) { new_page.Background = 1; } } return(new_page); }
public IVisio.Page NewPage(VisioAutomation.Geometry.Size?size, bool isbackgroundpage) { var cmdtarget = this._client.GetCommandTargetDocument(); var active_document = cmdtarget.ActiveDocument; var pages = active_document.Pages; IVisio.Page new_page; using (var undoscope = this._client.Undo.NewUndoScope(nameof(NewPage))) { new_page = pages.Add(); if (size.HasValue) { var targetpages = new TargetPages(new_page); this.SetPageSize(targetpages, size.Value); } if (isbackgroundpage) { new_page.Background = 1; } } return(new_page); }
public override void ConfigurePreTaskAction(AsyncTaskSequence sequence) { sequence.Add(() => s_logger.Info($"Start PageScrapping")); sequence.Add(() => s_logger.Info($" Title : {Title}")); sequence.Add(() => s_logger.Info($" MasterDirectory : {MasterDirectory}")); sequence.Add(() => s_logger.Info($" TargetPages : {TargetPages.ArrayToString()}")); }
public void DeletePages(TargetPages targetpages, bool renumber) { targetpages = targetpages.ResolveToPages(this._client); foreach (var page in targetpages.Pages) { page.Delete(renumber ? (short)1 : (short)0); } }
public void LayoutPage(TargetPages targetpages, VisioAutomation.Models.LayoutStyles.LayoutStyleBase layout) { targetpages = targetpages.ResolveToPages(this._client); using (var undoscope = this._client.Undo.NewUndoScope(nameof(SetPageSize))) { foreach (var page in targetpages.Pages) { layout.Apply(page); } } }
public void ResizePageToFitContents(TargetPages targetpages, VisioAutomation.Geometry.Size bordersize) { targetpages = targetpages.ResolveToPages(this._client); using (var undoscope = this._client.Undo.NewUndoScope(nameof(ResizePageToFitContents))) { foreach (var page in targetpages.Pages) { page.ResizeToFitContents(bordersize); } } }
public void SetPageBackground(TargetPages targetpages, string background_page_name) { if (background_page_name == null) { throw new System.ArgumentNullException(nameof(background_page_name)); } targetpages = targetpages.ResolveToPages(this._client); if (targetpages.Pages.Count < 1) { return; } var page0 = targetpages.Pages[0]; var doc = page0.Document; var doc_pages = doc.Pages; var names = new HashSet <string>(doc_pages.GetNamesU()); if (!names.Contains(background_page_name)) { string msg = string.Format("Could not find page with name \"{0}\"", background_page_name); throw new VisioAutomation.Exceptions.VisioOperationException(msg); } var bgpage = doc_pages.ItemU[background_page_name]; // Set the background page // Check that the intended background is indeed a background page if (bgpage.Background == 0) { string msg = string.Format("Page \"{0}\" is not a background page", bgpage.Name); throw new VisioAutomation.Exceptions.VisioOperationException(msg); } // don't allow the page to be set as a background to itself using (var undoscope = this._client.Undo.NewUndoScope(nameof(SetPageBackground))) { foreach (var page in targetpages.Pages) { if (page == bgpage) { string msg = "Cannot set page as its own background page"; throw new VisioAutomation.Exceptions.VisioOperationException(msg); } page.BackPage = bgpage; } } }
public override void ConfigureTaskImplementation(AsyncTaskSequence sequence) { TargetPages = TargetPages.OrderBy(a => a.Title, new NaturalStringComparer()).ToArray(); var workingDirectory = Configuration.ApplicationConfiguration.WorkingDirectory; var now = DateTime.Now; Guid entryNameSeedGuid = Guid.NewGuid(); var bookDir = entryNameSeedGuid.ToString("N"); var copyTo = workingDirectory + "\\" + MasterDirectory + "\\" + now.Year + "\\" + now.Month.ToString("00") + "\\" + now.Day.ToString("00") + "\\" + bookDir; //保存先ディレクトリ準備 if (!Directory.Exists(copyTo)) { Directory.CreateDirectory(copyTo); s_logger.Debug($"Create directory:{copyTo}"); } sequence.Add(new System.Threading.Tasks.Task(() => CreateBook(bookDir, Title))); var page = TargetPages.ElementAt(0); var img = page.Image; var destination = copyTo + "\\" + Path.GetFileName(img.AbsoluteMasterPath); AddTaskToProcessScrapPage(sequence, page, img, destination); sequence.Add(new System.Threading.Tasks.Task(() => SetFirstPage())); sequence.Add(new System.Threading.Tasks.Task(() => LibraryManager.Value.AddToMemory(NewBook))); //ファイルコピー for (int i = 1; i < TargetPages.Count(); ++i) { page = TargetPages.ElementAt(i); img = page.Image; destination = copyTo + "\\" + Path.GetFileName(img.AbsoluteMasterPath); AddTaskToProcessScrapPage(sequence, page, img, destination); } sequence.Add(new System.Threading.Tasks.Task(() => LibraryManager.Value.FireFillContents(NewBook))); sequence.Add(new System.Threading.Tasks.Task(() => s_logger.Info($"Pages Scrapped as:{NewBook}"))); sequence.Add(new System.Threading.Tasks.Task(() => SetContentsRegistered())); }
public void SetPageFormatCells(TargetPages targetpages, VisioAutomation.Pages.PageFormatCells cells) { targetpages = targetpages.ResolveToPages(this._client); using (var undoscope = this._client.Undo.NewUndoScope(nameof(SetPageFormatCells))) { foreach (var page in targetpages.Pages) { var writer = new VisioAutomation.ShapeSheet.Writers.SrcWriter(); writer.SetValues(cells); writer.BlastGuards = true; writer.Commit(page, CellValueType.Formula); } } }
public void SetPageSize(TargetPages targetpages, VisioAutomation.Geometry.Size new_size) { targetpages = targetpages.ResolveToPages(this._client); using (var undoscope = this._client.Undo.NewUndoScope(nameof(SetPageSize))) { foreach (var page in targetpages.Pages) { var page_sheet = page.PageSheet; var writer = new VisioAutomation.ShapeSheet.Writers.SrcWriter(); writer.SetValue(VisioAutomation.ShapeSheet.SrcConstants.PageWidth, new_size.Width); writer.SetValue(VisioAutomation.ShapeSheet.SrcConstants.PageHeight, new_size.Height); writer.Commit(page_sheet, CellValueType.Formula); } } }
public List <VisioAutomation.Geometry.Size> GetPageSize(TargetPages targetpages) { targetpages = targetpages.ResolveToPages(this._client); if (targetpages.Pages.Count < 1) { return(new List <VisioAutomation.Geometry.Size>(0)); } var sizes = new List <VisioAutomation.Geometry.Size>(targetpages.Pages.Count); foreach (var page in targetpages.Pages) { var size = VisioAutomation.Pages.PageHelper.GetSize(page); sizes.Add(size); } return(sizes); }
public VisioAutomation.Geometry.Size GetPageSize(TargetPages targetpages) { targetpages = targetpages.Resolve(this._client); if (targetpages.Pages.Count < 1) { throw new System.ArgumentException("No pages found"); } var query = new VisioAutomation.ShapeSheet.Query.CellQuery(); var col_height = query.Columns.Add(VisioAutomation.ShapeSheet.SrcConstants.PageHeight, nameof(VisioAutomation.ShapeSheet.SrcConstants.PageHeight)); var col_width = query.Columns.Add(VisioAutomation.ShapeSheet.SrcConstants.PageWidth, nameof(VisioAutomation.ShapeSheet.SrcConstants.PageWidth)); var cellqueryresult = query.GetResults <double>(targetpages.Pages[0].PageSheet); var row = cellqueryresult[0]; double height = row[col_height]; double width = row[col_width]; var s = new VisioAutomation.Geometry.Size(width, height); return(s); }
public ChangePageEvent(TargetPages target) { Target = target; }
private void ChangePageTo_Click(object sender, RoutedEventArgs e) { TargetPages target = (TargetPages)Enum.Parse(typeof(TargetPages), ((Button)sender).Name.Replace("btn", "").ToString()); ChangePageTo(this, new ChangePageEvent(target)); }
public Models.PageOrientation GetPageOrientation(TargetPages targetpages) { targetpages = targetpages.Resolve(this._client); return(PageCommands._GetPageOrientation(targetpages.Pages[0])); }