New Posts New Posts RSS Feed: [CANCELLED] Adding an Item to the PageNavigatorAdapter
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

[CANCELLED] Adding an Item to the PageNavigatorAdapter

 Post Reply Post Reply Page  12>
Author
Linguinut View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14-Jun-2007
Location: United States
Posts: 394
Post Options Post Options   Quote Linguinut Quote  Post ReplyReply Direct Link To This Post Topic: [CANCELLED] Adding an Item to the PageNavigatorAdapter
    Posted: 30-Nov-2007 at 4:58pm

I am not sure if this item has been addressed.  If it has, I apologize for the overlapping post. Ermm

How do I add a button to the PageNavigatorAdapter?  The public class does not appear to allow me to do this:

public class PageNavigatorAdapter : IPageViewToolBar
{
    public PageNavigatorAdapter(BindingNavigator pNavigator);
    public PageNavigatorAdapter(BindingNavigator pNavigator, bool pIsVisible);
    public ToolStripItem AddNewItemButton { protected get; set; }
    public bool AddNewItemEnabled { get; set; }
    public bool AddNewItemVisible { get; set; }
    public BindingSource BindingSource { get; set; }
    public ToolStripItem DeleteItemButton { protected get; set; }
    public bool DeleteItemEnabled { get; set; }
    public bool DeleteItemVisible { get; set; }
    public ToolStripItem EditItemButton { protected get; set; }
    public bool EditItemEnabled { get; set; }
    public bool EditItemVisible { get; set; }
    public ToolStripItem SaveButton { protected get; set; }
    public bool SaveEnabled { get; set; }
    public bool SaveVisible { get; set; }
    public bool Visible { get; set; }
    public WorkItem WorkItem { get; set; }
    public event EventHandler<EventArgs<object>> AddNewItemClick;
    public event EventHandler<EventArgs<object>> DeleteItemClick;
    public event EventHandler<EventArgs<object>> EditItemClick;
    public event EventHandler SaveClick;
}
 
There are plenty of things to utilize for the existing buttons, but no room to add a new button.  I really need this quite badly and I do not want to recreate a navigation toolbar wheel unless I have to.  On second thought, if I did that then I could implement the DevExpress control in its place...hhmmm...
 
Thanks,
Bill


Edited by Linguinut - 06-Dec-2007 at 4:38pm
Back to Top
Linguinut View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14-Jun-2007
Location: United States
Posts: 394
Post Options Post Options   Quote Linguinut Quote  Post ReplyReply Direct Link To This Post Posted: 30-Nov-2007 at 5:23pm
In the PageNavigatorAdapter class, could I make this function public?
 
/// <summary>Set the Adapter's ToolStripItem that represents a Button in the navigator.</summary>
/// <param name="pAdapterButton">The adapter's reference to the ToolStripItem.</param>
/// <param name="pNewButton">The new reference to the ToolStripItem in the Navigator.</param>
/// <param name="pClickHandler">The button's click handler.</param>
private void SetButton(ref ToolStripItem pAdapterButton, ToolStripItem pNewButton, EventHandler pClickHandler)
 
Of course, I am editing the IdeaBlade.CAB.UI class, but I do not see another way to do this.  Is there?
Back to Top
Linguinut View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14-Jun-2007
Location: United States
Posts: 394
Post Options Post Options   Quote Linguinut Quote  Post ReplyReply Direct Link To This Post Posted: 30-Nov-2007 at 6:34pm
Criminey!!  Nothing is simple.  The approach of changing the method to public introduces a whole gob of complications.  The interface must be changed, for one.  I tried.  What a headache!
 
I am now thinking that I should just hide the default PageNavigatorAdapter and create my own DevExpress DataNavigator.  I could just wire the two together, then add my own buttons however I desire. 
 
Well, if I am going to do that, I might as well go the whole way and create a whole new DataNavigatorAdapter class.  But, then, I would have to replace the PageNavigatorAdapter on the ControlViews...I am sure that will carry with it a tremendously lethal plague of exceptions that I will have to deal with.
 
Where does this end?
 
