home
products
contribute
download
documentation
forum
Home
Forums
New posts
Search forums
What's new
New posts
All posts
Latest activity
Members
Registered members
Current visitors
Donate
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Search titles only
By:
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
MediaPortal 1
MediaPortal 1 Plugins
Help needed: Writing own GUIDialog for Plugin
Contact us
RSS
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="ZealotSix" data-source="post: 380346" data-attributes="member: 81800"><p>junkixl, I've been down this road before, and had all the same problems you are describing. I was trying to create a dialog with the same functionality as GUIDialogYesNo, only with different button captions (retry/cancel in my case). I was unsucesful in creating my own dialog without requiring a custom skin, etc. What I ended up doing was modifying the GUIDialogYesNo at runtime. I do not know what you are trying to accomplish, but if you just want to change the button captions, you can do what I did:</p><p></p><p>[CODE]</p><p> /// <summary></p><p> /// Displays a yes/no dialog with custom labels for the buttons</p><p> /// </summary></p><p> /// <returns>True if yes was clicked, False if no was clicked</returns></p><p> private bool ShowCustomYesNo(string heading, string lines, string yesLabel, string noLabel, bool defaultYes) {</p><p> GUIDialogYesNo dialog = (GUIDialogYesNo)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_YES_NO);</p><p> try {</p><p> dialog.Reset();</p><p> dialog.SetHeading(heading);</p><p> string[] linesArray = lines.Split(new string[] { "\\n" }, StringSplitOptions.None);</p><p> if (linesArray.Length > 0) dialog.SetLine(1, linesArray[0]);</p><p> if (linesArray.Length > 1) dialog.SetLine(2, linesArray[1]);</p><p> if (linesArray.Length > 2) dialog.SetLine(3, linesArray[2]);</p><p> if (linesArray.Length > 3) dialog.SetLine(4, linesArray[3]);</p><p> dialog.SetDefaultToYes(defaultYes);</p><p></p><p> foreach (System.Windows.UIElement item in dialog.Children) {</p><p> if (item is GUIButtonControl) {</p><p> GUIButtonControl btn = (GUIButtonControl)item;</p><p> if (btn.GetID == 11 && !String.IsNullOrEmpty(yesLabel)) // Yes button</p><p> btn.Label = yesLabel;</p><p> else if (btn.GetID == 10 && !String.IsNullOrEmpty(noLabel)) // No button</p><p> btn.Label = noLabel;</p><p> }</p><p> }</p><p> dialog.DoModal(GetID);</p><p></p><p> return dialog.IsConfirmed;</p><p> }</p><p> finally {</p><p> // set the standard yes/no dialog back to it's original state (yes/no buttons)</p><p> if (dialog != null)</p><p> dialog.ClearAll();</p><p> }</p><p> }</p><p>[/CODE]</p><p></p><p>Hope this helps. If you end up doing something different, please post back here, because I would be interested in seeing it.</p></blockquote><p></p>
[QUOTE="ZealotSix, post: 380346, member: 81800"] junkixl, I've been down this road before, and had all the same problems you are describing. I was trying to create a dialog with the same functionality as GUIDialogYesNo, only with different button captions (retry/cancel in my case). I was unsucesful in creating my own dialog without requiring a custom skin, etc. What I ended up doing was modifying the GUIDialogYesNo at runtime. I do not know what you are trying to accomplish, but if you just want to change the button captions, you can do what I did: [CODE] /// <summary> /// Displays a yes/no dialog with custom labels for the buttons /// </summary> /// <returns>True if yes was clicked, False if no was clicked</returns> private bool ShowCustomYesNo(string heading, string lines, string yesLabel, string noLabel, bool defaultYes) { GUIDialogYesNo dialog = (GUIDialogYesNo)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_YES_NO); try { dialog.Reset(); dialog.SetHeading(heading); string[] linesArray = lines.Split(new string[] { "\\n" }, StringSplitOptions.None); if (linesArray.Length > 0) dialog.SetLine(1, linesArray[0]); if (linesArray.Length > 1) dialog.SetLine(2, linesArray[1]); if (linesArray.Length > 2) dialog.SetLine(3, linesArray[2]); if (linesArray.Length > 3) dialog.SetLine(4, linesArray[3]); dialog.SetDefaultToYes(defaultYes); foreach (System.Windows.UIElement item in dialog.Children) { if (item is GUIButtonControl) { GUIButtonControl btn = (GUIButtonControl)item; if (btn.GetID == 11 && !String.IsNullOrEmpty(yesLabel)) // Yes button btn.Label = yesLabel; else if (btn.GetID == 10 && !String.IsNullOrEmpty(noLabel)) // No button btn.Label = noLabel; } } dialog.DoModal(GetID); return dialog.IsConfirmed; } finally { // set the standard yes/no dialog back to it's original state (yes/no buttons) if (dialog != null) dialog.ClearAll(); } } [/CODE] Hope this helps. If you end up doing something different, please post back here, because I would be interested in seeing it. [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
MediaPortal 1
MediaPortal 1 Plugins
Help needed: Writing own GUIDialog for Plugin
Contact us
RSS
Top
Bottom