private void MChart_MouseMove(object sender, MouseEventArgs e) { int x = e.X; int y = e.Y; if (this.MCMM_LastX == x && this.MCMM_LastY == y) { return; } this.MCMM_LastX = x; this.MCMM_LastY = y; try { double aX = this.MChart.ChartAreas[0].AxisX.PixelPositionToValue(x); double aY = this.MChart.ChartAreas[0].AxisY.PixelPositionToValue(y); long sec = this.LastStartWeSec + LongTools.toInt(aX * 86400.0); sec = WeSec.WeSecToSec(sec); long dateTime = DateTimeToSec.toDateTime(sec); this.TTip.SetToolTip( this.MChart, Utils.DateTimeToString(dateTime) + "\n" + aY ); } catch { } }
private static void CheckHz() { long currTime = DDUtils.GetCurrTime(); HzChaserTime += 16L; // 16.666 == 60Hz HzChaserTime = LongTools.ToRange(HzChaserTime, currTime - 100L, currTime + 100L); while (currTime < HzChaserTime) { Thread.Sleep(1); currTime = DDUtils.GetCurrTime(); } FrameStartTime = currTime; }
public static HistoryData[] getHistories() { List <HistoryData> dest = new List <HistoryData>(); foreach (string dir in FileTools.lsDirs(Gnd.i.historyDir)) { dest.Add(new HistoryData(dir)); } // 新しい -> 古い ArrayTools.sort <HistoryData>(dest, delegate(HistoryData a, HistoryData b) { return(LongTools.comp(a.getStamp(), b.getStamp()) * -1); }); return(dest.ToArray()); }
private static void DeleteDeadData() { FileData[] files = Directory.GetFiles(Consts.DATA_DIR).Select(v => new FileData() { File = v, WroteDateTime = DateTimeToSec.ToDateTime(new FileInfo(v).LastWriteTime), }) .ToArray(); Array.Sort(files, (a, b) => { int ret = LongTools.Comp(a.WroteDateTime, b.WroteDateTime); if (ret != 0) { return(ret); } ret = StringTools.CompIgnoreCase(a.File, b.File); return(ret); }); long currDateTime = DateTimeToSec.Now.GetDateTime(); long expireDateTime = DateTimeToSec.ToDateTime(DateTimeToSec.ToSec(currDateTime) - Consts.DATA_LIFESPAN_SEC); for (int index = 0; index < files.Length; index++) { bool deleting = index + Consts.DATA_NUM_MAX < files.Length || files[index].WroteDateTime < expireDateTime; if (deleting == false) { break; } FileTools.Delete(files[index].File); } }
private int Comp_CSPrice(CSPrice a, CSPrice b) { return(LongTools.Comp(a.DateTime, b.DateTime)); }
private static void ConvImageJpeg(string rFile, string wFile, string midPathBase) { int w; int h; try // 画像読み込みテスト { using (Bitmap.FromFile(rFile)) { } } catch (Exception e) { ProcMain.WriteLog(e); throw new Exception("画像ファイル読み込みエラー"); } using (Image bmp = Bitmap.FromFile(rFile)) { w = bmp.Width; h = bmp.Height; bmp.Save(midPathBase + "1.bmp", ImageFormat.Bmp); // 透過を無効にしたいだけ、、、 } ProcMain.WriteLog("w: " + w); ProcMain.WriteLog("h: " + h); if (w < 1 || IntTools.IMAX < w) { throw new Exception("画像ファイルの幅に問題があります。"); } if (h < 1 || IntTools.IMAX < h) { throw new Exception("画像ファイルの高さに問題があります。"); } if (Ground.I.画像を二重に表示) { int mon_w = Ground.I.画像を二重に表示_MonitorW; int mon_h = Ground.I.画像を二重に表示_MonitorH; // 高さと幅はそれぞれ偶数でなければならない。 mon_w &= ~1; mon_h &= ~1; int ww = mon_w; int hh; { long t = h; t *= mon_w; t /= w; if (mon_h <= t) { hh = (int)t; } else { hh = mon_h; t = w; t *= mon_h; t /= h; ww = (int)t; } } string aa; if (Ground.I.画像を二重に表示_明るさ == 100) { aa = ""; } else { aa = ":" + Ground.I.画像を二重に表示_明るさ.ToString("D2"); } int ll = (ww - mon_w) / 2; int tt = (hh - mon_h) / 2; Run("ImgTools.exe /rf " + midPathBase + "1.bmp /wf " + midPathBase + "1w.png /e " + ww + " " + hh + " /C " + ll + " " + tt + " " + mon_w + " " + mon_h + " /BOKASHI 0 0 " + mon_w + " " + mon_h + " " + Ground.I.画像を二重に表示_ぼかし + " 1 " + " /DOTFLTR A R" + aa + " G" + aa + " B" + aa ); if (File.Exists(midPathBase + "1w.png") == false) { throw new Exception("画像処理エラー(1w)"); } ww = mon_w; { long t = h; t *= mon_w; t /= w; if (t <= mon_h) { hh = (int)t; } else { hh = mon_h; t = w; t *= mon_h; t /= h; ww = (int)t; } } Run("ImgTools.exe /rf " + midPathBase + "1.bmp /wf " + midPathBase + "1f.png /e " + ww + " " + hh); if (File.Exists(midPathBase + "1f.png") == false) { throw new Exception("画像処理エラー(1f)"); } ll = (mon_w - ww) / 2; tt = (mon_h - hh) / 2; Run("ImgTools.exe /rf " + midPathBase + "1w.png /wf " + midPathBase + "2.png /2 " + midPathBase + "1f.png /PASTE " + ll + " " + tt); } else { int ww = IntTools.ToRange(w, Consts.IMAGE_WH_MIN, Consts.IMAGE_WH_MAX); int hh; { long t = h; t *= ww; t /= w; if (Consts.IMAGE_WH_MIN <= t && t <= Consts.IMAGE_WH_MAX) { hh = (int)t; } else { hh = IntTools.ToRange(h, Consts.IMAGE_WH_MIN, Consts.IMAGE_WH_MAX); t = w; t *= hh; t /= h; t = LongTools.ToRange(t, Consts.IMAGE_WH_MIN, Consts.IMAGE_WH_MAX); ww = (int)t; } } ProcMain.WriteLog("ww.1: " + ww); ProcMain.WriteLog("hh.1: " + hh); // 高さと幅はそれぞれ偶数でなければならない。 ww &= ~1; hh &= ~1; ProcMain.WriteLog("ww.2: " + ww); ProcMain.WriteLog("hh.2: " + hh); Run("ImgTools.exe /rf " + midPathBase + "1.bmp /wf " + midPathBase + "2.png /e " + ww + " " + hh); } if (File.Exists(midPathBase + "2.png") == false) { throw new Exception("画像処理エラー(ImgTools)"); } Run("BmpToCsv.exe /J " + Ground.I.JpegQuality + " " + midPathBase + "2.png " + midPathBase + "3.jpg"); if (File.Exists(midPathBase + "3.jpg") == false) { throw new Exception("画像処理エラー(BmpToCsv)"); } File.Move(midPathBase + "3.jpg", wFile); }
public void Perform() { Console.WriteLine("Slimdown_Start"); //Console.WriteLine("Slimdown_Start, DY: " + this.DiskYellowFlag); // del @ 2020.4.1 long currDateTime = DateTimeToSec.Now.GetDateTime(); foreach (LiteGroup liteGroup in new GroupBundle().LiteGroups) { Group group = liteGroup.GetGroup(); List <UploadedFile> upFiles = new List <UploadedFile>(); long total = 0L; foreach (string file in group.GetFileBundle().Files) { FileInfo info = new FileInfo(file); UploadedFile upFile = new UploadedFile() { FilePath = file, Size = info.Length, WroteDateTime = DateTimeToSec.ToDateTime(info.LastWriteTime), }; upFiles.Add(upFile); total += upFile.Size; } upFiles.Sort((a, b) => { int ret = VariantTools.Comp(a, b, v => StringTools.EndsWithIgnoreCase(v.FilePath, Consts.TMP_FILE_SUFFIX) && DateTimeToSec.ToSec(v.WroteDateTime) + 3600 <= DateTimeToSec.ToSec(currDateTime) ? 0 : 1); // "1時間以上放置された作業ファイル" を先に if (ret != 0) { return(ret); } ret = LongTools.Comp(a.WroteDateTime, b.WroteDateTime); // 古い順 return(ret); }); while (1 <= upFiles.Count && (Consts.FILE_NUM_MAX < this.UploadedFiles.Count || group.GroupTotalFileSizeMax < total)) { UploadedFile upFile = upFiles[0]; upFiles.RemoveAt(0); upFile.Delete(); total -= upFile.Size; } this.UploadedFiles.AddRange(upFiles); this.TotalSize += total; } this.UploadedFiles.Sort((a, b) => LongTools.Comp(a.WroteDateTime, b.WroteDateTime)); // 古い順 while (1 <= this.UploadedFiles.Count && Consts.TOTAL_FILE_SIZE_MAX < this.TotalSize) { UploadedFile upFile = this.UploadedFiles[0]; this.UploadedFiles.RemoveAt(0); FileTools.Delete(upFile.FilePath); this.TotalSize -= upFile.Size; } #if false // del @ 2020.4.1 if (this.DiskYellowFlag) { int count = this.UploadedFiles.Count; // 10ファイル以上 -> 10% // 1~9ファイル -> 1 // 0ファイル -> 0 // if (10 <= count) { count /= 10; } else { count = Math.Min(1, count); } for (int index = 0; index < count; index++) { UploadedFile upFile = this.UploadedFiles[index]; upFile.Delete(); } } #endif Console.WriteLine("Slimdown_End"); }
public static int Comp(RawPrice a, RawPrice b) { return(LongTools.comp(a.DateTime, b.DateTime)); }