Exemplo n.º 1
0
        public ToolSettingsView(ITool tool, StackOrientation orientation)
        {
            Tool = tool;
            ColorSelectedCommand = new Command <ToolSettings>(paletteItem =>
            {
                Tool.Geometry.ToolSettings = paletteItem;
                Navigation.PopAsync();
            });

            _orientation = orientation;
            InitializeComponent();
            BindingContext = this;

            thinLineImage.Source         = ImageSource.FromResource("Sketching.Resources.ThinLine.png");
            thickLineImage.Source        = ImageSource.FromResource("Sketching.Resources.ThickLine.png");
            customColorsLayout.IsVisible = false;
            CreateColorPalette(tool);
            SetupAndFillColorGrids();

            // Xamarin.Forms bug still not fixed https://bugzilla.xamarin.com/show_bug.cgi?id=31970
            // Andreas 2016-12-21
            if (Device.OS == TargetPlatform.Windows)
            {
                var toolInitSize = tool.Geometry.Size;
                Device.StartTimer(TimeSpan.FromMilliseconds(10), () =>
                {
                    sizeSlider.Value = toolInitSize;
                    return(false);
                });
            }
        }
Exemplo n.º 2
0
        public void BuildFriends(StackLayout Stack, StackOrientation Orientation)
        {
            var             RowCount      = 3.0;
            var             LineCount     = (int)Math.Ceiling(Friends.Count() / RowCount);
            var             CirclePerLine = ((float)Friends.Count()) / (float)LineCount;
            Func <int, int> CalcIndex     = (int i) => (int)Math.Ceiling((CirclePerLine * i) - ((1.0 / RowCount) + 0.1));

            for (var i = 0; i < LineCount; ++i)
            {
                var SkipCount = CalcIndex(i);
                var TakeCount = CalcIndex(i + 1) - SkipCount;
                var Adjuster  = 0 == TakeCount % 2 ? 0.0 : 1.0;
                Stack.Children.Add
                (
                    new Grid()
                {
                    ColumnSpacing = Adjuster,
                    RowSpacing    = Adjuster,
                }.LineJustificate
                    (
                        Orientation,
                        CirclePerLine <= (float)TakeCount ?
                        GridEx.Justificate.Even :
                        GridEx.Justificate.Odd,
                        Friends
                        .Skip(SkipCount)
                        .Take(TakeCount)
                        .ToArray()
                    )
                );
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// Instance method used to change the current orientation of the layout panel.
 /// </summary>
 /// <param name="oldValue">Old value.</param>
 /// <param name="newValue">New value.</param>
 private void OnOrientationPropertyChanged(StackOrientation oldValue, StackOrientation newValue)
 {
     if (stack != null && oldValue != newValue)
     {
         stack.Orientation = newValue;
     }
 }
        protected override void OnSizeAllocated(double width, double height)
        {
            base.OnSizeAllocated(width, height);

            if (_screenSizeHandler.GetScreenSize() == ScreenSizes.Small)
            {
                var orientation = _screenSizeHandler.OnSizeAllocated(width, height);

                if (orientation == Orientations.Landscape)
                {
                    CurrentDate.FontSize         = Device.GetNamedSize(NamedSize.Large, typeof(Label));
                    CalendarNotesButton.FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Button));
                    NoDataImage.IsVisible        = false;
                    _stackOrientation            = StackOrientation.Horizontal;
                    ChangeOrientation();
                }
                if (orientation == Orientations.Portrait)
                {
                    CurrentDate.FontSize         = Device.GetNamedSize(NamedSize.Medium, typeof(Label));
                    CalendarNotesButton.FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Button));
                    NoDataImage.IsVisible        = true;
                    _stackOrientation            = StackOrientation.Vertical;
                    ChangeOrientation();
                }
            }
        }
Exemplo n.º 5
0
        protected override void LayoutChildren(double x, double y, double width, double height)
        {
            if (!HasVisibleChildren())
            {
                return;
            }

            LayoutInformation layoutInformationCopy = _layoutInformation;

            if (width == layoutInformationCopy.Constraint.Width && height == layoutInformationCopy.Constraint.Height)
            {
                StackOrientation orientation = Orientation;

                AlignOffAxis(layoutInformationCopy, orientation, width, height);
                ProcessExpanders(layoutInformationCopy, orientation, x, y, width, height);
            }
            else
            {
                CalculateLayout(layoutInformationCopy, x, y, width, height, true);
            }

            for (var i = 0; i < LogicalChildrenInternal.Count; i++)
            {
                var child = (View)LogicalChildrenInternal[i];
                if (child.IsVisible && layoutInformationCopy.Plots != null)
                {
                    LayoutChildIntoBoundingRegion(child, layoutInformationCopy.Plots[i], layoutInformationCopy.Requests[i]);
                }
            }
        }
