Exemplo n.º 1
0
        public void OverrideGroundTrafficINISettings(ATCIdentifier?ATCId, bool?PreferActive, byte?RangeInAirInNM, byte?RangeOnGroundInNM)
        {
            bool flag = false;

            if (ATCId.HasValue)
            {
                this.AIOptGroundIDString.Value = (byte)ATCId.Value;
                flag = true;
            }
            if (PreferActive.HasValue)
            {
                this.AIOptGroundPreferActive.Value = PreferActive.Value ? (byte)1 : (byte)0;
                flag = true;
            }
            byte?nullable1 = RangeInAirInNM;

            if ((nullable1.HasValue ? new int?((int)nullable1.GetValueOrDefault()) : new int?()).HasValue)
            {
                this.AIOptGroundRangeInAir.Value = RangeInAirInNM.Value;
                flag = true;
            }
            byte?nullable2 = RangeOnGroundInNM;

            if ((nullable2.HasValue ? new int?((int)nullable2.GetValueOrDefault()) : new int?()).HasValue)
            {
                this.AIOptGroundRangeOnGround.Value = RangeOnGroundInNM.Value;
                flag = true;
            }
            if (!flag)
            {
                return;
            }
            FSUIPCConnection.Process(this.classInstance, this.AIWriteOptionsGroupGround);
        }
Exemplo n.º 2
0
        private string getATCString(int ID, int Command)
        {
            int num = 4112;

            this.atcInfoCommand.Value   = Command;
            this.atcInfoAiID.Value      = ID;
            this.atcInfoSignature.Value = num;
            FSUIPCConnection.Process(this.classInstance, this.AITrafficIDStringGroupWrite);
            Thread.Sleep(10);
            FSUIPCConnection.Process(this.classInstance, this.AITrafficIDStringGroupTest);
            while (this.atcInfoTimeStampInit.Value == this.atcInfoTimeStamp.Value)
            {
                Thread.Sleep(10);
                FSUIPCConnection.Process(this.classInstance, this.AITrafficIDStringGroupTest);
            }
            FSUIPCConnection.Process(this.classInstance, this.AITrafficIDStringGroupRead);
            string str1 = Encoding.ASCII.GetString(this.atcInfoString.Value);
            string str2;

            if (Command == 3)
            {
                int length = str1.IndexOf(char.MinValue);
                str2 = str1.Substring(0, length) + "~" + str1.Substring(length + 1, str1.IndexOf(char.MinValue, length + 1) - length - 1);
            }
            else
            {
                str2 = str1.Substring(0, str1.IndexOf(char.MinValue));
            }
            return(str2);
        }
Exemplo n.º 3
0
        public void RemoveAll()
        {
            if (this.keySlotIndicators.Count + this.buttonSlotIndicators.Count + this.menuSlotIndicators.Count <= 0)
            {
                return;
            }
            IDictionaryEnumerator enumerator1 = (IDictionaryEnumerator)this.keySlotIndicators.GetEnumerator();

            while (enumerator1.MoveNext())
            {
                new Offset <int>(this.temporaryGroup, this.keySlotIndicators[enumerator1.Key.ToString()].Address - 3, true).Value = 0;
            }
            IDictionaryEnumerator enumerator2 = (IDictionaryEnumerator)this.buttonSlotIndicators.GetEnumerator();

            while (enumerator2.MoveNext())
            {
                new Offset <int>(this.temporaryGroup, this.buttonSlotIndicators[enumerator2.Key.ToString()].Address - 3, true).Value = 0;
            }
            IDictionaryEnumerator enumerator3 = (IDictionaryEnumerator)this.menuSlotIndicators.GetEnumerator();

            while (enumerator3.MoveNext())
            {
                new Offset <int>(this.temporaryGroup, this.menuSlotIndicators[enumerator3.Key.ToString()].Address - 3, true).Value = 0;
            }
            FSUIPCConnection.Process(this.classinstance, this.temporaryGroup);
            FSUIPCConnection.DeleteGroup(this.temporaryGroup);
            FSUIPCConnection.DeleteGroup(this.pollingSlotsGroup);
            this.menuSlotIndicators.Clear();
            this.buttonSlotIndicators.Clear();
            this.keySlotIndicators.Clear();
        }
Exemplo n.º 4
0
 public static void Process(byte ClassInstance, string GroupName)
 {
     FSUIPCConnection.Process(ClassInstance, (IEnumerable <string>) new List <string>()
     {
         GroupName
     });
 }
Exemplo n.º 5
0
 public void RemoveJoystickButtonPress(string ID)
 {
     new Offset <int>(this.temporaryGroup, this.buttonSlotIndicators[ID].Address - 3, true).Value = 0;
     FSUIPCConnection.Process(this.classinstance, this.temporaryGroup);
     FSUIPCConnection.DeleteGroup(this.temporaryGroup);
     this.buttonSlotIndicators[ID].Disconnect();
     this.buttonSlotIndicators.Remove(ID);
 }
Exemplo n.º 6
0
 public void Reconnect(bool ForNextProcessOnly)
 {
     if (!this.IsConnected)
     {
         FSUIPCConnection.AddOffset((IOffset)this);
     }
     this.onceOnly = ForNextProcessOnly;
 }
