Ejemplo n.º 1
0
        private void AddItem(MenuCode menuCode, string display, UIIcon uIIcon, string padding)
        {
            MenuItemDataModel dataModel = new MenuItemDataModel()
            {
                Code       = menuCode,
                Display    = display,
                IconSource = IconBinder.Source(uIIcon),
                Padding    = padding,
            };

            this.items.Add(dataModel);
        }
        private void OnStartupSuccess()
        {
            this.wrapper.CommMediumList((items) => {
                foreach (var item in items)
                {
                    if (item.MediumType != CommMediumType.None)
                    {
                        // The cross platform wrapper only returns the immediate icon path
                        item.IconSource = string.Format("{0}{1}", IconBinder.GetIconPrefix(), item.IconSource);
                        this.mediums.Add(item);
                    }
                }
            });
            this.cbComm.ItemsSource   = this.mediums;
            this.cbComm.SelectedIndex = 0;

            // Terminators
            this.wrapper.GetCurrentTerminator(this.GetTerminatorsOk, this.GetTerminatorsOnErr);
            this.wrapper.CurrentTerminatorChanged += Wrapper_CurrentTerminatorChanged;

            // Language
            this.wrapper.LanguageChanged += this.LanguageChangedHandler;

            // Scripts
            this.wrapper.CurrentScriptChanged += this.Wrapper_CurrentScriptChanged;

            // BLE
            this.wrapper.BLE_DeviceDiscovered        += this.BLE_DeviceDiscoveredHandler;
            this.wrapper.BLE_DeviceRemoved           += this.BLE_DeviceRemovedHandler;
            this.wrapper.BLE_DeviceUpdated           += this.BLE_DeviceUpdatedHandler;
            this.wrapper.BLE_DeviceDiscoveryComplete += BLE_DeviceDiscoveryCompleteHandler;

            // BT
            this.wrapper.BT_DeviceDiscovered  += this.BT_DeviceDiscoveredHandler;
            this.wrapper.BT_DiscoveryComplete += this.BT_DiscoveryCompleteHandler;
            //this.wrapper.BT_DeviceInfoGathered += this.BT_DeviceInfoGatheredHandler;
            this.wrapper.BT_ConnectionCompleted += this.BT_ConnectionCompletedHandler;
            this.wrapper.BT_BytesReceived       += this.BT_BytesReceivedHandler;
            this.wrapper.BT_PairInfoRequested   += this.BT_PairInfoRequestedHandler;
            this.wrapper.BT_PairStatus          += this.BT_PairStatusHandler;
            this.wrapper.BT_UnPairStatus        += this.BT_UnPairStatusHandler;

            // WIFI
            this.wrapper.OnWifiError                      += this.Wrapper_OnWifiError;
            this.wrapper.DiscoveredWifiNetworks           += this.Wrapper_DiscoveredWifiNetworks;
            this.wrapper.OnWifiConnectionAttemptCompleted += this.Wrapper_OnWifiConnectionAttemptCompletedHandler;
            this.wrapper.CredentialsRequestedEvent        += this.Wifi_CredentialsRequestedEventHandler;
            this.wrapper.Wifi_BytesReceived               += Wrapper_Wifi_BytesReceivedHandler;

            // Serial USB
            this.wrapper.SerialOnError           += this.Wrapper_SerialOnErrorHandler;
            this.wrapper.SerialDiscoveredDevices += this.Wrapper_SerialDiscoveredDevicesHandler;
            this.wrapper.Serial_BytesReceived    += this.Wrapper_Serial_BytesReceivedHandler;
            this.wrapper.OnSerialConfigRequest   += this.Wrapper_OnSerialConfigRequestHandler;

            // Ethernet
            this.wrapper.EthernetParamsRequestedEvent         += this.Wrapper_EthernetParamsRequestedEventHandler;
            this.wrapper.Ethernet_BytesReceived               += this.Wrapper_Ethernet_BytesReceivedHandler;
            this.wrapper.OnEthernetConnectionAttemptCompleted += this.Wrapper_OnEthernetConnectionAttemptCompletedHandler;
            this.wrapper.OnEthernetError      += this.Wrapper_OnEthernetErrorHandler;
            this.wrapper.OnEthernetListChange += this.Wrapper_OnEthernetListChangeHandler;

            App.STATIC_APP.LogMsgEvent += this.AppLogMsgEventHandler;

            // Call before rendering which will trigger initial resize events
            this.buttonSizer_BT = new ButtonGroupSizeSyncManager(this.btnBTConnect, this.btnBTDiscover);
            this.buttonSizer_BT.PrepForChange();

            this.buttonSizer_BLE = new ButtonGroupSizeSyncManager(this.btnDiscoverLE, this.btnInfoLE, this.btnLEConnect);
            this.buttonSizer_BLE.PrepForChange();

            this.buttonSizer_WIFI = new ButtonGroupSizeSyncManager(this.btnWifiDiscover, this.btnWifiConnect, this.btnWifiDisconnect);
            this.buttonSizer_WIFI.PrepForChange();

            buttonSizer_MAIN = new ButtonGroupSizeSyncManager(this.btnExit, this.btnLog);
            buttonSizer_MAIN.PrepForChange();

            this.wrapper.GetCurrentScript(this.PopulateScriptData, WindowHelpers.ShowMsg);
        }