internal YogaSize Measure(YogaNode node, float width, YogaMeasureMode widthMode, float height, YogaMeasureMode heightMode) { Debug.Assert(node == yogaNode, "YogaNode instance mismatch"); Vector2 size = DoMeasure(width, (MeasureMode)widthMode, height, (MeasureMode)heightMode); return(MeasureOutput.Make(Mathf.RoundToInt(size.x), Mathf.RoundToInt(size.y))); }
private static YogaSize MeasureTextInput(ReactTextInputShadowNode textInputNode, YogaNode node, float width, YogaMeasureMode widthMode, float height, YogaMeasureMode heightMode) { textInputNode._computedPadding = textInputNode.GetComputedPadding(); var normalizedWidth = Math.Max(0, (YogaConstants.IsUndefined(width) ? double.PositiveInfinity : width)); var normalizedHeight = Math.Max(0, (YogaConstants.IsUndefined(height) ? double.PositiveInfinity : height)); var normalizedText = string.IsNullOrEmpty(textInputNode._text) ? " " : textInputNode._text; var textBlock = new TextBlock { Text = normalizedText, TextWrapping = textInputNode._multiline ? TextWrapping.Wrap : TextWrapping.NoWrap, }; ApplyStyles(textInputNode, textBlock); textBlock.Measure(new Size(normalizedWidth, normalizedHeight)); return(MeasureOutput.Make( (float)Math.Ceiling(width), (float)Math.Ceiling(textBlock.ActualHeight))); }
internal long Measure(CSSNode node, float width, CSSMeasureMode widthMode, float height, CSSMeasureMode heightMode) { Debug.Assert(node == this.cssNode, "CSSNode instance mismatch"); Vector2 vector = this.DoMeasure(width, (VisualElement.MeasureMode)widthMode, height, (VisualElement.MeasureMode)heightMode); return(MeasureOutput.Make(Mathf.RoundToInt(vector.x), Mathf.RoundToInt(vector.y))); }
private static YogaSize MeasureText(ReactTextShadowNode textNode, YogaNode node, float width, YogaMeasureMode widthMode, float height, YogaMeasureMode heightMode) { // TODO: Measure text with DirectWrite or other API that does not // require dispatcher access. Currently, we're instantiating a // second CoreApplicationView (that is never activated) and using // its Dispatcher thread to calculate layout. var textBlock = new TextBlock { TextAlignment = TextAlignment.Left, TextWrapping = TextWrapping.Wrap, TextTrimming = TextTrimming.CharacterEllipsis, }; textNode.UpdateTextBlockCore(textBlock, true); for (var i = 0; i < textNode.ChildCount; ++i) { var child = textNode.GetChildAt(i); textBlock.Inlines.Add(ReactInlineShadowNodeVisitor.Apply(child)); } var normalizedWidth = YogaConstants.IsUndefined(width) ? double.PositiveInfinity : width; var normalizedHeight = YogaConstants.IsUndefined(height) ? double.PositiveInfinity : height; textBlock.Measure(new Size(normalizedWidth, normalizedHeight)); return(MeasureOutput.Make( (float)Math.Ceiling(textBlock.DesiredSize.Width), (float)Math.Ceiling(textBlock.DesiredSize.Height))); }
internal long Measure(CSSNode node, float width, CSSMeasureMode widthMode, float height, CSSMeasureMode heightMode) { Debug.Assert(node == cssNode, "CSSNode instance mismatch"); Vector2 size = DoMeasure(width, (MeasureMode)widthMode, height, (MeasureMode)heightMode); return(MeasureOutput.Make(Mathf.RoundToInt(size.x), Mathf.RoundToInt(size.y))); }
private static YogaSize MeasurePasswordBox(ReactPasswordBoxShadowNode textInputNode, YogaNode node, float width, YogaMeasureMode widthMode, float height, YogaMeasureMode heightMode) { var normalizedWidth = Math.Max(0, (YogaConstants.IsUndefined(width) ? double.PositiveInfinity : width)); var normalizedHeight = Math.Max(0, (YogaConstants.IsUndefined(height) ? double.PositiveInfinity : height)); var passwordChar = GetDefaultPasswordChar(); var normalizedText = !string.IsNullOrEmpty(textInputNode._text) ? new string(passwordChar[0], textInputNode._text.Length) : passwordChar; var textBlock = new TextBlock { Text = normalizedText, }; ApplyStyles(textInputNode, textBlock); textBlock.Measure(new Size(normalizedWidth, normalizedHeight)); return(MeasureOutput.Make( (float)Math.Ceiling(width), (float)Math.Ceiling(textBlock.ActualHeight))); }
/// <summary> /// Measures the width and height of a <see cref="ProgressRing"/>. /// </summary> /// <param name="node">The css style of the rendered <see cref="ProgressRing"/>.</param> /// <param name="width">The parameterized native width of the control.</param> /// <param name="widthMode">The width measurement mode.</param> /// <param name="height">The parameterized native height of the control.</param> /// <param name="heightMode">The height measurement mode.</param> /// <returns>The measurement <see cref="MeasureOutput"/> for the <see cref="ProgressRing"/> component.</returns> private static YogaSize MeasureProgressRing(YogaNode node, float width, YogaMeasureMode widthMode, float height, YogaMeasureMode heightMode) { var normalizedWidth = !YogaConstants.IsUndefined(width) ? width : 20f; var normalizedHeight = !YogaConstants.IsUndefined(height) ? height : 20f; return(MeasureOutput.Make(normalizedWidth, normalizedHeight)); }
private static YogaSize MeasureCanvas(YogaNode node, float width, YogaMeasureMode widthMode, float height, YogaMeasureMode heightMode) { var adjustedHeight = YogaConstants.IsUndefined(height) ? 4f : height; var adjustedWidth = YogaConstants.IsUndefined(width) ? 4f : width; return(MeasureOutput.Make(adjustedWidth, adjustedHeight)); }
private static YogaSize MeasureSwitch(YogaNode node, float width, YogaMeasureMode widthMode, float height, YogaMeasureMode heightMode) { // TODO: figure out how to properly measure the switch. // We are currently blocked until we switch to a UWP-specific React // JavaScript library as the iOS library we currently use specifies // an exact width and height for switch nodes. return(MeasureOutput.Make(56f, 40f)); }
private static YogaSize MeasureTextInput(ReactTextInputShadowNode textInputNode, YogaNode node, float width, YogaMeasureMode widthMode, float height, YogaMeasureMode heightMode) { textInputNode._computedPadding = textInputNode.GetComputedPadding(); var borderLeftWidth = textInputNode.GetBorder(YogaEdge.Left); var borderRightWidth = textInputNode.GetBorder(YogaEdge.Right); var normalizedWidth = Math.Max(0, (YogaConstants.IsUndefined(width) ? double.PositiveInfinity : width) - textInputNode._computedPadding[0] - textInputNode._computedPadding[2] - (YogaConstants.IsUndefined(borderLeftWidth) ? 0 : borderLeftWidth) - (YogaConstants.IsUndefined(borderRightWidth) ? 0 : borderRightWidth)); var normalizedHeight = Math.Max(0, YogaConstants.IsUndefined(height) ? double.PositiveInfinity : height); // This is not a terribly efficient way of projecting the height of // the text elements. It requires that we have access to the // dispatcher in order to do measurement, which, for obvious // reasons, can cause perceived performance issues as it will block // the UI thread from handling other work. // // TODO: determine another way to measure text elements. var task = DispatcherHelpers.CallOnDispatcher(() => { /* * var textBlock = new TextBlock * { * TextWrapping = TextWrapping.Wrap, * }; * * var normalizedText = string.IsNullOrEmpty(textNode._text) ? " " : textNode._text; * var inline = new Run { Text = normalizedText }; * FormatInline(textNode, inline); * * textBlock.Inlines.Add(inline); * * textBlock.Measure(new Size(normalizedWidth, normalizedHeight)); * * var borderTopWidth = textInputNode.GetBorder(CSSSpacingType.Top); * var borderBottomWidth = textInputNode.GetBorder(CSSSpacingType.Bottom); * * var finalizedHeight = (float)textBlock.DesiredSize.Height; * finalizedHeight += textInputNode._computedPadding[1]; * finalizedHeight += textInputNode._computedPadding[3]; * finalizedHeight += CSSConstants.IsUndefined(borderTopWidth) ? 0 : borderTopWidth; * finalizedHeight += CSSConstants.IsUndefined(borderBottomWidth) ? 0 : borderBottomWidth; * * return new MeasureOutput(width, finalizedHeight); */ float finalizedHeight = 1; return(MeasureOutput.Make( (float)Math.Ceiling(width), (float)Math.Ceiling(finalizedHeight))); }); return(task.Result); }
private void TestMeasureFuncWithDestructorForGC(CSSNode parent) { CSSNode child = new CSSNode(); parent.Insert(0, child); child.SetMeasureFunction((_, width, widthMode, height, heightMode) => { return(MeasureOutput.Make(120, 130)); }); }
//ADDED /// <summary> /// Handles the Click event of the bt_Save control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.Windows.RoutedEventArgs"/> instance containing the event data.</param> private void bt_Save_Click(object sender, RoutedEventArgs e) { try { System.Windows.Forms.SaveFileDialog _ofd = new System.Windows.Forms.SaveFileDialog() { Filter = "Tabla|*.csv" }; if (_ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK) { string _path = _ofd.FileName; FileStream _fs = new FileStream(_path, FileMode.Create, FileAccess.Write); StreamWriter _sw = new StreamWriter(_fs); try { //Columns for (int i = 0; i < ((GridView)lv_MeasuresOutput.View).Columns.Count; i++) { _sw.Write(((GridView)lv_MeasuresOutput.View).Columns[i].Header.ToString().Replace(',', '-') + ", "); } _sw.Write("Time, ElementsCount, Bell Number"); _sw.WriteLine(); List <PartitionInfo> _pinfo = this.uctrl_ListClusterAlgVisualizerClustEnsemble.GetSelected(); //Fill for (int i = 0; i < lv_MeasuresOutput.Items.Count; i++) { MeasureOutput _mo = (MeasureOutput)lv_MeasuresOutput.Items[i]; string _line = ""; _line += _mo.AlgorithmName.Replace(',', ';') + ", "; for (int j = 0; j < _mo.Values.Length; j++) { _line += _mo.Values[j].ToString() + ", "; } _line += i == lv_MeasuresOutput.Items.Count - 1 ? " , ," : _pinfo[i].Time + ", " + _pinfo[i].ElementCount + ", " + _pinfo[i].SearchSpace; _sw.WriteLine(_line); } } catch (Exception) { throw; } finally { _sw.Close(); _fs.Close(); } } } catch (Exception) { throw; } }
public void TestMeasureFuncWithChild() { CSSNode node = new CSSNode(); CSSNode child = new CSSNode(); node.Insert(0, child); node.SetMeasureFunction((_, width, widthMode, height, heightMode) => { return(MeasureOutput.Make(100, 150)); }); }
public void TestMeasureFuncWithFloat() { CSSNode node = new CSSNode(); node.SetMeasureFunction((_, width, widthMode, height, heightMode) => { return(MeasureOutput.Make(123.4f, 81.7f)); }); node.CalculateLayout(); Assert.AreEqual(123, node.LayoutWidth); Assert.AreEqual(81, node.LayoutHeight); }
public void TestMeasureFunc() { CSSNode node = new CSSNode(); node.SetMeasureFunction((_, width, widthMode, height, heightMode) => { return(MeasureOutput.Make(100, 150)); }); node.CalculateLayout(); Assert.AreEqual(100, node.LayoutWidth); Assert.AreEqual(150, node.LayoutHeight); }
private static YogaSize MeasureTextInput(ReactPasswordBoxShadowNode textInputNode, YogaNode node, float width, YogaMeasureMode widthMode, float height, YogaMeasureMode heightMode) { textInputNode._computedPadding = textInputNode.GetComputedPadding(); var borderLeftWidth = textInputNode.GetBorder(YogaEdge.Left); var borderRightWidth = textInputNode.GetBorder(YogaEdge.Right); var normalizedWidth = Math.Max(0, (YogaConstants.IsUndefined(width) ? double.PositiveInfinity : width) - textInputNode._computedPadding[0] - textInputNode._computedPadding[2] - (YogaConstants.IsUndefined(borderLeftWidth) ? 0 : borderLeftWidth) - (YogaConstants.IsUndefined(borderRightWidth) ? 0 : borderRightWidth)); var normalizedHeight = Math.Max(0, YogaConstants.IsUndefined(height) ? double.PositiveInfinity : height); // TODO: Measure text with DirectWrite or other API that does not // require dispatcher access. Currently, we're instantiating a // second CoreApplicationView (that is never activated) and using // its Dispatcher thread to calculate layout. var textBlock = new TextBlock { TextWrapping = TextWrapping.Wrap, }; var passwordChar = GetDefaultPasswordChar(); var normalizedText = !string.IsNullOrEmpty(textInputNode._text) ? new string(passwordChar[0], textInputNode._text.Length) : passwordChar; var inline = new Run { Text = normalizedText }; FormatTextElement(textInputNode, inline); textBlock.Inlines.Add(inline); textBlock.Measure(new Size(normalizedWidth, normalizedHeight)); var borderTopWidth = textInputNode.GetBorder(YogaEdge.Top); var borderBottomWidth = textInputNode.GetBorder(YogaEdge.Bottom); var finalizedHeight = (float)textBlock.DesiredSize.Height; finalizedHeight += textInputNode._computedPadding[1]; finalizedHeight += textInputNode._computedPadding[3]; finalizedHeight += YogaConstants.IsUndefined(borderTopWidth) ? 0 : borderTopWidth; finalizedHeight += YogaConstants.IsUndefined(borderBottomWidth) ? 0 : borderBottomWidth; return(MeasureOutput.Make( (float)Math.Ceiling(width), (float)Math.Ceiling(finalizedHeight))); }
private static YogaSize MeasureTextInput(ReactTextInputShadowNode textInputNode, YogaNode node, float width, YogaMeasureMode widthMode, float height, YogaMeasureMode heightMode) { textInputNode._computedPadding = textInputNode.GetComputedPadding(); var borderLeftWidth = textInputNode.GetBorder(YogaEdge.Left); var borderRightWidth = textInputNode.GetBorder(YogaEdge.Right); var normalizedWidth = Math.Max(0, (YogaConstants.IsUndefined(width) ? double.PositiveInfinity : width) - textInputNode._computedPadding[0] - textInputNode._computedPadding[2] - (YogaConstants.IsUndefined(borderLeftWidth) ? 0 : borderLeftWidth) - (YogaConstants.IsUndefined(borderRightWidth) ? 0 : borderRightWidth)); var normalizedHeight = Math.Max(0, YogaConstants.IsUndefined(height) ? double.PositiveInfinity : height); var textBlock = new TextBlock { TextWrapping = TextWrapping.Wrap, }; var normalizedText = string.IsNullOrEmpty(textInputNode._text) ? " " : textInputNode._text; var inline = new Run { Text = normalizedText }; FormatInline(textInputNode, inline); textBlock.Inlines.Add(inline); textBlock.Measure(new Size(normalizedWidth, normalizedHeight)); var borderTopWidth = textInputNode.GetBorder(YogaEdge.Top); var borderBottomWidth = textInputNode.GetBorder(YogaEdge.Bottom); var finalizedHeight = (float)textBlock.DesiredSize.Height; finalizedHeight += textInputNode._computedPadding[1]; finalizedHeight += textInputNode._computedPadding[3]; finalizedHeight += YogaConstants.IsUndefined(borderTopWidth) ? 0 : borderTopWidth; finalizedHeight += YogaConstants.IsUndefined(borderBottomWidth) ? 0 : borderBottomWidth; return(MeasureOutput.Make( (float)Math.Ceiling(width), (float)Math.Ceiling(finalizedHeight))); }
private static YogaSize MeasureText(ReactTextShadowNode textNode, YogaNode node, float width, YogaMeasureMode widthMode, float height, YogaMeasureMode heightMode) { Log.Info(ReactConstants.Tag, "MeasureText node=" + textNode.ReactTag); // This is not a terribly efficient way of projecting the height of // the text elements. It requires that we have access to the // dispatcher in order to do measurement, which, for obvious // reasons, can cause perceived performance issues as it will block // the UI thread from handling other work. // // TODO: determine another way to measure text elements. var task = DispatcherHelpers.CallOnDispatcher(() => { if (textView == null) { textView = new ReactTextView(ReactProgram.RctWindow); textView.LineWrapType = WrapType.Mixed; } var normalizedWidth = YogaConstants.IsUndefined(width) ? ReactProgram.RctWindow.ScreenSize.Width : width; var normalizedHeight = YogaConstants.IsUndefined(height) ? ReactProgram.RctWindow.ScreenSize.Height : height; textView.Resize((int)normalizedWidth, (int)normalizedHeight); textView.Text = textNode._preparedSpannableText; var textPartObject = textView.EdjeObject["elm.text"]; if (textPartObject == null) { throw new Exception("Invalid ReactTextView.EdjeObject[\"elm.text\"]"); } Size size = textPartObject.TextBlockFormattedSize; Log.Info(ReactConstants.Tag, "MeasureText result : width: " + size.Width + " height:" + size.Height); //textView.Unrealize(); return(MeasureOutput.Make( (float)size.Width, (float)size.Height)); }); return(task.Result); }
public void TestMeasureFuncWithChild() { YogaNode node = new YogaNode(); YogaNode child = new YogaNode(); node.Insert(0, child); try { node.SetMeasureFunction((_, width, widthMode, height, heightMode) => { return(MeasureOutput.Make(100, 150)); }); } catch (System.InvalidOperationException) { return; } Assert.Fail("Excepted exception of type 'System.InvalidOperationException'."); }
public bool RunSanityCheck(out string result) { bool success = false; string error = string.Empty; result = "Success"; try { var node = new YogaNode(); node.SetMeasureFunction((_, width, widthMode, height, heightMode) => MeasureOutput.Make(100f, 150f)); node.CalculateLayout(); if (Math.Abs(100f - node.LayoutWidth) > 0.01) { throw new Exception("Unexpected Width"); } if (Math.Abs(150f - node.LayoutHeight) > 0.01) { throw new Exception("Unexpected Height"); } success = true; } catch (Exception ex) { error = ex.Message + Environment.NewLine + ex.StackTrace; } if (success) { result = string.Format("SUCCESS -----------> {0}", GetExecutingAssemblyName()); } else { result = string.Format("FAILED -----------> {0}{1}{2}", GetExecutingAssemblyName(), Environment.NewLine + Environment.NewLine, error); } return(success); }
static YogaSize MeasureView(YogaNode node, float width, YogaMeasureMode widthMode, float height, YogaMeasureMode heightMode) { var constrainedWidth = (widthMode == YogaMeasureMode.Undefined) ? float.MaxValue : width; var constrainedHeight = (heightMode == YogaMeasureMode.Undefined) ? float.MaxValue : height; NativeView view = null; if (YogaKit.Bridges.ContainsKey(node)) { view = YogaKit.Bridges[node] as NativeView; } float sizeThatFitsWidth = 0; float sizeThatFitsHeight = 0; MeasureNativeView(view, constrainedWidth, constrainedHeight, out sizeThatFitsWidth, out sizeThatFitsHeight); var finalWidth = SanitizeMeasurement(constrainedWidth, sizeThatFitsWidth, widthMode); var finalHeight = SanitizeMeasurement(constrainedHeight, sizeThatFitsHeight, heightMode); return(MeasureOutput.Make(finalWidth, finalHeight)); }
private static YogaSize MeasureText(ReactTextShadowNode textNode, YogaNode node, float width, YogaMeasureMode widthMode, float height, YogaMeasureMode heightMode) { // This is not a terribly efficient way of projecting the height of // the text elements. It requires that we have access to the // dispatcher in order to do measurement, which, for obvious // reasons, can cause perceived performance issues as it will block // the UI thread from handling other work. // // TODO: determine another way to measure text elements. var task = DispatcherHelpers.CallOnDispatcher(() => { var textBlock = new RichTextBlock { TextWrapping = TextWrapping.Wrap, TextAlignment = TextAlignment.DetectFromContent, TextTrimming = TextTrimming.CharacterEllipsis, }; textNode.UpdateTextBlockCore(textBlock, true); var block = new Paragraph(); for (var i = 0; i < textNode.ChildCount; ++i) { var child = textNode.GetChildAt(i); block.Inlines.Add(ReactInlineShadowNodeVisitor.Apply(child)); } textBlock.Blocks.Add(block); var normalizedWidth = YogaConstants.IsUndefined(width) ? double.PositiveInfinity : width; var normalizedHeight = YogaConstants.IsUndefined(height) ? double.PositiveInfinity : height; textBlock.Measure(new Size(normalizedWidth, normalizedHeight)); return(MeasureOutput.Make( (float)Math.Ceiling(textBlock.DesiredSize.Width), (float)Math.Ceiling(textBlock.DesiredSize.Height))); }); return(task.Result); }
private YogaSize MeasureButton(ReactButtonShadowNode textNode, YogaNode node, float width, YogaMeasureMode widthMode, float height, YogaMeasureMode heightMode) { Log.Info(ReactConstants.Tag, "[1] MeasureButton node=" + textNode.ReactTag + " with=" + width + " height=" + height + " content=" + _preparedSpannableText); // This is not a terribly efficient way of projecting the height of // the text elements. It requires that we have access to the // dispatcher in order to do measurement, which, for obvious // reasons, can cause perceived performance issues as it will block // the UI thread from handling other work. // // TODO: determine another way to measure text elements. var task = DispatcherHelpers.CallOnDispatcher(() => { var btnView = new Button(ReactProgram.RctWindow); var normalizedWidth = YogaConstants.IsUndefined(width) ? double.PositiveInfinity : width; var normalizedHeight = YogaConstants.IsUndefined(height) ? double.PositiveInfinity : height; btnView.Resize((int)normalizedWidth, (int)normalizedHeight); btnView.Text = _preparedSpannableText; var btnPartObject = btnView.EdjeObject["elm.text"]; if (btnPartObject == null) { throw new Exception("Invalid Button.EdjeObject[\"elm.text\"]"); } Size size = btnPartObject.TextBlockFormattedSize; Log.Info(ReactConstants.Tag, "[2] EDC conf info ={ width: " + size.Width + " height:" + size.Height + "}"); btnView.Unrealize(); return(MeasureOutput.Make( (float)(size.Width + 80), (float)(size.Height < 80 ? 80 : size.Height))); }); return(task.Result); }
private void Update_ListViewMeasuresOutput(List <MeasureOutput> aMeasuresOutput) { try { ((GridView)lv_MeasuresOutput.View).Columns.Clear(); if (aMeasuresOutput.Count > 0) { MeasureOutput _measureOutput = aMeasuresOutput[0]; //Esta es la columna que muestra cual es el algoritmo que se le aplico a la particion en cuestion AddColumn("Algorithm", "AlgorithmName"); for (int i = 0; i < _measureOutput.Measures.Count; i++) { AddColumn(_measureOutput.Measures[i].MeasureName, "Values[" + i + "]"); } this.lv_MeasuresOutput.ItemsSource = aMeasuresOutput; } } catch (Exception _ex) { GeneralTools.Tools.WriteToLog(_ex); } }
public MeasureOutput Measure(MeasureOutput measureOutput, float width) { if (!IsMeasureDefined ()) { throw new NullReferenceException ("Missing IMeasureFunction"); } measureOutput.Height = CSSConstants.UNDEFINED; measureOutput.Width = CSSConstants.UNDEFINED; measureFunction.Measure (this, width, measureOutput); return measureOutput; }
private static YogaSize MeasureProgressBar(YogaNode node, float width, YogaMeasureMode widthMode, float height, YogaMeasureMode heightMode) { var adjustedHeight = YogaConstants.IsUndefined(height) ? 4f : height; return(MeasureOutput.Make(width, adjustedHeight)); }
private static YogaSize MeasurePicker(YogaNode node, float width, YogaMeasureMode widthMode, float height, YogaMeasureMode heightMode) { return(MeasureOutput.Make(width, 40f)); }