Пример #1
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="midiInfo"></param>
        /// <param name="i_Channel"></param>
        public void Refresh(ref MidiInfo midiInfo, int i_Channel)
        {
            _Channels.Clear();

            for (int i = 0; i < midiInfo.a_UsedChannels.Length; i++)
            {
                if (midiInfo.a_UsedChannels[i])
                {
                    _Channels.Add(new Channel
                                      {
                                          i_ChannelNumber = i,
                                          s_Instrument = midiInfo.a_ChannelInstrumentNames[i],
                                          i_NoteCount = midiInfo.notesForAllChannels[i].Count
                                          //i_NoteCount = -1
                                      });
                }
            }

            if (i_Channel >= 0)
            {
                for (int i = 0; i < channelsListView.Items.Count; i++)
                {
                    if (i_Channel == ((Channel)channelsListView.Items[i]).i_ChannelNumber)
                    {
                        channelsListView.SelectedIndex = i;
                        break;
                    }
                }
            }
        }
Пример #2
0
        public ChannelSelector(ref MidiInfo midiInfo, int i_Channel, RoutedEventHandler extOkButtonClickedEvent, NWGUI Browser)
        {
            Browser.okButton.Click += extOkButtonClickedEvent;

            for (int i = 0; i < midiInfo.a_UsedChannels.Length; i++) {
                if (midiInfo.a_UsedChannels[i]) {
                    _Channels.Add(new Channel {
                        i_ChannelNumber = i,
                        s_Instrument = midiInfo.a_ChannelInstrumentNames[i]
                    });
                }
            }

            if (i_Channel >= 0) {
                for (int i = 0; i < Browser.listView.Items.Count; i++) {
                    if (i_Channel == ((Channel)Browser.listView.Items[i]).i_ChannelNumber) {
                        Browser.listView.SelectedIndex = i;
                        break;
                    }
                }
            }
        }
Пример #3
0
        /// <summary>
        /// Constructor for window
        /// </summary>
        public NWGUI()
        {
            InitializeComponent();

            midiInfo = new MidiInfo(debugConsole);

            Stop.IsEnabled = false;
            Stop.Width = 0;

            instrument = ReadSettingsFromFile();
            if (instrument != 0) {
                Instrument_Clicked(instrument);
                foreach (MenuItem item in Instruments.Items) {
                    if (instrument == Convert.ToInt32(item.Tag))
                        item.IsChecked = true;
                }
            }

            i_InitialCanvasPosY = (double)(subcanv.GetValue(Canvas.TopProperty));

            //r_HeaderBackground.Background = new SolidColorBrush(Color.FromRgb(51, 51, 51));
            HideCanvasChildren();

            if (USE_OLD_SERIAL_READ_METHOD) {
                serialPort.ReadTimeout = 5;
                serialPortReadThread = new Thread(new ThreadStart(GetSerialData));
                serialPortReadThread.Start();
            }
            else
            {
                serialPort.DataReceived += SerialPortDataReceived;
            }

            channelSelector = new ChannelSelector(channelsListView, ChannelsListViewSelectionChanged);
            channelsListView.DataContext = channelSelector.Channels;
            serialPortSelector = new SerialPortSelector(serialPortsListView);
            serialPortsListView.DataContext = serialPortSelector.SerialPorts;

            //System.Console.WriteLine("{0}, {1}", window.ActualWidth, window.ActualHeight);
            //System.Console.WriteLine("{0}, {1}", LogoPositionX, LogoPositionY);
        }