Exemplo n.º 1
0
        private async Task <PacketLog> LoadLogFromFile(string path)
        {
            this.Cursor = Cursors.WaitCursor;
            SetEnabled(this, false);

            var log = await PacketLog.Load(path);

            this.Cursor = Cursors.Default;
            SetEnabled(this, true);

            return(log);

            void SetEnabled(Control parent, bool enabled)
            {
                foreach (Control item in parent.Controls)
                {
                    item.Enabled = enabled;
                    SetEnabled(item, enabled);
                }
            }
        }
Exemplo n.º 2
0
        private async void Form1_Load(object sender, EventArgs e)
        {
            Loading = true;
            lvPacketTypes.BeginUpdate();

            foreach (var type in PacketTypes)
            {
                var item = lvPacketTypes.Items.Add(type.Name.Replace("Packet", ""));

                item.Checked =
                    type != typeof(PlayerStatePacket) &&
                    type != typeof(StateListPacket) &&
                    type != typeof(CircuitStatePacket);
            }

            LoadCheckedPacketTypes();

            lvPacketTypes.EndUpdate();
            Loading = false;

            var args = Environment.GetCommandLineArgs();

            if (args.Length > 1)
            {
                try
                {
                    Log = await LoadLogFromFile(LastPath = args[1]);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Unable to open log file. Details: \n" + ex, "Error", MessageBoxButtons.OK);
                    return;
                }

                LoadLog(Log);
            }
        }