示例#1
0
        private void btnDelete_Click(object sender, RoutedEventArgs e)
        {
            TimerVM vm = (sender as MiniButton).Tag as TimerVM;

            arrTimer.RemoveAt(vm.Index);
            lstTimerVM.RemoveAt(vm.Index);
            for (int i = vm.Index; i < lstTimerVM.Count; ++i)
            {
                lstTimerVM[i].Index = i;
            }

            AutoSaveServer.ins.hasChanged = true;
        }
示例#2
0
        private void btnStop_Click(object sender, RoutedEventArgs e)
        {
            if (selectVM != null)
            {
                selectVM.IsSelect = false;
                selectVM          = null;
            }

            TimerServer.ins.stop();
            nowSecond = 0;
            updateTimerStatus();
            updateNowTime();
        }
示例#3
0
        private void initEditMode(TimerVM vm, EditTimeType type)
        {
            editVM                   = vm;
            editVM.IsEdit            = true;
            MainModel.ins.isEditTime = true;
            editType                 = type;
            switch (type)
            {
            case EditTimeType.Hour: oldValue = editVM.Hour; break;

            case EditTimeType.Minute: oldValue = editVM.Minute; break;

            case EditTimeType.Second: oldValue = editVM.Second; break;
            }
        }
示例#4
0
        private void grdTimeEditMask_MouseUp(object sender, MouseButtonEventArgs e)
        {
            if (editVM == null)
            {
                return;
            }

            if (e.ChangedButton != MouseButton.Right && e.ChangedButton != MouseButton.Left)
            {
                return;
            }

            if (e.ChangedButton == MouseButton.Right)
            {
                switch (editType)
                {
                case EditTimeType.Hour: editVM.Hour = oldValue; break;

                case EditTimeType.Minute: editVM.Minute = oldValue; break;

                case EditTimeType.Second: editVM.Second = oldValue; break;
                }
            }
            else if (e.ChangedButton == MouseButton.Left)
            {
                switch (editType)
                {
                case EditTimeType.Hour: editVM.md.hour = editVM.Hour; break;

                case EditTimeType.Minute: editVM.md.minute = editVM.Minute; break;

                case EditTimeType.Second: editVM.md.second = editVM.Second; break;
                }

                AutoSaveServer.ins.hasChanged = true;
            }

            editVM.IsEdit            = false;
            editVM                   = null;
            MainModel.ins.isEditTime = false;

            return;
        }
示例#5
0
        private void btnStart_Click(object sender, RoutedEventArgs e)
        {
            TimerVM vm = (sender as MiniButton).Tag as TimerVM;

            //nowSecond = vm.md.totalSecond;

            TimerServer.ins.restart(vm.md);

            nowSecond = TimeFormat.getTotalSecond(vm.md.hour, vm.md.minute, vm.md.second);

            if (selectVM != null)
            {
                selectVM.IsSelect = false;
            }
            selectVM          = vm;
            selectVM.IsSelect = true;

            updateNowTime();
            updateTimerStatus();
        }
示例#6
0
        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            TimerModel md = new TimerModel();
            TimerVM    vm = new TimerVM()
            {
                Index = lstTimerVM.Count,
                md    = md,
                IsNew = true,
            };

            foreach (var item in lstTimerVM)
            {
                item.IsNew = false;
            }

            arrTimer.Add(md);
            lstTimerVM.Add(vm);
            lstTimer.ScrollIntoView(lstTimerVM.Last());

            AutoSaveServer.ins.hasChanged = true;
        }
示例#7
0
        public TimerBox()
        {
            InitializeComponent();

            if (DesignerProperties.GetIsInDesignMode(this))
            {
                return;
            }

            grdSetting.Visibility = Visibility.Collapsed;
            txtMusic.Text         = MainModel.ins.cfgMd.timerMusicPath;
            sldVolume.Value       = getVolume();

            arrTimer = MainModel.ins.cfgMd.lstTimer;
            for (int i = 0; i < arrTimer.Count; ++i)
            {
                TimerVM vm = new TimerVM();
                vm.Index = i;
                vm.md    = arrTimer[i];
                //int totalSecond = TimeFormat.getTotalSecond(arrTimer[i].hour, arrTimer[i].minute, arrTimer[i].second);
                //vm.Time = formatTime(totalSecond);
                vm.Hour   = arrTimer[i].hour;
                vm.Minute = arrTimer[i].minute;
                vm.Second = arrTimer[i].second;
                lstTimerVM.Add(vm);
            }

            lstTimer.ItemsSource = lstTimerVM;

            TimerServer.ins.onTimerUpdated = (int _nowSecond, int _totalSecond) => {
                nowSecond = _nowSecond;
                Dispatcher.Invoke(updateNowTime);
            };

            TimerServer.ins.onTimerFinished = () => {
                nowSecond = 0;
                Dispatcher.Invoke(() => {
                    var win = MainModel.ins.detailWin;
                    win.show(DetailWinViewBox.Timer);

                    updateNowTime();
                    updateTimerStatus();
                });
            };

            TimerServer.ins.onPlayMusicFinished = () => {
                Dispatcher.Invoke(() => {
                    if (selectVM != null)
                    {
                        selectVM.IsSelect = false;
                        selectVM          = null;
                    }
                    updateTimerStatus();
                });
            };

            EventServer.ins.detailWinHideEvent += () => {
                showSettingBox(false);
            };

            updateTimerStatus();
            updateNowTime();
        }
示例#8
0
        private void lblSecond_Click(object sender, RoutedEventArgs e)
        {
            TimerVM vm = (sender as MiniButton).Tag as TimerVM;

            initEditMode(vm, EditTimeType.Second);
        }