public void Constructor_WithoutMapTheme_ReturnCorrectPropertyValues() { // Setup Color color = Color.Aqua; const int width = 4; const LineDashStyle dashStyle = LineDashStyle.DashDot; var mapLineData = new MapLineData("Test", new LineStyle { Color = color, Width = width, DashStyle = dashStyle }); // Call var properties = new MapLineDataProperties(mapLineData, Enumerable.Empty <MapDataCollection>()); // Assert Assert.AreEqual("Enkel symbool", properties.StyleType); Assert.AreEqual(mapLineData.ShowLabels, properties.ShowLabels); Assert.IsEmpty(properties.SelectedMetaDataAttribute.MetaDataAttribute); Assert.AreEqual(mapLineData.MetaData, properties.GetAvailableMetaDataAttributes()); Assert.AreEqual(color, properties.Color); Assert.AreEqual(width, properties.Width); Assert.AreEqual(dashStyle, properties.DashStyle); CollectionAssert.IsEmpty(properties.CategoryThemes); }
public void Convert_ValidLineDashStyle_ReturnsExpectedDashStyle(LineDashStyle lineDashStyle, DashStyle expectedDashStyle) { // Call DashStyle dashStyle = MapDataHelper.Convert(lineDashStyle); // Assert Assert.AreEqual(expectedDashStyle, dashStyle); }
private void listBox1_DrawItem(object sender, System.Windows.Forms.DrawItemEventArgs e) { try { if (editStyle == EditStyle.dash) { LineDashStyle style = (LineDashStyle)listBox1.Items[e.Index]; using (var bitmap = Current.Engine.CreateBitmap(e.Bounds.Width, e.Bounds.Height)) using (var canvas = bitmap.CreateCanvas()) using (var pen = Current.Engine.CreatePen(ArgbColor.Black, 2)) { if (style == (LineDashStyle)_style) { using (var brush = Current.Engine.CreateSolidBrush(ArgbColor.Yellow)) { canvas.FillRectangle(brush, new CanvasRectangle(0, 0, e.Bounds.Width, e.Bounds.Height)); } } pen.DashStyle = style; canvas.DrawLine(pen, 5, bitmap.Height / 2, bitmap.Width - 10, bitmap.Height / 2); e.Graphics.DrawImage(bitmap.ToGdiBitmap(), e.Bounds.Left, e.Bounds.Top); } } else if (editStyle == EditStyle.hatch) { HatchStyle style = (HatchStyle)listBox1.Items[e.Index]; using (var bitmap = Current.Engine.CreateBitmap(e.Bounds.Width, e.Bounds.Height)) using (var canvas = bitmap.CreateCanvas()) using (var hbrush = Current.Engine.CreateHatchBrush(style, ArgbColor.Black, ArgbColor.Transparent)) { if (style == (HatchStyle)_style) { using (var brush = Current.Engine.CreateSolidBrush(ArgbColor.Yellow)) { canvas.FillRectangle(brush, new CanvasRectangle(0, 0, e.Bounds.Width, e.Bounds.Height)); } } CanvasRectangleF rect = new CanvasRectangleF(5, 5, bitmap.Width - 10, bitmap.Height - 10); using (var pen = Current.Engine.CreatePen(ArgbColor.Black, 1)) { canvas.DrawRectangle(pen, rect); } canvas.FillRectangle(hbrush, rect); e.Graphics.DrawImage(bitmap.ToGdiBitmap(), e.Bounds.Left, e.Bounds.Top); } } } catch { } }
public override object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (value is LineDashStyle) { LineDashStyle dashStyle = (LineDashStyle)value; return(!(dashStyle == LineDashStyle.Custom)); } else { return(Binding.DoNothing); } }
public Form_UITypeEditor_DashStyle(IWindowsFormsEditorService wfes, LineDashStyle style) { editStyle = EditStyle.dash; InitializeComponent(); foreach (LineDashStyle s in Enum.GetValues(typeof(LineDashStyle))) { listBox1.Items.Add(s); } _wfes = wfes; _style = style; }
public GridlinesSettingsViewModel(PrinterLayer printerLayer) { units = new Collection <PrintingUnit>(); units.Add(PrintingUnit.Inch); units.Add(PrintingUnit.Centimeter); dashStyles = new Collection <LineDashStyle>(); foreach (LineDashStyle item in Enum.GetValues(typeof(LineDashStyle))) { dashStyles.Add(item); } showGridlines = true; useCellSize = true; GridlinesPrinterLayer gridlinesPrinterLayer = printerLayer as GridlinesPrinterLayer; if (gridlinesPrinterLayer == null) { selectedBrush = new GeoSolidBrush(GeoColor.StandardColors.Gray); selectedDashStyle = LineDashStyle.Dot; rows = 10; columns = 10; penWidth = 1; selectedUnit = PrintingUnit.Inch; left = 1; top = 1; right = 1; bottom = 1; cellHeight = 1; cellWidth = 1; selectedCellUnit = PrintingUnit.Inch; } else { selectedBrush = gridlinesPrinterLayer.DrawingPen.Brush as GeoSolidBrush; selectedDashStyle = gridlinesPrinterLayer.DrawingPen.DashStyle; rows = gridlinesPrinterLayer.Rows; columns = gridlinesPrinterLayer.Columns; penWidth = gridlinesPrinterLayer.DrawingPen.Width; selectedUnit = gridlinesPrinterLayer.MarginUnit; left = gridlinesPrinterLayer.Left; top = gridlinesPrinterLayer.Top; right = gridlinesPrinterLayer.Right; bottom = gridlinesPrinterLayer.Bottom; cellHeight = gridlinesPrinterLayer.CellHeight; cellWidth = gridlinesPrinterLayer.CellWidth; selectedCellUnit = gridlinesPrinterLayer.CellUnit; useCellSize = gridlinesPrinterLayer.UseCellSize; } }
static public float[] ToPickerArray(this LineDashStyle dashStyle, float penWidth, LineCap lineCap) { float[] pickerArray = null; float dashhWidth = 4f, dashHole = 2f; float dotWidth = 1f, dotHole = 1f; switch (lineCap) { case LineCap.Square: dashhWidth -= 1; dashHole += 1; dotWidth = 0.001f; dotHole = 2f; break; case LineCap.Round: dashhWidth -= 1f; dashHole += 1; dotWidth = 0.001f; dotHole = 1.7f; break; } switch (dashStyle) { case LineDashStyle.Dot: pickerArray = new[] { dotWidth, dotHole }; break; case LineDashStyle.Dash: pickerArray = new[] { dashhWidth, dashHole }; break; case LineDashStyle.DashDot: pickerArray = new[] { dashhWidth, dotHole, dotWidth, dotHole }; break; case LineDashStyle.DashDotDot: pickerArray = new[] { dashhWidth, dotHole, dotWidth, dotHole, dotWidth, dotHole }; break; default: return(null); } // ToDo: lineCap? penWidth = Math.Max(penWidth, 1f); return(pickerArray.Select(a => a * penWidth).ToArray()); }
public static string GetCssLineType(LineDashStyle lineStyle) { switch (lineStyle) { case LineDashStyle.Dot: case LineDashStyle.SystemDot: return("dotted"); case LineDashStyle.Dash: case LineDashStyle.LargeDash: case LineDashStyle.SystemDash: return("dashed"); default: return("solid"); } }
public void Properties_SetValues_PropertyValuesAsExpected() { // Setup Color color = Color.AliceBlue; const int width = 3; const LineDashStyle style = LineDashStyle.Solid; // Call var lineStyle = new LineStyle { Color = color, Width = width, DashStyle = style }; // Assert Assert.AreEqual(color, lineStyle.Color); Assert.AreEqual(width, lineStyle.Width); Assert.AreEqual(style, lineStyle.DashStyle); }
static public string FromDashStyle(this LineDashStyle dashStyle) { switch (dashStyle) { case LineDashStyle.Solid: return("esriSLSSolid"); case LineDashStyle.Dot: return("esriSLSDot"); case LineDashStyle.DashDotDot: return("esriSLSDashDotDot"); case LineDashStyle.DashDot: return("esriSLSDashDotDot"); case LineDashStyle.Dash: return("esriSLSDash"); } return("esriSLSSolid"); }
/// <summary> /// Converts <see cref="LineDashStyle"/> to <see cref="DashStyle"/>. /// </summary> /// <param name="dashStyle">The <see cref="LineDashStyle"/> to convert.</param> /// <returns>The converted <see cref="DashStyle"/>.</returns> /// <exception cref="InvalidEnumArgumentException">Thrown when <paramref name="dashStyle"/> /// is not a valid enum value of <see cref="LineDashStyle"/>.</exception> /// <exception cref="NotSupportedException">Thrown when <paramref name="dashStyle"/> /// is not supported for the conversion.</exception> public static DashStyle Convert(LineDashStyle dashStyle) { if (!Enum.IsDefined(typeof(LineDashStyle), dashStyle)) { throw new InvalidEnumArgumentException(nameof(dashStyle), (int)dashStyle, typeof(LineDashStyle)); } var lineStyle = DashStyle.Solid; switch (dashStyle) { case LineDashStyle.Solid: break; case LineDashStyle.Dash: lineStyle = DashStyle.Dash; break; case LineDashStyle.Dot: lineStyle = DashStyle.Dot; break; case LineDashStyle.DashDot: lineStyle = DashStyle.DashDot; break; case LineDashStyle.DashDotDot: lineStyle = DashStyle.DashDotDot; break; default: throw new NotSupportedException(); } return(lineStyle); }
public void SetProperties_IndividualProperties_UpdateDataAndNotifyObservers() { // Setup const int numberOfChangedProperties = 3; var mocks = new MockRepository(); var observer = mocks.StrictMock <IObserver>(); observer.Expect(o => o.UpdateObserver()).Repeat.Times(numberOfChangedProperties); mocks.ReplayAll(); var mapLineData = new MapLineData("Test", new LineStyle { Color = Color.AliceBlue, Width = 3, DashStyle = LineDashStyle.Solid }); mapLineData.Attach(observer); var properties = new MapLineDataProperties(mapLineData, Enumerable.Empty <MapDataCollection>()); Color newColor = Color.Blue; const int newWidth = 6; const LineDashStyle newDashStyle = LineDashStyle.DashDot; // Call properties.Color = newColor; properties.Width = newWidth; properties.DashStyle = newDashStyle; // Assert Assert.AreEqual(newColor, mapLineData.Style.Color); Assert.AreEqual(newWidth, mapLineData.Style.Width); Assert.AreEqual(newDashStyle, mapLineData.Style.DashStyle); mocks.VerifyAll(); }
public void ConvertLayerProperties_MapLineDataWithStyle_ConvertsStyleToMapLineLayer( [Values(KnownColor.AliceBlue, KnownColor.Azure)] KnownColor color, [Values(1, 5)] int width, [Values(LineDashStyle.Solid, LineDashStyle.Dash)] LineDashStyle lineStyle) { // Setup Color expectedColor = Color.FromKnownColor(color); var converter = new MapLineDataConverter(); var mapLineLayer = new MapLineLayer(); var mapLineData = new MapLineData("test", new LineStyle { Color = expectedColor, Width = width, DashStyle = lineStyle }); // Call converter.ConvertLayerProperties(mapLineData, mapLineLayer); // Assert AssertAreEqual(new LineSymbolizer(expectedColor, expectedColor, width, MapDataHelper.Convert(lineStyle), LineCap.Round), mapLineLayer.Symbolizer); }
/// <summary> /// Asserts the line style. /// </summary> /// <param name="lineStyle">The <see cref="LineStyle"/>to assert.</param> /// <param name="color">The expected <see cref="Color"/>.</param> /// <param name="width">The expected width of the line.</param> /// <param name="style">The expected <see cref="LineDashStyle"/>.</param> /// <exception cref="AssertionException">Thrown when one of the parameters /// doesn't have the expected corresponding value.</exception> public static void AssertEqualStyle(LineStyle lineStyle, Color color, int width, LineDashStyle style) { Assert.AreEqual(color, lineStyle.Color); Assert.AreEqual(width, lineStyle.Width); Assert.AreEqual(style, lineStyle.DashStyle); }