Beispiel #1
0
        /// <summary>
        /// Scans for issues.
        /// </summary>
        public void ScanForIssues()
        {
            if (_isValidationEnabled > 0)
            {
                return;
            }

            // Clear old list.
            ClearIssues();

            // Check settings.
            foreach (string project in DataEditorSettingsProxy.Default.ContentProjects)
            {
                if (!File.Exists(project))
                {
                    AddIssue("Path to content project is invalid: " + project, IssueType.Warning);
                }
            }

            // Check factories.
            foreach (var factory in FactoryManager.GetFactories())
            {
                ScanForIssues(factory);
            }

            // Check item pools.
            foreach (var pool in ItemPoolManager.GetItemPools())
            {
                ScanForIssues(pool);
            }
        }
Beispiel #2
0
        private void HandleCleared()
        {
            // Disable validation and tree updates (performance).
            ++_isValidationEnabled;
            tvData.BeginUpdate();

            // Clear the nodes.
            tvData.Nodes.Clear();

            // Create factory base type nodes in tree.
            foreach (var type in FactoryManager.GetFactoryTypes())
            {
                var baseType = type.BaseType;
                if (baseType != null && baseType != typeof(object))
                {
                    if (!tvData.Nodes.ContainsKey(baseType.AssemblyQualifiedName))
                    {
                        tvData.Nodes.Add(baseType.AssemblyQualifiedName, CleanFactoryName(baseType));
                    }
                    tvData.Nodes[baseType.AssemblyQualifiedName].Nodes.Add(type.AssemblyQualifiedName, CleanFactoryName(type));
                }
                else
                {
                    tvData.Nodes.Add(type.AssemblyQualifiedName, CleanFactoryName(type));
                }
            }

            // Create entries for pools.
            tvData.Nodes.Add(typeof(ItemPool).AssemblyQualifiedName, typeof(ItemPool).Name);
            tvData.Nodes.Add(typeof(AttributePool).AssemblyQualifiedName, typeof(AttributePool).Name);

            // Re-add existing data.
            foreach (var factory in FactoryManager.GetFactories())
            {
                HandleFactoryAdded(factory);
            }
            foreach (var pool in ItemPoolManager.GetItemPools())
            {
                HandleItemPoolAdded(pool);
            }
            foreach (var pool in AttributePoolManager.GetAttributePools())
            {
                HandleAttributePoolAdded(pool);
            }

            // Reenable tree updating and validation.
            tvData.EndUpdate();
            --_isValidationEnabled;

            // Rescan.
            ScanForIssues();
        }
Beispiel #3
0
        public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            var svc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));

            if (svc != null)
            {
                _list.Items.Clear();
                FactoryManager.GetFactories()
                .Where(factory => factory is SunFactory).ToList()
                .ForEach(factory => _list.Items.Add(factory.Name));
                if (_list.Items.Count == 0)
                {
                    return(value);
                }
                _list.Height = System.Math.Min(_list.Items.Count * _list.ItemHeight, _list.ItemHeight * 10);

                if (value != null)
                {
                    var item = _list.FindStringExact((string)value);
                    if (item >= 0)
                    {
                        _list.SelectedIndex = item;
                    }
                }
                EventHandler handler = (o, s) => svc.CloseDropDown();
                _list.SelectedIndexChanged += handler;
                svc.DropDownControl(_list);
                _list.SelectedIndexChanged -= handler;
                if (_list.SelectedItems.Count < 1)
                {
                    return(value);
                }
                return(_list.SelectedItems[0]);
            }
            return(value);
        }