private void BtnSave_Click(object sender, RoutedEventArgs e)
        {
            // if triggered by hotkey make sure textboxes are updated
            var bindings = BindingOperations.GetSourceUpdatingBindings(this);

            foreach (var b in bindings)
            {
                b.UpdateSource();
            }
            _pdfViewerWindow.currentPdfMetaData.InitializeDictToc(LstTOC.ToList());
            _pdfViewerWindow.currentPdfMetaData.Notes = DocNotes?.Trim();
            var delta = _pdfViewerWindow.currentPdfMetaData.PageNumberOffset - PageNumberOffset;

            if (delta != 0)
            {// user changed pagenumberoffset. we need to adjust the favorites page no
                var favlist = _pdfViewerWindow.currentPdfMetaData.dictFav.Values.ToList();
                foreach (var fav in favlist)
                {
                    fav.Pageno -= delta;
                }
                _pdfViewerWindow.currentPdfMetaData.Favorites = favlist;
                _pdfViewerWindow.currentPdfMetaData.InitializeFavList();
            }
            _pdfViewerWindow.currentPdfMetaData.PageNumberOffset = PageNumberOffset;
            _pdfViewerWindow.currentPdfMetaData.SaveIfDirty(ForceDirty: true);
            this.DialogResult = true;
            this.Close();
        }
 /// <summary>
 /// Cancel button click.
 /// </summary>
 /// <param name="sender">The sender.</param>
 /// <param name="e">The <see cref="RoutedEventArgs"/> instance containing the event data.</param>
 private void CancelButtonClick(object sender, RoutedEventArgs e)
 {
     foreach (var be in BindingOperations.GetSourceUpdatingBindings(this))
     {
         be.UpdateTarget();
     }
 }
Exemple #3
0
        private void btnOk_Click(object sender, RoutedEventArgs e)
        {
            foreach (BindingExpression expression in BindingOperations.GetSourceUpdatingBindings(null))
            {
                expression.UpdateSource();
            }

            this.DialogResult = true;
            this.DataContext  = this;
        }
Exemple #4
0
 private void SubmitButton_Click(object sender, RoutedEventArgs e)
 {
     beSet.UnionWith(BindingOperations.GetSourceUpdatingBindings(this));
     foreach (var be in beSet)
     {
         be.UpdateSource();
     }
     this.DialogResult = true;
     this.Close();
 }
        internal static void UpdateBindings(FrameworkElement element)
        {
            // hotkey doesn't update binding, so we need to update
            //http://social.msdn.microsoft.com/Forums/vstudio/en-US/e75a6449-1f40-463c-a251-12d317350bf2/textbox-focus-databinding-and-hotkeys?forum=wpf
            var bindings = BindingOperations.GetSourceUpdatingBindings(element); // get all bindings

            foreach (var b in bindings)
            {
                b.UpdateSource();
            }
        }
Exemple #6
0
        private void OkButtonClick(object sender, System.Windows.RoutedEventArgs e)
        {
            foreach (var be in BindingOperations.GetSourceUpdatingBindings(this))
            {
                be.UpdateSource();
            }

            if (string.IsNullOrEmpty(((GroupViewModel)this.DataContext).Error))
            {
                MaterialDesignThemes.Wpf.DialogHost.CloseDialogCommand.Execute(true, this);
            }
        }
        public void UpdateSources()
        {
            forceUpdateSource = false;

            foreach (var expr in BindingOperations.GetSourceUpdatingBindings(Control))
            {
                if (!expr.HasError)
                {
                    expr.UpdateSource();
                }
            }
        }         // proc UpdateSources
        private void btnOk_Click(object sender, RoutedEventArgs e)
        {
            if (rbBeli.IsChecked == true)
            {
                this.igra.TrenutniIgracPublic = Igrac.Crni;
            }
            else if (rbCrni.IsChecked == true)
            {
                this.igra.TrenutniIgracPublic = Igrac.Beli;
            }

            if (rbNajlakse.IsChecked == true)
            {
                this.Igra.DifficultyLevel = SettingSearchMode.DifficultyLevelE.VeryEasy;
            }
            else if (rbLako.IsChecked == true)
            {
                this.Igra.DifficultyLevel = SettingSearchMode.DifficultyLevelE.Easy;
            }
            else if (rbSrednje.IsChecked == true)
            {
                this.Igra.DifficultyLevel = SettingSearchMode.DifficultyLevelE.Intermediate;
            }
            else if (rbTesko.IsChecked == true)
            {
                this.Igra.DifficultyLevel = SettingSearchMode.DifficultyLevelE.Hard;
            }
            else if (rbNajteze.IsChecked == true)
            {
                this.Igra.DifficultyLevel = SettingSearchMode.DifficultyLevelE.VeryHard;
            }

            foreach (BindingExpression expression in BindingOperations.GetSourceUpdatingBindings(null))
            {
                expression.UpdateSource();
            }

            this.DialogResult = true;
            this.DataContext  = this;
        }
Exemple #9
0
        private static void ElementOnLoaded(object sender, RoutedEventArgs routedEventArgs)
        {
            var element = sender as FrameworkElement;

            if (element == null)
            {
                return;
            }

            //Revalidate all Bindings
            foreach (var be in BindingOperations.GetSourceUpdatingBindings(element))
            {
                be.UpdateSource();
            }

            //Apply error template
            ChangeErrorTemplate(sender, routedEventArgs);

            //Subscribing on HasErrorProperty, in order to when HasError = false - disable ErrorTemplate
            //Otherwise, there are cases when ErrorTemplate is applied, but in fact there are no errors
            DependencyPropertyDescriptor
            .FromProperty(Validation.HasErrorProperty, typeof(FrameworkElement))
            .AddValueChanged(element, ChangeErrorTemplate);
        }
Exemple #10
0
 private void TabControl_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
 {
     beSet.UnionWith(BindingOperations.GetSourceUpdatingBindings(this));
 }