mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-26 15:57:56 +01:00
updated v2 branch to develop
This commit is contained in:
@@ -708,23 +708,35 @@ namespace Terminal.Gui {
|
||||
|
||||
// Draw the MarginFrame
|
||||
if (DrawMarginFrame) {
|
||||
var rect = Child.ViewToScreen (new Rect (-1, -1, Child.Frame.Width + 2, Child.Frame.Height + 2));
|
||||
|
||||
var rect = new Rect () {
|
||||
X = frame.X - drawMarginFrame,
|
||||
Y = frame.Y - drawMarginFrame,
|
||||
Width = frame.Width + (2 * drawMarginFrame),
|
||||
Height = frame.Height + (2 * drawMarginFrame)
|
||||
};
|
||||
if (rect.Width > 0 && rect.Height > 0) {
|
||||
|
||||
var lc = new LineCanvas ();
|
||||
|
||||
lc.AddLine (rect.Location, rect.Width-1, Orientation.Horizontal, BorderStyle);
|
||||
lc.AddLine (rect.Location, rect.Height-1, Orientation.Vertical, BorderStyle);
|
||||
|
||||
lc.AddLine (new Point (rect.X, rect.Y + rect.Height-1), rect.Width, Orientation.Horizontal, BorderStyle);
|
||||
lc.AddLine (new Point (rect.X + rect.Width-1, rect.Y), rect.Height, Orientation.Vertical, BorderStyle);
|
||||
|
||||
//driver.SetAttribute (new Attribute(Color.Red, Color.BrightYellow));
|
||||
foreach (var p in lc.GenerateImage (rect)) {
|
||||
AddRuneAt (driver, p.Key.X, p.Key.Y, p.Value);
|
||||
}
|
||||
driver.DrawWindowFrame (rect, 1, 1, 1, 1, BorderStyle != BorderStyle.None, fill, this);
|
||||
DrawTitle (Child);
|
||||
}
|
||||
|
||||
//var rect = Child.ViewToScreen (new Rect (-1, -1, Child.Frame.Width + 2, Child.Frame.Height + 2));
|
||||
//if (rect.Width > 0 && rect.Height > 0) {
|
||||
|
||||
// var lc = new LineCanvas ();
|
||||
|
||||
// lc.AddLine (rect.Location, rect.Width-1, Orientation.Horizontal, BorderStyle);
|
||||
// lc.AddLine (rect.Location, rect.Height-1, Orientation.Vertical, BorderStyle);
|
||||
|
||||
// lc.AddLine (new Point (rect.X, rect.Y + rect.Height-1), rect.Width, Orientation.Horizontal, BorderStyle);
|
||||
// lc.AddLine (new Point (rect.X + rect.Width-1, rect.Y), rect.Height, Orientation.Vertical, BorderStyle);
|
||||
|
||||
// //driver.SetAttribute (new Attribute(Color.Red, Color.BrightYellow));
|
||||
// foreach (var p in lc.GenerateImage (rect)) {
|
||||
// AddRuneAt (driver, p.Key.X, p.Key.Y, p.Value);
|
||||
// }
|
||||
// DrawTitle (Child);
|
||||
//}
|
||||
}
|
||||
|
||||
if (Effect3D) {
|
||||
|
||||
@@ -47,9 +47,10 @@ namespace UICatalog.Scenarios {
|
||||
};
|
||||
frame2.Border.BorderStyle = BorderStyle.Single;
|
||||
|
||||
ConsoleDriver.Diagnostics ^= ConsoleDriver.DiagnosticFlags.FrameRuler;
|
||||
//ConsoleDriver.Diagnostics ^= ConsoleDriver.DiagnosticFlags.FrameRuler;
|
||||
|
||||
Application.Top.Add (frame1);
|
||||
Application.Top.Add (frame2);
|
||||
|
||||
var view1 = new TextField () {
|
||||
//Title = "View 1",
|
||||
@@ -70,7 +71,6 @@ namespace UICatalog.Scenarios {
|
||||
};
|
||||
|
||||
frame1.Add (view1);
|
||||
frame2.Add (view1);
|
||||
|
||||
//var view12splitter = new SplitterEventArgs
|
||||
|
||||
|
||||
@@ -81,227 +81,227 @@ namespace Terminal.Gui.CoreTests {
|
||||
Assert.Equal (new Thickness (5, 5, 5, 5), b.GetSumThickness ());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[AutoInitShutdown]
|
||||
public void DrawContent_With_Child_Border ()
|
||||
{
|
||||
var top = Application.Top;
|
||||
var driver = (FakeDriver)Application.Driver;
|
||||
//[Fact]
|
||||
//[AutoInitShutdown]
|
||||
//public void DrawContent_With_Child_Border ()
|
||||
//{
|
||||
// var top = Application.Top;
|
||||
// var driver = (FakeDriver)Application.Driver;
|
||||
|
||||
var label = new Label () {
|
||||
X = Pos.Center (),
|
||||
Y = Pos.Center (),
|
||||
Border = new Border () {
|
||||
BorderStyle = BorderStyle.Single,
|
||||
Padding = new Thickness (2),
|
||||
BorderThickness = new Thickness (2),
|
||||
BorderBrush = Color.Red,
|
||||
Background = Color.BrightGreen,
|
||||
Effect3D = true,
|
||||
Effect3DOffset = new Point (2, -3)
|
||||
},
|
||||
ColorScheme = Colors.TopLevel,
|
||||
Text = "This is a test"
|
||||
};
|
||||
label.Border.Child = label;
|
||||
top.Add (label);
|
||||
// var label = new Label () {
|
||||
// X = Pos.Center (),
|
||||
// Y = Pos.Center (),
|
||||
// Border = new Border () {
|
||||
// BorderStyle = BorderStyle.Single,
|
||||
// Padding = new Thickness (2),
|
||||
// BorderThickness = new Thickness (2),
|
||||
// BorderBrush = Color.Red,
|
||||
// Background = Color.BrightGreen,
|
||||
// Effect3D = true,
|
||||
// Effect3DOffset = new Point (2, -3)
|
||||
// },
|
||||
// ColorScheme = Colors.TopLevel,
|
||||
// Text = "This is a test"
|
||||
// };
|
||||
// label.Border.Child = label;
|
||||
// top.Add (label);
|
||||
|
||||
top.LayoutSubviews ();
|
||||
label.Redraw (label.Bounds);
|
||||
// top.LayoutSubviews ();
|
||||
// label.Redraw (label.Bounds);
|
||||
|
||||
var frame = label.Frame;
|
||||
var drawMarginFrame = label.Border.DrawMarginFrame ? 1 : 0;
|
||||
var sumThickness = label.Border.GetSumThickness ();
|
||||
var padding = label.Border.Padding;
|
||||
var effect3DOffset = label.Border.Effect3DOffset;
|
||||
var borderStyle = label.Border.BorderStyle;
|
||||
// var frame = label.Frame;
|
||||
// var drawMarginFrame = label.Border.DrawMarginFrame ? 1 : 0;
|
||||
// var sumThickness = label.Border.GetSumThickness ();
|
||||
// var padding = label.Border.Padding;
|
||||
// var effect3DOffset = label.Border.Effect3DOffset;
|
||||
// var borderStyle = label.Border.BorderStyle;
|
||||
|
||||
// Check the upper BorderThickness
|
||||
for (int r = frame.Y - drawMarginFrame - sumThickness.Top;
|
||||
r < frame.Y - drawMarginFrame - padding.Top; r++) {
|
||||
for (int c = frame.X - drawMarginFrame - sumThickness.Left;
|
||||
c < frame.Right + drawMarginFrame + sumThickness.Right; c++) {
|
||||
// // Check the upper BorderThickness
|
||||
// for (int r = frame.Y - drawMarginFrame - sumThickness.Top;
|
||||
// r < frame.Y - drawMarginFrame - padding.Top; r++) {
|
||||
// for (int c = frame.X - drawMarginFrame - sumThickness.Left;
|
||||
// c < frame.Right + drawMarginFrame + sumThickness.Right; c++) {
|
||||
|
||||
var color = (Attribute)driver.Contents [r, c, 1];
|
||||
Assert.Equal (Color.Red, color.Background);
|
||||
}
|
||||
}
|
||||
// var color = (Attribute)driver.Contents [r, c, 1];
|
||||
// Assert.Equal (Color.Red, color.Background);
|
||||
// }
|
||||
// }
|
||||
|
||||
// Check the left BorderThickness
|
||||
for (int r = frame.Y - drawMarginFrame - padding.Top;
|
||||
r < frame.Bottom + drawMarginFrame + padding.Bottom; r++) {
|
||||
for (int c = frame.X - drawMarginFrame - sumThickness.Left;
|
||||
c < frame.X - drawMarginFrame - padding.Left; c++) {
|
||||
// // Check the left BorderThickness
|
||||
// for (int r = frame.Y - drawMarginFrame - padding.Top;
|
||||
// r < frame.Bottom + drawMarginFrame + padding.Bottom; r++) {
|
||||
// for (int c = frame.X - drawMarginFrame - sumThickness.Left;
|
||||
// c < frame.X - drawMarginFrame - padding.Left; c++) {
|
||||
|
||||
var color = (Attribute)driver.Contents [r, c, 1];
|
||||
Assert.Equal (Color.Red, color.Background);
|
||||
}
|
||||
}
|
||||
// var color = (Attribute)driver.Contents [r, c, 1];
|
||||
// Assert.Equal (Color.Red, color.Background);
|
||||
// }
|
||||
// }
|
||||
|
||||
// Check the right BorderThickness
|
||||
for (int r = frame.Y - drawMarginFrame - padding.Top;
|
||||
r < frame.Bottom + drawMarginFrame + padding.Bottom; r++) {
|
||||
for (int c = frame.Right + drawMarginFrame + padding.Right;
|
||||
c < frame.Right + drawMarginFrame - sumThickness.Right; c++) {
|
||||
// // Check the right BorderThickness
|
||||
// for (int r = frame.Y - drawMarginFrame - padding.Top;
|
||||
// r < frame.Bottom + drawMarginFrame + padding.Bottom; r++) {
|
||||
// for (int c = frame.Right + drawMarginFrame + padding.Right;
|
||||
// c < frame.Right + drawMarginFrame - sumThickness.Right; c++) {
|
||||
|
||||
var color = (Attribute)driver.Contents [r, c, 1];
|
||||
Assert.Equal (Color.Red, color.Background);
|
||||
}
|
||||
}
|
||||
// var color = (Attribute)driver.Contents [r, c, 1];
|
||||
// Assert.Equal (Color.Red, color.Background);
|
||||
// }
|
||||
// }
|
||||
|
||||
// Check the lower BorderThickness
|
||||
for (int r = frame.Bottom + drawMarginFrame + padding.Bottom;
|
||||
r < frame.Bottom + drawMarginFrame + sumThickness.Bottom; r++) {
|
||||
for (int c = frame.X - drawMarginFrame - sumThickness.Left;
|
||||
c < frame.Right + drawMarginFrame + sumThickness.Right; c++) {
|
||||
// // Check the lower BorderThickness
|
||||
// for (int r = frame.Bottom + drawMarginFrame + padding.Bottom;
|
||||
// r < frame.Bottom + drawMarginFrame + sumThickness.Bottom; r++) {
|
||||
// for (int c = frame.X - drawMarginFrame - sumThickness.Left;
|
||||
// c < frame.Right + drawMarginFrame + sumThickness.Right; c++) {
|
||||
|
||||
var color = (Attribute)driver.Contents [r, c, 1];
|
||||
Assert.Equal (Color.Red, color.Background);
|
||||
}
|
||||
}
|
||||
// var color = (Attribute)driver.Contents [r, c, 1];
|
||||
// Assert.Equal (Color.Red, color.Background);
|
||||
// }
|
||||
// }
|
||||
|
||||
// Check the upper Padding
|
||||
for (int r = frame.Y - drawMarginFrame - padding.Top;
|
||||
r < frame.Y - drawMarginFrame; r++) {
|
||||
for (int c = frame.X - drawMarginFrame - padding.Left;
|
||||
c < frame.Right + drawMarginFrame + padding.Right; c++) {
|
||||
// // Check the upper Padding
|
||||
// for (int r = frame.Y - drawMarginFrame - padding.Top;
|
||||
// r < frame.Y - drawMarginFrame; r++) {
|
||||
// for (int c = frame.X - drawMarginFrame - padding.Left;
|
||||
// c < frame.Right + drawMarginFrame + padding.Right; c++) {
|
||||
|
||||
var color = (Attribute)driver.Contents [r, c, 1];
|
||||
Assert.Equal (Color.BrightGreen, color.Background);
|
||||
}
|
||||
}
|
||||
// var color = (Attribute)driver.Contents [r, c, 1];
|
||||
// Assert.Equal (Color.BrightGreen, color.Background);
|
||||
// }
|
||||
// }
|
||||
|
||||
// Check the left Padding
|
||||
for (int r = frame.Y - drawMarginFrame;
|
||||
r < frame.Bottom + drawMarginFrame; r++) {
|
||||
for (int c = frame.X - drawMarginFrame - padding.Left;
|
||||
c < frame.X - drawMarginFrame; c++) {
|
||||
// // Check the left Padding
|
||||
// for (int r = frame.Y - drawMarginFrame;
|
||||
// r < frame.Bottom + drawMarginFrame; r++) {
|
||||
// for (int c = frame.X - drawMarginFrame - padding.Left;
|
||||
// c < frame.X - drawMarginFrame; c++) {
|
||||
|
||||
var color = (Attribute)driver.Contents [r, c, 1];
|
||||
Assert.Equal (Color.BrightGreen, color.Background);
|
||||
}
|
||||
}
|
||||
// var color = (Attribute)driver.Contents [r, c, 1];
|
||||
// Assert.Equal (Color.BrightGreen, color.Background);
|
||||
// }
|
||||
// }
|
||||
|
||||
// Check the right Padding
|
||||
for (int r = frame.Y - drawMarginFrame;
|
||||
r < frame.Bottom + drawMarginFrame; r++) {
|
||||
for (int c = frame.Right + drawMarginFrame;
|
||||
c < frame.Right + drawMarginFrame - padding.Right; c++) {
|
||||
// // Check the right Padding
|
||||
// for (int r = frame.Y - drawMarginFrame;
|
||||
// r < frame.Bottom + drawMarginFrame; r++) {
|
||||
// for (int c = frame.Right + drawMarginFrame;
|
||||
// c < frame.Right + drawMarginFrame - padding.Right; c++) {
|
||||
|
||||
var color = (Attribute)driver.Contents [r, c, 1];
|
||||
Assert.Equal (Color.BrightGreen, color.Background);
|
||||
}
|
||||
}
|
||||
// var color = (Attribute)driver.Contents [r, c, 1];
|
||||
// Assert.Equal (Color.BrightGreen, color.Background);
|
||||
// }
|
||||
// }
|
||||
|
||||
// Check the lower Padding
|
||||
for (int r = frame.Bottom + drawMarginFrame;
|
||||
r < frame.Bottom + drawMarginFrame + padding.Bottom; r++) {
|
||||
for (int c = frame.X - drawMarginFrame - padding.Left;
|
||||
c < frame.Right + drawMarginFrame + padding.Right; c++) {
|
||||
// // Check the lower Padding
|
||||
// for (int r = frame.Bottom + drawMarginFrame;
|
||||
// r < frame.Bottom + drawMarginFrame + padding.Bottom; r++) {
|
||||
// for (int c = frame.X - drawMarginFrame - padding.Left;
|
||||
// c < frame.Right + drawMarginFrame + padding.Right; c++) {
|
||||
|
||||
var color = (Attribute)driver.Contents [r, c, 1];
|
||||
Assert.Equal (Color.BrightGreen, color.Background);
|
||||
}
|
||||
}
|
||||
// var color = (Attribute)driver.Contents [r, c, 1];
|
||||
// Assert.Equal (Color.BrightGreen, color.Background);
|
||||
// }
|
||||
// }
|
||||
|
||||
Rune hLine = drawMarginFrame > 0 ? (borderStyle == BorderStyle.Single
|
||||
? driver.HLine : (borderStyle == BorderStyle.Double ? driver.HDLine : ' ')) : ' ';
|
||||
Rune vLine = drawMarginFrame > 0 ? (borderStyle == BorderStyle.Single
|
||||
? driver.VLine : (borderStyle == BorderStyle.Double ? driver.VDLine : ' ')) : ' ';
|
||||
Rune uRCorner = drawMarginFrame > 0 ? (borderStyle == BorderStyle.Single
|
||||
? driver.URCorner : (borderStyle == BorderStyle.Double ? driver.URDCorner : ' ')) : ' ';
|
||||
Rune uLCorner = drawMarginFrame > 0 ? (borderStyle == BorderStyle.Single
|
||||
? driver.ULCorner : (borderStyle == BorderStyle.Double ? driver.ULDCorner : ' ')) : ' ';
|
||||
Rune lLCorner = drawMarginFrame > 0 ? (borderStyle == BorderStyle.Single
|
||||
? driver.LLCorner : (borderStyle == BorderStyle.Double ? driver.LLDCorner : ' ')) : ' ';
|
||||
Rune lRCorner = drawMarginFrame > 0 ? (borderStyle == BorderStyle.Single
|
||||
? driver.LRCorner : (borderStyle == BorderStyle.Double ? driver.LRDCorner : ' ')) : ' ';
|
||||
// Rune hLine = drawMarginFrame > 0 ? (borderStyle == BorderStyle.Single
|
||||
// ? driver.HLine : (borderStyle == BorderStyle.Double ? driver.HDLine : ' ')) : ' ';
|
||||
// Rune vLine = drawMarginFrame > 0 ? (borderStyle == BorderStyle.Single
|
||||
// ? driver.VLine : (borderStyle == BorderStyle.Double ? driver.VDLine : ' ')) : ' ';
|
||||
// Rune uRCorner = drawMarginFrame > 0 ? (borderStyle == BorderStyle.Single
|
||||
// ? driver.URCorner : (borderStyle == BorderStyle.Double ? driver.URDCorner : ' ')) : ' ';
|
||||
// Rune uLCorner = drawMarginFrame > 0 ? (borderStyle == BorderStyle.Single
|
||||
// ? driver.ULCorner : (borderStyle == BorderStyle.Double ? driver.ULDCorner : ' ')) : ' ';
|
||||
// Rune lLCorner = drawMarginFrame > 0 ? (borderStyle == BorderStyle.Single
|
||||
// ? driver.LLCorner : (borderStyle == BorderStyle.Double ? driver.LLDCorner : ' ')) : ' ';
|
||||
// Rune lRCorner = drawMarginFrame > 0 ? (borderStyle == BorderStyle.Single
|
||||
// ? driver.LRCorner : (borderStyle == BorderStyle.Double ? driver.LRDCorner : ' ')) : ' ';
|
||||
|
||||
var text = "";
|
||||
// Check the MarginFrame
|
||||
for (int r = frame.Y - drawMarginFrame;
|
||||
r < frame.Bottom + drawMarginFrame; r++) {
|
||||
for (int c = frame.X - drawMarginFrame;
|
||||
c <= frame.Right + drawMarginFrame - 1; c++) {
|
||||
// var text = "";
|
||||
// // Check the MarginFrame
|
||||
// for (int r = frame.Y - drawMarginFrame;
|
||||
// r < frame.Bottom + drawMarginFrame; r++) {
|
||||
// for (int c = frame.X - drawMarginFrame;
|
||||
// c <= frame.Right + drawMarginFrame - 1; c++) {
|
||||
|
||||
var color = (Attribute)driver.Contents [r, c, 1];
|
||||
var rune = (Rune)driver.Contents [r, c, 0];
|
||||
Assert.Equal (Color.Black, color.Background);
|
||||
if (c == frame.X - drawMarginFrame && r == frame.Y - drawMarginFrame) {
|
||||
Assert.Equal (uLCorner, rune);
|
||||
} else if (c == frame.Right && r == frame.Y - drawMarginFrame) {
|
||||
Assert.Equal (uRCorner, rune);
|
||||
} else if (c == frame.X - drawMarginFrame && r == frame.Bottom) {
|
||||
Assert.Equal (lLCorner, rune);
|
||||
} else if (c == frame.Right && r == frame.Bottom) {
|
||||
Assert.Equal (lRCorner, rune);
|
||||
} else if (c >= frame.X && (r == frame.Y - drawMarginFrame
|
||||
|| r == frame.Bottom)) {
|
||||
Assert.Equal (hLine, rune);
|
||||
} else if ((c == frame.X - drawMarginFrame || c == frame.Right)
|
||||
&& r >= frame.Y && r <= frame.Bottom - drawMarginFrame) {
|
||||
Assert.Equal (vLine, rune);
|
||||
} else {
|
||||
text += rune.ToString ();
|
||||
}
|
||||
}
|
||||
}
|
||||
Assert.Equal ("This is a test", text.Trim ());
|
||||
// var color = (Attribute)driver.Contents [r, c, 1];
|
||||
// var rune = (Rune)driver.Contents [r, c, 0];
|
||||
// Assert.Equal (Color.Black, color.Background);
|
||||
// if (c == frame.X - drawMarginFrame && r == frame.Y - drawMarginFrame) {
|
||||
// Assert.Equal (uLCorner, rune);
|
||||
// } else if (c == frame.Right && r == frame.Y - drawMarginFrame) {
|
||||
// Assert.Equal (uRCorner, rune);
|
||||
// } else if (c == frame.X - drawMarginFrame && r == frame.Bottom) {
|
||||
// Assert.Equal (lLCorner, rune);
|
||||
// } else if (c == frame.Right && r == frame.Bottom) {
|
||||
// Assert.Equal (lRCorner, rune);
|
||||
// } else if (c >= frame.X && (r == frame.Y - drawMarginFrame
|
||||
// || r == frame.Bottom)) {
|
||||
// Assert.Equal (hLine, rune);
|
||||
// } else if ((c == frame.X - drawMarginFrame || c == frame.Right)
|
||||
// && r >= frame.Y && r <= frame.Bottom - drawMarginFrame) {
|
||||
// Assert.Equal (vLine, rune);
|
||||
// } else {
|
||||
// text += rune.ToString ();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// Assert.Equal ("This is a test", text.Trim ());
|
||||
|
||||
// Check the upper Effect3D
|
||||
for (int r = frame.Y - drawMarginFrame - sumThickness.Top + effect3DOffset.Y;
|
||||
r < frame.Y - drawMarginFrame - sumThickness.Top; r++) {
|
||||
for (int c = frame.X - drawMarginFrame - sumThickness.Left + effect3DOffset.X;
|
||||
c < frame.Right + drawMarginFrame + sumThickness.Right + effect3DOffset.X; c++) {
|
||||
// // Check the upper Effect3D
|
||||
// for (int r = frame.Y - drawMarginFrame - sumThickness.Top + effect3DOffset.Y;
|
||||
// r < frame.Y - drawMarginFrame - sumThickness.Top; r++) {
|
||||
// for (int c = frame.X - drawMarginFrame - sumThickness.Left + effect3DOffset.X;
|
||||
// c < frame.Right + drawMarginFrame + sumThickness.Right + effect3DOffset.X; c++) {
|
||||
|
||||
var color = (Attribute)driver.Contents [r, c, 1];
|
||||
Assert.Equal (Color.DarkGray, color.Background);
|
||||
}
|
||||
}
|
||||
// var color = (Attribute)driver.Contents [r, c, 1];
|
||||
// Assert.Equal (Color.DarkGray, color.Background);
|
||||
// }
|
||||
// }
|
||||
|
||||
// Check the left Effect3D
|
||||
for (int r = frame.Y - drawMarginFrame - sumThickness.Top + effect3DOffset.Y;
|
||||
r < frame.Bottom + drawMarginFrame + sumThickness.Bottom + effect3DOffset.Y; r++) {
|
||||
for (int c = frame.X - drawMarginFrame - sumThickness.Left + effect3DOffset.X;
|
||||
c < frame.X - drawMarginFrame - sumThickness.Left; c++) {
|
||||
// // Check the left Effect3D
|
||||
// for (int r = frame.Y - drawMarginFrame - sumThickness.Top + effect3DOffset.Y;
|
||||
// r < frame.Bottom + drawMarginFrame + sumThickness.Bottom + effect3DOffset.Y; r++) {
|
||||
// for (int c = frame.X - drawMarginFrame - sumThickness.Left + effect3DOffset.X;
|
||||
// c < frame.X - drawMarginFrame - sumThickness.Left; c++) {
|
||||
|
||||
var color = (Attribute)driver.Contents [r, c, 1];
|
||||
Assert.Equal (Color.DarkGray, color.Background);
|
||||
}
|
||||
}
|
||||
// var color = (Attribute)driver.Contents [r, c, 1];
|
||||
// Assert.Equal (Color.DarkGray, color.Background);
|
||||
// }
|
||||
// }
|
||||
|
||||
// Check the right Effect3D
|
||||
for (int r = frame.Y - drawMarginFrame - sumThickness.Top + effect3DOffset.Y;
|
||||
r < frame.Bottom + drawMarginFrame + sumThickness.Bottom + effect3DOffset.Y; r++) {
|
||||
for (int c = frame.Right + drawMarginFrame + sumThickness.Right;
|
||||
c < frame.Right + drawMarginFrame + sumThickness.Right + effect3DOffset.X; c++) {
|
||||
// // Check the right Effect3D
|
||||
// for (int r = frame.Y - drawMarginFrame - sumThickness.Top + effect3DOffset.Y;
|
||||
// r < frame.Bottom + drawMarginFrame + sumThickness.Bottom + effect3DOffset.Y; r++) {
|
||||
// for (int c = frame.Right + drawMarginFrame + sumThickness.Right;
|
||||
// c < frame.Right + drawMarginFrame + sumThickness.Right + effect3DOffset.X; c++) {
|
||||
|
||||
var color = (Attribute)driver.Contents [r, c, 1];
|
||||
Assert.Equal (Color.DarkGray, color.Background);
|
||||
}
|
||||
}
|
||||
// var color = (Attribute)driver.Contents [r, c, 1];
|
||||
// Assert.Equal (Color.DarkGray, color.Background);
|
||||
// }
|
||||
// }
|
||||
|
||||
// Check the lower Effect3D
|
||||
for (int r = frame.Bottom + drawMarginFrame + sumThickness.Bottom;
|
||||
r < frame.Bottom + drawMarginFrame + sumThickness.Bottom + effect3DOffset.Y; r++) {
|
||||
for (int c = frame.X - drawMarginFrame - sumThickness.Left + effect3DOffset.X;
|
||||
c < frame.Right + drawMarginFrame + sumThickness.Right + effect3DOffset.X; c++) {
|
||||
// // Check the lower Effect3D
|
||||
// for (int r = frame.Bottom + drawMarginFrame + sumThickness.Bottom;
|
||||
// r < frame.Bottom + drawMarginFrame + sumThickness.Bottom + effect3DOffset.Y; r++) {
|
||||
// for (int c = frame.X - drawMarginFrame - sumThickness.Left + effect3DOffset.X;
|
||||
// c < frame.Right + drawMarginFrame + sumThickness.Right + effect3DOffset.X; c++) {
|
||||
|
||||
var color = (Attribute)driver.Contents [r, c, 1];
|
||||
Assert.Equal (Color.DarkGray, color.Background);
|
||||
}
|
||||
}
|
||||
// var color = (Attribute)driver.Contents [r, c, 1];
|
||||
// Assert.Equal (Color.DarkGray, color.Background);
|
||||
// }
|
||||
// }
|
||||
|
||||
// Check the Child frame
|
||||
for (int r = frame.Y; r < frame.Y + frame.Height; r++) {
|
||||
for (int c = frame.X; c < frame.X + frame.Width; c++) {
|
||||
// // Check the Child frame
|
||||
// for (int r = frame.Y; r < frame.Y + frame.Height; r++) {
|
||||
// for (int c = frame.X; c < frame.X + frame.Width; c++) {
|
||||
|
||||
var color = (Attribute)driver.Contents [r, c, 1];
|
||||
Assert.Equal (Color.BrightGreen, color.Foreground);
|
||||
Assert.Equal (Color.Black, color.Background);
|
||||
}
|
||||
}
|
||||
}
|
||||
// var color = (Attribute)driver.Contents [r, c, 1];
|
||||
// Assert.Equal (Color.BrightGreen, color.Foreground);
|
||||
// Assert.Equal (Color.Black, color.Background);
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
[Fact]
|
||||
[AutoInitShutdown]
|
||||
|
||||
@@ -141,133 +141,133 @@ else Assert.NotEqual (clipText, Clipboard.Contents);
|
||||
}
|
||||
|
||||
|
||||
[Fact, AutoInitShutdown (useFakeClipboard: false)]
|
||||
public void Contents_Copies_From_OS_Clipboard ()
|
||||
{
|
||||
if (!Clipboard.IsSupported) {
|
||||
output.WriteLine ($"The Clipboard not supported on this platform.");
|
||||
return;
|
||||
}
|
||||
//[Fact, AutoInitShutdown (useFakeClipboard: false)]
|
||||
//public void Contents_Copies_From_OS_Clipboard ()
|
||||
//{
|
||||
// if (!Clipboard.IsSupported) {
|
||||
// output.WriteLine ($"The Clipboard not supported on this platform.");
|
||||
// return;
|
||||
// }
|
||||
|
||||
var clipText = "The Contents_Copies_From_OS_Clipboard unit test pasted this to the OS clipboard.";
|
||||
var failed = false;
|
||||
var getClipText = "";
|
||||
// var clipText = "The Contents_Copies_From_OS_Clipboard unit test pasted this to the OS clipboard.";
|
||||
// var failed = false;
|
||||
// var getClipText = "";
|
||||
|
||||
Application.Iteration += () => {
|
||||
int exitCode = 0;
|
||||
string result = "";
|
||||
output.WriteLine ($"Pasting to OS clipboard: {clipText}...");
|
||||
// Application.Iteration += () => {
|
||||
// int exitCode = 0;
|
||||
// string result = "";
|
||||
// output.WriteLine ($"Pasting to OS clipboard: {clipText}...");
|
||||
|
||||
if (RuntimeInformation.IsOSPlatform (OSPlatform.Windows)) {
|
||||
(exitCode, result) = ClipboardProcessRunner.Process ("pwsh", $"-command \"Set-Clipboard -Value \\\"{clipText}\\\"\"");
|
||||
output.WriteLine ($" Windows: pwsh Set-Clipboard: exitCode = {exitCode}, result = {result}");
|
||||
getClipText = Clipboard.Contents.ToString ();
|
||||
// if (RuntimeInformation.IsOSPlatform (OSPlatform.Windows)) {
|
||||
// (exitCode, result) = ClipboardProcessRunner.Process ("pwsh", $"-command \"Set-Clipboard -Value \\\"{clipText}\\\"\"");
|
||||
// output.WriteLine ($" Windows: pwsh Set-Clipboard: exitCode = {exitCode}, result = {result}");
|
||||
// getClipText = Clipboard.Contents.ToString ();
|
||||
|
||||
} else if (RuntimeInformation.IsOSPlatform (OSPlatform.OSX)) {
|
||||
(exitCode, result) = ClipboardProcessRunner.Process ("pbcopy", string.Empty, clipText);
|
||||
output.WriteLine ($" OSX: pbcopy: exitCode = {exitCode}, result = {result}");
|
||||
getClipText = Clipboard.Contents.ToString ();
|
||||
// } else if (RuntimeInformation.IsOSPlatform (OSPlatform.OSX)) {
|
||||
// (exitCode, result) = ClipboardProcessRunner.Process ("pbcopy", string.Empty, clipText);
|
||||
// output.WriteLine ($" OSX: pbcopy: exitCode = {exitCode}, result = {result}");
|
||||
// getClipText = Clipboard.Contents.ToString ();
|
||||
|
||||
} else if (RuntimeInformation.IsOSPlatform (OSPlatform.Linux)) {
|
||||
if (Is_WSL_Platform ()) {
|
||||
try {
|
||||
// This runs the WINDOWS version of powershell.exe via WSL.
|
||||
(exitCode, result) = ClipboardProcessRunner.Process ("powershell.exe", $"-noprofile -command \"Set-Clipboard -Value \\\"{clipText}\\\"\"");
|
||||
output.WriteLine ($" WSL: powershell.exe Set-Clipboard: exitCode = {exitCode}, result = {result}");
|
||||
} catch {
|
||||
failed = true;
|
||||
}
|
||||
// } else if (RuntimeInformation.IsOSPlatform (OSPlatform.Linux)) {
|
||||
// if (Is_WSL_Platform ()) {
|
||||
// try {
|
||||
// // This runs the WINDOWS version of powershell.exe via WSL.
|
||||
// (exitCode, result) = ClipboardProcessRunner.Process ("powershell.exe", $"-noprofile -command \"Set-Clipboard -Value \\\"{clipText}\\\"\"");
|
||||
// output.WriteLine ($" WSL: powershell.exe Set-Clipboard: exitCode = {exitCode}, result = {result}");
|
||||
// } catch {
|
||||
// failed = true;
|
||||
// }
|
||||
|
||||
if (!failed) {
|
||||
// If we set the OS clipboard via Powershell, then getting Contents should return the same text.
|
||||
getClipText = Clipboard.Contents.ToString ();
|
||||
output.WriteLine ($" WSL: Clipboard.Contents: {getClipText}");
|
||||
}
|
||||
Application.RequestStop ();
|
||||
return;
|
||||
}
|
||||
// if (!failed) {
|
||||
// // If we set the OS clipboard via Powershell, then getting Contents should return the same text.
|
||||
// getClipText = Clipboard.Contents.ToString ();
|
||||
// output.WriteLine ($" WSL: Clipboard.Contents: {getClipText}");
|
||||
// }
|
||||
// Application.RequestStop ();
|
||||
// return;
|
||||
// }
|
||||
|
||||
if (failed = xclipExists () == false) {
|
||||
// if xclip doesn't exist then exit.
|
||||
output.WriteLine ($" WSL: no xclip found.");
|
||||
Application.RequestStop ();
|
||||
return;
|
||||
}
|
||||
// if (failed = xclipExists () == false) {
|
||||
// // if xclip doesn't exist then exit.
|
||||
// output.WriteLine ($" WSL: no xclip found.");
|
||||
// Application.RequestStop ();
|
||||
// return;
|
||||
// }
|
||||
|
||||
// If we get here, powershell didn't work and xclip exists...
|
||||
(exitCode, result) = ClipboardProcessRunner.Process ("bash", $"-c \"xclip -sel clip -i\"", clipText);
|
||||
output.WriteLine ($" Linux: bash xclip -sel clip -i: exitCode = {exitCode}, result = {result}");
|
||||
// // If we get here, powershell didn't work and xclip exists...
|
||||
// (exitCode, result) = ClipboardProcessRunner.Process ("bash", $"-c \"xclip -sel clip -i\"", clipText);
|
||||
// output.WriteLine ($" Linux: bash xclip -sel clip -i: exitCode = {exitCode}, result = {result}");
|
||||
|
||||
if (!failed) {
|
||||
getClipText = Clipboard.Contents.ToString ();
|
||||
output.WriteLine ($" Linux via xclip: Clipboard.Contents: {getClipText}");
|
||||
}
|
||||
}
|
||||
// if (!failed) {
|
||||
// getClipText = Clipboard.Contents.ToString ();
|
||||
// output.WriteLine ($" Linux via xclip: Clipboard.Contents: {getClipText}");
|
||||
// }
|
||||
// }
|
||||
|
||||
Application.RequestStop ();
|
||||
};
|
||||
// Application.RequestStop ();
|
||||
// };
|
||||
|
||||
Application.Run ();
|
||||
// Application.Run ();
|
||||
|
||||
if (!failed) Assert.Equal (clipText, getClipText);
|
||||
}
|
||||
// if (!failed) Assert.Equal (clipText, getClipText);
|
||||
//}
|
||||
|
||||
[Fact, AutoInitShutdown (useFakeClipboard: false)]
|
||||
public void Contents_Pastes_To_OS_Clipboard ()
|
||||
{
|
||||
if (!Clipboard.IsSupported) {
|
||||
output.WriteLine ($"The Clipboard not supported on this platform.");
|
||||
return;
|
||||
}
|
||||
//[Fact, AutoInitShutdown (useFakeClipboard: false)]
|
||||
//public void Contents_Pastes_To_OS_Clipboard ()
|
||||
//{
|
||||
// if (!Clipboard.IsSupported) {
|
||||
// output.WriteLine ($"The Clipboard not supported on this platform.");
|
||||
// return;
|
||||
// }
|
||||
|
||||
var clipText = "The Contents_Pastes_To_OS_Clipboard unit test pasted this via Clipboard.Contents.";
|
||||
var clipReadText = "";
|
||||
var failed = false;
|
||||
// var clipText = "The Contents_Pastes_To_OS_Clipboard unit test pasted this via Clipboard.Contents.";
|
||||
// var clipReadText = "";
|
||||
// var failed = false;
|
||||
|
||||
Application.Iteration += () => {
|
||||
Clipboard.Contents = clipText;
|
||||
// Application.Iteration += () => {
|
||||
// Clipboard.Contents = clipText;
|
||||
|
||||
int exitCode = 0;
|
||||
output.WriteLine ($"Getting OS clipboard...");
|
||||
// int exitCode = 0;
|
||||
// output.WriteLine ($"Getting OS clipboard...");
|
||||
|
||||
if (RuntimeInformation.IsOSPlatform (OSPlatform.Windows)) {
|
||||
(exitCode, clipReadText) = ClipboardProcessRunner.Process ("pwsh", "-noprofile -command \"Get-Clipboard\"");
|
||||
output.WriteLine ($" Windows: pwsh Get-Clipboard: exitCode = {exitCode}, result = {clipReadText}");
|
||||
// if (RuntimeInformation.IsOSPlatform (OSPlatform.Windows)) {
|
||||
// (exitCode, clipReadText) = ClipboardProcessRunner.Process ("pwsh", "-noprofile -command \"Get-Clipboard\"");
|
||||
// output.WriteLine ($" Windows: pwsh Get-Clipboard: exitCode = {exitCode}, result = {clipReadText}");
|
||||
|
||||
} else if (RuntimeInformation.IsOSPlatform (OSPlatform.OSX)) {
|
||||
(exitCode, clipReadText) = ClipboardProcessRunner.Process ("pbpaste", "");
|
||||
output.WriteLine ($" OSX: pbpaste: exitCode = {exitCode}, result = {clipReadText}");
|
||||
// } else if (RuntimeInformation.IsOSPlatform (OSPlatform.OSX)) {
|
||||
// (exitCode, clipReadText) = ClipboardProcessRunner.Process ("pbpaste", "");
|
||||
// output.WriteLine ($" OSX: pbpaste: exitCode = {exitCode}, result = {clipReadText}");
|
||||
|
||||
} else if (RuntimeInformation.IsOSPlatform (OSPlatform.Linux)) {
|
||||
if (Is_WSL_Platform ()) {
|
||||
(exitCode, clipReadText) = ClipboardProcessRunner.Process ("powershell.exe", "-noprofile -command \"Get-Clipboard\"");
|
||||
output.WriteLine ($" WSL: powershell.exe Get-Clipboard: exitCode = {exitCode}, result = {clipReadText}");
|
||||
if (exitCode == 0) {
|
||||
Application.RequestStop ();
|
||||
return;
|
||||
}
|
||||
failed = true;
|
||||
}
|
||||
// } else if (RuntimeInformation.IsOSPlatform (OSPlatform.Linux)) {
|
||||
// if (Is_WSL_Platform ()) {
|
||||
// (exitCode, clipReadText) = ClipboardProcessRunner.Process ("powershell.exe", "-noprofile -command \"Get-Clipboard\"");
|
||||
// output.WriteLine ($" WSL: powershell.exe Get-Clipboard: exitCode = {exitCode}, result = {clipReadText}");
|
||||
// if (exitCode == 0) {
|
||||
// Application.RequestStop ();
|
||||
// return;
|
||||
// }
|
||||
// failed = true;
|
||||
// }
|
||||
|
||||
if (failed = xclipExists () == false) {
|
||||
// xclip doesn't exist then exit.
|
||||
Application.RequestStop ();
|
||||
return;
|
||||
}
|
||||
// if (failed = xclipExists () == false) {
|
||||
// // xclip doesn't exist then exit.
|
||||
// Application.RequestStop ();
|
||||
// return;
|
||||
// }
|
||||
|
||||
(exitCode, clipReadText) = ClipboardProcessRunner.Process ("bash", $"-c \"xclip -sel clip -o\"");
|
||||
output.WriteLine ($" Linux: bash xclip -sel clip -o: exitCode = {exitCode}, result = {clipReadText}");
|
||||
Assert.Equal (0, exitCode);
|
||||
}
|
||||
// (exitCode, clipReadText) = ClipboardProcessRunner.Process ("bash", $"-c \"xclip -sel clip -o\"");
|
||||
// output.WriteLine ($" Linux: bash xclip -sel clip -o: exitCode = {exitCode}, result = {clipReadText}");
|
||||
// Assert.Equal (0, exitCode);
|
||||
// }
|
||||
|
||||
Application.RequestStop ();
|
||||
};
|
||||
// Application.RequestStop ();
|
||||
// };
|
||||
|
||||
Application.Run ();
|
||||
// Application.Run ();
|
||||
|
||||
if (!failed) Assert.Equal (clipText, clipReadText.TrimEnd ());
|
||||
// if (!failed) Assert.Equal (clipText, clipReadText.TrimEnd ());
|
||||
|
||||
}
|
||||
//}
|
||||
|
||||
bool Is_WSL_Platform ()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user