コード例 #1
0
        private void btnAdd_Click(object sender, System.EventArgs e)
        {
            formServer form = new formServer(0);

            form.dataObject = dataObject;
            form.ShowDialog();

            this.loadServers();
        }
コード例 #2
0
        private void btnEdit_Click(object sender, System.EventArgs e)
        {
            RegistryKey key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Imagine Interactive\Gameserver Panel\Servers");

            String[] serverList = key.GetSubKeyNames();
            String   idx        = serverList[this.servers.SelectedIndex];

            idx = idx.Replace("Server", "");
            key.Close();

            formServer form = new formServer(int.Parse(idx));

            form.dataObject = dataObject;
            form.ShowDialog();

            this.loadServers();
        }
コード例 #3
0
        private void btnEdit_Click(object sender, System.EventArgs e)
        {
            RegistryKey key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Imagine Interactive\Gameserver Panel\Servers");

            String[] serverList = key.GetSubKeyNames();
            String idx = serverList[this.servers.SelectedIndex];
            idx = idx.Replace("Server", "");
            key.Close();

            formServer form = new formServer(int.Parse(idx));
            form.dataObject = dataObject;
            form.ShowDialog();

            this.loadServers();
        }
コード例 #4
0
        private void btnAdd_Click(object sender, System.EventArgs e)
        {
            formServer form = new formServer(0);
            form.dataObject = dataObject;
            form.ShowDialog();

            this.loadServers();
        }
コード例 #5
0
ファイル: Plugin.cs プロジェクト: aachyee/desktopgadgets
        //handler clicks
        void IContextMenu.InvokeCommand(IntPtr pici)
        {
            Type typINVOKECOMMANDINFO =
                Type.GetType("ShellExt.INVOKECOMMANDINFO");
            INVOKECOMMANDINFO ici =
                (INVOKECOMMANDINFO)Marshal.PtrToStructure(pici, typINVOKECOMMANDINFO);

            switch (ici.verb)
            {
                case 1: formServer newServer = new formServer(0);
                        newServer.dataObject = this;
                        newServer.ShowDialog();

                        this.ClearAndAddFreshItems();
                        break;

                case 2: this.ClearAndAddFreshItems();
                        break;

                case 3: findGames();
                        break;

            }
        }
コード例 #6
0
ファイル: Plugin.cs プロジェクト: aachyee/desktopgadgets
        /// <summary>
        /// Called when the user opens the item by double-clicking it
        /// Opens the Folder in Explorer
        /// </summary>
        public void OpenItem()
        {
            Log.Debug("OpenItem Called");
            GameserverPlugin ctl = ((GameserverPlugin)open_command);
            if (ctl == null) return;

            if (this.snippet == "MESSAGE")
            {
                formServer newServer = new formServer(0);
                newServer.dataObject = ctl;
                newServer.ShowDialog();

                ctl.refresh(null);
            }
            else
            {
                DialogResult res;
                String[] cmd = this.snippet.Split('|');
                Log.Debug("Snippet Splitted");
                String serverName=this.heading;
                int queryPort = Int32.Parse(cmd[4]);
                String[] serverData = ctl.queryServer(cmd[3], cmd[1], queryPort);
                Log.Debug("Server Queried");
                if (serverData.Length > 3)
                {
                    serverName = serverData[2];
                    this.source = serverData[6]+","+serverData[5]+","+serverData[4];
                }
                String[] data = this.source.Split(',');
                Log.Debug("Connecting to "+this.snippet+" -> "+this.source);
                if (this.source == "0,0,0")
                {
                    res = MessageBox.Show( String.Format( ctl.lang.getValue("connectOffline"), serverName), "GameServer", MessageBoxButtons.YesNo);
                    if (res == DialogResult.No)
                    {
                        return;
                    }
                }
                else if (data[1] == data[2])
                {
                    res = MessageBox.Show( String.Format( ctl.lang.getValue("connectFull"), serverName), "GameServer", MessageBoxButtons.YesNo);
                    if (res == DialogResult.No)
                    {
                        return;
                    }
                }
                else
                {
                    res = MessageBox.Show( String.Format( ctl.lang.getValue("connectAsk"), serverName), "GameServer", MessageBoxButtons.YesNo);
                    if (res == DialogResult.No)
                    {
                        return;
                    }
                }

                ctl.joinServer(cmd[0], cmd[1], Int32.Parse(cmd[2]));
            }
        }
