diff --git a/OpenMetaverse.GUI/AvatarList.cs b/OpenMetaverse.GUI/AvatarList.cs index 0eaa82b8..2f03dc73 100644 --- a/OpenMetaverse.GUI/AvatarList.cs +++ b/OpenMetaverse.GUI/AvatarList.cs @@ -141,11 +141,11 @@ namespace OpenMetaverse.GUI private void AddAvatar(uint localID, UUID avatarID, Vector3 coarsePosition, Avatar avatar) { + if (!this.IsHandleCreated) return; + if (this.InvokeRequired) this.BeginInvoke((MethodInvoker)delegate { AddAvatar(localID, avatarID, coarsePosition, avatar); }); else { - if (!this.IsHandleCreated) return; - TrackedAvatar trackedAvatar = new TrackedAvatar(); trackedAvatar.CoarseLocation = coarsePosition; trackedAvatar.ID = avatarID; @@ -184,11 +184,11 @@ namespace OpenMetaverse.GUI private void RemoveAvatar(uint localID) { + if (!this.IsHandleCreated) return; + if (this.InvokeRequired) this.BeginInvoke((MethodInvoker)delegate { RemoveAvatar(localID); }); else { - if (!this.IsHandleCreated) return; - lock (_TrackedAvatars) { TrackedAvatar trackedAvatar; @@ -203,11 +203,11 @@ namespace OpenMetaverse.GUI private void UpdateAvatar(Avatar avatar) { + if (!this.IsHandleCreated) return; + if (this.InvokeRequired) this.BeginInvoke((MethodInvoker)delegate { UpdateAvatar(avatar); }); else { - if (!this.IsHandleCreated) return; - lock (_TrackedAvatars) { TrackedAvatar trackedAvatar; @@ -304,7 +304,7 @@ namespace OpenMetaverse.GUI private void Avatars_OnAvatarAppearance(UUID avatarID, bool isTrial, Primitive.TextureEntryFace defaultTexture, Primitive.TextureEntryFace[] faceTextures, List visualParams) { - if (visualParams.Count > 80) + if (visualParams.Count > 31) { lock (_TrackedAvatars) { @@ -313,8 +313,8 @@ namespace OpenMetaverse.GUI { this.BeginInvoke((MethodInvoker)delegate { - byte param = visualParams[80]; - if (param > 93) + byte param = visualParams[31]; + if (param > 0) trackedAvatar.ListViewItem.ForeColor = Color.Blue; else trackedAvatar.ListViewItem.ForeColor = Color.Magenta; diff --git a/OpenMetaverse.GUI/LocalChat.cs b/OpenMetaverse.GUI/LocalChat.cs index cc906740..209c141c 100644 --- a/OpenMetaverse.GUI/LocalChat.cs +++ b/OpenMetaverse.GUI/LocalChat.cs @@ -84,6 +84,8 @@ namespace OpenMetaverse.GUI public void LogChat(string name, ChatType type, string text, Color color) { + if (!this.IsHandleCreated) return; + if (this.InvokeRequired) { this.BeginInvoke((MethodInvoker)delegate { LogChat(name, type, text, color); }); diff --git a/OpenMetaverse.GUI/LoginPanel.cs b/OpenMetaverse.GUI/LoginPanel.cs index 7603f7d7..6275cf6a 100644 --- a/OpenMetaverse.GUI/LoginPanel.cs +++ b/OpenMetaverse.GUI/LoginPanel.cs @@ -230,6 +230,8 @@ namespace OpenMetaverse.GUI private void Network_OnDisconnected(NetworkManager.DisconnectType reason, string message) { + if (!this.IsHandleCreated) return; + this.BeginInvoke((MethodInvoker)delegate { btnLogin.Text = "Login"; diff --git a/OpenMetaverse.GUI/MiniMap.cs b/OpenMetaverse.GUI/MiniMap.cs index 122ab576..9e19e286 100644 --- a/OpenMetaverse.GUI/MiniMap.cs +++ b/OpenMetaverse.GUI/MiniMap.cs @@ -118,11 +118,11 @@ namespace OpenMetaverse.GUI private void UpdateMiniMap(Simulator sim) { + if (!this.IsHandleCreated) return; + if (this.InvokeRequired) this.BeginInvoke((MethodInvoker)delegate { UpdateMiniMap(sim); }); else { - if (!this.IsHandleCreated) return; - Bitmap bmp = _MapLayer == null ? new Bitmap(256, 256) : (Bitmap)_MapLayer.Clone(); Graphics g = Graphics.FromImage(bmp); diff --git a/OpenMetaverse.GUI/StatusOutput.cs b/OpenMetaverse.GUI/StatusOutput.cs index 3e9e2c14..f9111f26 100644 --- a/OpenMetaverse.GUI/StatusOutput.cs +++ b/OpenMetaverse.GUI/StatusOutput.cs @@ -54,14 +54,14 @@ namespace OpenMetaverse.GUI public void LogText(string text, Color color) { + if (!this.IsHandleCreated) return; + if (this.InvokeRequired) { this.BeginInvoke((MethodInvoker)delegate { LogText(text, color); }); } else { - if (!this.IsHandleCreated) return; - this.SelectionStart = this.Text.Length; this.SelectionColor = color; DateTime now = DateTime.Now; diff --git a/Programs/examples/Dashboard/Dashboard.Designer.cs b/Programs/examples/Dashboard/Dashboard.Designer.cs index b909fc9c..d43fc06f 100644 --- a/Programs/examples/Dashboard/Dashboard.Designer.cs +++ b/Programs/examples/Dashboard/Dashboard.Designer.cs @@ -36,6 +36,7 @@ namespace Dashboard this.tabPage2 = new System.Windows.Forms.TabPage(); this.tabPage3 = new System.Windows.Forms.TabPage(); this.tabPage4 = new System.Windows.Forms.TabPage(); + this.loginPanel1 = new OpenMetaverse.GUI.LoginPanel(); this.localChat1 = new OpenMetaverse.GUI.LocalChat(); this.statusOutput1 = new OpenMetaverse.GUI.StatusOutput(); this.avatarList1 = new OpenMetaverse.GUI.AvatarList(); @@ -62,8 +63,10 @@ namespace Dashboard // // splitContainer1 // - this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill; - this.splitContainer1.Location = new System.Drawing.Point(0, 0); + this.splitContainer1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.splitContainer1.Location = new System.Drawing.Point(0, 40); this.splitContainer1.Name = "splitContainer1"; // // splitContainer1.Panel1 @@ -73,8 +76,8 @@ namespace Dashboard // splitContainer1.Panel2 // this.splitContainer1.Panel2.Controls.Add(this.splitContainer2); - this.splitContainer1.Size = new System.Drawing.Size(632, 443); - this.splitContainer1.SplitterDistance = 418; + this.splitContainer1.Size = new System.Drawing.Size(772, 514); + this.splitContainer1.SplitterDistance = 540; this.splitContainer1.TabIndex = 4; // // splitContainer3 @@ -91,8 +94,8 @@ namespace Dashboard // splitContainer3.Panel2 // this.splitContainer3.Panel2.Controls.Add(this.statusOutput1); - this.splitContainer3.Size = new System.Drawing.Size(418, 443); - this.splitContainer3.SplitterDistance = 335; + this.splitContainer3.Size = new System.Drawing.Size(540, 514); + this.splitContainer3.SplitterDistance = 388; this.splitContainer3.TabIndex = 0; // // splitContainer2 @@ -109,8 +112,8 @@ namespace Dashboard // splitContainer2.Panel2 // this.splitContainer2.Panel2.Controls.Add(this.miniMap1); - this.splitContainer2.Size = new System.Drawing.Size(210, 443); - this.splitContainer2.SplitterDistance = 225; + this.splitContainer2.Size = new System.Drawing.Size(228, 514); + this.splitContainer2.SplitterDistance = 271; this.splitContainer2.TabIndex = 9; // // tabControl1 @@ -123,7 +126,7 @@ namespace Dashboard this.tabControl1.Location = new System.Drawing.Point(0, 0); this.tabControl1.Name = "tabControl1"; this.tabControl1.SelectedIndex = 0; - this.tabControl1.Size = new System.Drawing.Size(210, 225); + this.tabControl1.Size = new System.Drawing.Size(228, 271); this.tabControl1.TabIndex = 1; // // tabPage1 @@ -132,7 +135,7 @@ namespace Dashboard this.tabPage1.Location = new System.Drawing.Point(4, 22); this.tabPage1.Name = "tabPage1"; this.tabPage1.Padding = new System.Windows.Forms.Padding(3); - this.tabPage1.Size = new System.Drawing.Size(202, 199); + this.tabPage1.Size = new System.Drawing.Size(220, 245); this.tabPage1.TabIndex = 0; this.tabPage1.Text = "Nearby"; this.tabPage1.UseVisualStyleBackColor = true; @@ -143,7 +146,7 @@ namespace Dashboard this.tabPage2.Location = new System.Drawing.Point(4, 22); this.tabPage2.Name = "tabPage2"; this.tabPage2.Padding = new System.Windows.Forms.Padding(3); - this.tabPage2.Size = new System.Drawing.Size(202, 199); + this.tabPage2.Size = new System.Drawing.Size(202, 178); this.tabPage2.TabIndex = 1; this.tabPage2.Text = "Friends"; this.tabPage2.UseVisualStyleBackColor = true; @@ -153,7 +156,7 @@ namespace Dashboard this.tabPage3.Controls.Add(this.groupList1); this.tabPage3.Location = new System.Drawing.Point(4, 22); this.tabPage3.Name = "tabPage3"; - this.tabPage3.Size = new System.Drawing.Size(202, 199); + this.tabPage3.Size = new System.Drawing.Size(202, 178); this.tabPage3.TabIndex = 2; this.tabPage3.Text = "Groups"; this.tabPage3.UseVisualStyleBackColor = true; @@ -163,18 +166,26 @@ namespace Dashboard this.tabPage4.Controls.Add(this.inventoryTree1); this.tabPage4.Location = new System.Drawing.Point(4, 22); this.tabPage4.Name = "tabPage4"; - this.tabPage4.Size = new System.Drawing.Size(202, 199); + this.tabPage4.Size = new System.Drawing.Size(202, 178); this.tabPage4.TabIndex = 3; this.tabPage4.Text = "Inventory"; this.tabPage4.UseVisualStyleBackColor = true; // + // loginPanel1 + // + this.loginPanel1.Dock = System.Windows.Forms.DockStyle.Top; + this.loginPanel1.Location = new System.Drawing.Point(0, 0); + this.loginPanel1.Name = "loginPanel1"; + this.loginPanel1.Size = new System.Drawing.Size(772, 37); + this.loginPanel1.TabIndex = 5; + // // localChat1 // this.localChat1.Client = null; this.localChat1.Dock = System.Windows.Forms.DockStyle.Fill; this.localChat1.Location = new System.Drawing.Point(0, 0); this.localChat1.Name = "localChat1"; - this.localChat1.Size = new System.Drawing.Size(418, 335); + this.localChat1.Size = new System.Drawing.Size(540, 388); this.localChat1.TabIndex = 4; // // statusOutput1 @@ -185,7 +196,7 @@ namespace Dashboard this.statusOutput1.Location = new System.Drawing.Point(0, 0); this.statusOutput1.Name = "statusOutput1"; this.statusOutput1.ReadOnly = true; - this.statusOutput1.Size = new System.Drawing.Size(418, 104); + this.statusOutput1.Size = new System.Drawing.Size(540, 122); this.statusOutput1.TabIndex = 0; this.statusOutput1.Text = ""; // @@ -195,7 +206,8 @@ namespace Dashboard this.avatarList1.Dock = System.Windows.Forms.DockStyle.Fill; this.avatarList1.Location = new System.Drawing.Point(3, 3); this.avatarList1.Name = "avatarList1"; - this.avatarList1.Size = new System.Drawing.Size(196, 193); + this.avatarList1.Size = new System.Drawing.Size(214, 239); + this.avatarList1.Sorting = System.Windows.Forms.SortOrder.Ascending; this.avatarList1.TabIndex = 2; this.avatarList1.UseCompatibleStateImageBehavior = false; this.avatarList1.View = System.Windows.Forms.View.Details; @@ -206,7 +218,7 @@ namespace Dashboard this.friendsList1.Dock = System.Windows.Forms.DockStyle.Fill; this.friendsList1.Location = new System.Drawing.Point(3, 3); this.friendsList1.Name = "friendsList1"; - this.friendsList1.Size = new System.Drawing.Size(196, 193); + this.friendsList1.Size = new System.Drawing.Size(196, 172); this.friendsList1.TabIndex = 5; this.friendsList1.UseCompatibleStateImageBehavior = false; this.friendsList1.View = System.Windows.Forms.View.Details; @@ -217,7 +229,7 @@ namespace Dashboard this.groupList1.Dock = System.Windows.Forms.DockStyle.Fill; this.groupList1.Location = new System.Drawing.Point(0, 0); this.groupList1.Name = "groupList1"; - this.groupList1.Size = new System.Drawing.Size(202, 199); + this.groupList1.Size = new System.Drawing.Size(202, 178); this.groupList1.TabIndex = 7; this.groupList1.UseCompatibleStateImageBehavior = false; this.groupList1.View = System.Windows.Forms.View.Details; @@ -228,7 +240,7 @@ namespace Dashboard this.inventoryTree1.Dock = System.Windows.Forms.DockStyle.Fill; this.inventoryTree1.Location = new System.Drawing.Point(0, 0); this.inventoryTree1.Name = "inventoryTree1"; - this.inventoryTree1.Size = new System.Drawing.Size(202, 199); + this.inventoryTree1.Size = new System.Drawing.Size(202, 178); this.inventoryTree1.TabIndex = 1; // // miniMap1 @@ -239,7 +251,7 @@ namespace Dashboard this.miniMap1.Dock = System.Windows.Forms.DockStyle.Fill; this.miniMap1.Location = new System.Drawing.Point(0, 0); this.miniMap1.Name = "miniMap1"; - this.miniMap1.Size = new System.Drawing.Size(210, 214); + this.miniMap1.Size = new System.Drawing.Size(228, 239); this.miniMap1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom; this.miniMap1.TabIndex = 11; this.miniMap1.TabStop = false; @@ -248,7 +260,8 @@ namespace Dashboard // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(632, 443); + this.ClientSize = new System.Drawing.Size(772, 548); + this.Controls.Add(this.loginPanel1); this.Controls.Add(this.splitContainer1); this.Name = "Dashboard"; this.Text = "Dashboard"; @@ -288,6 +301,7 @@ namespace Dashboard private System.Windows.Forms.SplitContainer splitContainer3; private OpenMetaverse.GUI.LocalChat localChat1; private OpenMetaverse.GUI.StatusOutput statusOutput1; + private OpenMetaverse.GUI.LoginPanel loginPanel1; } } diff --git a/Programs/examples/Dashboard/Dashboard.cs b/Programs/examples/Dashboard/Dashboard.cs index c07da906..b36039c6 100644 --- a/Programs/examples/Dashboard/Dashboard.cs +++ b/Programs/examples/Dashboard/Dashboard.cs @@ -13,6 +13,7 @@ namespace Dashboard GridClient Client; LoginParams ClientLogin; + bool ShuttingDown = false; /// /// Provides a full representation of OpenMetaverse.GUI @@ -37,8 +38,12 @@ namespace Dashboard //login ClientLogin = Client.Network.DefaultLoginParams(firstName, lastName, password, "OpenMetaverse Dashboard", Assembly.GetExecutingAssembly().GetName().Version.ToString()); + loginPanel1.LoginParams = ClientLogin; + ClientLogin.Start = "last"; - Client.Network.BeginLogin(ClientLogin); + + if (firstName != String.Empty && lastName != String.Empty && password != String.Empty) + Client.Network.BeginLogin(ClientLogin); } private void InitializeClient(bool initialize) @@ -55,21 +60,24 @@ namespace Dashboard //initialize client object Client = new GridClient(); - Client.Network.OnLogin += new NetworkManager.LoginCallback(Network_OnLogin); Client.Settings.USE_TEXTURE_CACHE = true; + Client.Network.OnDisconnected += new NetworkManager.DisconnectedCallback(Network_OnDisconnected); + //define the client object for each GUI element avatarList1.Client = Client; friendsList1.Client = Client; groupList1.Client = Client; inventoryTree1.Client = Client; localChat1.Client = Client; + loginPanel1.Client = Client; miniMap1.Client = Client; statusOutput1.Client = Client; } private void Dashboard_FormClosing(object sender, FormClosingEventArgs e) { + ShuttingDown = true; InitializeClient(false); Environment.Exit(0); } @@ -89,19 +97,9 @@ namespace Dashboard MessageBox.Show(group.Name + " = " + group.ID); } - private void Network_OnLogin(LoginStatus login, string message) + private void Network_OnDisconnected(NetworkManager.DisconnectType reason, string message) { - if (login == LoginStatus.Failed) - { - this.BeginInvoke((MethodInvoker)delegate - { - if (MessageBox.Show(this, "Login failed. Try again?", this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes) - { - InitializeClient(true); - Client.Network.BeginLogin(ClientLogin); - } - }); - } + InitializeClient(!ShuttingDown); } } diff --git a/Programs/examples/Dashboard/Program.cs b/Programs/examples/Dashboard/Program.cs index 7f679249..c1a2bf8d 100644 --- a/Programs/examples/Dashboard/Program.cs +++ b/Programs/examples/Dashboard/Program.cs @@ -11,8 +11,12 @@ namespace Dashboard { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); - if (args.Length > 2) Application.Run(new Dashboard(args[0], args[1], args[2])); - else MessageBox.Show("Usage: dashboard.exe ", "Dashboard", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1); + + string firstName = args.Length > 0 ? args[0] : String.Empty; + string lastName = args.Length > 2 ? args[1] : String.Empty; + string password = args.Length > 2 ? args[2] : String.Empty; + + Application.Run(new Dashboard(firstName, lastName, password)); } } } \ No newline at end of file