public CollectionViewTest1() { InitializeComponent(); BindingContext = new TestSourceModel(); var RadioGroup = new RadioButtonGroup(); RadioGroup.Add(ShowBar); RadioGroup.Add(HideBar); ColView.ItemTemplate = new DataTemplate(() => { var item = new RecyclerViewItem() { HeightSpecification = LayoutParamPolicies.MatchParent, WidthSpecification = 200, }; item.SetBinding(View.BackgroundColorProperty, "BgColor"); var label = new TextLabel() { ParentOrigin = Tizen.NUI.ParentOrigin.Center, PivotPoint = Tizen.NUI.PivotPoint.Center, PositionUsesPivotPoint = true, }; label.PixelSize = 30; label.SetBinding(TextLabel.TextProperty, "Index"); item.Add(label); return(item); }); }
public LinearOrientationView() { InitializeComponent(); linearOrientGroup = new RadioButtonGroup(); linearOrientGroup.Add(linearOrientH); linearOrientGroup.Add(linearOrientV); linearOrientGroup.EnableMultiSelection = false; linearOrientH.IsSelected = true; }
public HorizontalAlignmentView() { InitializeComponent(); hAlignGroup = new RadioButtonGroup(); hAlignGroup.Add(hAlignBegin); hAlignGroup.Add(hAlignCenter); hAlignGroup.Add(hAlignEnd); hAlignGroup.EnableMultiSelection = false; hAlignBegin.IsSelected = true; }
public VerticalAlignmentView() { InitializeComponent(); vAlignGroup = new RadioButtonGroup(); vAlignGroup.Add(vAlignTop); vAlignGroup.Add(vAlignCenter); vAlignGroup.Add(vAlignBottom); vAlignGroup.EnableMultiSelection = false; vAlignTop.IsSelected = true; }
public CollectionViewTest4Page() { InitializeComponent(); BindingContext = new TestSourceModel(); var RadioGroup = new RadioButtonGroup(); RadioGroup.Add(Linear); RadioGroup.Add(Grid); ColView.ItemTemplate = LinearTemplate; }
public SetColorTestPage() { InitializeComponent(); ButtonColorName.Text = GetColorValues(ChangeColorButton.BackgroundColor); CheckBoxColorName.Text = GetColorValues(CheckBox2.BackgroundColor); ProgressBarColorName.Text = GetColorValues(ProgressBar.BackgroundColor); RadioColorName.Text = GetColorValues(RadioButton2.BackgroundColor); ChangeColorButton.Clicked += OnChangeColorClicked; RadioButtonGroup group = new RadioButtonGroup(); group.Add(RadioButton1); group.Add(RadioButton2); }
public void RadioButtonGroupGetItem() { tlog.Debug(tag, $"RadioButtonGroupGetItem START"); var testingTarget = new RadioButtonGroup(); Assert.IsNotNull(testingTarget, "null handle"); Assert.IsInstanceOf <RadioButtonGroup>(testingTarget, "Should return RadioButtonGroup instance."); RadioButton button = new RadioButton(); testingTarget.Add(button); var result = testingTarget.GetItem(0); tlog.Debug(tag, "GetItem : " + result); button.IsSelected = true; tlog.Debug(tag, "GetSelectedItem : " + testingTarget.GetSelectedItem()); try { testingTarget.Remove(button); } catch (Exception e) { tlog.Debug(tag, e.Message.ToString()); Assert.Fail("Caught Exception : Failed!"); } button.Dispose(); tlog.Debug(tag, $"RadioButtonGroupGetItem END (OK)"); }
public WidthSpecificationView() { InitializeComponent(); widthSpecGroup = new RadioButtonGroup(); widthSpecGroup.Add(widthSpecMatchParent); widthSpecGroup.Add(widthSpecWrapContent); widthSpecGroup.Add(widthSpecValue); widthSpecGroup.EnableMultiSelection = false; widthSpecWrapContent.IsSelected = true; // FIXME: TextField does not support IsEnabled now. widthSpecValueField.EnableEditing = false; inputFilter = new Text.InputFilter(); inputFilter.Accepted = "[0-9]"; widthSpecValueField.SetInputFilter(inputFilter); }
public LayoutTypeView() { InitializeComponent(); layoutTypeGroup = new RadioButtonGroup(); layoutTypeGroup.Add(layoutTypeLinear); layoutTypeGroup.EnableMultiSelection = false; layoutTypeLinear.IsSelected = true; }
protected override void OnCreate() { base.OnCreate(); // Set theme to wearable. // (It is not needed in the wearable device) Tizen.NUI.Components.StyleManager.Instance.Theme = "wearable"; Window window = NUIApplication.GetDefaultWindow(); window.BackgroundColor = Color.Black; var button1 = new RadioButton() { Size = new Size(100, 100), Position = new Position(0, -50), PositionUsesPivotPoint = true, ParentOrigin = ParentOrigin.Center, PivotPoint = PivotPoint.Center, IsSelected = true, }; window.Add(button1); var button2 = new RadioButton() { Size = new Size(100, 100), Position = new Position(0, 50), PositionUsesPivotPoint = true, ParentOrigin = ParentOrigin.Center, PivotPoint = PivotPoint.Center, }; window.Add(button2); var group = new RadioButtonGroup(); group.Add(button1); group.Add(button2); }
private View CreateRadioButtonExample() { var view = new View() { WidthResizePolicy = ResizePolicyType.FillToParent, HeightResizePolicy = ResizePolicyType.FitToChildren, Layout = new LinearLayout() { LinearOrientation = LinearLayout.Orientation.Vertical, }, }; var radio1 = new RadioButton() { Text = "Always on", Padding = 7 }; var radio2 = new RadioButton() { Text = "10 minutes", Padding = 7 }; var radio3 = new RadioButton() { Text = "1 minute", Padding = 7 }; var group = new RadioButtonGroup(); group.Add(radio1); group.Add(radio2); group.Add(radio3); view.Add(radio1); view.Add(radio2); view.Add(radio3); radio1.IsSelected = true; return(view); }
public View CreateRadioButton() { View view = new View() { Size = new Size(360, 360), PositionUsesPivotPoint = true, ParentOrigin = ParentOrigin.Center, PivotPoint = PivotPoint.Center, }; var button1 = new RadioButton() { Size = new Size(100, 100), Position = new Position(0, -40), PositionUsesPivotPoint = true, ParentOrigin = ParentOrigin.Center, PivotPoint = PivotPoint.Center, IsSelected = true, }; view.Add(button1); var button2 = new RadioButton() { Size = new Size(100, 100), Position = new Position(0, 40), PositionUsesPivotPoint = true, ParentOrigin = ParentOrigin.Center, PivotPoint = PivotPoint.Center, }; view.Add(button2); var group = new RadioButtonGroup(); group.Add(button1); group.Add(button2); return(view); }
public override void Initialize() { base.Initialize(); SetBackground(Color.White); lbl = new Label("Select one"); AddComponent(lbl, 50, 50); lblBlue = new Label("Blue Pill"); rbBlue = new RadioButton(); AddComponent(rbBlue, 50, 100); AddComponent(lblBlue, 90, 100); lblRed = new Label("Red Pill"); rbRed = new RadioButton(); AddComponent(rbRed, 50, 150); AddComponent(lblRed, 90, 150); group = new RadioButtonGroup(); group.Add(rbBlue); group.Add(rbRed); check = new CheckBox(); lblmessage = new Label("Remember: all I'm offering is the truth,\n nothing more"); lblWhiteRabbit = new Label(ResourceManager.CreateImage("whiteRabbit")); AddComponent(check, 10, 300); AddComponent(lblmessage, 10, 350); AddComponent(lblWhiteRabbit, 10, 500); lblWhiteRabbit.Visible = lblmessage.Visible = check.Visible = false; //Events rbRed.Released += rbRed_Released; rbBlue.Released += rbBlue_Released; check.Released += check_Released; }
protected override void OnCreate() { base.OnCreate(); Window window = NUIApplication.GetDefaultWindow(); window.BackgroundColor = Color.Black; var button1 = new RadioButton() { Size = new Size(100, 100), Position = new Position(0, -50), PositionUsesPivotPoint = true, ParentOrigin = ParentOrigin.Center, PivotPoint = PivotPoint.Center, IsSelected = true, }; window.Add(button1); var button2 = new RadioButton() { Size = new Size(100, 100), Position = new Position(0, 50), PositionUsesPivotPoint = true, ParentOrigin = ParentOrigin.Center, PivotPoint = PivotPoint.Center, }; window.Add(button2); var group = new RadioButtonGroup(); group.Add(button1); group.Add(button2); }
public void RadioButtonItemGroup() { tlog.Debug(tag, $"RadioButtonItemGroup START"); var testingTarget = new RadioButton(); Assert.IsNotNull(testingTarget, "null handle"); Assert.IsInstanceOf <RadioButton>(testingTarget, "Should return RadioButton instance."); var group = new RadioButtonGroup(); group.Add(testingTarget); tlog.Debug(tag, "ItemGroup : " + testingTarget.ItemGroup); testingTarget.Dispose(); tlog.Debug(tag, $"RadioButtonItemGroup END (OK)"); }
protected override void InitializeComponent() { Margins = true; Child = hPanel; hPanel.Children.Add(groupBox, true); groupBox.Child = vPanel; spinBox.ValueChanged += (sender, args) => { int value = spinBox.Value; slider.Value = value; progressBar.Value = value; }; slider.ValueChanged += (sender, args) => { int value = slider.Value; spinBox.Value = value; progressBar.Value = value; }; vPanel.Children.Add(spinBox); vPanel.Children.Add(slider); vPanel.Children.Add(progressBar); vPanel.Children.Add(iProgressBar); hPanel.Children.Add(groupBox2, true); groupBox2.Child = vPanel2; comboBox.Add("Combobox Item 1", "Combobox Item 2", "Combobox Item 3"); editableComboBox.Add("Editable Item 1", "Editable Item 2", "Editable Item 3"); radioButtonGroup.Add("Radio Button 1", "Radio Button 2", "Radio Button 3"); vPanel.Children.Add(comboBox); vPanel.Children.Add(editableComboBox); vPanel.Children.Add(radioButtonGroup); }
public override void OnCreate(View root) { var container = new View() { WidthResizePolicy = ResizePolicyType.FitToChildren, HeightResizePolicy = ResizePolicyType.FitToChildren, PositionUsesPivotPoint = true, ParentOrigin = ParentOrigin.Center, PivotPoint = PivotPoint.Center, }; // RadioButton1 var view0 = new RadioButton() { Text = "1", PointSize = 18, }; container.Add(view0); // RadioButton2 var view1 = new RadioButton { Position = new Position(0, 100), IsSelected = true, PointSize = 18, Text = "2" }; container.Add(view1); // RadioButton3 var view2 = new RadioButton { Position = new Position(0, 200), IsEnabled = false, PointSize = 18, Text = "3" }; container.Add(view2); // RadioButton4 var view3 = new RadioButton { Position = new Position(0, 300), IsEnabled = false, IsSelected = true, PointSize = 18, Text = "4" }; container.Add(view3); var group0 = new RadioButtonGroup(); group0.Add(view0); group0.Add(view1); group0.Add(view2); group0.Add(view3); //================================================================ // RadioButton5 var view4 = new RadioButton(new ButtonStyle() { IncludeDefaultStyle = true, Text = new TextLabelStyle() { Text = "5", PointSize = 18 }, PositionX = 220 }); container.Add(view4); // RadioButton6 var view5 = new RadioButton(new ButtonStyle() { IncludeDefaultStyle = true, Position = new Position(220, 100), IsSelected = true, Text = new TextLabelStyle() { Text = "6", PointSize = 18 } }); container.Add(view5); // RadioButton7 var view6 = new RadioButton(new ButtonStyle() { IncludeDefaultStyle = true, Position = new Position(220, 200), IsEnabled = false, Text = new TextLabelStyle() { Text = "7", PointSize = 18 } }); container.Add(view6); // RadioButton8 var view7 = new RadioButton(new ButtonStyle() { IncludeDefaultStyle = true, Position = new Position(220, 300), IsEnabled = false, IsSelected = true, Text = new TextLabelStyle() { Text = "8", PointSize = 18 } }); container.Add(view7); var group1 = new RadioButtonGroup(); group1.Add(view4); group1.Add(view5); group1.Add(view6); group1.Add(view7); root.Add(container); }
public override void OnCreate(View root) { // RadioButton1 var view0 = new RadioButton() { Text = "RadioButton1" }; root.Add(view0); // RadioButton2 var view1 = new RadioButton { Position = new Position(0, 100), IsSelected = true, Text = "RadioButton2" }; root.Add(view1); // RadioButton3 var view2 = new RadioButton { Position = new Position(0, 200), IsEnabled = false, Text = "RadioButton3" }; root.Add(view2); // RadioButton4 var view3 = new RadioButton { Position = new Position(0, 300), IsEnabled = false, IsSelected = true, Text = "RadioButton4" }; root.Add(view3); var group0 = new RadioButtonGroup(); group0.Add(view0); group0.Add(view1); group0.Add(view2); group0.Add(view3); //================================================================ // RadioButton5 var view4 = new RadioButton(new ButtonStyle() { IncludeDefaultStyle = true, Text = new TextLabelStyle() { Text = "RadioButton5" }, PositionX = 300 }); root.Add(view4); // RadioButton6 var view5 = new RadioButton(new ButtonStyle() { IncludeDefaultStyle = true, Position = new Position(300, 100), IsSelected = true, Text = new TextLabelStyle() { Text = "RadioButton6" } }); root.Add(view5); // RadioButton7 var view6 = new RadioButton(new ButtonStyle() { IncludeDefaultStyle = true, Position = new Position(300, 200), IsEnabled = false, Text = new TextLabelStyle() { Text = "RadioButton7" } }); root.Add(view6); // RadioButton8 var view7 = new RadioButton(new ButtonStyle() { IncludeDefaultStyle = true, Position = new Position(300, 300), IsEnabled = false, IsSelected = true, Text = new TextLabelStyle() { Text = "RadioButton8" } }); root.Add(view7); var group1 = new RadioButtonGroup(); group1.Add(view4); group1.Add(view5); group1.Add(view6); group1.Add(view7); }
public void Activate() { // tool bar tool_bar = new View(); tool_bar.BackgroundColor = Color.White; tool_bar.Size2D = new Size2D(NUIApplication.GetDefaultWindow().WindowSize.Width, 100); tool_bar.PositionUsesPivotPoint = true; tool_bar.ParentOrigin = ParentOrigin.TopLeft; tool_bar.PivotPoint = PivotPoint.TopLeft; NUIApplication.GetDefaultWindow().GetDefaultLayer().Add(tool_bar); NUIApplication.GetDefaultWindow().GetDefaultLayer().RaiseToTop(); // title of tool bar mTitle = new TextLabel(); mTitle.Text = APPLICATION_TITLE_WAVE; mTitle.FontFamily = "SamsungOne 400"; mTitle.PointSize = 20; mTitle.Position2D = new Position2D(400, 42); mTitle.ParentOrigin = ParentOrigin.TopLeft; mTitle.PositionUsesPivotPoint = true; mTitle.PivotPoint = PivotPoint.TopLeft; tool_bar.Add(mTitle); // push button of tool bar var style = new ButtonStyle(); style.Icon.ResourceUrl = new Selector <string>() { Normal = SLIDE_SHOW_START_ICON, Pressed = SLIDE_SHOW_START_ICON_SELECTED }; style.Position = new Position(800, 32); style.ParentOrigin = ParentOrigin.TopLeft; style.PivotPoint = PivotPoint.TopLeft; style.Size = new Size(58, 58); mSlideshowButton = new Button(style); mSlideshowButton.Clicked += OnPushButtonClicked; mSlideshowButton.RaiseToTop(); tool_bar.Add(mSlideshowButton); // toggle button of tool bar radiosParent = new View(); radiosParent.Size = new Size(200, 40); radiosParent.Position = new Position(900, 42); var layout = new LinearLayout(); layout.LinearOrientation = LinearLayout.Orientation.Horizontal; layout.CellPadding = new Size(30, 30); radiosParent.Layout = layout; tool_bar.Add(radiosParent); toggle = new RadioButtonGroup(); for (int i = 0; i < 3; i++) { radios[i] = new RadioButton(); radios[i].Size = new Size(37, 34); toggle.Add(radios[i]); radiosParent.Add(radios[i]); } var radioStyle = radios[0].Style; radioStyle.Icon.BackgroundImage = new Selector <string>() { Normal = EFFECT_WAVE_IMAGE, Selected = EFFECT_WAVE_IMAGE_SELECTED }; radios[0].ApplyStyle(radioStyle); radioStyle = radios[1].Style; radioStyle.Icon.BackgroundImage = new Selector <string>() { Normal = EFFECT_CROSS_IMAGE, Selected = EFFECT_CROSS_IMAGE_SELECTED }; radios[1].ApplyStyle(radioStyle); radioStyle = radios[2].Style; radioStyle.Icon.BackgroundImage = new Selector <string>() { Normal = EFFECT_FOLD_IMAGE, Selected = EFFECT_FOLD_IMAGE_SELECTED }; radios[2].ApplyStyle(radioStyle); radios[0].SelectedChanged += OnWaveClicked; radios[1].SelectedChanged += OnCrossClicked; radios[2].SelectedChanged += OnFoldClicked; radios[0].IsSelected = true; // load image mCurrentTexture = LoadStageFillingTexture(IMAGES[mIndex]); // content layer is 3D. content_layer = new Layer(); content_layer.Behavior = Layer.LayerBehavior.Layer3D; NUIApplication.GetDefaultWindow().AddLayer(content_layer); //use small cubes mCubeWaveEffect = new CubeTransitionWaveEffect(NUM_ROWS_WAVE, NUM_COLUMNS_WAVE); mCubeWaveEffect.SetTransitionDuration(ANIMATION_DURATION_WAVE); mCubeWaveEffect.SetCubeDisplacement(CUBE_DISPLACEMENT_WAVE); mCubeWaveEffect.TransitionCompleted += OnCubeEffectCompleted; mCubeWaveEffect.Position2D = new Position2D(0, tool_bar.Size2D.Height); mCubeWaveEffect.Size2D = new Size2D(NUIApplication.GetDefaultWindow().WindowSize.Width, NUIApplication.GetDefaultWindow().WindowSize.Height - tool_bar.Size2D.Height); mCubeWaveEffect.PivotPoint = PivotPoint.TopLeft; mCubeWaveEffect.ParentOrigin = ParentOrigin.TopLeft; mCubeWaveEffect.SetCurrentTexture(mCurrentTexture); // use big cubes mCubeCrossEffect = new CubeTransitionCrossEffect(NUM_ROWS_CROSS, NUM_COLUMNS_CROSS); mCubeCrossEffect.SetTransitionDuration(ANIMATION_DURATION_CROSS); mCubeCrossEffect.SetCubeDisplacement(CUBE_DISPLACEMENT_CROSS); mCubeCrossEffect.TransitionCompleted += OnCubeEffectCompleted; mCubeCrossEffect.Position2D = new Position2D(0, tool_bar.Size2D.Height); mCubeCrossEffect.Size2D = new Size2D(NUIApplication.GetDefaultWindow().WindowSize.Width, NUIApplication.GetDefaultWindow().WindowSize.Height - tool_bar.Size2D.Height); mCubeCrossEffect.PivotPoint = PivotPoint.TopLeft; mCubeCrossEffect.ParentOrigin = ParentOrigin.TopLeft; mCubeCrossEffect.SetCurrentTexture(mCurrentTexture); mCubeFoldEffect = new CubeTransitionFoldEffect(NUM_ROWS_FOLD, NUM_COLUMNS_FOLD); mCubeFoldEffect.SetTransitionDuration(ANIMATION_DURATION_FOLD); mCubeFoldEffect.TransitionCompleted += OnCubeEffectCompleted; mCubeFoldEffect.Position2D = new Position2D(0, tool_bar.Size2D.Height); mCubeFoldEffect.Size2D = new Size2D(NUIApplication.GetDefaultWindow().WindowSize.Width, NUIApplication.GetDefaultWindow().WindowSize.Height - tool_bar.Size2D.Height); mCubeFoldEffect.PivotPoint = PivotPoint.TopLeft; mCubeFoldEffect.ParentOrigin = ParentOrigin.TopLeft; mCubeFoldEffect.SetCurrentTexture(mCurrentTexture); mViewTimer = new Timer(VIEWINGTIME); mViewTimer.Tick += OnTimerTick; // content mCurrentEffect = mCubeWaveEffect; mContent = new View(); mContent.Size2D = new Size2D(NUIApplication.GetDefaultWindow().WindowSize.Width, NUIApplication.GetDefaultWindow().WindowSize.Height - tool_bar.Size2D.Height); mContent.ParentOrigin = ParentOrigin.TopLeft; mContent.PositionUsesPivotPoint = true; mContent.PivotPoint = PivotPoint.TopLeft; mContent.Add(mCurrentEffect); content_layer.Add(mContent); mPanGestureDetector = new PanGestureDetector(); mPanGestureDetector.Detected += OnPanGesture; mPanGestureDetector.Attach(mContent); }
public override void Initialize() { base.Initialize(); SetBackground(ResourceManager.CreateImage("metalBG"), Adjustment.FILL); Button button = new Button("Button"); ToggleButton toggleButton = new ToggleButton("Toggle"); toggleButton.Scalable = true; toggleButton.Rotable = true; toggleButton.Draggable = true; Label label = new Label("Label"); CheckBox checkbox1 = new CheckBox(); CheckBox checkbox2 = new CheckBox(); CheckBox checkbox3 = new CheckBox(); RadioButton radioButton1 = new RadioButton(); RadioButton radioButton2 = new RadioButton(); RadioButton radioButton3 = new RadioButton(); RadioButtonGroup group = new RadioButtonGroup(); group.Add(radioButton1); group.Add(radioButton2); group.Add(radioButton3); ProgressBar progressBar = new ProgressBar(); progressBar.Value = 50; Slider slider = new Slider(); string[] array = new string[] { "Listbox1", "Listbox2", "Listbox3", "Listbox4", "Listbox5", "Listbox6", "Listbox7", "Listbox8", "Listbox9", "Listbox10" }; ListBox listbox = new ListBox(array, 460, 200, ListBox.Orientation.VERTICAL); TextArea text = new TextArea("Text", 1, 10); ////Buttons & Toggle AddComponent(button, 10, 10); AddComponent(toggleButton, 100, 10); ////Label AddComponent(label, 10, 80); ////Checkbox AddComponent(checkbox1, 300, 10); AddComponent(checkbox2, 300, 50); AddComponent(checkbox3, 300, 90); ////RadioButton AddComponent(radioButton1, 350, 10); AddComponent(radioButton2, 350, 50); AddComponent(radioButton3, 350, 90); //ProgressBar AddComponent(progressBar, 10, 150); //Slider AddComponent(slider, 10, 200); //ListBox AddComponent(listbox, 10, 250); AddComponent(text, 10, 500); }
static void Main(string[] args) { PDFNet.Initialize(); // Relative path to the folder containing test files. // string input_path = "../../TestFiles/"; string output_path = "../../TestFiles/Output/"; // The vector used to store the name and count of all fields. // This is used later on to clone the fields Dictionary <string, int> field_names = new Dictionary <string, int>(); //---------------------------------------------------------------------------------- // Example 1: Programatically create new Form Fields and Widget Annotations. //---------------------------------------------------------------------------------- try { using (PDFDoc doc = new PDFDoc()) { // Create a blank new page and add some form fields. Page blank_page = doc.PageCreate(); // Text Widget Creation // Create an empty text widget with black text. TextWidget text1 = TextWidget.Create(doc, new Rect(110, 700, 380, 730)); text1.SetText("Basic Text Field"); text1.RefreshAppearance(); blank_page.AnnotPushBack(text1); // Create a vertical text widget with blue text and a yellow background. TextWidget text2 = TextWidget.Create(doc, new Rect(50, 400, 90, 730)); text2.SetRotation(90); // Set the text content. text2.SetText(" ****Lucky Stars!****"); // Set the font type, text color, font size, border color and background color. text2.SetFont(Font.Create(doc, Font.StandardType1Font.e_helvetica_oblique)); text2.SetFontSize(28); text2.SetTextColor(new ColorPt(0, 0, 1), 3); text2.SetBorderColor(new ColorPt(0, 0, 0), 3); text2.SetBackgroundColor(new ColorPt(1, 1, 0), 3); text2.RefreshAppearance(); // Add the annotation to the page. blank_page.AnnotPushBack(text2); // Create two new text widget with Field names employee.name.first and employee.name.last // This logic shows how these widgets can be created using either a field name string or // a Field object TextWidget text3 = TextWidget.Create(doc, new Rect(110, 660, 380, 690), "employee.name.first"); text3.SetText("Levi"); text3.SetFont(Font.Create(doc, Font.StandardType1Font.e_times_bold)); text3.RefreshAppearance(); blank_page.AnnotPushBack(text3); Field emp_last_name = doc.FieldCreate("employee.name.last", Field.Type.e_text, "Ackerman"); TextWidget text4 = TextWidget.Create(doc, new Rect(110, 620, 380, 650), emp_last_name); text4.SetFont(Font.Create(doc, Font.StandardType1Font.e_times_bold)); text4.RefreshAppearance(); blank_page.AnnotPushBack(text4); // Signature Widget Creation (unsigned) SignatureWidget signature1 = SignatureWidget.Create(doc, new Rect(110, 560, 260, 610)); signature1.RefreshAppearance(); blank_page.AnnotPushBack(signature1); // CheckBox Widget Creation // Create a check box widget that is not checked. CheckBoxWidget check1 = CheckBoxWidget.Create(doc, new Rect(140, 490, 170, 520)); check1.RefreshAppearance(); blank_page.AnnotPushBack(check1); // Create a check box widget that is checked. CheckBoxWidget check2 = CheckBoxWidget.Create(doc, new Rect(190, 490, 250, 540), "employee.name.check1"); check2.SetBackgroundColor(new ColorPt(1, 1, 1), 3); check2.SetBorderColor(new ColorPt(0, 0, 0), 3); // Check the widget (by default it is unchecked). check2.SetChecked(true); check2.RefreshAppearance(); blank_page.AnnotPushBack(check2); // PushButton Widget Creation PushButtonWidget pushbutton1 = PushButtonWidget.Create(doc, new Rect(380, 490, 520, 540)); pushbutton1.SetTextColor(new ColorPt(1, 1, 1), 3); pushbutton1.SetFontSize(36); pushbutton1.SetBackgroundColor(new ColorPt(0, 0, 0), 3); // Add a caption for the pushbutton. pushbutton1.SetStaticCaptionText("PushButton"); pushbutton1.RefreshAppearance(); blank_page.AnnotPushBack(pushbutton1); // ComboBox Widget Creation ComboBoxWidget combo1 = ComboBoxWidget.Create(doc, new Rect(280, 560, 580, 610)); // Add options to the combobox widget. combo1.AddOption("Combo Box No.1"); combo1.AddOption("Combo Box No.2"); combo1.AddOption("Combo Box No.3"); // Make one of the options in the combo box selected by default. combo1.SetSelectedOption("Combo Box No.2"); combo1.SetTextColor(new ColorPt(1, 0, 0), 3); combo1.SetFontSize(28); combo1.RefreshAppearance(); blank_page.AnnotPushBack(combo1); // ListBox Widget Creation ListBoxWidget list1 = ListBoxWidget.Create(doc, new Rect(400, 620, 580, 730)); // Add one option to the listbox widget. list1.AddOption("List Box No.1"); // Add multiple options to the listbox widget in a batch. string[] list_options = new string[2] { "List Box No.2", "List Box No.3" }; list1.AddOptions(list_options); // Select some of the options in list box as default options list1.SetSelectedOptions(list_options); // Enable list box to have multi-select when editing. list1.GetField().SetFlag(Field.Flag.e_multiselect, true); list1.SetFont(Font.Create(doc, Font.StandardType1Font.e_times_italic)); list1.SetTextColor(new ColorPt(1, 0, 0), 3); list1.SetFontSize(28); list1.SetBackgroundColor(new ColorPt(1, 1, 1), 3); list1.RefreshAppearance(); blank_page.AnnotPushBack(list1); // RadioButton Widget Creation // Create a radio button group and add three radio buttons in it. RadioButtonGroup radio_group = RadioButtonGroup.Create(doc, "RadioGroup"); RadioButtonWidget radiobutton1 = radio_group.Add(new Rect(140, 410, 190, 460)); radiobutton1.SetBackgroundColor(new ColorPt(1, 1, 0), 3); radiobutton1.RefreshAppearance(); RadioButtonWidget radiobutton2 = radio_group.Add(new Rect(310, 410, 360, 460)); radiobutton2.SetBackgroundColor(new ColorPt(0, 1, 0), 3); radiobutton2.RefreshAppearance(); RadioButtonWidget radiobutton3 = radio_group.Add(new Rect(480, 410, 530, 460)); // Enable the third radio button. By default the first one is selected radiobutton3.EnableButton(); radiobutton3.SetBackgroundColor(new ColorPt(0, 1, 1), 3); radiobutton3.RefreshAppearance(); radio_group.AddGroupButtonsToPage(blank_page); // Custom push button annotation creation PushButtonWidget custom_pushbutton1 = PushButtonWidget.Create(doc, new Rect(260, 320, 360, 360)); // Set the annotation appearance. custom_pushbutton1.SetAppearance(CreateCustomButtonAppearance(doc, false), Annot.AnnotationState.e_normal); // Create 'SubmitForm' action. The action will be linked to the button. FileSpec url = FileSpec.CreateURL(doc, "http://www.pdftron.com"); pdftron.PDF.Action button_action = pdftron.PDF.Action.CreateSubmitForm(url); // Associate the above action with 'Down' event in annotations action dictionary. Obj annot_action = custom_pushbutton1.GetSDFObj().PutDict("AA"); annot_action.Put("D", button_action.GetSDFObj()); blank_page.AnnotPushBack(custom_pushbutton1); // Add the page as the last page in the document. doc.PagePushBack(blank_page); // If you are not satisfied with the look of default auto-generated appearance // streams you can delete "AP" entry from the Widget annotation and set // "NeedAppearances" flag in AcroForm dictionary: // doc.GetAcroForm().PutBool("NeedAppearances", true); // This will force the viewer application to auto-generate new appearance streams // every time the document is opened. // // Alternatively you can generate custom annotation appearance using ElementWriter // and then set the "AP" entry in the widget dictionary to the new appearance // stream. // // Yet another option is to pre-populate field entries with dummy text. When // you edit the field values using PDFNet the new field appearances will match // the old ones. doc.RefreshFieldAppearances(); doc.Save(output_path + "forms_test1.pdf", 0); Console.WriteLine("Done."); } } catch (PDFNetException e) { Console.WriteLine(e.Message); } //---------------------------------------------------------------------------------- // Example 2: // Fill-in forms / Modify values of existing fields. // Traverse all form fields in the document (and print out their names). // Search for specific fields in the document. //---------------------------------------------------------------------------------- try { using (PDFDoc doc = new PDFDoc(output_path + "forms_test1.pdf")) { doc.InitSecurityHandler(); FieldIterator itr; for (itr = doc.GetFieldIterator(); itr.HasNext(); itr.Next()) { Field field = itr.Current(); string cur_field_name = field.GetName(); // Add one to the count for this field name for later processing field_names[cur_field_name] = (field_names.ContainsKey(cur_field_name) ? field_names[cur_field_name] + 1 : 1); Console.WriteLine("Field name: {0}", field.GetName()); Console.WriteLine("Field partial name: {0}", field.GetPartialName()); string str_val = field.GetValueAsString(); Console.Write("Field type: "); Field.Type type = field.GetType(); switch (type) { case Field.Type.e_button: Console.WriteLine("Button"); break; case Field.Type.e_radio: Console.WriteLine("Radio button: Value = " + str_val); break; case Field.Type.e_check: field.SetValue(true); Console.WriteLine("Check box: Value = " + str_val); break; case Field.Type.e_text: { Console.WriteLine("Text"); // Edit all variable text in the document String old_value = "none"; if (field.GetValue() != null) { old_value = field.GetValue().GetAsPDFText(); } field.SetValue("This is a new value. The old one was: " + old_value); } break; case Field.Type.e_choice: Console.WriteLine("Choice"); break; case Field.Type.e_signature: Console.WriteLine("Signature"); break; } Console.WriteLine("------------------------------"); } // Search for a specific field Field fld = doc.GetField("employee.name.first"); if (fld != null) { Console.WriteLine("Field search for {0} was successful", fld.GetName()); } else { Console.WriteLine("Field search failed."); } // Regenerate field appearances. doc.RefreshFieldAppearances(); doc.Save(output_path + "forms_test_edit.pdf", 0); Console.WriteLine("Done."); } } catch (PDFNetException e) { Console.WriteLine(e.Message); } //---------------------------------------------------------------------------------- // Sample: Form templating // Replicate pages and form data within a document. Then rename field names to make // them unique. //---------------------------------------------------------------------------------- try { // Sample: Copying the page with forms within the same document using (PDFDoc doc = new PDFDoc(output_path + "forms_test1.pdf")) { doc.InitSecurityHandler(); Page src_page = doc.GetPage(1); doc.PagePushBack(src_page); // Append several copies of the second page doc.PagePushBack(src_page); // Note that forms are successfully copied doc.PagePushBack(src_page); doc.PagePushBack(src_page); // Now we rename fields in order to make every field unique. // You can use this technique for dynamic template filling where you have a 'master' // form page that should be replicated, but with unique field names on every page. foreach (KeyValuePair <string, int> cur_field in field_names) { RenameAllFields(doc, cur_field.Key, cur_field.Value); } doc.Save(output_path + "forms_test1_cloned.pdf", 0); Console.WriteLine("Done."); } } catch (PDFNetException e) { Console.WriteLine(e.Message); } //---------------------------------------------------------------------------------- // Sample: // Flatten all form fields in a document. // Note that this sample is intended to show that it is possible to flatten // individual fields. PDFNet provides a utility function PDFDoc.FlattenAnnotations() // that will automatically flatten all fields. //---------------------------------------------------------------------------------- try { using (PDFDoc doc = new PDFDoc(output_path + "forms_test1.pdf")) { doc.InitSecurityHandler(); bool auto = true; if (auto) { doc.FlattenAnnotations(); } else // Manual flattening { // Traverse all pages PageIterator pitr = doc.GetPageIterator(); for (; pitr.HasNext(); pitr.Next()) { Page page = pitr.Current(); for (int i = page.GetNumAnnots() - 1; i >= 0; --i) { Annot annot = page.GetAnnot(i); if (annot.GetType() == Annot.Type.e_Widget) { annot.Flatten(page); } } } } doc.Save(output_path + "forms_test1_flattened.pdf", 0); Console.WriteLine("Done."); } } catch (PDFNetException e) { Console.WriteLine(e.Message); } }