Exemplo n.º 7
0
 public static void Close()
 {
     byte[] array = new byte[FSUIPCConnection.connections.Count];
     FSUIPCConnection.connections.Keys.CopyTo(array, 0);
     foreach (byte ClassInstance in array)
     {
         FSUIPCConnection.Close(ClassInstance);
     }
 }
Exemplo n.º 8
0
 public void RemoveMenuItem(string ID)
 {
     new Offset <int>(this.temporaryGroup, this.menuSlotIndicators[ID].Address - 3, true).Value = 0;
     FSUIPCConnection.Process(this.classinstance, this.temporaryGroup);
     FSUIPCConnection.DeleteGroup(this.temporaryGroup);
     this.menuSlotIndicators[ID].Disconnect();
     this.menuSlotIndicators.Remove(ID);
     this.menuKeepAlives[ID].Disconnect();
     this.menuKeepAlives.Remove(ID);
 }
Exemplo n.º 9
0
 public void SendTCASTargets()
 {
     if (this.aiTCASTargets.Count <= 0)
     {
         return;
     }
     foreach (AIPlaneInfo aiTcasTarget in this.aiTCASTargets)
     {
         new Offset <byte[]>(this.AITCASWrite, 8064, 40, true).Value = aiTcasTarget.getTCASByteArray();
     }
     FSUIPCConnection.Process(this.classInstance, this.AITCASWrite);
     FSUIPCConnection.DeleteGroup(this.AITCASWrite);
     this.aiTCASTargets.Clear();
 }
Exemplo n.º 10
0
        public void KeepMenuItemsAlive()
        {
            if (this.menuKeepAlives.Count <= 0)
            {
                return;
            }
            IDictionaryEnumerator enumerator = (IDictionaryEnumerator)this.menuKeepAlives.GetEnumerator();

            while (enumerator.MoveNext())
            {
                ((Offset <byte>)enumerator.Value).Value = byte.MaxValue;
            }
            FSUIPCConnection.Process(this.classinstance, this.keepAliveGroup);
        }
Exemplo n.º 11
0
        internal UserInputServices(byte ClassInstance)
        {
            this.classinstance           = ClassInstance;
            this.temporaryGroup         += this.classinstance.ToString();
            this.pollingSlotsGroup      += this.classinstance.ToString();
            this.pollingSlotsResetGroup += this.classinstance.ToString();
            this.keepAliveGroup         += this.classinstance.ToString();
            Offset <int> offset1 = new Offset <int>(this.temporaryGroup, 10508);
            Offset <int> offset2 = new Offset <int>(this.temporaryGroup, 12812);

            FSUIPCConnection.Process(this.classinstance, this.temporaryGroup);
            this.keySlotCount    = offset2.Value;
            this.buttonSlotCount = offset1.Value;
            FSUIPCConnection.DeleteGroup(this.temporaryGroup);
        }
Exemplo n.º 12
0
 public void Disconnect(bool AfterNextProcess)
 {
     if (AfterNextProcess)
     {
         this.onceOnly = true;
     }
     else
     {
         if (!this.IsConnected)
         {
             return;
         }
         FSUIPCConnection.RemoveOffset((IOffset)this);
     }
 }
Exemplo n.º 13
0
        public void AddJoystickButtonPress(string ID, byte JoystickNumber, byte ButtonNumber, StateChange StateChangeToDetect)
        {
            if (this.buttonSlotCount <= 0 || this.buttonSlotCount >= 9000)
            {
                throw new FSUIPCException(FSUIPCError.FSUIPC_ERR_VERSION, "This version of FSUIPC is too old to support joystick button user input.");
            }
            int freeSlot = this.findFreeSlot(this.buttonSlotsBase, this.buttonSlotCount);

            if (freeSlot < 0)
            {
                throw new FSUIPCException(FSUIPCError.FSUIPC_BUTTON_SLOTS_FULL, "Cannot add button press: " + ID);
            }
            new Offset <int>(this.temporaryGroup, this.buttonSlotsBase + freeSlot * 4, true).Value = this.assembleInt((byte)((uint)JoystickNumber + 128U), ButtonNumber, (byte)StateChangeToDetect);
            FSUIPCConnection.Process(this.classinstance, this.temporaryGroup);
            FSUIPCConnection.DeleteGroup(this.temporaryGroup);
            Offset <byte> offset = new Offset <byte>(this.pollingSlotsGroup, this.buttonSlotsBase + freeSlot * 4 + 3);

            this.buttonSlotIndicators.Add(ID, offset);
        }
Exemplo n.º 14
0
        public void AddKeyPresss(string ID, ModifierKeys Modifier, Keys Key, bool PassThroughToFS)
        {
            if (this.keySlotCount <= 0 || this.keySlotCount >= 9000)
            {
                throw new FSUIPCException(FSUIPCError.FSUIPC_ERR_VERSION, "This version of FSUIPC is too old to support hot key user input.");
            }
            int freeSlot = this.findFreeSlot(this.keySlotsBase, this.keySlotCount);

            if (freeSlot < 0)
            {
                throw new FSUIPCException(FSUIPCError.FSUIPC_KEY_SLOTS_FULL, "Cannot add keypress: " + ID);
            }
            new Offset <int>(this.temporaryGroup, this.keySlotsBase + freeSlot * 4, true).Value = this.assembleInt((byte)Key, (byte)Modifier, PassThroughToFS ? (byte)2 : (byte)0);
            FSUIPCConnection.Process(this.classinstance, this.temporaryGroup);
            FSUIPCConnection.DeleteGroup(this.temporaryGroup);
            Offset <byte> offset = new Offset <byte>(this.pollingSlotsGroup, this.keySlotsBase + freeSlot * 4 + 3);

            this.keySlotIndicators.Add(ID, offset);
        }
