Exemplo n.º 1
0
        public void AddOptionPage(IOptionPage aPage)
        {
            lock (iOptionPages)
            {
                if (aPage.Name == "General" || aPage.Name == "Network")
                {
                    if (iOptionPages.Count > 0 && iOptionPages[0].Name == "General")
                    {
                        iOptionPages.Insert(1, aPage);
                    }
                    else
                    {
                        iOptionPages.Insert(0, aPage);
                    }
                }
                else
                {
                    iOptionPages.Add(aPage);
                }
            }

            foreach (Option o in aPage.Options)
            {
                iOptionManager.Add(o);
            }

            aPage.EventOptionAdded   += OptionPageOptionAdded;
            aPage.EventOptionRemoved += OptionPageOptionRemoved;
            aPage.EventChanged       += OptionPageChanged;

            OnEventOptionPagesChanged();
        }
Exemplo n.º 2
0
        public OptionsDialog()
        {
            InitializeComponent();
#if DEBUG
            this.AttachDevTools();
#endif
            // These used to have [ImportMany(..., RequiredCreationPolicy = CreationPolicy.NonShared)], so they use their own
            // ExportProvider instance.
            // FIXME: Ideally, the export provider should be disposed when it's no longer needed.
            var ep = App.ExportProviderFactory.CreateExportProvider();
            this.optionPages = ep.GetExports <IControl, IOptionsMetadata>("OptionPages").ToArray();
            ILSpySettings settings = ILSpySettings.Load();
            var           tabItems = new List <TabItem>();
            foreach (var optionPage in optionPages.OrderBy(p => p.Metadata.Order))
            {
                TabItem tabItem = new TabItem();
                tabItem.Header  = MainWindow.GetResourceString(optionPage.Metadata.Title);
                tabItem.Content = optionPage.Value;
                tabItems.Add(tabItem);

                IOptionPage page = optionPage.Value as IOptionPage;
                if (page != null)
                {
                    page.Load(settings);
                }
            }
            tabControl.Items = tabItems;
        }
Exemplo n.º 3
0
        public OptionPageMonobjc(IOptionPage aOptionsPage, NSRect aFrameRect)
        {
            iName = aOptionsPage.Name;

            iView = new NSView(aFrameRect);

            iControls = new List <IOptionMonobjc>();

            float y   = iView.Frame.Height - 10;
            float mid = iView.Frame.Width * 0.5f;

            foreach (Option option in aOptionsPage.Options)
            {
                NSTextField label = new NSTextField();
                label.SetTitleWithMnemonic(new NSString(option.Name + ":"));
                label.IsSelectable    = false;
                label.IsEditable      = false;
                label.IsBordered      = false;
                label.DrawsBackground = false;
                label.Alignment       = NSTextAlignment.NSLeftTextAlignment;
                label.SizeToFit();
                label.Frame = new NSRect(10, y - label.Frame.Height, mid - 20, label.Frame.Height);

                iView.AddSubview(label);

                IOptionMonobjc o = null;

                if (option is OptionEnum || option is OptionNetworkInterface)
                {
                    o = new OptionNetworkInterfaceMonobjc(new NSRect(mid, y, mid - 10, 20), option);
                }
                else if (option is OptionFilePath)
                {
                    o = new OptionFilePathMonobjc(new NSRect(mid, y, mid - 10, 20), option);
                }
                else if (option is OptionFolderPath)
                {
                    o = new OptionFolderPathMonobjc(new NSRect(mid, y, mid - 10, 20), option);
                }
                else if (option is OptionBool)
                {
                    o = new OptionBoolMonobjc(new NSRect(mid, y, mid - 10, 20), option);
                }
                else if (option is OptionListFolderPath)
                {
                    o = new OptionListFolderPathMonobjc(new NSRect(mid, y, mid - 10, 20), option);
                }

                if (o != null)
                {
                    iView.AddSubview(o.View);
                    y -= o.Height;
                    iControls.Add(o);
                }
            }
        }
