public void CommonElementsTest() { CommonElements C = new CommonElements(); CollectionAssert.AreEqual( C.solution( new int[] { 0, 1, 4, 6, 7, 9 }, new int[] { 1, 2, 4, 5, 9, 10 } ), new int[] { 1, 4, 9 } ); CollectionAssert.AreEqual( C.solution( new int[] { 1, 2, 9, 10, 11, 12 }, new int[] { 0, 1, 2, 3, 4, 5, 8, 9, 10, 12, 14, 15 } ), new int[] { 1, 2, 9, 10, 12 } ); CollectionAssert.AreEqual( C.solution( new int[] { 0, 1, 2, 3, 4, 5 }, new int[] { 6, 7, 8, 9, 10, 11 } ), new int[] {} ); }
private static void RenderLabel(CommonElements common, ChartGraphics graph, CategoryNode node, DataPoint dataPoint, DataPointAttributes dataPointAttributes, string text, float startAngle, float sweepAngle, PointF centerAbsolute, float radiusAbsolute, int dataPointIndex, GraphicsPath sliceGraphicsPath) { if (string.IsNullOrEmpty(text)) { return; } SizeF size = graph.MeasureString(text.Replace("\\n", "\n"), dataPointAttributes.Font, new SizeF(1000f, 1000f), new StringFormat(StringFormat.GenericTypographic)); SizeF relativeSize = graph.GetRelativeSize(size); float num = relativeSize.Width / (float)text.Length; float num2 = relativeSize.Width + num; float num3 = relativeSize.Height + relativeSize.Height / 8f; float sliceCenterAngle = GetSliceCenterAngle(startAngle, sweepAngle); float labelAngle = GetLabelAngle(sliceCenterAngle); PointF sliceCenterRelative = GetSliceCenterRelative(graph, sliceCenterAngle, centerAbsolute, radiusAbsolute); RectangleF resizedRect = new RectangleF(sliceCenterRelative.X - num2 / 2f, sliceCenterRelative.Y - num3 / 2f, num2, num3); if (resizedRect.IsEmpty) { return; } int num4 = (int)labelAngle + dataPointAttributes.FontAngle; if (graph.CanLabelFitInSlice(sliceGraphicsPath, resizedRect, num4) || CanFitInResizedArea(text, dataPointAttributes.Font, relativeSize, sliceCenterRelative, graph, sliceGraphicsPath, resizedRect, num4, radiusAbsolute, out resizedRect)) { if (dataPoint != null) { graph.DrawPointLabelStringRel(common, text, dataPoint.Font, new SolidBrush(dataPoint.FontColor), resizedRect, format, (int)labelAngle + dataPoint.FontAngle, resizedRect, dataPoint.LabelBackColor, dataPoint.LabelBorderColor, dataPoint.LabelBorderWidth, dataPoint.LabelBorderStyle, dataPoint.series, dataPoint, dataPointIndex); return; } graph.DrawLabelBackground(num4, sliceCenterRelative, resizedRect, dataPointAttributes.LabelBackColor, dataPointAttributes.LabelBorderColor, dataPointAttributes.LabelBorderWidth, dataPointAttributes.LabelBorderStyle); graph.MapCategoryNodeLabel(common, node, resizedRect); graph.DrawStringRel(text, dataPointAttributes.Font, new SolidBrush(dataPointAttributes.FontColor), resizedRect, format, num4); } }
//Definition of pages, browsers and timeouts public void PagesDef(string browserName) { ChromeOptions chromeOptions = new ChromeOptions(); chromeOptions.AddArguments("--disable-extensions"); chromeOptions.AddArguments("--js-flags=--expose-gc"); chromeOptions.AddArguments("--enable-precise-memory-info"); chromeOptions.AddArguments("--disable-popup-blocking"); chromeOptions.AddArguments("--disable-default-apps"); chromeOptions.AddArguments("disable-infobars"); chromeOptions.AddArguments("--disable-settings-window"); switch (browserName) { case "Chrome": Driver = new ChromeDriver(chromeOptions); Driver.Manage().Timeouts().SetPageLoadTimeout(TimeSpan.FromSeconds(30)); Driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromMinutes(30)); Driver.Manage().Timeouts().SetScriptTimeout(TimeSpan.FromSeconds(30)); break; case "FireFox": Driver = new FirefoxDriver(); break; } // - Pages - // commonElements = new CommonElements(Driver); webPage1 = new WebPage1(Driver); }
public void CreateOffers() { Vector3 originPosition = offerOrigin.transform.localPosition; Transform parentTransform = offerOrigin.transform.parent; activeOfferNumber = 0; foreach (GameObject generatedOffer in generatedOffers) { Destroy(generatedOffer); } generatedOffers.Clear(); CommonElements common = CommonElements.instance; foreach (Connector.JsonData.Room room in common.lastJsonDataWrapper.jsonDatas[0].ROOMS) { GameObject offer = Instantiate(offerPrefab, originPosition, Quaternion.identity) as GameObject; offer.transform.SetParent(parentTransform, false); OfferPanel offerPanel = offer.GetComponent <OfferPanel>(); offerPanel.title.text = room.title; offerPanel.actualUsers.text = Random.Range(1, Int32.Parse(room.maxUsr)) + "/" + room.maxUsr; offerPanel.userName.text = CommonElements.instance.userNames[Int32.Parse(room.hID) - 1]; offerPanel.backImage.sprite = CommonElements.instance.facesList[Int32.Parse(room.hID) - 1]; offerPanel.description.text = room.descr; generatedOffers.Add(offer); offer.SetActive(false); } offerOrigin = generatedOffers[activeOfferNumber]; generatedOffers[activeOfferNumber].SetActive(true); }
private static void RenderNode(CommonElements common, ChartGraphics graph, CategoryNode node, RectangleF rectRelative, int level, double parentValue, ref float startAngle, float parentSweepAngle, float thresholdAngle, float incrementXRelative, float incrementYRelative, PointF centerAbsolute, float centerRadiusAbsolute, float edgeRadiusAbsolute, Series series, DataPointAttributes dataPointAttributes) { double absoluteValue = node.GetValues(series).AbsoluteValue; if (absoluteValue != 0.0) { CategoryNode dataPointNode = node.GetDataPointNode(series); DataPoint dataPoint; int dataPointIndex; if (dataPointNode != null) { dataPoint = dataPointNode.GetDataPoint(series); dataPointIndex = dataPointNode.Index; } else { dataPoint = null; dataPointIndex = -1; } DataPointAttributes dataPointAttributes2 = (dataPoint != null) ? dataPoint : dataPointAttributes; float num = (float)(absoluteValue / parentValue * (double)parentSweepAngle); float sweepAngle = num - thresholdAngle; using (GraphicsPath sliceGraphicsPath = RenderSlice(common, graph, node, dataPoint, dataPointAttributes2, rectRelative, startAngle, sweepAngle, centerAbsolute, edgeRadiusAbsolute, level, dataPointIndex)) { RenderLabel(common, graph, node, dataPoint, dataPointAttributes2, GetLabelText(node, dataPoint, series, dataPointAttributes2), startAngle, num, centerAbsolute, centerRadiusAbsolute, dataPointIndex, sliceGraphicsPath); } if (node.Children != null) { float startAngle2 = startAngle; RenderNodes(common, graph, node.Children, RectangleF.Inflate(rectRelative, incrementXRelative, incrementYRelative), level + 1, absoluteValue, ref startAngle2, num, incrementXRelative, incrementYRelative, series, dataPointAttributes); } startAngle += num; } }
/// <summary> /// Get value from custom attribute BubbleMaxSize /// </summary> /// <param name="area">Chart Area</param> /// <returns>Bubble Max size</returns> static internal double GetBubbleMaxSize(ChartArea area) { double maxPossibleBubbleSize = 15; // Try to find bubble size scale in the custom series properties foreach (Series ser in area.Common.DataManager.Series) { if (String.Compare(ser.ChartTypeName, ChartTypeNames.Bubble, StringComparison.OrdinalIgnoreCase) == 0 && ser.ChartArea == area.Name && ser.IsVisible()) { // Check if attribute for max. size is set if (ser.IsCustomPropertySet(CustomPropertyName.BubbleMaxSize)) { maxPossibleBubbleSize = CommonElements.ParseDouble(ser[CustomPropertyName.BubbleMaxSize]); if (maxPossibleBubbleSize < 0 || maxPossibleBubbleSize > 100) { throw(new ArgumentException(SR.ExceptionCustomAttributeIsNotInRange0to100("BubbleMaxSize"))); } } } } return(maxPossibleBubbleSize / 100); }
/// <summary> /// Check if any series is indexed. IsXValueIndexed flag is set or all X values are zeros. /// </summary> /// <param name="common">Reference to common chart classes.</param> /// <param name="series">Data series names.</param> /// <returns>True if any series is indexed.</returns> static internal bool IndexedSeries(CommonElements common, params string[] series) { // Data series loop bool zeroXValues = true; foreach (string ser in series) { Series localSeries = common.DataManager.Series[ser]; // Check series indexed flag if (localSeries.IsXValueIndexed) { // If flag set in at least one series - all series are indexed return(true); } // Check if series has all X values set to zero if (zeroXValues && !IndexedSeries(localSeries)) { zeroXValues = false; } } return(zeroXValues); }
// [Test] public void LogoutTestCounter() { var numberOfTries = 5; var numberOfFails = 0; for (int i = 0; i < numberOfTries; i++) { try { Driver = MyDriver.InitDriver(Browser.Chrome); WebDriverWait wait = new WebDriverWait(Driver, TimeSpan.FromSeconds(20)); Driver.Url = "https://www.pet24.lt/"; CommonElements commonElements = new CommonElements(Driver); commonElements.CloseCookiesBar(); LoginPage loginPage = new LoginPage(Driver); HomePage homePage = new HomePage(Driver); AccountPage accountPage = new AccountPage(Driver); homePage.goToUserLoginPage(); loginPage.LoginAsUser(User.TestUser); accountPage.ClickLogoutButton(); loginPage.AssertUserIsLoggedOut(); } catch (Exception e) { numberOfFails++; } finally { Driver.Quit(); } } Console.WriteLine($"Out of {numberOfTries} times, test failed {numberOfFails} times"); }
public virtual double GetYValue(CommonElements common, ChartArea area, Series series, DataPoint point, int pointIndex, int yValueIndex) { if (yValueIndex == -1) { return(0.0); } if (point.YValues.Length <= yValueIndex) { throw new InvalidOperationException(SR.ExceptionChartTypeRequiresYValues(Name, YValuesPerPoint.ToString(CultureInfo.InvariantCulture))); } if (point.Empty || double.IsNaN(point.YValues[yValueIndex])) { double num = GetEmptyPointValue(point, pointIndex); if (num == 0.0) { Axis axis = area.GetAxis(AxisName.Y, series.YAxisType, series.YSubAxisName); double maximum = axis.maximum; double minimum = axis.minimum; if (num < minimum) { num = minimum; } else if (num > maximum) { num = maximum; } } return(num); } return(point.YValues[yValueIndex]); }
public virtual double GetYValue(CommonElements common, ChartArea area, Series series, DataPoint point, int pointIndex, int yValueIndex) { if (yValueIndex == -1) { return(0.0); } if (point.Empty) { double num = GetEmptyPointValue(point, pointIndex); if (num == 0.0) { Axis axis = area.GetAxis(AxisName.Y, series.YAxisType, series.YSubAxisName); double maximum = axis.maximum; double minimum = axis.minimum; if (num < minimum) { num = minimum; } else if (num > maximum) { num = maximum; } } return(num); } return(point.YValues[yValueIndex]); }
public static void MapCategoryNode(CommonElements common, CategoryNode node, float startAngle, float sweepAngle, RectangleF rectangle, float doughnutRadius, ChartGraphics graph) { if (PieChart.CreateMapAreaPath(startAngle, sweepAngle, rectangle, doughnut: true, doughnutRadius, graph, out GraphicsPath path, out float[] _)) { common.HotRegionsList.AddHotRegion(graph, path, relativePath: false, node.ToolTip, node.Href, "", node, ChartElementType.Nothing); } }
/// <summary> /// Returns marker size. /// </summary> /// <param name="graph">The Chart Graphics object.</param> /// <param name="common">The Common elements object.</param> /// <param name="area">Chart area for this chart.</param> /// <param name="point">Data point.</param> /// <param name="markerSize">Marker size.</param> /// <param name="markerImage">Marker image.</param> /// <returns>Marker width and height.</returns> override protected SizeF GetMarkerSize( ChartGraphics graph, CommonElements common, ChartArea area, DataPoint point, int markerSize, string markerImage) { // Check required Y values number if (point.YValues.Length < this.YValuesPerPoint) { throw(new InvalidOperationException(SR.ExceptionChartTypeRequiresYValues(this.Name, this.YValuesPerPoint.ToString(CultureInfo.InvariantCulture)))); } // Marker size SizeF size = new SizeF(markerSize, markerSize); if (graph != null && graph.Graphics != null) { // Marker size is in pixels and we do the mapping for higher DPIs size.Width = markerSize * graph.Graphics.DpiX / 96; size.Height = markerSize * graph.Graphics.DpiY / 96; } // Check number of Y values for non empty points if (point.series.YValuesPerPoint > 1 && !point.IsEmpty) { // Scale Y values size.Width = ScaleBubbleSize(graph, common, area, point.YValues[1]); size.Height = ScaleBubbleSize(graph, common, area, point.YValues[1]); } return(size); }
/// <summary> /// Overrides the ConvertFrom method of TypeConverter. /// </summary> /// <param name="context">Descriptor context.</param> /// <param name="culture">Culture information.</param> /// <param name="value">Value to convert from.</param> /// <returns>Converted object.</returns> public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { object result = null; bool convertFromDate = false; // Try to check if value type is date if (context != null && context.Instance != null) { DataPoint dataPoint = (DataPoint)context.Instance; if (dataPoint.series != null && dataPoint.series.IsYValueDateTime()) { convertFromDate = true; } } // Can convert from string where each array element is separated by comma string stringValue = value as string; if (stringValue != null) { string[] values = stringValue.Split(new char[] { ',' }); double[] array = new double[values.Length]; for (int index = 0; index < values.Length; index++) { // Try to convert from date-time string format if (convertFromDate) { DateTime valueAsDate; if (DateTime.TryParse(values[index], CultureInfo.InvariantCulture, DateTimeStyles.None, out valueAsDate)) { result = valueAsDate; } else if (DateTime.TryParse(values[index], CultureInfo.CurrentCulture, DateTimeStyles.None, out valueAsDate)) { result = valueAsDate; } else { result = null; } } // Save converted value in the array if (result != null) { array[index] = (double)result; } else { array[index] = CommonElements.ParseDouble(values[index]); } } return(array); } // Call base class return(base.ConvertFrom(context, culture, value)); }
public CommonElements GetInstance() { if (!instance) { instance = this; } return(instance); }
private static void RenderDataPoint(ChartGraphics graph, CommonElements common, int index, TreeMapNode dataPointTreeMapNode) { RectangleF relativeRect = TreeMapChart.GetRelativeRect(graph, dataPointTreeMapNode); DataPoint dataPoint = dataPointTreeMapNode.DataPoint; graph.FillRectangleRel(relativeRect, dataPoint.Color, dataPoint.BackHatchStyle, dataPoint.BackImage, dataPoint.BackImageMode, dataPoint.BackImageTransparentColor, dataPoint.BackImageAlign, dataPoint.BackGradientType, dataPoint.BackGradientEndColor, dataPoint.BorderColor, dataPoint.BorderWidth, dataPoint.BorderStyle, dataPoint.series.ShadowColor, dataPoint.series.ShadowOffset, PenAlignment.Inset, ChartGraphics.GetBarDrawingStyle(dataPoint), true); TreeMapChart.AddDataPointHotRegion(graph, common, index, dataPoint, relativeRect); }
/// <summary> /// Paint Line Chart. /// </summary> /// <param name="graph">The Chart Graphics object.</param> /// <param name="common">The Common elements object.</param> /// <param name="area">Chart area for this char.t</param> /// <param name="seriesToDraw">Chart series to draw.</param> public override void Paint(ChartGraphics graph, CommonElements common, ChartArea area, Series seriesToDraw) { // Reset current direction this.currentKagiDirection = 0; // Call base class methods base.Paint(graph, common, area, seriesToDraw); }
public override double GetYValue(CommonElements common, ChartArea area, Series series, DataPoint point, int pointIndex, int yValueIndex) { if (yValueIndex == -1) { return(0.0 - (base.GetYValue(common, area, series, point, pointIndex, 1) - base.GetYValue(common, area, series, point, pointIndex, 0))); } return(base.GetYValue(common, area, series, point, pointIndex, yValueIndex)); }
/// <summary> /// Sets the value for a given combo box /// </summary> /// <param name="comboBox"> /// combo box which will be modified /// </param> /// <param name="inputValue"> /// value which will be selected within the combo box /// </param> /// <param name="statusIcon"> /// element which contains the status icon for the given combo box /// </param> /// <returns> /// true, if value is set; false, if an error occurred /// </returns> public bool SetComboBoxValue(Element comboBox, string inputValue, Element statusIcon) { if (comboBox == null) { Log.Error(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Combo box is null"); return(false); } Mouse.MoveTo(comboBox, 500); Mouse.Click(comboBox); ListItem listItem = this.GetListItem(inputValue); if (listItem == null) { return(false); } // scroll down or up to find value in combo box if it is not visible IList <ListItem> comboBoxList = new CommonElements().ListItemsComboBox; int counter = 0; while (listItem.Selected == false) { if (counter >= (comboBoxList.Count - 1)) { // list end, value not found, scrolling up now Keyboard.Press(Keys.Up); counter++; Mouse.MoveTo(listItem); } else { if (counter > ((comboBoxList.Count - 1) * 2)) { // searched entire list, parameter not found break; } // normal case, scrolling down Keyboard.Press(Keys.Down); counter++; Mouse.MoveTo(listItem); } } if (listItem.Selected == false) { // Parameter not found Log.Error(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Parameter " + listItem.Text + " not found"); return(false); } // Parameter is found, click it and confirm with "enter" Mouse.Click(listItem, DefaultValues.locDefaultLocation, DefaultValues.durDurationShort); Keyboard.Press(Keys.Enter); return(new ParameterStates().WaitForParameterUpdate(statusIcon)); }
void Awake() { DontDestroyOnLoad(gameObject); if (!instance) { instance = this; } }
private static void RenderNodes(CommonElements common, ChartGraphics graph, CategoryNodeCollection nodes, RectangleF rectRelative, double chartTotal, float incrementXRelative, float incrementYRelative, List <Series> seriesCollection) { float startAngle = 270f; foreach (Series item in seriesCollection) { RenderNodes(common, graph, nodes, rectRelative, 1, chartTotal, ref startAngle, 360f, incrementXRelative, incrementYRelative, item, GetFirstNonEmptyDataPointsAttributes(item)); } }
protected override PointF[] GetPointsPosition(ChartGraphics graph, Series series, bool indexedSeries) { lineTension = GetDefaultTension(); if (IsLineTensionSupported() && series.IsAttributeSet("LineTension")) { lineTension = CommonElements.ParseFloat(series["LineTension"]); } return(base.GetPointsPosition(graph, series, indexedSeries)); }
public static void MapCategoryNode(CommonElements common, CategoryNode node, float startAngle, float sweepAngle, RectangleF rectangle, float doughnutRadius, ChartGraphics graph) { GraphicsPath path = default(GraphicsPath); float[] array = default(float[]); if (PieChart.CreateMapAreaPath(startAngle, sweepAngle, rectangle, true, doughnutRadius, graph, out path, out array)) { common.HotRegionsList.AddHotRegion(graph, path, false, node.ToolTip, node.Href, "", node, ChartElementType.Nothing); } }
protected virtual SizeF GetMarkerSize(ChartGraphics graph, CommonElements common, ChartArea area, DataPoint point, int markerSize, string markerImage) { SizeF size = new SizeF(markerSize, markerSize); if (markerImage.Length > 0) { common.ImageLoader.GetAdjustedImageSize(markerImage, graph.Graphics, ref size); } return(size); }
/// <summary> /// Helper function, which returns the Y value of the point. /// </summary> /// <param name="common">Chart common elements.</param> /// <param name="area">Chart area the series belongs to.</param> /// <param name="series">Sereis of the point.</param> /// <param name="point">Point object.</param> /// <param name="pointIndex">Index of the point.</param> /// <param name="yValueIndex">Index of the Y value to get.</param> /// <returns>Y value of the point.</returns> virtual public double GetYValue( CommonElements common, ChartArea area, Series series, DataPoint point, int pointIndex, int yValueIndex) { return(point.YValues[yValueIndex]); }
/// <summary> /// This method recalculates size of the bars. This method is used /// from Paint or Select method. /// </summary> /// <param name="selection">If True selection mode is active, otherwise paint mode is active</param> /// <param name="graph">The Chart Graphics object</param> /// <param name="common">The Common elements object</param> /// <param name="area">Chart area for this chart</param> /// <param name="seriesToDraw">Chart series to draw.</param> override protected void ProcessChartType( bool selection, ChartGraphics graph, CommonElements common, ChartArea area, Series seriesToDraw) { _scaleDetected = false; base.ProcessChartType(selection, graph, common, area, seriesToDraw); }
/// <summary> /// Data manager public constructor /// </summary> /// <param name="container">Service container object.</param> public DataManager(IServiceContainer container) { if (container == null) { throw(new ArgumentNullException(SR.ExceptionInvalidServiceContainer)); } serviceContainer = container; Common = new CommonElements(container); _series = new SeriesCollection(this); }
public void InitPages() { loginPage = new LoginPage(Driver); homePage = new HomePage(Driver); commonElements = new CommonElements(Driver); productPage = new ProductPage(Driver); searchPage = new SearchPage(Driver); productFilterPage = new ProductFilterPage(Driver); shoppingCartPage = new ShoppingCartPage(Driver); accountPage = new AccountPage(Driver); userInfoPage = new UserInfoPage(Driver); }
public void DrawAccumulated3DLabels(ChartGraphics graph, CommonElements common, ChartArea area) { if (this.label3DInfoList != null) { foreach (Label3DInfo label3DInfo in this.label3DInfoList) { graph.StartAnimation(); this.DrawLabels(area, graph, common, label3DInfo.MarkerPosition, (int)label3DInfo.MarkerSize.Height, label3DInfo.PointEx.dataPoint, label3DInfo.PointEx.dataPoint.series, label3DInfo.PointEx.index - 1); graph.StopAnimation(); } this.label3DInfoList.Clear(); } }
/// <summary> /// Check if all data points in many series have X value set to 0. /// </summary> /// <param name="common">Reference to common chart classes.</param> /// <param name="series">Data series.</param> /// <returns>True if all data points have value 0.</returns> static internal bool SeriesXValuesZeros(CommonElements common, params string[] series) { // Data series loop foreach (string ser in series) { // Check one series X values if (!SeriesXValuesZeros(common.DataManager.Series[ser])) { return(false); } } return(true); }
public NotDoneActForm() { InitializeComponent(); CommonElements.InitMaterials(); MatCol.DataSource = CommonElements.Materials; MatCol.DisplayMember = "Name"; MatCol.ValueMember = "ID"; CommonElements.actions.TryGetValue("add", out add); CommonElements.actions.TryGetValue("del", out del); CommonElements.actions.TryGetValue("upd", out upd); }