How to make MainFrameBarManager memorize customized shortcut settings
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
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
SIGN IN To post a reply.
6 Replies
LS
Limin Shen
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
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
LS
Limin Shen
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
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
RC
Rajesh C
Syncfusion Team
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
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
LS
Limin Shen
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
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
RC
Rajesh C
Syncfusion Team
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#]
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
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
LS
Limin Shen
May 15, 2007 10:54 PM UTC
Thank you, Rajesh. That works.
Limin
Limin
SIGN IN To post a reply.
- 6 Replies
- 2 Participants
-
LS Limin Shen
- May 11, 2007 05:19 PM UTC
- May 15, 2007 10:54 PM UTC