Exemplo n.º 4
0
 private void ButtonResetClick(object sender, EventArgs e)
 {
     if (TreeViewOptions.SelectedNode != null)
     {
         OptionPageWinForms winformPage = TreeViewOptions.SelectedNode.Tag as OptionPageWinForms;
         IOptionPage        page        = winformPage.OptionPage;
         foreach (Option o in page.Options)
         {
             o.ResetToDefault();
         }
     }
 }
Exemplo n.º 5
0
 public OptionPageViewModel(HierarchicalViewModel aParent, IOptionPage aWrappedOptionPage, Dispatcher aDispatcher)
     : base(aParent)
 {
     Name    = aWrappedOptionPage.Name;
     Options = new List <OptionViewModel>();
     foreach (Option o in aWrappedOptionPage.Options)
     {
         OptionViewModel model = OptionViewModelFactory.Create(o);
         model.Dispatcher = aDispatcher;
         Options.Add(model);
     }
 }
Exemplo n.º 6
0
        public OptionPageWinForms(int aWidth, IOptionPage aOptionPage)
        {
            iLabels             = new List <Label>();
            iOptions            = new List <IOptionWinForms>();
            iOptionPage         = aOptionPage;
            iControl            = new ContainerControl();
            iControl.AutoScroll = true;

            // set the width of the page control before any children are added
            iControl.Width = aWidth;
            iControl.Dock  = DockStyle.Fill;

            for (int i = 0; i < iOptionPage.Options.Count; i++)
            {
                Option option = iOptionPage.Options[i];

                // create the option control
                IOptionWinForms optionWinform = null;

                if (option is OptionEnum || option is OptionNetworkInterface)
                {
                    optionWinform = new OptionWinFormsEnumerated(option);
                }
                else if (option is OptionBool)
                {
                    optionWinform = new OptionWinFormsBool(option);
                }
                else if (option is OptionFilePath ||
                         option is OptionFolderPath ||
                         option is OptionColor ||
                         option is OptionListFolderPath)
                {
                    throw new NotImplementedException();
                }

                if (optionWinform != null)
                {
                    // create the label control
                    Label labelControl = new Label();
                    labelControl.Text      = option.Name + ":";
                    labelControl.TextAlign = ContentAlignment.TopLeft;

                    iControl.Controls.Add(labelControl);
                    iControl.Controls.Add(optionWinform.Control);

                    iLabels.Add(labelControl);
                    iOptions.Add(optionWinform);
                }
            }

            // now update the layout of all controls
            UpdateLayout();
        }
Exemplo n.º 7
0
 void OKButton_Click(object sender, RoutedEventArgs e)
 {
     ILSpySettings.Update(
         delegate(XElement root) {
         foreach (var optionPage in optionPages)
         {
             IOptionPage page = optionPage.Value as IOptionPage;
             if (page != null)
             {
                 page.Save(root);
             }
         }
     });
     this.DialogResult = true;
     Close();
 }
Exemplo n.º 8
0
        public void RemoveOptionPage(IOptionPage aPage)
        {
            aPage.EventOptionAdded   -= OptionPageOptionAdded;
            aPage.EventOptionRemoved -= OptionPageOptionRemoved;
            aPage.EventChanged       -= OptionPageChanged;

            foreach (Option o in aPage.Options)
            {
                iOptionManager.Remove(o);
            }
            lock (iOptionPages)
            {
                iOptionPages.Remove(aPage);
            }
            OnEventOptionPagesChanged();
        }
Exemplo n.º 9
0
        public OptionsDialog()
        {
            InitializeComponent();
            App.CompositionContainer.ComposeParts(this);
            ILSpySettings settings = ILSpySettings.Load();

            foreach (var optionPage in optionPages)
            {
                TabItem tabItem = new TabItem();
                tabItem.Header  = optionPage.Metadata.Title;
                tabItem.Content = optionPage.Value;
                tabControl.Items.Add(tabItem);

                IOptionPage page = optionPage.Value as IOptionPage;
                if (page != null)
                {
                    page.Load(settings);
                }
            }
        }