コード例 #7
0
ファイル: Plugin.cs プロジェクト: aachyee/desktopgadgets
        /// <summary>
        /// Called when the user tries to view the details view of this item. We can
        /// create an activex control which shows the details view content, or use the
        /// details view helper. If we dont want to show the details view return true.
        /// </summary>
        /// <param name="title">title for the details view</param>
        /// <param name="flags">flags specifying the features to include in the details view</param>
        /// <param name="detailsControl">store the details view activex control here</param>
        /// <returns>true if details view should be cancelled, false if not</returns>
        public new bool OnDetailsView(out string title,
            out GoogleDesktopDisplayDetailsViewFlags flags, out object detailsControl)
        {
            // Here we can create any ActiveX control for displaying the details, and
            // return it via the detailsControl parameter.  We choose the
            // 'GoogleDesktopDisplayDetailsViewHelper' control that will give us a
            // UI that's inline with how the sidebar looks.
            // Well actually the Example used GoogleDesktopDisplayDetailsViewHelper but
            // we use a standard panel which is then filled by the standard components.

            GameserverPlugin ctl = ((GameserverPlugin)open_command);

            if (this.snippet == "MESSAGE")
            {
                formServer newServer = new formServer(0);
                newServer.dataObject = ctl;
                newServer.ShowDialog();

                ctl.refresh(null);

                detailsControl = open_command;
                title = heading;
                flags = GoogleDesktopDisplayDetailsViewFlags.GDD_DETAILS_VIEW_FLAG_TOOLBAR_OPEN;

                return true; // return false to show details view, true to cancel it.
            }
            RegistryKey key;
            String[] cmd = this.snippet.Split('|');
            String[] listData, listRules, listPlayers;

            int queryPort = Int32.Parse(cmd[4]);
            ctl.queryServerDetails(cmd[3],
                                                                cmd[1],
                                                                queryPort,
                                                                out listData,
                                                                out listRules,
                                                                out listPlayers
                                                               );

            System.Windows.Forms.Panel serverPanel;
            System.Windows.Forms.PictureBox serverPic;
            System.Windows.Forms.Label serverStats;
            System.Windows.Forms.ListView serverPlayers;
            System.Windows.Forms.Label serverMap;
            System.Windows.Forms.Label serverType;
            System.Windows.Forms.Label serverName;
            System.Windows.Forms.ColumnHeader columnID;
            System.Windows.Forms.TabControl tabControl1;
            System.Windows.Forms.TabPage tabPage1;
            System.Windows.Forms.TabPage tabPage2;
            System.Windows.Forms.ColumnHeader ruleName;
            System.Windows.Forms.ColumnHeader ruleValue;
            System.Windows.Forms.ListView serverRules;

            serverPanel = new System.Windows.Forms.Panel();
            serverPic = new System.Windows.Forms.PictureBox();
            serverStats = new System.Windows.Forms.Label();
            serverPlayers = new System.Windows.Forms.ListView();
            columnID = new System.Windows.Forms.ColumnHeader();
            serverMap = new System.Windows.Forms.Label();
            serverType = new System.Windows.Forms.Label();
            serverName = new System.Windows.Forms.Label();
            tabControl1 = new System.Windows.Forms.TabControl();
            tabPage1 = new System.Windows.Forms.TabPage();
            tabPage2 = new System.Windows.Forms.TabPage();
            serverRules = new System.Windows.Forms.ListView();
            ruleName = new System.Windows.Forms.ColumnHeader();
            ruleValue = new System.Windows.Forms.ColumnHeader();

            try
            {
                String[] snippetData = snippet.Split('|');
                //
                // serverPanel
                //
                serverPanel.BackColor = System.Drawing.Color.White;
                serverPanel.Controls.Add(serverPic);
                serverPanel.Controls.Add(serverStats);
                serverPanel.Controls.Add(tabControl1);
                serverPanel.Controls.Add(serverMap);
                serverPanel.Controls.Add(serverType);
                serverPanel.Controls.Add(serverName);
                serverPanel.Location = new System.Drawing.Point(4, 7);
                serverPanel.Name = "serverPanel";
                serverPanel.Size = new System.Drawing.Size(364, 352);
                serverPanel.TabIndex = 1;
                //
                // tabControl1
                //
                tabControl1.Controls.Add(tabPage1);
                tabControl1.Controls.Add(tabPage2);
                tabControl1.Location = new System.Drawing.Point(8, 96);
                tabControl1.Name = "tabControl1";
                tabControl1.SelectedIndex = 0;
                tabControl1.Size = new System.Drawing.Size(352, 232);
                tabControl1.TabIndex = 11;
                tabControl1.Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Bottom;
                //
                // tabPage1
                //
                tabPage1.Controls.Add(serverPlayers);
                tabPage1.Location = new System.Drawing.Point(4, 22);
                tabPage1.Name = "tabPlayers";
                tabPage1.Size = new System.Drawing.Size(344, 206);
                tabPage1.TabIndex = 0;
                tabPage1.Text = "Players";
                //
                // tabPage2
                //
                tabPage2.Controls.Add(serverRules);
                tabPage2.Location = new System.Drawing.Point(4, 22);
                tabPage2.Name = "tabRules";
                tabPage2.Size = new System.Drawing.Size(192, 74);
                tabPage2.TabIndex = 1;
                tabPage2.Text = "Rules";
                //
                // serverPic
                //
                serverPic.Location = new System.Drawing.Point(8, 8);
                serverPic.Name = "serverPic";
                serverPic.Size = new System.Drawing.Size(96, 88);
                serverPic.TabIndex = 10;
                serverPic.TabStop = false;
                //
                // serverStats
                //
                serverStats.BackColor = System.Drawing.Color.White;
                serverStats.Location = new System.Drawing.Point(108, 32);
                serverStats.Name = "serverStats";
                serverStats.Size = new System.Drawing.Size(200, 16);
                serverStats.TabIndex = 6;
                if (this.source == "0,0,0")
                {
                    serverStats.Text = ctl.lang.getValue("detailsOffline");
                    serverStats.ForeColor = Color.DarkRed;
                }
                else
                {
                    String[] stats = this.source.Split(',');
                    serverStats.Text = stats[0]+"ms ("+stats[1]+"/"+stats[2]+" Spieler)";

                    int ping = Int32.Parse(stats[0]);
                    if (ping < 80)
                        serverStats.ForeColor = Color.DarkGreen;
                    else if (ping < 100)
                        serverStats.ForeColor = Color.Green;
                    else if (ping < 150)
                        serverStats.ForeColor = Color.Orange;
                    else if (ping < 200)
                        serverStats.ForeColor = Color.DarkOrange;
                    else if (ping < 250)
                        serverStats.ForeColor = Color.Red;
                    else
                        serverStats.ForeColor = Color.DarkRed;

                }
                //
                // serverPlayers
                //
                serverPlayers.BackColor = System.Drawing.Color.White;
                serverPlayers.BorderStyle = System.Windows.Forms.BorderStyle.None;
                serverPlayers.Columns.Add(columnID);
                serverPlayers.FullRowSelect = true;
                serverPlayers.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable;
                serverPlayers.Location = new System.Drawing.Point(0, 0);
                serverPlayers.Name = "serverPlayers";
                serverPlayers.Size = new System.Drawing.Size(344, 208);
                serverPlayers.TabIndex = 9;
                serverPlayers.View = System.Windows.Forms.View.Details;
                serverPlayers.Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Bottom;
                //
                // columnID
                //
                columnID.Text = "#";
                columnID.Width = 25;
                //
                key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Imagine Interactive\Gameserver Panel\Games\"+snippetData[0]);
                String[] columns = key.GetValue("columns").ToString().Split(',');
                key.Close();
                for (int i=0; i<columns.Length; i++)
                {
                    if (columns[i] != "-")
                    {
                        ColumnHeader head = new ColumnHeader();
                        head.Text = columns[i];
                        if (i == 0) head.Width = 200;
                        serverPlayers.Columns.Add(head);
                    }
                }
                //
                // serverMap
                //
                serverMap.BackColor = System.Drawing.Color.White;
                serverMap.Location = new System.Drawing.Point(108, 80);
                serverMap.Name = "serverMap";
                serverMap.Size = new System.Drawing.Size(200, 16);
                serverMap.TabIndex = 8;
                String map = "unknown";
                if (snippetData.Length >= 6)
                {
                    map = snippetData[5];
                }
                serverMap.Text = ctl.lang.getValue("detailsMap")+": "+map;
                //
                // serverType
                //
                serverType.BackColor = System.Drawing.Color.White;
                serverType.Location = new System.Drawing.Point(108, 56);
                serverType.Name = "serverType";
                serverType.Size = new System.Drawing.Size(200, 16);
                serverType.TabIndex = 7;
                serverType.Text = ctl.lang.getValue("detailsGame")+": "+snippetData[0];
                //
                // serverName
                //
                serverName.BackColor = System.Drawing.Color.White;
                serverName.Location = new System.Drawing.Point(108, 8);
                serverName.Name = "serverName";
                serverName.Size = new System.Drawing.Size(240, 16);
                serverName.TabIndex = 5;
                serverName.Text = this.heading + " " + cmd[1]+":"+cmd[2];
                //
                // serverRules
                //
                serverRules.BackColor = System.Drawing.Color.White;
                serverRules.BorderStyle = System.Windows.Forms.BorderStyle.None;
                serverRules.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
                                                                                              ruleName,
                                                                                              ruleValue});
                serverRules.FullRowSelect = true;
                serverRules.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable;
                serverRules.Location = new System.Drawing.Point(0, -1);
                serverRules.Name = "serverRules";
                serverRules.Size = new System.Drawing.Size(344, 208);
                serverRules.TabIndex = 11;
                serverRules.View = System.Windows.Forms.View.Details;
                serverRules.Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Bottom;
                //
                // ruleName
                //
                ruleName.Text = "Name";
                ruleName.Width = 100;
                //
                // ruleValue
                //
                ruleValue.Text = "Value";
                ruleValue.Width = 238;

                // Fill Players
                serverPlayers.Items.Clear();
                for (int i=0; i<listPlayers.Length; i++)
                {
                    try
                    {
                        if (listPlayers[i] == null) continue;
                        String player = listPlayers[i].Trim();
                        if (player.Length > 0)
                        {
                            // MessageBox.Show("adding "+listPlayers[i]);
                            String[] playerData = player.Split(',');
                            ListViewItem listItem = serverPlayers.Items.Add((i+1).ToString()+".");
                            for (int c=0; c<columns.Length; c++)
                            {
                                if (columns[c] != "-")
                                    listItem.SubItems.Add( playerData[c] );
                            }
                        }
                    }
                    catch (Exception E)
                    {
                        Log.Error("Adding Player to DetailsView: "+E.Message);
                    }
                }

                // Fill Rules
                serverRules.Items.Clear();
                for (int i=0; i<listRules.Length; i++)
                {
                    try
                    {
                        if (listRules[i] == null) continue;
                        String rule = listRules[i].Trim();
                        if (rule.Length > 0)
                        {
                            String[] ruleData = rule.Split('=');
                            ListViewItem listItem = serverRules.Items.Add(ruleData[0]);
                            listItem.SubItems.Add( ruleData[1] );
                        }
                    }
                    catch (Exception E)
                    {
                        Log.Error("Adding Rule to DetailsView: "+E.Message);
                    }
                }

                serverPic.Image = new Bitmap( serverPic.Width, serverPic.Height );
                Graphics g = Graphics.FromImage( serverPic.Image );
                String resource = "GameserverPanel.Resources."+cmd[0]+".ico";
                Stream resStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resource);
                if (resStream != null)
                {
                    g.DrawImage( new Icon(resStream, 16, 16).ToBitmap(), 0, 0, 64, 64);
                    g.Dispose();
                }
            }
            catch (Exception E)
            {
                Log.Error("DetailsView: "+E.Message);
            }

            detailsControl = serverPanel;
            title = heading;
            flags = GoogleDesktopDisplayDetailsViewFlags.GDD_DETAILS_VIEW_FLAG_TOOLBAR_OPEN;

            return false; // return false to show details view, true to cancel it.
        }