Exemplo n.º 6
0
        public RadioGroupBase()
        {
            this.Container   = this.GetContainer();
            this.Content     = this.Container;
            this.Orientation = GetOrientation();

            this.SelectedCmd = new Command((o) =>
            {
                if (o == null)
                {
                    return;
                }

                this.IsInnerChanged = true;

                var item = (Radio)o;

                if (this.SelectedRadio != null)
                {
                    this.SelectedRadio.IsSelected      = false;
                    this.SelectedRadio.ControlTemplate = this.UnSelectedItemControlTemplate ?? DefaultControlTemplate;
                }

                this.SelectedItem  = item.Value;
                this.SelectedRadio = item;
                this.SelectedRadio.ControlTemplate = this.SelectedItemControlTemplate ?? DefaultControlTemplate;

                item.IsSelected = true;

                this.IsInnerChanged = false;
            });

            this.WrapItemsSource();
        }
Exemplo n.º 7
0
        private void InitialSetup()
        {
            _initialized    = true;
            _orientation    = StackOrientation.Vertical;
            _citiesListView = new CityListView()
            {
                BindingContext    = ViewModel,
                HorizontalOptions = LayoutOptions.FillAndExpand
            };

            _emptyStackLayout   = new StackLayout();
            _currentCityDetails = _emptyStackLayout;
            _citiesMapView      = new CitiesMapView()
            {
                BindingContext    = new MapViewModel(ViewModel.Cities),
                HorizontalOptions = LayoutOptions.FillAndExpand
            };

            _cityDetailsColumn = new ColumnDefinition()
            {
                Width = new GridLength(1, GridUnitType.Star)
            };

            MainGridLayout.Children.Add(_citiesListView, 0, 0);
            Grid.SetRowSpan(_citiesListView, 2);

            SetupLayout(_orientation, false);
        }
 public void InitScreenSize()
 {
     _stackOrientation = StackOrientation.Horizontal;
     if (_screenSizeHandler.GetStartingOrientation() == Orientations.Portrait && _screenSizeHandler.GetScreenSize() == ScreenSizes.Small)
     {
         _stackOrientation = StackOrientation.Vertical;
     }
 }
 /// <summary>
 ///     Make orientation foramtted string
 /// </summary>
 /// <param name="str"></param>
 /// <param name="orientation"></param>
 /// <returns></returns>
 public static FormattedString MakeOrientationFormattedString(string str, StackOrientation orientation)
 {
     if (orientation == StackOrientation.Vertical)
     {
         return(MakeTextVertical(str));
     }
     return(MakeTextHorizontal(str));
 }
 /// <summary>
 /// Ctr.
 /// </summary>
 public StackingLayoutStrategy()
 {
     Orientation              = StackOrientation.SingleRowHorizontal;
     ParentAlignment          = BranchParentAlignment.InvalidValue;
     ChildConnectorHookLength = 0;
     ParentConnectorShield    = 0;
     SiblingSpacing           = 5;
 }
 private void OnSizeChanged(object sender, EventArgs e)
 {
     _orientation = Width > Height ? StackOrientation.Horizontal : StackOrientation.Vertical;
     if (Device.Idiom == TargetIdiom.Desktop)
     {
         return;
     }
     SetupAndFillColorGrids();
 }
Exemplo n.º 12
0
        public static StackLayout Inside_Frame_View_Orientation(
            StackOrientation orientation)
        {
            var view = new StackLayout();

            view.Orientation = orientation;

            return(view);
        }
Exemplo n.º 13
0
        public static System.Windows.Controls.Orientation ToWPFOrientation(this StackOrientation orientation)
        {
            switch (orientation)
            {
            case StackOrientation.Horizontal: return(System.Windows.Controls.Orientation.Horizontal);

            case StackOrientation.Vertical: return(System.Windows.Controls.Orientation.Vertical);
            }
            throw new NotImplementedException();
        }
