public static void ShowToast(String message, UIColor fgColor = null, UIColor bgColor = null, double duration = 10.0f, float width = 320, float height = 60) { if (fgColor == null) { fgColor = UIColor.White; } if (bgColor == null) { bgColor = UIColor.Gray; } width = (float)iOSApp.AdjustSize(width); CGSize screen = UtilsiOS.GetScreenSize(); var size = new CGSize(width, height); var x = (screen.Width - size.Width) / 2.0; var y = screen.Height - size.Height - 120 * WidthMultiplier(); var point = new CGPoint(x, y); UIView view = AppDelegate.GetCurrentView(); ShowToast(message, fgColor, bgColor, view, point, size, duration); }
public UIView GetParentView() { iOSVariable parent = ParentView as iOSVariable; if (parent != null) { return(parent.ViewX); } return(AppDelegate.GetCurrentView()); }
public void CreateCombobox(CGRect rect, string argument) { UIView parent = GetParentView(); WidgetType = UIVariable.UIType.COMBOBOX; UIView mainView = AppDelegate.GetCurrentView(); int mainHeight = (int)mainView.Frame.Size.Height; int mainWidth = (int)mainView.Frame.Size.Width; int pickerHeight = Math.Min(mainHeight / 3, 320); int pickerWidth = Math.Min(mainWidth, 640); int pickerY = mainHeight - pickerHeight + 20; m_picker = new UIPickerView(); m_button = new UIButton(); m_button2 = new UIButton(); m_button.Frame = rect; m_picker.Frame = new CGRect(0, pickerY, pickerWidth, pickerHeight); m_button2.Frame = new CGRect(0, pickerY - 20, pickerWidth, 40); string alignment = "", color1 = "", color2 = "", closeLabel = ""; Utils.Extract(argument, ref alignment, ref color1, ref color2, ref closeLabel); m_alignment = alignment; Tuple <UIControlContentHorizontalAlignment, UITextAlignment> al = UtilsiOS.GetAlignment(alignment); m_viewY = new UIView(); m_viewY.Frame = new CGRect(0, 0, mainWidth, mainHeight); TypePickerViewModel model = new TypePickerViewModel(AppDelegate.GetCurrentController()); /*model.RowSelected += (row) => { * string text = model.SelectedText; * SetText(text, alignment, true); * ActionDelegate?.Invoke(WidgetName, text); * * m_viewY.RemoveFromSuperview(); * };*/ m_picker.ShowSelectionIndicator = true; m_picker.Hidden = true; m_picker.Model = model; if (!string.IsNullOrEmpty(color1)) { m_viewY.BackgroundColor = UtilsiOS.String2Color(color1); if (string.IsNullOrEmpty(color2)) { color2 = color1; } m_picker.BackgroundColor = UtilsiOS.String2Color(color2); } //m_button.SetTitle(extraLabel, UIControlState.Normal); m_button.BackgroundColor = UIColor.Clear; m_button.SetTitleColor(UIColor.Black, UIControlState.Normal); m_button.Hidden = false; m_button.Layer.BorderWidth = 1; m_button.Layer.CornerRadius = 4; m_button.Layer.BorderColor = UIColor.LightGray.CGColor; UIImage img = UtilsiOS.CreateComboboxImage(rect); m_button.SetBackgroundImage(img, UIControlState.Normal); m_button.ImageView.ClipsToBounds = true; m_button.ContentMode = UIViewContentMode.Right; m_button.HorizontalAlignment = al.Item1; m_button.TouchUpInside += (sender, e) => { ResetCombos(); m_button2.Hidden = false; m_picker.Hidden = false; model = m_picker.Model as TypePickerViewModel; string text = GetText(); int row = model.StringToRow(text); model.Selected(m_picker, (int)row, 0); mainView.BecomeFirstResponder(); mainView.AddSubview(m_viewY); }; if (string.IsNullOrEmpty(closeLabel)) { closeLabel = "X"; } m_button2.SetTitle(closeLabel + "\t", UIControlState.Normal); m_button2.HorizontalAlignment = UIControlContentHorizontalAlignment.Right; m_button2.BackgroundColor = UIColor.FromRGB(100, 100, 100); m_button2.SetTitleColor(UIColor.White, UIControlState.Normal); m_button2.Hidden = true; m_button2.TouchUpInside += (sender, e) => { m_button2.Hidden = true; m_picker.Hidden = true; string text = model.SelectedText; SetText(text, alignment, true /* triggered */); ActionDelegate?.Invoke(WidgetName, text); m_viewY.RemoveFromSuperview(); mainView.BecomeFirstResponder(); }; mainView.AddSubview(m_button); m_viewY.AddSubview(m_picker); m_viewY.AddSubview(m_button2); m_viewX = m_button; m_viewX.Tag = ++m_currentTag; }
void EditDataGrid(object sender, EventArgs e) { DataPoint point = m_model.GetPoint(m_rowIndex); Console.WriteLine("EditDataGrid {0}: {1} ({2})", m_rowIndex, point, m_model); if (point == null) { return; } m_detailView = new UIView(); m_detailView.BackgroundColor = UIColor.LightGray; m_detailView.Frame = new CGRect(10, m_grid.Frame.Top, m_grid.Frame.Width - 10, 240); AppDelegate.GetCurrentView().AddSubview(m_detailView); List <UITextField> textViews = new List <UITextField>(DataModel.ColNames.Count); nfloat y = 0; for (int i = 0; i < DataModel.ColNames.Count; i++) { UILabel coli = new UILabel(); coli.Frame = new CGRect(10, y, m_detailView.Frame.Right / 2, 20); UITextField texti = new UITextField(); textViews.Add(texti); texti.Frame = new CGRect(coli.Frame.Right, y, m_detailView.Frame.Right, 20); coli.Text = DataModel.ColNames[i]; texti.Text = point.GetStringValue(i); m_detailView.AddSubview(coli); m_detailView.AddSubview(texti); y = coli.Frame.Bottom + 10; } UIButton save = new UIButton(); save.SetTitle("Save", UIControlState.Normal); save.BackgroundColor = UIColor.DarkGray; save.Font = UIFont.FromName("Helvetica-Bold", 12f); save.Frame = new CGRect(m_detailView.Frame.Right / 4, m_detailView.Frame.Bottom - 220, 50, 20); save.TouchDown += (sender2, e2) => { m_detailView.RemoveFromSuperview(); DataPoint dataPoint = m_model.GetPoint(m_rowIndex); for (int i = 0; i < DataModel.ColNames.Count; i++) { dataPoint.Set(i, textViews[i].Text); } m_model.Reload(); }; UIButton cancel = new UIButton(); cancel.SetTitle("Cancel", UIControlState.Normal); cancel.TouchDown += (sender2, e2) => { m_detailView.RemoveFromSuperview(); m_grid.ItemsSource = m_model.DataPoints; }; cancel.BackgroundColor = UIColor.DarkGray; cancel.Font = UIFont.FromName("Helvetica-Bold", 12f); cancel.Frame = new CGRect(save.Frame.Right + 10, save.Frame.Top, 80, 20); m_detailView.AddSubview(save); m_detailView.AddSubview(cancel); }