Author |
Share Topic Topic Search Topic Options
|
jlozina
Newbie
Joined: 20-Jul-2011
Posts: 9
|
Post Options
Quote Reply
Topic: Cocktail functionaility Posted: 15-Jun-2012 at 7:57pm |
Hi
I'm looking at the cocktail framework and I have a few questions.
I was wondering if you have wizard functionailty available in the cocktail framework. The functionality I am after is to pop up a dialog box or window and go through either linear or dynamic page sequencing. For example the choices made in the first page would determine the page sequencing.
Also is there functionaility to hide and show fields in a form, and if they a visable to make them read only or editable> This would all be based on active directory groups and Thread.CurrentPrincipal.
Regards,
Joe
|
|
mgood
IdeaBlade
Joined: 18-Nov-2010
Location: Emeryville, CA
Posts: 583
|
Post Options
Quote Reply
Posted: 17-Jun-2012 at 2:47pm |
Joe, There's nothing specifically pre-built for wizards in Cocktail, but Cocktail has the dialog manager to handle the popup and the conductors to navigate from page to page in a wizard.
As for hiding fields, this can be accomplished by binding the visibility property of your fields to a property in the view model that controls whether the field is visible based on the current principal's roles.
As for tabs, Cocktail has a rich V/VM life-cycle management through the conductors mentioned above. This is not specific or limited to tabs. Tabs may just be the way your UI renders the different VMs, but it could also be a dockable UI or any other paradigm that has multiple closable views. You can download an MDI version of TempHire from the following link that has closable tabs as an example.
http://sdrv.ms/KNZkJz
|
|
giotis
Groupie
Joined: 26-Apr-2012
Location: Greece
Posts: 53
|
Post Options
Quote Reply
Posted: 18-Jun-2012 at 9:51am |
Dear Marcel I find this for close Tabs
<DataTemplate x:Key="TabHeaderStyle"> <StackPanel Orientation="Horizontal"> <TextBlock Text="{Binding Path=DisplayName}" VerticalAlignment="Bottom" Margin="4,0,8,0"/> <Button Content="X" Cursor="Hand" ToolTipService.ToolTip="Close this view." cal:Message.Attach="DeactivateItem($dataContext, 'true')" > </Button> </StackPanel> </DataTemplate>
<TabControl x:Name="Items" Grid.Row="1" Margin="20,10,25,10" BorderBrush="#FF1D5380" ItemTemplate="{StaticResource TabHeaderStyle}"> <TabControl.Effect> <DropShadowEffect BlurRadius="3" Opacity="0.2" Color="#FF333333" /> </TabControl.Effect> </TabControl>
I would like to ask you if you could the FormsManager to be generic type i.e.
in the StaffingResourceManagementView know that children are type StaffingResourceDetailViewModel if you do not know the type of child, but only the time it is createted (we have many types of childs - Details, Report...) how FormsManager could manage
Thank you
|
|
giotis
Groupie
Joined: 26-Apr-2012
Location: Greece
Posts: 53
|
Post Options
Quote Reply
Posted: 18-Jun-2012 at 10:02am |
The TempHire version operated asynchronously the children of StaffingResourceDetailViewModel the FormsManager not in MDI version there are no consequences for this
thank you
|
|
mgood
IdeaBlade
Joined: 18-Nov-2010
Location: Emeryville, CA
Posts: 583
|
Post Options
Quote Reply
Posted: 18-Jun-2012 at 10:21am |
You can have your tabs implement a common interface or extend a common base class and build a FormsManager around the common interface or base class. You'll need to customize the ObjectManager behavior a little bit in this case as you no longer will create only one type of objects. You will essentially have to create the specific instance if the tab doesn't exist already and then add it to the FormsManager explicitly instead of letting the FormsManager create the object if it doesn't exist already. The ObjectManager has the necessary methods to do that like Add and TryGetObject to avoid creating an object if it doesn't exist.
Originally posted by giotis
Dear Marcel I find this for close Tabs
<DataTemplate x:Key="TabHeaderStyle"> <StackPanel Orientation="Horizontal"> <TextBlock Text="{Binding Path=DisplayName}" VerticalAlignment="Bottom" Margin="4,0,8,0"/> <Button Content="X" Cursor="Hand" ToolTipService.ToolTip="Close this view." cal:Message.Attach="DeactivateItem($dataContext, 'true')" > </Button> </StackPanel> </DataTemplate>
<TabControl x:Name="Items" Grid.Row="1" Margin="20,10,25,10" BorderBrush="#FF1D5380" ItemTemplate="{StaticResource TabHeaderStyle}"> <TabControl.Effect> <DropShadowEffect BlurRadius="3" Opacity="0.2" Color="#FF333333" /> </TabControl.Effect> </TabControl>
I would like to ask you if you could the FormsManager to be generic type i.e.
in the StaffingResourceManagementView know that children are type StaffingResourceDetailViewModel if you do not know the type of child, but only the time it is createted (we have many types of childs - Details, Report...) how FormsManager could manage
Thank you
|
|
|
mgood
IdeaBlade
Joined: 18-Nov-2010
Location: Emeryville, CA
Posts: 583
|
Post Options
Quote Reply
Posted: 18-Jun-2012 at 10:22am |
Sorry, I don't know what you are trying to say.
Originally posted by giotis
The TempHire version operated asynchronously the children of StaffingResourceDetailViewModel the FormsManager not in MDI version there are no consequences for this
thank you
|
|
|
giotis
Groupie
Joined: 26-Apr-2012
Location: Greece
Posts: 53
|
Post Options
Quote Reply
Posted: 18-Jun-2012 at 10:29am |
The truth is that I tried with ObjectManager but I could not have succeeded can you drive me a bit;
|
|
giotis
Groupie
Joined: 26-Apr-2012
Location: Greece
Posts: 53
|
Post Options
Quote Reply
Posted: 18-Jun-2012 at 10:36am |
in MDI version
public void OpenStaffingResource(object sender, EventArgs args) { var staffingResource = SearchPane.CurrentStaffingResource;
var form = _forms.GetForm(staffingResource.Id); if (form.StaffingResource == null) form.Start(staffingResource.Id, model => UpdateCommands()); ActivateItem(form); }
not MDI
private void OnSelectionChangeElapsed(object sender, EventArgs e) { _selectionChangeTimer.Stop(); if (SearchPane.CurrentStaffingResource == null) return;
_navigationService.NavigateToAsync(() => ActiveDetail ?? _detailFactory.CreatePart(), target => target.Start(SearchPane.CurrentStaffingResource.Id)) .ContinueWith(navigation => { if (navigation.Cancelled) UpdateCommands(); }); }
operated asynchronously the children of StaffingResourceDetailViewModel there are no consequences for this
|
|
mgood
IdeaBlade
Joined: 18-Nov-2010
Location: Emeryville, CA
Posts: 583
|
Post Options
Quote Reply
Posted: 18-Jun-2012 at 11:14am |
The difference here is that in the MDI version we are not closing the current tab to navigate to another tab, so that's why we can simply activate the new tab synchronously. In the SDI version we want to make sure that if the current StaffingResourceDetailViewModel has pending changes, that we prompt the user and the user can decide if they want to cancel, save or discard the changes before navigating to the new StaffingResourceDetailViewModel. This is asynchronous, because we have to wait for the user's response. The NavigationService will trigger the CanClose method of the current StaffingResourceDetailViewModel and only navigate to the target if CanClose allows it.
Edited by mgood - 18-Jun-2012 at 11:16am
|
|
giotis
Groupie
Joined: 26-Apr-2012
Location: Greece
Posts: 53
|
Post Options
Quote Reply
Posted: 18-Jun-2012 at 11:33am |
Thank you for your response
Have something to tell me about the ObjectManager customization
|
|
mgood
IdeaBlade
Joined: 18-Nov-2010
Location: Emeryville, CA
Posts: 583
|
Post Options
Quote Reply
Posted: 18-Jun-2012 at 12:27pm |
Something like this should do the trick.
public interface IForm
{
}
public interface IFormsManager
{
void AddForm<T>(Guid key, T form) where T : IForm;
bool FormExists(Guid key);
T GetForm<T>(Guid key) where T : IForm;
T NewForm<T>() where T : IForm;
void DeleteForm(Guid key);
void Clear();
} public class FormsManager : ObjectManager<Guid, IForm>, IFormsManager
{
#region IFormsManager<T> Members
public void AddForm<T>(Guid key, T form) where T : IForm
{
Add(key, form);
}
public bool FormExists(Guid key)
{
return Exists(key);
}
public T GetForm<T>(Guid key) where T : IForm
{
var form = TryGetObject(key);
if (form == null)
{
form = NewForm<T>();
AddForm(key, form);
}
return (T) form;
}
public T NewForm<T>() where T : IForm
{
return Composition.GetInstance<T>(CreationPolicy.NonShared);
}
public void DeleteForm(Guid key)
{
Remove(key);
}
#endregion
}
|
|