Exemple #1
0
        public void Load(LibraryComponent lib, string fileName)
        {
            Init();

            var idents = new List <PuzzleIdent>();
            var file   = TrivialNameValueFileFormat.Load(lib.GetPathData(fileName));

            foreach (var pair in file)
            {
                if (pair.Key == "PuzzleExit.Duration")
                {
                    BatchExit.Duration = TimeSpan.FromSeconds(int.Parse(pair.Value));
                }

                if (pair.Key == "BatchExit.Duration")
                {
                    BatchExit.Duration = TimeSpan.FromSeconds(int.Parse(pair.Value));
                }

                if (pair.Key.StartsWith("Puzzle."))
                {
                    idents.Add(PuzzleIdent.Parse(pair.Value));
                }
            }

            AddRange(lib.LoadAllPuzzles(idents));
        }
Exemple #2
0
        public static void Run(
            string puzzle = "SQ1~P5", int min  = 0, int sec = 0,
            string solver = "fr!", string pool = PoolDefault,
            double minR   = 0, double maxR     = 2000)
        {
            if (min == 0 && sec == 0)
            {
                min = 3;
            }

            var pathHelper = new PathHelper();
            var compLib    = new LibraryComponent(pathHelper.GetRelDataPath("Lib"));

            var selection = compLib.GetPuzzlesWithCachingUsingRegex(puzzle).ToArray();

            if (!selection.Any())
            {
                throw new Exception($"Not puzzles found '{puzzle}', should be SQ1~P5 or SQ1, etc");
            }

            var solverRun = new SolverRun();

            solverRun.Init();
            solverRun.AddRange(
                selection
                .OrderBy(x => x.Rating)
                .Where(x => x.Rating >= minR && x.Rating <= maxR)
                );

            SolverRun(puzzle, min, sec, solver, pool, minR, maxR, solverRun);
        }
        public async Task<IHttpActionResult> PostLibraryComponent(LibraryComponent libraryComponent)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            db.LibraryComponents.Add(libraryComponent);

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (LibraryComponentExists(libraryComponent.LibraryComponentId))
                {
                    return Conflict();
                }
                else
                {
                    throw;
                }
            }

            return CreatedAtRoute("DefaultApi", new { id = libraryComponent.LibraryComponentId }, libraryComponent);
        }
        public async Task<IHttpActionResult> PutLibraryComponent(int id, LibraryComponent libraryComponent)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            if (id != libraryComponent.LibraryComponentId)
            {
                return BadRequest();
            }

            db.Entry(libraryComponent).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!LibraryComponentExists(id))
                {
                    return NotFound();
                }
                else
                {
                    throw;
                }
            }

            return StatusCode(HttpStatusCode.NoContent);
        }
Exemple #5
0
        public void LegaxySSX()
        {
            outp.WriteLine(Environment.CurrentDirectory);

            var l   = new LibraryComponent(helper.GetLibraryPath());
            var lib = l.LoadLegacySokoSolve_SSX(l.GetPathData(@"Sasquatch.ssx"));

            Assert.NotNull(lib);
            Assert.Equal(50, lib.Count);
        }
        public override void Init()
        {
            // Setup: Library
            var    path    = new PathHelper();
            var    compLib = new LibraryComponent(path.GetLibraryPath());
            string libName = "SokoSolve-v1\\Microban.ssx";

            //string libName = "SokoSolve-v1\\Sasquatch.ssx";
            library = new LibraryScene(this, compLib.LoadLibrary(compLib.GetPathData(libName)));
            library.Init();

            Current = library;
        }
