예제 #1
0
        public async void Import(int right, string path = null)
        {
            Window sender = Track.Get(_chain).Window;

            if (path == null)
            {
                OpenFileDialog ofd = new OpenFileDialog()
                {
                    AllowMultiple = false,
                    Filters       = new List <FileDialogFilter>()
                    {
                        new FileDialogFilter()
                        {
                            Extensions = new List <string>()
                            {
                                "apdev"
                            },
                            Name = "Apollo Device Preset"
                        }
                    },
                    Title = "Import Device Preset"
                };

                string[] result = await ofd.ShowAsync(sender);

                if (result.Length > 0)
                {
                    path = result[0];
                }
                else
                {
                    return;
                }
            }

            Copyable loaded = await Copyable.DecodeFile(path, sender);

            if (loaded != null && Copyable_Insert(loaded, right, out Action undo, out Action redo, out Action dispose))
            {
                Program.Project.Undo.Add("Device Imported", undo, redo, dispose);
            }
        }
예제 #2
0
        public static async void Import(ISelectParent parent, int right, string[] paths = null)
        {
            if (parent.ChildFileExtension == null)
            {
                return;
            }

            Window sender = parent.IWindow;

            paths = paths ?? await CreateOFD(parent).ShowAsync(sender);

            if (!paths.Any())
            {
                return;
            }

            Copyable loaded = await Copyable.DecodeFile(paths, sender, parent.ChildType);

            if (loaded != null && InsertCopyable(parent, loaded, right, "Imported", out InsertCopyableUndoEntry entry))
            {
                Program.Project.Undo.AddAndExecute(entry);
            }
        }