Exemplo n.º 15
0
        private int findFreeSlot(int slotsBase, int slotCount)
        {
            int num = -1;

            Offset <int>[] offsetArray = new Offset <int> [slotCount];
            for (int index = 0; index < slotCount; ++index)
            {
                offsetArray[index] = new Offset <int>(this.temporaryGroup, slotsBase + 4 * index);
            }
            FSUIPCConnection.Process(this.classinstance, this.temporaryGroup);
            for (int index = 0; index < slotCount && num < 0; ++index)
            {
                if (offsetArray[index].Value == 0)
                {
                    num = index;
                }
            }
            FSUIPCConnection.DeleteGroup(this.temporaryGroup);
            return(num);
        }
Exemplo n.º 16
0
        public void OverrideAirborneTrafficINISettings(ATCIdentifier?ATCId, byte?RangeInNM)
        {
            bool flag = false;

            if (ATCId.HasValue)
            {
                this.AIOptAirIDString.Value = (byte)ATCId.Value;
                flag = true;
            }
            byte?nullable = RangeInNM;

            if ((nullable.HasValue ? new int?((int)nullable.GetValueOrDefault()) : new int?()).HasValue)
            {
                this.AIOptAirRange.Value = RangeInNM.Value;
                flag = true;
            }
            if (!flag)
            {
                return;
            }
            FSUIPCConnection.Process(this.classInstance, this.AIWriteOptionsGroupAirborne);
        }
Exemplo n.º 17
0
        public void AddMenuItem(string ID, string MenuText, bool PauseFSOnSelection)
        {
            if (this.keySlotCount <= 0 || this.keySlotCount >= 9000)
            {
                throw new FSUIPCException(FSUIPCError.FSUIPC_ERR_VERSION, "This version of FSUIPC is too old to support adding FS menu items.");
            }
            int freeSlot = this.findFreeSlot(this.keySlotsBase, this.keySlotCount);

            if (freeSlot < 0)
            {
                throw new FSUIPCException(FSUIPCError.FSUIPC_KEY_SLOTS_FULL, "Cannot add menu item: " + ID);
            }
            new Offset <int>(this.temporaryGroup, this.keySlotsBase + freeSlot * 4, true).Value = this.assembleInt(byte.MaxValue, byte.MaxValue, PauseFSOnSelection ? (byte)2 : (byte)0);
            new Offset <string>(this.temporaryGroup, 12256, 31, true).Value = new string(Convert.ToChar(freeSlot), 1) + MenuText;
            FSUIPCConnection.Process(this.classinstance, this.temporaryGroup);
            FSUIPCConnection.DeleteGroup(this.temporaryGroup);
            Offset <byte> offset1 = new Offset <byte>(this.pollingSlotsGroup, this.keySlotsBase + freeSlot * 4 + 3);

            this.menuSlotIndicators.Add(ID, offset1);
            Offset <byte> offset2 = new Offset <byte>(this.keepAliveGroup, this.keySlotsBase + freeSlot * 4 + 1, true);

            this.menuKeepAlives.Add(ID, offset2);
            Thread.Sleep(250);
        }
