public IWidget AddLineItem2Dom(Orientation lineType, double x, double y, int w, int h) { if (_activeView == null) { return(null); } ILine widget = _activeView.CreateWidget(WidgetType.Line) as ILine; if (widget == null) { return(null); } IsDirty = true; // Save the initial location and size in base view style, so we can place widget in the original // laction with original size in base view if the widget is created in child view. widget.Orientation = lineType; widget.WidgetStyle.X = x; widget.WidgetStyle.Y = y; widget.WidgetStyle.Width = w; widget.WidgetStyle.Height = h; return(widget); }
/// <summary> /// Add defaut image and text for Toast. /// </summary> private void AddDefautForToast(IToast toast) { toast.ToastPage.Open(); IPageView curPageView = toast.ToastPage.PageViews.GetPageView(_document.AdaptiveViewSet.Base.Guid); //add default image for toast IImage image1 = curPageView.CreateWidget(WidgetType.Image) as IImage; Stream _imageStream = Application.GetResourceStream(new Uri(@"pack://*****:*****@"Pop_Panel"; IImage image2 = curPageView.CreateWidget(WidgetType.Image) as IImage; Stream _imageStream2 = Application.GetResourceStream(new Uri(@"pack://*****:*****@"IconBar"; //add default text for toast IShape textWidget = curPageView.CreateWidget(WidgetType.Shape) as IShape; textWidget.ShapeType = ShapeType.Paragraph; textWidget.WidgetStyle.X = 20; textWidget.WidgetStyle.Y = 15; textWidget.WidgetStyle.Width = 258; textWidget.WidgetStyle.Height = 47; textWidget.WidgetStyle.FontSize = 14; textWidget.WidgetStyle.FontColor = new StyleColor(ColorFillType.Solid, System.Drawing.Color.FromArgb(0xc8, 0xcb, 0xce).ToArgb()); textWidget.WidgetStyle.FontFamily = GlobalData.FindResource("Common_Font"); textWidget.Text = GlobalData.FindResource("widgets_Toast_Default_Msg"); textWidget.WidgetStyle.Z = 2; textWidget.Name = @"Pop_Message"; }
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"; 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.Paragraph; lable.Annotation.SetTextValue("CreatedTime", DateTime.Now.ToString()); lable.WidgetStyle.Height = 100; lable.WidgetStyle.Width = 200; lable.WidgetStyle.X = 150; lable.WidgetStyle.Y = 300; lable.WidgetStyle.Z = 9; lable.Name = "Label 1"; lable.Tooltip = "A label."; lable.SetRichText("Label"); lable.WidgetStyle.LineColor = new StyleColor(ColorFillType.Solid, -16777216); lable.WidgetStyle.LineWidth = 0; // No border lable.WidgetStyle.FillColor = new StyleColor(ColorFillType.Solid, 16777215); // Transparent lable.WidgetStyle.HorzAlign = Alignment.Left; lable.WidgetStyle.VertAlign = Alignment.Top; 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 master = baseView.CreateMaster(masterPage.Guid); IDocumentPage page2 = document.DuplicatePage(page.Guid); ITreeNode pageNode2 = document.DocumentSettings.LayoutSetting.PageTree.AddChild(TreeNodeType.Page); pageNode2.AttachedObject = page2; // Save the document to a pn file. string fileName = Path.Combine(Program.WORKING_DIRECTORY, _caseName + ".pn"); Program.Service.Save(fileName); // Close this document when you don't work on it anymore. Program.Service.Close(); }
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"; 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.Paragraph; 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"; lable.Tooltip = "A label."; lable.SetRichText("Label"); lable.WidgetStyle.FillColor = new StyleColor(ColorFillType.Solid, -999); List <Guid> guidList = new List <Guid>(); guidList.Add(image.Guid); guidList.Add(lable.Guid); masterBaseView.CreateGroup(guidList); 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 master = baseView.CreateMaster(masterPage.Guid); master.MasterStyle.X = 150; master.MasterStyle.Y = 50; // Copy master in the same page. ISerializeWriter writer = document.CreateSerializeWriter(document.AdaptiveViewSet.Base.Guid); writer.AddMaster(master); Stream stream = writer.WriteToStream(); // Create another document DocumentService Service = new DocumentService(); Service.NewDocument(DocumentType.Standard); IDocument document2 = Service.Document; IDocumentPage page2 = document2.CreatePage("Page 1"); ITreeNode pageNode2 = document2.DocumentSettings.LayoutSetting.PageTree.AddChild(TreeNodeType.Page); pageNode2.AttachedObject = page2; page2.Open(); IPageView baseView2 = page2.PageViews[document2.AdaptiveViewSet.Base.Guid]; baseView2.AddObjects(stream); string target = Path.Combine(Program.WORKING_DIRECTORY, _caseName + "_Target.pn"); Service.Save(target); Service.Close(); string source = Path.Combine(Program.WORKING_DIRECTORY, _caseName + "_Source.pn"); Program.Service.Save(source); Program.Service.Close(); }
protected override void RunInternal() { Program.Service.NewDocument(DocumentType.Standard); IDocument document = Program.Service.Document; 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]; 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"; // Creata a image widget. 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 flicking widget. IDynamicPanel dynamicPanel = baseView1.CreateWidget(WidgetType.DynamicPanel) as IDynamicPanel; dynamicPanel.Annotation.SetTextValue("CreatedTime", DateTime.Now.ToString()); dynamicPanel.WidgetStyle.Height = 198; dynamicPanel.WidgetStyle.Width = 152; dynamicPanel.WidgetStyle.X = 250; dynamicPanel.WidgetStyle.Y = 250; dynamicPanel.WidgetStyle.Z = 1; dynamicPanel.IsAutomatic = true; // Set start panel page as the first created page. dynamicPanel.StartPanelStatePage = dynamicPanel.CreatePanelStatePage("Panel 1"); dynamicPanel.CreatePanelStatePage("Panel 2"); dynamicPanel.CreatePanelStatePage("Panel 3"); int imageFileName = 1; foreach (IPage statePage in dynamicPanel.PanelStatePages) { statePage.Open(); // Open page to edit. // Get the base view of state page. IPageView stateBaseView = statePage.PageViews[document.AdaptiveViewSet.Base.Guid]; IImage statePageImage = stateBaseView.CreateWidget(WidgetType.Image) as IImage; statePageImage.Annotation.SetTextValue("CreatedTime", DateTime.Now.ToString()); statePageImage.WidgetStyle.Height = 198; statePageImage.WidgetStyle.Width = 152; string statePageImageFile = Path.Combine(Program.WORKING_IMAGES_DIRECTORY, "HangGame", imageFileName + ".png"); if (File.Exists(statePageImageFile)) { using (FileStream fileStream = new FileStream(statePageImageFile, FileMode.Open, FileAccess.Read)) { MemoryStream imageStream = new MemoryStream(); fileStream.CopyTo(imageStream); statePageImage.ImageStream = imageStream; } } statePage.Close(); // Close Page to release resources. imageFileName++; } // Create a group List <Guid> widgetGuidList = new List <Guid>(); widgetGuidList.Add(image.Guid); widgetGuidList.Add(dynamicPanel.Guid); IGroup group = page1.CreateGroup(widgetGuidList); // Create a serialize writer. ISerializeWriter writer = document.CreateSerializeWriter(document.AdaptiveViewSet.Base.Guid); // Add widgets and groups you want to copy to the writer. writer.AddGroup(group); // Serialize widgets and groups to a stream. Stream stream = writer.WriteToStream(); // DeflateStream Compress long deflateCompressStart = DateTime.Now.Ticks; MemoryStream deflateCompressedStream = new MemoryStream(); using (DeflateStream deflateStream = new DeflateStream(deflateCompressedStream, CompressionMode.Compress, true)) { stream.Position = 0; stream.CopyTo(deflateStream); } long deflateCompressEnd = DateTime.Now.Ticks; double deflateCompressRate = Math.Round((double)(stream.Length - deflateCompressedStream.Length) / (double)stream.Length * 100, 2); Console.WriteLine("DeflateStream compress length {0} to length {1}, compress rate: {2}%, take ticks: {3}.", stream.Length, deflateCompressedStream.Length, deflateCompressRate, deflateCompressEnd - deflateCompressStart); // GZipStream Compress long gZipStreamCompressStart = DateTime.Now.Ticks; MemoryStream gZipStreamCompressedStream = new MemoryStream(); using (GZipStream gZipStream = new GZipStream(gZipStreamCompressedStream, CompressionMode.Compress, true)) { stream.Position = 0; stream.CopyTo(gZipStream); } long gZipStreamCompressEnd = DateTime.Now.Ticks; double gZipStreamCompressRate = Math.Round((double)(stream.Length - gZipStreamCompressedStream.Length) / (double)stream.Length * 100, 2); Console.WriteLine("GZipStream compress length {0} to length {1}, compress rate: {2}%, take ticks: {3}.", stream.Length, gZipStreamCompressedStream.Length, gZipStreamCompressRate, gZipStreamCompressEnd - gZipStreamCompressStart); page1.Close(); // Paste stream to page 2. IDocumentPage page2 = document.CreatePage("Page 2"); ITreeNode node2 = document.DocumentSettings.LayoutSetting.PageTree.AddChild(TreeNodeType.Page); node2.AttachedObject = page2; page2.Open(); // Get the page view for base adaptive view. IPageView baseView2 = page2.PageViews[document.AdaptiveViewSet.Base.Guid]; IDocumentPage page3 = document.CreatePage("Page 3"); ITreeNode node3 = document.DocumentSettings.LayoutSetting.PageTree.AddChild(TreeNodeType.Page); node3.AttachedObject = page3; page3.Open(); // Get the page view for base adaptive view. IPageView baseView3 = page3.PageViews[document.AdaptiveViewSet.Base.Guid]; // DeflateStream Decompress long deflateDecompressStart = DateTime.Now.Ticks; deflateCompressedStream.Position = 0; MemoryStream deflateDecompressedStream = new MemoryStream(); using (DeflateStream deflateStream = new DeflateStream(deflateCompressedStream, CompressionMode.Decompress, true)) { deflateStream.CopyTo(deflateDecompressedStream); } long deflateDecompressEnd = DateTime.Now.Ticks; Console.WriteLine("DeflateStream decompress take ticks: {0}.", deflateDecompressEnd - deflateDecompressStart); deflateDecompressedStream.Position = 0; baseView2.AddObjects(deflateDecompressedStream); // Paste to page 2. page2.Close(); // GZipStream Decompress long gZipStreamDecompressStart = DateTime.Now.Ticks; gZipStreamCompressedStream.Position = 0; MemoryStream gZipStreamDecompressedStream = new MemoryStream(); using (GZipStream gZipStream = new GZipStream(gZipStreamCompressedStream, CompressionMode.Decompress, true)) { gZipStream.CopyTo(gZipStreamDecompressedStream); } long gZipStreamDecompressEnd = DateTime.Now.Ticks; Console.WriteLine("DeflateStream decompress take ticks: {0}.", gZipStreamDecompressEnd - gZipStreamDecompressStart); gZipStreamDecompressedStream.Position = 0; baseView3.AddObjects(gZipStreamDecompressedStream); // Paste to page 3. page3.Close(); // Save the document to a pn file. string fileName = Path.Combine(Program.WORKING_DIRECTORY, _caseName + ".pn"); Program.Service.Save(fileName); Program.Service.Close(); }
protected override void RunInternal() { // Create a new document. Program.Service.NewDocument(DocumentType.Standard); IDocument document = Program.Service.Document; document.WidgetAnnotationFieldSet.CreateAnnotationField("CreatedTime", AnnotationFieldType.Text); // Create a new page. IDocumentPage closePage = document.CreatePage("Close Page"); ITreeNode node1 = document.DocumentSettings.LayoutSetting.PageTree.AddChild(TreeNodeType.Page); node1.AttachedObject = closePage; closePage.Open(); // Get the page view for base adaptive view. IPageView baseView1 = closePage.PageViews[document.AdaptiveViewSet.Base.Guid]; // Create a image in the new page. 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 in the new page. 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 = 14; 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 = 600; hamburgerMenu.MenuButton.WidgetStyle.Y = 450; 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. // Close the new page. closePage.Close(); // Duplication the closed new page. then the document has two pages, they are the same except for // the guids of page, widgets and groups. IDocumentPage newClosePage = document.DuplicatePage(closePage.Guid); newClosePage.Name = closePage.Name + "_Duplicated"; ITreeNode node11 = document.DocumentSettings.LayoutSetting.PageTree.AddChild(TreeNodeType.Page); node11.AttachedObject = newClosePage; // Create another new page. IDocumentPage openPage = document.CreatePage("Open Page"); ITreeNode node2 = document.DocumentSettings.LayoutSetting.PageTree.AddChild(TreeNodeType.Page); node2.AttachedObject = openPage; openPage.Open(); // Get the page view for base adaptive view. IPageView baseView2 = openPage.PageViews[document.AdaptiveViewSet.Base.Guid]; // Create a button. IButton button = baseView2.CreateWidget(WidgetType.Button) as IButton; button.Annotation.SetTextValue("CreatedTime", DateTime.Now.ToString()); button.WidgetStyle.Height = 30; button.WidgetStyle.Width = 100; button.WidgetStyle.X = 0; button.WidgetStyle.Y = 0; button.WidgetStyle.Z = 0; button.Name = "Button 1"; button.Text = "Button"; button.Tooltip = "Html button."; // Create a toast. IToast toast = baseView2.CreateWidget(WidgetType.Toast) as IToast; toast.Annotation.SetTextValue("CreatedTime", DateTime.Now.ToString()); toast.WidgetStyle.Height = 146; toast.WidgetStyle.Width = 298; toast.WidgetStyle.X = 650; toast.WidgetStyle.Y = 450; toast.WidgetStyle.Z = 15; toast.Name = "Toast 1"; toast.Tooltip = "A ExposureTime toast."; toast.ExposureTime = 3; toast.DisplayPosition = ToastDisplayPosition.Top; toast.CloseSetting = ToastCloseSetting.ExposureTime; IPage toastPage = toast.ToastPage; toastPage.Open(); // Open page to edit. // Get the base view of toast page. IPageView toastBaseView = toastPage.PageViews[document.AdaptiveViewSet.Base.Guid]; IShape ellipse = toastBaseView.CreateWidget(WidgetType.Shape) as IShape; ellipse.ShapeType = ShapeType.Ellipse; ellipse.Annotation.SetTextValue("CreatedTime", DateTime.Now.ToString()); ellipse.WidgetStyle.Height = 100; ellipse.WidgetStyle.Width = 100; ellipse.Name = "Ellipse 1"; ellipse.Tooltip = "A Ellipse."; ellipse.SetRichText("Ellipse"); toastPage.Close(); // Close Page to release resources. // Duplicate the opened page. IDocumentPage newOpenPage = document.DuplicatePage(openPage.Guid); newOpenPage.Name = openPage.Name + "_Duplicated"; ITreeNode node22 = document.DocumentSettings.LayoutSetting.PageTree.AddChild(TreeNodeType.Page); node22.AttachedObject = newOpenPage; // Close the page. openPage.Close(); // Save document to pn file. string fileName = Path.Combine(Program.WORKING_DIRECTORY, _caseName + ".pn"); Program.Service.Save(fileName); // CLose document. Program.Service.Close(); }
protected override void RunInternal() { // Create a new document. Program.Service.NewDocument(DocumentType.Standard); IDocument document = Program.Service.Document; // Create a new page. 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]; IDynamicPanel dynamicPanel = baseView1.CreateWidget(WidgetType.DynamicPanel) as IDynamicPanel; dynamicPanel.Annotation.SetTextValue("CreatedTime", DateTime.Now.ToString()); dynamicPanel.WidgetStyle.Height = 198; dynamicPanel.WidgetStyle.Width = 152; dynamicPanel.IsAutomatic = true; // Set start panel page as the first created page. dynamicPanel.StartPanelStatePage = dynamicPanel.CreatePanelStatePage("Panel 1"); IEmbeddedPage embeddedPage2 = dynamicPanel.CreatePanelStatePage("Panel 2"); dynamicPanel.CreatePanelStatePage("Panel 3"); int imageFileName = 1; foreach (IPage statePage in dynamicPanel.PanelStatePages) { statePage.Open(); // Open page to edit. // Get the base view of state page. IPageView stateBaseView = statePage.PageViews[document.AdaptiveViewSet.Base.Guid]; IImage statePageImage = stateBaseView.CreateWidget(WidgetType.Image) as IImage; statePageImage.Annotation.SetTextValue("CreatedTime", DateTime.Now.ToString()); statePageImage.WidgetStyle.Height = 198; statePageImage.WidgetStyle.Width = 152; string statePageImageFile = Path.Combine(Program.WORKING_IMAGES_DIRECTORY, "HangGame", imageFileName + ".png"); if (File.Exists(statePageImageFile)) { using (FileStream fileStream = new FileStream(statePageImageFile, FileMode.Open, FileAccess.Read)) { MemoryStream imageStream = new MemoryStream(); fileStream.CopyTo(imageStream); statePageImage.ImageStream = imageStream; } } statePage.Close(); // Close Page to release resources. imageFileName++; } // Duplicate the page1. IDocumentPage page2 = document.DuplicatePage(page1.Guid); ITreeNode node2 = document.DocumentSettings.LayoutSetting.PageTree.AddChild(TreeNodeType.Page); node2.AttachedObject = page2; dynamicPanel.DeletePanelStatePage(embeddedPage2.Guid); page1.Close(); // Duplicate the page2. IDocumentPage page3 = document.DuplicatePage(page1.Guid); ITreeNode node3 = document.DocumentSettings.LayoutSetting.PageTree.AddChild(TreeNodeType.Page); node3.AttachedObject = page3; // Save document to pn file. string fileName = Path.Combine(Program.WORKING_DIRECTORY, _caseName + ".pn"); Program.Service.Save(fileName); // CLose document. Program.Service.Close(); }
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"; 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.Paragraph; lable.Annotation.SetTextValue("CreatedTime", DateTime.Now.ToString()); lable.WidgetStyle.Height = 100; lable.WidgetStyle.Width = 200; lable.WidgetStyle.X = 150; lable.WidgetStyle.Y = 300; lable.WidgetStyle.Z = 9; lable.Name = "Label 1"; lable.Tooltip = "A label."; lable.SetRichText("Label"); lable.WidgetStyle.LineColor = new StyleColor(ColorFillType.Solid, -16777216); lable.WidgetStyle.LineWidth = 0; // No border lable.WidgetStyle.FillColor = new StyleColor(ColorFillType.Solid, 16777215); // Transparent lable.WidgetStyle.HorzAlign = Alignment.Left; lable.WidgetStyle.VertAlign = Alignment.Top; 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 master = baseView.CreateMaster(masterPage.Guid); IDocumentPage page2 = document.CreatePage("Page 2"); ITreeNode pageNode2 = document.DocumentSettings.LayoutSetting.PageTree.AddChild(TreeNodeType.Page); pageNode2.AttachedObject = page2; page2.Open(); IPageView baseView2 = page2.PageViews[document.AdaptiveViewSet.Base.Guid]; IMaster master2 = baseView2.CreateMaster(masterPage.Guid); IHamburgerMenu hamburgerMenu = baseView2.CreateWidget(WidgetType.HamburgerMenu) as IHamburgerMenu; hamburgerMenu.Annotation.SetTextValue("CreatedTime", DateTime.Now.ToString()); hamburgerMenu.WidgetStyle.Height = 280; hamburgerMenu.WidgetStyle.Width = 150; hamburgerMenu.WidgetStyle.X = 0; hamburgerMenu.WidgetStyle.Y = 700; hamburgerMenu.WidgetStyle.Z = 14; 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 = 0; hamburgerMenu.MenuButton.WidgetStyle.Y = 700; 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]; // Create widgts on the base view in the menu page. 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. page2.Close(); // Save the document to a pn file. string before = Path.Combine(Program.WORKING_DIRECTORY, _caseName + "_Before.pn"); Program.Service.Save(before); // Delete master page. document.DeleteMasterPage(masterPage.Guid); document.DocumentSettings.LayoutSetting.MasterPageTree.RemoveChild(masterPageNode); string after = Path.Combine(Program.WORKING_DIRECTORY, _caseName + "_After_DeleteFromOpenedPage.pn"); Program.Service.Save(after); page2.Open(); string after2 = Path.Combine(Program.WORKING_DIRECTORY, _caseName + "_After_DeleteFromClosedPage.pn"); Program.Service.Save(after2); // Close this document when you don't work on it anymore. Program.Service.Close(); }
protected override void RunInternal() { // Create a document and Document type is "DocumentType.Library" !!!!!!!! Program.Service.NewDocument(DocumentType.Library); IDocument document = Program.Service.Document; // Create custom object 1, a custom object is actually a page. IDocumentPage page1 = document.CreatePage("CustomObject 1"); ITreeNode node1 = document.DocumentSettings.LayoutSetting.PageTree.AddChild(TreeNodeType.Page); node1.AttachedObject = page1; // Open the page. page1.Open(); // Get the page view for base adaptive view. IPageView baseView1 = page1.PageViews[document.AdaptiveViewSet.Base.Guid]; // Create a image widget in this custom object. 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"; // 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; } } // Create a flicking widget in this custom object. IDynamicPanel dynamicPanel = baseView1.CreateWidget(WidgetType.DynamicPanel) as IDynamicPanel; dynamicPanel.Annotation.SetTextValue("CreatedTime", DateTime.Now.ToString()); dynamicPanel.WidgetStyle.Height = 198; dynamicPanel.WidgetStyle.Width = 152; dynamicPanel.WidgetStyle.X = 0; dynamicPanel.WidgetStyle.Y = 250; dynamicPanel.WidgetStyle.Z = 16; dynamicPanel.IsAutomatic = true; // Set start panel page as the first created page. dynamicPanel.StartPanelStatePage = dynamicPanel.CreatePanelStatePage("Panel 1"); dynamicPanel.CreatePanelStatePage("Panel 2"); dynamicPanel.CreatePanelStatePage("Panel 3"); int imageFileName = 1; foreach (IPage statePage in dynamicPanel.PanelStatePages) { statePage.Open(); // Open page to edit. // Get the base view of state page. IPageView stateBaseView = statePage.PageViews[document.AdaptiveViewSet.Base.Guid]; IImage statePageImage = stateBaseView.CreateWidget(WidgetType.Image) as IImage; statePageImage.Annotation.SetTextValue("CreatedTime", DateTime.Now.ToString()); statePageImage.WidgetStyle.Height = 198; statePageImage.WidgetStyle.Width = 152; string statePageImageFile = Path.Combine(Program.WORKING_IMAGES_DIRECTORY, "HangGame", imageFileName + ".png"); if (File.Exists(statePageImageFile)) { using (FileStream fileStream = new FileStream(statePageImageFile, FileMode.Open, FileAccess.Read)) { MemoryStream imageStream = new MemoryStream(); fileStream.CopyTo(imageStream); statePageImage.ImageStream = imageStream; } } statePage.Close(); // Close Page to release resources. imageFileName++; } // Set the icon and tooltip for the library 1 ICustomObjectPage objectPage1 = page1 as ICustomObjectPage; objectPage1.Tooltip = "This custom object contains a image and a dynamic panel which has 3 panels."; string iconFile1 = Path.Combine(Program.WORKING_IMAGES_DIRECTORY, "icon", "1.png"); if (File.Exists(iconFile1)) { using (FileStream fileStream = new FileStream(iconFile1, FileMode.Open, FileAccess.Read)) { MemoryStream imageStream = new MemoryStream(); fileStream.CopyTo(imageStream); objectPage1.Icon = imageStream; } } // Close the custom object page. page1.Close(); // Create custom object 2 IDocumentPage page2 = document.CreatePage("CustomObject 2"); ITreeNode node2 = document.DocumentSettings.LayoutSetting.PageTree.AddChild(TreeNodeType.Page); node2.AttachedObject = page2; page2.Open(); // Get the page view for base adaptive view. IPageView baseView2 = page2.PageViews[document.AdaptiveViewSet.Base.Guid]; // Create a SVG widget in this library. ISvg svg = baseView2.CreateWidget(WidgetType.SVG) as ISvg; svg.Annotation.SetTextValue("CreatedTime", DateTime.Now.ToString()); svg.WidgetStyle.Height = 117; svg.WidgetStyle.Width = 150; svg.Name = "airplane 03"; svg.Tooltip = "A airplane svg"; string svgFile = Path.Combine(Program.WORKING_IMAGES_DIRECTORY, "Svg", "airplane 03.svg"); if (File.Exists(svgFile)) { using (FileStream fileStream = new FileStream(svgFile, FileMode.Open, FileAccess.Read)) { MemoryStream svgStream = new MemoryStream(); fileStream.CopyTo(svgStream); svg.XmlStream = svgStream; } } // Set the icon for the library 2 ICustomObjectPage objectPage2 = page2 as ICustomObjectPage; string iconFile2 = Path.Combine(Program.WORKING_IMAGES_DIRECTORY, "icon", "2.png"); if (File.Exists(iconFile2)) { using (FileStream fileStream = new FileStream(iconFile2, FileMode.Open, FileAccess.Read)) { MemoryStream imageStream = new MemoryStream(); fileStream.CopyTo(imageStream); objectPage2.Icon = imageStream; } } page2.Close(); // Save to a library file .libpn. The file extension is .libpn!!!!! string fileName = Path.Combine(Program.WORKING_DIRECTORY, _caseName + ".libpn"); Program.Service.Save(fileName); // Close the library document after you are done modifying libraries. Program.Service.Close(); }
protected override void RunInternal() { // Create a new document. Program.Service.NewDocument(DocumentType.Standard); IDocument document = Program.Service.Document; // Create a page. IDocumentPage page = document.CreatePage("Home"); // Create the page node in page tree. ITreeNode node = document.DocumentSettings.LayoutSetting.PageTree.AddChild(TreeNodeType.Page); node.AttachedObject = page; // Must open the page before you read and modify it. page.Open(); // Get the page view for base adaptive view. IPageView baseView = page.PageViews[document.AdaptiveViewSet.Base.Guid]; IDynamicPanel dynamicPanel = baseView.CreateWidget(WidgetType.DynamicPanel) as IDynamicPanel; dynamicPanel.Annotation.SetTextValue("CreatedTime", DateTime.Now.ToString()); dynamicPanel.WidgetStyle.Height = 198; dynamicPanel.WidgetStyle.Width = 152; dynamicPanel.WidgetStyle.X = 0; dynamicPanel.WidgetStyle.Y = 700; dynamicPanel.WidgetStyle.Z = 16; dynamicPanel.IsAutomatic = true; // Set start panel page as the first created page. dynamicPanel.StartPanelStatePage = dynamicPanel.CreatePanelStatePage("Panel 1"); dynamicPanel.CreatePanelStatePage("Panel 2"); dynamicPanel.CreatePanelStatePage("Panel 3"); int imageFileName = 1; foreach (IPage statePage in dynamicPanel.PanelStatePages) { statePage.Open(); // Open page to edit. // Get the base view of state page. IPageView stateBaseView = statePage.PageViews[document.AdaptiveViewSet.Base.Guid]; IImage statePageImage = stateBaseView.CreateWidget(WidgetType.Image) as IImage; statePageImage.Annotation.SetTextValue("CreatedTime", DateTime.Now.ToString()); statePageImage.WidgetStyle.Height = 198; statePageImage.WidgetStyle.Width = 152; string statePageImageFile = Path.Combine(Program.WORKING_IMAGES_DIRECTORY, "HangGame", imageFileName + ".png"); if (File.Exists(statePageImageFile)) { using (FileStream fileStream = new FileStream(statePageImageFile, FileMode.Open, FileAccess.Read)) { MemoryStream imageStream = new MemoryStream(); fileStream.CopyTo(imageStream); statePageImage.ImageStream = imageStream; } } statePage.Close(); // Close Page to release resources. imageFileName++; } //dynamicPanel.MovePanelStatePageTo(dynamicPanel.StartPanelStatePage, dynamicPanel.PanelStatePages.Count - 1); // Close the page if you don't want to work on it. page.Close(); // Save the document to a pn file. string fileName = Path.Combine(Program.WORKING_DIRECTORY, _caseName + ".pn"); Program.Service.Save(fileName); // Close this document when you don't work on it anymore. Program.Service.Close(); }
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(); }
protected override void RunInternal() { // Create a new document. Program.Service.NewDocument(DocumentType.Standard); IDocument document = Program.Service.Document; // Create a page. IDocumentPage page1 = document.CreatePage("Page 1"); // Create the page node in page tree. ITreeNode node = document.DocumentSettings.LayoutSetting.PageTree.AddChild(TreeNodeType.Page); node.AttachedObject = page1; // Must open the page before you read and modify it. page1.Open(); // Get the page view for base adaptive view. IPageView baseView = page1.PageViews[document.AdaptiveViewSet.Base.Guid]; IHamburgerMenu hamburgerMenu = baseView.CreateWidget(WidgetType.HamburgerMenu) as IHamburgerMenu; hamburgerMenu.Annotation.SetTextValue("CreatedTime", DateTime.Now.ToString()); hamburgerMenu.WidgetStyle.Height = 280; hamburgerMenu.WidgetStyle.Width = 150; hamburgerMenu.WidgetStyle.X = 0; hamburgerMenu.WidgetStyle.Y = 700; hamburgerMenu.WidgetStyle.Z = 14; 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 = 0; hamburgerMenu.MenuButton.WidgetStyle.Y = 700; 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]; // Create widgts on the base view in the menu page. 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. // Close the page if you don't want to work on it. page1.Close(); // Create a page. IDocumentPage page2 = document.CreatePage("Page 2"); // Create the page node in page tree. ITreeNode node2 = document.DocumentSettings.LayoutSetting.PageTree.AddChild(TreeNodeType.Page); node2.AttachedObject = page2; // Must open the page before you read and modify it. page2.Open(); // Get the page view for base adaptive view. IPageView baseView2 = page2.PageViews[document.AdaptiveViewSet.Base.Guid]; IToast toast = baseView2.CreateWidget(WidgetType.Toast) as IToast; toast.Annotation.SetTextValue("CreatedTime", DateTime.Now.ToString()); toast.WidgetStyle.Height = 146; toast.WidgetStyle.Width = 298; toast.WidgetStyle.X = 200; toast.WidgetStyle.Y = 700; toast.WidgetStyle.Z = 15; toast.Name = "Toast 1"; toast.Tooltip = "A ExposureTime toast."; toast.ExposureTime = 3; toast.DisplayPosition = ToastDisplayPosition.UserSetting; toast.CloseSetting = ToastCloseSetting.CloseButton; IPage toastPage = toast.ToastPage; toastPage.Open(); // Open page to edit. // Get the base view of toast page. IPageView toastBaseView = toastPage.PageViews[document.AdaptiveViewSet.Base.Guid]; IShape ellipse = toastBaseView.CreateWidget(WidgetType.Shape) as IShape; ellipse.ShapeType = ShapeType.Ellipse; ellipse.Annotation.SetTextValue("CreatedTime", DateTime.Now.ToString()); ellipse.WidgetStyle.Height = 100; ellipse.WidgetStyle.Width = 100; ellipse.Name = "Ellipse 1"; ellipse.Tooltip = "A Ellipse."; ellipse.SetRichText("Ellipse"); toastPage.Close(); // Close Page to release resources. // Close the page if you don't want to work on it. page2.Close(); // Create a page. IDocumentPage page3 = document.CreatePage("Page 3"); // Create the page node in page tree. ITreeNode node3 = document.DocumentSettings.LayoutSetting.PageTree.AddChild(TreeNodeType.Page); node3.AttachedObject = page3; // Must open the page before you read and modify it. page3.Open(); // Get the page view for base adaptive view. IPageView baseView3 = page3.PageViews[document.AdaptiveViewSet.Base.Guid]; IDynamicPanel dynamicPanel = baseView3.CreateWidget(WidgetType.DynamicPanel) as IDynamicPanel; dynamicPanel.Annotation.SetTextValue("CreatedTime", DateTime.Now.ToString()); dynamicPanel.WidgetStyle.Height = 198; dynamicPanel.WidgetStyle.Width = 152; dynamicPanel.WidgetStyle.X = 500; dynamicPanel.WidgetStyle.Y = 700; dynamicPanel.WidgetStyle.Z = 16; dynamicPanel.IsAutomatic = true; // Set start panel page as the first created page. dynamicPanel.StartPanelStatePage = dynamicPanel.CreatePanelStatePage("Panel 1"); dynamicPanel.CreatePanelStatePage("Panel 2"); dynamicPanel.CreatePanelStatePage("Panel 3"); int imageFileName = 1; foreach (IPage statePage in dynamicPanel.PanelStatePages) { statePage.Open(); // Open page to edit. // Get the base view of state page. IPageView stateBaseView = statePage.PageViews[document.AdaptiveViewSet.Base.Guid]; IImage statePageImage = stateBaseView.CreateWidget(WidgetType.Image) as IImage; statePageImage.Annotation.SetTextValue("CreatedTime", DateTime.Now.ToString()); statePageImage.WidgetStyle.Height = 198; statePageImage.WidgetStyle.Width = 152; string statePageImageFile = Path.Combine(Program.WORKING_IMAGES_DIRECTORY, "HangGame", imageFileName + ".png"); if (File.Exists(statePageImageFile)) { using (FileStream fileStream = new FileStream(statePageImageFile, FileMode.Open, FileAccess.Read)) { MemoryStream imageStream = new MemoryStream(); fileStream.CopyTo(imageStream); statePageImage.ImageStream = imageStream; } } statePage.Close(); // Close Page to release resources. imageFileName++; } // Close the page if you don't want to work on it. page3.Close(); document.DeletePage(page3.Guid); document.DocumentSettings.LayoutSetting.PageTree.RemoveChild(node3); // Save the document to a pn file. string fileName = Path.Combine(Program.WORKING_DIRECTORY, _caseName + ".pn"); Program.Service.Save(fileName); // Close this document when you don't work on it anymore. Program.Service.Close(); }
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(); }
protected override void RunInternal() { Program.Service.NewDocument(DocumentType.Standard); IDocument document = Program.Service.Document; IDocumentPage page = document.CreatePage("Page 1"); // Create the page node in page tree. ITreeNode node = document.DocumentSettings.LayoutSetting.PageTree.AddChild(TreeNodeType.Page); node.AttachedObject = page; // Must open the page before you read and modify it. page.Open(); IPageView baseView = page.PageViews[document.AdaptiveViewSet.Base.Guid]; IShape roundedRectangle = baseView.CreateWidget(WidgetType.Shape) as IShape; roundedRectangle.ShapeType = ShapeType.RoundedRectangle; roundedRectangle.Annotation.SetTextValue("CreatedTime", DateTime.Now.ToString()); roundedRectangle.WidgetStyle.Height = 100; roundedRectangle.WidgetStyle.Width = 200; roundedRectangle.WidgetStyle.X = 10; roundedRectangle.WidgetStyle.Y = 10; roundedRectangle.WidgetStyle.Z = 0; roundedRectangle.Name = "RoundedRectangle 1"; roundedRectangle.Tooltip = "A Rounded Rectangle."; roundedRectangle.SetRichText("RoundedRectangle"); roundedRectangle.WidgetStyle.Bold = true; roundedRectangle.WidgetStyle.FillColor = new StyleColor(ColorFillType.Solid, -999); roundedRectangle.WidgetStyle.FontColor = new StyleColor(ColorFillType.Solid, -35689); roundedRectangle.WidgetStyle.FontSize = 22; roundedRectangle.WidgetStyle.FontFamily = "Gull Sans"; roundedRectangle.WidgetStyle.Italic = true; roundedRectangle.WidgetStyle.Underline = true; roundedRectangle.WidgetStyle.LineColor = new StyleColor(ColorFillType.Solid, -45151); roundedRectangle.WidgetStyle.LineStyle = LineStyle.DashDotDot; roundedRectangle.WidgetStyle.LineWidth = 5; roundedRectangle.SetWidgetStyleAsDefaultStyle(document.AdaptiveViewSet.Base.Guid); IShape roundedRectangle2 = baseView.CreateWidget(WidgetType.Shape) as IShape; roundedRectangle2.ShapeType = ShapeType.RoundedRectangle; roundedRectangle2.Annotation.SetTextValue("CreatedTime", DateTime.Now.ToString()); roundedRectangle2.WidgetStyle.Height = 100; roundedRectangle2.WidgetStyle.Width = 200; roundedRectangle2.WidgetStyle.X = 10; roundedRectangle2.WidgetStyle.Y = 250; roundedRectangle2.WidgetStyle.Z = 1; roundedRectangle2.Name = "RoundedRectangle 2"; roundedRectangle2.Tooltip = "A new Rounded Rectangle."; roundedRectangle2.SetRichText("RoundedRectangle 2"); // Close the page if you don't want to work on it. page.Close(); // Save the document to a pn file. string fileName = Path.Combine(Program.WORKING_DIRECTORY, _caseName + ".pn"); Program.Service.Save(fileName); // Close this document when you don't work on it anymore. Program.Service.Close(); }
protected override void RunInternal() { Program.Service.NewDocument(DocumentType.Standard); IDocument document = Program.Service.Document; 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]; 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"; // Creata a image widget. 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 flicking widget. IDynamicPanel dynamicPanel = baseView1.CreateWidget(WidgetType.DynamicPanel) as IDynamicPanel; dynamicPanel.Annotation.SetTextValue("CreatedTime", DateTime.Now.ToString()); dynamicPanel.WidgetStyle.Height = 198; dynamicPanel.WidgetStyle.Width = 152; dynamicPanel.WidgetStyle.X = 250; dynamicPanel.WidgetStyle.Y = 250; dynamicPanel.WidgetStyle.Z = 1; dynamicPanel.IsAutomatic = true; // Set start panel page as the first created page. dynamicPanel.StartPanelStatePage = dynamicPanel.CreatePanelStatePage("Panel 1"); dynamicPanel.CreatePanelStatePage("Panel 2"); dynamicPanel.CreatePanelStatePage("Panel 3"); int imageFileName = 1; foreach (IPage statePage in dynamicPanel.PanelStatePages) { statePage.Open(); // Open page to edit. // Get the base view of state page. IPageView stateBaseView = statePage.PageViews[document.AdaptiveViewSet.Base.Guid]; IImage statePageImage = stateBaseView.CreateWidget(WidgetType.Image) as IImage; statePageImage.Annotation.SetTextValue("CreatedTime", DateTime.Now.ToString()); statePageImage.WidgetStyle.Height = 198; statePageImage.WidgetStyle.Width = 152; string statePageImageFile = Path.Combine(Program.WORKING_IMAGES_DIRECTORY, "HangGame", imageFileName + ".png"); if (File.Exists(statePageImageFile)) { using (FileStream fileStream = new FileStream(statePageImageFile, FileMode.Open, FileAccess.Read)) { MemoryStream imageStream = new MemoryStream(); fileStream.CopyTo(imageStream); statePageImage.ImageStream = imageStream; } } statePage.Close(); // Close Page to release resources. imageFileName++; } // Create a group List <Guid> widgetGuidList = new List <Guid>(); widgetGuidList.Add(image.Guid); widgetGuidList.Add(dynamicPanel.Guid); IGroup group = page1.CreateGroup(widgetGuidList); // Create a serialize writer. ISerializeWriter writer = document.CreateSerializeWriter(document.AdaptiveViewSet.Base.Guid); // Add widgets and groups you want to copy to the writer. writer.AddGroup(group); // Serialize widgets and groups to a stream. Stream stream = writer.WriteToStream(); // Paste stream back to page 1. IObjectContainer container = baseView1.AddObjects(stream); // Change the new widgets location. foreach (IWidget widget in container.WidgetList) { widget.WidgetStyle.X = widget.WidgetStyle.X + 50; widget.WidgetStyle.Y = widget.WidgetStyle.Y + 50; } page1.Close(); // Paste stream to page 2. IDocumentPage page2 = document.CreatePage("Page 2"); ITreeNode node2 = document.DocumentSettings.LayoutSetting.PageTree.AddChild(TreeNodeType.Page); node2.AttachedObject = page2; page2.Open(); // Get the page view for base adaptive view. IPageView baseView2 = page2.PageViews[document.AdaptiveViewSet.Base.Guid]; baseView2.AddObjects(stream); // Paste to page 2. page2.Close(); // Save document. string fileName = Path.Combine(Program.WORKING_DIRECTORY, _caseName + ".pn"); Program.Service.Save(fileName); Program.Service.Close(); }
protected override void RunInternal() { // Load a library file string libraryFileName = Path.Combine(Program.WORKING_DIRECTORY, "Test_CreateLibraryDocument.libpn"); ILibrary libraryLoad = Program.Service.LibraryManager.LoadLibrary(libraryFileName); // Cache the library guid. Guid libraryGuid = libraryLoad.Guid; // Create a new document. Program.Service.NewDocument(DocumentType.Standard); IDocument document = Program.Service.Document; // Create a page. IDocumentPage page = document.CreatePage("Home"); // Create the page node in page tree. ITreeNode node = document.DocumentSettings.LayoutSetting.PageTree.AddChild(TreeNodeType.Page); node.AttachedObject = page; // Must open the page before you read and modify it. page.Open(); // Get the page view for base adaptive view. IPageView baseView = page.PageViews[document.AdaptiveViewSet.Base.Guid]; // Create widgets on the base view in this page. IButton button = baseView.CreateWidget(WidgetType.Button) as IButton; button.WidgetStyle.Height = 30; button.WidgetStyle.Width = 100; button.Name = "Button 1"; button.Text = "Button"; button.Tooltip = "Html button."; // Get the loaded library with the cached guid. ILibrary libraryGet = Program.Service.LibraryManager.GetLibrary(libraryGuid); // Put the button in a writer. ISerializeWriter writer = document.CreateSerializeWriter(document.AdaptiveViewSet.Base.Guid); writer.AddWidget(button); // Create a new custom object which contains the button and add to the loaded library. libraryGet.AddCustomObject(writer, "New_Custom_Object_Which_Contains_Button", null, null); // Save changes to file libraryGet.Save(libraryGet.Name); page.Close(); // Save the document to a pn file. string fileName = Path.Combine(Program.WORKING_DIRECTORY, _caseName + ".pn"); Program.Service.Save(fileName); // Close this document when you don't work on it anymore. Program.Service.Close(); // Delete loaded libraries Program.Service.LibraryManager.DeleteLibrary(libraryGuid); }
protected override void RunInternal() { // Create a document. Program.Service.NewDocument(DocumentType.Standard); IDocument document = Program.Service.Document; // Create a new page. 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 widget in the new page. IImage image = baseView1.CreateWidget(WidgetType.Image) as IImage; image.Annotation.SetTextValue("CreatedTime", DateTime.Now.ToString()); image.WidgetStyle.Height = 267; image.WidgetStyle.Width = 116; image.WidgetStyle.WidgetRotate = 60; image.WidgetStyle.X = 100; image.WidgetStyle.Y = 100; 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 serialize writer first. ISerializeWriter writer = document.CreateSerializeWriter(document.AdaptiveViewSet.Base.Guid); // Add selected widgets in the writer. writer.AddWidget(image); MemoryStream iconStream = new MemoryStream(); string iconFile = Path.Combine(Program.WORKING_IMAGES_DIRECTORY, "icon", "3.png"); if (File.Exists(iconFile)) { using (FileStream fileStream = new FileStream(iconFile, FileMode.Open, FileAccess.Read)) { fileStream.CopyTo(iconStream); } } // Create a custom object which name is "CustomObjectName", the custom object is contains the widgets // you added in ISerializeWriter. // The new custom object is added to a new library document and the new library is managed by DocumentService. ILibrary library = Program.Service.LibraryManager.CreateLibrary(writer, "CustomObjectName", iconStream, null); iconStream.Dispose(); // Save the new library to a library file .libpn, the file extension is .libpn!!!!!!! string libraryFileName = Path.Combine(Program.WORKING_DIRECTORY, _caseName + ".libpn"); library.Save(libraryFileName); // Close the page. page1.Close(); // Close the document. Program.Service.Close(); // Delete the new library from DocumentService. Program.Service.LibraryManager.DeleteLibrary(library.Guid); }
protected override void RunInternal() { // Create a new document. Program.Service.NewDocument(DocumentType.Standard); IDocument document = Program.Service.Document; // Create a page note field. document.PageAnnotationFieldSet.CreateAnnotationField("Default", AnnotationFieldType.Text); // Create some widget note fields. document.WidgetAnnotationFieldSet.CreateAnnotationField("Description", AnnotationFieldType.Text); document.WidgetAnnotationFieldSet.CreateAnnotationField("CreatedTime", AnnotationFieldType.Text); // Create a device. IDevice devide = document.DeviceSet.CreateDevice("iPhone 6 Plus"); devide.Width = 1024; devide.Height = 768; devide.IsChecked = true; // Create a page. IDocumentPage page = document.CreatePage("Home"); // Create the page node in page tree. ITreeNode node = document.DocumentSettings.LayoutSetting.PageTree.AddChild(TreeNodeType.Page); node.AttachedObject = page; // Must open the page before you read and modify it. page.Open(); // Set page note. page.Annotation.SetTextValue("Default", "This Home page."); // Get the page view for base adaptive view. IPageView baseView = page.PageViews[document.AdaptiveViewSet.Base.Guid]; // Create widgets on the base view in this page. IButton button = baseView.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."; ICheckbox checkbox = baseView.CreateWidget(WidgetType.Checkbox) as ICheckbox; checkbox.Annotation.SetTextValue("CreatedTime", DateTime.Now.ToString()); checkbox.WidgetStyle.Height = 18; checkbox.WidgetStyle.Width = 120; checkbox.WidgetStyle.X = 150; checkbox.WidgetStyle.Y = 0; checkbox.WidgetStyle.Z = 1; checkbox.Name = "CheckBox 1"; checkbox.Text = "CheckBox"; checkbox.Tooltip = "Left align check box."; IDroplist dropList = baseView.CreateWidget(WidgetType.DropList) as IDroplist; dropList.Annotation.SetTextValue("CreatedTime", DateTime.Now.ToString()); dropList.WidgetStyle.Height = 22; dropList.WidgetStyle.Width = 200; dropList.WidgetStyle.X = 300; dropList.WidgetStyle.Y = 0; dropList.WidgetStyle.Z = 2; dropList.Name = "Droplist 1"; dropList.Tooltip = "A droplist has 3 item and item 3 is seleted."; // Create list items. dropList.CreateItem("Droplist Item 1"); dropList.CreateItem("Droplist Item 2"); IListItem item3 = dropList.CreateItem("Droplist Item 3"); item3.IsSelected = true; /* * IFlowShape flowShap = baseView.CreateWidget(WidgetType.FlowShape) as IFlowShape; // Here flow shape type is none. * // You must set specific flow shape type, then the flowshape is a valid flowshape. * flowShap.FlowShapeType = FlowShapeType.Database; * flowShap.Annotation.SetTextValue("CreatedTime", DateTime.Now.ToString()); * flowShap.Height = 80; * flowShap.Width = 60; * flowShap.X = 550; * flowShap.Y = 0; * flowShap.Z = 3; * flowShap.Name = "FlowShape 1"; * flowShap.Tooltip = "A Database flow shape."; * flowShap.SetRichText("Database"); // FlowShape support rich text. */ IHotSpot hotSpot = baseView.CreateWidget(WidgetType.HotSpot) as IHotSpot; hotSpot.Annotation.SetTextValue("CreatedTime", DateTime.Now.ToString()); hotSpot.WidgetStyle.Height = 100; hotSpot.WidgetStyle.Width = 100; hotSpot.WidgetStyle.X = 0; hotSpot.WidgetStyle.Y = 100; hotSpot.WidgetStyle.Z = 4; hotSpot.Name = "HotSpot 1"; hotSpot.Tooltip = "A hot sport link to Baidu"; // Create a link action to open www.baidu.com in new window. IInteractionEvent clickEvent = hotSpot.Events[EventType.OnClick]; IInteractionCase case1 = clickEvent.CreateCase("clickCase"); IInteractionOpenAction openAction = case1.CreateAction(ActionType.OpenAction) as IInteractionOpenAction; openAction.LinkType = LinkType.LinkToUrl; openAction.ExternalUrl = @"www.baidu.com"; openAction.OpenIn = ActionOpenIn.NewWindowOrTab; IImage image = baseView.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"; 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; } } ILine line = baseView.CreateWidget(WidgetType.Line) as ILine; line.Annotation.SetTextValue("CreatedTime", DateTime.Now.ToString()); line.Orientation = Orientation.Vertical; line.WidgetStyle.Height = 200; line.WidgetStyle.Width = 10; line.WidgetStyle.X = 300; line.WidgetStyle.Y = 100; line.WidgetStyle.Z = 6; line.Name = "Line"; line.Tooltip = "A Vertical line with"; IListBox listBox = baseView.CreateWidget(WidgetType.ListBox) as IListBox; listBox.Annotation.SetTextValue("CreatedTime", DateTime.Now.ToString()); listBox.WidgetStyle.Height = 100; listBox.WidgetStyle.Width = 200; listBox.WidgetStyle.X = 350; listBox.WidgetStyle.Y = 100; listBox.WidgetStyle.Z = 7; listBox.Tooltip = "A multiple-selected listBox which has 5 itmes. Item 1 and item 4 is selcted."; listBox.AllowMultiple = true; IListItem item1 = listBox.CreateItem("ListBox Item 1"); item1.IsSelected = true; listBox.CreateItem("ListBox Item 2"); listBox.CreateItem("ListBox Item 3"); IListItem item4 = listBox.CreateItem("ListBox Item 4"); item4.IsSelected = true; listBox.CreateItem("ListBox Item 5"); IRadioButton radioButton = baseView.CreateWidget(WidgetType.RadioButton) as IRadioButton; radioButton.Annotation.SetTextValue("CreatedTime", DateTime.Now.ToString()); radioButton.WidgetStyle.Height = 18; radioButton.WidgetStyle.Width = 120; radioButton.WidgetStyle.X = 0; radioButton.WidgetStyle.Y = 300; radioButton.WidgetStyle.Z = 8; radioButton.AlignButton = AlignButton.Right; radioButton.Text = "Radio Button"; radioButton.Tooltip = "A right aligned radio button"; IShape lable = baseView.CreateWidget(WidgetType.Shape) as IShape; lable.ShapeType = ShapeType.Paragraph; lable.Annotation.SetTextValue("CreatedTime", DateTime.Now.ToString()); lable.WidgetStyle.Height = 100; lable.WidgetStyle.Width = 200; lable.WidgetStyle.X = 150; lable.WidgetStyle.Y = 300; lable.WidgetStyle.Z = 9; lable.Name = "Label 1"; lable.Tooltip = "A label."; lable.SetRichText("Label"); lable.WidgetStyle.LineColor = new StyleColor(ColorFillType.Solid, -16777216); lable.WidgetStyle.LineWidth = 0; // No border lable.WidgetStyle.FillColor = new StyleColor(ColorFillType.Solid, 16777215); // Transparent lable.WidgetStyle.HorzAlign = Alignment.Left; lable.WidgetStyle.VertAlign = Alignment.Top; IShape roundedRectangle = baseView.CreateWidget(WidgetType.Shape) as IShape; roundedRectangle.ShapeType = ShapeType.RoundedRectangle; roundedRectangle.Annotation.SetTextValue("CreatedTime", DateTime.Now.ToString()); roundedRectangle.WidgetStyle.Height = 100; roundedRectangle.WidgetStyle.Width = 200; roundedRectangle.WidgetStyle.X = 400; roundedRectangle.WidgetStyle.Y = 300; roundedRectangle.WidgetStyle.Z = 10; roundedRectangle.Name = "RoundedRectangle 1"; roundedRectangle.Tooltip = "A Rounded Rectangle."; roundedRectangle.SetRichText("RoundedRectangle"); IShape triangle = baseView.CreateWidget(WidgetType.Shape) as IShape; triangle.ShapeType = ShapeType.Triangle; triangle.Annotation.SetTextValue("CreatedTime", DateTime.Now.ToString()); triangle.WidgetStyle.Height = 100; triangle.WidgetStyle.Width = 100; triangle.WidgetStyle.X = 650; triangle.WidgetStyle.Y = 300; triangle.WidgetStyle.Z = 11; triangle.Name = "Triangle 1"; triangle.Tooltip = "A Triangle."; triangle.SetRichText("Triangle"); ISvg svg = baseView.CreateWidget(WidgetType.SVG) as ISvg; svg.Annotation.SetTextValue("CreatedTime", DateTime.Now.ToString()); svg.WidgetStyle.Height = 117; svg.WidgetStyle.Width = 150; svg.WidgetStyle.X = 0; svg.WidgetStyle.Y = 450; svg.WidgetStyle.Z = 12; svg.Name = "airplane 03"; svg.Tooltip = "A airplane svg"; string svgFile = Path.Combine(Program.WORKING_IMAGES_DIRECTORY, "Svg", "airplane 03.svg"); if (File.Exists(svgFile)) { using (FileStream fileStream = new FileStream(svgFile, FileMode.Open, FileAccess.Read)) { MemoryStream svgStream = new MemoryStream(); fileStream.CopyTo(svgStream); svg.XmlStream = svgStream; } } ITextArea textArea = baseView.CreateWidget(WidgetType.TextArea) as ITextArea; textArea.Annotation.SetTextValue("CreatedTime", DateTime.Now.ToString()); textArea.WidgetStyle.Height = 100; textArea.WidgetStyle.Width = 200; textArea.WidgetStyle.X = 250; textArea.WidgetStyle.Y = 450; textArea.WidgetStyle.Z = 12; textArea.Name = "TextArea 1"; textArea.Tooltip = "A hidden border text area with max length is 10."; textArea.HintText = "Password"; textArea.MaxLength = 10; textArea.HideBorder = true; ITextField textField = baseView.CreateWidget(WidgetType.TextField) as ITextField; textField.Annotation.SetTextValue("CreatedTime", DateTime.Now.ToString()); textField.WidgetStyle.Height = 50; textField.WidgetStyle.Width = 100; textField.WidgetStyle.X = 500; textField.WidgetStyle.Y = 450; textField.WidgetStyle.Z = 13; textField.Name = "TextField 1"; textField.Tooltip = "A TextField"; textField.TextFieldType = TextFieldType.Email; textField.HintText = "emial"; IHamburgerMenu hamburgerMenu = baseView.CreateWidget(WidgetType.HamburgerMenu) as IHamburgerMenu; hamburgerMenu.Annotation.SetTextValue("CreatedTime", DateTime.Now.ToString()); hamburgerMenu.WidgetStyle.Height = 280; hamburgerMenu.WidgetStyle.Width = 150; hamburgerMenu.WidgetStyle.X = 0; hamburgerMenu.WidgetStyle.Y = 700; hamburgerMenu.WidgetStyle.Z = 14; 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 = 0; hamburgerMenu.MenuButton.WidgetStyle.Y = 700; 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]; // Create widgts on the base view in the menu page. 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. IToast toast = baseView.CreateWidget(WidgetType.Toast) as IToast; toast.Annotation.SetTextValue("CreatedTime", DateTime.Now.ToString()); toast.WidgetStyle.Height = 146; toast.WidgetStyle.Width = 298; toast.WidgetStyle.X = 200; toast.WidgetStyle.Y = 700; toast.WidgetStyle.Z = 15; toast.Name = "Toast 1"; toast.Tooltip = "A ExposureTime toast."; toast.ExposureTime = 3; toast.DisplayPosition = ToastDisplayPosition.Top; toast.CloseSetting = ToastCloseSetting.CloseButton; IPage toastPage = toast.ToastPage; toastPage.Open(); // Open page to edit. // Get the base view of toast page. IPageView toastBaseView = toastPage.PageViews[document.AdaptiveViewSet.Base.Guid]; IShape ellipse = toastBaseView.CreateWidget(WidgetType.Shape) as IShape; ellipse.ShapeType = ShapeType.Ellipse; ellipse.Annotation.SetTextValue("CreatedTime", DateTime.Now.ToString()); ellipse.WidgetStyle.Height = 100; ellipse.WidgetStyle.Width = 100; ellipse.Name = "Ellipse 1"; ellipse.Tooltip = "A Ellipse."; ellipse.SetRichText("Ellipse"); toastPage.Close(); // Close Page to release resources. IDynamicPanel dynamicPanel = baseView.CreateWidget(WidgetType.DynamicPanel) as IDynamicPanel; dynamicPanel.Annotation.SetTextValue("CreatedTime", DateTime.Now.ToString()); dynamicPanel.WidgetStyle.Height = 198; dynamicPanel.WidgetStyle.Width = 152; dynamicPanel.WidgetStyle.X = 500; dynamicPanel.WidgetStyle.Y = 700; dynamicPanel.WidgetStyle.Z = 16; dynamicPanel.IsAutomatic = true; // Set start panel page as the first created page. dynamicPanel.StartPanelStatePage = dynamicPanel.CreatePanelStatePage("Panel 1"); dynamicPanel.CreatePanelStatePage("Panel 2"); dynamicPanel.CreatePanelStatePage("Panel 3"); int imageFileName = 1; foreach (IPage statePage in dynamicPanel.PanelStatePages) { statePage.Open(); // Open page to edit. // Get the base view of state page. IPageView stateBaseView = statePage.PageViews[document.AdaptiveViewSet.Base.Guid]; IImage statePageImage = stateBaseView.CreateWidget(WidgetType.Image) as IImage; statePageImage.Annotation.SetTextValue("CreatedTime", DateTime.Now.ToString()); statePageImage.WidgetStyle.Height = 198; statePageImage.WidgetStyle.Width = 152; string statePageImageFile = Path.Combine(Program.WORKING_IMAGES_DIRECTORY, "HangGame", imageFileName + ".png"); if (File.Exists(statePageImageFile)) { using (FileStream fileStream = new FileStream(statePageImageFile, FileMode.Open, FileAccess.Read)) { MemoryStream imageStream = new MemoryStream(); fileStream.CopyTo(imageStream); statePageImage.ImageStream = imageStream; } } statePage.Close(); // Close Page to release resources. imageFileName++; } // Close the page if you don't want to work on it. page.Close(); // Save the document to a pn file. string fileName = Path.Combine(Program.WORKING_DIRECTORY, _caseName + ".pn"); Program.Service.Save(fileName); // Close this document when you don't work on it anymore. Program.Service.Close(); }