public void TestFormDepthByHeightGet(double value) { CandySettings candySettings = new CandySettings(20, 5, 5, 5); Assert.AreEqual(value, candySettings.FormDepthByHeight); }
public void TestCandyCountGet(double value) { CandySettings candySettings = new CandySettings(20, 5, 5, 5); Assert.AreEqual(value, candySettings.CandyCount); }
public SettingsViewModel(CandySettings settings) { _settings = settings; _phantom = _settings.Clone(); ApplicationInformationServiceUrl = _phantom.ToReactivePropertyAsSynchronized(x => x.ApplicationInformationServiceUrl) .SetValidateAttribute(() => ApplicationInformationServiceUrl); ApplicationRootDirectoryPath = _phantom.ToReactivePropertyAsSynchronized(x => x.ApplicationRootDirectoryPath); SetDefaultServiceCommand = ApplicationInformationServiceUrl.DistinctUntilChanged() .Select(x => x != CandySettings.DefaultApplicationInformationServiceUrl) .ToReactiveCommand(); SetDefaultServiceCommand.Subscribe(_ => SetDefaultService()); OkCommand = new ReactiveCommand(); OkCommand.Subscribe(_ => ApplySettings()); CancelCommand = new ReactiveCommand(); CancelCommand.Subscribe(_ => Cancel()); }
public CandyDBRepository(IOptions <CandySettings> candyConfig) { _Settings = candyConfig.Value; }
/// <summary> /// Кнопка построить деталь /// </summary> /// <param name="sender">Объект, вызвавший событие</param> /// <param name="e">Параметры события</param> private void BuildButton_Click(object sender, EventArgs e) { // Создадим конфетну форму CandySettings candySettings = null; try { int candyCount = Convert.ToInt32(CandyCountTextBox.Text); double formDepthByLength = Convert.ToDouble(FormDepthByLengthTextBox.Text); double formDepthByWidth = Convert.ToDouble(FormDepthByWidthTextBox.Text); double formDepthByHeight = Convert.ToDouble(FormDepthByHeightTextBox.Text); candySettings = new CandySettings(candyCount, formDepthByLength, formDepthByWidth, formDepthByHeight); } catch (CandyCountException exception) { ShowErrorMessage(CandyCountLabel, exception.Message); } catch (FormDepthByLengthException exception) { ShowErrorMessage(FormDepthByLengthLabel, exception.Message); } catch (FormDepthByWidthException exception) { ShowErrorMessage(FormDepthByWidthLabel, exception.Message); } catch (FormDepthByHeightException exception) { ShowErrorMessage(FormDepthByHeightLabel, exception.Message); } catch (FormatException) { ShowErrorMessage(null, "Невозможно построить деталь. " + "В параметрах допущена ошибка."); } // Создадим конфету CandyBase candy = null; try { switch (CandyType.SelectedIndex) { case 0: candy = BuildRectCandy(); break; case 1: candy = BuildSphereCandy(); break; case 2: candy = BuildCylinderCandy(); break; } } catch (CandyHeightException exception) { ShowErrorMessage(RectCandyHeightLabel, exception.Message); } catch (CandyLengthException exception) { Label label = (CandyType.SelectedIndex == 0) ? RectCandyLengthLabel : CylinderCandyLengthLabel; ShowErrorMessage(label, exception.Message); } catch (CandyRadiusException exception) { Label label = (CandyType.SelectedIndex == 1) ? SphereCandyRadiusLabel : CylinderCandyRadiusLabel; ShowErrorMessage(label, exception.Message); } catch (CandyWidthException exception) { ShowErrorMessage(RectCandyWidthLabel, exception.Message); } catch (FormatException) { ShowErrorMessage(null, "Невозможно построить деталь. " + "В параметрах допущена ошибка."); } if (candySettings != null && candy != null) { _kompasWrapper.StartKompas(); _kompasWrapper.BuildCandySettings(candySettings, candy); } }