Exemplo n.º 18
0
        public static void Process(byte ClassInstance, IEnumerable <string> GroupNames)
        {
            lock (FSUIPCConnection.dataGroups)
            {
                if (FSUIPCConnection.connections.ContainsKey(ClassInstance))
                {
                    ConnectionInfo connection = FSUIPCConnection.connections[ClassInstance];
                    if (connection.pView == IntPtr.Zero)
                    {
                        throw new FSUIPCException(FSUIPCError.FSUIPC_ERR_NOTOPEN, "The connection to FSUIPC is not open.");
                    }
                    int            num1        = 80;
                    List <IOffset> offsetList1 = new List <IOffset>();
                    int            int32       = connection.pView.ToInt32();
                    int            num2        = int32;
                    int            num3        = 0;
                    int            num4        = 0;
                    List <IOffset> offsetList2 = new List <IOffset>();
                    foreach (string groupName in GroupNames)
                    {
                        if (!FSUIPCConnection.dataGroups.ContainsKey(groupName))
                        {
                            throw new Exception("Group '" + groupName + "' does not exsist.");
                        }
                        Dictionary <Guid, IOffset> dataGroup = FSUIPCConnection.dataGroups[groupName];
                        offsetList2.AddRange((IEnumerable <IOffset>)dataGroup.Values);
                    }
                    int num5 = (num1 << 8) + 97;
                    foreach (IOffset offset in offsetList2)
                    {
                        if (!offset.Write)
                        {
                            switch (offset.DataType)
                            {
                            case fsuipcDataType.TypeByteArray:
                                byte[] numArray = (byte[])offset.Value;
                                if (numArray != null)
                                {
                                    byte[] oldValue = (byte[])offset.OldValue;
                                    bool   flag     = true;
                                    for (int index = 0; index < oldValue.Length; ++index)
                                    {
                                        flag &= (int)oldValue[index] == (int)numArray[index];
                                    }
                                    offset.Write = !flag && (offset.WriteOnly || offset.FileAddress != 0);
                                    break;
                                }
                                break;

                            case fsuipcDataType.TypeBitArray:
                                BitArray bitArray = (BitArray)offset.Value;
                                if (bitArray != null)
                                {
                                    BitArray oldValue = (BitArray)offset.OldValue;
                                    bool     flag     = true;
                                    for (int index = 0; index < oldValue.Length; ++index)
                                    {
                                        flag &= oldValue[index] == bitArray[index];
                                    }
                                    offset.Write = !flag && (offset.WriteOnly || offset.FileAddress != 0);
                                    break;
                                }
                                break;
                            }
                        }
                        ++num4;
                    }
                    int num6 = 0;
                    int num7 = (num5 << 16) + 30060;
                    foreach (IOffset offset in offsetList2)
                    {
                        if (offset.OnceOnly)
                        {
                            offsetList1.Add(offset);
                        }
                        int[] source1 = (int[])null;
                        if (offset.Write)
                        {
                            source1 = new int[3]
                            {
                                2,
                                offset.Address,
                                offset.DataLength
                            };
                            num3 = source1.Length * 4;
                        }
                        else if (!offset.WriteOnly)
                        {
                            source1 = new int[4]
                            {
                                1,
                                offset.Address,
                                offset.DataLength,
                                num7
                            };
                            num3 = source1.Length * 4;
                            offset.FileAddress = num2 + num3;
                        }
                        if (source1 != null)
                        {
                            if ((long)(num2 - int32 + num3 + offset.DataLength + 4) > (long)FSUIPCConnection.MaximumDataSize)
                            {
                                throw new FSUIPCException(FSUIPCError.FSUIPC_ERR_SIZE, "The amount of data requested exceeded the maximum allowed in one Process().");
                            }
                            byte[] source2 = new byte[source1[2]];
                            if (offset.Write)
                            {
                                switch (offset.DataType)
                                {
                                case fsuipcDataType.TypeByte:
                                    source2[0] = (byte)offset.Value;
                                    break;

                                case fsuipcDataType.TypeInt16:
                                    source2 = BitConverter.GetBytes((short)offset.Value);
                                    break;

                                case fsuipcDataType.TypeInt32:
                                    source2 = BitConverter.GetBytes((int)offset.Value);
                                    break;

                                case fsuipcDataType.TypeInt64:
                                    source2 = BitConverter.GetBytes((long)offset.Value);
                                    break;

                                case fsuipcDataType.TypeDouble:
                                    source2 = BitConverter.GetBytes((double)offset.Value);
                                    break;

                                case fsuipcDataType.TypeFloat:
                                    source2 = BitConverter.GetBytes((float)offset.Value);
                                    break;

                                case fsuipcDataType.TypeByteArray:
                                    source2 = (byte[])offset.Value;
                                    if (source2.Length != offset.DataLength)
                                    {
                                        throw new FSUIPCException(FSUIPCError.FSUIPC_ERR_WRITE_OVERFLOW, "Offset for Offset " + offset.Address.ToString("X") + " is a ByteArray with a declared length of " + offset.DataLength.ToString() + " Bytes. The array you are trying to write is different from this. (" + source2.Length.ToString() + " bytes)");
                                    }
                                    source2.CopyTo((Array)offset.OldValue, 0);
                                    break;

                                case fsuipcDataType.TypeUInt16:
                                    source2 = BitConverter.GetBytes((ushort)offset.Value);
                                    break;

                                case fsuipcDataType.TypeUInt32:
                                    source2 = BitConverter.GetBytes((uint)offset.Value);
                                    break;

                                case fsuipcDataType.TypeUInt64:
                                    source2 = BitConverter.GetBytes((ulong)offset.Value);
                                    break;

                                case fsuipcDataType.TypeString:
                                    string s = (string)offset.Value;
                                    if (s.Length >= offset.DataLength)
                                    {
                                        s = s.Substring(0, offset.DataLength - 1);
                                    }
                                    source1[2] = s.Length + 1;
                                    source2    = new byte[source1[2]];
                                    Encoding.ASCII.GetBytes(s).CopyTo((Array)source2, 0);
                                    break;

                                case fsuipcDataType.TypeBitArray:
                                    BitArray bits = (BitArray)offset.Value;
                                    if (bits.Length != offset.DataLength * 8)
                                    {
                                        throw new FSUIPCException(FSUIPCError.FSUIPC_ERR_WRITE_OVERFLOW, "Offset for Offset " + offset.Address.ToString("X") + " is a BitArray with a declared length of " + offset.DataLength.ToString() + " Bytes. The BitArray you are trying to write is different from this. (" + bits.Length.ToString() + " bits)");
                                    }
                                    offset.OldValue = (object)new BitArray(bits);
                                    bits.CopyTo((Array)source2, 0);
                                    break;

                                case fsuipcDataType.TypeSByte:
                                    source2[0] = (byte)offset.Value;
                                    break;
                                }
                            }
                            Marshal.Copy(source1, 0, new IntPtr(num2), source1.Length);
                            num2 += num3;
                            Marshal.Copy(source2, 0, new IntPtr(num2), source2.Length);
                            num2 += source2.Length;
                        }
                        ++num6;
                    }
                    Marshal.WriteInt32(new IntPtr(num2), 0);
                    IntPtr result = IntPtr.Zero;
                    int    num8   = 0;
                    while (Win32.SendMessageTimeout(connection.hWnd, connection.messageID, connection.atomFileName, IntPtr.Zero, SendMessageTimeoutFlags.SMTO_BLOCK, 2000U, out result) == IntPtr.Zero && num8 < 10)
                    {
                        ++num8;
                        Thread.Sleep(100);
                    }
                    if (num8 >= 10)
                    {
                        if (Marshal.GetLastWin32Error() == 0)
                        {
                            throw new FSUIPCException(FSUIPCError.FSUIPC_ERR_TIMEOUT, "SendMessage timed-out.  Tried 10 times.");
                        }
                        throw new FSUIPCException(FSUIPCError.FSUIPC_ERR_SENDMSG, "Error sending message to FSUIPC.");
                    }
                    connection.pView.ToInt32();
                    int num9 = 0;
                    foreach (IOffset offset in offsetList2)
                    {
                        if (!offset.Write && !offset.WriteOnly)
                        {
                            byte[] numArray = new byte[offset.DataLength];
                            Marshal.Copy(new IntPtr(offset.FileAddress), numArray, 0, numArray.Length);
                            switch (offset.DataType)
                            {
                            case fsuipcDataType.TypeByte:
                                offset.Value = (object)numArray[0];
                                break;

                            case fsuipcDataType.TypeInt16:
                                offset.Value = (object)BitConverter.ToInt16(numArray, 0);
                                break;

                            case fsuipcDataType.TypeInt32:
                                offset.Value = (object)BitConverter.ToInt32(numArray, 0);
                                break;

                            case fsuipcDataType.TypeInt64:
                                offset.Value = (object)BitConverter.ToInt64(numArray, 0);
                                break;

                            case fsuipcDataType.TypeDouble:
                                offset.Value = (object)BitConverter.ToDouble(numArray, 0);
                                break;

                            case fsuipcDataType.TypeFloat:
                                offset.Value = (object)BitConverter.ToSingle(numArray, 0);
                                break;

                            case fsuipcDataType.TypeByteArray:
                                offset.Value    = (object)numArray;
                                offset.OldValue = (object)numArray;
                                break;

                            case fsuipcDataType.TypeUInt16:
                                offset.Value = (object)BitConverter.ToUInt16(numArray, 0);
                                break;

                            case fsuipcDataType.TypeUInt32:
                                offset.Value = (object)BitConverter.ToUInt32(numArray, 0);
                                break;

                            case fsuipcDataType.TypeUInt64:
                                offset.Value = (object)BitConverter.ToUInt64(numArray, 0);
                                break;

                            case fsuipcDataType.TypeString:
                                string str    = Encoding.ASCII.GetString(numArray);
                                int    length = str.IndexOf(char.MinValue);
                                offset.Value = length <= 0 ? (length != -1 ? (object)"" : (object)str) : (object)str.Substring(0, length);
                                break;

                            case fsuipcDataType.TypeBitArray:
                                offset.Value    = (object)new BitArray(numArray);
                                offset.OldValue = (object)new BitArray(numArray);
                                break;

                            case fsuipcDataType.TypeSByte:
                                offset.Value = (object)(sbyte)numArray[0];
                                break;
                            }
                        }
                        offset.Write = false;
                        ++num9;
                    }
                    foreach (IOffset Offset in offsetList1)
                    {
                        Offset.OnceOnly = false;
                        FSUIPCConnection.RemoveOffset(Offset);
                    }
                }
                else
                {
                    if ((int)ClassInstance == 0)
                    {
                        throw new FSUIPCException(FSUIPCError.FSUIPC_ERR_NOTOPEN, "The connection to FSUIPC is not open.");
                    }
                    throw new FSUIPCException(FSUIPCError.FSUIPC_ERR_NOTOPEN, "The connection to class instance " + ClassInstance.ToString("D2") + " of WideClient.exe is not open.");
                }
            }
        }
