Exemple #1
0
        private void CloseWindow()
        {
            using (this.MTBusy.Section())
            {
                try
                {
                    // -- 9000

                    Ground.I.InputDir            = this.InputDir.Text;
                    Ground.I.OutputDir           = this.OutputDir.Text;
                    Ground.I.OutputToInputDir    = this.OutputToInputDir.Checked;
                    Ground.I.OutputOverwriteMode = this.OutputOverwriteMode.Checked;
                    Ground.I.Save();

                    Ground.I.Dispose();
                    Ground.I = null;

                    // ----
                }
                catch (Exception e)
                {
                    MessageDlgTools.Error("Error @ CloseWindow()", e);
                }
                this.MTBusy.Enter();
                this.Close();
            }
        }
Exemple #2
0
        private void MainTimer_Tick(object sender, EventArgs e)
        {
            if (this.MTBusy.HasVisitor())
            {
                return;
            }

            this.MTBusy.Enter();
            try
            {
                if (this.XPressed)
                {
                    this.XPressed = false;
                    this.CloseWindow();
                    return;
                }

                // -- 3001

                // ----
            }
            catch (Exception ex)
            {
                MessageDlgTools.Error("Error @ Timer", ex);
            }
            finally
            {
                this.MTBusy.Leave();
                this.MTCount++;
            }
        }
Exemple #3
0
        private void MainWin_Shown(object sender, EventArgs e)
        {
            // -- 0001

            try
            {
                Ground.I = new Ground();
                Ground.I.LoadDataDir();

                this.CurrPair.SelectedIndex = 22;                 // USDJPY

                {
                    long ed = Ground.I.Period_DateTimeEd;
                    long st = DateTimeToSec.ToDateTime(DateTimeToSec.ToSec(ed) - 86400 * 5);

                    this.DateTimeSt.Text = st.ToString();
                    this.DateTimeEd.Text = ed.ToString();
                }

                this.CondChanged();
            }
            catch (Exception ex)
            {
                MessageDlgTools.Error(Program.APP_TITLE + " - Error @ Shown", ex);

                Environment.Exit(1);                 // unrecoverable error
            }

            // ----

            this.MTBusy.Leave();
        }
Exemple #4
0
        private void BtnStart_Click(object sender, EventArgs e)
        {
            this.UIEvent_Go(() =>
            {
                string inputDir  = this.InputDir.Text;
                string outputDir = this.OutputDir.Text;

                try
                {
                    if (inputDir == "")
                    {
                        throw new Exception("入力フォルダを選択して下さい。");
                    }

                    if (outputDir == "")
                    {
                        throw new Exception("出力フォルダを選択して下さい。");
                    }

                    inputDir  = FileTools.MakeFullPath(inputDir);
                    outputDir = FileTools.MakeFullPath(outputDir);

                    if (Directory.Exists(inputDir) == false)
                    {
                        throw new Exception("入力フォルダが存在しません。");
                    }

                    if (Directory.Exists(outputDir) == false)
                    {
                        throw new Exception("出力フォルダが存在しません。");
                    }
                }
                catch (Exception ex)
                {
                    MessageDlgTools.Warning("変換開始_失敗", ex);
                    return;
                }

                this.Visible = false;

                new ConvMain().Perform(inputDir, outputDir, this.OutputOverwriteMode.Checked, Ground.I.ConvThreadCount);

                using (ReportLogViewer f = new ReportLogViewer())
                {
                    f.ShowDialog();
                }

                this.CloseWindow();
                //this.Visible = true; // 再表示は不要
            });
        }
Exemple #5
0
 private void UIEvent_Go(Action routine)
 {
     using (this.MTBusy.Section())
     {
         try
         {
             routine();
         }
         catch (Exception e)
         {
             MessageDlgTools.Error("Error @ UIEvent_Go()", e);
         }
     }
 }
Exemple #6
0
 private void UIEvent_Go(Action routine)
 {
     using (this.MTBusy.Section())
     {
         try
         {
             routine();
         }
         catch (Exception ex)
         {
             MessageDlgTools.Error(Program.APP_TITLE + " - Error @ UIEvent", ex);
         }
     }
 }
