One of my Tools->Options OptionsPad is larger than the default reserved space (right of the Options tree). I'm thinking I want to resize the options pad area to fit the larger pad. Currently the pad shows as being half truncated on the right. I'm not sure how to resize. Alternatively, I can break down the options into separate sub-items. I hesitate to do that as they are logically related.

Thinking out loud, maybe I should define an Initialize event using the pad's Xaml. In the Initialize event, I can find the parent Window, then adjust its Width and Height. ... More thinking ... maybe the best way to do this is to override the default OptionsDialog box. That would give me much more flexibility for resizing and also adding an Apply button. Is there a way to override without touching SoapBox source code?

asked 03 Jun '10, 12:48

BSalita's gravatar image

BSalita
276131417
accept rate: 22%

edited 13 Jun '10, 12:47

Scott%20Whitlock's gravatar image

Scott Whitlock ♦♦
696262833


Version 2010.06.13 of SoapBox Core now allows you to override the OptionsDialogView window with your own. If you don't provide one, it still loads the default. Here's how to create your own customized OptionsDialogView window:

  1. Start by going to this directory: trunkSoapBoxSoapBox.CoreSoapBox.Core.OptionsOptions
  2. Copy OptionsDialogView.xaml and OptionsDialogView.xaml.cs
  3. Paste them into your add-in
  4. You'll have to change the namespace in the .cs file, not to mention the xmlns lines and class name in the xaml file. There's also the fact that the xaml file depends on some resource strings from the SoapBox.Core.Options assembly, so you'll have to provide a reference to SoapBox.Core.Options in your add-in if you want to use those resource strings (Ok button text, etc.). Alternately, you can replace them with your own.
  5. In the .xaml.cs file, you have to Export your new view as a Window so SoapBox Core will find it and use it instead of the default one:

[Export(SoapBox.Core.ExtensionPoints.Options.OptionsDialog.View, typeof(Window))]
public partial class OptionsDialogView : Window
...

Then you can completely change the look and feel of the options dialog without affecting the functionality of it.

link

answered 13 Jun '10, 12:41

Scott%20Whitlock's gravatar image

Scott Whitlock ♦♦
696262833
accept rate: 50%

This is working for me with a couple exceptions.

  1. I'm using VB.Net. VB.Net members are case insensitive whereas C# is not. I had to change items() to OptionsItems().

    Private Property OptionItems() As IEnumerable(Of IOptionsItem) ' patch - 17-Jun-2010 - changed - Changed items to OptionsItems

(17 Jun '10, 10:47) BSalita
  1. I'm getting an error on the second launch of a dialog box. I believe the reason is that ShowDialog closes the Window. Because it's a MEF part, it doesn't get recreated on the next ShowDialog. It just errors out because the Window is closed. A possible solution is to Export a Window factory; the Export does a New Window and then a ShowDialog on it. This is familiar to me as I had the problem with my own code. The nice people on StackOverflow suggested this solution although I haven't tested it.
(17 Jun '10, 10:47) BSalita

@BSalita: Good info, I'll look into it. Thanks!

(17 Jun '10, 12:36) Scott Whitlock ♦♦

I don't really see a work-around at the moment. I have two options:

  1. Either I modify OptionsDialog to add Width and Height properties, which will control the width and height of the window. You can get a reference to it like this:

    [Import(CompositionPoints.Options.OptionsDialog, typeof(OptionsDialog))]
    private OptionsDialog optionsDialog { get; set; }
    
  2. ...or I can add an extension point in OptionsDialog.ShowDialog() that lets you grab a reference to the window that's opening and hook in some artibrary IExecutableCommand extensions.

I guess I could always do both too... let me know which you prefer.

link

answered 03 Jun '10, 20:58

Scott%20Whitlock's gravatar image

Scott Whitlock ♦♦
696262833
accept rate: 50%

Implementing 1., adding Width and Height, looks like it will resolve the main problem of resizing. There's still the lesser issue of adding an Apply button and who know what else.

Maybe it would be better to do one of the following:
1. Exposing OptionsWindowOpening event that will allow overriding of default options dialog window.
2. Implementing [Import(CompositionPoints.Options.OptionsDialogOverride, typeof(OptionsDialog))], that will be invoked in place of OptionsDialog. To make that work, ImportMany can be used. If the Import count is non-zero, call it in lieu of OptionsDialog.
3. Is there another way to handle weak Imports? Hmmm, yes, by adding a priority/preferred/overrides attribute in metadata combined with use of ImportMany. This would eliminate the need for a new CompositionPoint. The invoking routine would choose the preferred Export. Mef provides a mechanism for an attribute to be retrieved without invoking the constructor, I believe. Maybe a mechanism like this should be used routinely for any place where the SoapBox client may wish to extend.

link

answered 04 Jun '10, 06:38

BSalita's gravatar image

BSalita
276131417
accept rate: 22%

edited 04 Jun '10, 12:19

Scott%20Whitlock's gravatar image

Scott Whitlock ♦♦
696262833

Maybe the direction we need to go is to not provide a default Export for OptionsDialog. Then in your app, you create a concrete OptionsDialog that inherits from AbstractOptionsDialog. It will automatically use the default AbstractOptionsDialogView, unless you provide a new View for your concrete class.

(04 Jun '10, 12:23) Scott Whitlock ♦♦

Right, that might be the most elegant answer.

(04 Jun '10, 13:02) BSalita
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×17
×11
×4
×4
×1
×1

Asked: 03 Jun '10, 12:48

Seen: 2,015 times

Last updated: 17 Jun '10, 12:36

powered by OSQA