本文整理汇总了C#中Diagram.AddShape方法的典型用法代码示例。如果您正苦于以下问题:C# Diagram.AddShape方法的具体用法?C# Diagram.AddShape怎么用?C# Diagram.AddShape使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Diagram
的用法示例。
在下文中一共展示了Diagram.AddShape方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args)
{
string visioStencil = "sample.vss";
// Create a new diagram
Diagram diagram = new Diagram(visioStencil);
//Add a new rectangle shape
long shapeId = diagram.AddShape(
4.25, 5.5, 2, 1, @"Rectangle", 0);
Shape shape = diagram.Pages[0].Shapes.GetShape(shapeId);
shape.Text.Value.Add(new Txt(@"Rectangle text."));
//Add a new star shape
shapeId = diagram.AddShape(
2.0, 5.5, 2, 2, @"Star 7", 0);
shape = diagram.Pages[0].Shapes.GetShape(shapeId);
shape.Text.Value.Add(new Txt(@"Star text."));
//Add a new hexagon shape
shapeId = diagram.AddShape(
7.0, 5.5, 2, 2, @"Hexagon", 0);
shape = diagram.Pages[0].Shapes.GetShape(shapeId);
shape.Text.Value.Add(new Txt(@"Hexagon text."));
//Save the new diagram
diagram.Save("Drawing1.vdx", SaveFileFormat.VDX);
}
示例2: Main
public static void Main(string[] args)
{
// The path to the documents directory.
string dataDir = Path.GetFullPath("../../../Data/");
string visioStencil = dataDir + "Basic Shapes.vss";
// Create a new diagram.
Diagram diagram = new Diagram(visioStencil);
//Add a new rectangle shape.
long shapeId = diagram.AddShape(
4.25, 5.5, 2, 1, @"Rectangle", 0);
Shape shape = diagram.Pages[0].Shapes.GetShape(shapeId);
shape.Text.Value.Add(new Txt(@"Rectangle text."));
//Add a new star shape.
shapeId = diagram.AddShape(
2.0, 5.5, 2, 2, @"Star 7", 0);
shape = diagram.Pages[0].Shapes.GetShape(shapeId);
shape.Text.Value.Add(new Txt(@"Star text."));
//Add a new hexagon shape.
shapeId = diagram.AddShape(
7.0, 5.5, 2, 2, @"Hexagon", 0);
shape = diagram.Pages[0].Shapes.GetShape(shapeId);
shape.Text.Value.Add(new Txt(@"Hexagon text."));
//Save the new diagram.
diagram.Save(dataDir + "Drawing1.vdx", SaveFileFormat.VDX);
// Display Status.
System.Console.WriteLine("Diagram created and saved successfully.");
}
示例3: Run
public static void Run()
{
// ExStart:CreatingDiagramWithAspose
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_KnowledgeBase();
// Create a new diagram
Diagram diagram = new Diagram(dataDir + "Basic Shapes.vss");
// Add a new rectangle shape
long shapeId = diagram.AddShape(4.25, 5.5, 2, 1, @"Rectangle", 0);
Shape shape = diagram.Pages[0].Shapes.GetShape(shapeId);
shape.Text.Value.Add(new Txt(@"Rectangle text."));
// Add a new star shape
shapeId = diagram.AddShape(2.0, 5.5, 2, 2, @"Star 7", 0);
shape = diagram.Pages[0].Shapes.GetShape(shapeId);
shape.Text.Value.Add(new Txt(@"Star text."));
// Add a new hexagon shape
shapeId = diagram.AddShape(7.0, 5.5, 2, 2, @"Hexagon", 0);
shape = diagram.Pages[0].Shapes.GetShape(shapeId);
shape.Text.Value.Add(new Txt(@"Hexagon text."));
// Save the new diagram
diagram.Save(dataDir + "CreatingDiagramWithAspose_out.vdx", SaveFileFormat.VDX);
// ExEnd:CreatingDiagramWithAspose
}
示例4: Run
public static void Run()
{
// ExStart:ConnectVisioSubShapes
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_Shapes();
// Set sub shape ids
long shapeFromId = 2;
long shapeToId = 4;
// Load diagram
Diagram diagram = new Diagram(dataDir + "Drawing1.vsdx");
// Access a particular page
Page page = diagram.Pages.GetPage("Page-3");
// Initialize connector shape
Shape shape = new Shape();
shape.Line.EndArrow.Value = 4;
shape.Line.LineWeight.Value = 0.01388;
// Add shape
long connecter1Id = diagram.AddShape(shape, "Dynamic connector", page.ID);
// Connect sub-shapes
page.ConnectShapesViaConnector(shapeFromId, ConnectionPointPlace.Right, shapeToId, ConnectionPointPlace.Left, connecter1Id);
// Save Visio drawing
diagram.Save(dataDir + "ConnectVisioSubShapes_out.vsdx", SaveFileFormat.VSDX);
// ExEnd:ConnectVisioSubShapes
}
示例5: 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);
}
示例6: 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
}
示例7: 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
}
示例8: 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);
}