protected override void RunInternal()
        {
            Program.Service.NewDocument(DocumentType.Standard);
            IDocument document = Program.Service.Document;

            IMasterPage masterPage     = document.CreateMasterPage("Master 1");
            ITreeNode   masterPageNode = document.DocumentSettings.LayoutSetting.MasterPageTree.AddChild(TreeNodeType.MasterPage);

            masterPageNode.AttachedObject = masterPage;
            masterPage.Open();
            IPageView masterBaseView = masterPage.PageViews[document.AdaptiveViewSet.Base.Guid];

            IShape diamond = masterBaseView.CreateWidget(WidgetType.Shape) as IShape;

            diamond.ShapeType          = ShapeType.Diamond;
            diamond.WidgetStyle.Height = 200;
            diamond.WidgetStyle.Width  = 200;
            diamond.WidgetStyle.X      = 0;
            diamond.WidgetStyle.Y      = 0;
            diamond.WidgetStyle.Z      = 0;
            diamond.Name = "Z_0_In_MasterPage";
            diamond.SetRichText("Z_0_In_MasterPage");

            IShape ellipse = masterBaseView.CreateWidget(WidgetType.Shape) as IShape;

            ellipse.ShapeType          = ShapeType.Ellipse;
            ellipse.WidgetStyle.Height = 200;
            ellipse.WidgetStyle.Width  = 200;
            ellipse.WidgetStyle.X      = 50;
            ellipse.WidgetStyle.Y      = 50;
            ellipse.WidgetStyle.Z      = 1;
            ellipse.Name = "Z_1_In_MasterPage";
            ellipse.SetRichText("Z_1_In_MasterPage");

            IShape rectangle = masterBaseView.CreateWidget(WidgetType.Shape) as IShape;

            rectangle.ShapeType          = ShapeType.Rectangle;
            rectangle.WidgetStyle.Height = 200;
            rectangle.WidgetStyle.Width  = 200;
            rectangle.WidgetStyle.X      = 100;
            rectangle.WidgetStyle.Y      = 100;
            rectangle.WidgetStyle.Z      = 2;
            rectangle.Name = "Z_2_In_MasterPage";
            rectangle.SetRichText("Z_2_In_MasterPage");

            List <Guid> guidList = new List <Guid>();

            guidList.Add(ellipse.Guid);
            guidList.Add(rectangle.Guid);
            IGroup groupInMaster = masterBaseView.CreateGroup(guidList);

            groupInMaster.Name = "Group_In_MasterPage";

            IDocumentPage page     = document.CreatePage("Page 1");
            ITreeNode     pageNode = document.DocumentSettings.LayoutSetting.PageTree.AddChild(TreeNodeType.Page);

            pageNode.AttachedObject = page;
            page.Open();
            IPageView baseView = page.PageViews[document.AdaptiveViewSet.Base.Guid];

            IShape round = baseView.CreateWidget(WidgetType.Shape) as IShape;

            round.ShapeType          = ShapeType.RoundedRectangle;
            round.WidgetStyle.Height = 200;
            round.WidgetStyle.Width  = 200;
            round.WidgetStyle.X      = 0;
            round.WidgetStyle.Y      = 0;
            round.WidgetStyle.Z      = 0;
            round.Name = "Z_0_In_Page";
            round.SetRichText("Z_0_In_Page");

            IMaster master1 = baseView.CreateMaster(masterPage.Guid);

            master1.MasterStyle.X = 250;
            master1.MasterStyle.Y = 250;
            master1.MasterStyle.Z = 1;

            IShape triangle = baseView.CreateWidget(WidgetType.Shape) as IShape;

            triangle.ShapeType          = ShapeType.Triangle;
            triangle.WidgetStyle.Height = 200;
            triangle.WidgetStyle.Width  = 200;
            triangle.WidgetStyle.X      = 100;
            triangle.WidgetStyle.Y      = 100;
            triangle.WidgetStyle.Z      = 2;
            triangle.Name = "Z_2_In_Page";
            triangle.SetRichText("Z_2_In_Page");
            triangle.WidgetStyle.FillColor = new StyleColor(ColorFillType.Solid, -22550);

            IMaster master2 = baseView.CreateMaster(masterPage.Guid);

            master2.MasterStyle.X = 500;
            master2.MasterStyle.Y = 500;
            master2.MasterStyle.Z = 3;

            IShape triangle1 = baseView.CreateWidget(WidgetType.Shape) as IShape;

            triangle1.ShapeType          = ShapeType.Triangle;
            triangle1.WidgetStyle.Height = 200;
            triangle1.WidgetStyle.Width  = 200;
            triangle1.WidgetStyle.X      = 100;
            triangle1.WidgetStyle.Y      = 100;
            triangle1.WidgetStyle.Z      = 4;
            triangle1.Name = "Z_4_In_Page";
            triangle1.SetRichText("Z_4_In_Page");
            triangle1.WidgetStyle.FillColor = new StyleColor(ColorFillType.Solid, -22550);

            ISerializeWriter writer = document.CreateSerializeWriter(Guid.Empty);

            writer.AddPage(page);
            Stream stream = writer.WriteToStream();

            // Create another document
            DocumentService Service = new DocumentService();

            Service.NewDocument(DocumentType.Standard);
            IDocument document2 = Service.Document;

            IObjectContainer container = document2.AddPages(stream);

            stream.Close();

            foreach (IStandardPage newPage in container.StandardPageList)
            {
                ITreeNode node22 = document2.DocumentSettings.LayoutSetting.PageTree.AddChild(TreeNodeType.Page);
                node22.AttachedObject = newPage;
            }

            string target = Path.Combine(Program.WORKING_DIRECTORY, _caseName + "_Target.pn");

            Service.Save(target);
            Service.Close();

            // Save the document to a pn file.
            string source = Path.Combine(Program.WORKING_DIRECTORY, _caseName + "_Source.pn");

            Program.Service.Save(source);
            Program.Service.Close();
        }
