public void testAddingTwoSeconds() { MyTime time = new MyTime(0, 0, 1); time.AddSeconds(2); Assert.True(time == new MyTime(0, 0, 3)); }
public string GetTime(int id) { Console.WriteLine("Запрошена информация по Самолету " + id.ToString()); string txt = ""; MyTime MT = MyTime.GetMyTime(); foreach (var r in MT.reises) { if (r.plain != null) { if (r.plain == id) { if (r.registrtionTime != null) { Console.WriteLine("Самолет " + id.ToString() + " будет лететь " + (r.timeStop - r.timeStart).ToString() + " минут"); txt = (r.timeStop - r.timeStart).ToString() + ";" + r.reisNumber.ToString(); return(txt); } else { Console.WriteLine("Самолет " + id.ToString() + " прилетает. Еду везти не надо."); txt = "-1;" + r.reisNumber.ToString(); return(txt); } } } } Console.WriteLine("Самолета " + id.ToString() + " несуществует."); txt = "0;0"; return(txt); }
static void Main(string[] args) { MyTime mt = new MyTime(12897312); Person p = new Person(20, 1.8f, "1827817263"); Console.WriteLine(p); Console.WriteLine(p.GetId()); // watch only. cannot modify the id from outside the class code p.GoToMisradHapnim(); // encapsulation // access modifiers // properties // 1) maybe the age should be validated before modification? // 2) maybe i dont want the age to be modified from outside the class code // maybe i want to all view only //p.m_age = -2; // private p.SetAge(-2); p.SetAge(20); Console.WriteLine(p.GetAge()); // maybe i dont want access to this data at all ... ? //Console.WriteLine(p.atm_secret_code); // private member cannot be accessed from outside the class code AT ALL!!!! }
[TestMethod] //Нормализация (247 часов, 324 минуты, 5654 секунды переведёт в 10 дней 13:58:14) public void convertToDays() { MyTime exp = new MyTime(0, 247, 324, 5654); MyTime act = new MyTime(10, 13, 58, 14); Assert.AreEqual(exp.ConvertTo_Ds(), act); }
private void OpenMyLayerWinCommandClick() { var dd = new Demo1(); dd.Width = 500; dd.Height = 300; var vm = new Demo1ViewModel(); //设置20秒后关闭弹出窗体 MyTime.SetTimeout(10000, () => { ClosePopup.Request(); }); MyLayerServices.ShowDialog("Demo1", dd, vm, OnDialogCloseCallBack, new MyLayerOptions() { MaskBrush = SolidColorBrushConverter.From16JinZhi("#4F000000"), CanDrag = IsCandrag, HasShadow = HasShadow, AnimationType = SelectedAnimationType.Key }, delegate//窗体呈现完毕后执行的委托方法 { vm.Load(); }, ClosePopup//后台要关闭弹出窗口,只需要执行此InteractionRequest的Request()方法 ); }
[TestMethod] //Конвертация в строку public void ToString_test() { MyTime exp = new MyTime(4, 3, 2, 1); string act = "4d 3:2:1"; Assert.AreEqual(exp.ToString(), act); }
[TestMethod] //Конструктор по умолчанию public void Constructor_Default() { MyTime exp = new MyTime(0, 0, 0, 0); MyTime act = new MyTime(); Assert.AreEqual(exp, act); }
public Message(string senderId, string messageInfo, MessageType type) { SenderId = senderId; MessageInfo = messageInfo; Type = type; Time = new MyTime(DateTime.Now); }
public ReadyState(bool isPlayerControlled, MyTime time, Character mon) { this.finished = false; this.isPlayerControlled = isPlayerControlled; this.time = time; this.mon = mon; }
private void tmrAutoGenerateResult_Tick(object sender, EventArgs e) { DateTime dt = DateTime.Now; MyTime mt = AppSettings.CurrentSetting.AutoGenerateTime; if (mt != null && mt.Hour == dt.Hour && mt.Minute == dt.Minute) { if (!_HasGenerateResult) { _HasGenerateResult = true; List <string> readers = GetAttendanceReaders(); if (readers == null || readers.Count == 0) { MessageBox.Show("还未指定考勤点"); return; } LJH.GeneralLibrary.LOG.FileLog.Log("自动生成考勤结果", "开始生成考勤结果......"); DatetimeRange dr = new DatetimeRange(dt.Date.AddDays(-1), dt.Date.AddSeconds(-1)); //前一天的时间范围 List <Staff> staffs = (new StaffBLL(AppSettings.CurrentSetting.ConnectUri)).GetItems(null).QueryObjects; CreateAttendanceResults(staffs, dr, readers); } } else { _HasGenerateResult = false; } }
public void testAddingSecondsWhenHoursOverlapsDays() { MyTime time = new MyTime(23, 59, 59); time.AddSeconds(3); Assert.True(time == new MyTime(0, 0, 2)); }
public void testAddingSecondWhenMinutesOverlapsHours() { MyTime time = new MyTime(0, 59, 58); time.AddSeconds(2); Assert.True(time == new MyTime(1, 0, 0)); }
[TestMethod] //Конструктор с параметрами и свойства public void ConstructorParam_Properties() { MyTime exp = new MyTime(1, 2, 3, 4); MyTime act = new MyTime(); act.Days = 1; act.Hours = 2; act.Minutes = 3; act.Seconds = 4; Assert.AreEqual(exp, act); }
public void Load() { MyTime.SetInterval(5000, () => { CeshiText += 5000; OnPropertyChanged("CeshiText"); }); }
void Awake() { MyTime.MarkAsUnstable(); CompileDictionaries(); MyTime.MarkAsStable(); }
[TestMethod] //Разница 1 day 02:03:04 + 4 day 03:02:01 = 3 day 00:58:57 public void Sub_test() { MyTime s1 = new MyTime(1, 2, 3, 4); MyTime s2 = new MyTime(4, 3, 2, 1); MyTime s3 = s1 - s2; MyTime act = new MyTime(3, 0, 58, 57); Assert.AreEqual(s3.ConvertTo_Ds(), act); }
[TestMethod] //Сумма 1 day 23:59:59 + 6 sec = 2 day 00:00:05 public void Sum_test() { MyTime s1 = new MyTime(1, 23, 59, 59); MyTime s2 = new MyTime(0, 0, 0, 6); MyTime s3 = s1 + s2; MyTime act = new MyTime(2, 0, 0, 5); Assert.AreEqual(s3.ConvertTo_Ds(), act); }
public void testAddingSecondWhenSecondsOverlapsMinutes() { MyTime time = new MyTime(0, 0, 59); time.AddSeconds(1); Assert.True(time == new MyTime(0, 1, 0)); time.AddSeconds(10); Assert.True(time == new MyTime(0, 1, 10)); }
[TestMethod] //Сравнивает 1 день и 100 000 секунд (100 000 секунд = 1d 03:46:40) public void A_less_B() { MyTime t1 = new MyTime(0, 1, 0, 0); MyTime t2 = new MyTime(0, 0, 0, 100000); bool act = (t1 < t2); bool exp = true; Assert.AreEqual(exp, act); }
public Post(string postId, Post post) { PostId = postId; SenderId = post.SenderId; Title = post.Title; Body = post.Body; Time = new MyTime(DateTime.Now); LikerIdList = new List <string>(); CommentList = new CommentList(); DisableList = new List <string>(post.DisableList); }
public void Awake() { if (instance == null) { instance = this; } else { Destroy(this.gameObject); } }
public AttackingState(Controller controller, Vector2 enemyPosition, MyTime time) { this.controller = controller; this.finished = false; this.time = time; this.moveStart = this.controller.transform.position; this.moveTarget = this.controller.transform.position; this.moveStopRange = 0.5f; }
[TestMethod] // вызывается ли исключение, при попытке задать отрицательные значения public void Constructor_NegativeException() { try // попытка вызвать исключение { MyTime t = new MyTime(0, 0, -1, 0); // исключение должно вызваться здесь и дальше код не пойдёт Assert.Fail(); // если исключение не вызвалось, то тест провален } catch (MyTimeException) //если вызвалось, то тест пройден { } }
public Demo1ViewModel() { ClockText = 10; MyTime.SetInterval(1000, () => { if (ClockText > 0) { ClockText -= 1; OnPropertyChanged("ClockText"); } }); }
// handles a skill press private void handleSkillPress(string pressedSkill) { if (pressedSkill == "") { return; } long elapsedTime = MyTime.ElapsedTime(previousTime); previousTime = MyTime.CurrentTimeMillis(); if (elapsedTime > MaxPauseDuration) { pressedSkills.Clear(); } pressedSkills.Add(new SkillPress(pressedSkill, elapsedTime)); GameObject[] enemies = GameObject.FindGameObjectsWithTag("Enemy"); GameObject[] spotlights = GameObject.FindGameObjectsWithTag("Spotlight"); GameObject[] triggerables = new GameObject[enemies.Length + spotlights.Length]; Array.Copy(enemies, triggerables, enemies.Length); Array.Copy(spotlights, 0, triggerables, enemies.Length, spotlights.Length); foreach (GameObject obj in triggerables) { Vector2 playerPosition = new Vector2(Player.transform.position.x, Player.transform.position.z); Vector2 melodyPosition = new Vector2(obj.transform.position.x, obj.transform.position.z); double dist = Vector2.Distance(playerPosition, melodyPosition); if ((dist <= Radius && obj.tag != "Spotlight") || (obj.tag == "Spotlight" && obj.GetComponent <Spotlight>().hasPlayer)) { Melody objMelody = obj.GetComponent <Melody>(); objMelody.Wait(); if (checkMelody(objMelody.rythem) && objMelody.IsValid()) { if (obj.tag == "Enemy") { obj.transform.parent.gameObject.GetComponent <KillEnemy>().setEnemyDead(true); } else if (obj.tag == "Spotlight") { GameObject movBlock = obj.GetComponent <Spotlight>().movingBlock; movBlock.GetComponent <AscendingObject>().Trigger(); } } } } }
private void SystemOptions_Load(object sender, EventArgs e) { this.btnOk.Enabled = Operator.CurrentOperator.Permit(Permission.EditOptions); this.chkAutoCreate.Checked = AppSettings.CurrentSetting.AutoGenerateResult; MyTime mt = AppSettings.CurrentSetting.AutoGenerateTime; if (mt != null) { dtAutoGenerateResultTime.Value = new DateTime(2011, 1, 1, mt.Hour, mt.Minute, mt.Second); } this.chkAutoGetAttendanceLog.Checked = AppSettings.CurrentSetting.AutoGetAttendanceLog; }
/// <summary> /// 播放、暂停 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnPlayPause_Click(object sender, EventArgs e) { if (mySong.CurrentState != State.Playing) { MyTime.Start(); mySong.Play(); } else { MyTime.Stop(); mySong.Puase(); } }
//private void _DataGridView1DataError(object sender, DataGridViewDataErrorEventArgs e) //{ // dataGridView1.Refresh(); //} //private void _DataGridView1DataBindingComplete(object sender, DataGridViewBindingCompleteEventArgs e) //{ // Cursor.Current = Cursors.Default; // if (_positionForm != null) // _positionForm.UpdateGrid(_fillTable.Table); // dataGridView1.Refresh(); //} //private void _DataGridView1BindingContextChanged(object sender, EventArgs e) //{ // if (dataGridView1.DataSource == null) return; // foreach (DataGridViewColumn col in dataGridView1.Columns) // { // col.HeaderCell = new // DataGridViewAutoFilterColumnHeaderCell(col.HeaderCell); // } // dataGridView1.AutoResizeColumns(); // dataGridView1.Refresh(); //} //private void _DataGridView1KeyDown(object sender, KeyEventArgs e) //{ // if (e.Alt && (e.KeyCode == Keys.Down || e.KeyCode == Keys.Up)) // { // var filterCell = // dataGridView1.CurrentCell.OwningColumn.HeaderCell as // DataGridViewAutoFilterColumnHeaderCell; // if (filterCell != null) // { // filterCell.ShowDropDownList(); // e.Handled = true; // } // } //} private void _GatInterfaceShown(object sender, EventArgs e) { dateTimePicker1.Value = MyTime.GetLastTradingDay(); if (_fillTable == null) { _fillTable = new BindableDataTable(DbHandle.Instance.GetFills(ct_sourceName, dateTimePicker1.Value.ToString("yyyy-MM-dd"))); //fillTable.AddConstraints(new string[] {"OrderId", "ClOrdId", "ExecId"}); } //dataGridView1.DataSource = _fillTable.Binding; dxGrid1.DataSource = _fillTable.Binding; }
public static MyTime parseTime(String text) { String[] texts = text.Split(new String[] { ":" }, StringSplitOptions.RemoveEmptyEntries); if (texts.Length != 3) { return(null); } MyTime result = new MyTime(); result.hour = int.Parse(texts[0]); result.minute = int.Parse(texts[1]); result.second = int.Parse(texts[2]); return(result); }
private static string _FormatTimeStamp(string fixDateString) { string[] datePieces = fixDateString.Split(new[] { ' ', '-' }); TimeSpan easternTime = MyTime.GetEasternTime(datePieces[1], MyTime.TimeFormat.HHMMSSMMM_COLON); string outputTimeString = string.Format("{0}-{1}-{2} {3}", datePieces[0].Substring(0, 4), datePieces[0].Substring(4, 2), datePieces[0].Substring(6), string.Format("{0}:{1}:{2}.{3}", easternTime.Hours.ToString("00"), easternTime.Minutes.ToString("00"), easternTime.Seconds.ToString("00"), easternTime.Milliseconds.ToString("000"))); return(outputTimeString); }