Example #1
0
        /// <summary>
        /// Attempt to open a file and load it into the viewmodel if it exists.
        /// </summary>
        /// <param name="filePath"></param>
        /// <returns>True if file exists and was succesfully loaded. Otherwise false.</returns>
        protected bool OpenFile(string filePath)
        {
            try
            {
                var isReal = File.Exists(filePath);

                if (isReal == true)
                {
                    if (MDocumentModel == null)
                    {
                        MDocumentModel = new DocumentModel();
                    }

                    MDocumentModel.SetFileNamePath(filePath, isReal);

                    FilePath  = filePath;
                    ContentId = _mFilePath;

                    // Mark document loaded from persistence as unedited copy (display without dirty mark '*' in name)
                    IsDirty = false;

                    try
                    {
                        // XXX TODO Extend log4net FileOpen method to support base.FireFileProcessingResultEvent(...);
                        _mDocumentMiniUml.LoadFile(_mFilePath);
                    }
                    catch (Exception ex)
                    {
                        var msgBox = ServiceLocator.Current.GetInstance <IMessageBoxService>();
                        msgBox.Show(ex, ex.Message, "An error has occurred", MsgBoxButtons.OK);

                        return(false);
                    }
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception exp)
            {
                var msgBox = ServiceLocator.Current.GetInstance <IMessageBoxService>();
                msgBox.Show(exp, exp.Message, "An error has occurred", MsgBoxButtons.OK);

                return(false);
            }

            return(true);
        }