public static IEnumerable<Style> GetAvailableBeerStyles() { using (SQLiteConnection connection = DatabaseUtility.GetNewConnection()) { SQLiteCommand stylesCommand = connection.CreateCommand(); stylesCommand.CommandText = "SELECT Styles.name, Styles.notes, Styles.profile, Styles.ingredients, Styles.examples, StyleCategories.name, StyleCategories.number, StyleCategories.type, StyleClassifications.letter, StyleClassifications.guide FROM Styles " + "JOIN StyleCategories ON Styles.category = StyleCategories.id " + "JOIN StyleClassifications ON Styles.classification = StyleClassifications.id"; using (SQLiteDataReader reader = stylesCommand.ExecuteReader()) { while (reader.Read()) { StyleCategory category = new StyleCategory(reader.GetString(5), reader.GetInt32(6), reader.GetString(7)); StyleClassification classification = new StyleClassification(reader.GetString(8), reader.GetString(9)); string styleName = reader.GetString(0); List<StyleThreshold> thresholds = GetStyleThresholds(styleName, connection).ToList(); yield return new Style(styleName, category, classification, thresholds) { Notes = reader.GetString(1), Profile = reader.GetString(2), Ingredients = reader.GetString(3), Examples = reader.GetString(4) }; } } connection.Close(); } }
public static IEnumerable <Style> GetAvailableBeerStyles() { using var connection = DatabaseUtility.GetNewConnection(); var stylesCommand = connection.CreateCommand(); stylesCommand.CommandText = "SELECT Styles.name, Styles.notes, Styles.profile, Styles.ingredients, Styles.examples, StyleCategories.name, StyleCategories.number, StyleCategories.type, StyleClassifications.letter, StyleClassifications.guide FROM Styles " + "JOIN StyleCategories ON Styles.category = StyleCategories.id " + "JOIN StyleClassifications ON Styles.classification = StyleClassifications.id"; using var reader = stylesCommand.ExecuteReader(); while (reader.Read()) { var category = new StyleCategory(reader.GetString(5), reader.GetInt32(6), EnumConverter.Parse <StyleType>(reader.GetString(7))); var classification = new StyleClassification(reader.GetString(8), reader.GetString(9)); string styleName = reader.GetString(0); var thresholds = GetStyleThresholds(styleName, connection).ToList(); yield return(new Style(styleName, category, classification, thresholds) { Notes = reader.GetString(1), Profile = reader.GetString(2), Ingredients = reader.GetString(3), Examples = reader.GetString(4) }); } connection.Close(); }
public static Style GetStyle(XElement styleEntry) { string name = GetNameFromRecord(styleEntry); List<StyleThreshold> thresholds = new List<StyleThreshold>() { new StyleThreshold("og", (float) Convert.ToDouble(styleEntry.Element("OG_MIN").Value), (float) Convert.ToDouble(styleEntry.Element("OG_MAX").Value)), new StyleThreshold("fg", (float) Convert.ToDouble(styleEntry.Element("FG_MIN").Value), (float) Convert.ToDouble(styleEntry.Element("FG_MAX").Value)), new StyleThreshold("ibu", (float) Convert.ToDouble(styleEntry.Element("IBU_MIN").Value), (float) Convert.ToDouble(styleEntry.Element("IBU_MAX").Value)), new StyleThreshold("color", (float) Convert.ToDouble(styleEntry.Element("COLOR_MIN").Value), (float) Convert.ToDouble(styleEntry.Element("COLOR_MAX").Value)), new StyleThreshold("carb", (float) Convert.ToDouble(styleEntry.Element("CARB_MIN").Value), (float) Convert.ToDouble(styleEntry.Element("CARB_MAX").Value)), new StyleThreshold("abv", (float) Convert.ToDouble(styleEntry.Element("ABV_MIN").Value), (float) Convert.ToDouble(styleEntry.Element("ABV_MAX").Value)), }; string categoryName = styleEntry.Element("CATEGORY").Value; int categoryNumber = Convert.ToInt32(styleEntry.Element("CATEGORY_NUMBER").Value); string type = styleEntry.Element("TYPE").Value; StyleCategory category = new StyleCategory(categoryName, categoryNumber, type); string styleLetter = styleEntry.Element("STYLE_LETTER").Value; string styleGuide = styleEntry.Element("STYLE_GUIDE").Value; StyleClassification classification = new StyleClassification(styleLetter, styleGuide); return new Style(name, category, classification, thresholds) { Notes = GetNotesFromRecord(styleEntry), Profile = styleEntry.Element("PROFILE").Value, Ingredients = styleEntry.Element("INGREDIENTS").Value, Examples = styleEntry.Element("EXAMPLES").Value }; }
/// <ToBeCompleted></ToBeCompleted> public void CreateStyle(Design design, StyleCategory category) { if (design == null) { throw new ArgumentNullException("design"); } Style style; switch (category) { case StyleCategory.CapStyle: style = new CapStyle(GetNewStyleName(design.CapStyles)); ((CapStyle)style).CapShape = CapShape.None; ((CapStyle)style).ColorStyle = design.ColorStyles.Black; break; case StyleCategory.CharacterStyle: style = new CharacterStyle(GetNewStyleName(design.CharacterStyles)); ((CharacterStyle)style).ColorStyle = design.ColorStyles.Black; break; case StyleCategory.ColorStyle: style = new ColorStyle(GetNewStyleName(design.ColorStyles)); ((ColorStyle)style).Color = Color.Black; ((ColorStyle)style).Transparency = 0; break; case StyleCategory.FillStyle: style = new FillStyle(GetNewStyleName(design.FillStyles)); ((FillStyle)style).AdditionalColorStyle = design.ColorStyles.White; ((FillStyle)style).BaseColorStyle = design.ColorStyles.Black; ((FillStyle)style).FillMode = FillMode.Gradient; ((FillStyle)style).ImageLayout = ImageLayoutMode.Fit; break; case StyleCategory.LineStyle: style = new LineStyle(GetNewStyleName(design.LineStyles)); ((LineStyle)style).ColorStyle = design.ColorStyles.Black; ((LineStyle)style).DashCap = System.Drawing.Drawing2D.DashCap.Round; ((LineStyle)style).DashType = DashType.Solid; ((LineStyle)style).LineJoin = System.Drawing.Drawing2D.LineJoin.Round; ((LineStyle)style).LineWidth = 1; break; case StyleCategory.ParagraphStyle: style = new ParagraphStyle(GetNewStyleName(design.ParagraphStyles)); ((ParagraphStyle)style).Alignment = ContentAlignment.MiddleCenter; ((ParagraphStyle)style).Padding = new TextPadding(3); ((ParagraphStyle)style).Trimming = StringTrimming.EllipsisCharacter; ((ParagraphStyle)style).WordWrap = false; break; default: throw new NShapeUnsupportedValueException(typeof(StyleCategory), category); } ICommand cmd = new CreateStyleCommand(design, style); project.ExecuteCommand(cmd); }
//@Construct /// <summary> /// Initializes a StyleMainPage. /// </summary> public StyleMainPage() { this.InitializeComponent(); this.Loaded += async(s, e) => { if (this.StylesGridView.ItemsSource == null) { IEnumerable <StyleCategory> StyleCategorys = await Retouch_Photo2.XML.ConstructStylesFile(); if (StyleCategorys != null) { StyleCategory styleCategory = StyleCategorys.FirstOrDefault(); if (styleCategory != null) { IEnumerable <Retouch_Photo2.Styles.IStyle> Styles = styleCategory.Styles; this.StylesGridView.ItemsSource = Styles.ToList(); } } } }; this.StylesGridView.ItemClick += (s, e) => { if (e.ClickedItem is Retouch_Photo2.Styles.IStyle item) { Transformer transformer = this.SelectionViewModel.Transformer; this.MethodViewModel.ILayerChanged <Retouch_Photo2.Styles.IStyle> ( set: (layer) => { Transformer transformer2 = layer.Transform.Transformer; Retouch_Photo2.Styles.IStyle style2 = item.Clone(); style2.CacheTransform(); style2.DeliverBrushPoints(transformer2); layer.Style = style2; transformer = transformer2; this.SelectionViewModel.StandStyleLayer = layer; }, historyTitle: "Set style", getHistory: (layer) => layer.Style, setHistory: (layer, previous) => layer.Style = previous.Clone() ); Retouch_Photo2.Styles.IStyle style = item.Clone(); style.CacheTransform(); style.DeliverBrushPoints(transformer); this.SelectionViewModel.SetStyle(style); } }; }
/// <summary> /// An event that fires when a Category is appended to the current projects display library. /// </summary> /// <param name="library">[in] The Style Library object the category was appended too.</param> /// <param name="category">[in] The Category object Appended to the Style Library.</param> public static void DoCategoryAppended(StyleLibrary library, StyleCategory category) { string message = null; message = string.Format("\nCategory {0} was appended to the Style Library which now has {1} Categories.", category.Name, library.CategoryCount); Utility.ShowMessage(message); }
/// <summary> /// Initializes a new instance of <see cref="T:Dataweb.NShape.WinFormsUI.DesignEditorDialog" />. /// </summary> public DesignEditorDialog(Project project, StyleCategory styleCategory) : this(project) { designPresenter.SelectedStyleCategory = styleCategory; }