private void InitiateZones() { ZoneChoiceComboSnapped.ItemsSource = App.ZoneChoices.GetZoneChoices(); // Instantiate zone buttons: int count = App.ZoneChoices.GetZoneChoiceList().Count; App.MyAssert(count > 0); ZoneButton[] zb = new ZoneButton[count]; int i = 0; string buttonName; foreach (TP_ZoneChoiceItem zci in App.ZoneChoices.GetZoneChoiceList()) { if (String.IsNullOrEmpty(zci.ButtonName)) continue; buttonName = "zoneButton" + zci.ButtonName.Replace(" ", ""); zb[i] = new ZoneButton(buttonName, (Color)zci.ColorObj, zci.ButtonName); zb[i].Click += Zone_Click; ToolTip tt = new ToolTip(); tt.Content = zci.Meaning; zb[i].SetToolTip(tt); ZoneButtons.Items.Add(zb[i]); /* // Make widths narrower for filled state: NOT WORKING YET ObjectAnimationUsingKeyFrames anim = new ObjectAnimationUsingKeyFrames(); DiscreteObjectKeyFrame kf = new DiscreteObjectKeyFrame(); kf.KeyTime = TimeSpan.FromSeconds(0); kf.Value = 100; anim.KeyFrames.Add(kf); Storyboard.SetTargetName(anim, buttonName); Storyboard.SetTargetProperty(anim, "ZoneButtonWidth"); Filled.Storyboard.Children.Add(anim); */ i++; } Zone_Clear(); // disables SendButton too }
public void InitiateZones() // may also be called from Settings/My Organization if org changes { ZoneChoiceComboSnapped.ItemsSource = App.ZoneChoices.GetZoneChoices(); // Instantiate zone buttons: zbCount = App.ZoneChoices.GetZoneChoiceList().Count; App.MyAssert(zbCount > 0); zb = new ZoneButton[zbCount]; int i = 0; string buttonName; foreach(TP_ZoneChoiceItem zci in App.ZoneChoices.GetZoneChoiceList()) { if (String.IsNullOrEmpty(zci.ButtonName)) continue; buttonName = "zoneButton"+zci.ButtonName.Replace(" ",""); zb[i] = new ZoneButton(buttonName, (Color)zci.ColorObj, zci.ButtonName); zb[i].Click += Zone_Click; ToolTip tt = new ToolTip(); tt.Content = zci.Meaning; zb[i].SetToolTip(tt); ZoneButtons.Items.Add(zb[i]); /* DOESNT WORK... BUT MAYBE BECAUSE IN CONSTRUCTOR? // Make widths narrower for filled state: ObjectAnimationUsingKeyFrames anim = new ObjectAnimationUsingKeyFrames(); DiscreteObjectKeyFrame kf = new DiscreteObjectKeyFrame(); kf.KeyTime = TimeSpan.FromSeconds(0); //kf.Value = 100; kf.SetValue(ZoneButton.ZoneButtonWidthProperty, 100); anim.KeyFrames.Add(kf); Storyboard.SetTargetName(anim, buttonName); // fails with exception when filled mode invoked: Storyboard.SetTargetProperty(anim, "(ZoneButton.ZoneButtonWidthProperty)"); Storyboard.SetTargetProperty(anim, "ZoneButtonWidth"); // doesn't throw exception but doesn't change width either. Doesn't seem to call setter Filled.Storyboard.Children.Add(anim); */ i++; } Zone_Clear(); // disables SendButton too }