Exemple #7
0
        private void ComponentOnStateChangedEvent(LibraryComponent sender, LibraryComponentState state)
        {
            Dispatcher.Invoke(DispatcherPriority.Normal, new Action(() =>
            {
                //add active items
                if (state == LibraryComponentState.Active)
                {
                    TreeViewItem item = new TreeViewItem();
                    item.Header       = ((LibraryComponent)sender).Caption;
                    item.Tag          = sender;

                    plugTree.Items.Add(item);

                    return;
                }
                //remove inactive items
                for (int index = 0; index < plugTree.Items.Count; index++)
                {
                    Control vi           = (Control)plugTree.Items[index];
                    var libraryComponent = vi.Tag as LibraryComponent;
                    if (libraryComponent != null)
                    {
                        if (sender == libraryComponent)
                        {
                            switch (state)
                            {
                            case LibraryComponentState.Active:

                                break;

                            case LibraryComponentState.Inactive:
                                plugTree.Items.Remove(vi);
                                libraryComponent.ComponentUI.FadeOut();
                                break;

                            case LibraryComponentState.Hidden:

                                break;

                            case LibraryComponentState.Static:

                                break;

                            default:
                                throw new ArgumentOutOfRangeException("state");
                            }
                        }
                    }
                }
            }));
        }
        public LibrariesPage(TreehopperUsb Board)
        {
            InitializeComponent();

            this.Board = Board;

            components.ItemsSource = Components;

            foreach (Type type in typeof(LibraryComponent).GetTypeInfo().Assembly.GetTypes().Where(type => typeof(LibraryComponent).IsAssignableFrom(type) && type != typeof(LibraryComponent)))
            {
                LibraryComponent item = (LibraryComponent)Activator.CreateInstance(type, new object[] { this, Board });

                ComponentList.Add(item.Title, type);
            }
        }
Exemple #9
0
        public void Run(
            string puzzle = "SQ1~P13", int min = 0, int sec = 0,
            string solver = "fr!", string pool = BatchSolveComponent.PoolDefault,
            double minR   = 0, double maxR     = 2000, string save = null)
        {
            if (min == 0 && sec == 0)
            {
                min = 3;
            }

            var pathHelper = new PathHelper();
            var compLib    = new LibraryComponent(pathHelper.GetRelDataPath("Lib"));

            var selection = compLib.GetPuzzlesWithCachingUsingRegex(puzzle).ToArray();

            if (!selection.Any())
            {
                throw new Exception($"Not puzzles found '{puzzle}', should be SQ1~P5 or SQ1, etc");
            }

            var solverRun = new SolverRun();

            solverRun.Init();
            solverRun.AddRange(
                selection
                .OrderBy(x => x.Rating)
                .Where(x => x.Rating >= minR && x.Rating <= maxR)
                );

            var batch = new BatchSolveComponent();

            batch.SolverRun(new BatchSolveComponent.BatchArgs(puzzle, min, sec, solver, pool, minR, maxR, save)
            {
                Console = new TextWriterAdapter(System.Console.Out)
            }, solverRun);
        }
 // Constructor
 public Reservable(LibraryComponent libraryComponent)
     : base(libraryComponent)
 {
 }
 public LibController(LibraryComponent compLib, ISokobanSolutionRepository repSol)
 {
     this.compLib = compLib;
     this.repSol  = repSol;
 }
Exemple #12
0
        void plugTree_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs <object> e)
        {
            var sel = plugTree.SelectedItem as TreeViewItem;

            if (sel != null)
            {
                var t = sel.Tag as LibraryComponent;
                t.ChildrenToggled(sel.Header.ToString());
                //library togs

                if (t.Caption == " My Library" && grdDD.Visibility == Visibility.Hidden)
                {
                    Tabs.FadeIn();
                    Container.FadeOut();
                    switch (sel.Header.ToString())
                    {
                    case " Songs":
                        EnumerationsContainer.LibraryUi = LibraryUiMode.Songs;
                        break;

                    case " Artists":
                        EnumerationsContainer.LibraryUi = LibraryUiMode.Artist;
                        break;

                    case " Albums":
                        EnumerationsContainer.LibraryUi = LibraryUiMode.Album;
                        break;

                    case " Genres":
                        EnumerationsContainer.LibraryUi = LibraryUiMode.Genre;
                        break;
                    }
                    RefreshUi();
                }
                else
                {
                    Tabs.FadeOut();
                    Container.FadeIn();
                    LibraryComponent lc = sel.Tag as LibraryComponent;

                    if (!lc.Initialized)
                    {
                        lc.Initialize();
                    }
                    if (!Container.Children.Contains(lc.ComponentUI))
                    {
                        if (lc.ComponentUI != null)
                        {
                            Container.Children.Add(lc.ComponentUI);
                        }
                    }
                    foreach (Control v in Container.Children)
                    {
                        if (v != lc.ComponentUI)
                        {
                            v.FadeOut();
                        }
                    }
                    lc.ComponentUI.FadeIn();
                }
            }
        }
Exemple #13
0
 // Constructor
 public Decorator(LibraryComponent libraryComponent)
 {
     this.libraryComponent = libraryComponent;
 }