Ejemplo n.º 1
0
 protected void OnLabelAttached()
 {
     LabelAttached?.Invoke(this, null);
 }
Ejemplo n.º 2
0
        private void RefreshList(bool first = false)
        {
            LabelTarget.SuspendLayout();
            LabelIP.SuspendLayout();
            LabelAttached.SuspendLayout();

            LabelTarget.Text   = "Target: NULL";
            LabelIP.Text       = "IP/Port: 0.0.0.0:0";
            LabelAttached.Text = "Attached: False";

            LvTM.Items.Clear();
            if (_tmapi != null)
            {
                if (!_tmapi.InitComms())
                {
                    // Target Manager not installed
                    MbOpenTM.Visible       = false;
                    MbRefresh.Visible      = false;
                    MbNotInstalled.Visible = true;
                    LvTM.Enabled           = false;

                    MetroFramework.MetroMessageBox.Show(Application.OpenForms["Display"], "Please download and install the Target Manager before using this Communicator.", "Looks like you don't have the Target Manager installed.");
                    goto exit;
                }


                List <string> targets = _tmapi.GetAllTargets();
                if (targets == null || targets.Count == 0)
                {
                    // Target Manager not configured
                    MbOpenTM.Visible       = true;
                    MbRefresh.Visible      = true;
                    MbNotInstalled.Visible = false;
                    LvTM.Enabled           = false;

                    MetroFramework.MetroMessageBox.Show(Application.OpenForms["Display"], "Please open the Target Manager and add your PS3 as a debugging station.", "Looks like you don't have the Target Manager configured.");
                    goto exit;
                }

                // Target Manager configured
                MbOpenTM.Visible       = false;
                MbRefresh.Visible      = false;
                MbNotInstalled.Visible = false;
                LvTM.Enabled           = true;

                int connected = _tmapi.GetConnectedTarget();
                for (int target = 0; target < targets.Count; target++)
                {
                    LvTM.Items.Add(new ListViewItem(targets[target], 0)
                    {
                        ToolTipText = "Status: Not Connected", Tag = 0
                    });
                    if (target == connected)
                    {
                        // If this is the first time calling RefreshList and AttachOnConnect
                        if (first && McAttachOnConnect.Checked)
                        {
                            if (_tmapi.AttachProcess(McContinueOnAttach.Checked))
                            {
                                _com.Ready = true;
                            }
                        }

                        LvTM.Items[target].Tag         = 1;
                        LvTM.Items[target].ToolTipText = "Status: Connected, Not Attached";
                        if (_com.GetProcessState() != NetCheatX.Core.Types.ProcessState.Killed)
                        {
                            LvTM.Items[target].Tag         = 2;
                            LvTM.Items[target].ToolTipText = "Status: Connected and Attached";
                        }

                        LabelTarget.Text   = "Target: " + _tmapi.SCE.GetTargetName();
                        LabelIP.Text       = "IP/Port: " + _tmapi.SCE.GetTargetIPPort();
                        LabelAttached.Text = "Attached: " + ((int)LvTM.Items[target].Tag == 2).ToString();
                    }
                }
            }


            exit : LabelTarget.ResumeLayout(true);
            LabelIP.ResumeLayout(true);
            LabelAttached.ResumeLayout(true);
        }