public CompactForm()
 {
     InitializeComponent();
     rankingForm.AutoSizeChanged += new EventHandler(rankingForm_AutoSizeChanged);
     rankingForm.MouseTransModeChanged += new EventHandler(rankingForm_MouseTransModeChanged);
     actionReport = new FF14LogParser();
     SetFormActionReport();
 }
        public Report()
        {
            ar = new FF14LogParser();

            Span = 60;//60秒

            FF14FastReportDS = new FF14FastReportDataSet();
            Reset();

        }
        public FastRepMainForm()
        {
            InitializeComponent();

            actionreport = new FF14LogParser();
            frepForm = new FastReportForm();
            rf = new RankingForm();

            bindingSource2.DataSource = actionreport.ds;
        }
        private void ファイルからインポートToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FF14FastReport.OpenGameLogFolderForm frm = new FF14FastReport.OpenGameLogFolderForm();
            if (frm.ShowDialog(this) == DialogResult.OK)
            {
                FFXIVLogFileReader fr = new FFXIVLogFileReader(frm.SelectedFolder);
              FF14LogParser actionReport = new FF14LogParser();

                foreach (FFXIVLog log in fr.GetLogs())
                {
                    actionReport.Add(log);
                }
                bindingSource1.DataSource = actionReport.ds;
                bindingSource1.DataMember = "Anaylzed";
            }

        }
 private void 開くOToolStripMenuItem_Click(object sender, EventArgs e)
 {
     openFileDialog1.InitialDirectory = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "log");
     if (openFileDialog1.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
     {
         try
         {
             FF14LogParser actionReport = new FF14LogParser();
             actionReport.Read(openFileDialog1.FileName);
             bindingSource1.DataSource = actionReport.ds;
             bindingSource1.DataMember = "Anaylzed";
         }
         catch (Exception _e)
         {
             MessageBox.Show(_e.Message);
         }
     }
 }
        public void SetActionReport(FF14LogParser _ar)
        {
//            ar = new ActionReport();
            Reset();
            ar.ds.Merge((FFXIVLogDataSet)_ar.ds.Copy());
        }
        /// <summary>
        /// 更新する
        /// </summary>
        public void Update()
        {
            Dirs.Clear();
            Files.Clear();
            LogFiles.Clear();

            Dirs.AddRange(Directory.GetDirectories(FolderFullPath));
            Files.AddRange(Directory.GetDirectories(FolderFullPath));
            if (Directory.Exists(logFolderPath) && File.Exists(GetLogFilePath(0)))
            {
                LogFiles.AddRange(Directory.GetFiles(logFolderPath));
                LogFiles.Sort();
                string firstLogFile = GetLogFilePath(0);
                string lastLogFile = GeLastWriteLogFile();

                FFXIVLog[] f_logs =  FFXIVLogFileReader.GetLogsFromFile(firstLogFile);
                FFXIVLog[] l_logs = FFXIVLogFileReader.GetLogsFromFile(lastLogFile);
                //最後にログインした時間をログから設定
                LastLoginTimeFromLogFile = f_logs[0].TimeStampServerTime.Add(new TimeSpan(9, 0, 0));//ログファイルの時間はGMTなので+9時間
                //最後にプレイした時間をログから設定
                LastPlayTimeFromLogFile = l_logs[l_logs.Length-1].TimeStampServerTime.Add(new TimeSpan(9, 0, 0));
                //サーバー名
                for (int i = 0; i < 999; i++)
                {
                    if (f_logs[i].LogBody.StartsWith(":Welcome to "))
                    {
                        ServerName = f_logs[0].LogBody.Substring(":Welcome to ".Length).Replace(" !", "");
                        break;
                    }
                }
                //キャラ名取得
                FF14LogParser ar = new FF14LogParser();
                foreach (FFXIVLog log in f_logs)
                {
                    ar.Add(log);
                    FFXIVLogDataSet.ActorRow[] arows = (FFXIVLogDataSet.ActorRow[])ar.ds.Actor.Select("IsMe = True");
                    if (arows.Length > 0)
                    {
                        CharacterName = arows[0].Name;
                        break;
                    }
                }
                if (CharacterName == "")
                {
                    foreach (FFXIVLog log in l_logs)
                    {
                        ar.Add(log);
                        FFXIVLogDataSet.ActorRow[] arows = (FFXIVLogDataSet.ActorRow[])ar.ds.Actor.Select("IsMe = True");
                        if (arows.Length > 0)
                        {
                            CharacterName = arows[0].Name;
                            break;
                        }
                    }
                }


            }
        }
        private void InitializeData()
        {
            LogCount = 0;//カウントを0にする

            int logcount = logmemoryInfo.GetLogCount();

            FF14LogParser _actionReport = new FF14LogParser();


            if (logcount > 1000)
            {//ファイルからよまないとね

                SetStatus("ログファイルからデータを読み込んでいます。0/"+logcount +"行");

                FFXIVUserFolder userfolder = new FFXIVUserFolder();
                CharacterFolder playnow = null;
                foreach(CharacterFolder cf in userfolder.GetCharacterFolders())
                {
                    if(playnow==null)playnow =cf;
                    if (cf.LastPlayTimeFromLogFile > playnow.LastPlayTimeFromLogFile)
                    {
                        playnow = cf;
                    }
                }
                List<FFXIVLog> LogsFromFile = new List<FFXIVLog>();
                logcount = logmemoryInfo.GetLogCount();
                if (playnow.LastPlayTimeFromLogFile > FFXIVLog.StartDateTime)
                {
                    int filenum = 0;
                    while(filenum < logmemoryInfo.GetLogCount()/1000)
                    {
                        foreach (FFXIVLog log in FFXIVLogFileReader.GetLogsFromFile(playnow.GetLogFilePath(filenum)))
                        {
                            _actionReport.Add(log);
                        }
                        filenum++;
                        SetStatus("ログファイルからデータを読み込んでいます。"+filenum+"000/" + logcount + "行");
                    }
                }
                SetStatus("メモリからログを読み込んでいます。");
                foreach (byte[] data in logmemoryInfo.GetNewLogsData())
                {
                    _actionReport.Add(FFXIVLog.ParseSingleLog(data));
                }
            }
            actionReport = _actionReport;
            SetFormActionReport();
            SetLogCount();
            //rankingForm.report.SetActionReport(actionReport);
        }
        private void 開くOToolStripMenuItem_Click(object sender, EventArgs e)
        {
            openFileDialog1.InitialDirectory = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "log");
            if (openFileDialog1.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
            {
                try
                {
                    FF14LogParser _ar = new FF14LogParser();

                    System.Threading.ThreadStart ts = () =>
                    {
                        _ar.Read(openFileDialog1.FileName);
                    };
                    System.Threading.Thread th = new System.Threading.Thread(ts);
                    th.Start();

                    int p = 0;
                    SetStatus(String.Format("ファイルを読み込んでいます・・・{0} ", Path.GetFileName(openFileDialog1.FileName)));
                    Application.DoEvents();
                    System.Threading.Thread.Sleep(100);

                    while (th.IsAlive)
                    {
                        SetProgress(Math.Min(100, 10 * p++), true);
                        System.Diagnostics.Debug.WriteLine(actionReport.Progress);
                        System.Threading.Thread.Sleep(100);
                        Application.DoEvents();
                    }
                    SetProgress(0, false);
                    SetStatus(String.Format("ファイルを読み込んでいます・・・ {0} 完了", Path.GetFileName(openFileDialog1.FileName)));

                    if (MessageBox.Show("読み込んだデータの解析を行いますか?", "再解析", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
                    {
                        FF14LogParser ar = new FF14LogParser();
                        ts = () =>
                        {
                            foreach (FFXIVLogDataSet.AnaylzedRow arow in _ar.ds.Anaylzed)
                            {
                                FFXIVLog log = FFXIVLog.CreateLog(arow.TotalSeconds, arow.LogType, arow.ActionType, arow.Body);
                                ar.Add(log);
                            }
                        };

                        th = new System.Threading.Thread(ts);
                        th.Start();

                        while (th.IsAlive)
                        {
                            SetProgress(Math.Min(100, 100 * ar.ds.Anaylzed.Count / _ar.ds.Anaylzed.Count), true);
                            SetStatus(String.Format("解析しています・・・{0}/{1}", ar.ds.Anaylzed.Count, _ar.ds.Anaylzed.Count));
                            Application.DoEvents();
                            System.Threading.Thread.Sleep(500);
                        }
                        SetStatus(String.Format("解析しています・・・{0}/{1}", ar.ds.Anaylzed.Count, _ar.ds.Anaylzed.Count));
                        SetProgress(0, false);
                        Application.DoEvents();

                        actionReport = ar;
                    }
                    else
                    {
                        actionReport = _ar;
                    }
                    SetStatus("表示範囲指定ウィンドウを開いています・・・");
                    Application.DoEvents();
                    データ範囲指定ToolStripMenuItem_Click(this, null);

                }
                catch (Exception _e)
                {
                    MessageBox.Show(_e.Message);
                    actionReport = _processActionReport;
                }
            }
        }
        private void ログのインポートToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                FF14FastReport.OpenGameLogFolderForm frm = new FF14FastReport.OpenGameLogFolderForm();
                if (frm.ShowDialog(this) == DialogResult.OK)
                {
                    if (Directory.Exists(frm.SelectedFolder))
                    {
                        FFXIVLogFileReader fr = new FFXIVLogFileReader(frm.SelectedFolder);
                        FF14LogParser _ar = new FF14LogParser();

                        FFXIVLog[] logs = fr.GetLogs();
                        SetStatus(logs.Length + "行のログを解析しています。");
                        Application.DoEvents();
                        System.Threading.ThreadStart ts = () =>
                        {
                            foreach (FFXIVLog log in logs)
                            {
                                _ar.Add(log);
                            }
                        };
                        System.Threading.Thread th = new System.Threading.Thread(ts);
                        th.Start();

                        while (th.IsAlive)
                        {
                            SetProgress(100 * _ar.ds.Anaylzed.Count / logs.Length, true);
                            Application.DoEvents();
                            System.Threading.Thread.Sleep(100);
                        }
                        SetProgress(0, false);
                        SetStatus("読み込みが完了しました");
                        Application.DoEvents();

                        actionReport = _ar;
                        データ範囲指定ToolStripMenuItem_Click(this, null);
                    }
                }
            }
            catch
            {
                MessageBox.Show("ログファイルの読み込みに失敗しました。");
            }
        }
 private void 更新するUToolStripMenuItem_Click(object sender, EventArgs e)
 {
     actionReport = _processActionReport;
     UpdateData();
 }
 public void SetActionReport(FF14LogParser ar)
 {
     actionReport = ar;
     _processActionReport = actionReport;
     pivot = new PivotA((FFXIVLogDataSet.AnaylzedRow[]) ar.ds.Anaylzed.Select());
 }
        public FastReportForm()
        {
            InitializeComponent();
            ar = new FF14LogParser();

            dAndDSizeChanger = new DAndDSizeChanger(this, this, DAndDArea.All, 4);

            foreach(Control ctrl in this.Controls)
            {
                SetDAndDSizeChanger(ctrl);
            }


        }