Пример #1
0
        /// <summary>
        /// Function to read the current settings into their respective controls.
        /// </summary>
        public override void InitializeSettings()
        {
            if (_pendingDisabled == null)
            {
                _pendingDisabled = new HashSet <string>(StringComparer.OrdinalIgnoreCase);
                _sysDisabled     = new HashSet <string>(StringComparer.OrdinalIgnoreCase);

                // Get user plug-in disabled names.
                foreach (var plugInName in Program.Settings.DisabledPlugIns)
                {
                    if (_pendingDisabled.Contains(plugInName))
                    {
                        continue;
                    }

                    _pendingDisabled.Add(plugInName);
                }

                // Get system disabled plug-ins.
                foreach (var plugIn in Gorgon.PlugIns.Where(item => (item is GorgonFileSystemProviderPlugIn || item is EditorPlugIn) &&
                                                            (!_pendingDisabled.Contains(item.Name)) &&
                                                            (PlugIns.IsDisabled(item))))
                {
                    if (_sysDisabled.Contains(plugIn.Name))
                    {
                        continue;
                    }

                    _sysDisabled.Add(plugIn.Name);
                }
            }

            listContentPlugIns.BeginUpdate();
            listDisabledPlugIns.BeginUpdate();

            listDisabledPlugIns.Items.Clear();
            listContentPlugIns.Items.Clear();

            foreach (var plugIn in Gorgon.PlugIns)
            {
                if ((!(plugIn is EditorPlugIn)) &&
                    (!(plugIn is GorgonFileSystemProviderPlugIn)))
                {
                    continue;
                }

                var item = new ListViewItem
                {
                    Name = plugIn.Name,
                    Text = plugIn.Description,
                    Tag  = plugIn
                };

                if (plugIn is ContentPlugIn)
                {
                    item.SubItems.Add(Resources.GOREDIT_TEXT_CONTENT);
                }

                if (plugIn is FileWriterPlugIn)
                {
                    item.SubItems.Add(Resources.GOREDIT_TEXT_FILE_WRITER);
                }

                if (plugIn is GorgonFileSystemProviderPlugIn)
                {
                    item.SubItems.Add(Resources.GOREDIT_TEXT_FILE_READER);
                }

                if (_pendingDisabled.Contains(plugIn.Name))
                {
                    item.SubItems[1].Text = Resources.GOREDIT_TEXT_DISABLED;
                    item.ForeColor        = Color.FromKnownColor(KnownColor.DimGray);
                }
                else if (_sysDisabled.Contains(plugIn.Name))
                {
                    item.SubItems[1].Text = Resources.GOREDIT_TEXT_ERROR;
                    item.ForeColor        = Color.DarkRed;

                    // We've got a disabled plug-in, add to the secondary list view
                    // to show why the plug-in was disabled.
                    var disabledItem = new ListViewItem
                    {
                        Name = plugIn.Name,
                        Text = plugIn.Description,
                        Tag  = plugIn
                    };

                    disabledItem.SubItems.Add(PlugIns.GetDisabledReason(plugIn));
                    disabledItem.SubItems.Add(plugIn.PlugInPath);

                    listDisabledPlugIns.Items.Add(disabledItem);
                }

                item.SubItems.Add(plugIn.PlugInPath);

                listContentPlugIns.Items.Add(item);
            }

            listContentPlugIns.EndUpdate();
            listContentPlugIns.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
            listDisabledPlugIns.EndUpdate();
            listDisabledPlugIns.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
        }