public PackageListItem(GamePackRep pack, MHUrhoApp game) : base(game, "UI/AvailablePackItemStyle.xml", true) { this.Pack = pack; UIElement fixedElementContents = game.UI.LoadLayout(game.PackageManager.GetXmlFile("UI/AvailablePackItemFixedLayout.xml", true), game.PackageManager.GetXmlFile("UI/AvailablePackItemStyle.xml", true)); FixedElement.AddChild(fixedElementContents); var thumbnail = (BorderImage)FixedElement.GetChild("Thumbnail", true); thumbnail.Texture = pack.Thumbnail; thumbnail.ImageRect = new IntRect(0, 0, pack.Thumbnail.Width, pack.Thumbnail.Height); var name = (Text)FixedElement.GetChild("NameText", true); name.Value = pack.Name; UIElement expandingElementContents = game.UI.LoadLayout(game.PackageManager.GetXmlFile("UI/AvailablePackItemExpandingLayout.xml", true), game.PackageManager.GetXmlFile("UI/AvailablePackItemStyle.xml", true)); ExpandingElement.AddChild(expandingElementContents); descriptionText = (Text)ExpandingElement.GetChild("DescriptionText", true); descriptionText.Value = pack.Description; }
public LevelPickingLevelItem(LevelRep level, MHUrhoApp game) : base(game, "UI/LevelItemStyle.xml", true) { this.Level = level; XmlFile styleFile = game.PackageManager.GetXmlFile("UI/LevelItemStyle.xml", true); UIElement fixedElementContents = game.UI.LoadLayout(game.PackageManager.GetXmlFile("UI/LevelItemFixedLayout.xml", true), styleFile); FixedElement.AddChild(fixedElementContents); UIElement expandingElementContents = game.UI.LoadLayout(game.PackageManager.GetXmlFile("UI/LevelItemExpandingLayout.xml", true), styleFile); ExpandingElement.AddChild(expandingElementContents); var thumbnailElement = (BorderImage)fixedElementContents.GetChild("Thumbnail", true); thumbnailElement.Texture = level.Thumbnail; thumbnailElement.ImageRect = new IntRect(0, 0, level.Thumbnail.Width, level.Thumbnail.Height); var nameElement = (Text)CheckBox.GetChild("NameText", true); nameElement.Value = level.Name; ((Text)ExpandingElement.GetChild("DescriptionText", true)).Value = level.Description; }
public LevelPickingNewLevelItem(MHUrhoApp game) : base(game, "UI/LevelItemStyle.xml", false) { UIElement fixedElementContets = game.UI.LoadLayout(game.PackageManager.GetXmlFile("UI/NewLevelItemLayout.xml", true), game.PackageManager.GetXmlFile("UI/LevelItemStyle.xml", true)); FixedElement.AddChild(fixedElementContets); }
static void Main(string[] args) { //создание экземпляров классов Element и FixedElement FixedElement fixedElement = new FixedElement(); Element dimensionColumn = new Element(); Element dimensionRow = new Element(); //создание списка измерений, а также экземпляра класса таблицы фактов List <Dimensions> allDimensions = new List <Dimensions>(); Facts facts = new Facts(); //установка соединения с БД const string databaseName = @"D:\Warehouse_apple.db"; SQLiteConnection connection = new SQLiteConnection(string.Format("Data Source={0};", databaseName)); connection.Open(); //заполнение полей экземляра таблицы фактов и списка измерений ReadFacts(facts); ReadDimensions(allDimensions); XmlDocument doc = new XmlDocument(); int key; do { Console.Write(" 1 - Create XML\n 2 - Open report\n 0 - Exit\nSelect action: "); key = Convert.ToInt32(Console.ReadLine()); switch (key) { case 1: GenerateXML(allDimensions, connection); break; case 2: Console.Write("Input the name of report: "); doc.Load("D:\\UNIVER\\3 курс\\Спецкурс\\" + Console.ReadLine()); break; case 0: return; default: Console.WriteLine("Wrong key!"); break; } } while (key == 1); XmlNode report = doc.SelectSingleNode("Report"); foreach (XmlNode node in report) { switch (node.Name) { case "DimensionByColumn": dimensionColumn.DimID = Convert.ToInt32(node.InnerText); break; case "DimensionByRow": dimensionRow.DimID = Convert.ToInt32(node.InnerText); break; case "Fixed": foreach (XmlNode child in node.ChildNodes) { if (child.Name == "Dimension") { fixedElement.DimID = Convert.ToInt32(child.InnerText); } else { fixedElement.FixID = Convert.ToInt32(child.InnerText); break; } } break; case "Selection": foreach (XmlNode child in node.ChildNodes) { string text = child.FirstChild.InnerText; string[] values = text.Split(' '); if (child.Name == "Column") { // dimensionColumn.key_name = child.FirstChild.Name; for (int i = 0; i < values.Length; i++) { dimensionColumn.values.Add(Convert.ToInt32(values[i])); } } if (child.Name == "Row") { // dimensionRow.key_name = child.FirstChild.Name; for (int i = 0; i < values.Length; i++) { dimensionRow.values.Add(Convert.ToInt32(values[i])); } } } break; } } //формируем запрос для получения названий строк string command_Row = "SELECT * FROM " + allDimensions[dimensionRow.DimID - 1].TableName + " WHERE " + allDimensions[dimensionRow.DimID - 1].PK + " = " + dimensionRow.values[0].ToString(); for (int i = 1; i < dimensionRow.values.Count; i++) { command_Row += " OR ID = "; command_Row += dimensionRow.values[i].ToString(); } SQLiteCommand comm_Row = new SQLiteCommand(command_Row, connection); SQLiteDataReader reader_Row = comm_Row.ExecuteReader(); //формируем запрос для получения названий столбцов string command_Column = "SELECT * FROM " + allDimensions[dimensionColumn.DimID - 1].TableName + " WHERE " + allDimensions[dimensionColumn.DimID - 1].PK + " = " + dimensionColumn.values[0].ToString(); for (int i = 1; i < dimensionColumn.values.Count; i++) { command_Column += " OR ID = "; command_Column += dimensionColumn.values[i].ToString(); } SQLiteCommand comm_Column = new SQLiteCommand(command_Column, connection); SQLiteDataReader reader_Column = comm_Column.ExecuteReader(); //запрос для получения данных о фиксированном измерении string command = "SELECT * FROM " + allDimensions[fixedElement.DimID - 1].TableName + " WHERE " + allDimensions[fixedElement.DimID - 1].PK + " = " + fixedElement.FixID.ToString(); SQLiteCommand comm = new SQLiteCommand(command, connection); SQLiteDataReader reader = comm.ExecuteReader(); List <Attribute> AttributesFixed = new List <Attribute>(); AttributesFixed = allDimensions[fixedElement.DimID - 1].AttributesList; Console.WriteLine("------------------\nReport:"); foreach (DbDataRecord record in reader) { for (int num = 1; num < record.FieldCount; num++) { Console.WriteLine("{0}: {1}", AttributesFixed[num].Name, record[num]); } } Console.WriteLine(); Console.WriteLine("В таблице выводится {0}\n", facts.GetField(facts.Measure - 1).Name); // Console.Write("{0}\\{1}", dimensionRow.table_name, dimensionColumn.table_name); // Console.Write("\t "); foreach (DbDataRecord record_Column in reader_Column) { Console.Write("\t {0} {1}", record_Column[1], record_Column[2]); } Console.WriteLine(); int order = 0; Dimensions dimFixed = allDimensions[fixedElement.DimID - 1]; Dimensions dimColumn = allDimensions[dimensionColumn.DimID - 1]; Dimensions dimRow = allDimensions[dimensionRow.DimID - 1]; foreach (DbDataRecord record_Row in reader_Row) { string selection = "SELECT " + facts.GetField(facts.Measure - 1).RealName + " FROM " + facts.RealName + " WHERE " + facts.GetField(dimFixed.ID - 1).RealName + " = " + fixedElement.FixID.ToString() + " AND " + facts.GetField(dimRow.ID - 1).RealName + " = " + dimensionRow.values[order] + " AND "; Console.Write("{0} {1}|", record_Row[1], record_Row[2]); for (int l = 0; l < dimensionColumn.values.Count; l++) { string finalSelection = selection + facts.GetField(dimColumn.ID - 1).RealName + " = " + dimensionColumn.values[l].ToString(); SQLiteCommand result = new SQLiteCommand(finalSelection, connection); SQLiteDataReader prices = result.ExecuteReader(); Console.Write("\t "); foreach (DbDataRecord price in prices) { Console.Write("{0}", price[0]); } Console.Write("\t\t|"); } order++; Console.WriteLine("\n"); } Console.WriteLine("\n--------------------------------"); connection.Close(); }