public static void RenderW2DImage(Graphics graphics, Rectangle rectangle, IW2DSymbol symb, Image image) { //TODO: This will currently just draw the default W2D image, it will not consider color overrides nor size parameters //But something is better than nothing at the moment. if (image != null) { //Start from center var location = new Point(rectangle.Width / 2, rectangle.Height / 2); //Displace according to image size location.X -= image.Width / 2; location.Y -= image.Height / 2; //Draw the result. graphics.DrawImage(image, location); } }
/// <summary> /// Sets the color of the text. /// </summary> /// <param name="sym">The sym.</param> /// <param name="c">The c.</param> public static void SetTextColor(this IW2DSymbol sym, Color c) { Check.NotNull(sym, "sym"); //NOXLATE sym.TextColor = Utility.SerializeHTMLColor(c, true); }
private void Symbol_SelectedIndexChanged(object sender, System.EventArgs e) { if (m_inUpdate) return; bool isSymbol = false; ShapeType selectedShape = ShapeType.Circle; // see if need to change symbol type foreach (string s in Enum.GetNames(typeof(ShapeType))) if (string.Compare(s, (string)Symbol.SelectedValue, true) == 0) { selectedShape = (ShapeType)Enum.Parse(typeof(ShapeType), s); isSymbol = true; break; } if (m_item.Symbol.Type == PointSymbolType.Mark) m_lastMark = (IMarkSymbol)m_item.Symbol; else if (m_item.Symbol.Type == PointSymbolType.Font) m_lastFont = (IFontSymbol)m_item.Symbol; if (isSymbol) { //W2D symbol is not selected, so invalidate grpW2DStyle.Tag = null; bool update = m_item.Symbol != m_lastMark; if (m_lastMark == null) m_lastMark = _factory.CreateDefaultMarkSymbol(); m_lastMark.Shape = selectedShape; m_item.Symbol = m_lastMark; setUIForMarkSymbol(true); if (update) UpdateDisplay(); } else if (Symbol.SelectedIndex == 6) //Font { //W2D symbol is not selected, so invalidate grpW2DStyle.Tag = null; // user wants to change away FROM a valid 'Mark' symbol type // if ("Font..." == Symbol.SelectedText) bool update = m_item.Symbol != m_lastFont; if (m_lastFont == null) { m_lastFont = _factory.CreateDefaultFontSymbol(); m_lastFont.SizeContext = SizeContextType.DeviceUnits; m_lastFont.Rotation = "0"; m_lastFont.SizeX = "10"; m_lastFont.SizeY = "10"; m_lastFont.Unit = LengthUnitType.Points; } m_item.Symbol = m_lastFont; setUIForMarkSymbol(false); if (update) UpdateDisplay(); } else if (Symbol.SelectedIndex == 7) //Symbol { using (var picker = new SymbolPicker(m_editor.GetEditedResource().CurrentConnection)) { if (picker.ShowDialog() == DialogResult.OK) { bool update = m_item.Symbol != m_lastSymbol; if (m_lastSymbol == null) { m_lastSymbol = _factory.CreateDefaultW2DSymbol(picker.SymbolLibrary, picker.SymbolName); m_lastSymbol.SizeContext = SizeContextType.DeviceUnits; m_lastSymbol.Rotation = "0"; m_lastSymbol.SizeX = "10"; m_lastSymbol.SizeY = "10"; m_lastSymbol.Unit = LengthUnitType.Points; } m_item.Symbol = m_lastSymbol; //Store the W2D preview image grpW2DStyle.Tag = picker.SymbolImage; setUIForMarkSymbol(false); if (update) UpdateDisplay(); } } } else { //W2D symbol is not selected, so invalidate grpW2DStyle.Tag = null; MessageBox.Show(this, Strings.SymbolTypeNotSupported, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information); return; } UpdatePreviewResult(); if (Changed != null) Changed(this, new EventArgs()); }