Exemplo n.º 19
0
        public void CheckForInput()
        {
            if (this.keySlotIndicators.Count + this.buttonSlotIndicators.Count + this.menuSlotIndicators.Count <= 0)
            {
                return;
            }
            FSUIPCConnection.Process(this.classinstance, this.pollingSlotsGroup);
            List <UserInputKeyEventArgs>    inputKeyEventArgsList    = new List <UserInputKeyEventArgs>();
            List <UserInputButtonEventArgs> inputButtonEventArgsList = new List <UserInputButtonEventArgs>();
            List <UserInputMenuEventArgs>   inputMenuEventArgsList   = new List <UserInputMenuEventArgs>();
            IDictionaryEnumerator           enumerator1 = (IDictionaryEnumerator)this.keySlotIndicators.GetEnumerator();

            while (enumerator1.MoveNext())
            {
                Offset <byte> offset = (Offset <byte>)enumerator1.Value;
                if ((int)offset.Value > 0)
                {
                    Keys keys = Keys.None;
                    if ((int)offset.Value > 1)
                    {
                        keys = (Keys)offset.Value;
                    }
                    inputKeyEventArgsList.Add(new UserInputKeyEventArgs()
                    {
                        ID = enumerator1.Key.ToString(),
                        SecondKeyPressed = keys
                    });
                    new Offset <byte>(this.pollingSlotsResetGroup, offset.address, true).Value = (byte)0;
                }
            }
            IDictionaryEnumerator enumerator2 = (IDictionaryEnumerator)this.menuSlotIndicators.GetEnumerator();

            while (enumerator2.MoveNext())
            {
                Offset <byte> offset = (Offset <byte>)enumerator2.Value;
                if (((int)offset.Value & 1) == 1)
                {
                    inputMenuEventArgsList.Add(new UserInputMenuEventArgs()
                    {
                        ID = enumerator2.Key.ToString()
                    });
                    new Offset <byte>(this.pollingSlotsResetGroup, offset.address, true).Value = (byte)0;
                }
            }
            IDictionaryEnumerator enumerator3 = (IDictionaryEnumerator)this.buttonSlotIndicators.GetEnumerator();

            while (enumerator3.MoveNext())
            {
                Offset <byte> offset = (Offset <byte>)enumerator3.Value;
                if (((int)offset.Value & 1) == 1)
                {
                    bool flag = ((int)offset.Value & 2) == 2;
                    inputButtonEventArgsList.Add(new UserInputButtonEventArgs()
                    {
                        ID          = enumerator3.Key.ToString(),
                        ButtonState = flag
                    });
                    new Offset <byte>(this.pollingSlotsResetGroup, offset.address, true).Value = (byte)0;
                }
            }
            if (inputKeyEventArgsList.Count + inputButtonEventArgsList.Count + inputMenuEventArgsList.Count <= 0)
            {
                return;
            }
            FSUIPCConnection.Process(this.classinstance, this.pollingSlotsResetGroup);
            FSUIPCConnection.DeleteGroup(this.pollingSlotsResetGroup);
            foreach (UserInputKeyEventArgs e in inputKeyEventArgsList)
            {
                if (this.KeyPressed != null)
                {
                    this.KeyPressed((object)this, e);
                }
            }
            foreach (UserInputButtonEventArgs e in inputButtonEventArgsList)
            {
                if (this.ButtonPressed != null)
                {
                    this.ButtonPressed((object)this, e);
                }
            }
            foreach (UserInputMenuEventArgs e in inputMenuEventArgsList)
            {
                if (this.MenuSelected != null)
                {
                    this.MenuSelected((object)this, e);
                }
            }
        }