I am giving up for the day.  Perhaps someone can chime in here and let me know how to add a toolstripitem to the page navigator.  I will be back at this tomorrow.
Back to Top
Linguinut View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14-Jun-2007
Location: United States
Posts: 394
Post Options Post Options   Quote Linguinut Quote  Post ReplyReply Direct Link To This Post Posted: 03-Dec-2007 at 10:03am
Cry
Back to Top
Linguinut View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14-Jun-2007
Location: United States
Posts: 394
Post Options Post Options   Quote Linguinut Quote  Post ReplyReply Direct Link To This Post Posted: 04-Dec-2007 at 9:41am
How do I add an item?  Can it even be done?
Cry Cry
Back to Top
Linguinut View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14-Jun-2007
Location: United States
Posts: 394
Post Options Post Options   Quote Linguinut Quote  Post ReplyReply Direct Link To This Post Posted: 04-Dec-2007 at 6:07pm
Disapprove
Back to Top
Linguinut View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14-Jun-2007
Location: United States
Posts: 394
Post Options Post Options   Quote Linguinut Quote  Post ReplyReply Direct Link To This Post Posted: 05-Dec-2007 at 11:04am
Angry
Back to Top
Linguinut View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14-Jun-2007
Location: United States
Posts: 394
Post Options Post Options   Quote Linguinut Quote  Post ReplyReply Direct Link To This Post Posted: 06-Dec-2007 at 2:24pm
Dead
Back to Top
mykel View Drop Down
Newbie
Newbie
Avatar

Joined: 18-Sep-2007
Location: Philippines
Posts: 30
Post Options Post Options   Quote mykel Quote  Post ReplyReply Direct Link To This Post Posted: 12-Dec-2007 at 7:46pm
I think I can help you with this, linguinut (i hope) :) do you still want to hear?
Back to Top
mykel View Drop Down
Newbie
Newbie
Avatar

Joined: 18-Sep-2007
Location: Philippines
Posts: 30
Post Options Post Options   Quote mykel Quote  Post ReplyReply Direct Link To This Post Posted: 12-Dec-2007 at 7:52pm

You first add the toolStripItem in the Toolbar of the DevExPageView Form. then take note of the CreateNavigatorAdapter() method inside the code of the form, because you will be setting your newly added button from the PageNavigatorAdapter into the ToolStripItem control.

Back to Top
mykel View Drop Down
Newbie
Newbie
Avatar

Joined: 18-Sep-2007
Location: Philippines
Posts: 30
Post Options Post Options   Quote mykel Quote  Post ReplyReply Direct Link To This Post Posted: 12-Dec-2007 at 7:55pm
In the IPageViewToolBar interface, you need to add the following getter and setter of the function you want to add. In my application, I added an Undo functionality and add the following codes:

/// <summary>Get or set the enabled state of the UndoItem button.</summary>

bool UndoItemEnabled { get; set;}

/// <summary>Get or set the visible state of the UndoItem button.</summary>

bool UndoItemVisible { get; set;}

/// <summary>Raised on UndoItem click.</summary>

event EventHandler<EventArgs<Object>> UndoItemClick;

Take note that you will only add the Enabled and Visible codes, if you will need to manipulate the behavior of your control. But the event handler is an important thing here.
Back to Top
mykel View Drop Down
Newbie
Newbie
Avatar

Joined: 18-Sep-2007
Location: Philippines
Posts: 30
Post Options Post Options   Quote mykel Quote  Post ReplyReply Direct Link To This Post Posted: 12-Dec-2007 at 7:58pm
Then in the PageNavigatorAdapter, You have to add the ff methods and variables:
 
private ToolStripItem mUndoItemButton;

// <summary>Raised on UndoItem click.</summary>

public event EventHandler<EventArgs<Object>> UndoItemClick;

/// <summary>Set the ToolStripItem that represents the UndoItem Button.</summary>

/// <remarks>

/// Derived classes can "get" this ToolStripItem.

/// </remarks>

public ToolStripItem UndoItemButton

{

protected get { return mUndoItemButton; }

set

{

SetButton(ref mUndoItemButton, value, UndoItemButtonClick);

}

}

private void UndoItemButtonClick(object sender, EventArgs e)

