private void CreateLayout() { // Create a label for showing the load status for the public service var label1ViewFrame = new CoreGraphics.CGRect(10, 30, View.Bounds.Width-10, 20); _publicLayerLabel = new UILabel(label1ViewFrame); _publicLayerLabel.TextColor = UIColor.Gray; _publicLayerLabel.Font = _publicLayerLabel.Font.WithSize(12); _publicLayerLabel.Text = PublicLayerName; // Create a label to show the load status of the secured layer var label2ViewFrame = new CoreGraphics.CGRect(10, 55, View.Bounds.Width-10, 20); _secureLayerLabel = new UILabel(label2ViewFrame); _secureLayerLabel.TextColor = UIColor.Gray; _secureLayerLabel.Font = _secureLayerLabel.Font.WithSize(12); _secureLayerLabel.Text = SecureLayerName; // Setup the visual frame for the MapView var mapViewRect = new CoreGraphics.CGRect(0, 80, View.Bounds.Width, View.Bounds.Height - 80); // Create a map view with a basemap _myMapView = new MapView(); _myMapView.Frame = mapViewRect; // Add the map view and button to the page View.AddSubviews(_publicLayerLabel, _secureLayerLabel, _myMapView); }
public override void Arrange(RectangleF finalRect) { base.Arrange(finalRect); var content = this.Content; if (content == null) { return; } if (content.HorizontalAlignment == HorizontalAlignment.Stretch && content.ReadLocalValue(UIElement.WidthProperty) == DependencyProperty.UnsetValue) { this.contentSize.Width = finalRect.Width - this.Margin.HorizontalThicknessF(); } if (content.VerticalAlignment == VerticalAlignment.Stretch && content.ReadLocalValue(UIElement.HeightProperty) == DependencyProperty.UnsetValue) { this.contentSize.Height = finalRect.Height - this.Margin.VerticalThicknessF(); } this.contentSize = content.SizeThatFitsMaxAndMin(this.contentSize); var padding = this.Padding; var x = this.ActualWidth - this.contentSize.Width < 0 ? padding.Left : padding.Left + (this.ActualWidth - this.contentSize.Width - padding.HorizontalThickness()) / 2; var y = this.ActualHeight - this.contentSize.Height < 0 ? padding.Top : padding.Top + (this.ActualHeight - this.contentSize.Height - padding.VerticalThickness()) / 2; this.ArrangeContent(new RectangleF(new PointF((nfloat)x, (nfloat)y), this.contentSize)); }
public override void Draw(CoreGraphics.CGRect rect) { base.Draw(rect); var width = rect.Width / 2f - 1f; var addedRect = new CoreGraphics.CGRect(0, 0, width, rect.Height); var removedRect = new CoreGraphics.CGRect(rect.Width / 2f + 1f, 0, width, rect.Height); var context = UIGraphics.GetCurrentContext(); context.SaveState(); context.SetFillColor(UIColor.FromRGB(204, 255, 204).CGColor); context.AddPath(GraphicsUtil.MakeRoundedRectPath(addedRect, 5)); context.FillPath(); context.SetFillColor(UIColor.FromRGB(255, 221, 221).CGColor); context.AddPath(GraphicsUtil.MakeRoundedRectPath(removedRect, 5)); context.FillPath(); context.RestoreState(); UIColor.FromRGB(57, 152, 57).SetColor(); var stringRect = addedRect; stringRect.Y += 1f; string addedString = (Added == null) ? "-" : "+" + Added.Value; new NSString(addedString).DrawString(stringRect, UIFont.SystemFontOfSize(12f), UILineBreakMode.TailTruncation, UITextAlignment.Center); UIColor.FromRGB(0xcc, 0x33, 0x33).SetColor(); stringRect = removedRect; stringRect.Y += 1f; string removedString = (Removed == null) ? "-" : "-" + Removed.Value; new NSString(removedString).DrawString(stringRect, UIFont.SystemFontOfSize(12f), UILineBreakMode.TailTruncation, UITextAlignment.Center); }
public override bool FinishedLaunching(UIApplication app, NSDictionary options) { ScreenBounds = UIScreen.MainScreen.Bounds; global::Xamarin.Forms.Forms.Init(); LoadApplication(new App()); return base.FinishedLaunching(app, options); }
public override void LayoutSubviews () { base.LayoutSubviews (); if (imageview.Superview == null) { this.AddSubview (imageview); framespec = new CoreGraphics.CGRect(20, 3, 60, (nfloat)DataColumn.Renderer.DataGrid.RowHeight - 5); } imageview.Frame = framespec; imageview.Image = (UIImage)DataColumn.RowData.GetType ().GetProperty ("CustomerImage").GetValue (DataColumn.RowData); }
protected override void ArrangeContent(SizeF finalSize) { var padding = this.Padding; var availableSize = new SizeF( finalSize.Width - padding.HorizontalThicknessF() - this.Margin.HorizontalThicknessF(), finalSize.Height - padding.VerticalThicknessF() - this.Margin.VerticalThicknessF()); var contentSize = this.MessureContent(availableSize); var contentFrame = new RectangleF(padding.LeftF(), padding.TopF(), contentSize.Width, contentSize.Height); this.NativeArrangeContent(contentFrame); }
public override void ViewDidLoad () { base.ViewDidLoad (); Title = "Gesture Recognizers"; imgDragMe.Image = UIImage.FromBundle ("Images/DragMe.png"); imgTapMe.Image = UIImage.FromBundle ("Images/DoubleTapMe.png"); originalImageFrame = imgDragMe.Frame; WireUpTapGestureRecognizer (); WireUpDragGestureRecognizer (); }
protected override void OnElementChanged (VisualElementChangedEventArgs e) { base.OnElementChanged (e); if (e.OldElement != null) { return; } // Set new size for the UIWebView. Only set width, height is correct. Frame = new CoreGraphics.CGRect (0, 0, UIScreen.MainScreen.Bounds.Width, Frame.Height); var webView = this; // Allow user to zoom the content webView.ScalesPageToFit = true; // Don't bounce at the end of the screen webView.ScrollView.Bounces = false; }
static ContextActionsCell() { var rect = new RectangleF(0, 0, 1, 1); var size = rect.Size; UIGraphics.BeginImageContext(size); var context = UIGraphics.GetCurrentContext(); context.SetFillColor(1, 0, 0, 1); context.FillRect(rect); DestructiveBackground = UIGraphics.GetImageFromCurrentImageContext(); context.SetFillColor(UIColor.LightGray.ToColor().ToCGColor()); context.FillRect(rect); NormalBackground = UIGraphics.GetImageFromCurrentImageContext(); context.Dispose(); }
private void CreateLayout() { // Setup the visual frame for the MapView var mapViewRect = new CoreGraphics.CGRect(0, 90, View.Bounds.Width, View.Bounds.Height - 90); // Create a map view with a basemap _myMapView = new MapView(); _myMapView.Map = new Map(Basemap.CreateImagery()); _myMapView.Frame = mapViewRect; // Create a button to load a web map var buttonRect = new CoreGraphics.CGRect(40, 50, View.Bounds.Width-80, 30); UIButton loadWebMapButton = new UIButton(buttonRect); loadWebMapButton.SetTitleColor(UIColor.Blue, UIControlState.Normal); loadWebMapButton.SetTitle("Load secure web map", UIControlState.Normal); loadWebMapButton.TouchUpInside += LoadWebMapButton_TouchUpInside; // Add the map view and button to the page View.AddSubviews(loadWebMapButton, _myMapView); }
public static void ShowContextMenu (Gtk.Widget parent, Gdk.EventButton evt, NSMenu menu) { if (parent == null) throw new ArgumentNullException ("parent"); if (menu == null) throw new ArgumentNullException ("menu"); parent.GrabFocus (); int x, y; if (evt != null) { x = (int)evt.X; y = (int)evt.Y; } else { Gdk.ModifierType mod; parent.GdkWindow.GetPointer (out x, out y, out mod); var titleBarHeight = MonoDevelop.Components.Mac.GtkMacInterop.GetTitleBarHeight (); y -= titleBarHeight; } Gtk.Application.Invoke (delegate { // Explicitly release the grab because the menu is shown on the mouse position, and the widget doesn't get the mouse release event Gdk.Pointer.Ungrab (Gtk.Global.CurrentEventTime); var nsview = MonoDevelop.Components.Mac.GtkMacInterop.GetNSView (parent); var toplevel = parent.Toplevel as Gtk.Window; var screenPoint = NSEvent.CurrentMouseLocation; var screenRect = new CoreGraphics.CGRect (screenPoint.X, screenPoint.Y, 0, 0); var nswindow = MonoDevelop.Components.Mac.GtkMacInterop.GetNSWindow (toplevel); var rect = nswindow.ConvertRectFromScreen (screenRect); var pt = rect.Location; var tmp_event = NSEvent.MouseEvent (NSEventType.LeftMouseDown, pt, 0, 0, nswindow.WindowNumber, null, 0, 0, 0); NSMenu.PopUpContextMenu (menu, tmp_event, nsview); }); }
public override void DrawText(RectangleF rect) => base.DrawText(TextInsets.InsetRect(rect));
public override void DrawText(CoreGraphics.CGRect rect) { base.DrawText(_edgeInsets.InsetRect(rect)); }
public static RectangleF ToRectangleF(this CoreGraphics.CGRect r) { return(new RectangleF((float)r.X, (float)r.Y, (float)r.Width, (float)r.Height)); }
/// <summary> /// Initializes a new instance of the <see cref="Pad" /> class. /// </summary> /// <param name="majorVersion">Major version.</param> /// <param name="minorVersion">Minor version.</param> public Pad() { var info = GetDeviceInfo(); var majorVersion = info.MajorVersion; var minorVersion = info.MinorVersion; double baseDPI = 132; switch (majorVersion) { case 1: baseDPI = 132; Version = IPadVersion.IPad1; break; case 2: baseDPI = minorVersion > 4 ? 163 : 132; Version = IPadVersion.IPad2Wifi + minorVersion - 1; break; case 3: baseDPI = minorVersion > 3 ? 163 : 132; Version = IPadVersion.IPad3Wifi + minorVersion - 1; break; case 4: baseDPI = minorVersion > 3 ? 163 : 132; Version = IPadVersion.IPadAirWifi + minorVersion - 1; break; case 5: baseDPI = minorVersion < 3 ? 163 : 132; Version = IPadVersion.IPadMini4 + minorVersion - 1; break; case 6: baseDPI = 132; switch (minorVersion) { case 3: Version = IPadVersion.IPadPro1_97; break; case 4: Version = IPadVersion.IPadPro1_97Cellular; break; case 7: Version = IPadVersion.IPadPro1_129; break; case 8: Version = IPadVersion.IPadPro1_129Cellular; break; } break; default: Version = IPadVersion.Unknown; break; } int width; int height; if (UIKit.UIDevice.CurrentDevice.CheckSystemVersion(8, 0)) { CoreGraphics.CGRect bounds = UIKit.UIScreen.MainScreen.NativeBounds; width = (int)bounds.Width; height = (int)bounds.Height; } else { //All older devices are portrait by design so treat the default bounds as such CoreGraphics.CGRect bounds = UIKit.UIScreen.MainScreen.Bounds; width = System.Math.Min((int)bounds.Width, (int)bounds.Height); height = System.Math.Max((int)bounds.Width, (int)bounds.Height); } width *= (int)UIKit.UIScreen.MainScreen.Scale; height *= (int)UIKit.UIScreen.MainScreen.Scale; double dpi = baseDPI * UIKit.UIScreen.MainScreen.Scale; Display = new Display(height, width, dpi, dpi); //Name = HardwareVersion = Version.GetDescription(); }
private void ShowLoginUI() { // Get the URL for the service being requested var info = _loginTaskCompletionSource.Task.AsyncState as CredentialRequestInfo; var serviceUrl = info.ServiceUri.GetLeftPart(UriPartial.Path); // Create a view to show login controls over the map view var ovBounds = new CoreGraphics.CGRect(0,80, _myMapView.Bounds.Width, _myMapView.Bounds.Height - 80); _loginUI = new LoginOverlay(ovBounds, 0.75f, UIColor.White, serviceUrl); // Handle the login event to get the login entered by the user _loginUI.OnLoginInfoEntered += LoginEntered; // Handle the cancel event when the user closes the dialog without entering a login _loginUI.OnCanceled += LoginCanceled; // Add the login UI view (will display semi-transparent over the map view) View.Add(_loginUI); }
public static override Foundation.NSObject CreateElement(Foundation.NSString role, CoreGraphics.CGRect frame, Foundation.NSString label, Foundation.NSObject parent) { throw new NotImplementedException(); }
/// <summary> /// The y coordinate of the center of the frame. /// </summary> public static nfloat GetCenterY(this CoreGraphics.CGRect viewFrame) { return(viewFrame.Y + viewFrame.Height / 2); }
public void AddProcedure(string code,string description) { CoreGraphics.CGRect descriptionFrame = new CoreGraphics.CGRect(14,baseYProcDescriptionValue,377,30); CoreGraphics.CGRect codeFrame = new CoreGraphics.CGRect(405,baseYProcCodeValue,70,30); UITextField codeText = new UITextField(codeFrame); UITextField descriptionText = new UITextField(descriptionFrame); codeText.Text=code; codeText.BorderStyle = UITextBorderStyle.RoundedRect; codeText.Tag = 2; codeText.EditingDidBegin += (object sender, EventArgs e) => { showKeyBoard = true; }; codeText.EditingDidEnd += (object sender, EventArgs e) => { showKeyBoard = false; }; descriptionText.BorderStyle = UITextBorderStyle.RoundedRect; descriptionText.Tag = 1; descriptionText.Text=description; descriptionText.EditingDidBegin += (object sender, EventArgs e) => { showKeyBoard = true; }; descriptionText.EditingDidEnd += (object sender, EventArgs e) => { showKeyBoard = false; }; descriptionText.EditingDidEnd += (senderDesc, e) => { bool itemPreviouslySearched = false; string lastSelectedProcedures = ReadFile("lastSelectedProcedures.txt"); if(lastSelectedProcedures != string.Empty){ lastSelectedProceduresObj = (ProcedureDiagnosticMaster)JsonConvert.DeserializeObject(lastSelectedProcedures,typeof(ProcedureDiagnosticMaster)); foreach (DataResults item in lastSelectedProceduresObj.results) { if(item.Name != null){ if(item.Name.ToLower().Contains(descriptionText.Text.Trim().ToLower())){ itemPreviouslySearched = true; break; } } } } if(itemPreviouslySearched){ int uvWidth=280; List<CodePickerModel> list=SetDataSource(out uvWidth,lastSelectedProceduresObj); float x = (float)descriptionText.Frame.X; float y = (float)descriptionText.Frame.Y; cp =new CodePicker(this,uvWidth,descriptionText.Text,"CPT"); cp.PresentFromPopover(descriptionText,x,y,uvWidth); cp.DataSource=list; cp._ValueChanged += delegate { codeText.Text = cp.SelectedCodeValue; descriptionText.Text = cp.SelectedText; }; }else{ if(descriptionText.Text.Trim().Length > 0) DownloadData("CPT",descriptionText.Text,codeText,descriptionText); } }; procedureScrollView.AddSubview(codeText); baseYProcCodeValue += 44; procedureScrollView.AddSubview(descriptionText); baseYProcDescriptionValue += 44; }
/// <summary> /// The baseline of the view whose frame is viewFrame. Use only when defining constraints. /// </summary> public static nfloat GetBaseline(this CoreGraphics.CGRect viewFrame) { return(0); }
/// <summary> /// The x coordinate of the center of the frame. /// </summary> public static nfloat GetCenterX(this CoreGraphics.CGRect viewFrame) { return(viewFrame.X + viewFrame.Width / 2); }
public OnboardingContentViewItem(CoreGraphics.CGRect gRect) { this.Frame = gRect; Initialize(); }
private Size OnArrange(Size finalSize) { if (TickmarkPositions == null || TickmarkPositions.Count() < 2) { return(finalSize); } var majorTickmarksBounds = new List <Rect>(); var minorTickmarksBounds = new List <Rect>(); // Iterate all child ticks and calculate bounds for each foreach (UIElement child in Children) { FrameworkElement c = child as FrameworkElement; if (c == null) { continue; } double position = GetPosition(c); var isMajorTickmark = GetIsMajorTickmark(c); if (isMajorTickmark && !ShowTickLabels) { continue; // Don't worry about calculating bounds for major ticks if labels are hidden } // Calculate the bounds of the tick mark position = finalSize.Width * position; var desiredSize = GetDesiredSize(c); var x = position - (desiredSize.Width * .5); #if __ANDROID__ // In the implementation of the Android time slider, the tickbar is aligned horizontally with its parent to allow // tick labels to use the entire space within the control. The TickInset property defines how much extra room is // available outside the bounds of the Tickbar and needs to be taken into account in the placement of ticks. // This inset also needs to be adjusted slightly, as it yields a position that is slightly offset for reasons as // yet unknown. var pixelsPerDip = Android.Util.TypedValue.ApplyDimension(Android.Util.ComplexUnitType.Dip, 1, ViewExtensions.GetDisplayMetrics()); x += TickInset - (2 * pixelsPerDip); #endif var childBounds = new Rect(0, 0, desiredSize.Width, finalSize.Height); childBounds.SetX(x); // Store the bounds for application later once tick (i.e. label) collision has been accounted for if (isMajorTickmark) { majorTickmarksBounds.Add(childBounds); } else { minorTickmarksBounds.Add(childBounds); } } if (ShowTickLabels) { // Calculate positioning of tick labels and major/minor ticks var minimumLabelSpacing = 6; var majorTickInterval = 2; var doMajorTicksCollide = false; var firstMajorTickIndex = 0; var tickCount = _minorTickmarks.Count; // Calculate the largest number of ticks to allow between major ticks. This prevents scenarios where // there are two major ticks placed undesirably close to the end of the tick bar. var maxMajorTickInterval = Math.Ceiling(tickCount / 2d); // Calculate the number of ticks between each major tick and the index of the first major tick for (int i = majorTickInterval; i <= maxMajorTickInterval; i++) { var prospectiveInterval = i; var allowsEqualNumberOfTicksOnEnds = false; // Check that the prospective interval between major ticks results in an equal number of minor // ticks on both ends of the tick bar for (int m = prospectiveInterval; m < tickCount; m += prospectiveInterval) { var totalNumberOfTicksOnEnds = tickCount - m + 1; // If the total number of minor ticks on both ends of the tick bar (i.e. before and after the // first and last major ticks) is less than the major tick interval being tested, then we've // found the number of minor ticks that would be on the ends if we use this major tick interval. // If that total is divisible by two, then the major tick interval under test allows for an // equal number of minor ticks on the ends. if (totalNumberOfTicksOnEnds / 2 < prospectiveInterval && totalNumberOfTicksOnEnds % 2 == 0) { allowsEqualNumberOfTicksOnEnds = true; break; } } // Only consider intervals that leave an equal number of ticks on the ends if (!allowsEqualNumberOfTicksOnEnds) { continue; } // Calculate the tick index of the first major tick if we were to use the prospective interval. // The index is calculated such that there will be an equal number of minor ticks before and // after the first and last major tick mark. firstMajorTickIndex = (int)Math.Truncate(((tickCount - 1) % prospectiveInterval) / 2d); doMajorTicksCollide = false; // With the given positioning of major tick marks, check whether they (i.e. their labels) will overlap for (var j = firstMajorTickIndex; j < tickCount - prospectiveInterval; j += i) { // Get the bounds of the major tick marks at index j and the one subsequent to that var currentBounds = majorTickmarksBounds[j]; var nextBounds = majorTickmarksBounds[j + i]; if (currentBounds.Right + minimumLabelSpacing > nextBounds.Left) { doMajorTicksCollide = true; break; } } if (!doMajorTicksCollide) { // The ticks don't at the given interval, so use that majorTickInterval = prospectiveInterval; break; } } if (doMajorTicksCollide) { // Multiple major ticks (and their labels) won't fit without overlapping. Display one major tick // in the middle instead majorTickInterval = tickCount; // Calculate the index of the middle tick. Note that, if there are an even number of ticks, there // is not one perfectly centered. This logic takes the one before the true center of the tick bar. if (tickCount % 2 == 0) { firstMajorTickIndex = (int)Math.Truncate(tickCount / 2d) - 1; } else { firstMajorTickIndex = (int)Math.Truncate(tickCount / 2d); } } // Apply the ticks' layouts for (var i = 0; i < tickCount; i++) { // Check whether the current tick index refers to a major or minor tick var isMajorTickIndex = (i - firstMajorTickIndex) % majorTickInterval == 0; // Arrange either the major or minor tick for the current index if (isMajorTickIndex) { _majorTickmarks[i].Arrange(majorTickmarksBounds[i]); _minorTickmarks[i].Arrange(new Rect(0, 0, 0, 0)); } else { _minorTickmarks[i].Arrange(minorTickmarksBounds[i]); _majorTickmarks[i].Arrange(new Rect(0, 0, 0, 0)); } } } else { // !ShowTickLabels for (var i = 0; i < _minorTickmarks.Count; i++) { _minorTickmarks[i].Arrange(minorTickmarksBounds[i]); } foreach (var majorTick in _majorTickmarks) { majorTick.Arrange(new Rect(0, 0, 0, 0)); } } return(finalSize); }
bool OnShouldReceiveTouch(UIGestureRecognizer r, UITouch t) { var scrollPos = t.LocationInView(_scrollView); var rect = new RectangleF(0, 0, _scrollView.ContentSize.Width, _scrollView.ContentSize.Height); return !rect.Contains(scrollPos); }
public SaveMapDialogOverlay(CoreGraphics.CGRect frame, nfloat transparency, UIColor color, PortalItem mapItem) : base(frame) { // Store the current portal item for the map (if any) _portalItem = mapItem; // Create a semi-transparent overlay with the specified background color BackgroundColor = color; Alpha = transparency; // Set size and spacing for controls nfloat controlHeight = 25; nfloat rowSpace = 11; nfloat buttonSpace = 15; nfloat textViewWidth = Frame.Width - 60; nfloat buttonWidth = 60; // Get the total height and width of the control set (five rows of controls, four sets of space) nfloat totalHeight = (5 * controlHeight) + (4 * rowSpace); nfloat totalWidth = textViewWidth; // Find the center x and y of the view nfloat centerX = Frame.Width / 2; nfloat centerY = Frame.Height / 2; // Find the start x and y for the control layout nfloat controlX = centerX - (totalWidth / 2); nfloat controlY = centerY - (totalHeight / 2); // Label for inputs var description = new UILabel(new CoreGraphics.CGRect(controlX, controlY, textViewWidth, controlHeight)); description.Text = "Portal item info"; description.TextColor = UIColor.Blue; // Adjust the Y position for the next control controlY = controlY + controlHeight + rowSpace; // Title text input _titleTextField = new UITextField(new CoreGraphics.CGRect(controlX, controlY, textViewWidth, controlHeight)); _titleTextField.Placeholder = "Title"; _titleTextField.AutocapitalizationType = UITextAutocapitalizationType.None; _titleTextField.BackgroundColor = UIColor.LightGray; // Adjust the Y position for the next control controlY = controlY + controlHeight + rowSpace; // Description text input _descriptionTextField = new UITextField(new CoreGraphics.CGRect(controlX, controlY, textViewWidth, controlHeight)); _descriptionTextField.Placeholder = "Description"; _descriptionTextField.AutocapitalizationType = UITextAutocapitalizationType.None; _descriptionTextField.BackgroundColor = UIColor.LightGray; // Adjust the Y position for the next control controlY = controlY + controlHeight + rowSpace; // Tags text input _tagsTextField = new UITextField(new CoreGraphics.CGRect(controlX, controlY, textViewWidth, controlHeight)); _tagsTextField.Text = "ArcGIS Runtime, Web Map"; _tagsTextField.AutocapitalizationType = UITextAutocapitalizationType.None; _tagsTextField.BackgroundColor = UIColor.LightGray; // Adjust the Y position for the next control controlY = controlY + controlHeight + rowSpace; // Button to save the map UIButton saveButton = new UIButton(new CoreGraphics.CGRect(controlX, controlY, buttonWidth, controlHeight)); saveButton.SetTitle("Save", UIControlState.Normal); saveButton.SetTitleColor(UIColor.Red, UIControlState.Normal); saveButton.TouchUpInside += SaveButtonClick; // Adjust the X position for the next control controlX = controlX + buttonWidth + buttonSpace; // Button to cancel the save UIButton cancelButton = new UIButton(new CoreGraphics.CGRect(controlX, controlY, buttonWidth, controlHeight)); cancelButton.SetTitle("Cancel", UIControlState.Normal); cancelButton.SetTitleColor(UIColor.Blue, UIControlState.Normal); cancelButton.TouchUpInside += (s, e) => { OnCanceled.Invoke(this, null); }; // Add the controls AddSubviews(description, _titleTextField, _descriptionTextField, _tagsTextField, saveButton, cancelButton); // If there's an existing portal item, configure the dialog for "update" (read-only entries) if (this._portalItem != null) { _titleTextField.Text = this._portalItem.Title; _titleTextField.Enabled = false; _descriptionTextField.Text = this._portalItem.Description; _descriptionTextField.Enabled = false; _tagsTextField.Text = string.Join(",", this._portalItem.Tags); _tagsTextField.Enabled = false; // Change the button text saveButton.SetTitle("Update", UIControlState.Normal); } }
/// <summary> /// Draws the specified rect. /// </summary> /// <param name="rect">The rect.</param> public override void Draw(CoreGraphics.CGRect rect) { base.Draw(rect); ResizeText(); }
void OnKeyboardShown(object sender, UIKeyboardEventArgs args) { _lastKeyboardRect = args.FrameEnd; UpdateInsets(); }
void ActivateMore() { var displayed = new HashSet<nint>(); for (var i = 0; i < _buttons.Count; i++) { var tag = _buttons[i].Tag; if (tag >= 0) displayed.Add(tag); } var frame = _moreButton.Frame; if (!Forms.IsiOS8OrNewer) { var container = _moreButton.Superview; frame = new RectangleF(container.Frame.X, 0, frame.Width, frame.Height); } var x = frame.X - _scroller.ContentOffset.X; var path = _tableView.IndexPathForCell(this); var rowPosition = _tableView.RectForRowAtIndexPath(path); var sourceRect = new RectangleF(x, rowPosition.Y, rowPosition.Width, rowPosition.Height); if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0)) { var actionSheet = new MoreActionSheetController(); for (var i = 0; i < _cell.ContextActions.Count; i++) { if (displayed.Contains(i)) continue; var item = _cell.ContextActions[i]; var weakItem = new WeakReference<MenuItem>(item); var action = UIAlertAction.Create(item.Text, UIAlertActionStyle.Default, a => { _scroller.SetContentOffset(new PointF(0, 0), true); MenuItem mi; if (weakItem.TryGetTarget(out mi)) mi.Activate(); }); actionSheet.AddAction(action); } var controller = GetController(); if (controller == null) throw new InvalidOperationException("No UIViewController found to present."); if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Phone) { var cancel = UIAlertAction.Create(StringResources.Cancel, UIAlertActionStyle.Cancel, null); actionSheet.AddAction(cancel); } else { actionSheet.PopoverPresentationController.SourceView = _tableView; actionSheet.PopoverPresentationController.SourceRect = sourceRect; } controller.PresentViewController(actionSheet, true, null); } else { var d = new MoreActionSheetDelegate { Scroller = _scroller, Items = new List<MenuItem>() }; var actionSheet = new UIActionSheet(null, d); for (var i = 0; i < _cell.ContextActions.Count; i++) { if (displayed.Contains(i)) continue; var item = _cell.ContextActions[i]; d.Items.Add(item); actionSheet.AddButton(item.Text); } if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Phone) { var index = actionSheet.AddButton(StringResources.Cancel); actionSheet.CancelButtonIndex = index; } actionSheet.ShowFrom(sourceRect, _tableView, true); } }
private void ArrangeContent(RectangleF finalRect) { var content = this.Content; if (content != null) { var x = finalRect.X; var y = finalRect.Y; var actualWidth = (nfloat)this.ActualWidth; var actualHeight = (nfloat)this.ActualHeight; switch (content.HorizontalAlignment) { case HorizontalAlignment.Right: x += actualWidth - finalRect.Width; break; case HorizontalAlignment.Center: x += (actualWidth - finalRect.Width == 0) ? 0 : (actualWidth - finalRect.Width) / 2; break; case HorizontalAlignment.Stretch: x += (actualWidth - finalRect.Width <= 0) ? 0 : (actualWidth - finalRect.Width) / 2; break; default: break; } switch (content.VerticalAlignment) { case VerticalAlignment.Bottom: y += actualHeight - finalRect.Height; break; case VerticalAlignment.Center: y += (actualHeight - finalRect.Height == 0) ? 0 : (actualHeight - finalRect.Height) / 2; break; case VerticalAlignment.Stretch: y += (actualHeight - finalRect.Height <= 0) ? 0 : (actualHeight - finalRect.Height) / 2; break; default: break; } var contentRect = new RectangleF(new PointF(x, y), finalRect.Size); this.NativeArrangeContent(contentRect); } }
public CCGameView(RectangleF frame) : base(frame) { BeginInitialise(); }
public override void DrawRect(CoreGraphics.CGRect dirtyRect) { NSColor.Green.Set(); NSGraphics.RectFill(this.Bounds); }
public Task Save(CompressedBitmapFormat format, float quality, Stream target) { return Task.Run(() => { #if UIKIT var data = format == CompressedBitmapFormat.Jpeg ? inner.AsJPEG((float)quality) : inner.AsPNG(); data.AsStream().CopyTo(target); #else #if UNIFIED var rect = new CoreGraphics.CGRect(); #else var rect = new RectangleF(); #endif var cgImage = inner.AsCGImage(ref rect, null, null); var imageRep = new NSBitmapImageRep(cgImage); var props = format == CompressedBitmapFormat.Png ? new NSDictionary() : new NSDictionary(new NSNumber(quality), new NSString("NSImageCompressionFactor")); var type = format == CompressedBitmapFormat.Png ? NSBitmapImageFileType.Png : NSBitmapImageFileType.Jpeg; var outData = imageRep.RepresentationUsingTypeProperties(type, props); outData.AsStream().CopyTo(target); #endif }); }
public static int GetTitleBarHeight () { var frame = new CoreGraphics.CGRect (0, 0, 100, 100); var rect = NSWindow.ContentRectFor (frame, NSWindowStyle.Titled); return (int)(frame.Height - rect.Height); }
void ActivateMore() { var displayed = new HashSet <nint>(); for (var i = 0; i < _buttons.Count; i++) { var tag = _buttons[i].Tag; if (tag >= 0) { displayed.Add(tag); } } var frame = _moreButton.Frame; if (!Forms.IsiOS8OrNewer) { var container = _moreButton.Superview; frame = new RectangleF(container.Frame.X, 0, frame.Width, frame.Height); } var x = frame.X - _scroller.ContentOffset.X; var path = _tableView.IndexPathForCell(this); var rowPosition = _tableView.RectForRowAtIndexPath(path); var sourceRect = new RectangleF(x, rowPosition.Y, rowPosition.Width, rowPosition.Height); if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0)) { var actionSheet = new MoreActionSheetController(); for (var i = 0; i < _cell.ContextActions.Count; i++) { if (displayed.Contains(i)) { continue; } var item = _cell.ContextActions[i]; var weakItem = new WeakReference <MenuItem>(item); var action = UIAlertAction.Create(item.Text, UIAlertActionStyle.Default, a => { _scroller.SetContentOffset(new PointF(0, 0), true); MenuItem mi; if (weakItem.TryGetTarget(out mi)) { ((IMenuItemController)mi).Activate(); } }); actionSheet.AddAction(action); } var controller = GetController(); if (controller == null) { throw new InvalidOperationException("No UIViewController found to present."); } if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Phone) { var cancel = UIAlertAction.Create(StringResources.Cancel, UIAlertActionStyle.Cancel, null); actionSheet.AddAction(cancel); } else { actionSheet.PopoverPresentationController.SourceView = _tableView; actionSheet.PopoverPresentationController.SourceRect = sourceRect; } controller.PresentViewController(actionSheet, true, null); } else { var d = new MoreActionSheetDelegate { Scroller = _scroller, Items = new List <MenuItem>() }; var actionSheet = new UIActionSheet(null, d); for (var i = 0; i < _cell.ContextActions.Count; i++) { if (displayed.Contains(i)) { continue; } var item = _cell.ContextActions[i]; d.Items.Add(item); actionSheet.AddButton(item.Text); } if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Phone) { var index = actionSheet.AddButton(StringResources.Cancel); actionSheet.CancelButtonIndex = index; } actionSheet.ShowFrom(sourceRect, _tableView, true); } }
public Image(AppKit.NSImage img) { var tmp = new CoreGraphics.CGRect(); Init(img.AsCGImage(ref tmp, null, null)); }
public override void DrawRect(CoreGraphics.CGRect dirtyRect) { NSColor.Red.Set(); NSBezierPath.StrokeRect(this.Bounds); }
public static Rectangle ToRectangle(this CoreGraphics.CGRect r) { return(new Rectangle((int)r.X, (int)r.Y, (int)r.Width, (int)r.Height)); }
public override void Draw(CoreGraphics.CGRect rect) { base.Draw(rect); ScrollToSelection(false); }
public FormsLabel(RectangleF frame) : base(frame) { }
public override void DidCropToImage(TOCropViewController cropViewController, UIImage image, CoreGraphics.CGRect cropRect, nint angle) { IsCropped = true; try { if (image != null) { _page.CroppedImage = image.AsJPEG().ToArray(); } } catch (Exception ex) { Debug.WriteLine(ex.Message); } finally { if (image != null) { image.Dispose(); image = null; } CloseView(); } }
public override CoreGraphics.CGRect TextRectForBounds(CoreGraphics.CGRect bounds, nint numberOfLines) { var textRect = base.TextRectForBounds(_edgeInsets.InsetRect(bounds), numberOfLines); return(_inverseEdgeInsets.InsetRect(textRect)); }
void OnKeyboardHidden(object sender, UIKeyboardEventArgs args) { _setInsetAction(new UIEdgeInsets(0, 0, 0, 0)); _lastKeyboardRect = RectangleF.Empty; }
public OAuthPropsDialogOverlay(CoreGraphics.CGRect frame, nfloat transparency, UIColor color, string clientId, string redirectUrl) : base(frame) { // Create a semi-transparent overlay with the specified background color BackgroundColor = color; Alpha = transparency; // Set size and spacing for controls nfloat controlHeight = 25; nfloat rowSpace = 7; nfloat lessRowSpace = 4; nfloat buttonSpace = 15; nfloat textViewWidth = 200; nfloat buttonWidth = 60; // Get the total height and width of the control set (four rows of controls, three sets of space) nfloat totalHeight = (6 * controlHeight) + (5 * rowSpace); nfloat totalWidth = textViewWidth; // Find the start x and y for the control layout nfloat controlX = 10; nfloat controlY = 10; // Label for inputs var description = new UILabel(new CoreGraphics.CGRect(controlX, controlY, textViewWidth, controlHeight)); description.Text = "OAuth Settings"; description.TextColor = UIColor.Blue; // Adjust the Y position for the next control controlY = controlY + controlHeight + rowSpace; // Client ID text input and label var clientIdLabel = new UILabel(new CoreGraphics.CGRect(controlX, controlY, textViewWidth, controlHeight)); clientIdLabel.Text = "Client ID"; controlY = controlY + controlHeight + lessRowSpace; _clientIdTextField = new UITextField(new CoreGraphics.CGRect(controlX, controlY, textViewWidth, controlHeight)); _clientIdTextField.Placeholder = "Client ID"; _clientIdTextField.Text = clientId; _clientIdTextField.AutocapitalizationType = UITextAutocapitalizationType.None; _clientIdTextField.BackgroundColor = UIColor.LightGray; // Adjust the Y position for the next control controlY = controlY + controlHeight + rowSpace; // Redirect Url text input and label var redirectLabel = new UILabel(new CoreGraphics.CGRect(controlX, controlY, textViewWidth, controlHeight)); redirectLabel.Text = "Redirect URL"; controlY = controlY + controlHeight + lessRowSpace; _redirectUrlTextField = new UITextField(new CoreGraphics.CGRect(controlX, controlY, textViewWidth, controlHeight)); _redirectUrlTextField.Placeholder = "Redirect URI"; _redirectUrlTextField.Text = redirectUrl; _redirectUrlTextField.AutocapitalizationType = UITextAutocapitalizationType.None; _redirectUrlTextField.BackgroundColor = UIColor.LightGray; // Adjust the Y position for the next control controlY = controlY + controlHeight + rowSpace; // Button to save the values UIButton saveButton = new UIButton(new CoreGraphics.CGRect(controlX, controlY, buttonWidth, controlHeight)); saveButton.SetTitle("Save", UIControlState.Normal); saveButton.SetTitleColor(UIColor.Red, UIControlState.Normal); saveButton.TouchUpInside += SaveButtonClick; // Adjust the X position for the next control controlX = controlX + buttonWidth + buttonSpace; // Button to cancel the save UIButton cancelButton = new UIButton(new CoreGraphics.CGRect(controlX, controlY, buttonWidth, controlHeight)); cancelButton.SetTitle("Cancel", UIControlState.Normal); cancelButton.SetTitleColor(UIColor.Blue, UIControlState.Normal); cancelButton.TouchUpInside += (s, e) => { OnCanceled.Invoke(this, null); }; // Add the controls AddSubviews(description, clientIdLabel, _clientIdTextField, redirectLabel, _redirectUrlTextField, saveButton, cancelButton); }
protected virtual void KeyboardWillShowNotification(NSNotification notification) { Console.WriteLine ("[LoginVC] Keyboard Showing Up"); //[UIView beginAnimations:nil context:NULL]; //[UIView setAnimationBeginsFromCurrentState:YES]; //[UIView setAnimationDuration:0.5]; //yourView.frame = CGRectMake(yourView.frame.origin.x, yourView.frame.origin.y-100, yourView.frame.size.width, yourView.frame.size.height); //[UIView commitAnimations]; CoreGraphics.CGRect layoutChanges = new CoreGraphics.CGRect ( this.View.Bounds.X, -200, this.View.Bounds.Width, this.View.Bounds.Height); UIView.BeginAnimations(null,IntPtr.Zero); UIView.SetAnimationBeginsFromCurrentState (true); UIView.SetAnimationDuration (0.2); this.View.Frame = layoutChanges; UIView.CommitAnimations (); }
public static void ShowWebivew(WebAuthenticator webview) { var app = NSApplication.SharedApplication; var rect = new CoreGraphics.CGRect(0,0,400,600); webview.Frame = rect; window = new NSWindow(rect, NSWindowStyle.Closable | NSWindowStyle.Titled, NSBackingStore.Buffered, false); window.ContentView = webview; window.IsVisible = false; window.Title = webview.Authenticator.Title; app.BeginSheet(window,app.MainWindow); webview.BeginLoadingInitialUrl(); }
protected virtual void KeyboardWillHideNotification(NSNotification notification) { Console.WriteLine ("[LoginVC] Keyboard Closed"); CoreGraphics.CGRect layoutChanges = new CoreGraphics.CGRect ( this.View.Bounds.X, 0, this.View.Bounds.Width, this.View.Bounds.Height); UIView.BeginAnimations(null,IntPtr.Zero); UIView.SetAnimationBeginsFromCurrentState (true); UIView.SetAnimationDuration (0.2); this.View.Frame = layoutChanges; UIView.CommitAnimations (); }
private async Task EvaluateAndShowTooltipAsync(IAsyncQuickInfoSession session, ITextView view, SnapshotPoint point, DataTipInfo debugInfo, CancellationToken cancellationToken) { var options = DebuggingService.DebuggerSession.EvaluationOptions.Clone(); options.AllowMethodEvaluation = true; options.AllowTargetInvoke = true; var val = DebuggingService.CurrentFrame.GetExpressionValue(debugInfo.Text, options); if (val.IsEvaluating) { await WaitOneAsync(val.WaitHandle, cancellationToken); } if (cancellationToken.IsCancellationRequested) { return; } if (val == null || val.IsUnknown || val.IsNotSupported) { return; } if (!view.Properties.TryGetProperty(typeof(Widget), out Widget gtkParent)) { return; } provider.textDocumentFactoryService.TryGetTextDocument(view.TextDataModel.DocumentBuffer, out var textDocument); // This is a bit hacky, since AsyncQuickInfo is designed to display multiple elements if multiple sources // return value, we don't want that for debugger value hovering, hence we dismiss AsyncQuickInfo // and do our own thing, notice VS does same thing await session.DismissAsync(); await provider.joinableTaskContext.Factory.SwitchToMainThreadAsync(); lastView = view; val.Name = debugInfo.Text; #if MAC var location = new PinnedWatchLocation(textDocument?.FilePath); var snapshot = view.TextDataModel.DocumentBuffer.CurrentSnapshot; int line, column; var start = debugInfo.Span.GetStartPoint(snapshot); snapshot.GetLineAndColumn(start, out line, out column); location.Column = column; location.Line = line; var end = debugInfo.Span.GetEndPoint(snapshot); snapshot.GetLineAndColumn(end, out line, out column); location.EndColumn = column; location.EndLine = line; window = new MacDebuggerTooltipWindow(location, DebuggingService.CurrentFrame, val, watch: null); view.LayoutChanged += LayoutChanged; #if CLOSE_ON_FOCUS_LOST view.LostAggregateFocus += View_LostAggregateFocus; #endif RegisterForHiddenAsync(view).Ignore(); var cocoaView = (ICocoaTextView)view; var bounds = view.TextViewLines.GetCharacterBounds(point); var rect = new CoreGraphics.CGRect(bounds.Left - view.ViewportLeft, bounds.Top - view.ViewportTop, bounds.Width, bounds.Height); window.Show(rect, cocoaView.VisualElement, AppKit.NSRectEdge.MaxXEdge); #else throw new NotImplementedException(); #endif }
public override void Arrange(RectangleF finalRect) { base.Arrange(finalRect); this.ArrangeChilds(finalRect.Size); }
public override void Arrange(RectangleF finalRect) { var orientation = this.Orientation; if ((this.ActualHeight != finalRect.Height && orientation == Orientation.Horizontal) || (this.ActualWidth != finalRect.Width && orientation == Orientation.Vertical)) { this.needsResizeChilds.Clear(); foreach (var child in this.Children) { this.needsResizeChilds.Add(child); } } base.Arrange(finalRect); this.ArrangeChilds(finalRect.Size); }
public override void Arrange(RectangleF finalRect) { if (finalRect.Size == this.arrangedSize && this.IsArrangeValid) { base.Arrange(finalRect); return; } if (this.controlTemplateInstance != null) { this.NativeArrange(finalRect); var margin = this.Margin; var padding = this.Padding; var rawWidthOfRect = finalRect.Width - margin.HorizontalThicknessF() - padding.HorizontalThicknessF(); var rawHeigthOfRect = finalRect.Height - margin.VerticalThicknessF() - padding.VerticalThicknessF(); var contentFrame = new RectangleF(padding.LeftF(), padding.TopF(), rawWidthOfRect, rawHeigthOfRect); this.TranslatePoint = finalRect.Location; if (this.controlTemplateInstance.IsArrangeValid && this.controlTemplateInstance.arrangedSize == contentFrame.Size) { return; } this.arrangedSize = finalRect.Size; this.controlTemplateInstance.Arrange(contentFrame); this.IsArrangeValid = true; this.RenderSize = this.controlTemplateInstance.RenderSize; } else { base.Arrange(finalRect); } }
public static async void ShowWebivew(WebAuthenticatorWebView webview) { var app = NSApplication.SharedApplication; var rect = new CoreGraphics.CGRect (0, 0, 400, 600); webview.Frame = rect; window = new NSWindow (rect, NSWindowStyle.Closable | NSWindowStyle.Titled, NSBackingStore.Buffered, false); window.ContentView = webview; window.IsVisible = false; window.Title = webview.Authenticator.Title; while (shownInWindow == null) { shownInWindow = app.MainWindow; if (shownInWindow == null) await Task.Delay (1000); } app.BeginSheet (window, shownInWindow); webview.BeginLoadingInitialUrl (); }
public override void Arrange(RectangleF finalRect) { base.Arrange(finalRect); if (this.controlTemplateInstance == null) { this.ArrangeContent(finalRect.Size); } }
static extern /* CGRect */ RectangleF AVMakeRectWithAspectRatioInsideRect(/* CGSize */ SizeF aspectRatio, /* CGRect */ RectangleF boundingRect);
protected virtual void ArrangeContent(SizeF finalSize) { Thickness nativePadding = this.GetNativePadding(); var totalLeftOffset = this.Padding.LeftF() + nativePadding.LeftF(); var totalTopOffset = this.Padding.TopF() + nativePadding.TopF(); var totalRightOffset = this.Padding.RightF() + nativePadding.RightF(); var totalBottomOffset = this.Padding.BottomF() + nativePadding.BottomF(); var rawWidthOfRect = finalSize.Width - this.Margin.HorizontalThicknessF(); var rawHeigthOfRect = finalSize.Height - this.Margin.VerticalThicknessF(); var x = (nfloat)totalLeftOffset; var y = (nfloat)totalTopOffset; var width = this.contentSize.Width; var heigth = this.contentSize.Height; if ((rawWidthOfRect - totalLeftOffset - totalRightOffset - this.contentSize.Width) > 0) { x += (rawWidthOfRect - totalLeftOffset - totalRightOffset - this.contentSize.Width) / 2; width = this.contentSize.Width; } if ((rawHeigthOfRect - totalTopOffset - totalBottomOffset - this.contentSize.Height) > 0) { y += (rawHeigthOfRect - totalTopOffset - totalBottomOffset - this.contentSize.Height) / 2; heigth = this.contentSize.Height; } var contentFrame = new RectangleF(x, y, width, heigth); if (this.contentTemplateInstance == null) { this.NativeArrangeContent(contentFrame); } else { this.contentTemplateInstance.Arrange(contentFrame); } }
public static RectangleF WithAspectRatio(this RectangleF self, SizeF aspectRatio) { return(AVMakeRectWithAspectRatioInsideRect(aspectRatio, self)); }
public override void DidCropToImage(TOCropViewController cropViewController, UIImage image, CoreGraphics.CGRect cropRect, nint angle) { DidCrop = true; try { if (image != null) { App.CroppedImage = image.AsPNG().ToArray(); } } catch (Exception ex) { Debug.WriteLine(ex.Message); } finally { if (image != null) { image.Dispose(); image = null; } } parent.DismissViewController(true, () => { App.Current.MainPage.Navigation.PopModalAsync(); }); }
void CreateLines() { var size = Bounds.Size; UIView[] outerLines = new UIView[3]; var i = 0; while(i != outerLines.Count()) { var line = outerLines[i]; CoreGraphics.CGRect lineFrame; switch (i) { case 0: lineFrame = new CoreGraphics.CGRect(0, 0, size.Width, lineWidth); break; case 1: lineFrame = new CoreGraphics.CGRect(size.Width - lineWidth, 0, lineWidth, size.Height); break; case 2: lineFrame = new CoreGraphics.CGRect(0, size.Height - lineWidth, size.Width, lineWidth); break; case 3: lineFrame = new CoreGraphics.CGRect(0, 0, lineWidth, size.Height); break; default: lineFrame = CoreGraphics.CGRect.Empty; break; } line.Frame = lineFrame; this.AddSubview(line); i++; } i = 0; UIView[] corners = new UIView[3]; while(i != outerLines.Count()) { var corner = corners[i]; CoreGraphics.CGRect horizontalFrame = CoreGraphics.CGRect.Empty; CoreGraphics.CGRect verticalFrame = CoreGraphics.CGRect.Empty; switch (i) { case 0: verticalFrame = new CoreGraphics.CGRect(-cornerDepth, -cornerDepth, cornerDepth, cornerWidth); horizontalFrame = new CoreGraphics.CGRect(size.Width + cornerDepth - cornerWidth, -cornerDepth, cornerWidth, cornerDepth); break; case 1: verticalFrame = new CoreGraphics.CGRect(size.Width, -cornerDepth, cornerDepth, cornerWidth); horizontalFrame = new CoreGraphics.CGRect(size.Width + cornerDepth- cornerWidth, -cornerDepth, cornerWidth, cornerDepth); break; case 2: verticalFrame = new CoreGraphics.CGRect(-cornerDepth, size.Height + cornerDepth - cornerWidth, cornerDepth, cornerWidth); horizontalFrame = new CoreGraphics.CGRect(-cornerDepth, size.Height, cornerWidth, cornerDepth); break; case 3: verticalFrame = new CoreGraphics.CGRect(size.Width, size.Height + cornerDepth - cornerWidth, cornerDepth, cornerWidth); horizontalFrame = new CoreGraphics.CGRect(size.Width + cornerDepth - cornerWidth, size.Height, cornerWidth, cornerDepth); break; defaut: verticalFrame = CoreGraphics.CGRect.Empty; horizontalFrame = CoreGraphics.CGRect.Empty; break; } corners[0].Frame = verticalFrame; corners[1].Frame = horizontalFrame; i++; } var lineThickness = lineWidth / UIScreen.MainScreen.Scale; }
public ShapefileMetadataDialog(CoreGraphics.CGRect frame, nfloat opacity, UIColor color, ShapefileInfo metadata) : base(frame) { // Create a semi-transparent overlay with the specified background color BackgroundColor = color; Alpha = opacity; // Variables for space between controls and for control width (height will vary) nfloat rowSpace = 5; nfloat controlWidth = Frame.Width - 20; // Find the center x and y of the view nfloat centerX = Frame.Width / 2; nfloat centerY = Frame.Height / 2; // Find the start x and y for the control layout nfloat controlX = centerX - (controlWidth / 2); nfloat controlY = 20; // Label for credits metadata UILabel creditsLabel = new UILabel(new CoreGraphics.CGRect(controlX, controlY, controlWidth, 20)); creditsLabel.Text = metadata.Credits; creditsLabel.TextColor = UIColor.Blue; // Adjust the Y position for the next control controlY = controlY + 20 + rowSpace; // Label for the summary metadata UILabel summaryLabel = new UILabel(new CoreGraphics.CGRect(controlX, controlY, controlWidth, 120)); summaryLabel.LineBreakMode = UILineBreakMode.WordWrap; summaryLabel.Lines = 0; summaryLabel.Text = metadata.Summary; // Adjust the Y position for the next control controlY = controlY + 120 + rowSpace; // ImageView for metadata thumbnail _shapefileThumbnailImage = new UIImageView(new CoreGraphics.CGRect(centerX - 80, controlY, 160, 160)); LoadThumbnail(metadata); // Adjust the Y position for the next control controlY = controlY + 160 + rowSpace; // Metadata tags UILabel tagsLabel = new UILabel(new CoreGraphics.CGRect(controlX, controlY, controlWidth, 100)); tagsLabel.LineBreakMode = UILineBreakMode.WordWrap; tagsLabel.Lines = 0; tagsLabel.Text = string.Join(",", metadata.Tags); // Adjust the Y position for the next control controlY = controlY + 100 + rowSpace; // Button to hide the dialog UIButton hideButton = new UIButton(new CoreGraphics.CGRect(controlX, controlY, controlWidth, 20)); hideButton.SetTitle("OK", UIControlState.Normal); hideButton.SetTitleColor(UIColor.Blue, UIControlState.Normal); hideButton.TouchUpInside += (s, e) => { Hide(); }; // Add the controls AddSubviews(creditsLabel, summaryLabel, _shapefileThumbnailImage, tagsLabel, hideButton); }