Exemplo n.º 20
0
 public static void Process(byte ClassInstance)
 {
     FSUIPCConnection.Process(ClassInstance, "");
 }
Exemplo n.º 21
0
 public static void Process(IEnumerable <string> GroupNames)
 {
     FSUIPCConnection.Process((byte)0, GroupNames);
 }
Exemplo n.º 22
0
 public static void Process(string GroupName)
 {
     FSUIPCConnection.Process((byte)0, GroupName);
 }
Exemplo n.º 23
0
 public static void Process()
 {
     FSUIPCConnection.Process((byte)0, "");
 }
Exemplo n.º 24
0
        public static void Open(byte ClassInstance, int RequiredFlightSimVersion)
        {
            FSUIPCConnection.DeleteGroup(FSUIPCConnection.SystemOffsetsGroup);
            bool flag = false;

            if (FSUIPCConnection.connections.ContainsKey(ClassInstance))
            {
                throw new FSUIPCException(FSUIPCError.FSUIPC_ERR_OPEN, "The connection to FSUIPC is already open.");
            }
            ConnectionInfo connectionInfo = new ConnectionInfo();

            FSUIPCConnection.connections.Add(ClassInstance, connectionInfo);
            if ((int)ClassInstance == 0)
            {
                connectionInfo.hWnd = Win32.FindWindowEx(IntPtr.Zero, IntPtr.Zero, "UIPCMAIN", IntPtr.Zero);
                if (connectionInfo.hWnd == IntPtr.Zero)
                {
                    connectionInfo.hWnd = Win32.FindWindowEx(IntPtr.Zero, IntPtr.Zero, "FS98MAIN", IntPtr.Zero);
                    flag = true;
                }
            }
            else
            {
                connectionInfo.hWnd = Win32.FindWindowEx(IntPtr.Zero, IntPtr.Zero, "FS98MAIN" + ClassInstance.ToString("D2"), IntPtr.Zero);
                flag = true;
            }
            if (connectionInfo.hWnd == IntPtr.Zero)
            {
                FSUIPCConnection.Close(ClassInstance);
                throw new FSUIPCException(FSUIPCError.FSUIPC_ERR_NOFS, "Cannot find FSUIPC or WideFS running on this machine.");
            }
            connectionInfo.messageID = Win32.RegisterWindowMessage(FSUIPCConnection.FS6IPCMessageName);
            if ((int)connectionInfo.messageID == 0)
            {
                FSUIPCConnection.Close(ClassInstance);
                throw new FSUIPCException(FSUIPCError.FSUIPC_ERR_REGMSG, "Could not register the IPC window message");
            }
            ++FSUIPCConnection.tryCount;
            string str = FSUIPCConnection.FS6IPCMessageName + ":" + Process.GetCurrentProcess().Id.ToString("X") + ":" + FSUIPCConnection.tryCount.ToString("X");

            connectionInfo.atomFileName = Win32.GlobalAddAtom(str);
            if (connectionInfo.atomFileName == IntPtr.Zero)
            {
                FSUIPCConnection.Close(ClassInstance);
                throw new FSUIPCException(FSUIPCError.FSUIPC_ERR_ATOM, "Could not add the Global Atom for the file mapping path.");
            }
            connectionInfo.hMap = Win32.CreateFileMapping(new IntPtr(-1), IntPtr.Zero, PageProtection.ReadWrite, 0U, FSUIPCConnection.MaximumDataSize + 256U, str);
            if (connectionInfo.hMap == IntPtr.Zero || Marshal.GetLastWin32Error() == FSUIPCConnection.ERROR_ALREADY_EXISTS)
            {
                FSUIPCConnection.Close(ClassInstance);
                throw new FSUIPCException(FSUIPCError.FSUIPC_ERR_MAP, "Could not create file mapping.");
            }
            connectionInfo.pView = Win32.MapViewOfFile(connectionInfo.hMap, DesiredAccess.MapWrite, 0U, 0U, 0U);
            if (connectionInfo.pView == IntPtr.Zero)
            {
                FSUIPCConnection.Close(ClassInstance);
                throw new FSUIPCException(FSUIPCError.FSUIPC_ERR_VIEW, "Could not Open file view.");
            }
            Offset <int> offset1 = new Offset <int>(FSUIPCConnection.SystemOffsetsGroup, 13060);
            Offset <int> offset2 = new Offset <int>(FSUIPCConnection.SystemOffsetsGroup, 13064);

            for (int index = 0; index < 5 && (offset1.dataValue == 0 || offset2.dataValue == 0); ++index)
            {
                FSUIPCConnection.Process(ClassInstance, FSUIPCConnection.SystemOffsetsGroup);
                Thread.Sleep(100);
            }
            if (offset1.dataValue < 429391877 || ((long)offset2.dataValue & 4294901760L) != 4208852992L)
            {
                if (flag)
                {
                    FSUIPCConnection.Close(ClassInstance);
                    throw new FSUIPCException(FSUIPCError.FSUIPC_ERR_RUNNING, "FSUIPC is not running.");
                }
                FSUIPCConnection.Close(ClassInstance);
                throw new FSUIPCException(FSUIPCError.FSUIPC_ERR_VERSION, "Incorrect version of FSUIPC.");
            }
            int num = offset2.dataValue & (int)ushort.MaxValue;

            FSUIPCConnection.fsVersionConnected = (FlightSim)num;
            if (RequiredFlightSimVersion != 0 && RequiredFlightSimVersion != num)
            {
                FSUIPCConnection.Close(ClassInstance);
                throw new FSUIPCException(FSUIPCError.FSUIPC_ERR_WRONGFS, "Incorrect version of Flight Sim");
            }
            FSUIPCConnection.DeleteGroup(FSUIPCConnection.SystemOffsetsGroup);
            if (!FSUIPCConnection.aiServices.ContainsKey(ClassInstance))
            {
                FSUIPCConnection.aiServices.Add(ClassInstance, new AITrafficServices(ClassInstance));
            }
            if (!FSUIPCConnection.userInput.ContainsKey(ClassInstance))
            {
                FSUIPCConnection.userInput.Add(ClassInstance, new UserInputServices(ClassInstance));
            }
            if (FSUIPCConnection.payloadServices.ContainsKey(ClassInstance))
            {
                return;
            }
            FSUIPCConnection.payloadServices.Add(ClassInstance, new PayloadServices(ClassInstance));
        }
