This project is read-only.

Using the individual Signum.Windows Controls out of the box

Jul 3, 2012 at 12:08 PM

Hi all,

Up to now, I used the various controls (EntityLine, ValueLine, DataBorder etc ...) within a NormalWindow, through the Navigator manager. Now I would like to create a custom Window,  but I would still use the controls (ValueLine, EntityCombo, Common.Route...) attached to some Entity using the MVVM pattern. Is there a way to do this?


Jul 3, 2012 at 9:38 PM

You definitely can use the controls by setting all the necessary properties yourself:

* Binding Entity/Value
* Setting LabelText
* Setting Implementations (if necessary)
* Setting View and Find if necessary
* Setting m:Common.IsReadonly if necessary
* Etc (see Signum.Window.Common.TaskXXX for a comprehensive list)

Alternatively, you could set the TypeContext on your window (just like you do in your custom controls) and use m:Common.Route (this is what we do most of the time).

Not sure how it will work with MVVM, bus if you have a complex window you can build an entity that represents the Model by making it inherit from ModelEntity instead of Entity. This way you getthe biding/notification/validations infrastructure out of the box. 

Hope it helps 

Jul 4, 2012 at 12:06 PM

Hi Olmo,

thank you for your suggestions.

I do not have fully understood the first example, but with the second, setting the DataContext properly, it works. My wish is to switch from "Window" navigation, to the "Page" navigation.

Bye

Jul 4, 2012 at 12:26 PM

When you use m:Common.Route, a set of properties are set on the controls. m:Common.route is a shortcut so let the runtime set them for you, and this infrastructure is extensible.

If what you want is that there's some special control to contain EntityLines/ValueLines etc... (a Wizard for example), the last answer is the way to go. 

If what you want is to replace NormalWindow by NormalPage or NormalTab  or something like this, that integrates in your application without opening popups all the time, take a look to NavigationManager class, and override it with your own version. This way whenever you do Navigation.View a tab will be created. 

We could have an Skype support session if you find it necessary. 

Jul 4, 2012 at 12:41 PM
Olmo wrote:

If what you want is to replace NormalWindow by NormalPage or NormalTab  or something like this, that integrates in your application without opening popups all the time, take a look to NavigationManager class, and override it with your own version. This way whenever you do Navigation.View a tab will be created. 

We could have an Skype support session if you find it necessary. 

We would be very interested in the outcome of that Skype session :-)

Jul 4, 2012 at 2:35 PM

I also try to personalize the NavigationManager. About Skype, unfortunately I have trouble talking in English.

Thanks a lot. See you soon.

Jul 24, 2012 at 2:27 PM

@angabanga: Any luck yet implementing your own NavigationManager ?

Jul 24, 2012 at 4:34 PM

Its a matter of reading NavigationManager source control and override the necessary methods so it works creating tabs on your main window with a searchcontrol on it/ or creating some NormalTab that mimics NormalWindow for viewing entities.  

Jul 25, 2012 at 5:03 PM

Hi Olmo,

I'll explain in short what I did:

I've added two classes: NormalUserControl and SearchUserControl derived from UserControl with some adjustments (Title, DialogResult, etc..)

In NavigationManager I have duplicated "Explore", "Navigate", "Search" with "ExploreUserControl" etc.

To do this I introduce some variables: TaskSearchUserControl, TaskNormalUserControl.

A trick: to allow close correctly, tho delegates:    

        public Action<BaseUserControl> UserControlLoad;
        public Action<object, EventArgs> UserControlClose;

An example: in SearchUSerControl method, finally I call:

            SearchUserControl sw = CreateSearchUserControl(options);

            if (options.Closed != null)
                sw.Closed += options.Closed;
            if (UserControlClose != null)
                sw.Closed += new EventHandler(UserControlClose);
            if (UserControlLoad != null)
                UserControlLoad(sw);

Finally in my startup window


            Navigator.Manager.UserControlLoad = MyApplication.Instance().OpenTab;
            Navigator.Manager.UserControlClose = MyApplication.Instance().CloseTab;

that's all in short, but obviously the real work was much more difficult.

Bye.

Jul 25, 2012 at 6:01 PM

Hi angabanga. 

A few questions about your implementation: 

You said you have duplicated Explore, Navigate etc... with ExploreUserControl...

Did you inherit from NavigationManager, or did you modify the source code?

I recommend the first option, otherwise you will have troubles getting the latest version from Signum Framework

 

Why you preferred to duplicate the methods over overriding it?

Otherwise the entitylines and the rest of the framework won't use your methods. 

 

Once you override it, you can make your own navigation manager know about MyApplication.Instance() with no events in between.

Cheers.


Jul 26, 2012 at 8:05 PM

Oh boys, I had not thought to inherit NavigationManager.

My implementation then is incomplete. I have not resolved yet.

However I need to duplicate these methods (perhaps in a partial class), because the return values ​​of functions are different.

 

For example:

public virtual void Explore(ExploreOptions options)

{

	AssertFindable(options.QueryName);

	if (options.NavigateIfOne)

	{

	Lite lite = FindUnique(new FindUniqueOptions(options.QueryName)

	{

		FilterOptions = options.FilterOptions,

		UniqueType = UniqueType.Only,
	
	});

	if (lite != null)

	{

		Navigate(lite, new NavigateOptions());

		return;

	}

}

SearchWindow sw = CreateSearchWindow(options);

if (options.Closed != null)

sw.Closed += options.Closed;

sw.Show();

}

becomes:

		
		public virtual BaseUserControl ExploreControl(ExploreOptions options)
		{
			AssertFindable(options.QueryName);

			if (options.NavigateIfOne)
			{
				Lite lite = FindUnique(new FindUniqueOptions(options.QueryName)
				{
					FilterOptions = options.FilterOptions,
					UniqueType = UniqueType.SingleOrMany,
				});

				if (lite != null)
				{
					return NavigateControl(lite, new NavigateOptions());
				}
			}

			SearchUserControl sw = CreateSearchUserControl(options);

			if (options.Closed != null)
				sw.Closed += options.Closed;
			if (UserControlClose != null)
				sw.Closed += new EventHandler(UserControlClose);
			if (UserControlLoad != null)
				UserControlLoad(sw);

			return sw;
		}


 Bye

Jul 27, 2012 at 7:53 PM

Why you need to return the control ? Navigator.Explore/Find/Navigate/View are Facade of the framework.

There's plenty of code that relies on  this signature but you are free to implement it however you want. 

If you inherit from NavigationManager, you can add a field that references your main window and then add/ removes tabs without returning anything. 

Hope it helps. 

Jul 28, 2012 at 10:02 AM

I'll follow this way. Thank you very much.

Bye