public PrinterOnMobileActivityData() { Options = new PrinterOnJobOptions(); }
/// <summary> /// Set job options /// </summary> /// <param name="option"><see cref="PrinterOnJobOptions"/> should be given</param> public void SetOptions(MobilePrintJobOptions option) { PrinterOnJobOptions ponOption = (PrinterOnJobOptions)option; _name = ponOption.GetOption("name"); _email = ponOption.GetOption("email"); // If all default, skip option setting if (ponOption.Copies == -1 && ponOption.Page == null && ponOption.Orientation == null && ponOption.Color == null && ponOption.Duplex == null && ponOption.PaperSize == null) { return; } // Click Option Setting if (!_mobile.Click(new UiSelector().ResourceId("com.printeron.droid.phone:id/action_generic_settings"))) { throw new MobileWorkflowException("Can not find option setting button"); } // Set Copies if (ponOption.Copies != -1) { _mobile.SetText(new UiSelector().ResourceId("com.printeron.droid.phone:id/fragment_print_option_copies_edit"), ponOption.Copies.ToString()); } // Set Pages if (ponOption.Page != null) { if (ponOption.Page.ToLower().Equals("all")) { _mobile.Click(new UiSelector().ResourceId("com.printeron.droid.phone:id/fragment_print_option_page_range_all_radio")); } else { _mobile.Click(new UiSelector().ResourceId("com.printeron.droid.phone:id/fragment_print_option_page_range_selection_radio")); _mobile.SetText(new UiSelector().ResourceId("com.printeron.droid.phone:id/fragment_print_option_page_range_selection_edit"), ponOption.Page); } } // Set Orientation if (ponOption.Orientation != null) { _mobile.Click(new UiSelector().ResourceId("com.printeron.droid.phone:id/fragment_print_option_page_orientation_spinner")); int idx = 0; if (ponOption.Orientation.Equals(Option_Orientation.Portrait)) { idx = 0; } else if (ponOption.Orientation.Equals(Option_Orientation.Landscape)) { idx = 1; } _mobile.Click(new UiSelector().ClassName("android.widget.CheckedTextView"), idx); } // Set Duplex if (ponOption.Duplex != null) { _mobile.Click(new UiSelector().ResourceId("com.printeron.droid.phone:id/fragment_print_option_duplex_spinner")); int idx = 0; if (ponOption.Duplex.Equals(Option_Duplex.None)) { idx = 0; } else if (ponOption.Duplex.Equals(Option_Duplex.LongEdge)) { idx = 1; } else if (ponOption.Duplex.Equals(Option_Duplex.ShortEdge)) { idx = 2; } _mobile.Click(new UiSelector().ClassName("android.widget.CheckedTextView"), idx); } // Set Color if (ponOption.Color != null) { _mobile.Click(new UiSelector().ResourceId("com.printeron.droid.phone:id/fragment_print_option_color_spinner")); int idx = 0; if (ponOption.Color.Equals(Option_Color.BlackWhite)) { idx = 0; } else if (ponOption.Color.Equals(Option_Color.Color)) { idx = 1; } _mobile.Click(new UiSelector().ClassName("android.widget.CheckedTextView"), idx); } // Set Paper Size if (ponOption.PaperSize != null) { _mobile.Click(new UiSelector().ResourceId("com.printeron.droid.phone:id/fragment_print_option_media_size_spinner")); string textToClick = GetEnumDescription(ponOption.PaperSize); ScrollAndClick(new UiSelector().Text(textToClick), new UiSelector().ClassName("android.widget.ListView")); } // Click Ok Button _mobile.Click(new UiSelector().ResourceId("com.printeron.droid.phone:id/fragment_print_setting_button_ok")); }