public ActionDialogWindow(ActionDialogViewModel viewModel)
        {
            InitializeComponent();

            this.DataContext = viewModel;

            Global.Dialogs.Register(this, viewModel);
        }
Exemplo n.º 2
0
        public ActionDialogWindow(ActionDialogViewModel viewModel)
        {
            InitializeComponent();

            this.DataContext = viewModel;

            Global.Dialogs.Register(this, viewModel);
        }
Exemplo n.º 3
0
        private void Ok(object param)
        {
            Global.Configuration.MaxDatasheetsCacheSize = m_maxCacheSize.ValidValue * 1024 * 1024;
            Global.Configuration.FavouritesOnStart      = m_favouritesOnStart;
            Global.Configuration.EnableSmoothScrolling  = m_enableSmoothScrollingOption;
            if (Global.Configuration.Language != m_selectedLanguage.Name)
            {
                Global.Configuration.Language = m_selectedLanguage.Name;
                Global.ApplyLanguage();
                Global.MessageBox(this, Global.GetStringResource("StringLanguageChangeRestart"), MessageBoxExPredefinedButtons.Ok);
            }
            Global.SaveConfiguration();

            if (m_initialPath != AppDataPath)
            {
                bool errorOccurred = false;
                Task task          = Task.Run(() =>
                {
                    try
                    {
                        Global.ApplyAppDataPathAndCopy(AppDataPath);
                    }
                    catch
                    {
                        errorOccurred = true;
                    }
                });
                ActionDialogViewModel dialogViewModel = new ActionDialogViewModel(task, Global.GetStringResource("StringWaitForDataMove"));
                Global.Dialogs.ShowDialog(this, dialogViewModel);
                if (errorOccurred)
                {
                    Global.MessageBox(this, Global.GetStringResource("StringDataMoveError"), MessageBoxExPredefinedButtons.Ok);
                    return;
                }

                bool tryAgain = false;
                do
                {
                    try
                    {
                        tryAgain = false;
                        Directory.Delete(m_initialPath, true);
                    }
                    catch
                    {
                        if (Global.MessageBox(this, string.Format(Global.GetStringResource("StringOldDataRemoveErrorTemplate"), m_initialPath), MessageBoxExPredefinedButtons.YesNo) == MessageBoxExButton.Yes)
                        {
                            tryAgain = true;
                        }
                    }
                }while (tryAgain);
            }

            Global.Dialogs.Close(this);
        }
        private void AddCustom(object param)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Filter      = Global.PdfFilter;
            openFileDialog.Multiselect = true;
            openFileDialog.ShowDialog(Global.Dialogs.GetWindow(this));
            foreach (var fileName in openFileDialog.FileNames)
            {
                if (string.IsNullOrWhiteSpace(fileName) || !File.Exists(fileName))
                {
                    continue;
                }

                bool          add  = true;
                PartViewModel part = null;

                if (openFileDialog.FileNames.Length == 1) // if there is only one pdf to add, open window to edit properties of it
                {
                    EditPartViewModel dialogViewModel = new EditPartViewModel(openFileDialog.FileName);
                    Global.Dialogs.ShowDialog(this, dialogViewModel);
                    if (dialogViewModel.Result != EditPartViewModel.EditPartResult.Ok)
                    {
                        add = false;
                    }
                    else
                    {
                        part = dialogViewModel.Part;
                    }
                }
                else // if more then just add it
                {
                    part = PartViewModel.MakeCustom(fileName);
                    File.Copy(fileName, part.CustomPath);
                }

                if (add)
                {
                    m_searchResults.Add(part);
                    m_savedParts.Add(part);
                    part.LastUseDate = DateTime.MinValue;

                    ActionDialogViewModel actionDialogViewModel = new ActionDialogViewModel(part.ComputePagesCount(), Global.GetStringResource("StringCountingPages"));
                    Global.Dialogs.ShowDialog(this, actionDialogViewModel);
                }
            }

            m_filteredResults.Refresh();
        }
Exemplo n.º 5
0
        private void AddCustom(object param)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();
            openFileDialog.Filter = Global.GetStringResource("StringPdfFiles") + "|*.pdf";
            openFileDialog.ShowDialog(Global.Dialogs.GetWindow(this));
            if (!string.IsNullOrWhiteSpace(openFileDialog.FileName) && File.Exists(openFileDialog.FileName))
            {
                EditPartViewModel dialogViewModel = new EditPartViewModel(openFileDialog.FileName);
                Global.Dialogs.ShowDialog(this, dialogViewModel);
                if (dialogViewModel.Result == EditPartViewModel.EditPartResult.Ok)
                {
                    PartViewModel part = dialogViewModel.Part;
                    m_searchResults.Add(part);
                    m_savedParts.Add(part);
                    part.LastUseDate = DateTime.MinValue;

                    ActionDialogViewModel actionDialogViewModel = new ActionDialogViewModel(part.ComputePagesCount(), Global.GetStringResource("StringCountingPages"));
                    Global.Dialogs.ShowDialog(this, actionDialogViewModel);
                }

                m_filteredResults.Refresh();
            }
        }
        private void Ok(object param)
        {
            Global.Configuration.MaxDatasheetsCacheSize = m_maxCacheSize.ValidValue * 1024 * 1024;
            Global.Configuration.FavouritesOnStart = m_favouritesOnStart;
            if (Global.Configuration.Language != m_selectedLanguage.Name)
            {
                Global.Configuration.Language = m_selectedLanguage.Name;
                Global.ApplyLanguage();
                Global.MessageBox(this, Global.GetStringResource("StringLanguageChangeRestart"), MessageBoxExPredefinedButtons.Ok);
            }
            Global.SaveConfiguration();

            if (m_initialPath != AppDataPath)
            {
                bool errorOccurred = false;
                Task task = Task.Run(() =>
                {
                    try
                    {
                        Global.ApplyAppDataPathAndCopy(AppDataPath);
                    }
                    catch
                    {
                        errorOccurred = true;
                    }
                });
                ActionDialogViewModel dialogViewModel = new ActionDialogViewModel(task, Global.GetStringResource("StringWaitForDataMove"));
                Global.Dialogs.ShowDialog(this, dialogViewModel);
                if (errorOccurred)
                {
                    Global.MessageBox(this, Global.GetStringResource("StringDataMoveError"), MessageBoxExPredefinedButtons.Ok);
                    return;
                }

                bool tryAgain = false;
                do
                {
                    try
                    {
                        tryAgain = false;
                        Directory.Delete(m_initialPath, true);
                    }
                    catch
                    {
                        if (Global.MessageBox(this, string.Format(Global.GetStringResource("StringOldDataRemoveErrorTemplate"), m_initialPath), MessageBoxExPredefinedButtons.YesNo) == MessageBoxExButton.Yes)
                        {
                            tryAgain = true;
                        }
                    }
                }
                while (tryAgain);
            }

            Global.Dialogs.Close(this);
        }