Exemple #1
0
        //loading background image from file.
        public void LoadBackgroundImageFromFile(object messageIn)
        {
            if (mySelectedCAGrid2DViewModel != null)
            {
                bool?aDialogResult = null;

                string aDefaultExtension = ".jpg";
                string aFileExtensions   = "Images jpeg files (.jpg)|*.jpg|png files (.png)|*.png|gif files (.gif)|*.gif|bmp files (.bmp)|*.bmp";

                string aFileName = null;
                aDialogResult = DialogMediator.ShowOpenFileDialog(this, aFileExtensions, aDefaultExtension, out aFileName);

                if (aDialogResult == true)
                {
                    try
                    {
                        ImageBrush aCABackgroundImageBrush = new ImageBrush();

                        aCABackgroundImageBrush.ImageSource           = new BitmapImage(new Uri(@aFileName, UriKind.Relative));
                        mySelectedCAGrid2DViewModel.CABackgroundImage = aCABackgroundImageBrush;
                    }
                    catch (Exception ex)
                    {
                        if (ex is OutOfMemoryException || ex is System.IO.FileNotFoundException || ex is ArgumentException || ex is UriFormatException)
                        {
                            DialogMediator.ShowMessageBox(null, "Exception during reading of background image", "Problem with reading of background image : \n" + aFileName
                                                          + "\n" + "Following exception occured : \n" + ex.Message, System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Error);
                        }
                        else
                        {
                            throw;
                        }
                    }
                }
            }
        }
Exemple #2
0
        //loading specific CA from file
        public void LoadCAFromFile(object messageIn)
        {
            bool?aDialogResult = null;

            string aDefaultExtension = ".xml";
            string aFileExtensions   = "Xml files (.xml)|*.xml";

            string aFileName = null;

            aDialogResult = DialogMediator.ShowOpenFileDialog(this, aFileExtensions, aDefaultExtension, out aFileName);

            if (aDialogResult == true)
            {
                var aCAGrid2DVM = new CAGrid2DVM();

                try
                {
                    //reading CA from specified file and adding it to list of CAs
                    CAGrid2DRW.ReadCA(aFileName, this, ref aCAGrid2DVM);
                    myGrid2DViewModelList.Add(aCAGrid2DVM);
                }
                catch (Exception ex)
                {
                    if (ex is System.IO.FileNotFoundException || ex is System.Security.SecurityException || ex is UriFormatException || ex is System.Xml.XmlException ||
                        ex is FormatException || ex is OverflowException || ex is ArgumentOutOfRangeException || ex is NullReferenceException || ex is CAExplorerException)
                    {
                        DialogMediator.ShowMessageBox(null, "Exception during reading CA", "Problem with reading following CA file : \n" + aFileName
                                                      + "\n" + "Following exception occured : \n" + ex.Message, System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Error);
                    }
                    else
                    {
                        throw;
                    }
                }
            }
        }