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 UIEvent_Go(Action routine)
 {
     using (this.MTBusy.Section())
     {
         try
         {
             routine();
         }
         catch (Exception e)
         {
             MessageDlgTools.Error("Error @ UIEvent_Go()", e);
         }
     }
 }
Exemple #5
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 #6
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 #7
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 #8
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 #9
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 #10
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 #11
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 #12
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++;
            }
        }