本文整理汇总了C#中Diagram.AddMaster方法的典型用法代码示例。如果您正苦于以下问题:C# Diagram.AddMaster方法的具体用法?C# Diagram.AddMaster怎么用?C# Diagram.AddMaster使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Diagram
的用法示例。
在下文中一共展示了Diagram.AddMaster方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Run
public static void Run()
{
// ExStart:CopyShape
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_Shapes();
// Load a source Visio
Diagram srcVisio = new Diagram(dataDir + "Drawing1.vsdx");
// Initialize a new Visio
Diagram newDiagram = new Diagram();
// Add all masters from the source Visio diagram
MasterCollection originalMasters = srcVisio.Masters;
foreach (Master master in originalMasters)
newDiagram.AddMaster(srcVisio, master.Name);
// Get the page object from the original diagram
Aspose.Diagram.Page SrcPage = srcVisio.Pages.GetPage("Page-1");
// Copy themes from the source diagram
newDiagram.CopyTheme(srcVisio);
// Copy pagesheet of the source Visio page
newDiagram.Pages[0].PageSheet.Copy(SrcPage.PageSheet);
// Copy shapes from the source Visio page
foreach (Aspose.Diagram.Shape shape in SrcPage.Shapes)
{
newDiagram.Pages[0].Shapes.Add(shape);
}
// Save the new Visio
newDiagram.Save(dataDir + "CopyShapes_out.vsdx", SaveFileFormat.VSDX);
// ExEnd:CopyShape
}
示例2: Run
public static void Run()
{
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_Shapes();
string pageName = @"Page-1";
////////////// Modify time line ///////////
DateTime startDate = new DateTime(2015, 8, 1);
DateTime endDate = new DateTime(2016, 6, 1);
DateTime fisYear = startDate;
//Load a diagram
Diagram diagram = new Diagram(dataDir + "input.vdx");
//Get page
Aspose.Diagram.Page page = diagram.Pages.GetPage(pageName);
long timelineId = 1;
Shape timeline = diagram.Pages.GetPage(pageName).Shapes.GetShape(timelineId);
double xpos = timeline.XForm.PinX.Value;
double ypos = timeline.XForm.PinY.Value;
// Add milestone
string milestoneMasterName = "2 triangle milestone";
//Add Master
diagram.AddMaster(dataDir + "Timeline.vss", milestoneMasterName);
//Add Shape in Visio diagram using AddShape method
long milestoneShapeId = diagram.AddShape(xpos, ypos, milestoneMasterName, 0);
//Get the shape based on ID
Shape milestone = page.Shapes.GetShape(milestoneShapeId);
//Instantiate MilestoneHelper object
MilestoneHelper milestoneHelper = new MilestoneHelper(milestone);
//Set Milestone Date
milestoneHelper.MilestoneDate = new DateTime(2015, 8, 1);
//Set IsAutoUpdate to true
milestoneHelper.IsAutoUpdate = true;
//RefreshMilesone of timeline shape
milestoneHelper.RefreshMilestone(timeline);
//Save Visio file
diagram.Save(dataDir + "output.vdx", SaveFileFormat.VDX);
}
示例3: Run
public static void Run()
{
// ExStart:AddMasterFromStencil
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_Master();
// Load diagram
Diagram diagram = new Diagram();
// Load stencil to a stream
string templateFileName = dataDir + "NetApp-FAS-series.vss";
Stream stream = new FileStream(templateFileName, FileMode.Open);
// Add master with stencil file path and master id
string masterName = "FAS80xx rear empty";
diagram.AddMaster(templateFileName, 2);
// Add master with stencil file path and master name
diagram.AddMaster(templateFileName, masterName);
// Add master with stencil file stream and master id
diagram.AddMaster(stream, 2);
// Adds master to diagram from source diagram
Diagram src = new Diagram(templateFileName);
diagram.AddMaster(src, masterName);
// Add master with stencil file stream and master id
diagram.AddMaster(stream, masterName);
// Adds shape with defined PinX and PinY.
diagram.AddShape(2.0, 2.0, masterName, 0);
diagram.AddShape(6.0, 6.0, masterName, 0);
// Adds shape with defined PinX,PinY,Width and Height.
diagram.AddShape(7.0, 3.0, 1.5, 1.5, masterName, 0);
// ExEnd:AddMasterFromStencil
}
示例4: Run
public static void Run()
{
// ExStart:AddingNewShape
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_Shapes();
// Load a diagram
Diagram diagram = new Diagram(dataDir + "Drawing1.vsdx");
// Get page by name
Page page = diagram.Pages.GetPage("Page-2");
// Add master with stencil file path and master name
string masterName = "Rectangle";
diagram.AddMaster(dataDir + "Basic Shapes.vss", masterName);
// Page indexing starts from 0
int PageIndex = 1;
double width = 2, height = 2, pinX = 4.25, pinY = 4.5;
// Add a new rectangle shape
long rectangleId = diagram.AddShape(pinX, pinY, width, height, masterName, PageIndex);
// Set shape properties
Shape rectangle = page.Shapes.GetShape(rectangleId);
rectangle.XForm.PinX.Value = 5;
rectangle.XForm.PinY.Value = 5;
rectangle.Type = TypeValue.Shape;
rectangle.Text.Value.Add(new Txt("Aspose Diagram"));
rectangle.TextStyle = diagram.StyleSheets[3];
rectangle.Line.LineColor.Value = "#ff0000";
rectangle.Line.LineWeight.Value = 0.03;
rectangle.Line.Rounding.Value = 0.1;
rectangle.Fill.FillBkgnd.Value = "#ff00ff";
rectangle.Fill.FillForegnd.Value = "#ebf8df";
diagram.Save(dataDir + "AddShape_out.vsdx", SaveFileFormat.VSDX);
Console.WriteLine("Shape has been added.");
// ExEnd:AddingNewShape
}
示例5: Run
public static void Run()
{
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_Diagrams();
//Set license (you can add 10 shapes without setting a license)
//License lic = new License();
//lic.SetLicense(dataDir + "Aspose.Total.lic");
// Load masters from any existing diagram, stencil or template
// and add in the new diagram
string visioStencil = dataDir + "AddConnectShapes.vss";
//Names of the masters present in the stencil
string rectangleMaster = @"Rectangle", starMaster = @"Star 7",
hexagonMaster = @"Hexagon", connectorMaster = "Dynamic connector";
int pageNumber = 0;
double width = 2, height = 2, pinX = 4.25, pinY = 9.5;
// Create a new diagram
Diagram diagram = new Diagram(visioStencil);
//Add a new rectangle shape
long rectangleId = diagram.AddShape(
pinX, pinY, width, height, rectangleMaster, pageNumber);
//Set the new shape's properties
Shape shape = diagram.Pages[pageNumber].Shapes.GetShape(rectangleId);
shape.Text.Value.Add(new Txt(@"Rectangle text."));
shape.Name = "Rectangle1";
shape.XForm.LocPinX.Ufe.F = "Width*0.5";
shape.XForm.LocPinY.Ufe.F = "Height*0.5";
shape.Line.LineColor.Value = "7";
shape.Line.LineWeight.Value = 0.03;
shape.Fill.FillBkgnd.Value = "1";
shape.Fill.FillForegnd.Value = "3";
shape.Fill.FillPattern.Value = 31;
//Add a new star shape
pinX = 2.0;
pinY = 4.5;
long starId = diagram.AddShape(
pinX, pinY, width, height, starMaster, pageNumber);
//Set the star shape's properties
shape = diagram.Pages[pageNumber].Shapes.GetShape(starId);
shape.Text.Value.Add(new Txt(@"Star text."));
shape.Name = "Star1";
shape.XForm.LocPinX.Ufe.F = "Width*0.5";
shape.XForm.LocPinY.Ufe.F = "Height*0.5";
shape.Line.LineColor.Value = "#ff0000";
shape.Line.LineWeight.Value = 0.03;
shape.Fill.FillBkgnd.Value = "#ff00ff";
shape.Fill.FillForegnd.Value = "#0000ff";
shape.Fill.FillPattern.Value = 31;
//Add a new hexagon shape
pinX = 7.0;
long hexagonId = diagram.AddShape(
pinX, pinY, width, height, hexagonMaster, pageNumber);
//Set the hexagon shape's properties
shape = diagram.Pages[pageNumber].Shapes.GetShape(hexagonId);
shape.Text.Value.Add(new Txt(@"Hexagon text."));
shape.Name = "Hexagon1";
shape.XForm.LocPinX.Ufe.F = "Width*0.5";
shape.XForm.LocPinY.Ufe.F = "Height*0.5";
shape.Line.LineWeight.Value = 0.03;
shape.Fill.FillPattern.Value = 31;
//Add master to dynamic connector from the stencil
diagram.AddMaster(visioStencil, connectorMaster);
//Connect rectangle and star shapes
Shape connector1 = new Shape();
long connecter1Id = diagram.AddShape(connector1, connectorMaster, 0);
diagram.Pages[0].ConnectShapesViaConnector(rectangleId, ConnectionPointPlace.Bottom,
starId, ConnectionPointPlace.Top, connecter1Id);
//Connect rectangle and hexagon shapes
Shape connector2 = new Shape();
long connecter2Id = diagram.AddShape(connector2, connectorMaster, 0);
diagram.Pages[0].ConnectShapesViaConnector(rectangleId, ConnectionPointPlace.Bottom,
hexagonId, ConnectionPointPlace.Left, connecter2Id);
//Save the diagram
diagram.Save(dataDir + "Output.vdx", SaveFileFormat.VDX);
}