Exemple #7
0
        private void MainWin_Shown(object sender, EventArgs e)
        {
            // -- 0001

            try
            {
                Ground.I = new Ground();

                CommonUtils.AntiWindowsDefenderSmartScreen();

                {
                    string file = @".\Conv.exe";

                    if (File.Exists(file) == false)
                    {
                        file = @"..\..\..\..\Conv\Conv\bin\Release\Conv.exe";

                        if (File.Exists(file) == false)
                        {
                            throw new Exception("no Conv.exe");
                        }
                    }
                    Ground.I.ConvExeFile = file;
                }

                if (Ground.I.Load())
                {
                    this.InputDir.Text               = Ground.I.InputDir;
                    this.OutputDir.Text              = Ground.I.OutputDir;
                    this.OutputToInputDir.Checked    = Ground.I.OutputToInputDir;
                    this.OutputOverwriteMode.Checked = Ground.I.OutputOverwriteMode;
                }

                this.UIRefresh();
                ChocomintDialogsCommon.PostShown(this);
            }
            catch (Exception ex)
            {
                MessageDlgTools.Error("Error @ Shown", ex);

                Environment.Exit(1);                 // fatal
            }

            // ----

            this.MTBusy.Leave();
        }
Exemple #8
0
        private void 移動平均入力ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.UIEvent_Go(() =>
            {
                try
                {
                    string value = string.Join(":", ChartSrvc.I.Macs.Select(v => StringUtils.SecToUIString(v.SecSpan)).ToArray());

                    value = InputStringDlgTools.Show(
                        "移動平均入力",
                        "移動平均の時間(NNd,NNh,NNm,NN)を[:]区切りで入力して下さい。例 3d:12h:90m:6660",
                        false,
                        value
                        );

                    if (value == null)
                    {
                        return;
                    }

                    int[] secs = value.Split(':').Select(v => StringUtils.UIStringToSec(v)).ToArray();

                    if (Consts.MA_NUM_MAX < secs.Length)
                    {
                        throw new Exception("多いよ!");
                    }

                    foreach (int sec in secs)
                    {
                        if (sec % this.MaStep != 0 || sec < Consts.MA_SEC_SPAN_MIN || Consts.MA_SEC_SPAN_MAX < sec)
                        {
                            throw new Exception("不正なスパン:" + StringUtils.SecToUIString(sec));
                        }
                    }

                    ChartSrvc.I.Macs = secs.Select(sec => new ChartSrvc.MacInfo(sec, this.MaStep)).ToArray();
                }
                catch (Exception ex)
                {
                    MessageDlgTools.Warning("移動平均入力_失敗", ex);
                }

                this.DrawCharts();
            });
        }
Exemple #9
0
        private void CloseWindow()
        {
            using (this.MTBusy.Section())
            {
                try
                {
                    // -- 9000

                    // none

                    // ----
                }
                catch (Exception e)
                {
                    MessageDlgTools.Error("Error @ CloseWindow()", e);
                }
                this.MTBusy.Enter();
                this.Close();
            }
        }
Exemple #10
0
        private void CommonCought(Exception e)
        {
            Exception te = Utils.GetTrueException(e);

            if (te is Returning)
            {
                return;
            }

            if (te is CUIError)
            {
                MessageDlgTools.Error("Prime4096 エラー", e, this.Visible);
            }
            else if (te is LongMessageException)
            {
                LongMessageDlgTools.Warning("Prime4096", e.Message, Consts.LongMessageDlg_Size, this.Visible);
            }
            else
            {
                MessageDlgTools.Warning("Prime4096", e, this.Visible);
            }
        }
Exemple #11
0
        private void ReportLogViewer_Shown(object sender, EventArgs e)
        {
            try
            {
                this.MS_Init();
                this.MS_AutoResize();
                this.LoadReport();
                this.MS_AutoResize();

                ExtraTools.SetEnabledDoubleBuffer(this.MainSheet);

                this.MS_Refresh();
                this.MainSheet.ClearSelection();
            }
            catch (Exception ex)
            {
                MessageDlgTools.Error("レポート_初期化エラー", ex);

                // clear
                this.MainSheet.RowCount    = 0;
                this.MainSheet.ColumnCount = 0;
            }
        }
