Exemple #1
0
        private void infoProcess_OutputDataReceived(object sender, DataReceivedEventArgs e)
        {
            if (e.Data != "" || e.Data != null)
            {
                songInfo = JsonConvert.DeserializeObject <MDOut>(e.Data);
                infoProcess.CancelOutputRead();
                txtGame.Text      = songInfo.Containerinfo.Game;
                txtSystem.Text    = songInfo.Containerinfo.System;
                txtDumper.Text    = songInfo.Containerinfo.Dumper;
                txtCopyright.Text = songInfo.Containerinfo.Copyright;

                lstChannels.Items.Clear();
                lstSubsongs.Items.Clear();
                lstChannels.BeginUpdate();
                lstSubsongs.BeginUpdate();
                var x = 0;
                foreach (var channel in songInfo.Channels)
                {
                    var ls = new  ListViewItem();
                    ls.Text = x.ToString();
                    ls.SubItems.Add(channel);
                    ls.SubItems.Add("");

                    lstChannels.Items.Add(ls);

                    x++;

                    chdVoiceName.Width = -1;
                }

                var y = 0;
                foreach (var song in songInfo.Songs)
                {
                    var ls = new ListViewItem();
                    ls.Text = y.ToString();
                    ls.SubItems.Add(song.Name);
                    ls.SubItems.Add(song.Author);

                    lstSubsongs.Items.Add(ls);

                    y++;

                    clhNumber.Width   = -1;
                    clhName.Width     = -1;
                    clhComposer.Width = -1;
                }
                lstChannels.EndUpdate();
                lstSubsongs.EndUpdate();

                lstSubsongs.Items[0].Selected = true;
            }
        }
Exemple #2
0
        public MainWindow()
        {
            InitializeComponent();

            _infoProcess = new Process()
            {
                EnableRaisingEvents = true
            };
            _probeProcess = new Process()
            {
                EnableRaisingEvents = true
            };
            _dumpingProcess = new Process()
            {
                EnableRaisingEvents = true
            };

            _infoProcess.OutputDataReceived += (sender, args) =>
            {
                if (args.Data != "" || args.Data != null)
                {
                    _songInfo = JsonConvert.DeserializeObject <MDOut>(args.Data);
                    _infoProcess.CancelOutputRead();

                    this.Dispatcher.Invoke(() =>
                    {
                        txtGame.Text      = _songInfo.Containerinfo.Game;
                        txtSystem.Text    = _songInfo.Containerinfo.System;
                        txtDumper.Text    = _songInfo.Containerinfo.Dumper;
                        txtCopyright.Text = _songInfo.Containerinfo.Copyright;

                        thrInfo.Visibility  = Visibility.Hidden;
                        thrProbe.Visibility = Visibility.Visible;

                        _channelInfoParsed = new ObservableCollection <ChannelInfo>();

                        Probe();


                        var indexed = new List <IndexedSong>();

                        for (int i = 0; i < _songInfo.Songs.Count; i++)
                        {
                            var s  = _songInfo.Songs[i];
                            s.Name = s.Name == "" ? null : s.Name;
                            indexed.Add(new IndexedSong(i, s));
                        }

                        lstSubSongs.ItemsSource = indexed;
                    });
                }
            };

            _infoProcess.Exited += (sender, args) => { };
            double mxp = 0.0;

            _probeProcess.OutputDataReceived += (sender, args) =>
            {
                string line = args.Data;

                if (line == null)
                {
                    _probeProcess.CancelOutputRead();
                    return;
                }
                if (line != "")
                {
                    if (line[0] == 'p')
                    {
                        var x = line.Split('|');
                        mxp = Double.Parse(x[2]);
                        this.Dispatcher.Invoke(() =>
                        {
                            thrProbe.Maximum = Double.Parse(x[2]);
                            thrProbe.Value   = Double.Parse(x[1]);
                        });
                    }
                    else
                    {
                        _channelInfo = JsonConvert.DeserializeObject <IncomingChannelInfo>(line);
                        foreach (var channel in _channelInfo.Channels)
                        {
                            _channelInfoParsed.Add(new ChannelInfo()
                            {
                                ChannelName     = channel,
                                CurrentProgress = 0.0,
                                MaximumProgress = mxp
                            });
                        }

                        this.Dispatcher.Invoke(() =>
                        {
                            lstInfo.Visibility  = Visibility.Visible;
                            lstInfo.ItemsSource = _channelInfoParsed;
                        });
                    }
                }
            };

            _probeProcess.Exited += (sender, args) =>
            {
                this.Dispatcher.Invoke(() =>
                {
                    thrProbe.Visibility = Visibility.Hidden;
                    if (lstSubSongs.SelectedItems.Count != 0)
                    {
                        btnDump.IsEnabled = true;
                    }
                });
            };

            string lineD;

            _dumpingProcess.OutputDataReceived += (sender, args) =>
            {
                lineD = args.Data;

                if (lineD == null)
                {
                    _dumpingProcess.CancelOutputRead();
                    return;
                }

                if (lineD != "")
                {
                    var x = lineD.Split('|');
                    _channelInfoParsed[Int32.Parse(x[0])].MaximumProgress = Double.Parse(x[2]);
                    _channelInfoParsed[Int32.Parse(x[0])].CurrentProgress = Double.Parse(x[1]);
                }
            };

            _dumpingProcess.Exited += (sender, args) =>
            {
                this.Dispatcher.Invoke(() =>
                {
                    btnLoad.IsEnabled = true;
                    btnDump.IsEnabled = true;
                });

                Process.Start("explorer", $"/select,\"{_ofDialog.FileName}\"");
            };
        }