protected override void OnStateChanged(EventArgs e) { base.OnStateChanged(e); if (WindowState == WindowState.Maximized) { _oldThickness = BorderThickness; BorderThickness = new Thickness(0); } else if (_oldThickness != null) { BorderThickness = _oldThickness.Value; _oldThickness = null; } }
public Input() { _name = DefaultName; _id = Guid.NewGuid().ToString(); _displayNumber = true; _complete = false; _needsToBeStored = true; _required = true; _viewed = false; _completionTimestamp = null; _labelFontSize = 20; _displayConditions = new List<InputDisplayCondition>(); _backgroundColor = null; _padding = null; _frame = true; _completionRecords = new List<InputCompletionRecord>(); }
private View GetSeparator(Thickness?padding = null) { var absoluteLayout = new AbsoluteLayout { HorizontalOptions = LayoutOptions.Center }; if (padding.HasValue) { absoluteLayout.Padding = padding.Value; } absoluteLayout.Children.Add(new BoxView { HeightRequest = 0.5f, WidthRequest = AppProvider.Screen.Width - 20, BackgroundColor = AppResources.SeparatorColor }); return(absoluteLayout); }
public Input() { _name = DefaultName; _id = Guid.NewGuid().ToString(); _displayNumber = true; _complete = false; _needsToBeStored = true; _required = true; _viewed = false; _completionTimestamp = null; _labelFontSize = 20; _displayConditions = new List <InputDisplayCondition>(); _backgroundColor = null; _padding = null; _frame = true; _completionRecords = new List <InputCompletionRecord>(); _submissionTimestamp = null; }
public static ThicknessAnimation CreateThicknessAnimation(Thickness toValue, Thickness?fromValue = null, TimeSpan?beginTimeSpan = null, TimeSpan?durationSpan = null, IEasingFunction easingFuction = null) { var duration = durationSpan != null ? new Duration(durationSpan.Value) : new Duration(TimeSpan.FromSeconds(0)); beginTimeSpan = beginTimeSpan != null ? beginTimeSpan.Value : TimeSpan.FromSeconds(0); fromValue = fromValue ?? new Thickness(0); var animation = new ThicknessAnimation() { BeginTime = beginTimeSpan, From = fromValue, To = toValue, Duration = duration, EasingFunction = easingFuction }; return(animation); }
/// <inheritdoc /> protected override void OnAttached() { // no transparency, because it has more then one unwanted issues if (this.AssociatedObject.AllowsTransparency && this.AssociatedObject.IsLoaded == false && new WindowInteropHelper(this.AssociatedObject).Handle == IntPtr.Zero) { try { this.AssociatedObject.SetCurrentValue(Window.AllowsTransparencyProperty, false); } catch (Exception) { //For some reason, we can't determine if the window has loaded or not, so we swallow the exception. } } if (this.AssociatedObject.WindowStyle != WindowStyle.None) { this.AssociatedObject.SetCurrentValue(Window.WindowStyleProperty, WindowStyle.None); } this.savedBorderThickness = this.AssociatedObject.BorderThickness; this.borderThicknessChangeNotifier = new PropertyChangeNotifier(this.AssociatedObject, Control.BorderThicknessProperty); this.borderThicknessChangeNotifier.ValueChanged += this.BorderThicknessChangeNotifierOnValueChanged; this.savedResizeBorderThickness = this.ResizeBorderThickness; this.resizeBorderThicknessChangeNotifier = new PropertyChangeNotifier(this, ResizeBorderThicknessProperty); this.resizeBorderThicknessChangeNotifier.ValueChanged += this.ResizeBorderThicknessChangeNotifierOnValueChanged; this.savedTopMost = this.AssociatedObject.Topmost; this.topMostChangeNotifier = new PropertyChangeNotifier(this.AssociatedObject, Window.TopmostProperty); this.topMostChangeNotifier.ValueChanged += this.TopMostChangeNotifierOnValueChanged; this.AssociatedObject.SourceInitialized += this.AssociatedObject_SourceInitialized; this.AssociatedObject.Loaded += this.AssociatedObject_Loaded; this.AssociatedObject.Unloaded += this.AssociatedObject_Unloaded; this.AssociatedObject.Closed += this.AssociatedObject_Closed; this.AssociatedObject.StateChanged += this.AssociatedObject_StateChanged; this.AssociatedObject.LostFocus += this.AssociatedObject_LostFocus; this.AssociatedObject.Deactivated += this.AssociatedObject_Deactivated; base.OnAttached(); }
public void Init( UserControl control, string text, Brush background = null, Brush borderBackground = null, HorizontalAlignment horizontalAlign = HorizontalAlignment.Center, VerticalAlignment verticalAlign = VerticalAlignment.Bottom, Thickness?margin = null, int cornerRadius = 12, Thickness?toastTextMargin = null, Brush toastTextForeground = null) { this.mToastIcon.Visibility = Visibility.Collapsed; if (control != null) { this.ParentControl = control; } this.InitProperties(1, text, background, borderBackground, horizontalAlign, verticalAlign, margin, cornerRadius, toastTextMargin, toastTextForeground, false, false); }
public static bool ExtendGlassFrame(Window window, Thickness?margin) { if (!DwmIsCompositionEnabled()) { return(false); } IntPtr hwnd = new WindowInteropHelper(window).EnsureHandle(); // Set the background to transparent from both the WPF and Win32 perspectives // window.Background = Brushes.Transparent; HwndSource.FromHwnd(hwnd).CompositionTarget.BackgroundColor = Colors.Transparent; Margins margins = new Margins(margin.GetValueOrDefault(Margins.NullThickness)); DwmExtendFrameIntoClientArea(hwnd, ref margins); return(true); }
private void ItemsSourceChanged(object sender, EventArgs eventArgs) { if (!_currentMargin.HasValue) { _currentMargin = this.Margin; } Storyboard storyb = new Storyboard(); DoubleAnimation da = new DoubleAnimation(0.3, 1, TimeSpan.FromMilliseconds(500)); ThicknessAnimation ta = new ThicknessAnimation(new Thickness(_currentMargin.Value.Left - 10, 0, _currentMargin.Value.Right + 10, 0), _currentMargin.Value, TimeSpan.FromSeconds(0.4)); Storyboard.SetTarget(da, this); Storyboard.SetTarget(ta, this); Storyboard.SetTargetProperty(da, new PropertyPath(OpacityProperty)); Storyboard.SetTargetProperty(ta, new PropertyPath(MarginProperty)); storyb.Children.Add(da); storyb.Children.Add(ta); storyb.Begin(this); }
private static TextBlock CreateTextBlock(string text, int?fontHeight = null, Thickness?margin = null) { var textBlock = new TextBlock { Text = text, Style = (Style)Application.Current.Resources["PhoneTextExtraLargeStyle"] }; if (fontHeight.HasValue) { textBlock.FontSize = fontHeight.Value; } if (margin.HasValue) { textBlock.Margin = margin.Value; } return(textBlock); }
private void OnKeyboardNotification(NSNotification notification) { if (!IsViewLoaded) { return; } var frameBegin = UIKeyboard.FrameBeginFromNotification(notification); var frameEnd = UIKeyboard.FrameEndFromNotification(notification); if (Element is ContentPage page) // && !(page.Content is ScrollView)) { var padding = page.Padding; if (_basePadding == null) { _basePadding = padding; } page.Padding = new Thickness(padding.Left, padding.Top, padding.Right, padding.Bottom + frameBegin.Top - frameEnd.Top); } }
private static void OnTextBoxViewMarginChanged(TextBox textBox, Thickness?margin) { if (!textBox.IsLoaded) { textBox.Dispatcher.BeginInvoke( DispatcherPriority.Loaded, new Action(() => OnTextBoxViewMarginChanged(textBox, margin))); return; } var textBoxView = textBox.NestedChildren() .SingleOrDefault(x => x.GetType().Name == "TextBoxView"); if (margin == null) { textBoxView?.ClearValue(FrameworkElement.MarginProperty); } else { textBoxView?.SetValue(FrameworkElement.MarginProperty, margin); } }
public static T FillHorizontally <T>(this T child, Container parent = null, Thickness?padding = null) where T : ConsoleControl { parent = parent ?? child.Parent; var effectivePadding = padding.HasValue ? padding.Value : new Thickness(0, 0, 0, 0); Action syncAction = () => { if (parent.Width == 0) { return; } if (parent.Width - (effectivePadding.Right + effectivePadding.Left) <= 0) { return; } child.Bounds = new Rectangle(effectivePadding.Left, child.Y, parent.Width - (effectivePadding.Right + effectivePadding.Left), child.Height); }; parent.SubscribeForLifetime(nameof(ConsoleControl.Bounds), syncAction, parent); syncAction(); return(child); }
protected override void OnElementChanged(ElementChangedEventArgs <Button> e) { base.OnElementChanged(e); if (e.OldElement != null) { } if (e.NewElement != null) { if (Control == null) { AppCompatButton button = CreateNativeControl(); button.SetOnClickListener(ButtonClickListener.Instance.Value); button.SetOnTouchListener(ButtonTouchListener.Instance.Value); button.Tag = this; var useLegacyColorManagement = e.NewElement.UseLegacyColorManagement(); _textColorSwitcher = new TextColorSwitcher(button.TextColors, useLegacyColorManagement); SetNativeControl(button); button.AddOnAttachStateChangeListener(this); } if (_backgroundTracker == null) { _backgroundTracker = new ButtonBackgroundTracker(Element, Control); } else { _backgroundTracker.Button = e.NewElement; } _defaultFontSize = 0f; _defaultPadding = null; UpdateAll(); } }
public ItemTemplateContext(DataTemplate formsDataTemplate, object item, BindableObject container, double?height = null, double?width = null, Thickness?itemSpacing = null) { FormsDataTemplate = formsDataTemplate; Item = item; Container = container; if (height.HasValue) { ItemHeight = height.Value; } if (width.HasValue) { ItemWidth = width.Value; } if (itemSpacing.HasValue) { ItemSpacing = itemSpacing.Value; } }
public static TextBlock NewText(String txt, FontSettings FontSetting = null, Thickness?Padding = null, TextWrapping Wrapping = TextWrapping.NoWrap, Brush Background = null) { TextBlock result = new TextBlock(); FontSettings fs = new FontSettings(); if (!(FontSetting is null)) { fs = FontSetting; } result.FontFamily = fs.Family; result.FontSize = fs.Size; result.FontStyle = fs.Style; result.FontStretch = fs.Stretch; result.FontWeight = fs.Weight; result.Foreground = fs.Foreground; result.Background = fs.Background; if (Background != null) { result.Background = Background; } if (Padding != null) { result.Padding = (Thickness)Padding; } result.Text = txt; result.TextWrapping = Wrapping; //does not work with textwrapping ... //result.Measure(new Size(9999999, 9999999)); //srsly chris .. i'm disappointed in myself. //result.Width = result.DesiredSize.Width; //result.Height = result.DesiredSize.Height; return(result); }
protected override MaterialButton CreateNativeView() { MaterialButton nativeButton = new MauiMaterialButton(Context) { IconGravity = MaterialButton.IconGravityTextStart, IconTintMode = Android.Graphics.PorterDuff.Mode.Add, IconTint = (_transparentColorStateList ??= Colors.Transparent.ToDefaultColorStateList()), SoundEffectsEnabled = false }; return(nativeButton); } void SetupDefaults(MaterialButton nativeView) { DefaultPadding = new Thickness( nativeView.PaddingLeft, nativeView.PaddingTop, nativeView.PaddingRight, nativeView.PaddingBottom); DefaultBackground = nativeView.Background; }
//////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> Removes the drop shadow. </summary> //////////////////////////////////////////////////////////////////////////////////////////////////// internal void RemoveDropShadow() { //Remove the elements that we added to the _parent.Children try { if (_parent == null) { return; } //Hiding the shadow will take care of a few steps needed to completely remove // the shadow. HideDropShadow(); var childCollection = _parent.Children; if (childCollection.Contains(_roundedRectMask)) { childCollection.Remove(_roundedRectMask); } if (childCollection.Contains(_dropShadowHost)) { childCollection.Remove(_dropShadowHost); } _roundedRectMask = null; _dropShadowHost = null; _elementsOriginalMargin = null; } //I would not want cleanup work to cause an exception. There is nothing we need to do, but // we developers need to know if it is happening during development. catch (Exception e) { Debug.WriteLine($"{nameof(RemoveDropShadow)} caused the following exception : {e}"); } }
public ValueRenderRectangle(IPoint2D position, ISize renderSize, IPoint2D offset, Thickness?padding) { if (padding?.IsEmpty == false) { X = position.X + padding.Left; Y = position.Y + padding.Top; Width = renderSize.Width - padding.Width; Height = renderSize.Height - padding.Height; } else { X = position.X; Y = position.Y; Width = renderSize.Width; Height = renderSize.Height; } if (ReferenceEquals(null, offset)) { throw new ArgumentNullException(nameof(offset)); } Offset = offset; TopLeft = new ValuePoint2D(X, Y); TopRight = new ValuePoint2D(X + Width, Y); BottomLeft = new ValuePoint2D(X, Y + Height); BottomRight = new ValuePoint2D(X + Width, Y + Height); _hash = 0; _hash = GeometryHelper.BuildRectHash(this); }
public async Task TrySetViewBoundsAsync(GeoboundingBox bounds, Thickness?margin, MapAnimationKind animation, bool retryOnFailure = false) { if (DigiTransitMapControl == null) { return; } // We're checking for the MapStyle type as a proxy for "are we running on Creators or higher?". // We don't need to run the following code if we are. if (margin != null && !ApiInformation.IsTypePresent("Windows.UI.Xaml.Controls.Maps.MapStyle") && DeviceTypeHelper.GetDeviceFormFactorType() != DeviceFormFactorType.Phone) { //Margins are a little smaller on desktop for some reason. investigate this a little further, may just be a DPI thing? const int desktopPlusCoeff = 40; margin = new Thickness(margin.Value.Left + desktopPlusCoeff, margin.Value.Top + desktopPlusCoeff, margin.Value.Right + desktopPlusCoeff, margin.Value.Bottom + desktopPlusCoeff); } //If map movement fails, keep retrying until we get it right bool moved = false; do { moved = await DigiTransitMapControl.TrySetViewBoundsAsync(bounds, margin, animation); if (moved) { break; } else { await Task.Delay(2000); //looong delay to acommodate slow mobile rendering } } while (!moved && retryOnFailure); }
/// <summary> /// Add Path /// </summary> /// <param name="name"></param> /// <param name="data"></param> /// <param name="margin"></param> /// <param name="row"></param> /// <param name="column"></param> /// <param name="columnSpan"></param> /// <returns></returns> private Path AddPath( string name, string data, Thickness?margin, int?row, int?column, int?columnSpan) { Path path = new Path { Tag = name, Data = GetGeometry(data) }; if (margin != null) { path.Margin = margin.Value; } path.SetBinding(Path.FillProperty, new Binding() { Path = new PropertyPath(nameof(Foreground)), Mode = BindingMode.TwoWay, Source = this }); if (row != null) { Grid.SetRow(path, row.Value); } if (column != null) { Grid.SetColumn(path, column.Value); } if (columnSpan != null) { Grid.SetColumnSpan(path, columnSpan.Value); } return(path); }
public static T Fill <T>(this T child, Container parent = null, Thickness?padding = null) where T : ConsoleControl { parent = parent ?? child.Parent; var effectivePadding = padding.HasValue ? padding.Value : new Thickness(0, 0, 0, 0); Action syncAction = () => { if (parent.Width == 0 || parent.Height == 0) { return; } var newBounds = new Rectangle(new Point(0, 0), parent.Size); newBounds.X += effectivePadding.Left; newBounds.Width -= effectivePadding.Left; newBounds.Width -= effectivePadding.Right; newBounds.Y += effectivePadding.Top; newBounds.Height -= effectivePadding.Top; newBounds.Height -= effectivePadding.Bottom; if (newBounds.Width < 0) { newBounds.Width = 0; } if (newBounds.Height < 0) { newBounds.Height = 0; } child.Bounds = newBounds; }; parent.SubscribeForLifetime(nameof(ConsoleControl.Bounds), syncAction, parent); syncAction(); return(child); }
protected override void OnAttached() { windowChrome = new WindowChrome { ResizeBorderThickness = SystemParameters2.Current.WindowResizeBorderThickness, CaptionHeight = 0, CornerRadius = new CornerRadius(0), GlassFrameThickness = new Thickness(0), UseAeroCaptionButtons = false }; AssociatedObject.SetValue(WindowChrome.WindowChromeProperty, windowChrome); AssociatedObject.WindowStyle = WindowStyle.None; savedBorderThickness = AssociatedObject.BorderThickness; AssociatedObject.Unloaded += AssociatedObject_Unloaded; AssociatedObject.SourceInitialized += AssociatedObject_SourceInitialized; AssociatedObject.StateChanged += AssociatedObject_StateChanged; AssociatedObject.Activated += AssociatedObject_Activated; base.OnAttached(); }
public void Reset() { _view = null; _complete = false; _needsToBeStored = true; _latitude = null; _longitude = null; _locationUpdateTimestamp = null; _viewed = false; _completionTimestamp = null; _backgroundColor = null; _padding = null; }
private void BorderThicknessChangeNotifierOnValueChanged(object sender, EventArgs e) { savedBorderThickness = AssociatedObject.BorderThickness; }
void UpdateContentEdge(Thickness?delta = null) { _paddingDeltaPix = delta ?? new Thickness(); UpdatePadding(); }
protected override void OnAttached() { this.isWindwos10OrHigher = IsWindows10OrHigher(); this.windowChrome = new WindowChrome { #if NET4_5 ResizeBorderThickness = SystemParameters.WindowResizeBorderThickness, #else ResizeBorderThickness = SystemParameters2.Current.WindowResizeBorderThickness, #endif CaptionHeight = 10, CornerRadius = new CornerRadius(0), GlassFrameThickness = new Thickness(0), IgnoreTaskbarOnMaximize = false, UseAeroCaptionButtons = false, }; var window = this.AssociatedObject as WindowWithDialogs; if (window != null) { this.windowChrome.IgnoreTaskbarOnMaximize = window.IgnoreTaskbarOnMaximize; this.windowChrome.UseNoneWindowStyle = window.UseNoneWindowStyle; System.ComponentModel.DependencyPropertyDescriptor.FromProperty(WindowWithDialogs.IgnoreTaskbarOnMaximizeProperty, typeof(WindowWithDialogs)) .AddValueChanged(this.AssociatedObject, this.IgnoreTaskbarOnMaximizePropertyChangedCallback); System.ComponentModel.DependencyPropertyDescriptor.FromProperty(WindowWithDialogs.UseNoneWindowStyleProperty, typeof(WindowWithDialogs)) .AddValueChanged(this.AssociatedObject, this.UseNoneWindowStylePropertyChangedCallback); } this.AssociatedObject.SetValue(WindowChrome.WindowChromeProperty, this.windowChrome); // no transparency, because it hase more then one unwanted issues var windowHandle = new WindowInteropHelper(this.AssociatedObject).Handle; if (!this.AssociatedObject.IsLoaded && windowHandle == IntPtr.Zero) { try { this.AssociatedObject.AllowsTransparency = false; } catch (Exception) { // For some reason, we can't determine if the window has loaded or not, so we swallow the exception. } } this.AssociatedObject.WindowStyle = WindowStyle.None; this.savedBorderThickness = this.AssociatedObject.BorderThickness; this.savedResizeBorderThickness = this.windowChrome.ResizeBorderThickness; this.borderThicknessChangeNotifier = new PropertyChangeNotifier(this.AssociatedObject, Control.BorderThicknessProperty); this.borderThicknessChangeNotifier.ValueChanged += this.BorderThicknessChangeNotifierOnValueChanged; this.savedTopMost = this.AssociatedObject.Topmost; this.topMostChangeNotifier = new PropertyChangeNotifier(this.AssociatedObject, Window.TopmostProperty); this.topMostChangeNotifier.ValueChanged += this.TopMostChangeNotifierOnValueChanged; // #1823 try to fix another nasty issue // WindowState = Maximized // ResizeMode = NoResize if (this.AssociatedObject.ResizeMode == ResizeMode.NoResize) { this.windowChrome.ResizeBorderThickness = new Thickness(0); } var topmostHack = new Action(() => { if (this.AssociatedObject.Topmost) { var raiseValueChanged = this.topMostChangeNotifier.RaiseValueChanged; this.topMostChangeNotifier.RaiseValueChanged = false; this.AssociatedObject.Topmost = false; this.AssociatedObject.Topmost = true; this.topMostChangeNotifier.RaiseValueChanged = raiseValueChanged; } }); this.AssociatedObject.LostFocus += (sender, args) => { topmostHack(); }; this.AssociatedObject.Deactivated += (sender, args) => { topmostHack(); }; this.AssociatedObject.Loaded += this.AssociatedObject_Loaded; this.AssociatedObject.Unloaded += this.AssociatedObject_Unloaded; this.AssociatedObject.Closed += this.AssociatedObjectClosed; this.AssociatedObject.SourceInitialized += this.AssociatedObject_SourceInitialized; this.AssociatedObject.StateChanged += this.OnAssociatedObjectHandleMaximize; base.OnAttached(); }
public static void UpdatePadding(this UIButton platformButton, IButton button, Thickness?defaultPadding = null) => UpdatePadding(platformButton, button.Padding, defaultPadding);
public GroupFooterItemTemplateContext(DataTemplate formsDataTemplate, object item, BindableObject container, double?height = null, double?width = null, Thickness?itemSpacing = null, IMauiContext mauiContext = null) : base(formsDataTemplate, item, container, height, width, itemSpacing, mauiContext) { }
public static void UpdatePadding(this UIButton platformButton, Thickness padding, Thickness?defaultPadding = null) { if (padding.IsNaN) { padding = defaultPadding ?? Thickness.Zero; } // top and bottom insets reset to a "default" if they are exactly 0 // however, internally they are floor-ed, so there is no actual fractions var top = padding.Top; if (top == 0.0) { top = AlmostZero; } var bottom = padding.Bottom; if (bottom == 0.0) { bottom = AlmostZero; } platformButton.ContentEdgeInsets = new UIEdgeInsets( (float)top, (float)padding.Left, (float)bottom, (float)padding.Right); }
public static T FillAndPreserveAspectRatio <T>(this T child, Container parent = null, Thickness?padding = null) where T : ConsoleControl { parent = parent ?? child.Parent; var effectivePadding = padding.HasValue ? padding.Value : new Thickness(0, 0, 0, 0); Action syncAction = () => { if (parent.Width == 0 || parent.Height == 0) { return; } var aspectRatio = (float)child.Width / child.Height; var newW = parent.Width - (effectivePadding.Left + effectivePadding.Right); var newH = Geometry.Round(newW / aspectRatio); if (newH > parent.Height) { newH = parent.Height; newW = Geometry.Round(newH * aspectRatio); } var newLeft = (parent.Width - newW) / 2; var newTop = (parent.Height - newH) / 2; child.Bounds = new Rectangle(newLeft, newTop, newW, newH); }; parent.SubscribeForLifetime(nameof(ConsoleControl.Bounds), syncAction, parent); syncAction(); return(child); }
public ObservableItemTemplateCollection(IList itemsSource, DataTemplate itemTemplate, BindableObject container, double?itemHeight = null, double?itemWidth = null, Thickness?itemSpacing = null, IMauiContext mauiContext = null) { if (!(itemsSource is INotifyCollectionChanged notifyCollectionChanged)) { throw new ArgumentException($"{nameof(itemsSource)} must implement {nameof(INotifyCollectionChanged)}"); } _notifyCollectionChanged = notifyCollectionChanged; _itemsSource = itemsSource; _itemTemplate = itemTemplate; _container = container; _mauiContext = mauiContext; if (itemHeight.HasValue) { _itemHeight = itemHeight.Value; } if (itemWidth.HasValue) { _itemWidth = itemWidth.Value; } if (itemSpacing.HasValue) { _itemSpacing = itemSpacing.Value; } for (int n = 0; n < itemsSource.Count; n++) { // We're using this as a source for a ListViewBase, and we need INCC to work. So ListViewBase is going // to iterate over the entire source list right off the bat, no matter what we do. Creating one // ItemTemplateContext per item in the collection is unavoidable. Luckily, ITC is pretty cheap. Add(new ItemTemplateContext(itemTemplate, itemsSource[n], container, _itemHeight, _itemWidth, _itemSpacing, _mauiContext)); } _notifyCollectionChanged.CollectionChanged += InnerCollectionChanged; CollectionChanged += TemplateCollectionChanged; }
public Button(object?content = null, Action <RoutedEventArgs>?click = null, Brush?background = null, Brush?foreground = null, Thickness?margin = null) : base(