Exemple #12
0
        public void Perform(string inputDir, string outputDir, bool outputOverwriteMode, int threadCount)
        {
            try
            {
                Ground.I.CmProgressRate.Clear();
                Ground.I.CmReport.Clear();

                using (WorkingDir wd = new WorkingDir())
                {
                    string        successfulFile = wd.MakePath();
                    double        progressRate   = 0.0;
                    List <string> reportBuff     = new List <string>();

                    WaitDlgTools.Show(
                        Consts.CONV_PROCESSING_TITLE,
                        Consts.CONV_PROCESSING_MESSAGE_NORMAL,
                        () =>
                    {
                        ProcessTools.Batch(new string[]
                        {
                            string.Format(
                                Ground.I.ConvExeFile + " CS-Conv {0} {1} {2} {3} \"{4}\""
                                , StringTools.LiteEncode(inputDir)
                                , StringTools.LiteEncode(outputDir)
                                , outputOverwriteMode ? 1 : 0
                                , threadCount
                                , successfulFile
                                ),
                        },
                                           ProcMain.SelfDir
                                           );
                    },
                        () =>
                    {
                        if (Ground.I.EvCancellable_Y.WaitForMillis(0))
                        {
                            WaitDlg.Cancellable = true;
                        }
                        if (Ground.I.EvCancellable_N.WaitForMillis(0))
                        {
                            WaitDlg.Cancellable = false;
                        }
                        if (Ground.I.EvMessage_Normal.WaitForMillis(0))
                        {
                            WaitDlg.MessagePost.Post(Consts.CONV_PROCESSING_MESSAGE_NORMAL);
                        }
                        if (Ground.I.EvMessage_StartGenVideo.WaitForMillis(0))
                        {
                            WaitDlg.MessagePost.Post(Consts.CONV_PROCESSING_MESSAGE_START_GEN_VIDEO);
                        }
                        if (Ground.I.EvMessage_GenVideoRunning.WaitForMillis(0))
                        {
                            WaitDlg.MessagePost.Post(Consts.CONV_PROCESSING_MESSAGE_GEN_VIDEO_RUNNING);
                        }

                        {
                            byte[] message = Ground.I.CmProgressRate.Recv();

                            if (message != null)
                            {
                                progressRate = double.Parse(Encoding.ASCII.GetString(message));
                            }
                        }

                        {
                            byte[] message = Ground.I.CmReport.Recv();

                            if (message != null)
                            {
                                reportBuff.Add(Encoding.UTF8.GetString(message));

                                while (REPORT_BUFF_MAX < reportBuff.Count)
                                {
                                    reportBuff.RemoveAt(0);
                                }

                                WaitDlg.DetailMessagePost.Post(reportBuff.ToArray());
                            }
                        }

                        return(progressRate);
                    },
                        () =>
                    {
                        Ground.I.EvStop_Conv.Set();
                        Ground.I.EvStop_Master.Set();
                    });

                    if (File.Exists(successfulFile) == false)
                    {
                        throw new Exception("変換プロセスは正常に動作しませんでした。");
                    }

                    bool userCancelled = Ground.I.EvMessage_UserCancelled.WaitForMillis(0);

                    if (WaitDlg.LastCancelled || userCancelled)
                    {
                        MessageDlgTools.Show(MessageDlg.Mode_e.Warning, "変換中止", "変換プロセスを中止しました。(" + (userCancelled ? 1 : 0) + ")");
                    }
                    else
                    {
                        MessageDlgTools.Information("変換完了", "変換プロセスは終了しました。");
                    }
                }
            }
            catch (Exception ex)
            {
                MessageDlgTools.Error("変換処理エラー", ex);
            }
        }
