コード例 #1
0
        private void Devices_CmdCopy_Executed(object sender, ExecutedRoutedEventArgs evt)
        {
            Device device = Devices.First(d => IsSelectedDevice(d));

            if (device is DectDevice dectDevice)
            {
                DectDevice newDevice = new DectDevice(dectDevice)
                {
                    DeviceName = string.Empty
                };
                if (newDevice.Edit(this))
                {
                    Devices.Add(newDevice);
                    Devices_SelectDevice(newDevice);
                }
            }
            if (device is JuisDevice juisDevice)
            {
                JuisDevice newDevice = new JuisDevice(juisDevice)
                {
                    DeviceName = string.Empty
                };
                if (newDevice.Edit(this))
                {
                    Devices.Add(newDevice);
                    Devices_SelectDevice(newDevice);
                }
            }

            Devices_SetDataGridFocus();
        }
コード例 #2
0
        public JuisDeviceDialog(JuisDevice device)
        {
            origDevice = device ?? throw new ArgumentNullException(nameof(device));
            DeviceData = new JuisDevice(device);

            InitComboBoxValues(device);
            InitializeComponent();
            DataContext = this;
        }
コード例 #3
0
        // Initialize the Mesh Master Values list

        private void InitComboBoxValues(JuisDevice device)
        {
            AnnexValues     = JuisDevice.GetAnnexValues().AppendMissingAsUnknown(device.Annex);
            BuildTypeValues = JuisDevice.GetFirmwareBuildTypeValues().AppendMissingAsUnknown(device.FirmwareBuildType);
            CountryValues   = Device.GetCountryValues().AppendMissingAsUnknown(device.Country);
            LanguageValues  = Device.GetLanguageValues().AppendMissingAsUnknown(device.Language);
            OEMValues       = Device.GetOemValues().AppendMissingAsUnknown(device.OEM);

            MeshMasterValues = new List <ComboBoxValue>();
            foreach (JuisDevice masterDevice in App.GetMainWindow().Devices.Where(d => d is JuisDevice && d.ID != device.ID))
            {
                MeshMasterValues.Add(new ComboBoxValue(masterDevice.ID, masterDevice.DeviceName));
            }
            MeshMasterValues.Sort(new ComboBoxValueComparer(new NaturalStringComparer(App.defaultDisplayStringComparison)));
            MeshMasterValues.Prepend(string.Empty, JCstring.ComboBoxValueNoMaster);
            MeshMasterValues.AppendMissingAsUnknown(device.MeshMaster);
        }
コード例 #4
0
        private void Devices_CmdAddJUIS_Executed(object sender, ExecutedRoutedEventArgs evt)
        {
            JuisDevice newDevice = new JuisDevice()
            {
                Annex             = programSettings.DefaultAnnex,
                FirmwareBuildType = programSettings.DefaultFirmwareBuildType,
                Country           = programSettings.DefaultCountry,
                Language          = programSettings.DefaultLanguage,
                OEM = programSettings.DefaultOEM
            };

            if (newDevice.Edit(this))
            {
                Devices.Add(newDevice);
                Devices_SelectDevice(newDevice);
            }

            Devices_SetDataGridFocus();
        }
