コード例 #1
0
        public static void Save(ViewModel vm, string path = configFileName)
        {
            SaveClass    saveClass = new SaveClass(vm);
            StreamWriter writer    = new StreamWriter(path);

            ser.Serialize(writer, saveClass);
            writer.Close();
        }
コード例 #2
0
        public static ViewModel Load(string path = configFileName)
        {
            Folder    folder;
            SaveClass sc = LoadSaveClass(path);
            ViewModel vm = new ViewModel
            {
                WindowWidth  = sc.Window.Width,
                WindowHeight = sc.Window.Height,
                WindowLeft   = sc.Window.PositionX,
                WindowTop    = sc.Window.PositionY,
                WindowState  = sc.Window.Maximized ? System.Windows.WindowState.Maximized : System.Windows.WindowState.Normal
            };

            if (Folder.TryCreate(sc.Search.Src, out folder))
            {
                vm.Search.Src = folder;
            }
            if (Folder.TryCreate(sc.Search.Ref, out folder))
            {
                vm.Search.Ref = folder;
            }

            vm.Search.SrcFound = sc.Search.SrcFound;
            vm.Search.SrcNot   = sc.Search.SrcNot;
            vm.Search.RefFound = sc.Search.RefFound;

            vm.Search.IsWithExtension = sc.Search.WithExtensions;


            if (Folder.TryCreate(sc.Choose.Src, out folder))
            {
                vm.Choose.Src = folder;
            }

            vm.Choose.Have   = sc.Choose.Have;
            vm.Choose.Havent = sc.Choose.Havent;

            vm.Choose.Min = new IntSize(sc.Choose.MinWidth, sc.Choose.MinHeight);
            vm.Choose.Max = new IntSize(sc.Choose.MaxWidth, sc.Choose.MaxHeight);


            if (Folder.TryCreate(sc.Choose.Src, out folder))
            {
                vm.Choose.Src = folder;
            }
            if (Folder.TryCreate(sc.Edit.Src, out folder))
            {
                vm.Edit.Src = folder;
            }
            if (Folder.TryCreate(sc.Edit.DestPath, SubfolderType.This, out folder))
            {
                vm.Edit.Dest = folder;
            }

            vm.Edit.IsFlipX = sc.Edit.FlipX;
            vm.Edit.IsFlipX = sc.Edit.FlipY;

            vm.Edit.Wanna  = sc.Edit.Wanna;
            vm.Edit.Offset = sc.Edit.Offset;

            vm.Edit.ModeType          = sc.Edit.Mode;
            vm.Edit.ReferencePosition = sc.Edit.ReferencePositionType;
            vm.Edit.EncoderType       = sc.Edit.EditEncoder;


            if (Folder.TryCreate(sc.Copy.Src, out folder))
            {
                vm.Copy.Src = folder;
            }
            if (Folder.TryCreate(sc.Copy.DestPath, SubfolderType.This, out folder))
            {
                vm.Copy.Dest = folder;
            }


            if (Folder.TryCreate(sc.Mix.Folder, out folder))
            {
                vm.Mix.Folder = folder;
            }

            vm.Mix.IsMix  = sc.Mix.Mix;
            vm.Mix.IsAuto = sc.Mix.Auto;

            return(vm);
        }