Exemple #13
0
        private void Btn個数_Click(object sender, EventArgs e)
        {
            using (this.MTBusy.Section())
            {
                try
                {
                    string minval = this.T個数_最小値.Text;
                    string maxval = this.T個数_最大値.Text;

                    if (minval == "")
                    {
                        throw new Exception("最小値 が 未入力です。");
                    }

                    if (maxval == "")
                    {
                        throw new Exception("最大値 が 未入力です。");
                    }

                    if (StringTools.LiteValidate(minval, StringTools.DECIMAL) == false)
                    {
                        throw new Exception("最小値 に [0-9] 以外の文字が含まれています。");
                    }

                    if (StringTools.LiteValidate(minval, StringTools.DECIMAL) == false)
                    {
                        throw new Exception("最大値 に [0-9] 以外の文字が含まれています。");
                    }

                    if (Ground.TCalc_Int.Calc(Consts.S2P4096_1, "-", minval)[0] == '-')
                    {
                        throw new LongMessageException(Utils.AutoInsertNewLine("最小値 には 0 以上 " + Consts.S2P4096_1 + " 以下の整数を入力して下さい。", Consts.MaxLineLen_LongMessageDlg));
                    }

                    if (Ground.TCalc_Int.Calc(Consts.S2P4096_1, "-", maxval)[0] == '-')
                    {
                        throw new LongMessageException(Utils.AutoInsertNewLine("最大値 には 0 以上 " + Consts.S2P4096_1 + " 以下の整数を入力して下さい。", Consts.MaxLineLen_LongMessageDlg));
                    }

                    if (Ground.TCalc_Int.Calc(maxval, "-", minval)[0] == '-')
                    {
                        throw new Exception("最大値 < 最小値 になっています。");
                    }

                    string outFile = "PrimeCount_" + minval + "-" + maxval + ".txt";

                    if (Consts.OutputLocalFileLenMax < outFile.Length)
                    {
                        //outFile = "PrimeCount.txt";
                        outFile = "PrimeCount_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".txt";
                    }

                    //outFile = Path.Combine(ProcMain.SelfDir, outFile);
                    outFile = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), outFile);

                    outFile = InputFileDlgTools.Save(
                        "Prime4096",
                        "出力ファイルを選択して下さい。",
                        true,
                        outFile,
                        null,
                        "txt"
                        );

                    if (outFile == null)
                    {
                        throw new Returning();
                    }

                    bool[] cancelledBox = new bool[1];

                    this.Visible = false;
                    this.CommonInterlude_INIT(currValue => string.Format("{0} あたりの素数を数えています...", currValue));

                    WaitDlgTools.Show(
                        "Prime4096",
                        "数えています...",
                        () => Prime4096.WritePrimeCount(minval, maxval, outFile, () => cancelledBox[0] == false),
                        this.CommonInterlude,
                        () => cancelledBox[0] = true
                        );

                    if (WaitDlg.LastCancelled)
                    {
                        // memo: Prime4096.exe, Prime53.exe は ABORTED 行等を出力しない。

                        File.WriteAllText(
                            outFile,
                            File.ReadAllText(outFile, Encoding.ASCII).Trim() + "\n中止しました。\nこの出力結果は正しくない可能性があります。",
                            StringTools.ENCODING_SJIS
                            );

                        MessageDlgTools.Show(MessageDlg.Mode_e.Warning, "Prime4096", "中止しました。\r\n出力ファイルの内容は正しくない可能性があります。");
                    }
                    else
                    {
                        MessageDlgTools.Information("Prime4096", "完了しました。");
                    }
                }
                catch (Exception ex)
                {
                    this.CommonCought(ex);
                }
            }
            this.Visible = true;             // 復元
        }
Exemple #14
0
        private void MainWin_Shown(object sender, EventArgs e)
        {
            // -- 0001

            try
            {
                this.MainWin_Resize(null, null);

                {
                    string currPair = InputComboDlgTools.Show(
                        "通貨ペア選択",
                        "通貨ペアを選択して下さい。",
                        Consts.CurrPairs.Select(v => new InputComboDlgTools.Item <string>(v, v)),
                        false,
                        Consts.DefaultCurrPair
                        );

                    if (currPair == null)
                    {
                        throw new Exception("currPair == null");
                    }

                    ChartSrvc.I = new ChartSrvc(currPair);
                }

                Consts.TTSEC_END_MIN = TTCommon.DateTimeToTTSec(20000101000000);
                Consts.TTSEC_END_MAX = TTCommon.DateTimeToTTSec(DateTimeToSec.Now.GetDateTime());

                this.TTSecEnd  = Consts.TTSEC_END_MAX;
                this.TTSecStep = Consts.TTSEC_STEP_MIN;

                {
                    int maStep = InputStringDlgTools.Int(
                        "移動平均プロット間隔入力",
                        "移動平均のプロット間隔を秒単位で入力して下さい。",
                        false,
                        60,
                        Consts.MA_STEP_MIN,
                        Consts.MA_STEP_MAX,
                        -1
                        );

                    if (maStep == -1)
                    {
                        throw new Exception("maStep == -1");
                    }

                    this.MaStep = maStep;
                }

                ChartSrvc.I.Macs = new ChartSrvc.MacInfo[]
                {
                    ChartSrvc.MacInfo.Safe(86400 * 5, this.MaStep),                     // 5 days
                    ChartSrvc.MacInfo.Safe(86400 * 25, this.MaStep),                    // 25 days
                };

                this.DrawCharts();

                this.移動平均入力ToolStripMenuItem_Click(null, null);                 // zantei
            }
            catch (Exception ex)
            {
                MessageDlgTools.Error("Error @ Shown", ex);

                Environment.Exit(1);                 // fatal
            }

            // ----

            this.MTBusy.Leave();
        }