コード例 #5
0
        private void Backstage_Init1()
        {
            Backstage_DefaultAnnexValues     = JuisDevice.GetAnnexValues().Prepend(string.Empty, JCstring.ComboBoxValueNotSet);
            Backstage_DefaultBuildTypeValues = JuisDevice.GetFirmwareBuildTypeValues().Prepend("-1", JCstring.ComboBoxValueNotSet);
            Backstage_DefaultCountryValues   = Device.GetCountryValues().Prepend(string.Empty, JCstring.ComboBoxValueNotSet);
            Backstage_DefaultLanguageValues  = Device.GetLanguageValues().Prepend(string.Empty, JCstring.ComboBoxValueNotSet);
            Backstage_DefaultOEMValues       = Device.GetOemValues().Prepend(string.Empty, JCstring.ComboBoxValueNotSet);

            Backstage_UILanguageValues = new List <ComboBoxValue>();
            foreach (string language in App.AdditionalLanguages)
            {
                if (languageDictionary.TryGetValue(language, out string languageFull))
                {
                    Backstage_UILanguageValues.Add(new ComboBoxValue(language, languageFull));
                }
            }
            Backstage_UILanguageValues.Add(new ComboBoxValue("en", JCstring.ComboBoxValueLanguageEN));             // Main language
            Backstage_UILanguageValues.Prepend("auto", JCstring.ComboBoxValueAutomatic);
            Backstage_UILanguageValues.Sort(1, Backstage_UILanguageValues.Count - 1, new ComboBoxValueComparer(App.defaultDisplayStringComparison));
        }
コード例 #6
0
        // Event handler: Worker_DoWork

        private void Worker_DoWork_Handler(object sender, DoWorkEventArgs evt)
        {
            BackgroundWorker worker = (BackgroundWorker)sender;
            int progress            = 0;

            foreach (Device device in queryDevices)
            {
                if (device is DectDevice dectDevice)
                {
                    JuisDevice dectBase = null;
                    Dispatcher.Invoke(DispatcherPriority.Normal, new Action(() => {
                        dectBase = App.GetMainWindow().Devices.FindByID(dectDevice.DectBase) as JuisDevice;
                    }));

                    string message = null;
                    if (string.IsNullOrWhiteSpace(dectDevice.DectBase))
                    {
                        message = string.Format(CultureInfo.CurrentCulture, JCstring.MessageTextDectBaseNotSet, dectDevice.DeviceName);
                    }
                    else
                    if (dectBase == null)
                    {
                        message = string.Format(CultureInfo.CurrentCulture, JCstring.MessageTextDectBaseNotFound, dectDevice.DeviceName);
                    }

                    if (message != null)
                    {
                        int result = -1;
                        Dispatcher.Invoke(DispatcherPriority.Normal, new Action(() => {
                            result = MessageBoxEx2.Show(new MessageBoxEx2Params {
                                CaptionText = JCstring.MessageCaptionError,
                                MessageText = message.Unescape(),
                                Image       = MessageBoxEx2Image.Error,
                                ButtonText  = new string[] { JCstring.DialogButtonTextSkip, JCstring.DialogButtonTextCancel },
                                Owner       = this
                            });
                        }));

                        if (result == 0)                                // Skip button
                        {
                            continue;
                        }
                        else                                                    // Cancel button, close box
                        {
                            break;
                        }
                    }

                    string queryUpdateResponse = dectDevice.QueryFirmwareUpdate(dectBase);

                    Dispatcher.Invoke(DispatcherPriority.Normal, new Action(() => {
                        dectDevice.SetFirmwareUpdate(queryUpdateResponse);
                    }));
                }

                if (device is JuisDevice juisDevice)
                {
                    JuisDevice meshMaster = null;
                    Dispatcher.Invoke(DispatcherPriority.Normal, new Action(() => {
                        meshMaster = App.GetMainWindow().Devices.FindByID(juisDevice.MeshMaster) as JuisDevice;
                    }));

                    try {
                        JUIS.UpdateInfo queryUpdateResponse = juisDevice.QueryFirmwareUpdate(meshMaster);
                        Dispatcher.Invoke(DispatcherPriority.Normal, new Action(() => {
                            juisDevice.SetFirmwareUpdate(queryUpdateResponse);
                        }));
                    }
                    catch {
                        Dispatcher.Invoke(DispatcherPriority.Normal, new Action(() => {
                            juisDevice.SetFirmwareUpdate(null);
                        }));
                    }
                }

                worker.ReportProgress(++progress);
                if (worker.CancellationPending)
                {
                    break;
                }
            }
        }