Ejemplo n.º 1
0
 public ChannelCopyDialog(AffectGridDelegate affectGridDelegate, EventSequence sequence, Channel selected, bool constrainToGroup)
 {
     InitializeComponent();
     _channels = new Channel[constrainToGroup ? sequence.ChannelCount : sequence.FullChannelCount];
     for (var channel = 0; channel < _channels.Length; channel++) {
         _channels[channel] = constrainToGroup ? sequence.Channels[channel] : sequence.FullChannels[channel];
     }
     // ReSharper disable CoVariantArrayConversion
     comboBoxSourceChannel.Items.AddRange(_channels);
     comboBoxDestinationChannel.Items.AddRange(_channels);
     // ReSharper restore CoVariantArrayConversion
     if (comboBoxSourceChannel.Items.Count > 0) {
         if (comboBoxSourceChannel.Items.Contains(selected)) {
             comboBoxSourceChannel.SelectedItem = selected;
         }
         else {
             comboBoxSourceChannel.SelectedIndex = 0;
         }
     }
     if (comboBoxDestinationChannel.Items.Count > 0) {
         comboBoxDestinationChannel.SelectedIndex = 0;
     }
     _eventSequence = sequence;
     _sequenceData = new byte[1,sequence.TotalEventPeriods];
     _affectGridDelegate = affectGridDelegate;
 }
Ejemplo n.º 2
0
 public ThinSelection(Channel[] values)
 {
     InitializeComponent();
     _channels = values;
     foreach (var c in _channels) {
         listBox.Items.Add(c.Name);
     }
 }
Ejemplo n.º 3
0
        private static XmlNode FormatChannel(XmlDocument doc, Channel ch)
        {
            XmlNode node = doc.CreateElement("Channel");
            node.InnerText = ch.Name;

            Xml.SetAttribute(node, "color", ch.Color.ToArgb().ToString(CultureInfo.InvariantCulture));
            Xml.SetAttribute(node, "output", (ch.OutputChannel).ToString(CultureInfo.InvariantCulture));
            Xml.SetAttribute(node, "id", ch.Id.ToString(CultureInfo.InvariantCulture));
            Xml.SetAttribute(node, "enabled", ch.Enabled.ToString());

            return node;
        }
Ejemplo n.º 4
0
        private static XmlNode FormatChannel(XmlDocument doc, Channel ch)
        {
            XmlNode node = doc.CreateElement("Channel");
            Xml.SetAttribute(node, "name", ch.Name);
            Xml.SetAttribute(node, "color", ch.Color.ToArgb().ToString(CultureInfo.InvariantCulture));
            Xml.SetAttribute(node, "output", (ch.OutputChannel).ToString(CultureInfo.InvariantCulture));
            Xml.SetAttribute(node, "id", ch.Id.ToString(CultureInfo.InvariantCulture));
            Xml.SetAttribute(node, "enabled", ch.Enabled.ToString());

            if (ch.DimmingCurve != null) {
                Xml.SetValue(node, "Curve", string.Join(",", ch.DimmingCurve.Select(num => num.ToString(CultureInfo.InvariantCulture)).ToArray()));
            }

            return node;
        }
Ejemplo n.º 5
0
        public TestConsoleDialog(EventSequence sequence, IExecution executionInterface, bool constrainToGroup)
        {
            InitializeComponent();
            _sequence = sequence;
            _executionInterface = executionInterface;
            _executionContextHandle = _executionInterface.RequestContext(false, true, null);
            _executionInterface.SetAsynchronousContext(_executionContextHandle, sequence);
            _channelLevels = new byte[_sequence.FullChannelCount];
            var channels = new Channel[constrainToGroup ? _sequence.ChannelCount + 1 : _sequence.FullChannelCount + 1];
            channels[0] = new Channel(Resources.Unassigned, Color.Gainsboro, 0);

            for (var channel = 1; channel <= channels.Length - 1; channel++) {
                channels[channel] = constrainToGroup ? _sequence.Channels[channel - 1] : _sequence.FullChannels[channel - 1];
            }

            foreach (var trackBar in groupBox2.Controls.Cast<object>().OfType<ConsoleTrackBar>().Where(trackBar => trackBar.Master != null)) {
                trackBar.TextStrings = channels;
                trackBar.ResetIndex = 0;
                _channelControls.Add(trackBar);
            }
        }
