private void SetupBindingCombos() { if (DeviceList.SelectedIndex > -1 && MapsView.SelectedIndices.Count > 0) { MidiMap midiMap = (MidiMap)DeviceList.SelectedItem; ControlBinding binding = (ControlBinding)MapsView.SelectedItems[0].Tag; TargetTypeCombo.Items.Clear(); TargetTypeCombo.Items.AddRange(UiTools.GetBindingTargetTypeList()); TargetTypeCombo.SelectedIndex = (int)binding.TargetType; BindTypeCombo.Items.Clear(); BindTypeCombo.Items.AddRange(Enum.GetNames(typeof(BindingType))); BindTypeCombo.SelectedIndex = (int)binding.BindingType; RepeatCheckbox.Checked = binding.Parent.AutoRepeat; UpdatePropertyCombo(); DeviceImage.Invalidate(); } else { TargetTypeCombo.Items.Clear(); BindTypeCombo.Items.Clear(); TargetPropertyCombo.ClearText(); } }
private void DeviceImage_Paint(object sender, PaintEventArgs e) { ControlMap selectedMap = null; if (DeviceList.SelectedIndex > -1 && ImageLoaded) { if (MapsView.SelectedIndices.Count > 0) { ControlBinding binding = (ControlBinding)MapsView.SelectedItems[0].Tag; selectedMap = binding.Parent; } SolidBrush BackgroundBrush = new SolidBrush(Color.FromArgb(128, 10, 10, 45)); MidiMap midiMap = (MidiMap)DeviceList.SelectedItem; foreach (ControlMap cm in midiMap.ControlMaps) { if (cm.Mapped) { Brush textBrush = UiTools.StadardTextBrush; if (cm == selectedMap) { textBrush = UiTools.YellowTextBrush; } SizeF sizeText = e.Graphics.MeasureString(cm.Name, UiTools.StandardLarge); Point pnt = ImageToControl(new PointF(cm.X, cm.Y)); pnt.Offset(new Point((int)(-sizeText.Width / 2), (int)(-sizeText.Height / 2))); Point pnt2 = ImageToControl(new PointF(cm.X + cm.Width, cm.Y + cm.Height)); Size size = new Size((int)sizeText.Width, (int)sizeText.Height); e.Graphics.FillRectangle(BackgroundBrush, new Rectangle(pnt, size)); e.Graphics.DrawString(cm.Name, UiTools.StandardLarge, textBrush, pnt); } } BackgroundBrush.Dispose(); } }
private void SetupBindingCombos() { if (Properties.Settings.Default.XboxCustomMapping && MapsView.SelectedItems.Count > 0) { ControlBinding binding = (ControlBinding)MapsView.SelectedItems[0].Tag; MapsView.EndUpdate(); TargetTypeCombo.Items.Clear(); TargetTypeCombo.Items.AddRange(UiTools.GetBindingTargetTypeList()); TargetTypeCombo.SelectedIndex = (int)binding.TargetType; BindTypeCombo.Items.Clear(); BindTypeCombo.Items.AddRange(Enum.GetNames(typeof(BindingType))); BindTypeCombo.SelectedIndex = (int)binding.BindingType; RepeatCheckbox.Checked = binding.Parent.AutoRepeat; UpdatePropertyCombo(); } else { TargetTypeCombo.Items.Clear(); BindTypeCombo.Items.Clear(); TargetPropertyCombo.Items.Clear(); } }
private void RepeatCheckbox_CheckedChanged(object sender, EventArgs e) { if (DeviceList.SelectedIndex > -1 && MapsView.SelectedIndices.Count > 0) { MidiMap midiMap = (MidiMap)DeviceList.SelectedItem; ControlBinding binding = (ControlBinding)MapsView.SelectedItems[0].Tag; binding.Parent.AutoRepeat = RepeatCheckbox.Checked; } }
private void RepeatCheckbox_CheckedChanged(object sender, EventArgs e) { if (MapsView.SelectedIndices.Count > 0) { ControlBinding binding = (ControlBinding)MapsView.SelectedItems[0].Tag; binding.Parent.AutoRepeat = RepeatCheckbox.Checked; MapsView.SelectedItems[0].SubItems[2].Text = binding.Parent.AutoRepeat ? "Repeat" : "Once"; SetDirty(); } }
private void PropertyNameText_TextChanged(object sender, EventArgs e) { if (ignoreChanges > 0) { return; } ControlBinding binding = (ControlBinding)MapsView.SelectedItems[0].Tag; binding.PropertyName = PropertyNameText.Text; }
private void MapsView_ItemDrag(object sender, ItemDragEventArgs e) { if (DeviceList.SelectedIndex > -1 && MapsView.SelectedIndices.Count > 0) { MidiMap midiMap = (MidiMap)DeviceList.SelectedItem; ControlBinding binding = (ControlBinding)MapsView.SelectedItems[0].Tag; DragSource = binding.Parent; DoDragDrop(MidiControlDataFormat, DragDropEffects.Copy); } }
private void BindTypeCombo_SelectionChanged(object sender, EventArgs e) { if (ignoreChanges > 0) { return; } ControlBinding binding = (ControlBinding)MapsView.SelectedItems[0].Tag; binding.BindingType = (BindingType)BindTypeCombo.SelectedIndex; UpdatePropertyCombo(); SetDirty(); }
private void BindTypeCombo_SelectionChanged(object sender, EventArgs e) { if (DeviceList.SelectedIndex > -1 && MapsView.SelectedIndices.Count > 0) { MidiMap midiMap = (MidiMap)DeviceList.SelectedItem; ControlBinding binding = (ControlBinding)MapsView.SelectedItems[0].Tag; binding.BindingType = (BindingType)BindTypeCombo.SelectedIndex; UpdatePropertyCombo(); MapsView.SelectedItems[0].SubItems[4].Text = binding.ToString(); } }
private void TargetPropertyCombo_SelectionChanged(object sender, EventArgs e) { if (ignoreChanges > 0) { return; } filterLabel.Visible = false; filterList.Visible = false; ScriptableProperty prop = TargetPropertyCombo.SelectedItem as ScriptableProperty; ControlBinding binding = (ControlBinding)MapsView.SelectedItems[0].Tag; if (prop != null) { binding.PropertyName = prop.Name; binding.Max = prop.Max; binding.Min = prop.Min; binding.Integer = prop.Type == ScriptablePropertyTypes.Integer; if (binding.BindingType == BindingType.SetValue && prop.Type == ScriptablePropertyTypes.ConstellationFilter) { filterLabel.Visible = true; filterList.Visible = true; filterList.Items.Clear(); int index = 0; int selectedIndex = 0; foreach (string name in ConstellationFilter.Families.Keys) { filterList.Items.Add(name); if (name == binding.Value) { selectedIndex = index; } index++; } filterList.SelectedIndex = selectedIndex; } } else { if (TargetPropertyCombo.SelectedItem is string) { binding.PropertyName = TargetPropertyCombo.SelectedItem.ToString(); } } MapsView.SelectedItems[0].SubItems[1].Text = binding.ToString(); MapsView.SelectedItems[0].SubItems[2].Text = binding.Parent.AutoRepeat ? "Repeat" : "Once"; SetDirty(); }
private void filterList_SelectionChanged(object sender, EventArgs e) { ControlBinding binding = (ControlBinding)ButtonMap.BindingA; ScriptableProperty prop = TargetPropertyCombo.SelectedItem as ScriptableProperty; if (prop != null) { if (binding.BindingType == BindingType.SetValue && prop.Type == ScriptablePropertyTypes.ConstellationFilter) { binding.Value = filterList.SelectedItem.ToString(); } } }
private void Delete_Click(object sender, EventArgs e) { if (UiTools.ShowMessageBox(Language.GetLocalizedText(1171, "This will remove this control map. Are you sure you want to do this?"), Language.GetLocalizedText(1172, "Remove Control Map"), MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes) { MidiMap midiMap = (MidiMap)DeviceList.SelectedItem; ControlBinding binding = (ControlBinding)MapsView.SelectedItems[0].Tag; midiMap.ControlMaps.Remove(binding.Parent); LoadControlMaps(); midiMap.Dirty = true; } }
private void PropertyNameText_TextChanged(object sender, EventArgs e) { if (DeviceList.SelectedIndex > -1 && MapsView.SelectedIndices.Count > 0) { MidiMap midiMap = (MidiMap)DeviceList.SelectedItem; ControlBinding binding = (ControlBinding)MapsView.SelectedItems[0].Tag; binding.PropertyName = PropertyNameText.Text; } UpdateSelectedControlMap(); }
private void TargetPropertyCombo_SelectionChanged(object sender, EventArgs e) { if (DeviceList.SelectedIndex > -1 && MapsView.SelectedIndices.Count > 0) { MidiMap midiMap = (MidiMap)DeviceList.SelectedItem; ControlBinding binding = (ControlBinding)MapsView.SelectedItems[0].Tag; ScriptableProperty prop = TargetPropertyCombo.SelectedItem as ScriptableProperty; filterLabel.Visible = false; filterList.Visible = false; if (prop != null) { binding.PropertyName = prop.Name; binding.Max = prop.Max; binding.Min = prop.Min; binding.Integer = prop.Type == ScriptablePropertyTypes.Integer; if (binding.BindingType == BindingType.SetValue && prop.Type == ScriptablePropertyTypes.ConstellationFilter) { filterLabel.Visible = true; filterList.Visible = true; filterList.Items.Clear(); int index = 0; int selectedIndex = 0; foreach (string name in ConstellationFilter.Families.Keys) { filterList.Items.Add(name); if (name == binding.Value) { selectedIndex = index; } index++; } filterList.SelectedIndex = selectedIndex; } } else { if (TargetPropertyCombo.SelectedItem is string) { binding.PropertyName = TargetPropertyCombo.SelectedItem.ToString(); } } MapsView.SelectedItems[0].SubItems[4].Text = binding.ToString(); } }
private void filterList_SelectionChanged(object sender, EventArgs e) { ScriptableProperty prop = TargetPropertyCombo.SelectedItem as ScriptableProperty; ControlBinding binding = (ControlBinding)MapsView.SelectedItems[0].Tag; if (prop != null) { if (binding.BindingType == BindingType.SetValue && prop.Type == ScriptablePropertyTypes.ConstellationFilter) { binding.Value = filterList.SelectedItem.ToString(); SetDirty(); } } MapsView.SelectedItems[0].SubItems[1].Text = binding.ToString(); MapsView.SelectedItems[0].SubItems[2].Text = binding.Parent.AutoRepeat ? "Repeat" : "Once"; }
void monitoringMap_MessageReceived(object sender, MIDI.MidiMessage message, int channel, int key, int value) { if (monitoringMap != null) { ControlMap map = monitoringMap.FindMap(channel, key); if (map != null) { MethodInvoker doIt = delegate { foreach (ListViewItem item in MapsView.Items) { ControlBinding cb = item.Tag as ControlBinding; if (cb != null) { if (cb.Parent == map) { item.Selected = true; MapsView.EnsureVisible(item.Index); break; } } } }; if (this.InvokeRequired) { try { this.Invoke(doIt); } catch { } } else { doIt(); } } } }
private void filterList_SelectionChanged(object sender, EventArgs e) { if (DeviceList.SelectedIndex > -1 && MapsView.SelectedIndices.Count > 0) { MidiMap midiMap = (MidiMap)DeviceList.SelectedItem; ControlBinding binding = (ControlBinding)MapsView.SelectedItems[0].Tag; ScriptableProperty prop = TargetPropertyCombo.SelectedItem as ScriptableProperty; if (prop != null) { if (binding.BindingType == BindingType.SetValue && prop.Type == ScriptablePropertyTypes.ConstellationFilter) { binding.Value = filterList.SelectedItem.ToString(); } } MapsView.SelectedItems[0].SubItems[4].Text = binding.ToString(); } }
private void UpdatePropertyCombo() { BindingTargetType tt = (BindingTargetType)TargetTypeCombo.SelectedIndex; TargetPropertyCombo.Items.Clear(); TargetPropertyCombo.ClearText(); filterLabel.Visible = false; filterList.Visible = false; if (DeviceList.SelectedIndex > -1 && MapsView.SelectedIndices.Count > 0) { MidiMap midiMap = (MidiMap)DeviceList.SelectedItem; ControlBinding binding = (ControlBinding)MapsView.SelectedItems[0].Tag; binding.TargetType = tt; IScriptable scriptInterface = null; bool comboVisible = true; switch (tt) { case BindingTargetType.Setting: scriptInterface = Settings.Active as IScriptable; break; case BindingTargetType.SpaceTimeController: scriptInterface = SpaceTimeController.ScriptInterface; break; case BindingTargetType.Goto: comboVisible = false; break; case BindingTargetType.Layer: scriptInterface = LayerManager.ScriptInterface; break; case BindingTargetType.Navigation: scriptInterface = Earth3d.MainWindow as IScriptable; break; //case BindingTargetType.Actions: // break; //case BindingTargetType.Key: // break; //case BindingTargetType.Mouse: // break; default: break; } if (comboVisible) { TargetPropertyCombo.Visible = true; PropertyNameText.Visible = false; BindTypeCombo.Visible = true; BindTypeLabel.Visible = true; if (scriptInterface != null) { switch (binding.BindingType) { case BindingType.Action: TargetPropertyCombo.Items.Clear(); TargetPropertyCombo.Items.AddRange(scriptInterface.GetActions()); break; case BindingType.Toggle: TargetPropertyCombo.Items.Clear(); TargetPropertyCombo.Items.AddRange(UiTools.GetFilteredProperties(scriptInterface.GetProperties(), binding.BindingType)); break; case BindingType.SyncValue: TargetPropertyCombo.Items.Clear(); TargetPropertyCombo.Items.AddRange(scriptInterface.GetProperties()); break; case BindingType.SetValue: TargetPropertyCombo.Items.Clear(); TargetPropertyCombo.Items.AddRange(scriptInterface.GetProperties()); break; default: break; } } TargetPropertyCombo.SelectedItem = binding.PropertyName; } else { PropertyNameText.Visible = true; TargetPropertyCombo.Visible = false; PropertyNameText.Text = binding.PropertyName; BindTypeCombo.Visible = false; BindTypeLabel.Visible = false; } MapsView.SelectedItems[0].SubItems[4].Text = binding.ToString(); UpdateSelectedControlMap(); } }