Exemple #15
0
        private void MainTimer_Tick(object sender, EventArgs e)
        {
            if (this.MTBusy.HasVisitor())
            {
                return;
            }

            this.MTBusy.Enter();
            try
            {
                if (this.XPressed)
                {
                    this.XPressed = false;
                    this.CloseWindow();
                    return;
                }

                // -- 3001

                // ---- CondChanged

                if (this.CondChangedCount == 1)                 // Do Refresh
                {
                    GrphCond cond                = null;
                    string   statusText          = this.Status.Text;
                    bool     statusTextErrorFlag = false;

                    try
                    {
                        cond = this.GetGrphCond();
                    }
                    catch (Exception ex)
                    {
                        statusText          = ex.Message;
                        statusTextErrorFlag = true;

                        this.LastGrphCond = null;
                    }

                    if (cond != null && (this.LastGrphCond == null || this.LastGrphCond.IsSame(cond) == false)) // ? グラフ更新の必要あり
                    {
                        this.LastGrphCond = cond;                                                               // DrawGrph()が例外を投げたとき何度もDrawGrph()しないよう、先に更新する。
                        this.DrawGrph(cond);

                        statusText =
                            DateTimeUnit.FromDateTime(Ground.I.GrphData.GetPrice(Ground.I.GrphData.Start).DateTime) +
                            " ~ " +
                            DateTimeUnit.FromDateTime(Ground.I.GrphData.GetPrice(Ground.I.GrphData.End).DateTime) +
                            ", Range: " +
                            (Ground.I.GrphData.GetPrice(Ground.I.GrphData.End).TTSec - Ground.I.GrphData.GetPrice(Ground.I.GrphData.Start).TTSec) +
                            " sec (" +
                            ((Ground.I.GrphData.GetPrice(Ground.I.GrphData.End).TTSec - Ground.I.GrphData.GetPrice(Ground.I.GrphData.Start).TTSec) / 86400.0).ToString("F3") +
                            " days), Step: " +
                            Ground.I.GrphData.Step +
                            " mins";
                    }

                    if (this.Status.Text != statusText)
                    {
                        this.Status.Text = statusText;
                    }

                    Color statusTextForeColor = Consts.LABEL_FORE_COLOR;
                    Color statusTextBackColor = Consts.LABEL_BACK_COLOR;

                    if (statusTextErrorFlag)
                    {
                        statusTextForeColor = Color.White;
                        statusTextBackColor = Color.Red;
                    }

                    if (this.Status.ForeColor != statusTextForeColor)
                    {
                        this.Status.ForeColor = statusTextForeColor;
                    }

                    if (this.Status.BackColor != statusTextBackColor)
                    {
                        this.Status.BackColor = statusTextBackColor;
                    }
                }

                {
                    string text = StringTools.Repeat("/", this.CondChangedCount);

                    if (this.SubStatus.Text != text)
                    {
                        this.SubStatus.Text = text;
                    }
                }

                if (0 < this.CondChangedCount)
                {
                    this.CondChangedCount--;
                }

                // ----
            }
            catch (Exception ex)
            {
                MessageDlgTools.Error(Program.APP_TITLE + " - Error @ Timer", ex);
            }
            finally
            {
                this.MTBusy.Leave();
                this.MTCount++;
            }
        }