Ejemplo n.º 6
0
        public void RemoveChannel(Channel channelObject)
        {
            //Find where the associated channel info is
            var objectIndex = _channelObjects.IndexOf(channelObject);
            var outputIndex = _channelOutputs[objectIndex];

            //remove them
            _channelOutputs.RemoveAt(objectIndex);
            _channelObjects.RemoveAt(objectIndex);

            // Now update the output mapping for the channel
            for (var i = 0; i < _channelOutputs.Count; i++) {
                if (_channelOutputs[i] > outputIndex) {
                    _channelOutputs[i]--;
                }
            }

            Freeze();
            IsDirty = true;
        }
Ejemplo n.º 7
0
 private int GetOutputForChannel(Channel c)
 {
     return _eventSequence.Channels[GetChannelIndex(c)].OutputChannel;
 }
Ejemplo n.º 8
0
 private int GetChannelIndex(Channel channel)
 {
     return _sequence.Channels.IndexOf(channel);
 }
Ejemplo n.º 9
0
        public void AddChannelObject(Channel channelObject,bool addOutput = true)
        {
            _channelObjects.Add(channelObject);
            if (addOutput) {
                AddChannelOutput(_channelOutputs.Count);
            }

            IsDirty = true;
        }
Ejemplo n.º 10
0
 public void CopyChannel(Channel source, Channel dest)
 {
     var index = _fullChannels.IndexOf(source);
     var num2 = _fullChannels.IndexOf(dest);
     for (var i = 0; i < TotalEventPeriods; i++) {
         EventValues[num2, i] = EventValues[index, i];
     }
 }
Ejemplo n.º 11
0
 private Rectangle GetChannelNameRect(Channel channel)
 {
     return channel != null
         ? new Rectangle(0,
             (GetChannelIndex(channel) - vScrollBar1.Value) * _gridRowHeight + pictureBoxTime.Height + splitContainer2.SplitterWidth,
             pictureBoxChannels.Width, _gridRowHeight) : Rectangle.Empty;
 }
Ejemplo n.º 12
0
 public static void DrawItem(DrawItemEventArgs e, Channel c, ListBox lb)
 {
     e.DrawItem(c.Name, c.Color, lb, UseCheckmark);
 }
Ejemplo n.º 13
0
 public static void DrawItem(DrawItemEventArgs e, Channel c, bool useCheckmark = false)
 {
     e.DrawItem(c.Name, c.Color, useCheckmark);
 }
Ejemplo n.º 14
0
 // Not true since this is called via reflection.
 // ReSharper disable MemberCanBePrivate.Global
 public StandardSequence()
 {
     // ReSharper restore MemberCanBePrivate.Global
     object obj2;
     _executionInterface = null;
     _systemInterface = null;
     _gridRowHeight = 20;
     _visibleRowCount = 0;
     _visibleEventPeriods = 0;
     _channelBackBrush = null;
     _waveformBackBrush = null;
     _gridBackBrush = null;
     _channelNameFont = new Font("Arial", 8f);
     _channelStrikeoutFont = new Font("Arial", 8f, FontStyle.Strikeout);
     _timeFont = new Font("Arial", 8f);
     _selectedChannel = null;
     _currentlyEditingChannel = null;
     _editingChannelIndex = 0;
     _gridGraphics = null;
     _selectedRange = new Rectangle();
     _gridColWidth = 30;
     _selectionRectangle = new Rectangle();
     _selectionBrush = new SolidBrush(Color.FromArgb(63, Color.Blue));
     _positionBrush = new SolidBrush(Color.FromArgb(63, Color.Red));
     _mouseDownInGrid = false;
     _position = -1;
     _previousPosition = -1;
     _mouseChannelCaret = -1;
     _mouseTimeCaret = -1;
     _undoStack = new Stack();
     _redoStack = new Stack();
     _lineRect = new Rectangle(-1, -1, -1, -1);
     _lastCellX = -1;
     _lastCellY = -1;
     _lastGroupIndex = 0;
     _initializing = false;
     _selectedEventIndex = -1;
     _selectedCells = new Rectangle();
     _mouseDownAtInGrid = new Point();
     _mouseDownAtInChannels = Point.Empty;
     _waveformPcmData = null;
     _waveformPixelData = null;
     _waveformCenterLine = 36;
     _showingOutputs = false;
     _selectedLineIndex = 0;
     _eventMarks = new List<int> {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1};
     _showingGradient = true;
     _showWaveformZeroLine = true;
     _actualLevels = false;
     _showCellText = false;
     _lastSelectableControl = null;
     if (Interfaces.Available.TryGetValue("IExecution", out obj2)) {
         _executionInterface = (IExecution) obj2;
     }
     if (Interfaces.Available.TryGetValue("ISystem", out obj2)) {
         _systemInterface = (ISystem) obj2;
     }
     _toolStrips = new Dictionary<string, ToolStrip>();
     _toolStripCheckStateChangeHandler = toolStripItem_CheckStateChanged;
     _inPlayback = false;
 }
