2 // Radegast Metaverse Client
3 // Copyright (c) 2009-2013, Radegast Development Team
4 // All rights reserved.
6 // Redistribution and use in source and binary forms, with or without
7 // modification, are permitted provided that the following conditions are met:
9 // * Redistributions of source code must retain the above copyright notice,
10 // this list of conditions and the following disclaimer.
11 // * Redistributions in binary form must reproduce the above copyright
12 // notice, this list of conditions and the following disclaimer in the
13 // documentation and/or other materials provided with the distribution.
14 // * Neither the name of the application "Radegast", nor the names of its
15 // contributors may be used to endorse or promote products derived from
16 // this software without specific prior written permission.
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21 // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
22 // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24 // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25 // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26 // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 using System.Collections.Generic;
34 using System.Windows.Forms;
39 public partial class ntfScriptDialog : Notification
41 RadegastInstance instance;
45 public ntfScriptDialog(RadegastInstance instance, string message, string objectName, UUID imageID, UUID objectID, string firstName, string lastName, int chatChannel, List<string> buttons)
46 : base(NotificationType.ScriptDialog)
48 InitializeComponent();
50 this.instance = instance;
51 this.chatChannel = chatChannel;
52 this.objectID = objectID;
54 descBox.BackColor = instance.MainForm.NotificationBackground;
55 descBox.Text = firstName + " " + lastName + "'s " + objectName + "\r\n\r\n" + message.Replace("\n", "\r\n") + "\r\n";
57 NotificationEventArgs args = new NotificationEventArgs(instance);
58 args.Text = descBox.Text;
64 if (buttons.Count == 1 && buttons[0] == "!!llTextBox!!")
66 txtTextBox.Visible = true;
67 sendBtn.Visible = true;
68 args.Buttons.Add(ignoreBtn);
72 foreach (string label in buttons)
74 Button b = new Button();
75 b.Size = new Size(btnWidth, btnHeight);
77 b.Location = new Point(5 + (i % 3) * (btnWidth + 5), btnsPanel.Size.Height - (i / 3) * (btnHeight + 5) - (btnHeight + 5));
78 b.Name = i.ToString();
79 b.Click += new EventHandler(b_Click);
80 b.UseVisualStyleBackColor = true;
81 b.Margin = new Padding(0, 3, 0, 3);
82 b.Padding = new Padding(0);
83 btnsPanel.Controls.Add(b);
89 args.Buttons.Add(ignoreBtn);
90 FireNotificationCallback(args);
93 void b_Click(object sender, EventArgs e)
95 string label = ((Button)sender).Text;
96 int index = int.Parse(((Button)sender).Name);
97 instance.Client.Self.ReplyToScriptDialog(chatChannel, index, label, objectID);
98 instance.MainForm.RemoveNotification(this);
101 private void ignoreBtn_Click(object sender, EventArgs e)
103 instance.MainForm.RemoveNotification(this);
106 private void sendBtn_Click(object sender, EventArgs e)
108 instance.Client.Self.ReplyToScriptDialog(chatChannel, 0, txtTextBox.Text, objectID);
109 instance.MainForm.RemoveNotification(this);