Example #1
0
        // Used by LoadProfile, shouldn't be used seperately.
        private void _PartialLoad(StackPanel sp, Dictionary <string, Dictionary <string, string> > pData)
        {
            try
            {
                // Careful, this assumes that the stackpanel's only children are ProfileCreatorEntries
                foreach (object pceObj in sp.Children)
                {
                    ProfileCreatorEntry pce = (ProfileCreatorEntry)pceObj;

                    // Attempt to find a defined sqlKey for this appKEy in the profile segment.
                    var matchTables = pData.Where(dd => dd.Value
                                                  .Where(keys => keys.Key == pce.AppKey).Count() > 0
                                                  );

                    // No match found, clear the sqlKey and tablename and disable
                    if (matchTables.Count() == 0)
                    {
                        pce.SqlKey     = "";
                        pce.TableName  = "";
                        pce.IsIncluded = false;
                    }
                    else // Match found, set known values to ui
                    {
                        pce.TableName  = matchTables.First().Key;
                        pce.SqlKey     = matchTables.First().Value.Where(kvp => kvp.Key == pce.AppKey).First().Value; // I'm too deep in to change the structure now :P
                        pce.IsIncluded = true;
                    }
                }
            }
            catch
            {
                Logger.Log("There was a problem loading this profile into the UI. Is the profile valid for this version of TrinityCreator?", Logger.Status.Error);
            }
        }
Example #2
0
        private void addCustomFieldBtn_Click(object sender, RoutedEventArgs e)
        {
            var ne = new ProfileCreatorEntry();

            CustomFieldsElements.Add(ne);
            customFieldsSp.Children.Add(ne);
        }
Example #3
0
        // Load an existing profile into the UI
        private void LoadProfile(Profile p)
        {
            // Load metadata
            EditingProfile = p;
            DataContext    = EditingProfile;

            // Call partial loads for each creator
            _PartialLoad(creatureSp, p.Creature);
            _PartialLoad(questSp, p.Quest);
            _PartialLoad(itemSp, p.Item);
            _PartialLoad(lootSp, p.Loot);
            _PartialLoad(vendorSp, p.Vendor);
            _PartialLoadDefinitions(definitionsSp, p.Definitions);

            // Manually set metadata fields because faster

            // Add Custom Fields
            customFieldsSp.Children.Clear();
            CustomFieldsElements.Clear();
            foreach (var custFieldPair in p.CustomFields)
            {
                foreach (var keys in custFieldPair.Value)
                {
                    // Prepare the ProfileCreatorEntry
                    var ne = new ProfileCreatorEntry();
                    ne.AppKey     = keys.Key;
                    ne.SqlKey     = keys.Value;
                    ne.TableName  = custFieldPair.Key;
                    ne.IsIncluded = true;

                    // Add them to UI
                    CustomFieldsElements.Add(ne);
                    customFieldsSp.Children.Add(ne);
                }
            }
        }