Ejemplo n.º 15
0
 private int GetChannelIndex(Channel c)
 {
     return _eventSequence.Channels.IndexOf(c);
 }
Ejemplo n.º 16
0
 private int GetEventFromChannel(Channel channel)
 {
     return _sequence.FullChannels.IndexOf(channel);
 }
Ejemplo n.º 17
0
        private bool ChannelClickValid()
        {
            var isValid = false;
            var mouseY = pictureBoxChannels.PointToClient(MousePosition).Y;

            if (mouseY > pictureBoxTime.Height + splitContainer2.SplitterWidth) {
                _selectedLineIndex = vScrollBar1.Value + (mouseY - (pictureBoxTime.Height + splitContainer2.SplitterWidth)) / _gridRowHeight;
                if (_selectedLineIndex < _sequence.ChannelCount) {
                    _editingChannelIndex = _selectedLineIndex;
                    isValid = (_editingChannelIndex >= 0);
                }
            }

            if (isValid) {
                _currentlyEditingChannel = SelectedChannel = _sequence.Channels[_editingChannelIndex]; //Tested okay
            }

            return isValid;
        }
Ejemplo n.º 18
0
        private void pictureBoxGrid_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button != MouseButtons.Left || _sequence.ChannelCount == 0) {
                return;
            }

            _mouseDownInGrid = true;
            lblFollowMouse.Visible = true & (_executionInterface.EngineStatus(_executionContextHandle) != Utils.ExecutionRunning);
            _mouseDownAtInGrid.X = (e.X / _gridColWidth) + hScrollBar1.Value;
            _mouseDownAtInGrid.Y = (e.Y / _gridRowHeight) + vScrollBar1.Value;

            if (_selectedCells.Width != 0) {
                EraseSelectedRange();
            }

            if ((ModifierKeys & Keys.Control) != Keys.None) {
                _selectedLineIndex = (e.Y / _gridRowHeight) + vScrollBar1.Value;
                _editingChannelIndex = GetEventFromChannelNumber(_selectedLineIndex);
                _currentlyEditingChannel = _sequence.Channels[_selectedLineIndex];
                _lineRect.X = _mouseDownAtInGrid.X;
                _lineRect.Y = _mouseDownAtInGrid.Y;
                _lineRect.Width = 0;
                _lineRect.Height = 0;
                InvalidateRect(_lineRect);
            }
            else if ((ModifierKeys & Keys.Shift) != Keys.None) {
                var rect = new Rectangle {
                    X = _selectedCells.X, Y = _selectedCells.Y,
                    Width = (hScrollBar1.Value + (int) Math.Floor(e.X / (float) _gridColWidth) - _selectedCells.Left) + 1,
                    Height = (vScrollBar1.Value + (e.Y / _gridRowHeight) - _selectedCells.Top) + 1
                };

                if (rect.Width < 0) {
                    rect.Width--;
                }
                if (rect.Height < 0) {
                    rect.Height--;
                }
                if (rect.Bottom > _sequence.ChannelCount) {
                    rect.Height = _sequence.ChannelCount - rect.Y;
                }
                if (rect.Right > _sequence.TotalEventPeriods) {
                    rect.Width = _sequence.TotalEventPeriods - rect.X;
                }
                _selectedCells = rect.NormalizeRect();
                DrawSelectedRange();
            }
            else if ((e.Y / _gridRowHeight) + vScrollBar1.Value < _sequence.ChannelCount &&
                     (e.X / _gridColWidth) + hScrollBar1.Value < _sequence.TotalEventPeriods) {
                _selectedLineIndex = (e.Y / _gridRowHeight) + vScrollBar1.Value;
                _editingChannelIndex = GetEventFromChannelNumber(_selectedLineIndex);
                _currentlyEditingChannel = _sequence.Channels[_selectedLineIndex];
                _selectedRange.X = hScrollBar1.Value + ((int) Math.Floor(e.X / ((float) _gridColWidth)));
                _selectedRange.Y = _selectedLineIndex;
                _selectedRange.Width = 1;
                _selectedRange.Height = 1;
                _selectedCells = _selectedRange;
                DrawSelectedRange();
            }
            else {
                _currentlyEditingChannel = null;
                _editingChannelIndex = -1;
                _selectedLineIndex = -1;
            }

            UpdatePositionLabel(_selectedCells, false);
        }