Esempio n. 2
0
        protected override void RunInternal()
        {
            Program.Service.NewDocument(DocumentType.Standard);
            IDocument document = Program.Service.Document;

            IMasterPage masterPage     = document.CreateMasterPage("Master 1");
            ITreeNode   masterPageNode = document.DocumentSettings.LayoutSetting.MasterPageTree.AddChild(TreeNodeType.MasterPage);

            masterPageNode.AttachedObject = masterPage;
            masterPage.Open();
            IPageView masterBaseView = masterPage.PageViews[document.AdaptiveViewSet.Base.Guid];

            IButton button = masterBaseView.CreateWidget(WidgetType.Button) as IButton;

            button.Annotation.SetTextValue("CreatedTime", DateTime.Now.ToString());

            // Size
            button.WidgetStyle.Height = 30;
            button.WidgetStyle.Width  = 100;

            // Location
            button.WidgetStyle.X = 0;
            button.WidgetStyle.Y = 0;
            button.WidgetStyle.Z = 0;

            // Text things
            button.Name    = "Button 1";
            button.Text    = "Button";
            button.Tooltip = "Html button.";

            IImage image = masterBaseView.CreateWidget(WidgetType.Image) as IImage;

            image.Annotation.SetTextValue("CreatedTime", DateTime.Now.ToString());
            image.WidgetStyle.Height = 267;
            image.WidgetStyle.Width  = 116;
            image.WidgetStyle.X      = 150;
            image.WidgetStyle.Y      = 100;
            image.WidgetStyle.Z      = 5;
            image.Name    = "4.png Group_In_MasterPage";
            image.Tooltip = "A png image has 116 x 267 in size";

            // It is a png image by default. Set image stream
            string imageFile = Path.Combine(Program.WORKING_IMAGES_DIRECTORY, "HangGame", "4.png");

            if (File.Exists(imageFile))
            {
                using (FileStream fileStream = new FileStream(imageFile, FileMode.Open, FileAccess.Read))
                {
                    MemoryStream imageStream = new MemoryStream();
                    fileStream.CopyTo(imageStream);
                    image.ImageStream = imageStream;
                }
            }

            IShape lable = masterBaseView.CreateWidget(WidgetType.Shape) as IShape;

            lable.ShapeType = ShapeType.Diamond;
            lable.Annotation.SetTextValue("CreatedTime", DateTime.Now.ToString());
            lable.WidgetStyle.Height = 100;
            lable.WidgetStyle.Width  = 200;
            lable.WidgetStyle.X      = 350;
            lable.WidgetStyle.Y      = 300;
            lable.WidgetStyle.Z      = 9;
            lable.Name    = "Label 1 Group_In_MasterPage";
            lable.Tooltip = "A label.";
            lable.SetRichText("Label Group_In_MasterPage");
            lable.WidgetStyle.FillColor = new StyleColor(ColorFillType.Solid, -888);

            List <Guid> guidList = new List <Guid>();

            guidList.Add(image.Guid);
            guidList.Add(lable.Guid);
            IGroup groupInMaster = masterBaseView.CreateGroup(guidList);

            groupInMaster.Name = "Group_In_MasterPage";

            IDocumentPage page     = document.CreatePage("Page 1");
            ITreeNode     pageNode = document.DocumentSettings.LayoutSetting.PageTree.AddChild(TreeNodeType.Page);

            pageNode.AttachedObject = page;
            page.Open();
            IPageView baseView = page.PageViews[document.AdaptiveViewSet.Base.Guid];

            IMaster master2 = baseView.CreateMaster(masterPage.Guid);

            master2.MasterStyle.X = 10;
            master2.MasterStyle.Y = 10;
            master2.MasterStyle.Z = 1;

            IShape lable2 = baseView.CreateWidget(WidgetType.Shape) as IShape;

            lable2.ShapeType = ShapeType.RoundedRectangle;
            lable2.Annotation.SetTextValue("CreatedTime", DateTime.Now.ToString());
            lable2.WidgetStyle.Height = 100;
            lable2.WidgetStyle.Width  = 100;
            lable2.WidgetStyle.X      = 500;
            lable2.WidgetStyle.Y      = 0;
            lable2.WidgetStyle.Z      = 2;
            lable2.Name = "Label Group_In_Page";
            lable2.SetRichText("Label Group_In_Page");

            guidList = new List <Guid>();
            guidList.Add(master2.Guid);
            guidList.Add(lable2.Guid);
            IGroup groupInPage = baseView.CreateGroup(guidList);

            groupInPage.Name = "Group_In_Page";

            IMaster master = baseView.CreateMaster(masterPage.Guid);

            master.MasterStyle.X = 0;
            master.MasterStyle.Y = 500;
            master.MasterStyle.Z = 3;

            ISerializeWriter writer = document.CreateSerializeWriter(Guid.Empty);

            writer.AddPage(page);
            Stream stream = writer.WriteToStream();

            // Create another document
            DocumentService Service = new DocumentService();

            Service.NewDocument(DocumentType.Standard);
            IDocument document2 = Service.Document;

            IObjectContainer container = document2.AddPages(stream);

            stream.Close();

            foreach (IStandardPage newPage in container.StandardPageList)
            {
                ITreeNode node22 = document2.DocumentSettings.LayoutSetting.PageTree.AddChild(TreeNodeType.Page);
                node22.AttachedObject = newPage;
            }

            string target = Path.Combine(Program.WORKING_DIRECTORY, _caseName + "_Target.pn");

            Service.Save(target);
            Service.Close();

            // Save the document to a pn file.
            string source = Path.Combine(Program.WORKING_DIRECTORY, _caseName + "_Source.pn");

            Program.Service.Save(source);
            Program.Service.Close();
        }
