private void OnKeyDown(Object sender, KeyEventArgs e) { switch (e.KeyData) { case Keys.F2: { if (SelectedStyle != null) { SelectedStyle.BeginEdit(); } break; } case (Keys.Control | Keys.Home): { if (_tvDefinedStyles.Nodes.Count > 0) { SelectedStyle = (StyleNode)_tvDefinedStyles.Nodes[0]; } break; } case (Keys.Control | Keys.End): { int numNodes = _tvDefinedStyles.Nodes.Count; if (numNodes > 0) { SelectedStyle = (StyleNode)_tvDefinedStyles.Nodes[numNodes - 1]; } break; } } }
/// <summary> /// Update the list of symbols given the current symbol geometry type, style, and search text. /// </summary> private async Task SearchForSymbols() { if (SelectedSymbolType == null || SelectedStyle == null) { _symbols.Clear(); } else { //Get results and populate symbol gallery StyleItemType _itemTypeToSearch; if (_selectedSymbolType == "Line symbols") { _itemTypeToSearch = StyleItemType.LineSymbol; } else if (_selectedSymbolType == "Polygon symbols") { _itemTypeToSearch = StyleItemType.PolygonSymbol; } else { _itemTypeToSearch = StyleItemType.PointSymbol; } //Search for symbols in the selected style _symbols = await SelectedStyle.SearchSymbolsAsync(_itemTypeToSearch, _searchString); } NotifyPropertyChanged(() => Symbols); }
public override Task SaveAsync(string location) { if (SelectedStyle == null) { return(Task.Delay(0)); } return(Task.Run(() => { SelectedStyle?.CreateDiffuseMap(false, Path.Combine(location, DiffuseTexture)); SelectedStyle?.CreateNormalsMap(false, Path.Combine(location, NormalsTexture)); })); }
public override void Dispose(bool disposing) { if (SelectedStyle != null) { SelectedStyle.Dispose(); } if (HoveredStyle != null) { HoveredStyle.Dispose(); } base.Dispose(disposing); }
private void ApplySlowDiffuse() { var applyId = ++_applyId; var diffuse = SelectedStyle?.CreateDiffuseMap(false, LicensePlatesStyle.Format.Png); if (_applyId != applyId) { return; } Renderer?.OverrideTexture(DiffuseTexture, diffuse); }
private void ApplySlowNormals() { var applyId = ++_applyId; var normals = SelectedStyle?.CreateNormalsMap(PreviewMode, LicensePlatesStyle.Format.Png); if (_applyId != applyId) { return; } Renderer?.OverrideTexture(NormalsTexture, normals); _flatNormals = false; }
public override void Dispose() { _keepGoing = false; base.Dispose(); SelectedStyle?.Dispose(); SelectedStyle = null; if (_thread != null) { lock (_threadObj) { Monitor.PulseAll(_threadObj); } _thread.Abort(); _thread = null; } }
protected override Task SaveOverrideAsync(IPaintShopRenderer renderer, string location) { if (SelectedStyle == null) { return(Task.Delay(0)); } return(Task.Run(() => { if (DiffuseTexture != null) { SelectedStyle?.CreateDiffuseMap(false, Path.Combine(location, DiffuseTexture)); } if (NormalsTexture != null) { SelectedStyle?.CreateNormalsMap(false, Path.Combine(location, NormalsTexture)); } })); }
/// <summary> /// Converts an object into its XML representation. /// </summary> /// <param name="writer">The <see cref="T:System.Xml.XmlWriter"/> stream to which the object is serialized. </param> public void WriteXml(XmlWriter writer) { writer.WriteStartElement("BackStyle"); BackStyle.WriteXml(writer); writer.WriteEndElement(); writer.WriteStartElement("ClickStyle"); ClickStyle.WriteXml(writer); writer.WriteEndElement(); writer.WriteStartElement("HoverStyle"); HoverStyle.WriteXml(writer); writer.WriteEndElement(); writer.WriteStartElement("SelectedStyle"); SelectedStyle.WriteXml(writer); writer.WriteEndElement(); writer.WriteStartElement("DisabledStyle"); DisabledStyle.WriteXml(writer); writer.WriteEndElement(); writer.WriteStartElement("SelectedHoverStyle"); SelectedHoverStyle.WriteXml(writer); writer.WriteEndElement(); writer.WriteElementString("NormalBorder", PaintUtility.GetString(NormalBorder)); writer.WriteElementString("HoverBorder", PaintUtility.GetString(HoverBorder)); writer.WriteElementString("NormalForeGround", PaintUtility.GetString(NormalForeGround)); writer.WriteElementString("SelectedBorder", PaintUtility.GetString(SelectedBorder)); writer.WriteElementString("HoverForeGround", PaintUtility.GetString(HoverForeGround)); writer.WriteStartElement("AppearenceText"); AppearenceText.WriteXml(writer); writer.WriteEndElement(); writer.WriteElementString("SelectedForeGround", PaintUtility.GetString(SelectedForeGround)); writer.WriteElementString("DisabledBorder", PaintUtility.GetString(DisabledBorder)); writer.WriteElementString("DisabledForeGround", PaintUtility.GetString(DisabledForeGround)); writer.WriteElementString("Gradient", Gradient.ToString()); }
/// <summary> /// Creates a new object that is a copy of the current instance. /// </summary> /// <returns> /// A new object that is a copy of this instance. /// </returns> /// <filterpriority>2</filterpriority> public object Clone() { var app = new AppearanceItem(); app.BackStyle.Assign((ColorPair)BackStyle.Clone()); app.ClickStyle.Assign((ColorPair)ClickStyle.Clone()); app.DisabledBorder = DisabledBorder; app.DisabledForeGround = DisabledForeGround; app.DisabledStyle.Assign((ColorPair)DisabledStyle.Clone()); app.Gradient = Gradient; app.HoverBorder = HoverBorder; app.HoverForeGround = HoverForeGround; app.HoverStyle.Assign((ColorPair)HoverStyle.Clone()); app.NormalBorder = NormalBorder; app.NormalForeGround = NormalForeGround; app.SelectedBorder = SelectedBorder; app.SelectedForeGround = SelectedForeGround; app.SelectedHoverStyle.Assign((ColorPair)SelectedHoverStyle.Clone()); app.SelectedStyle.Assign((ColorPair)SelectedStyle.Clone()); app.AppearenceText.Assign((AppearenceText)AppearenceText.Clone()); return(app); }
private void ApplyQuick() { var applyId = ++_applyId; var diffuse = SelectedStyle?.CreateDiffuseMap(true, LicensePlatesStyle.Format.Png); if (_applyId != applyId) { return; } Renderer?.OverrideTexture(DiffuseTexture, diffuse); if (_applyId != applyId) { return; } if (!_flatNormals) { _flatNormals = true; Renderer?.OverrideTexture(NormalsTexture, Color.FromRgb(127, 127, 255).ToColor()); } }
/// <summary> /// Generates an object from its XML representation. /// </summary> /// <param name="reader">The <see cref="T:System.Xml.XmlReader"/> stream from which the object is deserialized. </param> public void ReadXml(XmlReader reader) { var doc = new XmlDocument(); doc.Load(reader); if (doc.GetElementsByTagName("BackStyle").Count > 0) { var xml = "<ColorPair>" + doc.GetElementsByTagName("BackStyle")[0].InnerXml + "</ColorPair>"; BackStyle.ReadXml(new XmlTextReader(xml, XmlNodeType.Document, null)); } if (doc.GetElementsByTagName("ClickStyle").Count > 0) { var xml = "<ColorPair>" + doc.GetElementsByTagName("ClickStyle")[0].InnerXml + "</ColorPair>"; ClickStyle.ReadXml(new XmlTextReader(xml, XmlNodeType.Document, null)); } if (doc.GetElementsByTagName("HoverStyle").Count > 0) { var xml = "<ColorPair>" + doc.GetElementsByTagName("HoverStyle")[0].InnerXml + "</ColorPair>"; HoverStyle.ReadXml(new XmlTextReader(xml, XmlNodeType.Document, null)); } if (doc.GetElementsByTagName("SelectedStyle").Count > 0) { var xml = "<ColorPair>" + doc.GetElementsByTagName("SelectedStyle")[0].InnerXml + "</ColorPair>"; SelectedStyle.ReadXml(new XmlTextReader(xml, XmlNodeType.Document, null)); } if (doc.GetElementsByTagName("DisabledStyle").Count > 0) { var xml = "<ColorPair>" + doc.GetElementsByTagName("DisabledStyle")[0].InnerXml + "</ColorPair>"; DisabledStyle.ReadXml(new XmlTextReader(xml, XmlNodeType.Document, null)); } if (doc.GetElementsByTagName("SelectedHoverStyle").Count > 0) { var xml = "<ColorPair>" + doc.GetElementsByTagName("SelectedHoverStyle")[0].InnerXml + "</ColorPair>"; SelectedHoverStyle.ReadXml(new XmlTextReader(xml, XmlNodeType.Document, null)); } if (doc.GetElementsByTagName("NormalBorder").Count > 0) { NormalBorder = PaintUtility.GetColor(doc.GetElementsByTagName("NormalBorder")[0].InnerText); } if (doc.GetElementsByTagName("HoverBorder").Count > 0) { HoverBorder = PaintUtility.GetColor(doc.GetElementsByTagName("HoverBorder")[0].InnerText); } if (doc.GetElementsByTagName("SelectedBorder").Count > 0) { SelectedBorder = PaintUtility.GetColor(doc.GetElementsByTagName("SelectedBorder")[0].InnerText); } if (doc.GetElementsByTagName("NormalForeGround").Count > 0) { NormalForeGround = PaintUtility.GetColor(doc.GetElementsByTagName("NormalForeGround")[0].InnerText); } if (doc.GetElementsByTagName("HoverForeGround").Count > 0) { HoverForeGround = PaintUtility.GetColor(doc.GetElementsByTagName("HoverForeGround")[0].InnerText); } if (doc.GetElementsByTagName("AppearenceText").Count > 0) { var xml = "<AppearenceText>" + doc.GetElementsByTagName("AppearenceText")[0].InnerXml + "</AppearenceText>"; AppearenceText.ReadXml(new XmlTextReader(xml, XmlNodeType.Document, null)); } if (doc.GetElementsByTagName("SelectedForeGround").Count > 0) { SelectedForeGround = PaintUtility.GetColor(doc.GetElementsByTagName("SelectedForeGround")[0].InnerText); } if (doc.GetElementsByTagName("DisabledBorder").Count > 0) { DisabledBorder = PaintUtility.GetColor(doc.GetElementsByTagName("DisabledBorder")[0].InnerText); } if (doc.GetElementsByTagName("DisabledForeGround").Count > 0) { DisabledForeGround = PaintUtility.GetColor(doc.GetElementsByTagName("DisabledForeGround")[0].InnerText); } if (doc.GetElementsByTagName("Gradient").Count > 0) { Gradient = Convert.ToInt32(doc.GetElementsByTagName("Gradient")[0].InnerText); } }
/// <summary> /// Indicates wether <see cref="SelectedStyle"/> needs to be serialized by designer or not. /// </summary> /// <returns>true if designer needs to serialize</returns> protected virtual bool ShouldSerializeSelectedStyle() { return(SelectedStyle.DefaultChanged()); }