public WpfTextStringFormat(FlowDirection direction, TextTrimming trimming, WpfTextAnchor anchor) { this.Direction = direction; this.Trimming = trimming; this.Anchor = anchor; }
private void UpdateItemsSource(List<ApplicationBarIconButton> buttons, FlowDirection flowDirection) { try { if (buttons != null || buttons.Count == 0) { if (flowDirection == FlowDirection.RightToLeft) buttons.Reverse(); Buttons.Dettach(SysAppBar); Buttons.Clear(); foreach (ApplicationBarIconButton button in buttons) { Buttons.Add(button); } Buttons.Attach(DataContext, SysAppBar); } else { Buttons.Dettach(SysAppBar); Buttons.Clear(); Buttons.Attach(DataContext, SysAppBar); } } catch (Exception e) { Console.WriteLine(e); } }
public VirtualKey(VirtualKeyboard keyboard, KeySet keySet, KeySetRow row, Key key) { _keyboard = keyboard; _keySet = keySet; _key = key; if (row.IndexOf(key) < row.Count/2) _popupFlowDirection = FlowDirection.LeftToRight; else _popupFlowDirection = FlowDirection.RightToLeft; PrimaryAction = new VirtualKeyAction(keyboard, keySet, key.DefaultAction, key.Width); Loaded += (s, e) => { if (AlternativesPopup != null) { if (_popupFlowDirection == FlowDirection.LeftToRight) { AlternativesPopup.HorizontalOffset = -ActualWidth; AlternativesPopup.Placement = PlacementMode.Right; } else { AlternativesPopup.HorizontalOffset = ActualWidth; AlternativesPopup.Placement = PlacementMode.Left; } } }; }
internal FlowLayoutSettings (Control owner) { flow_breaks = new Dictionary<object, bool> (); wrap_contents = true; flow_direction = FlowDirection.LeftToRight; this.owner = owner; }
public FluentMenu(Action<IMenuRegister> completionAction, IMenuRegister parentMenu, string name) { _completionAction = completionAction; _parentMenu = parentMenu; _name = name; _flowDirection = FlowDirection.LeftToRight; }
private void UpdateItemsSource(List<ApplicationBarIconButton> buttons, FlowDirection flowDirection) { if (buttons != null) { if (buttons.Count > 0) { if (flowDirection == FlowDirection.RightToLeft) buttons.Reverse(); Buttons.Dettach(SysAppBar); Buttons.Clear(); foreach (ApplicationBarIconButton button in buttons) { Buttons.Add(button); } Buttons.Attach(DataContext, SysAppBar); } } else { Buttons.Dettach(SysAppBar); Buttons.Clear(); Buttons.Attach(DataContext, SysAppBar); } }
public static BitmapSource RenderToBitmap( this Visual visual, PixelFormat pixelFormat, FlowDirection flowDirection = FlowDirection.LeftToRight, double dpiX = 96.0, double dpiY = 96.0) { if (visual == null) throw new ArgumentException("visual"); var cv = visual as ContainerVisual; if (cv != null) { var bounds = cv.DescendantBounds; var size = new Size(bounds.Right, bounds.Bottom); return visual.RenderToBitmap(size, bounds.Location, bounds.Size, pixelFormat); } else { var bounds = VisualTreeHelper.GetDescendantBounds(visual); var size = new Size(bounds.Right, bounds.Bottom); return visual.RenderToBitmap(size, bounds.Location, bounds.Size, pixelFormat); } }
public static BitmapSource RenderToBitmap( this Visual visual, FlowDirection flowDirection = FlowDirection.LeftToRight, double dpiX = 96.0, double dpiY = 96.0) { return visual.RenderToBitmap(PixelFormats.Pbgra32, flowDirection, dpiX, dpiY); }
public SupportedCulture(string cultureId, EventHandler isSelectedChangEventHandler) { CultureInfo = CultureInfo.GetCultureInfo(cultureId); Flag = (ImageSource) App.Current.FindResource(cultureId); XmlLanguage = XmlLanguage.GetLanguage(CultureInfo.Name); FlowDirection = CultureInfo.TextInfo.IsRightToLeft ? FlowDirection.RightToLeft : FlowDirection.LeftToRight; IsSelectedChanged += isSelectedChangEventHandler; }
public PlacementHelper(Rect placementRect, Size popupSize, double horizontalOffset, double verticalOffset, Size viewPortSize, FlowDirection flowDirection) { this.popupSize = popupSize; this.placementRect = placementRect; this.viewPortRect = new Rect(0, 0, viewPortSize.Width, viewPortSize.Height); this.offset = new Point(horizontalOffset, verticalOffset); this.flowDirection = flowDirection; }
/// <summary> /// Sets the selectors and title flow direction. /// </summary> /// <param name="flowDirection">Flow direction to set.</param> internal void SetFlowDirection(FlowDirection flowDirection) { HeaderTitle.FlowDirection = flowDirection; PrimarySelector.FlowDirection = flowDirection; SecondarySelector.FlowDirection = flowDirection; TertiarySelector.FlowDirection = flowDirection; }
/// <summary> /// Sets the selectors and title flow direction. /// </summary> /// <param name="flowDirection">Flow direction to set.</param> public override void SetFlowDirection(FlowDirection flowDirection) { HeaderTitle.FlowDirection = flowDirection; PrimarySelector.FlowDirection = flowDirection; SecondarySelector.FlowDirection = flowDirection; TertiarySelector.FlowDirection = flowDirection; }
public static IGeometry Read(string text, Typeface font, double size, Point origin, FlowDirection flowDirection, IGeometryFactory geomFact) { var formattedText = new FormattedText(text, System.Globalization.CultureInfo.CurrentUICulture, flowDirection, font, size, Brushes.Black); var geom = formattedText.BuildGeometry(origin); return WpfGeometryReader.Read(geom.GetFlattenedPathGeometry(FlatnessFactor, ToleranceType.Relative), geomFact); }
public static void SetFlowDirection(IArrangedElement container, FlowDirection value) { if (!System.Windows.Forms.ClientUtils.IsEnumValid(value, (int) value, 0, 3)) { throw new InvalidEnumArgumentException("value", (int) value, typeof(FlowDirection)); } container.Properties.SetInteger(_flowDirectionProperty, (int) value); LayoutTransaction.DoLayout(container, container, PropertyNames.FlowDirection); }
/// <summary> /// Constructing TextBounds object /// </summary> internal TextBounds( Rect bounds, FlowDirection flowDirection, IList<TextRunBounds> runBounds ) { _bounds = bounds; _flowDirection = flowDirection; _runBounds = runBounds; }
public TextImageWidget(string label, RGBA_Bytes fillColor, RGBA_Bytes borderColor, RGBA_Bytes textColor, double borderWidth, BorderDouble margin, ImageBuffer image = null, double fontSize = 12, FlowDirection flowDirection = FlowDirection.LeftToRight, double height = 40, double width = 0, bool centerText = false, double imageSpacing = 0) : base() { this.image = image; this.fillColor = fillColor; this.borderColor = borderColor; this.borderWidth = borderWidth; this.Margin = new BorderDouble(0); this.Padding = new BorderDouble(0); TextWidget textWidget = new TextWidget(label, pointSize: fontSize); ImageWidget imageWidget; FlowLayoutWidget container = new FlowLayoutWidget(flowDirection); if (centerText) { // make sure the contents are centered GuiWidget leftSpace = new GuiWidget(0, 1); leftSpace.HAnchor = Agg.UI.HAnchor.ParentLeftRight; container.AddChild(leftSpace); } if (image != null && image.Width > 0) { imageWidget = new ImageWidget(image); imageWidget.VAnchor = VAnchor.ParentCenter; imageWidget.Margin = new BorderDouble(right: imageSpacing); container.AddChild(imageWidget); } if (label != "") { textWidget.VAnchor = VAnchor.ParentCenter; textWidget.TextColor = textColor; textWidget.Padding = new BorderDouble(3, 0); container.AddChild(textWidget); } if (centerText) { GuiWidget rightSpace = new GuiWidget(0, 1); rightSpace.HAnchor = Agg.UI.HAnchor.ParentLeftRight; container.AddChild(rightSpace); container.HAnchor = Agg.UI.HAnchor.ParentLeftRight | Agg.UI.HAnchor.FitToChildren; } container.VAnchor = Agg.UI.VAnchor.ParentCenter; container.MinimumSize = new Vector2(width, height); container.Margin = margin; this.AddChild(container); HAnchor = HAnchor.ParentLeftRight | HAnchor.FitToChildren; VAnchor = VAnchor.ParentCenter | Agg.UI.VAnchor.FitToChildren; }
public static BitmapSource RenderToBitmap( this Visual visual, Size size, FlowDirection flowDirection = FlowDirection.LeftToRight, double dpiX = 96.0, double dpiY = 96.0) { if (visual == null) throw new ArgumentException("visual"); return visual.RenderToBitmap(size, new Point(0, 0), size, PixelFormats.Pbgra32); }
public static double GetFontWidth(string text, CultureInfo cultureInfo, FontFamily fontFamily, double fontSize, FlowDirection leftToRight) { return new FormattedText(text, cultureInfo, leftToRight, new Typeface(fontFamily.ToString()), fontSize, Brushes.Black) .Width; }
public GenericTextParagraphProperties(FontRendering newRendering) { _flowDirection = FlowDirection.LeftToRight; _textAlignment = newRendering.TextAlignment; _firstLineInParagraph = false; _alwaysCollapsible = false; _defaultTextRunProperties = new GenericTextRunProperties( newRendering.Typeface, newRendering.FontSize, newRendering.FontSize, newRendering.TextDecorations, newRendering.TextColor, null, BaselineAlignment.Baseline, CultureInfo.CurrentUICulture); _textWrap = TextWrapping.Wrap; _lineHeight = 0; _indent = 0; _paragraphIndent = 0; }
public static BitmapSource RenderToBitmap( this Visual visual, Size bitmapSize, Point visualPositionOnBitmap, FlowDirection flowDirection = FlowDirection.LeftToRight, double dpiX = 96.0, double dpiY = 96.0) { if (visual == null) throw new ArgumentException("visual"); var bounds = VisualTreeHelper.GetDescendantBounds(visual); return visual.RenderToBitmap(bitmapSize, visualPositionOnBitmap, bounds.Size, PixelFormats.Pbgra32); }
private static ContainerProxy CreateContainerProxy(IArrangedElement container, FlowDirection flowDirection) { switch (flowDirection) { case FlowDirection.RightToLeft: return new RightToLeftProxy(container); case FlowDirection.TopDown: return new TopDownProxy(container); case FlowDirection.BottomUp: return new BottomUpProxy(container); case FlowDirection.LeftToRight: default: return new ContainerProxy(container); } }
public static void ChangeLanguage(string code, FlowDirection flowDirection) { var culture = new CultureInfo(code); Windows.Globalization.ApplicationLanguages.PrimaryLanguageOverride = culture.Name; CultureInfo.DefaultThreadCurrentCulture = culture; CultureInfo.DefaultThreadCurrentUICulture = culture; var frame = Window.Current.Content as Frame; if (frame != null) frame.FlowDirection = flowDirection; //var loader = new Windows.ApplicationModel.Resources.ResourceLoader(); ResourceManager.Current.DefaultContext.Reset(); Windows.ApplicationModel.Resources.Core.ResourceContext.GetForCurrentView().Reset(); Windows.ApplicationModel.Resources.Core.ResourceContext.GetForViewIndependentUse().Reset(); }
public FormattedText( string textToFormat, CultureInfo culture, FlowDirection flowDirection, Typeface typeface, double emSize, Brush foreground) { this.Foreground = foreground; this.PlatformImpl = PlatformInterface.Instance.CreateFormattedText( textToFormat, typeface, emSize); this.Text = textToFormat; }
// ------------------------------------------------------------------ // // Visual Helpers // // ------------------------------------------------------------------ #region Visual Helpers // ------------------------------------------------------------------ // Update mirroring transform. // ------------------------------------------------------------------ internal static void UpdateMirroringTransform(FlowDirection parentFD, FlowDirection childFD, ContainerVisual visualChild, double width) { // Set mirroring transform if necessary, or clear it just in case it was set in the previous // format process. if (parentFD != childFD) { MatrixTransform transform = new MatrixTransform(-1.0, 0.0, 0.0, 1.0, width, 0.0); visualChild.Transform = transform; visualChild.SetValue(FrameworkElement.FlowDirectionProperty, childFD); } else { visualChild.Transform = null; visualChild.ClearValue(FrameworkElement.FlowDirectionProperty); } }
/// <summary> /// Create an instance of AnnotationDocumentPaginator for a given document and annotation store. /// </summary> /// <param name="originalPaginator">document to add annotations to</param> /// <param name="annotationStore">store to retrieve annotations from</param> /// <param name="flowDirection"></param> public AnnotationDocumentPaginator(DocumentPaginator originalPaginator, AnnotationStore annotationStore, FlowDirection flowDirection) { _isFixedContent = originalPaginator is FixedDocumentPaginator || originalPaginator is FixedDocumentSequencePaginator; if (!_isFixedContent && !(originalPaginator is FlowDocumentPaginator)) throw new ArgumentException(SR.Get(SRID.OnlyFlowAndFixedSupported)); _originalPaginator = originalPaginator; _annotationStore = annotationStore; _locatorManager = new LocatorManager(_annotationStore); _flowDirection = flowDirection; // Register for events _originalPaginator.GetPageCompleted += new GetPageCompletedEventHandler(HandleGetPageCompleted); _originalPaginator.ComputePageCountCompleted += new AsyncCompletedEventHandler(HandleComputePageCountCompleted); _originalPaginator.PagesChanged += new PagesChangedEventHandler(HandlePagesChanged); }
public GenericTextParagraphProperties( FlowDirection flowDirection, TextAlignment textAlignment, bool firstLineInParagraph, bool alwaysCollapsible, TextRunProperties defaultTextRunProperties, TextWrapping textWrap, double lineHeight, double indent) { _flowDirection = flowDirection; _textAlignment = textAlignment; _firstLineInParagraph = firstLineInParagraph; _alwaysCollapsible = alwaysCollapsible; _defaultTextRunProperties = defaultTextRunProperties; _textWrap = textWrap; _lineHeight = lineHeight; _indent = indent; }
/// <summary> /// Construct a FormattedText object. /// </summary> /// <param name="textToFormat">String of text to be displayed.</param> /// <param name="culture">Culture of text.</param> /// <param name="flowDirection">Flow direction of text.</param> /// <param name="typeface">Type face used to display text.</param> /// <param name="emSize">Font em size in visual units (1/96 of an inch).</param> /// <param name="foreground">Foreground brush used to render text.</param> /// <param name="numberSubstitution">Number substitution behavior to apply to the text; can be null, /// in which case the default number number method for the text culture is used.</param> public FormattedText( string textToFormat, CultureInfo culture, FlowDirection flowDirection, Typeface typeface, double emSize, Brush foreground, NumberSubstitution numberSubstitution) : this( textToFormat, culture, flowDirection, typeface, emSize, foreground, numberSubstitution, TextFormattingMode.Ideal ) { }
/// <summary> /// Calculates the desired width for the given text. /// </summary> /// <param name="text">The text.</param> /// <param name="fontSize">The used fontsize.</param> /// <param name="fontFamily">The used font family.</param> /// <param name="fontWeight">The used font weight.</param> /// <param name="fontStyle">The used font style.</param> /// <param name="fontStretch">The used font stretch.</param> /// <param name="flowDirection">The used flow direction.</param> /// <param name="foreground">The used foreground brush.</param> /// <returns>A double representing the desired width for the given text.</returns> public static double CalculateWidth(this string text, double fontSize, FontFamily fontFamily, FontWeight fontWeight, FontStyle fontStyle, FontStretch fontStretch, FlowDirection flowDirection, Brush foreground) { var typeface = new Typeface(fontFamily, fontStyle, fontWeight, fontStretch); var formattedText = new FormattedText ( text, CultureInfo.CurrentCulture, flowDirection, typeface, fontSize, foreground ) { Trimming = TextTrimming.CharacterEllipsis }; return formattedText.Width; }
public void Add(Layer item, FlowDirection direction) { Args.Requires(() => item, () => item != null); Args.Requires(() => direction, () => direction == FlowDirection.OneWay || direction == FlowDirection.OneWayToSource || direction == FlowDirection.TwoWay); if (!otherLayers.Any(l => l.Item2 == item)) { WithOtherSideUpdateSuppressed(item, () => { if (Type == ConnectionType.Output) { item.InputConnections.Add(ConnectedLayer, direction); } else { item.OutputConnections.Add(ConnectedLayer, direction); } }); otherLayers.Add(Tuple.Create(direction, item)); } }
//Set Defaults public DropDownButtonBase(string label, RGBA_Bytes fillColor, RGBA_Bytes borderColor, RGBA_Bytes textColor, double borderWidth, BorderDouble margin, int fontSize = 12, FlowDirection flowDirection = FlowDirection.LeftToRight, double height = 40) { FlowLayoutWidget container = new FlowLayoutWidget(); container.Padding = new BorderDouble(0); container.Margin = new BorderDouble(0); if (label != "") { TextWidget text = new TextWidget(label, pointSize: fontSize, textColor: textColor); text.VAnchor = VAnchor.ParentCenter; text.Padding = new BorderDouble(0, 0); container.AddChild(text); } GuiWidget arrow = new GuiWidget(20, height); arrow.VAnchor = VAnchor.ParentCenter; container.AddChild(arrow); this.AddChild(container); this.Padding = new BorderDouble(0, 0); this.fillColor = fillColor; this.borderColor = borderColor; this.borderWidth = borderWidth; this.HAnchor = HAnchor.FitToChildren; }
private void RenderCells( DrawingContext context, Rect viewport, double canvasWidth, double columnHeight, double[] columnEdges, int firstVisibleColumn, int lastVisibleColumn, int firstVisibleRow, int lastVisibleRow, int firstNonFrozenColumn, int lastNonFrozenColumn) { double horizontalOffset = cellsPresenter.HorizontalOffset; double verticalOffset = cellsPresenter.VerticalOffset; double rowHeight = cellsPresenter.RowHeight; var visibleColumns = cellsPresenter.VisibleColumns; Typeface typeface = cellsPresenter.Typeface; double fontSize = cellsPresenter.FontSize; FlowDirection flowDirection = cellsPresenter.FlowDirection; CultureInfo currentCulture = CultureInfo.CurrentCulture; Pen verticalGridLinesPen = cellsPresenter.VerticalGridLinesPen; Brush keySeparatorBrush = cellsPresenter.KeySeparatorBrush; Brush freezableAreaSeparatorBrush = cellsPresenter.FreezableAreaSeparatorBrush; Brush selectionForeground = cellsPresenter.SelectionForeground; if (!IsSelectionActive) { selectionForeground = cellsPresenter.InactiveSelectionForeground; } var rowSelection = cellsPresenter.ViewModel.RowSelection; double padding = rowHeight / 10; double totalPadding = 2 * padding; for (int col = firstVisibleColumn; col <= lastVisibleColumn; ++col) { double leftEdge = columnEdges[col] - horizontalOffset; double rightEdge = columnEdges[col + 1] - horizontalOffset; double cellWidth = rightEdge - leftEdge; if (verticalGridLinesPen != null) { context.DrawLineSnapped( verticalGridLinesPen, new Point(leftEdge, 0), new Point(leftEdge, columnHeight)); } var column = visibleColumns[col]; if (column.IsKeySeparator) { context.DrawRectangle( keySeparatorBrush, null, new Rect(leftEdge, 0, cellWidth, columnHeight)); } else if (column.IsFreezableAreaSeparator) { context.DrawRectangle( freezableAreaSeparatorBrush, null, new Rect(leftEdge, 0, cellWidth, columnHeight)); } } double lastRightEdge = columnEdges[columnEdges.Length - 1]; if (lastRightEdge <= viewport.Right && verticalGridLinesPen != null) { context.DrawLineSnapped( verticalGridLinesPen, new Point(lastRightEdge, 0), new Point(lastRightEdge, columnHeight)); } bool hasFrozenColumns = firstNonFrozenColumn > firstVisibleColumn || lastNonFrozenColumn < lastVisibleColumn; int viewportSizeHint = lastVisibleRow - firstVisibleRow + 1; for (int row = firstVisibleRow; row <= lastVisibleRow; ++row) { double rowX = -horizontalOffset; double rowY = (row * rowHeight) - verticalOffset; Brush foreground = cellsPresenter.Foreground; if (rowSelection.Contains(row)) { foreground = selectionForeground; } int styleHash = ComputeRowStyleHash(rowHeight, flowDirection, typeface, fontSize, foreground); if (!TryGetCachedRow(row, styleHash, out var rowVisual)) { var rowContext = rowVisual.RenderOpen(); for (int col = firstNonFrozenColumn; col <= lastNonFrozenColumn; ++col) { var column = visibleColumns[col]; if (column.IsKeySeparator || column.IsFreezableAreaSeparator) { continue; } double topEdge = 0; double leftEdge = columnEdges[col]; double rightEdge = columnEdges[col + 1]; double cellWidth = rightEdge - leftEdge; var value = column.GetCellValue(row, viewportSizeHint); if (value != null) { var formatted = new FormattedText( value.ToString(), currentCulture, flowDirection, typeface, fontSize, foreground, null, TextFormattingMode.Display); formatted.MaxTextWidth = Math.Max(cellWidth - totalPadding, 0); formatted.MaxTextHeight = rowHeight; formatted.TextAlignment = column.TextAlignment; formatted.Trimming = TextTrimming.CharacterEllipsis; if (totalPadding < cellWidth) { var offsetY = (rowHeight - formatted.Height) / 2; var origin = new Point( leftEdge + padding, topEdge + offsetY); origin = origin.Round(MidpointRounding.AwayFromZero); rowContext.DrawText(formatted, origin); } } } rowContext.Close(); } AddAtOffset(rowVisual, rowX, rowY); if (hasFrozenColumns) { if (nonFrozenAreaClip == null) { double nonFrozenLeftEdge = columnEdges[firstNonFrozenColumn]; double nonFrozenRightEdge = canvasWidth - (columnEdges[lastVisibleColumn + 1] - columnEdges[lastNonFrozenColumn + 1]); var nonFrozenArea = new Rect( nonFrozenLeftEdge, 0, Math.Max(nonFrozenRightEdge - nonFrozenLeftEdge, 0), rowHeight); nonFrozenAreaClip = new RectangleGeometry(nonFrozenArea) { Transform = new TranslateTransform(horizontalOffset, 0) }; } rowVisual.Clip = nonFrozenAreaClip; ((TranslateTransform)nonFrozenAreaClip.Transform).X = horizontalOffset; if (!TryGetCachedFrozenRow(row, styleHash, out var frozenRowVisual)) { var rowContext = frozenRowVisual.RenderOpen(); for (int col = firstVisibleColumn; col <= lastVisibleColumn; ++col) { var column = visibleColumns[col]; if (column.IsKeySeparator || column.IsFreezableAreaSeparator) { continue; } if (col >= firstNonFrozenColumn && col <= lastNonFrozenColumn) { continue; } double topEdge = 0; double leftEdge = columnEdges[col]; double rightEdge = columnEdges[col + 1]; double cellWidth = rightEdge - leftEdge; if (col > lastNonFrozenColumn) { double distance = columnEdges[lastVisibleColumn + 1] - columnEdges[col]; leftEdge = canvasWidth - distance; rightEdge = leftEdge + cellWidth; } var value = column.GetCellValue(row, viewportSizeHint); if (value != null) { var formatted = new FormattedText( value.ToString(), currentCulture, flowDirection, typeface, fontSize, foreground, null, TextFormattingMode.Display); formatted.MaxTextWidth = Math.Max(cellWidth - totalPadding, 0); formatted.MaxTextHeight = rowHeight; formatted.TextAlignment = column.TextAlignment; formatted.Trimming = TextTrimming.CharacterEllipsis; if (totalPadding < cellWidth) { var offsetY = (rowHeight - formatted.Height) / 2; var origin = new Point( leftEdge + padding, topEdge + offsetY); origin = origin.Round(MidpointRounding.AwayFromZero); rowContext.DrawText(formatted, origin); } } } rowContext.Close(); } AddAtOffset(frozenRowVisual, 0, rowY); } } }
internal Team(SpriteManager spriteManager, Vector2 starPosition, FlowDirection direction) { this.direction = direction; scoreText = scoreText; float scale = TournamentLayout.ClientScale * GameBase.WindowManager.Ratio; spriteManager.Add(scoreText = new pText(string.Empty, 20, new Vector2(480, 946) / scale, 1.01f, true, Color.White) { Field = direction == FlowDirection.Right ? Fields.TopRight : Fields.TopLeft, Origin = Origins.Centre, FontFace = FontFace.ExoLight, TextItalic = true, TextShadow = false }); spriteManager.Add(teamName = new pText(string.Empty, 16, new Vector2(110, 78) / scale, 1.01f, true, Color.White) { Field = direction == FlowDirection.Right ? Fields.TopRight : Fields.TopLeft, Origin = direction == FlowDirection.Right ? Origins.CentreRight : Origins.CentreLeft, FontFace = FontFace.ExoRegular, TextBold = true, TextShadow = false }); spriteManager.Add(teamFlag = new pSprite(null, new Vector2(57, 78) / scale, 1.01f, true, Color.White) { Field = direction == FlowDirection.Right ? Fields.TopRight : Fields.TopLeft, Origin = Origins.Centre, Scale = 0.3f }); winsTextElements.Add(winsText = new pText(@"0", 60 / TournamentLayout.ClientScale / 1.6f, starPosition - new Vector2(0, 6), 1.01f, true, Color.White) { Origin = Origins.Centre, FontFace = FontFace.ExoMedium, TextShadow = false }); winsTextElements.Add(winsTextBo1 = new pText(@"of", 20 / TournamentLayout.ClientScale / 1.6f, starPosition, 1.01f, true, Color.White) { Origin = Origins.TopLeft, FontFace = FontFace.ExoLight, Alpha = 0, TextShadow = false }); winsTextElements.Add(winsTextBo2 = new pText(@"0", 20 / TournamentLayout.ClientScale / 1.6f, starPosition, 1.01f, true, Color.White) { Origin = Origins.TopLeft, FontFace = FontFace.ExoLight, Alpha = 0, TextBold = true, TextShadow = false }); spriteManager.Add(winsTextElements); for (int i = 0; i < max_stars; i++) { var starSprite = new pTextAwesome(FontAwesome.star_o, 60 / TournamentLayout.ClientScale / 1.6f, starPosition) { Depth = 1.01f, Origin = direction == FlowDirection.Left ? Origins.CentreRight : Origins.CentreLeft, Alpha = 1f, TextShadow = false }; var starSprite2 = new pTextAwesome(FontAwesome.star, 60 / TournamentLayout.ClientScale / 1.6f, starPosition) { Depth = 1.01f, Origin = direction == FlowDirection.Left ? Origins.CentreRight : Origins.CentreLeft, Alpha = 0, TextShadow = false }; blankStars.Add(starSprite); spriteManager.Add(starSprite); filledStars.Add(starSprite2); spriteManager.Add(starSprite2); if (i == 0) { continue; } blankStars[i].Position.X = blankStars[i - 1].Position.X + (direction == FlowDirection.Left ? -1 : 1) * (blankStars[i].MeasureText().X / TournamentLayout.ClientScale + star_spacing); filledStars[i].Position.X = filledStars[i - 1].Position.X + (direction == FlowDirection.Left ? -1 : 1) * (filledStars[i].MeasureText().X / TournamentLayout.ClientScale + star_spacing); } refreshStars(); InputManager.Bind(InputEventType.OnClick, handleMouseClick, InputTargetPriority.Highest, BindLifetime.Permanent); }
public TextImageWidget(string label, RGBA_Bytes fillColor, RGBA_Bytes borderColor, RGBA_Bytes textColor, double borderWidth, BorderDouble margin, ImageBuffer image = null, int fontSize = 12, FlowDirection flowDirection = FlowDirection.LeftToRight, double height = 40, double width = 0, bool centerText = false) : base() { this.image = image; this.fillColor = fillColor; this.borderColor = borderColor; this.borderWidth = borderWidth; this.Margin = new BorderDouble(0); this.Padding = new BorderDouble(0); TextWidget textWidget = new TextWidget(label, pointSize: fontSize); ImageWidget imageWidget; FlowLayoutWidget container = new FlowLayoutWidget(flowDirection); if (centerText) { // make sure the contents are centered GuiWidget leftSpace = new GuiWidget(0, 1); leftSpace.HAnchor = Agg.UI.HAnchor.ParentLeftRight; container.AddChild(leftSpace); } if (image != null && image.Width > 0) { imageWidget = new ImageWidget(image); imageWidget.VAnchor = VAnchor.ParentCenter; container.AddChild(imageWidget); } if (label != "") { textWidget.VAnchor = VAnchor.ParentCenter; textWidget.TextColor = textColor; textWidget.Padding = new BorderDouble(3, 0); container.AddChild(textWidget); } if (centerText) { GuiWidget rightSpace = new GuiWidget(0, 1); rightSpace.HAnchor = Agg.UI.HAnchor.ParentLeftRight; container.AddChild(rightSpace); container.HAnchor = Agg.UI.HAnchor.ParentLeftRight | Agg.UI.HAnchor.FitToChildren; } container.VAnchor = Agg.UI.VAnchor.ParentCenter; container.MinimumSize = new Vector2(width, height); container.Margin = margin; this.AddChild(container); HAnchor = HAnchor.ParentLeftRight | HAnchor.FitToChildren; VAnchor = VAnchor.ParentCenter | Agg.UI.VAnchor.FitToChildren; }
public async Task HorizontalTextAlignmentAdjustsForFlowDirection(TextAlignment alignment, FlowDirection flowDirection, UITextAlignment expected) { var label = new LabelStub { Text = "This is TEXT!", HorizontalTextAlignment = alignment, FlowDirection = flowDirection }; var values = await GetValueAsync(label, (handler) => { return(new { ViewValue = label.HorizontalTextAlignment, NativeViewValue = GetNativeHorizontalTextAlignment(handler) }); }); Assert.Equal(expected, values.NativeViewValue); }
/// <include file="../../docs/Microsoft.Maui.Controls/Page.xml" path="//Member[@MemberName='DisplayActionSheet'][2]/Docs" /> public Task <string> DisplayActionSheet(string title, string cancel, string destruction, FlowDirection flowDirection, params string[] buttons) { var args = new ActionSheetArguments(title, cancel, destruction, buttons); args.FlowDirection = flowDirection; if (IsPlatformEnabled) { MessagingCenter.Send(this, ActionSheetSignalName, args); } else { _pendingActions.Add(() => MessagingCenter.Send(this, ActionSheetSignalName, args)); } return(args.Result.Task); }
/// <include file="../../docs/Microsoft.Maui.Controls/Page.xml" path="//Member[@MemberName='DisplayAlert'][2]/Docs" /> public Task <bool> DisplayAlert(string title, string message, string accept, string cancel, FlowDirection flowDirection) { if (string.IsNullOrEmpty(cancel)) { throw new ArgumentNullException("cancel"); } var args = new AlertArguments(title, message, accept, cancel); args.FlowDirection = flowDirection; if (IsPlatformEnabled) { MessagingCenter.Send(this, AlertSignalName, args); } else { _pendingActions.Add(() => MessagingCenter.Send(this, AlertSignalName, args)); } return(args.Result.Task); }
private CheckBoxViewStates getCheckBoxButtonView(string label, string normalImageName = null, string normalToPressedImageName = null, string pressedImageName = null, string pressedToNormalImageName = null, string pressedLabel = null) { ImageBuffer normalImage = new ImageBuffer(); ImageBuffer pressedImage = new ImageBuffer(); ImageBuffer normalToPressedImage = new ImageBuffer(); ImageBuffer pressedToNormalImage = new ImageBuffer(); string pressedText = pressedLabel; if (pressedLabel == null) { pressedText = label; } if (normalToPressedImageName == null) { normalToPressedImageName = pressedImageName; } if (pressedImageName == null) { pressedImageName = normalToPressedImageName; } if (pressedToNormalImageName == null) { pressedToNormalImageName = normalImageName; } if (normalImageName != null) { ImageIO.LoadImageData(this.GetImageLocation(normalImageName), normalImage); if (!ActiveTheme.Instance.IsDarkTheme && AllowThemeToAdjustImage) { InvertLightness.DoInvertLightness(normalImage); } } if (pressedImageName != null) { ImageIO.LoadImageData(this.GetImageLocation(pressedImageName), pressedImage); if (!ActiveTheme.Instance.IsDarkTheme && AllowThemeToAdjustImage) { InvertLightness.DoInvertLightness(pressedImage); } } if (normalToPressedImageName != null) { ImageIO.LoadImageData(this.GetImageLocation(normalToPressedImageName), normalToPressedImage); if (!ActiveTheme.Instance.IsDarkTheme && AllowThemeToAdjustImage) { InvertLightness.DoInvertLightness(normalToPressedImage); } } if (pressedToNormalImageName != null) { ImageIO.LoadImageData(this.GetImageLocation(pressedToNormalImageName), pressedToNormalImage); if (!ActiveTheme.Instance.IsDarkTheme && AllowThemeToAdjustImage) { InvertLightness.DoInvertLightness(pressedToNormalImage); } } if (invertImageLocation) { flowDirection = FlowDirection.RightToLeft; } else { flowDirection = FlowDirection.LeftToRight; } //Create the multi-state button view GuiWidget normal = new TextImageWidget(label, normalFillColor, normalBorderColor, normalTextColor, borderWidth, Margin, normalImage, flowDirection: flowDirection, fontSize: this.fontSize, height: this.FixedHeight); GuiWidget normalHover = new TextImageWidget(label, hoverFillColor, normalBorderColor, hoverTextColor, borderWidth, Margin, normalImage, flowDirection: flowDirection, fontSize: this.fontSize, height: this.FixedHeight); GuiWidget switchNormalToPressed = new TextImageWidget(label, pressedFillColor, normalBorderColor, pressedTextColor, borderWidth, Margin, normalToPressedImage, flowDirection: flowDirection, fontSize: this.fontSize, height: this.FixedHeight); GuiWidget pressed = new TextImageWidget(pressedText, pressedFillColor, pressedBorderColor, pressedTextColor, borderWidth, Margin, pressedImage, flowDirection: flowDirection, fontSize: this.fontSize, height: this.FixedHeight); GuiWidget pressedHover = new TextImageWidget(label, hoverFillColor, pressedBorderColor, hoverTextColor, borderWidth, Margin, pressedImage, flowDirection: flowDirection, fontSize: this.fontSize, height: this.FixedHeight); GuiWidget switchPressedToNormal = new TextImageWidget(label, normalFillColor, pressedBorderColor, normalTextColor, borderWidth, Margin, pressedToNormalImage, flowDirection: flowDirection, fontSize: this.fontSize, height: this.FixedHeight); GuiWidget disabled = new TextImageWidget(label, disabledFillColor, disabledBorderColor, disabledTextColor, borderWidth, Margin, normalImage, flowDirection: flowDirection, fontSize: this.fontSize, height: this.FixedHeight); CheckBoxViewStates checkBoxButtonViewWidget = new CheckBoxViewStates(normal, normalHover, switchNormalToPressed, pressed, pressedHover, switchPressedToNormal, disabled); return(checkBoxButtonViewWidget); }
public static void PushNavigationPage(FlowDirection direction) { ((App)Application.Current).SetMainPage(new FlowDirectionGalleryNP(direction)); }
void SetContent(FlowDirection direction) { var hOptions = LayoutOptions.Start; var imageCell = new DataTemplate(typeof(ImageCell)); imageCell.SetBinding(ImageCell.ImageSourceProperty, "."); imageCell.SetBinding(ImageCell.TextProperty, "."); var textCell = new DataTemplate(typeof(TextCell)); textCell.SetBinding(TextCell.DetailProperty, "."); var entryCell = new DataTemplate(typeof(EntryCell)); entryCell.SetBinding(EntryCell.TextProperty, "."); var switchCell = new DataTemplate(typeof(SwitchCell)); switchCell.SetBinding(SwitchCell.OnProperty, "."); switchCell.SetValue(SwitchCell.TextProperty, "Switch Cell!"); var vc = new ViewCell { View = new StackLayout { Children = { new Label { HorizontalOptions = hOptions, Text = "View Cell! I have context actions." } } } }; var a1 = new MenuItem { Text = "First" }; vc.ContextActions.Add(a1); var a2 = new MenuItem { Text = "Second" }; vc.ContextActions.Add(a2); var viewCell = new DataTemplate(() => vc); var relayout = new Switch { IsToggled = true, HorizontalOptions = LayoutOptions.End, VerticalOptions = LayoutOptions.Center }; var flipButton = new Button { Text = direction == FlowDirection.RightToLeft ? "Switch to Left To Right" : "Switch to Right To Left", HorizontalOptions = LayoutOptions.StartAndExpand, VerticalOptions = LayoutOptions.Center }; flipButton.Clicked += (s, e) => { FlowDirection newDirection; if (direction == FlowDirection.LeftToRight || direction == FlowDirection.MatchParent) { newDirection = FlowDirection.RightToLeft; } else { newDirection = FlowDirection.LeftToRight; } if (relayout.IsToggled) { ParentPage.FlowDirection = newDirection; direction = newDirection; flipButton.Text = direction == FlowDirection.RightToLeft ? "Switch to Left To Right" : "Switch to Right To Left"; return; } if (ParentPage == this) { FlowDirectionGalleryLandingPage.PushContentPage(newDirection); return; } string parentType = ParentPage.GetType().ToString(); switch (parentType) { case "Microsoft.Maui.Controls.ControlGallery.FlowDirectionGalleryMDP": FlowDirectionGalleryLandingPage.PushFlyoutPage(newDirection); break; case "Microsoft.Maui.Controls.ControlGallery.FlowDirectionGalleryCarP": FlowDirectionGalleryLandingPage.PushCarouselPage(newDirection); break; case "Microsoft.Maui.Controls.ControlGallery.FlowDirectionGalleryNP": FlowDirectionGalleryLandingPage.PushNavigationPage(newDirection); break; case "Microsoft.Maui.Controls.ControlGallery.FlowDirectionGalleryTP": FlowDirectionGalleryLandingPage.PushTabbedPage(newDirection); break; } }; var horStack = new StackLayout { Orientation = StackOrientation.Horizontal, Children = { flipButton, new Label { Text = "Relayout", HorizontalOptions = LayoutOptions.End, VerticalOptions = LayoutOptions.Center }, relayout } }; var grid = new Grid { ColumnDefinitions = { new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }, new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }, }, RowDefinitions = { new RowDefinition { Height = new GridLength(100, GridUnitType.Absolute) }, new RowDefinition { Height = new GridLength(100, GridUnitType.Absolute) }, new RowDefinition { Height = new GridLength(100, GridUnitType.Absolute) }, new RowDefinition { Height = new GridLength(100, GridUnitType.Absolute) }, new RowDefinition { Height = new GridLength(100, GridUnitType.Absolute) }, new RowDefinition { Height = new GridLength(100, GridUnitType.Absolute) }, new RowDefinition { Height = new GridLength(100, GridUnitType.Absolute) }, } }; int col = 0; int row = 0; var ai = AddView <ActivityIndicator>(grid, ref col, ref row); ai.IsRunning = true; var box = AddView <BoxView>(grid, ref col, ref row); box.WidthRequest = box.HeightRequest = 20; box.BackgroundColor = Color.Purple; var btn = AddView <Button>(grid, ref col, ref row); btn.Text = "Some text"; var date = AddView <DatePicker>(grid, ref col, ref row, 2); var edit = AddView <Editor>(grid, ref col, ref row); edit.WidthRequest = 100; edit.HeightRequest = 100; edit.Text = "Some longer text for wrapping"; var entry = AddView <Entry>(grid, ref col, ref row); entry.WidthRequest = 100; entry.Text = "Some text"; var image = AddView <Image>(grid, ref col, ref row); image.Source = "oasis.jpg"; var lbl1 = AddView <Label>(grid, ref col, ref row); lbl1.WidthRequest = 100; lbl1.HorizontalTextAlignment = TextAlignment.Start; lbl1.Text = "Start text"; var lblLong = AddView <Label>(grid, ref col, ref row); lblLong.WidthRequest = 100; lblLong.HorizontalTextAlignment = TextAlignment.Start; lblLong.Text = "Start text that should wrap and wrap and wrap"; var lbl2 = AddView <Label>(grid, ref col, ref row); lbl2.WidthRequest = 100; lbl2.HorizontalTextAlignment = TextAlignment.End; lbl2.Text = "End text"; var lbl3 = AddView <Label>(grid, ref col, ref row); lbl3.WidthRequest = 100; lbl3.HorizontalTextAlignment = TextAlignment.Center; lbl3.Text = "Center text"; //var ogv = AddView<OpenGLView>(grid, ref col, ref row, hOptions, vOptions, margin); var pkr = AddView <Picker>(grid, ref col, ref row); pkr.ItemsSource = Enumerable.Range(0, 10).ToList(); var sld = AddView <Slider>(grid, ref col, ref row); sld.WidthRequest = 100; sld.Maximum = 10; Device.StartTimer(TimeSpan.FromSeconds(1), () => { sld.Value += 1; if (sld.Value == 10d) { sld.Value = 0; } return(true); }); var stp = AddView <Stepper>(grid, ref col, ref row); var swt = AddView <Switch>(grid, ref col, ref row); var time = AddView <TimePicker>(grid, ref col, ref row, 2); var prog = AddView <ProgressBar>(grid, ref col, ref row, 2); prog.WidthRequest = 200; prog.BackgroundColor = Color.DarkGray; Device.StartTimer(TimeSpan.FromSeconds(1), () => { prog.Progress += .1; if (prog.Progress == 1d) { prog.Progress = 0; } return(true); }); var srch = AddView <SearchBar>(grid, ref col, ref row, 2); srch.WidthRequest = 200; srch.Text = "Some text"; TableView tbl = new TableView { Intent = TableIntent.Menu, Root = new TableRoot { new TableSection("TableView") { new TextCell { Text = "A", }, new TextCell { Text = "B", }, new TextCell { Text = "C", }, new TextCell { Text = "D", }, } } }; var stack = new StackLayout { Children = { new Button { Text = "Go back to Gallery home", Command = new Command(() =>{ ((App)Application.Current).SetMainPage(((App)Application.Current).CreateDefaultMainPage()); }) }, new Label { Text = $"Device Direction: {DeviceDirection}" }, horStack, grid, new Label { Text = "TableView", FontSize = 10, TextColor = Color.DarkGray }, tbl, new Label { Text = "ListView w/ TextCell", FontSize = 10, TextColor = Color.DarkGray }, new ListView { HorizontalOptions = hOptions, ItemsSource = Enumerable.Range(0, 3).Select(c => "Text Cell!"), ItemTemplate = textCell }, new Label { Text = "ListView w/ SwitchCell", FontSize = 10, TextColor = Color.DarkGray }, new ListView { HorizontalOptions = hOptions, ItemsSource = Enumerable.Range(0, 3).Select(c => true), ItemTemplate = switchCell }, new Label { Text = "ListView w/ EntryCell", FontSize = 10, TextColor = Color.DarkGray }, new ListView { HorizontalOptions = hOptions, ItemsSource = Enumerable.Range(0, 3).Select(c => "Entry Cell!"), ItemTemplate = entryCell }, new Label { Text = "ListView w/ ImageCell", FontSize = 10, TextColor = Color.DarkGray }, new ListView { HorizontalOptions = hOptions, ItemsSource = Enumerable.Range(0, 3).Select(c => "coffee.png"), ItemTemplate = imageCell }, new Label { Text = "ListView w/ ViewCell", FontSize = 10, TextColor = Color.DarkGray }, new ListView { HorizontalOptions = hOptions, ItemsSource = Enumerable.Range(0, 3), ItemTemplate = viewCell }, }, HorizontalOptions = hOptions }; Content = new ScrollView { Content = stack }; }
public static void PushFlyoutPage(FlowDirection direction) { ((App)Application.Current).SetMainPage(new FlowDirectionGalleryMDP(direction)); }
public static void PushCarouselPage(FlowDirection direction) { ((App)Application.Current).SetMainPage(new FlowDirectionGalleryCarP(direction)); }
public static void PushTabbedPage(FlowDirection direction) { ((App)Application.Current).SetMainPage(new FlowDirectionGalleryTP(direction)); }
public ControlPoint(Point point, FlowDirection direct) { }
/// <summary> /// Get the Index value for the previous focused GridColumn /// </summary> /// <param name="TreeGrid"></param> /// <param name="columnIndex"></param> /// <returns></returns> internal static int GetPreviousFocusTreeGridColumnIndex(this SfTreeGrid TreeGrid, int columnIndex, FlowDirection flowdirection = FlowDirection.LeftToRight) { if (flowdirection == FlowDirection.RightToLeft) { return(GetNextFocusTreeGridColumnIndex(TreeGrid, columnIndex)); } var index = columnIndex; if (index < 0 || index >= TreeGrid.Columns.Count) { return(-1); } var gridColumn = TreeGrid.Columns[index]; if (gridColumn == null || !gridColumn.AllowFocus || gridColumn.ActualWidth == 0.0 || double.IsNaN(gridColumn.ActualWidth)) { index = GetPreviousFocusTreeGridColumnIndex(TreeGrid, columnIndex - 1); } return(index); }
// works on IRModel public bool InferAllLayersChannelOrder(Model model, out Dictionary <string, ChannelsOrder> layerChannelOrder) { layerChannelOrder = new Dictionary <string, ChannelsOrder>(); IDictionary <string, TensorShape?> shapesByName = new Dictionary <string, TensorShape?>(); IDictionary <string, int?> ranksByName = new Dictionary <string, int?>(); foreach (var i in model.inputs) { ranksByName[i.name] = i.rank; if (!ModelAnalyzer.IsInputShapeAcceptablyKnowForShapeInference(i)) { continue; } shapesByName[i.name] = new TensorShape(i.shape); } IRShapeInferenceAndConstantFusing shapeInferencePass = new IRShapeInferenceAndConstantFusing(); shapeInferencePass.InferAllShapes(model, ref shapesByName, ref ranksByName); // flood-fill approach: NCHW layout is propagated from NCHW ops // * onnx-nchw ops are flagged as being native nchw // * nchw layout is propagated to upstream and downstream nodes // foreach node: // take layout being propagated to // if T or T-1 flip layout depending on upstream/downstream direction // - stop if layout is the same as previously propagated // - native nchw layout has priority Queue <(string, ChannelsOrder, FlowDirection)> layersToInferLayout = new Queue <(string, ChannelsOrder, FlowDirection)>(); for (int l = 0; l < model.layers.Count; l++) { var layer = model.layers[l]; if (!IsLayerNecessarilyNCHWOnnx(layer)) { continue; } layersToInferLayout.Enqueue((layer.name, ChannelsOrder.NativeNCHW, FlowDirection.Seed)); } while (layersToInferLayout.Any()) { (string, ChannelsOrder, FlowDirection)layerData = layersToInferLayout.Dequeue(); string name = layerData.Item1; ChannelsOrder deducedChannelOrder = layerData.Item2; // 0: in-place native // 1: downstream // 2: upstream FlowDirection flowDirection = layerData.Item3; if (!layerChannelOrder.ContainsKey(name)) { layerChannelOrder[name] = deducedChannelOrder; } else if (deducedChannelOrder == layerChannelOrder[name]) { continue; } else if (layerChannelOrder[name] == ChannelsOrder.NativeNCHW) { continue; } // heuristic to stop ping-pong loop, prioritize NHWC over NCHW as it implies less transposes // if incoming is NativeNCHW always propagate that // TODO: count # of transpose swaps else if (layerChannelOrder[name] == ChannelsOrder.NHWC && deducedChannelOrder != ChannelsOrder.NativeNCHW) { continue; } Layer layer; bool found = ModelAnalyzer.FindLayerByName(model, name, out layer); if (IsLayerChangingLayoutToNHWC(layer, shapesByName, ranksByName)) { // NCHW -> T -> NHWC if (((deducedChannelOrder == ChannelsOrder.NCHW) || (deducedChannelOrder == ChannelsOrder.NativeNCHW)) && (flowDirection == FlowDirection.Downstream)) { deducedChannelOrder = ChannelsOrder.TransposeToNHWC; } // NCHW <- T <- NHWC else if ((deducedChannelOrder == ChannelsOrder.NHWC) && (flowDirection == FlowDirection.Upstream)) { deducedChannelOrder = ChannelsOrder.TransposeToNHWC; } } else if (IsLayerChangingLayoutToNCHW(layer, shapesByName, ranksByName)) { // NHWC -> T-1 -> NCHW if ((deducedChannelOrder == ChannelsOrder.NHWC) && (flowDirection == FlowDirection.Downstream)) { deducedChannelOrder = ChannelsOrder.TransposeToNCHW; } // NHWC <- T-1 <- NCHW else if (((deducedChannelOrder == ChannelsOrder.NCHW) || (deducedChannelOrder == ChannelsOrder.NativeNCHW)) && (flowDirection == FlowDirection.Upstream)) { deducedChannelOrder = ChannelsOrder.TransposeToNCHW; } } if ((deducedChannelOrder == ChannelsOrder.TransposeToNCHW || deducedChannelOrder == ChannelsOrder.TransposeToNHWC) && (deducedChannelOrder == layerChannelOrder[name])) { continue; } layerChannelOrder[name] = deducedChannelOrder; foreach (var input in layer.inputs) { if (deducedChannelOrder == ChannelsOrder.TransposeToNCHW) { layersToInferLayout.Enqueue((input, ChannelsOrder.NHWC, FlowDirection.Upstream)); } else if (deducedChannelOrder == ChannelsOrder.TransposeToNHWC) { layersToInferLayout.Enqueue((input, ChannelsOrder.NCHW, FlowDirection.Upstream)); } else { layersToInferLayout.Enqueue((input, deducedChannelOrder, FlowDirection.Upstream)); } } var outputs = ModelAnalyzer.FindLayerOutputs(model, layer.name); foreach (var output in outputs) { if (deducedChannelOrder == ChannelsOrder.TransposeToNCHW) { layersToInferLayout.Enqueue((output, ChannelsOrder.NCHW, FlowDirection.Downstream)); } else if (deducedChannelOrder == ChannelsOrder.TransposeToNHWC) { layersToInferLayout.Enqueue((output, ChannelsOrder.NHWC, FlowDirection.Downstream)); } else { layersToInferLayout.Enqueue((output, deducedChannelOrder, FlowDirection.Downstream)); } } } bool modelExportedASNHWC = false; foreach (string key in layerChannelOrder.Keys.ToList()) { var value = layerChannelOrder[key]; if (value == ChannelsOrder.NativeNCHW) { layerChannelOrder[key] = ChannelsOrder.NCHW; } if (value == ChannelsOrder.NHWC) { modelExportedASNHWC = true; } } return(modelExportedASNHWC); }
public FlowDirectionGalleryNP(FlowDirection direction) { FlowDirection = direction; Navigation.PushAsync(new FlowDirectionGalleryCP(direction)); Navigation.PushAsync(new FlowDirectionGalleryCP(direction)); }
public MangaObject ParseMangaObject(string content) { HtmlDocument MangaObjectDocument = new HtmlDocument(); MangaObjectDocument.LoadHtml(content); HtmlNode InformationNode = MangaObjectDocument.DocumentNode.SelectSingleNode("//div[contains(@class,'ipsBox')]/div"); String Cover = InformationNode.SelectSingleNode(".//div[1]/img").Attributes["src"].Value; HtmlNode MangaProperties = InformationNode.SelectSingleNode(".//table[contains(@class,'ipb_table')]"), ChapterListing = MangaObjectDocument.DocumentNode.SelectSingleNode("//table[contains(@class,'chapters_list')]"); String MangaName = HtmlEntity.DeEntitize(MangaObjectDocument.DocumentNode.SelectSingleNode("//h1[contains(@class,'ipsType_pagetitle')]").InnerText.Trim()), MangaTypeProp = HtmlEntity.DeEntitize(MangaProperties.SelectSingleNode(".//tr[5]/td[2]").InnerText), Desciption = HtmlEntity.DeEntitize(MangaProperties.SelectSingleNode(".//tr[7]/td[2]").InnerText.Replace("<br>", "\n")); MangaObjectType MangaType = MangaObjectType.Unknown; FlowDirection PageFlowDirection = FlowDirection.RightToLeft; switch (MangaTypeProp.ToLower()) { default: MangaType = MangaObjectType.Unknown; PageFlowDirection = FlowDirection.RightToLeft; break; case "manga (japanese)": MangaType = MangaObjectType.Manga; PageFlowDirection = FlowDirection.RightToLeft; break; case "manhwa (korean)": MangaType = MangaObjectType.Manhwa; PageFlowDirection = FlowDirection.LeftToRight; break; case "manhua (chinese)": MangaType = MangaObjectType.Manhua; PageFlowDirection = FlowDirection.LeftToRight; break; } HtmlNodeCollection AlternateNameNodes = MangaProperties.SelectSingleNode(".//tr[1]/td[2]").SelectNodes(".//span"), GenreNodes = MangaProperties.SelectSingleNode(".//tr[4]/td[2]").SelectNodes(".//a/span"); String[] AlternateNames = { }, Authors = { HtmlEntity.DeEntitize(MangaProperties.SelectSingleNode(".//tr[2]/td[2]/a").InnerText) }, Artists = { HtmlEntity.DeEntitize(MangaProperties.SelectSingleNode(".//tr[3]/td[2]/a").InnerText) }, Genres = { }; if (AlternateNameNodes != null && AlternateNameNodes.Count > 0) { AlternateNames = (from HtmlNode AltNameNode in AlternateNameNodes select HtmlEntity.DeEntitize(AltNameNode.InnerText.Trim())).ToArray(); } if (GenreNodes != null && GenreNodes.Count > 0) { Genres = (from HtmlNode GenreNode in GenreNodes select HtmlEntity.DeEntitize(GenreNode.InnerText.Trim())).ToArray(); } List <ChapterObject> Chapters = new List <ChapterObject>(); HtmlNodeCollection ChapterNodes = ChapterListing.SelectNodes(String.Format(".//tr[contains(@class,'lang_{0} chapter_row')]", ExtensionDescriptionAttribute.Language)); if (ChapterNodes != null && ChapterNodes.Count > 0) { foreach (HtmlNode ChapterNode in ChapterNodes) { HtmlNode VolChapNameNode = ChapterNode.SelectSingleNode("td[1]/a"); Match VolChapMatch = Regex.Match(VolChapNameNode.InnerText, @"(Vol\.(?<Volume>\d+)\s)?(Ch\.(?<Chapter>\d+))(\.(?<SubChapter>\d+))?"); String ChapterName = VolChapNameNode.InnerText.Substring(VolChapMatch.Length + 2).Trim(), ReleaseData = ReleaseData = ChapterNode.SelectSingleNode("td[5]").InnerText; ChapterObject PrevChapter = Chapters.LastOrDefault(); UInt32 Volume = 0, Chapter = 0, SubChapter = 0; if (VolChapMatch.Groups["Volume"].Success) { UInt32.TryParse(VolChapMatch.Groups["Volume"].Value, out Volume); } if (VolChapMatch.Groups["Chapter"].Success) { UInt32.TryParse(VolChapMatch.Groups["Chapter"].Value, out Chapter); } if (VolChapMatch.Groups["SubChapter"].Success) { UInt32.TryParse(VolChapMatch.Groups["SubChapter"].Value, out SubChapter); } DateTime Released = DateTime.MinValue; if (ReleaseData.Contains("-")) { ReleaseData = ReleaseData.Split(new String[] { " - " }, StringSplitOptions.RemoveEmptyEntries)[0]; } DateTime.TryParse(ReleaseData, out Released); String ChapterUrl = VolChapNameNode.Attributes["href"].Value; String ChapterHash = ChapterUrl.Split('#').Last().Split('_').First(); ChapterUrl = String.Format("https://bato.to/areader?id={0}&p=1&supress_webtoon=t", ChapterHash); ChapterObject chapterObject = new ChapterObject() { Name = HtmlEntity.DeEntitize(ChapterName), Volume = Volume, Chapter = Chapter, SubChapter = SubChapter, Released = Released, Locations = { new LocationObject() { ExtensionName = ExtensionDescriptionAttribute.Name, ExtensionLanguage = ExtensionDescriptionAttribute.Language, Url = ChapterUrl } } }; if (!Chapters.Any(o => o.Chapter == chapterObject.Chapter && ((Int32)o.SubChapter - chapterObject.SubChapter).InRange(-4, 4))) { Chapters.Add(chapterObject); } else { Chapters.Find(o => o.Chapter == chapterObject.Chapter && ((Int32)o.SubChapter - chapterObject.SubChapter).InRange(-4, 4)).Merge(chapterObject); } } } Chapters.Reverse(); Double Rating = -1; try { HtmlNode RatingNode = MangaObjectDocument.DocumentNode.SelectSingleNode("//div[contains(@class,'rating')]"); String RatingText = new String(RatingNode.InnerText.Trim().Substring(1, 4).Where(IsValidRatingChar).ToArray()); Double.TryParse(RatingText, out Rating); } catch { } return(new MangaObject() { Name = MangaName, MangaType = MangaType, PageFlowDirection = PageFlowDirection, Description = HtmlEntity.DeEntitize(Desciption), AlternateNames = AlternateNames.ToList(), CoverLocations = { new LocationObject() { Url = Cover, ExtensionName = ExtensionDescriptionAttribute.Name, ExtensionLanguage = ExtensionDescriptionAttribute.Language } }, Authors = Authors.ToList(), Artists = Artists.ToList(), Genres = Genres.ToList(), Released = (Chapters.FirstOrDefault() ?? new ChapterObject()).Released, Chapters = Chapters, Rating = Rating }); }
/// <summary> /// Create an instance of AnnotationDocumentPaginator for a given document and annotation store. /// </summary> /// <param name="originalPaginator">document to add annotations to</param> /// <param name="annotationStore">store to retrieve annotations from</param> /// <param name="flowDirection"></param> public AnnotationDocumentPaginator(DocumentPaginator originalPaginator, AnnotationStore annotationStore, FlowDirection flowDirection) { _isFixedContent = originalPaginator is FixedDocumentPaginator || originalPaginator is FixedDocumentSequencePaginator; if (!_isFixedContent && !(originalPaginator is FlowDocumentPaginator)) { throw new ArgumentException(SR.Get(SRID.OnlyFlowAndFixedSupported)); } _originalPaginator = originalPaginator; _annotationStore = annotationStore; _locatorManager = new LocatorManager(_annotationStore); _flowDirection = flowDirection; // Register for events _originalPaginator.GetPageCompleted += new GetPageCompletedEventHandler(HandleGetPageCompleted); _originalPaginator.ComputePageCountCompleted += new AsyncCompletedEventHandler(HandleComputePageCountCompleted); _originalPaginator.PagesChanged += new PagesChangedEventHandler(HandlePagesChanged); }
/// <summary> /// Gets the text line offset x. /// </summary> /// <param name="width">The line width.</param> /// <param name="widthIncludingTrailingWhitespace">The paragraph width including whitespace.</param> /// <param name="paragraphWidth">The paragraph width.</param> /// <param name="textAlignment">The text alignment.</param> /// <param name="flowDirection">The flow direction of the line.</param> /// <returns>The paragraph offset.</returns> internal static double GetParagraphOffsetX(double width, double widthIncludingTrailingWhitespace, double paragraphWidth, TextAlignment textAlignment, FlowDirection flowDirection) { if (double.IsPositiveInfinity(paragraphWidth)) { return(0); } if (flowDirection == FlowDirection.LeftToRight) { switch (textAlignment) { case TextAlignment.Center: return(Math.Max(0, (paragraphWidth - width) / 2)); case TextAlignment.Right: return(Math.Max(0, paragraphWidth - widthIncludingTrailingWhitespace)); default: return(0); } } switch (textAlignment) { case TextAlignment.Center: return(Math.Max(0, (paragraphWidth - width) / 2)); case TextAlignment.Right: return(0); default: return(Math.Max(0, paragraphWidth - widthIncludingTrailingWhitespace)); } }
/// <summary> /// Create an instance of AnnotationDocumentPaginator for a given document and annotation store. /// </summary> /// <param name="originalPaginator">document to add annotations to</param> /// <param name="annotationStore">store to retrieve annotations from</param> /// <param name="flowDirection"></param> public AnnotationDocumentPaginator(DocumentPaginator originalPaginator, Stream annotationStore, FlowDirection flowDirection) : this(originalPaginator, new XmlStreamStore(annotationStore), flowDirection) { }
/// <include file="../../docs/Microsoft.Maui.Controls/Page.xml" path="//Member[@MemberName='DisplayAlert'][1]/Docs" /> public Task DisplayAlert(string title, string message, string cancel, FlowDirection flowDirection) { return(DisplayAlert(title, message, null, cancel, flowDirection)); }
// Token: 0x06004136 RID: 16694 RVA: 0x0012A365 File Offset: 0x00128565 internal Rect GetBoundsFromTextPosition(int characterIndex, out FlowDirection flowDirection) { return(this.GetBoundsFromPosition(characterIndex, 1, out flowDirection)); }
public static Maui.FlowDirection ToPlatformFlowDirection(this FlowDirection flowDirection) { return(flowDirection.ToEffectiveFlowDirection().IsLeftToRight() ? Maui.FlowDirection.LeftToRight : Maui.FlowDirection.RightToLeft); }
public static IntPtr Box_FlowDirection(FlowDirection val) { IntPtr ret = NoesisGUI_PINVOKE.Box_FlowDirection((int)val); return(ret); }
private LanguageResources() { FlowDirection = FlowDirection.LeftToRight; }
public static FlowDirection Unbox_FlowDirection(IntPtr val) { FlowDirection ret = (FlowDirection)NoesisGUI_PINVOKE.Unbox_FlowDirection(val); return(ret); }
public static void SetFlowDirection(FlowDirection value) => FlowDirection = value;
public static double GetVisibleWidth(FrameworkElement element, FrameworkElement parent, FlowDirection flowDirection) { if (element == null) { throw new ArgumentNullException(nameof(element)); } if (parent == null) { throw new ArgumentNullException(nameof(parent)); } var location = element.TransformToAncestor(parent).Transform(new Point(0, 0)); if (flowDirection != parent.FlowDirection) { location.X -= element.ActualWidth; } int width = (int)Math.Floor(element.ActualWidth); var hitTest = parent.InputHitTest(new Point(location.X + width, location.Y)); if (IsAncestorTill(hitTest as FrameworkElement, element, parent)) { return(width); } //BinarySearch here int end = (int)Math.Floor(element.ActualWidth); int start = 0; while (start < end) { width = (end + start) / 2; hitTest = parent.InputHitTest(new Point(location.X + width, location.Y)); if (IsAncestorTill(hitTest as FrameworkElement, element, parent)) { //Speed tweak hitTest = parent.InputHitTest(new Point(location.X + width + 1, location.Y)); if (IsAncestorTill(hitTest as FrameworkElement, element, parent)) { start = width; } else { return(width); } } else { end = width; } } //for (int width = (int) Math.Floor(element.ActualWidth); width >= 0; width--) //{ // var hitTest = parent.InputHitTest(new Point(location.X + width, location.Y)); // // if (hitTest == null) continue; // // if (IsAncestorTill(hitTest as FrameworkElement, element, parent)) // { // return width; // } //} return(element.ActualWidth); }
/// <summary> /// Sets the selectors and title flow direction. /// </summary> /// <param name="flowDirection">Flow direction to set.</param> internal abstract void SetFlowDirection(FlowDirection flowDirection);
private ButtonViewStates getButtonView(string label, string normalImageName = null, string hoverImageName = null, string pressedImageName = null, string disabledImageName = null, bool centerText = false) { if (hoverImageName == null) { hoverImageName = normalImageName; } if (pressedImageName == null) { pressedImageName = hoverImageName; } if (disabledImageName == null) { disabledImageName = normalImageName; } ImageBuffer normalImage = new ImageBuffer(); ImageBuffer pressedImage = new ImageBuffer(); ImageBuffer hoverImage = new ImageBuffer(); ImageBuffer disabledImage = new ImageBuffer(); if (normalImageName != null) { ImageIO.LoadImageData(this.GetImageLocation(normalImageName), normalImage); if (!ActiveTheme.Instance.IsDarkTheme && AllowThemeToAdjustImage) { InvertLightness.DoInvertLightness(normalImage); } } if (hoverImageName != null) { ImageIO.LoadImageData(this.GetImageLocation(pressedImageName), pressedImage); if (!ActiveTheme.Instance.IsDarkTheme && AllowThemeToAdjustImage) { InvertLightness.DoInvertLightness(pressedImage); } } if (pressedImageName != null) { ImageIO.LoadImageData(this.GetImageLocation(hoverImageName), hoverImage); if (!ActiveTheme.Instance.IsDarkTheme && AllowThemeToAdjustImage) { InvertLightness.DoInvertLightness(hoverImage); } } if (disabledImageName != null) { ImageIO.LoadImageData(this.GetImageLocation(disabledImageName), disabledImage); if (!ActiveTheme.Instance.IsDarkTheme && AllowThemeToAdjustImage) { InvertLightness.DoInvertLightness(disabledImage); } } if (invertImageLocation) { flowDirection = FlowDirection.RightToLeft; } else { flowDirection = FlowDirection.LeftToRight; } //Create the multi-state button view ButtonViewStates buttonViewWidget = new ButtonViewStates( new TextImageWidget(label, normalFillColor, normalBorderColor, normalTextColor, borderWidth, Margin, normalImage, flowDirection: flowDirection, fontSize: this.fontSize, height: this.FixedHeight, centerText: centerText), new TextImageWidget(label, hoverFillColor, hoverBorderColor, hoverTextColor, borderWidth, Margin, hoverImage, flowDirection: flowDirection, fontSize: this.fontSize, height: this.FixedHeight, centerText: centerText), new TextImageWidget(label, pressedFillColor, pressedBorderColor, pressedTextColor, borderWidth, Margin, pressedImage, flowDirection: flowDirection, fontSize: this.fontSize, height: this.FixedHeight, centerText: centerText), new TextImageWidget(label, disabledFillColor, disabledBorderColor, disabledTextColor, borderWidth, Margin, disabledImage, flowDirection: flowDirection, fontSize: this.fontSize, height: this.FixedHeight, centerText: centerText) ); return(buttonViewWidget); }