コード例 #8
0
ファイル: Plugin.cs プロジェクト: aachyee/desktopgadgets
        //handler clicks
        void IContextMenu.InvokeCommand(IntPtr pici)
        {
            Type typINVOKECOMMANDINFO =
                Type.GetType("ShellExt.INVOKECOMMANDINFO");
            INVOKECOMMANDINFO ici =
                (INVOKECOMMANDINFO)Marshal.PtrToStructure(pici, typINVOKECOMMANDINFO);

            GameserverPlugin ctl = this.open_command as GameserverPlugin;

            Log.Debug("Item ContextMenu clicked: "+ici.verb);

            if (this.snippet == "MESSAGE")
            {
                switch (ici.verb)
                {
                    case 0: formServer newServer = new formServer(0);
                            newServer.dataObject = ctl;
                            newServer.ShowDialog();

                            ctl.refresh(null);
                            break;
                }
            }
            else
            {
                switch (ici.verb)
                {
                    case 0: OpenItem();
                        break;
                    case 1: Object[] friends = ctl.getFriends();
                        String[] cmd = this.snippet.Split('|');
                        String game = cmd[0];
                        String ip = cmd[1];
                        int port = Int32.Parse(cmd[2]);
                        friendList fList = new friendList(friends, game, ip, port);
                        fList.dataObject = open_command;
                        if (fList.ShowDialog() == DialogResult.OK)
                        {
                            for (int i=0; i<fList.friends.CheckedItems.Count; i++)
                            {
                                String line = fList.friends.CheckedItems[i].ToString();
                                String friendId = line.Split('\n').GetValue(1).ToString();
                                friendId = friendId.Trim();
                                bool sideBar = line.Split('\n').GetValue(2).ToString().Equals("true");

                                if (sideBar && !fList.labelSendText.Checked)
                                {
                                    Log.Debug("Sending Data Invite to "+friendId);
                                    ctl.talk_service.SendTalkData(friendId, this.snippet);
                                }
                                else
                                {
                                    Log.Debug("Sending Text Invite to "+friendId);
                                    String msg = String.Format(ctl.lang.getValue("talkInviteText"), game, ip, port);
                                    ctl.talk_service.SendTalkText(friendId, msg);
                                }
                            }
                        }
                        fList.Dispose();
                        /*
                        if (friend.has_sidebar)
                        {
                            ctl.talk_service.SendTalkData(friend.user_id, this.snippet);
                        }
                        else
                        {
                            String[] cmd = this.snippet.Split('|');
                            String game = cmd[0];
                            String ip = cmd[1];
                            int port = Int32.Parse(cmd[2]);
                            String msg = String.Format("Lust auf eine Runde {0} auf {1}:{2}?", game, ip, port);
                            ctl.talk_service.SendTalkText(friend.user_id, msg);
                        }
                        MessageBox.Show("Einladung an "+friend.user_id+" gesendet");
                        */
                        break;
                    case 2: ctl.refresh(null);
                        break;
                }
            }
        }