本文整理汇总了C#中Project.Open方法的典型用法代码示例。如果您正苦于以下问题:C# Project.Open方法的具体用法?C# Project.Open怎么用?C# Project.Open使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Project
的用法示例。
在下文中一共展示了Project.Open方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BaseTest
public void BaseTest() {
// -- Create a project --
Project project = new Project();
project.Name = "Test";
project.Repository = new CachedRepository();
((CachedRepository)project.Repository).Store = RepositoryHelper.CreateXmlStore();
project.Repository.Erase();
project.Create();
project.AddLibrary(typeof(Dataweb.NShape.GeneralShapes.Circle).Assembly);
//
Diagram diagram = new Diagram("All Shapes");
diagram.Width = 800;
diagram.Height = 600;
project.Repository.InsertDiagram(diagram);
int x = 0;
int shapeCount = 0;
foreach (ShapeType st in project.ShapeTypes) {
x += 50;
Shape s = st.CreateInstance();
s.X = x;
s.Y = 50;
if (s is IPlanarShape) {
((IPlanarShape)s).Angle = -300;
//((IPlanarShape)s).FillStyle
// ((ILinearShape)s).LineStyle
}
diagram.Shapes.Add(s, shapeCount + 1);
project.Repository.InsertShape(s, diagram);
++shapeCount;
}
//
Diagram diagram2 = new Diagram("Connections");
diagram2.Width = 800;
diagram2.Height = 600;
Circle circle = (Circle)project.ShapeTypes["Circle"].CreateInstance();
circle.X = 50;
circle.Y = 50;
circle.Diameter = 10;
diagram2.Shapes.Add(circle, diagram.Shapes.MaxZOrder + 10);
Box box = (Box)project.ShapeTypes["Box"].CreateInstance();
box.X = 100;
box.Y = 50;
box.Width = 20;
box.Height = 10;
box.Angle = 450;
diagram2.Shapes.Add(box, diagram2.Shapes.MaxZOrder + 10);
Polyline polyLine = (Polyline)project.ShapeTypes["Polyline"].CreateInstance();
polyLine.Connect(1, box, 3);
polyLine.Connect(2, circle, 7);
diagram2.Shapes.Add(polyLine, diagram2.Shapes.MaxZOrder + 10);
project.Repository.InsertDiagram(diagram2);
//
project.Repository.SaveChanges();
project.Close();
//
// -- Reload project and modify --
project.Open();
diagram = project.Repository.GetDiagram("All Shapes");
project.Repository.GetDiagramShapes(diagram);
foreach (Shape s in diagram.Shapes) {
s.MoveBy(300, 300);
if (s is ICaptionedShape)
((ICaptionedShape)s).SetCaptionText(0, s.Type.Name);
project.Repository.UpdateShape(s);
}
project.Repository.SaveChanges();
project.Close();
//
// -- Reload and check --
project.Open();
diagram = project.Repository.GetDiagram("All Shapes");
int c = 0;
foreach (Shape s in diagram.Shapes) {
Assert.AreEqual(350, s.Y);
if (s is IPlanarShape) Assert.AreEqual(3300, ((IPlanarShape)s).Angle, s.Type.Name);
if (s is ICaptionedShape)
Assert.AreEqual(((ICaptionedShape)s).GetCaptionText(0), s.Type.Name);
++c;
}
Assert.AreEqual(shapeCount, diagram.Shapes.Count);
Assert.AreEqual(shapeCount, c);
project.Close();
}
示例2: TemplateTest
public void TemplateTest() {
Project project = new Project();
project.Name = "Test";
project.Repository = new CachedRepository();
((CachedRepository)project.Repository).Store = RepositoryHelper.CreateXmlStore();
project.Repository.Erase();
project.Create();
project.AddLibrary(typeof(Dataweb.NShape.GeneralShapes.Circle).Assembly);
Template template = new Template("Template1", project.ShapeTypes["RoundedBox"].CreateInstance());
((IPlanarShape)template.Shape).FillStyle = project.Design.FillStyles.Red;
project.Repository.InsertTemplate(template);
Diagram diagram = new Diagram("Diagram A");
diagram.Shapes.Add(template.CreateShape(), 1);
project.Repository.InsertDiagram(diagram);
Assert.ReferenceEquals(((IPlanarShape)diagram.Shapes.Bottom).FillStyle, ((IPlanarShape)template.Shape).FillStyle);
IFillStyle fillStyle = project.Design.FillStyles.Green;
((IPlanarShape)template.Shape).FillStyle = fillStyle;
Assert.ReferenceEquals(((IPlanarShape)diagram.Shapes.Bottom).FillStyle, ((IPlanarShape)template.Shape).FillStyle);
project.Repository.SaveChanges();
project.Close();
//
project.Open();
template = project.Repository.GetTemplate("Template1");
diagram = project.Repository.GetDiagram("Diagram A");
Assert.AreEqual(((IPlanarShape)diagram.Shapes.Bottom).FillStyle.BaseColorStyle, ((IPlanarShape)template.Shape).FillStyle.BaseColorStyle);
project.Close();
}
示例3: StylesTest
public void StylesTest() {
Project project = new Project();
project.Repository = new CachedRepository();
((CachedRepository)project.Repository).Store = RepositoryHelper.CreateXmlStore();
project.Name = "Test";
project.Repository.Erase();
project.Create();
project.AddLibrary(typeof(Dataweb.NShape.GeneralShapes.Circle).Assembly);
ColorStyle colorStyle = (ColorStyle)project.Design.ColorStyles.Blue;
colorStyle.Color = Color.LightBlue;
project.Repository.UpdateStyle(colorStyle);
project.Repository.SaveChanges();
project.Close();
project.Open();
colorStyle = (ColorStyle)project.Design.ColorStyles.Blue;
Assert.AreEqual(Color.LightBlue.ToArgb(), colorStyle.Color.ToArgb());
project.Close();
}
示例4: AggregationTest
public void AggregationTest() {
// -- Create a project --
Project project = new Project();
project.Name = "Test";
project.Repository = new CachedRepository();
((CachedRepository)project.Repository).Store = RepositoryHelper.CreateXmlStore();
project.Repository.Erase();
project.Create();
project.AddLibrary(typeof(Dataweb.NShape.GeneralShapes.Circle).Assembly);
Diagram diagram = new Diagram("Diagram A");
// Create a group
ShapeGroup group = (ShapeGroup)project.ShapeTypes["ShapeGroup"].CreateInstance();
group.Children.Add(project.ShapeTypes["Circle"].CreateInstance(), 1);
group.Children.Add(project.ShapeTypes["Square"].CreateInstance(), 2);
group.Children.Add(project.ShapeTypes["Diamond"].CreateInstance(), 3);
group.MoveTo(200, 200);
diagram.Shapes.Add(group, 1);
// Create an aggregation
Box box = (Box)project.ShapeTypes["Box"].CreateInstance();
box.Children.Add(project.ShapeTypes["Circle"].CreateInstance(), 1);
box.Children.Add(project.ShapeTypes["Square"].CreateInstance(), 2);
box.Children.Add(project.ShapeTypes["Diamond"].CreateInstance(), 3);
box.MoveTo(400, 200);
diagram.Shapes.Add(box, 2);
// Save everything
project.Repository.InsertDiagram(diagram);
project.Repository.SaveChanges();
project.Close();
//
// -- Reload and modify --
project.Open();
foreach (Diagram d in project.Repository.GetDiagrams())
diagram = d;
group = (ShapeGroup)diagram.Shapes.Bottom;
Shape shape = null;
foreach (Shape s in group.Children)
shape = s;
group.Children.Remove(shape);
project.Repository.DeleteShape(shape);
box = (Box)diagram.Shapes.TopMost;
foreach (Shape s in box.Children)
shape = s;
box.Children.Remove(shape);
project.Repository.DeleteShape(shape);
project.Repository.SaveChanges();
project.Close();
//
// -- Check --
project.Open();
foreach (Diagram d in project.Repository.GetDiagrams()) {
project.Repository.GetDiagramShapes(d);
foreach (Shape s in d.Shapes)
Assert.AreEqual(2, s.Children.Count);
}
project.Close();
}