Exemplo n.º 14
0
 /// <summary>
 /// Creates a custom stacklayout.
 /// </summary>
 /// <param name="orientation">Defines stacklayout's orientation.</param>
 /// <param name="margin">Stacklayout's margin.</param>
 /// <param name="spacing">Stacklayout's spacing.</param>
 /// <param name="bgColor">Stacklayout's background color.</param>
 /// <returns>A custom stacklayout.</returns>
 public static StackLayout CreateStackLayout(StackOrientation orientation, Thickness margin, double spacing, Color bgColor)
 {
     return(new StackLayout
     {
         Orientation = orientation,
         Margin = margin,
         Spacing = spacing,
         BackgroundColor = bgColor,
         HorizontalOptions = LayoutOptions.Center,
         VerticalOptions = LayoutOptions.Center
     });
 }
        public RestTimerPage()
        {
            InitializeComponent();

            _screenSizeHandler = new ScreenSizeHandler();

            _stackOrientation = StackOrientation.Horizontal;
            if (_screenSizeHandler.GetStartingOrientation() == Orientations.Portrait)
            {
                _stackOrientation = StackOrientation.Vertical;
            }
        }
		public SiloView (IUnityContainer container, IEventAggregator events)
		{
			Container = container;
			Events = events;

			InitializeComponent ();

			Events.GetEvent<OrientationEvent> ().Subscribe (
				o => Orientation = (o == ViewOrientation.Portrait) ? StackOrientation.Horizontal : StackOrientation.Vertical);

			UpdateOrientation ();
		}
        public SiloView(IUnityContainer container, IEventAggregator events)
        {
            Container = container;
            Events    = events;

            InitializeComponent();

            Events.GetEvent <OrientationEvent> ().Subscribe(
                o => Orientation = (o == ViewOrientation.Portrait) ? StackOrientation.Horizontal : StackOrientation.Vertical);

            UpdateOrientation();
        }
Exemplo n.º 18
0
        public static StackLayout StackLayout(StackOrientation orientation, params View[] children)
        {
            var stacklayout = new StackLayout();

            stacklayout.Orientation = orientation;

            foreach (var child in children)
            {
                stacklayout.Children.Add(child);
            }

            return(stacklayout);
        }
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value == null)
            {
                return(false);
            }
            StackOrientation orientation = (StackOrientation)value;

            if (orientation == StackOrientation.Horizontal)
            {
                return(Aspect.AspectFit);
            }
            return(Aspect.AspectFill);
        }
Exemplo n.º 20
0
        public static Grid LineJustificate(this Grid grid, StackOrientation Orientation, Justificate Option, params View[] views)
        {
            switch (Orientation)
            {
            case StackOrientation.Horizontal:
                grid.HorizontalJustificate(Option, views);
                break;

            case StackOrientation.Vertical:
                grid.VerticalJustificate(Option, views);
                break;
            }
            return(grid);
        }
Exemplo n.º 21
0
        StackLayout CreateStackLayout(IEnumerable <View> children, StackOrientation orientation = StackOrientation.Vertical)
        {
            var sl = new StackLayout()
            {
                Orientation = orientation
            };

            foreach (var child in children)
            {
                sl.Children.Add(child);
            }

            return(sl);
        }
Exemplo n.º 22
0
        void CompressNaiveLayout(LayoutInformation layout, StackOrientation orientation, double widthConstraint, double heightConstraint)
        {
            if (layout.CompressionSpace <= 0)
            {
                return;
            }

            if (orientation == StackOrientation.Vertical)
            {
                CompressVerticalLayout(layout, widthConstraint, heightConstraint);
            }
            else
            {
                CompressHorizontalLayout(layout, widthConstraint, heightConstraint);
            }
        }
Exemplo n.º 23
0
        static NSLayoutConstraint [] Stack(StackOrientation orientation, float padding, NSLayoutFormatOptions options, params NSView [] views)
        {
            var names           = views.Select((view, index) => $"{view.Identifier}__{index}");
            var orientIndicator = orientation == StackOrientation.Horizontal ? "H:" : "V:";
            var separator       = padding < 0 ? "-" : $"-({padding})-";
            var vfl             = string.Join(separator, names.Select(name => $"[{name}]"));
            var objects         = new List <object> ();

            for (var i = 0; i < views.Length; i++)
            {
                objects.Add(names.ElementAt(i));
                objects.Add(views [i]);
            }

            return(NSLayoutConstraint.FromVisualFormat(orientIndicator + vfl, options, objects.ToArray()));
        }
Exemplo n.º 24
0
        private void SetupLayout(StackOrientation newOrientation, bool subsequentCall)
        {
            switch (newOrientation)
            {
            case StackOrientation.Vertical:
                SetupVerticalLayout(subsequentCall);
                break;

            case StackOrientation.Horizontal:
                SetupHorizontalLayout(subsequentCall);
                break;

            default:
                SetupVerticalLayout(subsequentCall);
                break;
            }
        }
Exemplo n.º 25
0
 protected override void OnSizeAllocated(double width, double height)
 {
     base.OnSizeAllocated(width, height); //must be called
     if (this.ContentOrientationWidth != width || this.ContentOrientationHeight != height)
     {
         this.ContentOrientationWidth  = width;
         this.ContentOrientationHeight = height;
         if (width > height)
         {
             ContentOrientation = StackOrientation.Horizontal;
         }
         else
         {
             ContentOrientation = StackOrientation.Vertical;
         }
     }
 }
