void AddSwipeDelete() { UIButton rightSwipeViewText = new UIButton(); rightSwipeViewText.SetTitle("Delete", UIControlState.Normal); rightSwipeViewText.SetTitleColor(UIColor.White, UIControlState.Normal); rightSwipeViewText.VerticalAlignment = UIControlContentVerticalAlignment.Center; rightSwipeViewText.BackgroundColor = UIColor.FromRGB(220, 89, 95); rightSwipeViewText.TouchDown += (sender, e) => { m_model.RemovePoint(m_rowIndex); }; UIButton rightSwipeViewButton = new UIButton(); rightSwipeViewButton.SetImage(UtilsiOS.LoadImage("Delete"), UIControlState.Normal); rightSwipeViewButton.BackgroundColor = UIColor.FromRGB(220, 89, 95); rightSwipeViewButton.HorizontalAlignment = UIControlContentHorizontalAlignment.Center; rightSwipeViewButton.TouchDown += (sender, e) => { m_model.RemovePoint(m_rowIndex); }; CustomSwipeView rightSwipeView = new CustomSwipeView(); rightSwipeView.AddSubview(rightSwipeViewButton); rightSwipeView.AddSubview(rightSwipeViewText); m_grid.RightSwipeView = rightSwipeView; }
public static Stream ImageToStream(string imagePath) { var image = UtilsiOS.LoadImage(imagePath); Byte[] byteArray = null; using (var imageData = image.AsPNG()) { byteArray = new Byte[imageData.Length]; Marshal.Copy(imageData.Bytes, byteArray, 0, Convert.ToInt32(imageData.Length)); } var pngImageStream = new MemoryStream(byteArray); return(pngImageStream); }
public static UIImage ImageOfSize(string imageName, CGSize destinationSize) { UIImage img = UtilsiOS.LoadImage(imageName); UIGraphics.BeginImageContext(destinationSize); CGRect newRect = new CGRect(0, 0, destinationSize.Width, destinationSize.Height); img.Draw(newRect); UIImage newImage = UIGraphics.GetImageFromCurrentImageContext(); UIGraphics.EndImageContext(); return(newImage); }
public static void AddTab(string text, string selectedImageName, string notSelectedImageName = null) { var selImage = UtilsiOS.LoadImage(selectedImageName); if (selImage == null) { throw new ArgumentException("Image [" + selectedImageName + "] not found."); } selImage = selImage.ImageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal); UIViewController tab = new UIViewController(); tab.Title = text; tab.TabBarItem.SelectedImage = selImage; tab.TabBarItem.Image = selImage; if (notSelectedImageName != null) { var image = UtilsiOS.LoadImage(notSelectedImageName); if (image == null) { throw new ArgumentException("Image [" + notSelectedImageName + "] not found."); } image = image.ImageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal); tab.TabBarItem.Image = image; } List <UIViewController> controllers = Instance.ViewControllers == null ? new List <UIViewController>() : new List <UIViewController>(Instance.ViewControllers); controllers.Add(tab); Instance.ViewControllers = controllers.ToArray(); m_activeTab = new iOSTab(tab, text); m_tabs.Add(m_activeTab); if (controllers.Count == 1) { // Lift the tabbar back up: Instance.OffsetTabBar(); } m_allTabs[text] = m_tabs.Count - 1; SelectTab(m_tabs.Count - 1); }
void AddSwipeEdit() { UIButton leftSwipeViewText = new UIButton(); leftSwipeViewText.SetTitle("Edit", UIControlState.Normal); leftSwipeViewText.SetTitleColor(UIColor.White, UIControlState.Normal); leftSwipeViewText.VerticalAlignment = UIControlContentVerticalAlignment.Center; leftSwipeViewText.BackgroundColor = UIColor.FromRGB(0, 158, 218); leftSwipeViewText.TouchDown += EditDataGrid; UIButton leftSwipeViewButton = new UIButton(); leftSwipeViewButton.SetImage(UtilsiOS.LoadImage("Edit"), UIControlState.Normal); leftSwipeViewButton.BackgroundColor = UIColor.FromRGB(0, 158, 218); leftSwipeViewButton.TouchDown += EditDataGrid; CustomSwipeView leftSwipeView = new CustomSwipeView(); leftSwipeView.AddSubview(leftSwipeViewButton); leftSwipeView.AddSubview(leftSwipeViewText); m_grid.LeftSwipeView = leftSwipeView; }
public virtual iOSVariable GetWidget(string widgetType, string widgetName, string initArg, CGRect rect) { UIVariable.UIType type = UIVariable.UIType.NONE; iOSVariable widgetFunc = null; UIView widget = null; switch (widgetType) { case "View": type = UIVariable.UIType.VIEW; widget = new UIView(rect); break; case "Button": type = UIVariable.UIType.BUTTON; widget = new UIButton(rect); //widget = new UIButton(UIButtonType.System); ((UIButton)widget).SetTitleColor(UIColor.Black, UIControlState.Normal); ((UIButton)widget).SetTitle(initArg, UIControlState.Normal); AddBorderFunction.AddBorder(widget); break; case "Label": type = UIVariable.UIType.LABEL; widget = new UILabel(rect); ((UILabel)widget).TextColor = UIColor.Black; ((UILabel)widget).Text = initArg; break; case "TextEdit": type = UIVariable.UIType.TEXT_FIELD; widget = new UITextField(rect); ((UITextField)widget).TextColor = UIColor.Black; ((UITextField)widget).Placeholder = initArg; MakeBottomBorder(widget, (int)rect.Width, (int)rect.Height); break; case "TextEditView": type = UIVariable.UIType.TEXT_VIEW; widget = new UITextView(rect); ((UITextView)widget).TextColor = UIColor.Black; AddBorderFunction.AddBorder(widget); break; case "TextView": type = UIVariable.UIType.TEXT_VIEW; widget = new UITextView(rect); ((UITextView)widget).TextColor = UIColor.Black; ((UITextView)widget).Editable = false; AddBorderFunction.AddBorder(widget); break; case "ImageView": type = UIVariable.UIType.IMAGE_VIEW; widget = new UIImageView(rect); if (!string.IsNullOrWhiteSpace(initArg)) { UIImage img = UtilsiOS.LoadImage(initArg); ((UIImageView)widget).Image = img; } break; case "Combobox": type = UIVariable.UIType.COMBOBOX; widgetFunc = new iOSVariable(type, widgetName, widget); widgetFunc.CreateCombobox(rect, initArg); break; case "TypePicker": type = UIVariable.UIType.PICKER_VIEW; widget = new UIPickerView(rect); ((UIPickerView)widget).AutosizesSubviews = true; break; case "Picker": type = UIVariable.UIType.PICKER_IMAGES; widget = new UIPickerView(rect); ((UIPickerView)widget).AutosizesSubviews = true; break; case "ListView": type = UIVariable.UIType.LIST_VIEW; widget = new UITableView(rect); ((UITableView)widget).AutosizesSubviews = true; ((UITableView)widget).AutoresizingMask = UIViewAutoresizing.FlexibleBottomMargin; ((UITableView)widget).BackgroundColor = UIColor.Clear; break; case "Switch": type = UIVariable.UIType.SWITCH; widget = new UISwitch(rect); break; case "Slider": type = UIVariable.UIType.SLIDER; widget = new UISlider(rect); break; case "Stepper": type = UIVariable.UIType.STEPPER; widgetFunc = new iOSVariable(type, widgetName, widget); widgetFunc.CreateStepper(rect, initArg); break; case "SegmentedControl": type = UIVariable.UIType.SEGMENTED; widget = new UISegmentedControl(rect); break; //default: // type = UIVariable.UIType.VIEW; // widget = new UIView(rect); // break; } SetOptionsFunction.SetMultiline(widget); if (widgetFunc == null) { widgetFunc = new iOSVariable(type, widgetName, widget); } //iOSVariable widgetFunc = new iOSVariable(type, widgetName, widget); SetValues(widgetFunc, initArg); return(widgetFunc); }