Esempio n. 3
0
        protected override void RunInternal()
        {
            // Create a new document.
            Program.Service.NewDocument(DocumentType.Standard);
            IDocument document = Program.Service.Document;

            // Create a new page 1.
            IDocumentPage page1 = document.CreatePage("Page 1");
            ITreeNode     node1 = document.DocumentSettings.LayoutSetting.PageTree.AddChild(TreeNodeType.Page);

            node1.AttachedObject = page1;

            page1.Open();

            // Get the page view for base adaptive view.
            IPageView baseView1 = page1.PageViews[document.AdaptiveViewSet.Base.Guid];

            // Create a image.
            IImage image = baseView1.CreateWidget(WidgetType.Image) as IImage;

            image.Annotation.SetTextValue("CreatedTime", DateTime.Now.ToString());
            image.WidgetStyle.Height = 267;
            image.WidgetStyle.Width  = 116;
            image.Name    = "4.png";
            image.Tooltip = "A png image has 116 x 267 in size";

            string imageFile = Path.Combine(Program.WORKING_IMAGES_DIRECTORY, "HangGame", "4.png");

            if (File.Exists(imageFile))
            {
                using (FileStream fileStream = new FileStream(imageFile, FileMode.Open, FileAccess.Read))
                {
                    MemoryStream imageStream = new MemoryStream();
                    fileStream.CopyTo(imageStream);
                    image.ImageStream = imageStream;
                }
            }

            // Create a hamburger menu.
            IHamburgerMenu hamburgerMenu = baseView1.CreateWidget(WidgetType.HamburgerMenu) as IHamburgerMenu;

            hamburgerMenu.Annotation.SetTextValue("CreatedTime", DateTime.Now.ToString());
            hamburgerMenu.WidgetStyle.Height = 280;
            hamburgerMenu.WidgetStyle.Width  = 150;
            hamburgerMenu.WidgetStyle.X      = 200;
            hamburgerMenu.WidgetStyle.Y      = 200;
            hamburgerMenu.WidgetStyle.Z      = 1;
            hamburgerMenu.Name    = "HamburgerMenu 1";
            hamburgerMenu.Tooltip = "A hamburger menu.";

            // Menu botton
            hamburgerMenu.MenuButton.WidgetStyle.Height = 50;
            hamburgerMenu.MenuButton.WidgetStyle.Width  = 50;
            hamburgerMenu.MenuButton.WidgetStyle.X      = 200;
            hamburgerMenu.MenuButton.WidgetStyle.Y      = 200;
            hamburgerMenu.MenuButton.WidgetStyle.Z      = 0;

            // Menu page,  add a shape
            IPage menuPage = hamburgerMenu.MenuPage;

            menuPage.Open(); // Open page to edit.

            // Get the base view of menu page.
            IPageView menuBaseView = menuPage.PageViews[document.AdaptiveViewSet.Base.Guid];

            IShape diamond = menuBaseView.CreateWidget(WidgetType.Shape) as IShape;

            diamond.ShapeType = ShapeType.Diamond;
            diamond.Annotation.SetTextValue("CreatedTime", DateTime.Now.ToString());
            diamond.WidgetStyle.Height = 100;
            diamond.WidgetStyle.Width  = 100;
            diamond.Name    = "Diamond 1";
            diamond.Tooltip = "A Diamond.";
            diamond.SetRichText("Diamond");
            menuPage.Close(); // Close Page to release resources.

            // Create a serialize writer first.
            ISerializeWriter writer = document.CreateSerializeWriter(document.AdaptiveViewSet.Base.Guid);

            // Add the new page 1 to the writer.
            writer.AddPage(page1);

            // Serialize page 1 to a stream.
            Stream stream = writer.WriteToStream();

            // The data of page is already in stream, so close the page will not change anything in stream.
            page1.Close();

            // Add pages in stream.
            IObjectContainer container = document.AddPages(stream);

            stream.Close();

            foreach (IStandardPage page in container.StandardPageList)
            {
                ITreeNode node22 = document.DocumentSettings.LayoutSetting.PageTree.AddChild(TreeNodeType.Page);
                node22.AttachedObject = page;
            }

            // Save document.
            string fileName = Path.Combine(Program.WORKING_DIRECTORY, _caseName + ".pn");

            Program.Service.Save(fileName);

            // Close document.
            Program.Service.Close();
        }