{

InvokeClickHandlerWithCurrentObject(UndoItemClick, true);

}

/// <summary>Get or set the visible state of the Undo button.</summary>

public bool UndoItemVisible

{

get { return GetToolStripItemVisible(UndoAllButton); }

set { SetToolStripItemVisible(UndoAllButton, value); }

}

/// <summary>Get or set the enabled state of the Undo button.</summary>

public bool UndoItemEnabled

{

get { return GetToolStripItemEnabled(UndoItemButton); }

set { SetToolStripItemEnabled(UndoItemButton, value); }

}

Back to Top
mykel View Drop Down
Newbie
Newbie
Avatar

Joined: 18-Sep-2007
Location: Philippines
Posts: 30
Post Options Post Options   Quote mykel Quote  Post ReplyReply Direct Link To This Post Posted: 12-Dec-2007 at 8:01pm
Once you added this, Now you have to place a setting code in the DevExPageView CreateNavigatorAdapter() method:

navAdapter.UndoItemButton = undoCurrentToolStripMenuItem;

given that the undoCurrentToolStripMenuItem is the ToolStripItem button you added in your UI.
Back to Top
mykel View Drop Down
Newbie
Newbie
Avatar

Joined: 18-Sep-2007
Location: Philippines
Posts: 30
Post Options Post Options   Quote mykel Quote  Post ReplyReply Direct Link To This Post Posted: 12-Dec-2007 at 8:05pm
And then in the generic PageController (ex. SummaryDetailPageController<TRootObject>) you configure the events of your added toolbar.

/// <summary>Configure the UndoItem button.</summary>

protected virtual void ConfigureUndoItemButton()

{

PageToolBar.UndoItemClick += UndoItemHandler;

}

then call this event in the AddCommandHandlers() method.
Back to Top
mykel View Drop Down
Newbie
Newbie
Avatar

Joined: 18-Sep-2007
Location: Philippines
Posts: 30
Post Options Post Options   Quote mykel Quote  Post ReplyReply Direct Link To This Post Posted: 12-Dec-2007 at 8:10pm
oh Im sorry, I forgot about the PageController class. You need to add the ff in the PageController, before doing something in the SummaryDetailPageController:
 

#region Undo Item

/// <summary>Handle request to undo an item.</summary>

protected void UndoItemHandler(object sender, EventArgs<Object> e)

{

// ToDo: Use Resources

object item = e.Data;

UndoItem(item);

}

/// <summary>Delete the item.</summary>

/// <remarks>

/// This implementation can only delete

/// an <see cref="Entity"/>.

/// </remarks>

protected virtual void UndoItem(object pItem)

{

if (pItem is Entity)

{

((Entity)pItem).Undo();

((Entity)pItem).ClearErrors();

((CommonEntity)pItem).VerifierResults.Clear();

}

else

{

throw new InvalidOperationException("Can't undo an item of type, " + pItem.GetType());

}

}

#endregion

 

Note that this is only my example for creating an undo functionality. You have to modify the code inside the methods and events in order to implement the functionality of your toolbar button event once you click it.

I think thats all. I am sorry if ever I missed out something. Let me know if you encounter problems with this.
 
Hope this helps. :)
Back to Top
Linguinut View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14-Jun-2007
Location: United States
Posts: 394
Post Options Post Options   Quote Linguinut Quote  Post ReplyReply Direct Link To This Post Posted: 12-Dec-2007 at 8:34pm
mykel, thanks gobs for the response.  Two thumbs up!  Thumbs%20Up Thumbs%20Up
 
My gut is telling me that fiddling with the interfaces on this Adapter is not the way to go, though.  The toolbar's Button.Add functionality (for example) should be exposed so that the user control can add to its basic set of items (Print Report Button, Drop-Down List Control for filtering data, Simple label control for information, etc.).  Adding the proper handler would be module specific.  Your undo example is good and I understand the work involved in making it happen (for the most part); however, an ad hoc toolbar item is what I would like to achieve.  Perhaps, I am dreaming a little too much, eh?
Back to Top
 Post Reply Post Reply Page  12>

Forum Jump Forum Permissions View Drop Down