Exemplo n.º 10
0
        public OptionPageWinForms(int aWidth, IOptionPage aOptionPage, Control aHelpTextControl)
        {
            iOptions            = new List <IOptionWinForms>();
            iOptionPage         = aOptionPage;
            iControl            = new ContainerControl();
            iControl.AutoScroll = true;
            iHelpTextControl    = aHelpTextControl;

            // set the width of the page control before any children are added
            iControl.Width = aWidth;

            int labelWidth  = aWidth / 2;
            int optionWidth = aWidth - labelWidth;
            int currentY    = 0;

            for (int i = 0; i < iOptionPage.Options.Count; i++)
            {
                Option option = iOptionPage.Options[i];

                // create the label for the option
                Label labelControl = new Label();
                labelControl.AutoSize  = false;
                labelControl.Text      = option.Name;
                labelControl.TextAlign = ContentAlignment.MiddleLeft;

                // create the option control
                IOptionWinForms optionWinform = null;

                if (option is OptionEnum || option is OptionNetworkInterface || option is OptionBoolEnum)
                {
                    optionWinform = new OptionWinFormsEnumerated(option);
                }
                else if (option is OptionFilePath)
                {
                    optionWinform = new OptionWinFormsFilePath(option, optionWidth);
                }
                else if (option is OptionFolderPath)
                {
                    optionWinform = new OptionWinFormsFolderPath(option, optionWidth);
                }
                else if (option is OptionFolderName)
                {
                    optionWinform = new OptionWinFormsFolderName(option, optionWidth);
                }
                else if (option is OptionUri)
                {
                    optionWinform = new OptionWinFormsUri(option, optionWidth);
                }
                else if (option is OptionBool)
                {
                    optionWinform = new OptionWinFormsBool(option);
                }
                else if (option is OptionColor)
                {
                    optionWinform = new OptionWinFormsARGB(option);
                }
                else if (option is OptionListFolderPath)
                {
                    optionWinform = new OptionWinFormsListFolderPath(option, optionWidth);
                }
                else if (option is OptionInt)
                {
                    optionWinform = new OptionWinFormsInt(option);
                }
                else if (option is OptionUint)
                {
                    optionWinform = new OptionWinFormsUint(option);
                }
                else if (option is OptionNumber)
                {
                    optionWinform = new OptionWinFormsNumber(option);
                }
                else if (option is OptionString)
                {
                    optionWinform = new OptionWinFormsString(option);
                }

                // calculate positioning of the controls
                if (optionWinform != null)
                {
                    iOptions.Add(optionWinform);
                    Control optionControl = optionWinform.Control;

                    labelControl.Location = new Point(0, currentY);
                    labelControl.Anchor   = AnchorStyles.Left | AnchorStyles.Top;
                    labelControl.TabStop  = false;
                    labelControl.Width    = labelWidth;
                    labelControl.Height   = optionControl.Height;

                    optionControl.Location = new Point(labelWidth, currentY);
                    optionControl.Width    = optionWidth;
                    optionControl.Anchor   = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right;
                    optionControl.TabStop  = true;
                    optionControl.TabIndex = i;

                    if (aHelpTextControl != null)
                    {
                        labelControl.Tag     = optionControl;
                        labelControl.Click  += SelectOptionLabel;
                        optionControl.Tag    = labelControl;
                        optionControl.Name   = option.Description;
                        optionControl.Enter += SelectOption;
                        optionControl.Leave += DeselectOption;
                    }

                    iControl.Controls.Add(labelControl);
                    iControl.Controls.Add(optionControl);

                    currentY += optionControl.Height;
                }
            }
        }
Exemplo n.º 11
0
 public OptionPageWinForms(int aWidth, IOptionPage aOptionPage)
     : this(aWidth, aOptionPage, null)
 {
 }