Example #1
0
        void panel_Click(object sender, EventArgs e)
        {
            var pointRelativeToTreeview = PointToClient(Cursor.Position);
            var panelClickedNode        = TreeView.GetNodeAt(pointRelativeToTreeview) as TreeNodeEx;

            //we want to delete this node from out list
            Controller.DeleteTreeNode(panelClickedNode);

            DebugMethods.Log(panelClickedNode.Text);
        }
Example #2
0
        public async void CheckArgs(BluetoothLEAdvertisementReceivedEventArgs args)
        {
            Console.WriteLine("★Scan");

            // console log
            DebugMethods.OutputLog(args);

            // FIDOサービスを検索
            var fidoServiceUuid = new Guid("0000fffd-0000-1000-8000-00805f9b34fb");

            if (args.Advertisement.ServiceUuids.Contains(fidoServiceUuid) == false)
            {
                return;
            }

            // 発見
            addLog("Scan FIDO Device");
            this.AdvWatcher.Stop();

            // connect
            {
                addLog("Conncect FIDO Device");
                BleDevice = await BluetoothLEDevice.FromBluetoothAddressAsync(args.BluetoothAddress);

                DebugMethods.OutputLog(BleDevice);
            }

            // FIDOのサービスをGET
            {
                addLog("Connect FIDO Service");
                var services = await BleDevice.GetGattServicesForUuidAsync(fidoServiceUuid);

                if (services.Services.Count <= 0)
                {
                    // サービス無し
                    addLog("Error Connect FIDO Service");
                    return;
                }
                Service_Fido = services.Services.First();
            }

            // Characteristicアクセス
            // - コマンド送信ハンドラ設定
            // - 応答受信ハンドラ設定
            {
                // FIDO Service Revision(Read)
                await DebugMethods.OutputLog(Service_Fido, GattCharacteristicUuids.SoftwareRevisionString);

                // FIDO Control Point Length(Read-2byte)
                await DebugMethods.OutputLog(Service_Fido, new Guid("F1D0FFF3-DEAA-ECEE-B42F-C9BA7ED623BB"));

                // FIDO Service Revision Bitfield(Read/Write-1+byte)
                await DebugMethods.OutputLog(Service_Fido, new Guid("F1D0FFF4-DEAA-ECEE-B42F-C9BA7ED623BB"));

                // FIDO Status(Notiry) 受信データ
                {
                    var characteristics = await Service_Fido.GetCharacteristicsForUuidAsync(new Guid("F1D0FFF2-DEAA-ECEE-B42F-C9BA7ED623BB"));

                    if (characteristics.Characteristics.Count > 0)
                    {
                        this.Characteristic_Receive = characteristics.Characteristics.First();
                        if (this.Characteristic_Receive == null)
                        {
                            Console.WriteLine("Characteristicに接続できない...");
                        }
                        else
                        {
                            if (this.Characteristic_Receive.CharacteristicProperties.HasFlag(GattCharacteristicProperties.Notify))
                            {
                                // イベントハンドラ追加
                                this.Characteristic_Receive.ValueChanged += characteristicChanged_OnReceiveFromDevice;

                                // これで有効になる
                                await this.Characteristic_Receive.WriteClientCharacteristicConfigurationDescriptorAsync(GattClientCharacteristicConfigurationDescriptorValue.Notify);
                            }
                        }
                    }
                }

                // FIDO Control Point(Write) 送信データ
                {
                    var characteristics = await Service_Fido.GetCharacteristicsForUuidAsync(new Guid("F1D0FFF1-DEAA-ECEE-B42F-C9BA7ED623BB"));

                    if (characteristics.Characteristics.Count > 0)
                    {
                        this.Characteristic_Send = characteristics.Characteristics.First();
                        if (this.Characteristic_Send == null)
                        {
                            Console.WriteLine("Characteristicに接続できない...");
                        }
                    }
                }

                addLog("BLE FIDOキーと接続しました!");
                addLog("");
            }
        }
Example #3
0
        public static BaseNode CreateNode(IINode iNode, bool isPolyObject, bool isParentNode)
        {
            //We need to create our 'RealBaseNode'
            BaseNode tempBaseNode;

            if (isParentNode)
            {
                tempBaseNode = new ParentNode(iNode, isPolyObject);
            }
            else
            {
                tempBaseNode = new ChildNode(iNode, isPolyObject);
            }

            IObject baseObjectRef = iNode.ObjectRef.FindBaseObject();

            if (!isPolyObject)
            {
                //Cast base object to triObject because we know it's a triObject
                ITriObject triObj = baseObjectRef as ITriObject;
                if (triObj == null)
                {
                    return(null);                //if for some reason the cast failed, return
                }
                IMesh triMesh = triObj.Mesh;

                var numFaces = triMesh.NumFaces;

                DebugMethods.Log(isParentNode? String.Format("ParentNode num face {0}", numFaces) : String.Format("ChildNode num face {0}", numFaces));

                //Build FaceID Dictionary.
                for (int index = 0; index < numFaces; index++)
                {
                    IFace  face  = triMesh.Faces[index];
                    ushort matID = face.MatID;

                    if (tempBaseNode.DoesKeyExist(matID))
                    {
                        tempBaseNode.SetMaterialIDBit(matID, index);
                    }
                    else
                    {
                        tempBaseNode.CreateNewMaterialBitArray(matID, index, numFaces);
                    }
                }
            }
            else
            {
                IPolyObject polyObj = baseObjectRef as IPolyObject;
                if (polyObj == null)
                {
                    return(null);                 //if for some reason the cast failed, return
                }
                IMNMesh polyMesh = polyObj.Mesh;

                var numFaces = polyMesh.FNum;

                DebugMethods.Log(isParentNode ? String.Format("ParentNode num face {0}", numFaces) : String.Format("ChildNode num face {0}", numFaces));

                //Build FaceID Dictionary.
                for (int index = 0; index < numFaces; index++)
                {
                    IMNFace face  = polyMesh.F(index);
                    ushort  matID = face.Material;

                    if (tempBaseNode.DoesKeyExist(matID))
                    {
                        //Same material ID, just set the bit
                        //tempBaseNode.GetMaterialBitArray(matID).Set(index, true);
                        tempBaseNode.SetMaterialIDBit(matID, index);
                    }
                    else
                    {
                        tempBaseNode.CreateNewMaterialBitArray(matID, index, numFaces);
                    }
                }
            }
            //We should have a 'RealBaseNode' with a filled up dictionary full of IDs & faces!
            //Maybe there is some weird object with 0 faces?
            if (tempBaseNode.GetMaterialIDCount() == 0)
            {
                return(null);
            }

            return(tempBaseNode);
        }