We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to make MainFrameBarManager memorize customized shortcut settings

Thread ID:

Created:

Updated:

Platform:

Replies:

60804 May 11,2007 05:19 PM UTC May 15,2007 10:54 PM UTC WinForms 6
loading
Tags: Tools
Limin Shen
Asked On May 11, 2007 05:19 PM UTC

Hello,

I implemented customization shortcut setting for BarItems by using CustomizationPanel. But it seems that each time i close the appliation, the MainFrameBarManager will forget all the changes in shortcut. When the application launches again, it goes back to the default shortcut setting specified in windows designer. Hmmmm... i was wondering if there's a way could make MainFrameBarManager to memorize those changes.

Thanks,
Limin

Limin Shen
Replied On May 11, 2007 10:12 PM UTC

Update:

I tried to use SaveBarState() and LoadBarState() function in Form_Load() and Form_closing(). It seems that location and visibility of toolbar item could be memorized in XML file. But the shortcut information cannot. Could anybody help this issue?

Thanks,
Limin

Limin Shen
Replied On May 11, 2007 11:39 PM UTC

Update again:

I tried creating a class CustomMainFrameBarManager deriving from MainFrameBarManager, and implemented these two functions. But shortcut information still doesn't work.


public void LoadBarCustomization(AppStateSerializer serializer)
{
this.LoadCustomizationInfo(serializer);
}

public void SaveBarCustomization(AppStateSerializer serializer)
{
this.SaveCustomizationInfo(serializer);
}

Looking forward to your answer~

Thanks,
Limin

Rajesh C [Syncfusion]
Replied On May 12, 2007 12:23 AM UTC

Hi Limin,

I am not able to reproduce the issue.

Could you please modified the sample and also update us the steps to reproduce the issue? It will help to resolve this issue.

http://www.syncfusion.com/Support/user/uploads/BarItem_cb706728.zip

Thank you for using Syncfusion products.

Regards,
Rajesh C

Limin Shen
Replied On May 14, 2007 06:48 PM UTC

Hi Rajesh,

Oh, i guess i haven't explained clearly. What I am asking is if there's a way to store hotkey setting changes at the runtime. For example, in my application, the default shortcut for CUT is Ctrl+C; COPY is Ctrl+V. At the runtime, user changes CUT to Ctrl+T; COPY to NULL. Those changes work correctly without closing the application. But when user closes the application, and launches it again, CUT and COPY's shortcut setting will go back to Ctrl+C & Ctrl+V, and forget what user has specified last time (Ctrl+T, NULL). Can MainFrameBarManager be able to store those settings?

(There are two pictures in the attachment. hotkey0.jpg shows the shortcut settings when application launches; hotkey1.jpg shows the shortcut settings after user does changes. When the application is closed and launched again, shortcut settings display exactly the same as hotkey0.jpg without memorizing those showed in hotkey1.jpg.)

Hope this can help you reproduce the problem.

Thanks,
Limin

hotkey.zip

Rajesh C [Syncfusion]
Replied On May 15, 2007 12:49 AM UTC

Hi Limin,

I have Serialized the shortcuts of the BarItems by using Xml Serialization. Please refer the following code snippet that illustrates the same

[ C#]

// Serialization
private void SerializeBarItemShortcuts(string fileName)
{

BarItemShortcut myList = new BarItemShortcut();

ArrayList shortcuts = new ArrayList();
foreach( BarItem bItem in mainFrameBarManager1.Items )
{
shortcuts.Add(bItem.Shortcut);
}
myList.Items = shortcuts;
XmlSerializer s = new XmlSerializer(typeof(BarItemShortcut));
TextWriter w = new StreamWriter(fileName);
s.Serialize(w, myList);
w.Close();
}

// Deserialization
private void DeserializeBarItemShortcuts(string fileName)
{
XmlSerializer s = new XmlSerializer(typeof(BarItemShortcut));
ArrayList shortcuts = new ArrayList();
BarItemShortcut newList;
FileInfo f = new FileInfo(fileName);
if (f.Exists)
{
TextReader r = new StreamReader(fileName);
newList = (BarItemShortcut)s.Deserialize(r);
shortcuts = (ArrayList)newList.Items;
int i=0;
foreach (Shortcut sc in shortcuts)
{
this.mainFrameBarManager1.Items[i].Shortcut = sc;
i++;
}
r.Close();
}
}

[XmlRoot("BarItemShortcut")]
public class BarItemShortcut
{
private ArrayList items;
public BarItemShortcut() {}

[XmlElement("item")]
public ArrayList Items
{
get
{
return items;
}
set
{
items = value;
}
}
}


kindly take a look at the attached sample.

http://websamples.syncfusion.com/samples/Tools.Windows/F60804/Main.htm

In this sample it is possible to persist the shortcuts that have been changed during run time.

I have used DeserializeBarItemShortcuts() and SerializeBarItemShortcuts() function in Form_Load() and Form_closing() events.

Please let me know if you have any other queries.

Regards,
Rajesh C


Limin Shen
Replied On May 15, 2007 10:54 PM UTC

Thank you, Rajesh. That works.

Limin

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;