예제 #1
0
 public void InitializeComponent() {
     if (_contentLoaded) {
         return;
     }
     _contentLoaded = true;
     System.Windows.Application.LoadComponent(this, new System.Uri("/4-StopWatch;component/MainPage.xaml", System.UriKind.Relative));
     this.CurrentLapTimeDisplay = ((_4_StopWatch.TimeSpanDisplay)(this.FindName("CurrentLapTimeDisplay")));
     this.TotalTimeDisplay = ((_4_StopWatch.TimeSpanDisplay)(this.FindName("TotalTimeDisplay")));
     this.LapProgressBar = ((System.Windows.Controls.ProgressBar)(this.FindName("LapProgressBar")));
     this.StartBtn = ((System.Windows.Controls.Button)(this.FindName("StartBtn")));
     this.StopBtn = ((System.Windows.Controls.Button)(this.FindName("StopBtn")));
     this.ResetBtn = ((System.Windows.Controls.Button)(this.FindName("ResetBtn")));
     this.LapBtn = ((System.Windows.Controls.Button)(this.FindName("LapBtn")));
     this.LapsStackPanel = ((System.Windows.Controls.StackPanel)(this.FindName("LapsStackPanel")));
 }
예제 #2
0
        void InsertLapInList(TimeSpan timeSpan)
        {
            int lapNumber = LapsStackPanel.Children.Count + 1;
            Grid grid = new Grid();
            grid.Children.Add(new TextBlock { Text="lap "+ lapNumber,
                Margin =new Thickness(24,0,0,0)});
            TimeSpanDisplay display = new TimeSpanDisplay
            {
                Time = timeSpan,
                DigitWidth = 18,
                HorizontalAlignment = HorizontalAlignment.Right,
                Margin = new Thickness(0, 0, 24, 0)
            };
                grid.Children.Add(display);

            LapsStackPanel.Children.Insert(0,grid);
        }