/// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public async Task SetBackgroundPictureAsync(IBackgroundPicture picture)
        {
            Task t = new Task((() => { picture.Save(false); }));

            t.Start();
            await t;
        }
        /// <summary>
        ///     Initializes current application mode asynchronously
        ///     Асинхронная инициализация
        /// </summary>
        /// <returns>
        ///     An instance of System.Threading.Tasks.Task that represents current asynchronous operation
        /// </returns>
        public async Task InitializeAsync()
        {
            var devices = await this._configService.GetAllDevicesAsync();

            this.Devices =
                new ObservableCollection <IConfigDeviceViewModel>(
                    devices.Select((m) => _configDeviceViewModelFactory.CreateConfigDeviceViewModel(m)));
            if (Devices.Any((model => model.DeviceNumber > 103)))
            {
                while (Devices.Any((model => model.DeviceNumber > 103)))
                {
                    Devices.Remove(Devices.First((model => model.DeviceNumber > 103)));
                    await this._configService.RemoveDeviceAsync(devices.First((device => device.DeviceNumber > 103)));
                }
            }
            this.CurrentDevice = this.Devices.FirstOrDefault();
            BackgroundPicture  = _configService.GetBackgroundPicture();
            (new LoggerServiceBase()).LogMessage(" Переход в режим конфигурации", LogManager.GetLogger(LogMessageTypes.COMMEN_MESSAGE), LogMessageTypes.COMMEN_MESSAGE);
        }
        private void OnAddImage()
        {
            try
            {
                BackgroundPicture            = new BackgroundPicture();
                BackgroundPicture.IsEditMode = true;
                OpenFileDialog dlg = new OpenFileDialog();
                dlg.Title  = "Open Image";
                dlg.Filter = "Image File|*.bmp; *.gif; *.jpg; *.jpeg; *.png;";

                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    if (File.Exists(dlg.FileName))
                    {
                        BackgroundPicture.InitImageFromPath(dlg.FileName);
                    }
                }
            }
            catch
            {
            }
            OnPropertyChanged(nameof(BackgroundPicture));
        }
 private void OnDeleteImageCommand()
 {
     BackgroundPicture.Save(true);
     BackgroundPicture = null;
 }