本文整理汇总了C#中Diagram类的典型用法代码示例。如果您正苦于以下问题:C# Diagram类的具体用法?C# Diagram怎么用?C# Diagram使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Diagram类属于命名空间,在下文中一共展示了Diagram类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Run
public static void Run()
{
try
{
// ExStart:ExportToSWFWithoutViewer
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_Diagrams();
// Instantiate Diagram Object and open VSD file
Diagram diagram = new Diagram(dataDir + "ExportToSWFWithoutViewer.vsd");
// Instantiate the Save Options
SWFSaveOptions options = new SWFSaveOptions();
// Set Save format as SWF
options.SaveFormat = SaveFileFormat.SWF;
// Exclude the embedded viewer
options.ViewerIncluded = false;
// Save the resultant SWF file
diagram.Save(dataDir + "ExportToSWFWithoutViewer_out.swf", SaveFileFormat.SWF);
// ExEnd:ExportToSWFWithoutViewer
}
catch (System.Exception ex)
{
System.Console.WriteLine(ex.Message + "\nThis example will only work if you apply a valid Aspose License. You can purchase full license or get 30 day temporary license from http:// Www.aspose.com/purchase/default.aspx.");
}
}
示例2: Run
public static void Run()
{
// ExStart:SetShapeTextPositionAtBottom
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_ShapeTextBoxData();
// Load source Visio diagram
Diagram diagram = new Diagram(dataDir + "Drawing1.vsdx");
// Get shape
long shapeid = 1;
Shape shape = diagram.Pages.GetPage("Page-1").Shapes.GetShape(shapeid);
// Set text position at the bottom,
// TxtLocPinY = "TxtHeight*1" and TxtPinY = "Height*0"
shape.TextXForm.TxtLocPinY.Value = shape.TextXForm.TxtHeight.Value;
shape.TextXForm.TxtPinY.Value = 0;
// Set orientation angle
double angleDeg = 0;
double angleRad = (Math.PI / 180) * angleDeg;
shape.TextXForm.TxtAngle.Value = angleRad;
// Save Visio diagram in the local storage
diagram.Save(dataDir + "SetShapeTextPositionAtBottom_out.vsdx", SaveFileFormat.VSDX);
// ExEnd:SetShapeTextPositionAtBottom
}
示例3: Run
public static void Run()
{
// ExStart:UseDiagramSaveOptions
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_LoadSaveConvert();
// Call the diagram constructor to a VSDX diagram
Diagram diagram = new Diagram(dataDir + "Drawing1.vsdx");
// Options when saving a diagram into Visio format
DiagramSaveOptions options = new DiagramSaveOptions(SaveFileFormat.VSDX);
// Summary:
// When characters in the diagram are unicode and not be set with correct font
// value or the font is not installed locally, they may appear as block,
// image or XPS. Set the DefaultFont such as MingLiu or MS Gothic to show these
// characters.
options.DefaultFont = "MS Gothic";
// Summary:
// Defines whether need enlarge page to fit drawing content or not.
// Remarks:
// Default value is false.
options.AutoFitPageToDrawingContent = true;
diagram.Save(dataDir + "UseDiagramSaveOptions_out.vsdx", options);
// ExEnd:UseDiagramSaveOptions
}
示例4: Run
public static void Run()
{
// ExStart:CalculateCenterOfSubShapes
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_Shapes();
// Load Visio diagram
Diagram diagram = new Diagram(dataDir + "Drawing1.vsdx");
// Get a group shape by ID and page index is 0
Shape shape = diagram.Pages[0].Shapes.GetShape(795);
// Get a sub-shape of the group shape by id
Shape subShape = shape.Shapes.GetShape(794);
Matrix m = new Matrix();
// Apply the translation vector
m.Translate(-(float)subShape.XForm.LocPinX.Value, -(float)subShape.XForm.LocPinY.Value);
// Set the elements of that matrix to a rotation
m.Rotate((float)subShape.XForm.Angle.Value);
// Apply the translation vector
m.Translate((float)subShape.XForm.PinX.Value, (float)subShape.XForm.PinY.Value);
// Get pinx and piny
double pinx = m.OffsetX;
double piny = m.OffsetY;
// Calculate the sub-shape pinx and piny
double resultx = shape.XForm.PinX.Value - shape.XForm.LocPinX.Value - pinx;
double resulty = shape.XForm.PinY.Value - shape.XForm.LocPinY.Value - piny;
// ExEnd:CalculateCenterOfSubShapes
}
示例5: Run
public static void Run()
{
// ExStart:AddHyperlinkToShape
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_Hyperlinks();
// Load source Visio diagram
Diagram diagram = new Diagram(dataDir + "Drawing1.vsdx");
// Get page by name
Page page = diagram.Pages.GetPage("Page-1");
// Get shape by ID
Shape shape = page.Shapes.GetShape(2);
// Initialize Hyperlink object
Hyperlink hyperlink = new Hyperlink();
// Set address value
hyperlink.Address.Value = "http:// Www.google.com/";
// Set sub address value
hyperlink.SubAddress.Value = "Sub address here";
// Set description value
hyperlink.Description.Value = "Description here";
// Set name
hyperlink.Name = "MyHyperLink";
// Add hyperlink to the shape
shape.Hyperlinks.Add(hyperlink);
// Save diagram to local space
diagram.Save(dataDir + "AddHyperlinkToShape_out.vsdx", SaveFileFormat.VSDX);
// ExEnd:AddHyperlinkToShape
}
示例6: Main
static void Main(string[] args)
{
//Save the uploaded file as PDF
Diagram diagram = new Diagram("Drawing1.vsd");
//Find a particular shape and update its properties
foreach (Aspose.Diagram.Shape shape in diagram.Pages[0].Shapes)
{
if (shape.Name.ToLower() == "process1")
{
shape.Text.Value.Clear();
shape.Text.Value.Add(new Txt("Hello World"));
//Find custom style sheet and set as shape's text style
foreach (StyleSheet styleSheet in diagram.StyleSheets)
{
if (styleSheet.Name == "CustomStyle1")
{
shape.TextStyle = styleSheet;
}
}
//Set horizontal and vertical position of the shape
shape.XForm.PinX.Value = 5;
shape.XForm.PinY.Value = 5;
//Set height and width of the shape
shape.XForm.Height.Value = 2;
shape.XForm.Width.Value = 3;
}
}
//Save shape as VDX
diagram.Save("Drawing1.vdx", SaveFileFormat.VDX);
}
示例7: saveDiagram
public String saveDiagram( Diagram diagram,
string author, string password)
{
this.author = author;
this.password = password;
return this.saveDiagram(diagram);
}
示例8: 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);
}
示例9: Run
public static void Run()
{
// ExStart:SettingCellsInEventSection
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_EventSection();
// Load diagram
Diagram diagram = new Diagram(dataDir + "TestTemplate.vsdm");
// Get page
Aspose.Diagram.Page page = diagram.Pages.GetPage(0);
// Get shape id
long shapeId = page.AddShape(3.0, 3.0, 0.36, 0.36, "Square");
// Get shape
Aspose.Diagram.Shape shape = page.Shapes.GetShape(shapeId);
// Set event cells in the ShapeSheet
shape.Event.EventXFMod.Ufe.F = "CALLTHIS(\"ThisDocument.ShowAlert\")";
shape.Event.EventDblClick.Ufe.F = "CALLTHIS(\"ThisDocument.ShowAlert\")";
shape.Event.EventDrop.Ufe.F = "CALLTHIS(\"ThisDocument.ShowAlert\")";
shape.Event.EventMultiDrop.Ufe.F = "CALLTHIS(\"ThisDocument.ShowAlert\")";
shape.Event.TheText.Ufe.F = "CALLTHIS(\"ThisDocument.ShowAlert\")";
shape.Event.TheData.Ufe.F = "CALLTHIS(\"ThisDocument.ShowAlert\")";
// Save diagram
diagram.Save(dataDir + "SettingCellsInEventSection_out.vsdm", SaveFileFormat.VSDM);
// ExEnd:SettingCellsInEventSection
}
示例10: Main
public static void Main(string[] args)
{
// The path to the documents directory.
string dataDir = Path.GetFullPath("../../../Data/");
//Call the diagram constructor to load diagram from a VSD file
Diagram diagram = new Diagram(dataDir + "drawing.vsd");
//enter page index i.e. 0 for first one
foreach (Shape shape in diagram.Pages[0].Shapes)
{
//Filter shapes by type Foreign
if (shape.Type == Aspose.Diagram.TypeValue.Foreign)
{
using (System.IO.MemoryStream stream = new System.IO.MemoryStream(shape.ForeignData.Value))
{
//Load memory stream into bitmap object
System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(stream);
// save bmp here
bitmap.Save(dataDir + "Image" + shape.ID + ".bmp");
}
}
}
}
示例11: 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.");
}
示例12: Run
public static void Run()
{
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_Diagrams();
string fileName = "LayOutShapesInFlowchartStyle.vdx";
Diagram diagram = new Diagram(dataDir + fileName);
LayoutOptions flowChartOptions = new LayoutOptions();
flowChartOptions.LayoutStyle = LayoutStyle.FlowChart;
flowChartOptions.SpaceShapes = 1f;
flowChartOptions.EnlargePage = true;
flowChartOptions.Direction = LayoutDirection.BottomToTop;
diagram.Layout(flowChartOptions);
diagram.Save(dataDir + "sample_btm_top.vdx", SaveFileFormat.VDX);
diagram = new Diagram(dataDir + fileName);
flowChartOptions.Direction = LayoutDirection.TopToBottom;
diagram.Layout(flowChartOptions);
diagram.Save(dataDir + "sample_top_btm.vdx", SaveFileFormat.VDX);
diagram = new Diagram(dataDir + fileName);
flowChartOptions.Direction = LayoutDirection.LeftToRight;
diagram.Layout(flowChartOptions);
diagram.Save(dataDir + "sample_left_right.vdx", SaveFileFormat.VDX);
diagram = new Diagram(dataDir + fileName);
flowChartOptions.Direction = LayoutDirection.RightToLeft;
diagram.Layout(flowChartOptions);
diagram.Save(dataDir + "sample_right_left.vdx", SaveFileFormat.VDX);
}
示例13: Run
public static void Run()
{
// ExStart:SetVisioProperties
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_Intro();
// Build path of an existing diagram
string visioDrawing = dataDir + "Drawing1.vsdx";
// Call the diagram constructor to load diagram from a VSDX file
Diagram diagram = new Diagram(visioDrawing);
// Set some summary information about the diagram
diagram.DocumentProps.Creator = "Ijaz";
diagram.DocumentProps.Company = "Aspose";
diagram.DocumentProps.Category = "Drawing 2D";
diagram.DocumentProps.Manager = "Sergey Polshkov";
diagram.DocumentProps.Title = "Aspose Title";
diagram.DocumentProps.TimeCreated = DateTime.Now;
diagram.DocumentProps.Subject = "Visio Diagram";
diagram.DocumentProps.Template = "Aspose Template";
// Write the updated file to the disk in VSDX file format
diagram.Save(dataDir + "SetVisioProperties_out.vsdx", SaveFileFormat.VSDX);
// ExEnd:SetVisioProperties
}
示例14: Run
public static void Run()
{
// ExStart:GroupShapes
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_Shapes();
// Load a Visio diagram
Diagram diagram = new Diagram(dataDir + "Drawing1.vsdx");
// Get page by name
Page page = diagram.Pages.GetPage("Page-3");
// Initialize an array of shapes
Aspose.Diagram.Shape[] ss = new Aspose.Diagram.Shape[3];
// Extract and assign shapes to the array
ss[0] = page.Shapes.GetShape(15);
ss[1] = page.Shapes.GetShape(16);
ss[2] = page.Shapes.GetShape(17);
// Mark array shapes as group
page.Shapes.Group(ss);
// Save visio diagram
diagram.Save(dataDir + "GroupShapes_out.vsdx", SaveFileFormat.VSDX);
// ExEnd:GroupShapes
}
示例15: Run
public static void Run()
{
// ExStart:RetrieveUserDefinedCells
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_UserDefinedCells();
int count = 0;
// Load diagram
Diagram diagram = new Diagram(dataDir + "Drawing1.vsdx");
// Iterate through pages
foreach (Aspose.Diagram.Page objPage in diagram.Pages)
{
// Iterate through shapes
foreach (Aspose.Diagram.Shape objShape in objPage.Shapes)
{
Console.WriteLine(objShape.NameU);
// Iterate through user-defined cells
foreach (Aspose.Diagram.User objUserField in objShape.Users)
{
count++;
Console.WriteLine(count + " - Name: " + objUserField.NameU + " Value: " + objUserField.Value.Val + " Prompt: " + objUserField.Prompt.Value);
}
}
}
// ExEnd:RetrieveUserDefinedCells
}