//统一处理业务 private void ProgressChanged(object o, ProgressChangedEventArgs eventArgs) { try { //调试,查看时间 watchDate.Text = anchorDateTime.ToString("an: yyyy-MM-dd HH:mm:sss") + " - " + ctDateTime.ToString("yyyy-MM-dd HH:mm:sss"); //检测到网络畅通 if (new Ping().Send("119.29.29.29", 1000).Status != IPStatus.Success) { return; } var setTime = new SetTime(); var unixBeijingTime = setTime.GetUnixBeijingTime(); //增加对比时间点更新 setTime.SetTimeFunc(unixBeijingTime); if (setTime.ifTimeDiff()) { var BlazingsBingWallpaperFullPath = Path.Combine(Environment.CurrentDirectory, "BlazingsBingWallpaper.exe"); if (File.Exists(BlazingsBingWallpaperFullPath)) { System.Diagnostics.Process.Start(BlazingsBingWallpaperFullPath); } } } catch (Exception e) { } }
private void setTimeToolStripMenuItem_Click(object sender, EventArgs e) { SetTime setTimerForm = new SetTime(); setTimerForm.SetTimeChangeEvent += new EventHandler <SetTimerEventArgs>(this.SetTimeEvent); setTimerForm.Show(); }
/// <summary> /// 定时器设置 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void SetTime_Click(object sender, EventArgs e) { ComArgs.RoLog.WriteLog(LogStatus.LInfo, "准备更新定时器..."); SetTime settime = new SetTime(); settime.ShowDialog(); //执行完毕后,记录对应信息 SetTime.Text = ComArgs.SetTimer.IsRun ? @"定时运行(开启)" : @"定时运行(关闭)"; }
public void TotalMilliseconds_Nonsense() { string timeString = "9&2.5"; int milliseconds = SetTime.TotalMilliseconds(timeString); Assert.Equal(0, milliseconds); }
public void TotalMilliseconds_Nonsense_CorrectFormat() { //will not return 0 since time is in correct format. test will fail. string timeString = "1:1:36"; int milliseconds = SetTime.TotalMilliseconds(timeString); Assert.Equal(0, milliseconds); }
public void TotalMilliseconds_Seconds() { //arrange string timeString = "0:0:1"; //act int milliseconds = SetTime.TotalMilliseconds(timeString); //assert Assert.Equal(1000, milliseconds); }
public void TotalMilliseconds_SecondsIncorrect() { //incorrect answer, test will fail. //arrange string timeString = "0:0:1"; //act int milliseconds = SetTime.TotalMilliseconds(timeString); //assert Assert.Equal(1005, milliseconds); }
public void TotalMilliseconds_MinutesIncorrect() { //incorrect answer. test will fail. //arrange string timeString = "0:1"; //act int milliseconds = SetTime.TotalMilliseconds(timeString); //incorrect answer vs method answer //assert Assert.Equal(60019, milliseconds); }
public void TotalMilliseconds_Hours() { //create initial string of hours to plug into program to test //arrange string timeString = "1"; //put into method //act int milliseconds = SetTime.TotalMilliseconds(timeString); //correct answer versus method answer. //assert Assert.Equal(3600000, milliseconds); }
protected virtual void LogBoostUsed(ITimeBoost boost) { var log = new StringBuilder(); log.AppendLine(); log.AppendLine("UI: '{0}' : '{1}' : '{2}'", Title, SubTitle, SummaryText); log.AppendLine("User: {0}", User); log.AppendLine("Boost: {0}", boost); log.AppendLine("Get: {0}", GetTime.Trace(false)); log.AppendLine("Set: {0}", SetTime.Trace(false)); log.AppendLine("Time: {0} > {1}", OldTime, Time); log.AppendLine(); log.Log("/TimeBoosts/" + DateTime.Now.ToDirectoryName() + "/" + boost + ".log"); }
double xl, ym, zn; //地平直行座標 void Start() { // 軌道要素 // Dictionary <string, double> a_dictionary = new Dictionary <string, double>() { { "Mercury", 0.38710 }, { "Venus", 0.72333 }, { "Mars", 1.52368 }, { "Jupiter", 5.20260 }, { "Saturn", 9.55491 } };//軌道長半径[au] Dictionary <string, double> t0_dictionary = new Dictionary <string, double>() { { "Mercury", 2455284.96736 }, { "Venus", 2454884.30555556 }, { "Mars", 2454942.90694 }, { "Jupiter", 2455638.20833333 }, { "Saturn", 2463566.125 } };//近日点通過時刻[day](土星だけ調べられてない) Dictionary <string, double> e_dictionary = new Dictionary <string, double>() { { "Mercury", 0.20564 }, { "Venus", 0.00676 }, { "Mars", 0.09342 }, { "Jupiter", 0.04853 }, { "Saturn", 0.05549 } };//離心率 Dictionary <string, double> omega_dictionary = new Dictionary <string, double>() { { "Mercury", 77.7518 }, { "Venus", 131.8301 }, { "Mars", 336.4100 }, { "Jupiter", 14.6376 }, { "Saturn", 93.4304 } };//近日点黄経[deg] Dictionary <string, double> Omega_dictionary = new Dictionary <string, double>() { { "Mercury", 48.5563 }, { "Venus", 76.8511 }, { "Mars", 49.7048 }, { "Jupiter", 100.6584 }, { "Saturn", 113.8321 } };//昇交点黄経[deg] Dictionary <string, double> i_dictionary = new Dictionary <string, double>() { { "Mercury", 7.0053 }, { "Venus", 3.3949 }, { "Mars", 1.8496 }, { "Jupiter", 1.3022 }, { "Saturn", 2.4882 } };//軌道傾斜角[deg] Dictionary <string, double> T_dictionary = new Dictionary <string, double>() { { "Mercury", 0.240852 }, { "Venus", 0.615207 }, { "Mars", 1.880866 }, { "Jupiter", 11.86155 }, { "Saturn", 29.53216 } };//公転周期[year] planetname = transform.name; a = a_dictionary[planetname]; //惑星の軌道長半径[au] t0 = t0_dictionary[planetname]; //惑星の近日点通過時刻[day] e = e_dictionary[transform.name]; //惑星の離心率[-] omega = (Math.PI / 180.0) * (omega_dictionary[planetname] - Omega_dictionary[planetname]); //惑星の近日点引数[rad] Omega = (Math.PI / 180.0) * Omega_dictionary[planetname]; //惑星の昇交点経度[rad] i = (Math.PI / 180.0) * i_dictionary[planetname]; //惑星の軌道傾斜角[rad] T = 365.25 * T_dictionary[planetname]; //惑星の公転周期[day] n = 2 * Math.PI / T; //[/day] settime = GameObject.Find("TimeManager").GetComponent <SetTime>(); earth = GameObject.Find("EarthOrbit").GetComponent <EarthOrbital>(); sun = GameObject.Find("Sun").GetComponent <SunOrbital>(); }
private void Addbtn_Click(object sender, EventArgs e) { string name = txtName.Text.Trim(); string time = txtTime.Text.Trim(); if (string.IsNullOrEmpty(name) || string.IsNullOrEmpty(time)) { MessageBox.Show("请填写完整影片名称与放映时长", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } time = time.Contains(":") ? time.Replace(":", ":") : time; List <SetTime> list = new List <SetTime>((BindingList <SetTime>) this.dataGridView2.DataSource); //判断当前加入的电影是否已在列表中 SetTime s = list?.Find(x => x.MovieName == name); if (s != null) { //如果在,则提示用户是否覆盖 DialogResult re = MessageBox.Show("您即将添加的电影" + Environment.NewLine + "《" + name + "》\r\n已在列表中,请问要覆盖吗?", "已存在", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (re == DialogResult.OK) { //用户要覆盖,则将其本身存在去除掉 int index = blist.IndexOf(s); s.MovieTime = time; blist.Remove(s); blist.Insert(index, s); } else { return; } } else { //不存在,则添加 blist.Add(new SetTime() { MovieName = name, MovieTime = time }); } SaveJson(new List <SetTime>(blist)); txtName.Focus(); }
private void DelRow(int rowIndex) { List <SetTime> list = new List <SetTime>((BindingList <SetTime>) this.dataGridView2.DataSource); //找到当前的影片 SetTime movie = dataGridView2.Rows[rowIndex].DataBoundItem as SetTime; if (movie != null) { //如果在,则提示用户是否覆盖 DialogResult re = MessageBox.Show($"你确定要删除{Environment.NewLine + movie.MovieName + Environment.NewLine}吗,数据删除后不可恢复", "警告", MessageBoxButtons.OKCancel); if (re == DialogResult.OK) { blist.Remove(movie); } else { return; } } }
private void btn2_SetTime_Click(object sender, EventArgs e) { if (GloablInfo.curDevInfo != null) { SetTime st = new SetTime(); st.command = SmartDeviceInterface.COM_SET_TIME_JS_; st.data = new TimeString[1]; st.data[0] = new TimeString(); st.data[0].time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); string strSend = JsonConvert.SerializeObject(st); int iResponseLen = SmartDeviceInterface.MAX_DATA_LENGTH; GloablInfo.UpdateMsg("发送数据:" + strSend); string strJsonResponse = ""; IntPtr szResponse = Marshal.AllocHGlobal(iResponseLen); int iResult = SmartDeviceInterface.SmartDevice_Common(GloablInfo.curDevInfo.deviceID, SmartDeviceInterface.COM_SET_TIME_JS, strSend, strSend.Length, szResponse, ref iResponseLen); if (iResponseLen > 0) { byte[] byteJsonResponse = new byte[iResponseLen]; Marshal.Copy(szResponse, byteJsonResponse, 0, iResponseLen); strJsonResponse = System.Text.UTF8Encoding.Default.GetString(byteJsonResponse); } if (iResult == SmartDeviceInterface.OPERATOR_SUCCESS) { } txtSystemMgr.Text += GloablInfo.GetResultDescription(iResult); Marshal.FreeHGlobal(szResponse); GloablInfo.UpdateMsg("接收数据:" + strJsonResponse); } else { txtSystemMgr.Text += "请选择设备\r\n"; } }
public override int GetHashCode() { int hash = 1; if (UserId != 0) { hash ^= UserId.GetHashCode(); } if (ClockId != 0) { hash ^= ClockId.GetHashCode(); } if (Hour != 0) { hash ^= Hour.GetHashCode(); } if (Minute != 0) { hash ^= Minute.GetHashCode(); } if (LabelId != 0) { hash ^= LabelId.GetHashCode(); } if (SetTime != 0L) { hash ^= SetTime.GetHashCode(); } if (OpenState != 0) { hash ^= OpenState.GetHashCode(); } if (TipState != 0) { hash ^= TipState.GetHashCode(); } return(hash); }
void _timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { derp = new SetTime(settime); maindispatcher.Invoke(derp); }
public void GetUnixBeijingTimeTest() { var setTime = new SetTime(); var unixBeijingTime = setTime.GetUnixBeijingTime(); }
public void SetTimeFuncTest() { var setTime = new SetTime(); setTime.SetTimeFunc(1564033137); }
void _timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { derp = new SetTime(settime); maindispatcher.Invoke(derp); }
protected virtual void OnSetTime(DateTime e) { SetTime?.Invoke(this, e); }