Example #1
0
        public static void Parse(STreasureTable treasures_table)
        {
            string strColumnSearchName    = DBTableAttributtesFetcher.GetPrimaryKeyName(EDBTable.eTreasureTable);
            string strColumnRetriveName   = DBTableAttributtesFetcher.GetColumnsNames(EDBTable.eTreasureTable)[(int)EDBTreasureTableColumns.eATreasures];
            string strItemTypesTableSufix = DBTableAttributtesFetcher.GetNameSufix(EDBTable.eItemTypes);

            //Split the and entries first
            string strATreasures = App.DB.GetColumnValueFromMemoryTable(strColumnSearchName, treasures_table.ID, treasures_table.TableName, strColumnRetriveName);

            string [] strTableAndEntriesSplitted = strATreasures.Split(',');
            foreach (string strTableOrEntries in strTableAndEntriesSplitted)
            {
                List <object> treasureItems = new List <object>();

                //Split the or entries second
                string[] strTableOrEntriesSplitted = strTableOrEntries.Split('|');
                foreach (string strEntry in strTableOrEntriesSplitted)
                {
                    string[] strEntrySplitted = strEntry.Split('x');
                    //Translate the entry to the respective table
                    string strEntryID    = strEntrySplitted[(int)STreasureTableElement.EDataIndex.eID];
                    string strEntryTable = treasures_table.TableName;
                    ItemTypes.ItemTypes.GetFinalItemAndTableFromEncapsulatedItemAndTableWithSufix(ref strEntryID, ref strEntryTable, strItemTypesTableSufix);
                    //Now we need to check if it is a table or an item
                    string[] strEntryIDSplitted = strEntryID.Split('.');
                    //is an item in the format GroupID.SubgroupID
                    if (strEntryIDSplitted.Length == 2)
                    {
                        STreasureTableElement item = new STreasureTableElement(strEntryIDSplitted, strEntrySplitted, strEntryTable);
                        treasureItems.Add(item);
                    }
                    else if (string.IsNullOrEmpty(strEntryIDSplitted[0]) == false)
                    {
                        STreasureTable innerTresureTable = new STreasureTable(strEntryIDSplitted[0], strEntryTable, strEntrySplitted[(int)STreasureTableElement.EDataIndex.eProbability], strEntrySplitted[(int)STreasureTableElement.EDataIndex.eOccurrence]);
                        // Recursive parse tables, hopefully modders didn't create loop references in the treasure tables because I am not protecting them for now
                        Parse(innerTresureTable);
                        treasureItems.Add(innerTresureTable);
                    }
                }
                if (treasureItems.Count > 0)
                {
                    treasures_table.Elements.Add(treasureItems);
                }
            }
        }
Example #2
0
        private void LoadItemsWoker_DoWork(object sender, DoWorkEventArgs e)
        {
            //1st - Get from DB all data to fill the grid and save it on the list
            //Fetch this item data from DB
            ViewerTreeItemDescriptor selectedItem = Viewer.I.SelectedItem;

            _arrayDBValues = App.DB.GetAllDataOfAnItemFromMemory(selectedItem.PrimaryKeyValue, selectedItem.PrimaryKeyName, selectedItem.TableName);
            //Fill a list with the data so it can be shown on the DataGrid
            foreach (object columnValue in _arrayDBValues)
            {
                _dataGridItems.Add(new ViewerDataGridItem(DBTableAttributtesFetcher.GetColumnsNames(EDBTable.eTreasureTable)[_dataGridItems.Count], columnValue));
            }
            //2nd - Parse the treasure table data to a list
            _treasures = new STreasureTable(selectedItem.PrimaryKeyValue, selectedItem.TableName, "1.0", "1");
            Parse(_treasures);
            //3rd - Display the information on canvas
            CreateUpdateTreasurePanel();
        }
