protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            var service  = This.GetService <IOptionsService>();
            var contents = new List <IOptionsPanel>();

            if (service != null)
            {
                foreach (var id in service.OptionsPanels.Keys)
                {
                    var           creator = service.OptionsPanels[id];
                    IOptionsPanel content = null;
                    try { content = creator(); }
                    catch (Exception ex)
                    {
                        This.Logger.Error(string.Format(
                                              "Unable to instantiate panel {0}: {1}", id, ex.Message), ex);
                    }

                    if (content != null)
                    {
                        if (content is Control)
                        {
                            Control control = ((Control)content);
                            control.Margin = new Padding(3);
                            control.Dock   = DockStyle.Fill;
                            contents.Add(content);
                        }
                        else
                        {
                            This.Logger.Error(string.Format(
                                                  "Unable to load panel {0}: it is not a control.", id));
                        }
                    }
                    else
                    {
                        This.Logger.Error(string.Format(
                                              "Unable to instantiate panel {0}: returned instance is null.", id));
                    }
                }
            }
            else
            {
                var content = new GeneralOptionsPanel();
                content.Dock = DockStyle.Fill;
                contents.Add(content);
            }

            AddContents(contents.ToArray());
        }
Exemplo n.º 2
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            var service = This.GetService<IOptionsService>();
            var contents = new List<IOptionsPanel>();

            if (service != null)
            {
                foreach (var id in service.OptionsPanels.Keys)
                {
                    var creator = service.OptionsPanels[id];
                    IOptionsPanel content = null;
                    try { content = creator(); }
                    catch (Exception ex)
                    {
                        This.Logger.Error(string.Format(
                            "Unable to instantiate panel {0}: {1}", id, ex.Message), ex);
                    }

                    if (content != null)
                    {
                        if (content is Control)
                        {
                            Control control = ((Control)content);
                            control.Margin = new Padding(3);
                            control.Dock = DockStyle.Fill;
                            contents.Add(content);
                        }
                        else This.Logger.Error(string.Format(
                            "Unable to load panel {0}: it is not a control.", id));
                    }
                    else This.Logger.Error(string.Format(
                        "Unable to instantiate panel {0}: returned instance is null.", id));
                }
            }
            else
            {
                var content = new GeneralOptionsPanel();
                content.Dock = DockStyle.Fill;
                contents.Add(content);
            }

            AddContents(contents.ToArray());
        }