Exemple #1
0
        /// <summary>
        /// Open a file
        /// </summary>
        /// <param name="fullPath">absolute path</param>
        public static bool Open(string fullPath)
        {
            if (System.IO.Path.GetFullPath(fullPath) != fullPath)
            {
                throw new Exception(Resources.GetString("NotAbsolutePathError"));
            }

            var dialog = new Dialog.SaveOnDisposing(
                () =>
            {
                try
                {
                    if (Core.LoadFrom(fullPath))
                    {
                        RecentFiles.AddRecentFile(fullPath);
                    }
                }
                catch (Exception e)
                {
                    var messageBox = new Dialog.MessageBox();
                    messageBox.Show("Error", e.Message);
                }

                System.IO.Directory.SetCurrentDirectory(System.IO.Path.GetDirectoryName(fullPath));
            });

            return(true);
        }
Exemple #2
0
        public static bool New()
        {
            var dialog = new Dialog.SaveOnDisposing(
                () =>
            {
                Core.New();
            });

            return(true);
        }
Exemple #3
0
        /// <summary>
        /// Open a file
        /// </summary>
        /// <param name="fullPath">absolute path</param>
        public static bool Open(string fullPath)
        {
            if (!Utils.Misc.IsFullPath(fullPath))
            {
                throw new Exception(Resources.GetString("NotAbsolutePathError"));
            }
            fullPath = Utils.Misc.BackSlashToSlash(fullPath);

            if (Core.IsChanged)
            {
                var dialog = new Dialog.SaveOnDisposing(
                    () =>
                {
                    try
                    {
                        if (Core.LoadFrom(fullPath))
                        {
                            RecentFiles.AddRecentFile(fullPath);
                            System.IO.Directory.SetCurrentDirectory(System.IO.Path.GetDirectoryName(fullPath));
                        }
                        else
                        {
                            swig.GUIManager.show(string.Format(Resources.GetString("Error_NotFound"), fullPath), "Error", swig.DialogStyle.Error, swig.DialogButtons.OK);
                        }
                    }
                    catch (Exception e)
                    {
                        HandleExceptionWhileOpenning(e);
                    }
                });

                return(true);
            }
            else
            {
                try
                {
                    if (Core.LoadFrom(fullPath))
                    {
                        RecentFiles.AddRecentFile(fullPath);
                        System.IO.Directory.SetCurrentDirectory(System.IO.Path.GetDirectoryName(fullPath));
                    }
                    else
                    {
                        swig.GUIManager.show(string.Format(Resources.GetString("Error_NotFound"), fullPath), "Error", swig.DialogStyle.Error, swig.DialogButtons.OK);
                    }
                }
                catch (Exception e)
                {
                    HandleExceptionWhileOpenning(e);
                }

                return(true);
            }
        }
Exemple #4
0
        /// <summary>
        /// Open a file
        /// </summary>
        /// <param name="fullPath">absolute path</param>
        public static bool Open(string fullPath)
        {
            if (System.IO.Path.GetFullPath(fullPath) != fullPath)
            {
                throw new Exception(Resources.GetString("NotAbsolutePathError"));
            }

            if (Core.IsChanged)
            {
                var dialog = new Dialog.SaveOnDisposing(
                    () =>
                {
                    try
                    {
                        if (Core.LoadFrom(fullPath))
                        {
                            RecentFiles.AddRecentFile(fullPath);
                        }
                    }
                    catch (Exception e)
                    {
                        swig.GUIManager.show(e.Message, "Error", swig.DialogStyle.Error, swig.DialogButtons.OK);
                        //var messageBox = new Dialog.MessageBox();
                        //messageBox.Show("Error", e.Message);
                    }

                    System.IO.Directory.SetCurrentDirectory(System.IO.Path.GetDirectoryName(fullPath));
                });

                return(true);
            }
            else
            {
                try
                {
                    if (Core.LoadFrom(fullPath))
                    {
                        RecentFiles.AddRecentFile(fullPath);
                    }
                }
                catch (Exception e)
                {
                    swig.GUIManager.show(e.Message, "Error", swig.DialogStyle.Error, swig.DialogButtons.OK);
                    //var messageBox = new Dialog.MessageBox();
                    //messageBox.Show("Error", e.Message);
                }

                System.IO.Directory.SetCurrentDirectory(System.IO.Path.GetDirectoryName(fullPath));

                return(true);
            }
        }
Exemple #5
0
        public static bool New()
        {
            if (Core.IsChanged)
            {
                var dialog = new Dialog.SaveOnDisposing(
                    () =>
                {
                    Core.New();
                });
            }
            else
            {
                Core.New();
            }

            return(true);
        }
Exemple #6
0
        public override bool Closing()
        {
            if (Manager.IgnoreDisposingDialogBox)
            {
                return(true);
            }
            if (!Core.IsChanged)
            {
                return(true);
            }

            var dialog = new Dialog.SaveOnDisposing(
                () =>
            {
                Manager.IgnoreDisposingDialogBox = true;
                Manager.NativeManager.Close();
            });

            return(false);
        }
Exemple #7
0
        /// <summary>
        /// Open a file
        /// </summary>
        /// <param name="fullPath">absolute path</param>
        public static bool Open(string fullPath)
        {
            if (System.IO.Path.GetFullPath(fullPath) != fullPath)
            {
                throw new Exception(Resources.GetString("NotAbsolutePathError"));
            }

            if (Core.IsChanged)
            {
                var dialog = new Dialog.SaveOnDisposing(
                    () =>
                {
                    try
                    {
                        if (Core.LoadFrom(fullPath))
                        {
                            RecentFiles.AddRecentFile(fullPath);
                            System.IO.Directory.SetCurrentDirectory(System.IO.Path.GetDirectoryName(fullPath));
                        }
                        else
                        {
                            if (Core.Language == Language.Japanese)
                            {
                                swig.GUIManager.show(fullPath + "が見つかりません。", "Error", swig.DialogStyle.Error, swig.DialogButtons.OK);
                            }
                            else
                            {
                                swig.GUIManager.show(fullPath + " is not found.", "Error", swig.DialogStyle.Error, swig.DialogButtons.OK);
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        swig.GUIManager.show(e.Message, "Error", swig.DialogStyle.Error, swig.DialogButtons.OK);
                    }
                });

                return(true);
            }
            else
            {
                try
                {
                    if (Core.LoadFrom(fullPath))
                    {
                        RecentFiles.AddRecentFile(fullPath);
                        System.IO.Directory.SetCurrentDirectory(System.IO.Path.GetDirectoryName(fullPath));
                    }
                    else
                    {
                        if (Core.Language == Language.Japanese)
                        {
                            swig.GUIManager.show(fullPath + "が見つかりません。", "Error", swig.DialogStyle.Error, swig.DialogButtons.OK);
                        }
                        else
                        {
                            swig.GUIManager.show(fullPath + " is not found.", "Error", swig.DialogStyle.Error, swig.DialogButtons.OK);
                        }
                    }
                }
                catch (Exception e)
                {
                    swig.GUIManager.show(e.Message, "Error", swig.DialogStyle.Error, swig.DialogButtons.OK);
                }

                return(true);
            }
        }