Chronos Plugins 5.4.0
This documentation covers the plugin interfaces definitions and an example implementation.
Loading...
Searching...
No Matches
FrappuccinoCompositionEditor.cs
Go to the documentation of this file.
1using System;
2using System.Windows.Forms;
3
4namespace MockPlugin.Tasks
5{
9 public partial class FrappuccinoCompositionEditor : Form
10 {
12 {
13 InitializeComponent();
14 }
20 {
21 InitializeComponent();
22 mData = theData;
23 }
25
29 private void CopyDataToGui()
30 {
31 if (mData.Volume < 200)
32 {
33 cboSize.SelectedIndex = 0;
34 }
35 else if (mData.Volume < 400)
36 {
37 cboSize.SelectedIndex = 1;
38 }
39 else
40 {
41 cboSize.SelectedIndex = 2;
42 }
43 switch (mData.Cream)
44 {
45 case BrewFrappuccino.CreamType.LowFat:
46 rbLowFat.Checked = true;
47 break;
48 case BrewFrappuccino.CreamType.Normal:
49 rbRegularCream.Checked = true;
50 break;
51 case BrewFrappuccino.CreamType.Vegan:
52 rbVeganCream.Checked = true;
53 break;
54 }
55 chkCaffeine.Checked = !mData.DeCaffeinated;
56 if (mData.MuchIce)
57 {
58 rbLotsOfIce.Checked = true;
59 }
60 else
61 {
62 rbLowIce.Checked = true;
63 }
64 lblDevName.Text = mData.DevInEditor?.Name ?? "(not set)";
65 }
71 private void FrappuccinoCompositionEditor_Shown(object sender, EventArgs e)
72 {
74 }
75
79 private void CopyGuItoData()
80 {
81 switch (cboSize.SelectedIndex)
82 {
83 case 0:
84 mData.Volume = 150;
85 break;
86 case 1:
87 mData.Volume = 250;
88 break;
89 default:
90 mData.Volume = 450;
91 break;
92 }
93 mData.MuchIce = rbLotsOfIce.Checked;
94 mData.DeCaffeinated = !chkCaffeine.Checked;
95 if (rbVeganCream.Checked)
96 {
97 mData.Cream = BrewFrappuccino.CreamType.Vegan;
98 }
99 else if (rbRegularCream.Checked)
100 {
101 mData.Cream = BrewFrappuccino.CreamType.Normal;
102 }
103 else
104 {
105 mData.Cream = BrewFrappuccino.CreamType.LowFat;
106 }
107 }
113 private void btnOK_Click(object sender, EventArgs e)
114 {
116 }
117 }
118}
Example task implementations. Since there are lots of things that can be done from a task,...
Provides an editor for the BrewFrappuccino-Task's "Composition" information.
FrappuccinoCompositionEditor(BrewFrappuccino.CompositionData theData)
Initialize from a given composition object.
readonly BrewFrappuccino.CompositionData mData
void btnOK_Click(object sender, EventArgs e)
Update our data object.
void FrappuccinoCompositionEditor_Shown(object sender, EventArgs e)
If we set the controls' values from the constructor, sometimes they don't get updated properly.
void CopyGuItoData()
When the user clicked on OK, we want to push the state represented by the GUI into our composition ob...
A task working on a complex parameter set.
CreamType
Enum properties result in nice drop-down lists.
Let's pretend the composition is really complex and better done with a custom editor.