Exemplo n.º 26
0
 void AlignOffAxis(LayoutInformation layout, StackOrientation orientation, double widthConstraint, double heightConstraint)
 {
     for (var i = 0; i < layout.Plots?.Length; i++)
     {
         if (!((View)LogicalChildrenInternal[i]).IsVisible)
         {
             continue;
         }
         if (orientation == StackOrientation.Vertical)
         {
             layout.Plots[i].Width = widthConstraint;
         }
         else
         {
             layout.Plots[i].Height = heightConstraint;
         }
     }
 }
Exemplo n.º 27
0
        void CalculateLayout(LayoutInformation layout, double x, double y, double widthConstraint, double heightConstraint, bool processExpanders)
        {
            layout.Constraint       = new Size(widthConstraint, heightConstraint);
            layout.Expanders        = 0;
            layout.CompressionSpace = 0;
            layout.Plots            = new Rectangle[Children.Count];
            layout.Requests         = new SizeRequest[Children.Count];

            StackOrientation orientation = Orientation;

            CalculateNaiveLayout(layout, orientation, x, y, widthConstraint, heightConstraint);
            CompressNaiveLayout(layout, orientation, widthConstraint, heightConstraint);

            if (processExpanders)
            {
                AlignOffAxis(layout, orientation, widthConstraint, heightConstraint);
                ProcessExpanders(layout, orientation, x, y, widthConstraint, heightConstraint);
            }
        }
Exemplo n.º 28
0
        protected override async void OnSizeAllocated(double width, double height)
        {
            base.OnSizeAllocated(width, height);
            if (Math.Abs(_width - width) > 0.1 || Math.Abs(_height - height) > 0.1)
            {
                _width  = width;
                _height = height;

                var newOrientation = ViewHelper.DetermineOrientation(width, height);
                if (_cityDetailsViewShowing && newOrientation == StackOrientation.Horizontal)
                {
                    await CloseCityDetailsView();
                }
                if (_initialized && _orientation != newOrientation)
                {
                    _orientation = newOrientation;
                    SetupLayout(_orientation);
                }
            }
        }
Exemplo n.º 29
0
        protected override void OnSizeAllocated(double width, double height)
        {
            base.OnSizeAllocated(width, height);
            if (_width != width || _height != height)
            {
                _width  = width;
                _height = height;

                var newOrientation = ViewHelper.DetermineOrientation(width, height);
                if (_cityDetailsViewShowing && newOrientation == StackOrientation.Horizontal)
                {
                    CloseCityDetailsView();
                }
                if (_initialized && _orientation != newOrientation)
                {
                    _orientation = newOrientation;
                    SetupLayout(_orientation);
                }
            }
        }
Exemplo n.º 30
0
        protected override void OnElementChanged(ElementChangedEventArgs <DraggableSeparator> e)
        {
            base.OnElementChanged(e);

            if (e.OldElement != null)
            {
                e.OldElement.OrientationChanged -= OrientationChanged;
                e.OldElement.ViewRemoved        -= NewElementOnViewRemoved;
            }

            if (e.NewElement != null)
            {
                e.NewElement.OrientationChanged += OrientationChanged;
                e.NewElement.ViewRemoved        += NewElementOnViewRemoved;
            }

            Orientation = e.NewElement?.Orientation ?? StackOrientation.Vertical;

            if (Control != null)
            {
                return;
            }
            if (_element != null)
            {
                return;
            }

            _element = new Rectangle
            {
                Fill            = new SolidColorBrush(Windows.UI.Color.FromArgb(29, 38, 55, 0)),
                Stroke          = new SolidColorBrush(Windows.UI.Color.FromArgb(29, 38, 55, 0)),
                StrokeThickness = 1
            };

            _element.PointerPressed  += PointerPressed;
            _element.PointerReleased += PointerReleased;
            _element.PointerEntered  += PointerEntered;
            _element.PointerExited   += PointerExited;

            SetNativeControl(_element);
        }
        protected override void OnSizeAllocated(double width, double height)
        {
            base.OnSizeAllocated(width, height);

            var orientation = _screenSizeHandler.OnSizeAllocated(width, height);

            switch (orientation)
            {
            case Orientations.Landscape:
                MotivationalQuoteImage.Padding = new Thickness(10, 10, 0, 10);
                _stackOrientation           = StackOrientation.Horizontal;
                MainStackLayout.Orientation = _stackOrientation;
                break;

            case Orientations.Portrait:
                MotivationalQuoteImage.Padding = new Thickness(0, 0, 0, 10);
                _stackOrientation           = StackOrientation.Vertical;
                MainStackLayout.Orientation = _stackOrientation;
                break;
            }
        }
		void OnOrientationEventReceived (ViewOrientation orientation)
		{
			Orientation = (orientation == ViewOrientation.Portrait) ? StackOrientation.Horizontal : StackOrientation.Vertical;

			UpdateOrientation ();
		}