示例#1
0
 private void dataGridInstances_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (dataGrid.SelectedItem != null && Main != null)
     {
         TGIRecord record = dataGrid.SelectedItem as TGIRecord;
         SimCityPak.Views.ViewSearchProperties res = new SimCityPak.Views.ViewSearchProperties(Main, record.HexId, null, true);
         res.Show();
     }
 }
        public ViewPropertyRegistryRecord(TGIRecord record)
        {
            InitializeComponent();

            _record = record;

            txtId.Text          = _record.HexId;
            txtDisplayName.Text = _record.DisplayName;
            txtComment.Text     = _record.Comments;
        }
示例#3
0
 private void InstanceRegistryChanged(object sender, TGIRecord record)
 {
     foreach (DatabaseIndex i in Indices)
     {
         if (record.Id == i.InstanceId)
         {
             i.InstanceName = record.DisplayName;
         }
     }
     Indices.Changed();
 }
        private void button1_Click(object sender, RoutedEventArgs e)
        {
            IFormatProvider format = CultureInfo.CurrentCulture;

            uint id;
            bool isValid = true;

            if (txtId.Text.ToLower().StartsWith("0x"))
            {
                isValid &= UInt32.TryParse(txtId.Text.Trim().Substring(2), NumberStyles.AllowHexSpecifier, format, out id);
            }
            else
            {
                isValid &= UInt32.TryParse(txtId.Text.Trim(), NumberStyles.Number, format, out id);
            }

            //deals with the mass import - not needed to be used, usually hidden, but don't delete
            if (!string.IsNullOrEmpty(txtImport.Text))
            {
                foreach (string line in txtImport.Text.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries))
                {
                    string[] items        = line.Split(new string[] { "  " }, StringSplitOptions.RemoveEmptyEntries);
                    string   propertyName = items[0].Trim().Substring("property ".Length);
                    string   keyId        = items[1].Trim().Substring(0, 10);
                    string   description  = string.Empty;
                    if (items.Length > 2)
                    {
                        description = items[2].Trim();
                    }

                    TGIRecord record = new TGIRecord();
                    record.Id          = UInt32.Parse(keyId.Trim().Substring(2), NumberStyles.AllowHexSpecifier, format);
                    record.DisplayName = propertyName.Trim();
                    record.Comments    = description;

                    TGIRegistry.Instance.Instances.InsertRecord(record);
                }
            }

            if (isValid)
            {
                _record.Id          = id;
                _record.DisplayName = txtDisplayName.Text.TrimEnd();
                _record.Comments    = txtComment.Text.TrimEnd();

                //if (!TGIRegistry.Instance.Instances.Cache.ContainsKey(id))
                //{
                TGIRegistry.Instance.Properties.InsertRecord(_record);
                //}


                this.Close();
            }
        }
