Exemplo n.º 1
0
        private void MediaPlayer_LengthChanged(object sender, Vlc.DotNet.Core.VlcMediaPlayerLengthChangedEventArgs e)
        {
            Dispatcher.Invoke((Action) delegate
            {
                if (e.NewLength != 0)
                {
                    Times.Minimum = 0;
                    Times.Maximum = control.SourceProvider.MediaPlayer.Length;
                    TimeAll.Text  = new TimeSpan(e.NewLength * 10000).ToString(@"hh\:mm\:ss");


                    Binding binding = new Binding();

                    binding.Source = control.SourceProvider;               // элемент-источник
                    binding.Mode   = BindingMode.OneWay;                   // элемент-источник
                    binding.Path   = new PropertyPath("MediaPlayer.Time"); // свойство элемента-источника

                    TimeLast.SetBinding(TextBlock.TextProperty, binding);  // установка привязки для элемента-приемника
                }
            });
        }
Exemplo n.º 2
0
        private void Caculatetime()
        {
            string timedata;

            if (File.Exists(path + "\\userdata\\time.txt"))
            {
                timedata = File.ReadAllText(path + "\\userdata\\time.txt");
                int times = Int32.Parse(timedata);
                if (times / 20000000 == 0)
                {
                    TimeLast.Text = ""; TimeLast.Refresh();
                    MessageBox.Show("毕业时间信息格式不正确,请前往基本设置进行检查。\n请按格式设置完毕后重启软件,目前暂不可用。");
                    return;
                }
                int      years  = times / 10000;
                int      months = (times % 10000) / 100;
                int      days   = times % 100;
                DateTime nows   = DateTime.Now;
                DateTime cru    = new DateTime(years, months, days, 23, 59, 59);
                if (nows >= cru)
                {
                    TimeLast.Text = ""; TimeLast.Refresh();
                    MessageBox.Show("毕业了!");
                    return;
                }
                TimeSpan daysa = cru - nows;
                TimeLast.Text = daysa.Days.ToString("D3"); TimeLast.Refresh();
            }
            else
            {
                TimeLast.Text = ""; TimeLast.Refresh();
                File.Create(path + "\\userdata\\time.txt").Close();
                File.WriteAllText(path + "\\userdata\\time.txt", "00000000");
                MessageBox.Show("毕业时间信息缺失,请前往基本设置进行设置。\n请按格式设置完毕后重启软件,目前暂不可用。");
            }
        }