Example #3
0
        private FrameworkElement RenderTreasureTable(STreasureTable table, bool big_gui)
        {
            //Create a group box to group all treasures from this table
            GroupBox groupBox = new GroupBox();

            groupBox.Header = table.DisplayInfo;
            groupBox.HorizontalAlignment = HorizontalAlignment.Center;
            groupBox.Style = new Style();
            //Create a wrap pannel to wrap items/tables
            WrapPanel groupWrapPanel = new WrapPanel();

            groupWrapPanel.HorizontalAlignment = HorizontalAlignment.Center;
            groupWrapPanel.VerticalAlignment   = VerticalAlignment.Center;
            groupBox.Content = groupWrapPanel;

            foreach (List <object> listObj in table.Elements)
            {
                //if there is only one object we will add it directly to the wrap pannel
                //otherwise we will add it to a flip view
                if (listObj.Count == 1)
                {
                    FrameworkElement itemRendered = RenderObject(listObj[0], big_gui);
                    if (itemRendered != null)
                    {
                        groupWrapPanel.Children.Add(itemRendered);
                    }
                }
                else
                {
                    //we will make a list with all the images/tables
                    List <FrameworkElement> items = new List <FrameworkElement>();
                    foreach (object obj in listObj)
                    {
                        FrameworkElement itemRendered = RenderObject(obj, big_gui);
                        if (obj != null)
                        {
                            items.Add(itemRendered);
                        }
                    }
                    //If the other items didn't exist we will add this as an and item
                    if (items.Count == 1)
                    {
                        groupWrapPanel.Children.Add(items[0]);
                    }
                    else if (items.Count > 1)
                    {
                        //Create a flip view to aggregate all items images
                        FlipView flipView = new FlipView();
                        flipView.IsBannerEnabled         = false;
                        flipView.MouseHoverBorderEnabled = false;
                        flipView.CircularNavigation      = true;
                        flipView.ItemsSource             = items;
                        flipView.MinHeight = 0;
                        flipView.MinWidth  = 0;
                        flipView.HorizontalContentAlignment = HorizontalAlignment.Center;
                        flipView.VerticalContentAlignment   = VerticalAlignment.Center;
                        flipView.HorizontalAlignment        = HorizontalAlignment.Center;
                        flipView.VerticalAlignment          = VerticalAlignment.Center;
                        flipView.IsNavigationEnabled        = false;

                        NumericUpDown numericUpDown = new NumericUpDown();
                        numericUpDown.Style                      = FindResource("CustomNumericUpDownStyle") as Style;
                        numericUpDown.DataContext                = flipView;
                        numericUpDown.IsReadOnly                 = false;
                        numericUpDown.InterceptManualEnter       = false;
                        numericUpDown.Interval                   = 1;
                        numericUpDown.Minimum                    = 1;
                        numericUpDown.HorizontalAlignment        = HorizontalAlignment.Stretch;
                        numericUpDown.HorizontalContentAlignment = HorizontalAlignment.Center;
                        numericUpDown.VerticalAlignment          = VerticalAlignment.Center;
                        numericUpDown.VerticalContentAlignment   = VerticalAlignment.Center;
                        numericUpDown.PreviewKeyUp              += NumericUpDown_PreviewKeyUp;
                        numericUpDown.PreviewKeyDown            += NumericUpDown_PreviewKeyDown;
                        Binding maximumBinding = new Binding();
                        maximumBinding.Path = new PropertyPath("Items.Count");
                        maximumBinding.Mode = BindingMode.OneWay;
                        BindingOperations.SetBinding(numericUpDown, NumericUpDown.MaximumProperty, maximumBinding);
                        Binding valueBinding = new Binding();
                        valueBinding.Path      = new PropertyPath("SelectedIndex");
                        valueBinding.Mode      = BindingMode.TwoWay;
                        valueBinding.Converter = new Int32IndexToNumberConverter();
                        BindingOperations.SetBinding(numericUpDown, NumericUpDown.ValueProperty, valueBinding);

                        StackPanel stackPanel = new StackPanel();
                        stackPanel.HorizontalAlignment = HorizontalAlignment.Center;
                        stackPanel.VerticalAlignment   = VerticalAlignment.Center;
                        stackPanel.Children.Add(flipView);
                        stackPanel.Children.Add(numericUpDown);

                        groupWrapPanel.Children.Add(stackPanel);
                    }
                }
            }

            return(groupBox);
        }