示例#5
0
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            TGIRecord newRecord = new TGIRecord();

            newRecord.Id       = _index.InstanceId;
            newRecord.Name     = txtDisplayName.Text;
            newRecord.Comments = txtComment.Text;

            TGIRegistry.Instance.Instances.InsertRecord(newRecord);

            //FIXME Hidden should be added..?
            this.Close();
        }
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            bool isValid = true;

            if (cbPropertyName.SelectedItem != null)
            {
                TGIRecord registry = (TGIRecord)cbPropertyName.SelectedItem;
                PropertyId = registry.Id;
            }
            else
            {
                IFormatProvider format = CultureInfo.CurrentCulture;
                uint            id;
                if (cbPropertyName.Text.ToLower().StartsWith("0x"))
                {
                    isValid &= UInt32.TryParse(cbPropertyName.Text.Trim().Substring(2), NumberStyles.AllowHexSpecifier, format, out id);
                }
                else
                {
                    isValid &= UInt32.TryParse(cbPropertyName.Text.Trim(), NumberStyles.Number, format, out id);
                }
                if (isValid)
                {
                    PropertyId = id;
                }
            }

            if (isValid)
            {
                Type selectedPropertyType = (Type)cbTypeName.SelectedItem;
                PropertyType = selectedPropertyType;

                IsArray = chkIsArray.IsChecked.GetValueOrDefault(false);

                this.DialogResult = true;
                this.Close();
            }
        }
        void backgroundWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker worker = sender as BackgroundWorker;

            while (_cacheReady == false) // wait for cache to be ready
            {
                Thread.Sleep(100);
            }

            while (_keywordHashes.Count > _currentKeywordHash && !_interrupted)
            {
                KeyValuePair <uint, string> keywordHash;
                lock (_keywordHashes) { keywordHash = _keywordHashes.ElementAt(_currentKeywordHash++); }

                if (_keywordHashes != null && _cacheInstances.Contains(keywordHash.Key)) // search currently loaded Instance ID's for possible matches against our hash database
                {
                    TGIRecord newRecord = new TGIRecord();
                    newRecord.DisplayName = keywordHash.Value;
                    newRecord.Id          = keywordHash.Key;

                    if (newRecord.Id != 0)
                    {
                        if (TGIRegistry.Instance.Instances.Cache.ContainsKey(newRecord.Id))
                        {
                            TGIRecord currentRecord = new TGIRecord();

                            if (TGIRegistry.Instance.Instances.Cache.TryGetValue(newRecord.Id, out currentRecord) && // if entry exists
                                currentRecord.Name.ToLowerInvariant() == newRecord.Name.ToLowerInvariant())          // and if it's a dupe
                            {
                                _countDupe++;
                            }
                            else // not a dupe, but still a new value. Going to overwrite it!
                            {
                                newRecord.Comments = currentRecord.Name; // adds old value to the comments
                                TGIRegistry.Instance.Instances.InsertRecord(newRecord);
                                _countAdded++;
                            }
                        }
                        else
                        {
                            TGIRegistry.Instance.Instances.InsertRecord(newRecord);
                            _countAdded++;
                        }
                    }
                }
                else if (_cacheGroups.Contains(keywordHash.Key)) // search currently loaded Group Container ID's for possible matches against our hash database
                {
                    TGIRecord newRecord = new TGIRecord();
                    newRecord.DisplayName = keywordHash.Value;
                    newRecord.Id          = keywordHash.Key;

                    if (newRecord.Id != 0)
                    {
                        if (TGIRegistry.Instance.Groups.Cache.ContainsKey(newRecord.Id))
                        {
                            TGIRecord currentRecord = new TGIRecord();
                            TGIRegistry.Instance.Groups.Cache.TryGetValue(newRecord.Id, out currentRecord);

                            if (currentRecord.Name.ToLowerInvariant() == newRecord.Name.ToLowerInvariant()) // is it a valid one?
                            {
                                _countDupe++;
                            }
                            else // always add when importing group names (no way to validate them)
                            {
                                newRecord.Comments = currentRecord.Name;
                                TGIRegistry.Instance.Groups.InsertRecord(newRecord);
                                _countAdded++;
                            }
                        }
                        else
                        {
                            TGIRegistry.Instance.Groups.InsertRecord(newRecord);
                            _countAdded++;
                        }
                    }
                }
                else if (_cacheProperties.Contains(keywordHash.Key)) // search currelty loaded Property Key ID's for possible matches against our hash database
                {
                    TGIRecord newRecord = new TGIRecord();
                    newRecord.DisplayName = keywordHash.Value;
                    newRecord.Id          = keywordHash.Key;

                    if (newRecord.Id != 0)
                    {
                        if (TGIRegistry.Instance.Properties.Cache.ContainsKey(newRecord.Id))
                        {
                            TGIRecord currentRecord = new TGIRecord();
                            TGIRegistry.Instance.Properties.Cache.TryGetValue(newRecord.Id, out currentRecord);

                            if (currentRecord.Name.ToLowerInvariant() == newRecord.Name.ToLowerInvariant()) // is it a valid one?
                            {
                                _countDupe++;
                            }
                            else // names do not match, is the old one even a FNV valid one?
                            {
                                newRecord.Comments = currentRecord.DisplayName;
                                TGIRegistry.Instance.Properties.InsertRecord(newRecord);
                                _countAdded++;
                            }
                        }
                        else
                        {
                            TGIRegistry.Instance.Properties.InsertRecord(newRecord);
                            _countAdded++;
                        }
                    }
                }

                // report back our progress..
                worker.ReportProgress((int)(((float)_countNameHashesDone++ / (float)_countTotalKeywords) * 100));
                _statusText = "Searching hashes (" + _countNameHashesDone.ToString() + "/" + _countTotalKeywords + "), added: " + _countAdded + " dupes: " + _countDupe;
            }
        }