Exemplo n.º 25
0
 public static void DisconnectGroup(string groupName)
 {
     FSUIPCConnection.DeleteGroup(groupName);
 }
Exemplo n.º 26
0
 public static void Open(byte ClassInstance, FlightSim RequiredFlightSimVersion)
 {
     FSUIPCConnection.Open(ClassInstance, (int)RequiredFlightSimVersion);
 }
Exemplo n.º 27
0
 public static void Open(FlightSim RequiredFlightSimVersion)
 {
     FSUIPCConnection.Open((byte)0, (int)RequiredFlightSimVersion);
 }
Exemplo n.º 28
0
 public static void Open()
 {
     FSUIPCConnection.Open((byte)0, FlightSim.Any);
 }
Exemplo n.º 29
0
        public void RefreshAITrafficInformation(bool UpdateGroundTraffic, bool UpdateAirbourneTraffic)
        {
            FSUIPCConnection.Process(this.classInstance, this.AISystemGroup);
            List <int> processedPlaneIDs = new List <int>();

            this.aiArrivalRunwaysInUse.Clear();
            this.aiDepartureRunwaysInUse.Clear();
            if (UpdateGroundTraffic)
            {
                List <Offset <byte[]> > offsetList1 = new List <Offset <byte[]> >();
                List <Offset <byte[]> > offsetList2 = new List <Offset <byte[]> >();
                for (int index = 0; index < (int)this.slotsUsedGround.Value; ++index)
                {
                    Offset <byte[]> offset1 = new Offset <byte[]>(this.AISlotGroup, 57472 + 40 * index, 40);
                    Offset <byte[]> offset2 = new Offset <byte[]>(this.AISlotGroup, 53312 + 20 * index, 20);
                    offsetList1.Add(offset1);
                    offsetList2.Add(offset2);
                }
                if (offsetList1.Count > 0)
                {
                    FSUIPCConnection.Process(this.classInstance, this.AISlotGroup);
                    FSUIPCConnection.DeleteGroup(this.AISlotGroup);
                    processedPlaneIDs = new List <int>();
                    for (int index = 0; index < offsetList1.Count; ++index)
                    {
                        AIPlaneInfo planeInfo = this.updatePlaneInfo(offsetList1[index].Value, offsetList2[index].Value, this.aiGround, this.aiGroundIDs, processedPlaneIDs);
                        if (planeInfo != null)
                        {
                            this.addToRunwaysInUse(planeInfo);
                        }
                    }
                }
                List <int> intList = new List <int>();
                foreach (int aiGroundId in this.aiGroundIDs)
                {
                    if (!processedPlaneIDs.Contains(aiGroundId))
                    {
                        intList.Add(this.aiGroundIDs.IndexOf(aiGroundId));
                    }
                }
                intList.Sort();
                intList.Reverse();
                foreach (int index in intList)
                {
                    AIPlaneInfo aiPlaneInfo = this.aiGround[index];
                    aiPlaneInfo.id = 0;
                    this.aiGround.Remove(aiPlaneInfo);
                }
                this.aiGround.Sort(new Comparison <AIPlaneInfo>(this.comparePlaneDistance));
                this.aiGroundIDs.Clear();
                foreach (AIPlaneInfo aiPlaneInfo in this.aiGround)
                {
                    this.aiGroundIDs.Add(aiPlaneInfo.id);
                }
            }
            if (UpdateAirbourneTraffic)
            {
                List <Offset <byte[]> > offsetList1 = new List <Offset <byte[]> >();
                List <Offset <byte[]> > offsetList2 = new List <Offset <byte[]> >();
                for (int index = 0; index < (int)this.slotsUsedAir.Value; ++index)
                {
                    Offset <byte[]> offset1 = new Offset <byte[]>(this.AISlotGroup, 61568 + 40 * index, 40);
                    Offset <byte[]> offset2 = new Offset <byte[]>(this.AISlotGroup, 55360 + 20 * index, 20);
                    offsetList1.Add(offset1);
                    offsetList2.Add(offset2);
                }
                if (offsetList1.Count > 0)
                {
                    FSUIPCConnection.Process(this.classInstance, this.AISlotGroup);
                    FSUIPCConnection.DeleteGroup(this.AISlotGroup);
                    processedPlaneIDs = new List <int>();
                    for (int index = 0; index < offsetList1.Count; ++index)
                    {
                        AIPlaneInfo planeInfo = this.updatePlaneInfo(offsetList1[index].Value, offsetList2[index].Value, this.aiAirborne, this.aiAirbornIDs, processedPlaneIDs);
                        if (planeInfo != null)
                        {
                            this.addToRunwaysInUse(planeInfo);
                        }
                    }
                }
                List <int> intList = new List <int>();
                foreach (int aiAirbornId in this.aiAirbornIDs)
                {
                    if (!processedPlaneIDs.Contains(aiAirbornId))
                    {
                        intList.Add(this.aiAirbornIDs.IndexOf(aiAirbornId));
                    }
                }
                intList.Sort();
                intList.Reverse();
                foreach (int index in intList)
                {
                    AIPlaneInfo aiPlaneInfo = this.aiAirborne[index];
                    aiPlaneInfo.id = 0;
                    this.aiAirborne.Remove(aiPlaneInfo);
                }
                this.aiAirborne.Sort(new Comparison <AIPlaneInfo>(this.comparePlaneDistance));
                this.aiAirbornIDs.Clear();
                foreach (AIPlaneInfo aiPlaneInfo in this.aiAirborne)
                {
                    this.aiAirbornIDs.Add(aiPlaneInfo.id);
                }
            }
            this.aiAll.Clear();
            this.aiAll.AddRange((IEnumerable <AIPlaneInfo>) this.aiGround);
            this.aiAll.AddRange((IEnumerable <AIPlaneInfo>) this.aiAirborne);
            if (this.aiAll.Count <= 0)
            {
                return;
            }
            this.aiAll.Sort(new Comparison <AIPlaneInfo>(this.comparePlaneDistance));
            this.aiAllIDs.Clear();
            foreach (AIPlaneInfo aiPlaneInfo in this.aiAll)
            {
                this.aiAllIDs.Add(aiPlaneInfo.id);
            }
        }
Exemplo n.º 30
0
 internal void cleanup()
 {
     FSUIPCConnection.DeleteGroup(this.AISystemGroup);
     FSUIPCConnection.DeleteGroup(this.AIWriteOptionsGroupAirborne);
     FSUIPCConnection.DeleteGroup(this.AIWriteOptionsGroupGround);
 }