Screenshot is overlapping when using Noksa.WebDriver.ScreenshotsExtensions - c#

I'm trying to take a screenshot of a web element that is larger than the screen. I'm using Noksa to do this but part of the content is being overlapped upon when the bottom portion of the screen is being merged with the top. Everything else looks fine except for the 3 or 4 lines that are being cutoff from the bottom part of the page before scrolling. Has anyone else experienced this before?
ScreenshotMaker scrnShot = new ScreenshotMaker();
var by = By.XPath("//*[#id='gw-center-bottom-section']");
var onlyEleDecorator = new OnlyElementDecorator(scrnShot);
onlyEleDecorator.SetElement(by);
ImageBytes = driver.TakeScreenshot(new VerticalCombineDecorator (onlyEleDecorator));
File.WriteAllBytes(filePath + "myFile.bmp", ImageBytes);

Related

Setting y-axis range using Interactive data display WPF

I'm stuck on a problem where i need to set y-axis based on its plot. Right now program stretches the plot to fit whole chart however i need it to let some free space above the plot. I wasn't able to come up with anything so far. Code looks like this:
Chart chart = new Chart()
{
LegendVisibility = Visibility.Hidden,
LeftTitle = YaxisName[i],
BottomTitle = "Carrier i [-]",
};
chart.Content = getChart(graphIndex, GraphYvalues, GraphXvalues, GraphListOfNames[graphIndex]);
chartView.Children.Add(chart);
Could someone please help me out? Thank you
Eventually I was able to scramble something up. It's actually so damn easy. I gave up on setting the range of y-axis and instead of that I added padding to the plot itself like this:
LineGraph lineGraphFar = new LineGraph()
{
Stroke = new SolidColorBrush(Colors.Red),
Padding = new System.Windows.Thickness(0, 30, 0, 0)
};
It's surely not the greatest option but it will do the job.

iOS Loading overlay does not cover the whole screen

I'm trying to display an overlay during an auto login HTTP call.
I've found this code, which seems outdated somehow, but found nothing more recent.
Anyway, the Overlay is showing but not covering the whole screen as expected.
The calling code is this:
AppDelegate.FinishedLaunching
var avc = new AutoLoginViewController();
var navController = new UINavigationController(avc);
AutoLoginViewController.ViewDidLoad
var bounds = UIScreen.MainScreen.Bounds;
// show the loading overlay on the UI thread using the correct orientation sizing
loadPop = new LoadingOverlay(bounds, NSBundle.MainBundle.GetLocalizedString("connecting"));
View.Add(loadPop);
But the result is the following:
If I set a breakpoint in the LoadingOverlay constructor, I can see that the screen bounds (iPhone 6) are fine:
{{X=0,Y=0,Width=375,Height=667}}
public class LoadingOverlay : UIView
{
public LoadingOverlay(CGRect frame, string text) : base(frame)
{
// configurable bits
BackgroundColor = UIColor.Black;
Alpha = 0.75f;
AutoresizingMask = UIViewAutoresizing.FlexibleDimensions;
...
}
}
Clearly the UIView width is incorrect.
Because we're in 2020, maybe there is another way.
Any help appreciated.
EDIT: The app breaks on iPhone 8 iOS 13.3 simulator, So I can't say if this is tied to a particular screen size (1x in my case).
Cause :
It seems that you didn't set the LaunchImage , So whether on a simulator or real device , the value of bounds is a static value .
Solution:
The easiest way is set the size of overlay as bounds of View .
var bounds = View.Bounds;
Or you could set all size of LaunchImage of different screen .

imagesharp trying to make an animated gif that count from 0 to 9

