示例#1
0
        /// <summary>
        /// Checks if the scenario details need saving or not
        /// </summary>
        /// <returns></returns>
        public bool NeedSave()
        {
            BindingExpression be = TitleTextBox.GetBindingExpression(TextBox.TextProperty);

            if (be != null && be.IsDirty)
            {
                return(true);
            }
            be = AuthorTextbox.GetBindingExpression(TextBox.TextProperty);
            if (be != null && be.IsDirty)
            {
                return(true);
            }
            be = DescriptionTextBox.GetBindingExpression(TextBox.TextProperty);
            if (be != null && be.IsDirty)
            {
                return(true);
            }
            be = CreateDatePicker.GetBindingExpression(DatePicker.SelectedDateProperty);
            if (be != null && be.IsDirty)
            {
                return(true);
            }
            be = RatingTextBox.GetBindingExpression(TextBox.TextProperty);
            if (be != null && be.IsDirty)
            {
                return(true);
            }
            return(false);
        }
示例#2
0
        /// <summary>
        /// Updates the changes in the scenario values into the datamodel. Occurs when the save button is clicked
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void SaveDataButton_OnClickDataButton_Click(object sender, RoutedEventArgs e)
        {
            BindingExpression be = TitleTextBox.GetBindingExpression(TextBox.TextProperty);

            if (be != null)
            {
                be.UpdateSource();
            }
            be = AuthorTextbox.GetBindingExpression(TextBox.TextProperty);
            if (be != null)
            {
                be.UpdateSource();
            }
            be = DescriptionTextBox.GetBindingExpression(TextBox.TextProperty);
            if (be != null)
            {
                be.UpdateSource();
            }
            be = CreateDatePicker.GetBindingExpression(DatePicker.SelectedDateProperty);
            if (be != null)
            {
                be.UpdateSource();
            }
            be = RatingTextBox.GetBindingExpression(TextBox.TextProperty);
            if (be != null)
            {
                be.UpdateSource();
            }
            WorkbookModel workbook = new WorkbookModel(Globals.ThisAddIn.Application.ActiveWorkbook);

            workbook.ShouldScanAfterSave = false;
            Globals.ThisAddIn.Application.ActiveWorkbook.Save();
            workbook.ShouldScanAfterSave = true;
        }
示例#3
0
        /// <summary>
        /// Updates the Targets of every field. This is done when changes get discarded. So the values get overridden with the values in the source of the binding
        /// </summary>
        private void UpdateTargets()
        {
            BindingExpression be = TitleTextBox.GetBindingExpression(TextBox.TextProperty);

            if (be != null)
            {
                be.UpdateTarget();
            }
            be = AuthorTextbox.GetBindingExpression(TextBox.TextProperty);
            if (be != null)
            {
                be.UpdateTarget();
            }
            be = DescriptionTextBox.GetBindingExpression(TextBox.TextProperty);
            if (be != null)
            {
                be.UpdateTarget();
            }
            be = CreateDatePicker.GetBindingExpression(DatePicker.SelectedDateProperty);
            if (be != null)
            {
                be.UpdateTarget();
            }
            be = RatingTextBox.GetBindingExpression(TextBox.TextProperty);
            if (be != null)
            {
                be.UpdateTarget();
            }
        }
示例#4
0
        private void TitleTextBox_LostFocus(object sender, RoutedEventArgs e)
        {
            BindingExpression be = TitleTextBox.GetBindingExpression(TextBox.TextProperty);

            be.UpdateSource();
        }
示例#5
0
        public void Save()
        {
            // Název
            try
            {
                TitleTextBox.GetBindingExpression(TextBox.TextProperty).UpdateSource();
            }
            catch { }
            if (string.IsNullOrWhiteSpace(Task.Title))
            {
                Task.Title = AppResources.TitleUntitled;
            }
            else
            {
                Task.Title = Task.Title.Trim();
            }

            // Detail
            try
            {
                DetailTextBox.GetBindingExpression(TextBox.TextProperty).UpdateSource();
            }
            catch { }
            Task.Detail = Task.Detail.Trim();

            // Datum & čas
            if (IsSetDueDate)
            {
                Task.DueDate = DueDate;
            }
            else
            {
                Task.DueDate = null;
            }

            // Připomenutí
            if (IsSetDueDate && IsSetReminder)
            {
                Task.Reminder = Reminder;
            }
            else
            {
                Task.Reminder = null;
            }

            // Opakování
            if (IsSetRepeats)
            {
                Task.Repeats = Repeats;
            }
            else
            {
                Task.Repeats = Repeats.None;
            }

            // Nastavení dlaždice
            if (Task.TileSettings == null)
            {
                Task.TileSettings = Settings.Current.DefaultTaskTileSettings.Clone();
            }

            // ULOŽENÍ
            App.Tasks.Update(Task);
        }