Example #1
0
 public void LoadDefaults(SIEESettings settings)
 {
     try { SetDefaults(settings.GetType(), this); }
     catch (Exception ex)
     {
         SIEEMessageBox.Show(
             "Cannot set defaults. Reason:\n" + ex.Message,
             "Load default values",
             System.Windows.MessageBoxImage.Error);
     }
 }
Example #2
0
        private void btn_export_Click(object sender, EventArgs e)
        {
            if (description == null)
            {
                return;
            }

            if (chkbox_clear.Checked)
            {
                description.ClearLocation(settings);
            }

            if (chbox_ignoreEmtpyFields.Checked)
            {
                List <SIEEField> toBeRemoved = new List <SIEEField>();
                foreach (SIEEDocument doc in batch)
                {
                    toBeRemoved = doc.Fieldlist.Where(n => !(n is SIEETableField) && n.Value == string.Empty).ToList();
                    foreach (SIEEField f in toBeRemoved)
                    {
                        doc.Fieldlist.Remove(f);
                    }
                }
            }

            Cursor.Current = Cursors.WaitCursor;
            DateTime startTime = DateTime.Now;

            export.ExportBatch(settings, batch);
            TimeSpan duration = DateTime.Now - startTime;

            Cursor.Current = Cursors.Default;

            string timeTakenString = "Time taken: " + duration.Milliseconds + " milliseconds";

            if (batch.ExportSucceeded())
            {
                SIEEMessageBox.Show("Success!\n" + timeTakenString,
                                    "Export result", System.Windows.MessageBoxImage.None);
            }
            else
            {
                SIEEMessageBox.Show("Failed:\n" + batch.ErrorMessage() + "\n" + timeTakenString,
                                    "Export result", System.Windows.MessageBoxImage.Error);
            }
            export.Term();
        }
Example #3
0
        private void initializeDefaultSetting()
        {
            defaultSettings = new SIEEDefaultValues();
            var ds = Properties.Settings.Default.DefaultSettings;

            if (!string.IsNullOrEmpty(ds))
            {
                try { defaultSettings.Initialize(ds); }
                catch (Exception e)
                {
                    SIEEMessageBox.Show(
                        "Could not load default settings from " + ds + ":\n" + e.Message,
                        "Default settings",
                        System.Windows.MessageBoxImage.Error);
                }
            }
        }
Example #4
0
        public void LoadDefaultsFile(object sender, ExecutedRoutedEventArgs e)
        {
            OpenFileDialog dialog = new OpenFileDialog();

            dialog.Filter = "Document (*.xml)|*.xml";
            dialog.Title  = "Select default settings file";
            if (dialog.ShowDialog() == true)
            {
                Properties.Settings.Default.DefaultSettings = dialog.FileName;
                Properties.Settings.Default.Save();
                try { defaultSettings.Initialize(dialog.FileName); }
                catch (Exception ex)
                {
                    SIEEMessageBox.Show(
                        "Can't load " + dialog.FileName + ":\n" + ex.Message,
                        "Default settings",
                        System.Windows.MessageBoxImage.Error);
                }
            }
        }
 private void runAllTests()
 {
     vmTestResultDialogProxy.IsRunning = true;
     try
     {
         foreach (TestFunctionDefinition tfd in TestList)
         {
             bool success = runOneTest(tfd.Name, tfd.Function);
             if (!(tfd.ContinueOnError ? true : success) || stopTest)
             {
                 break;
             }
         }
     }
     catch (Exception e)
     {
         SIEEMessageBox.Show("Unhandled exception in connection test.\nReason: " + e.Message,
                             "Unhandled exception", MessageBoxImage.Error);
     }
     finally { vmTestResultDialogProxy.IsRunning = false; }
 }
Example #6
0
        // Open the tree view according to the serialzed path.
        // Expands all nodes on the way
        public TVIViewModel InitializeTree(List <string> serializedPath, Type modelType)
        {
            if (serializedPath == null)
            {
                return(null);
            }

            SIEETreeView currentTree = this;
            TVIViewModel currItem    = null;

            try
            {
                for (int i = 0; i != serializedPath.Count; i++)
                {
                    TVIModel tvim = (TVIModel)TVIViewModel.deSerialize(serializedPath[i], modelType);

                    currItem = currentTree.findChild(tvim.Id);
                    if (currItem == null)
                    {
                        throw new Exception(tvim.DisplayName + " not found");
                    }
                    currItem.IsExpanded = true;
                    currItem.IsSelected = true;
                    currentTree         = currItem.Children;
                }
            }
            catch (Exception e)
            {
                string errMsg = "No items in tree view";
                string title  = "Error";
                if (this.Count() > 0)
                {
                    TVIModel someModel = this[0].Tvim;
                    errMsg = "Could not locate " + someModel.GetTypeName() + ". Reason:\n" + e.Message;
                    title  = "Navigate to " + someModel.GetTypeName();
                }
                SIEEMessageBox.Show(errMsg, title, System.Windows.MessageBoxImage.Error);
            }
            return(currItem);
        }