anyone could tell me why this generate a black only animated gif?
the code also output each in memory generated gif to show that they are different
public static void Test()
{
Image<Rgba32> img = null;
Image<Rgba32> gif = null;
TextGraphicsOptions textGraphicsOptions = new TextGraphicsOptions(true);
SolidBrush<Rgba32> brushYellow = new SolidBrush<Rgba32>(Rgba32.Yellow);
FontCollection fonts = new FontCollection();
fonts.Install(fontLocation);
Font font = fonts.CreateFont("Liberation Mono", PngFontHeight, FontStyle.Regular);
gif = new Image<Rgba32>(400, 400);
for (int i = 0; i < 10;++i)
{
img = new Image<Rgba32>(400, 400);
img.Mutate(x => x.Fill(Rgba32.Black));
img.Mutate(x => x.DrawText(textGraphicsOptions, i.ToString(), font, brushYellow, new PointF(1,1)));
gif.Frames.AddFrame(img.Frames[0]);
using (FileStream fs = File.Create(Path.Join(Program.workingDirectory, string.Format("Test-{0}.gif", i))))
{
img.SaveAsGif(fs);
}
img.Dispose();
}
using (FileStream fs = File.Create(Path.Join(Program.workingDirectory, "Test.gif")))
{
gif.SaveAsGif(fs);
}
}
if I code it to load each individual physical file using this code it make the animated gif as expected.
I want to create the animated gif in memory only.
When you create an Image<>...
gif = new Image<Rgba32>(400, 400);
...gif.Frames[0] is a "transparent black" frame (each pixel's RGBA value is #00000000). The additional frames you create in your for loop and add with...
gif.Frames.AddFrame(img.Frames[0]);
...become gif.Frames[1] through gif.Frames[10], for a total of 11 frames.
The GIF encoder uses GifColorTableMode to decide if a color table is generated for each frame or the color table for the first frame is used for all frames. The combination of the default value, GifColorTableMode.Global, plus that first transparent frame results in an 11-frame .gif file with only one color, that same "transparent black". This is why your yellow text doesn't appear and every frame looks the same.
To solve this, at some point before you save the file you need to remove that initial transparent frame so it doesn't influence color table calculations and because it's not part of your animation, anyways...
gif.Frames.RemoveFrame(0);
You may also want to change to GifColorTableMode.Local so your .gif file contains color tables reflecting all of the colors rendered...
gif.MetaData.GetFormatMetaData(GifFormat.Instance).ColorTableMode = GifColorTableMode.Local;
...although your 10 frames each use almost the same set of colors so if file size is a greater concern than color representation you might leave that property alone. Generating your 400 × 400 animation with GifColorTableMode.Global produces a 9,835-byte file whereas GifColorTableMode.Local produces a 16,703-byte file; 70% bigger but I can't tell the difference between them.
Related issue on GitHub
By the way, since I found this along the way, if you wanted to change the duration of the animated frames you would do so using another GetFormatMetaData() method similar to the one shown above...
GifFrameMetaData frameMetaData = img.MetaData.GetFormatMetaData(GifFormat.Instance);
frameMetaData.FrameDelay = 100;// 1 second

How to change data label position in EPPlus?

So here is my successfully generated chart. However for some reason on this chart only it decides the date times should show up at the top of the chart instead of the bottom. Here is my code and what I've tried. Notice the text is neither bold nor is at showing where it should. I've also tried giving the chart a ton of area to work with and it still does this. Any help in the right direction would be greatly appreciated.
ExcelChart paintDewChart = overview.Drawings.AddChart(w.Name + "Dew", OfficeOpenXml.Drawing.Chart.eChartType.LineMarkersStacked);
paintDewChart.Title.Text = "Paint Dew";
paintDewChart.SetPosition(24, 0, 0, 0);
paintDewChart.SetSize(1550, 400);
paintDewChart.Legend.Position = eLegendPosition.Bottom;
var dser1 = (ExcelLineChartSerie)(paintDewChart.Series.Add(w2.Cells["C4:C" + water.Count.ToString()], w1.Cells["A4:A" + water.Count.ToString()]));
var dser2 = (ExcelLineChartSerie)(paintDewChart.Series.Add(w2.Cells["D4:D" + water.Count.ToString()], w1.Cells["A4:A" + water.Count.ToString()]));
dser1.Header = "PC2 Dew";
dser2.Header = "B Dew";
dser1.DataLabel.Position = eLabelPosition.Bottom;
dser2.DataLabel.Position = eLabelPosition.Bottom;
dser1.DataLabel.Font.Bold = true;
dser2.DataLabel.Font.Bold = true;
EDIT:
I figured out I can flip the orientation with this, however labels still overlay on the graph instead of below it.
paintDewChart.YAxis.Orientation = eAxisOrientation.MaxMin;
Here is the correct code I need for my situation.
paintDewChart.YAxis.Orientation = eAxisOrientation.MaxMin;
paintDewChart.XAxis.LabelPosition = eTickLabelPosition.High;
paintDewChart.XAxis.TickLabelPosition = eTickLabelPosition.High;
EDIT: Also depending on minimum and maximum value ranges going from positive to negative, you may need this.
paintDewChart.XAxis.Crosses = eCrosses.Max;

Custom label not aligning horizontally in ASP.NET charts

I am binding datatable to ASP.NET chart for which I am using custom label for X-Axis. The label text is aligned vertically and the chart size gets reduced.
I tried the following code :
Chart2.ChartAreas[0].AxisX.IsLabelAutoFit = false;
Chart2.ChartAreas[0].AxisX.LabelStyle.Enabled = true;
Chart2.ChartAreas[0].AxisX.LabelStyle.Font = new System.Drawing.Font("Comic Sans", 9F);
Chart2.ChartAreas[0].AxisX.LabelAutoFitStyle = LabelAutoFitStyles.WordWrap;
I also tried the following fix by searching the internet:
Chart2.ChartAreas[0].AxisX.LabelStyle.Angle = 90;
Chart2.ChartAreas[0].AxisX.LabelAutoFitStyle = LabelAutoFitStyles.LabelsAngleStep90;
I tried changing various values for the angle but still it would align vertically.
Any links or suggestion on this would be much appreciated.
I am Ultra New, but this may help:" i have been searching for a solution for the last 4 hrs and someone suggested using annotations. Also this code is in VB, but it may help with another direction if you can't find an answer.
Dim MyTextAnnotation As TextAnnotation
MyTextAnnotation = New TextAnnotation
MyTextAnnotation.Text = "some notation"
MyTextAnnotation.X = 0
MyTextAnnotation.Y = 0
chart1.Annotations.Add(MyTextAnnotation)

Categories

Resources