Exemplo n.º 1
0
        public MainForm()
        {
            InitializeComponent();
            Log.Message("MainForm initialized.");
            Sandbox.Run();

            MenuBuilder mb = new MenuBuilder(m_puzzleTree, this.puzzleToolStripMenuItem,
                                             this.menuShowPuzzleTree_Click, this.menuPuzzle_Click);

            mb.BuildMenu();
            UpdateNumPuzzles(mb.NumPuzzles, mb.NumTilings);
            BuildScrambleMenu();
            Log.Message("Menus built.");

            m_settings = Settings.Load();
            m_renderer = new PuzzleRenderer(m_glControl, this.UpdateStatus, this.SelectedMacro, m_settings);
            m_propertyGrid.SelectedObject = m_settings;
            CollapseGroups();

            // Show side controls by default.
            m_splitContainer.Panel2Collapsed = false;

            PrepareWaitIcon();
            Log.Message("MainForm constructed.");
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            #region const
            const string END             = "E";
            const string MENU_CACHE_NAME = "MainMenu";
            #endregion

            string      choose;
            int         number;
            MenuBuilder menu = new MenuBuilder();

            do
            {
                Console.WriteLine("Select design pattern to show");

                var cache = LocalCache.Instance.Get <IDictionary <int, string> >(MENU_CACHE_NAME);

                if (cache != null)
                {
                    Menu = cache;
                }
                else
                {
                    Menu = menu.BuildMenu <PatternsTypeBase>();
                    LocalCache.Instance.Add <IDictionary <int, string> >(Menu, MENU_CACHE_NAME);
                }
                foreach (var item in Menu)
                {
                    Console.WriteLine("[{0}]. {1}.", item.Key, item.Value);
                }
                Console.WriteLine("[E]. Exit");

                choose = Console.ReadLine();

                if (Int32.TryParse(choose, out number))
                {
                    SelectPattern(number);
                }
                else
                {
                    Console.WriteLine("Incorect format");
                }
            }while (choose.ToUpper() != END);
        }
Exemplo n.º 3
0
        protected override void DrawList()
        {
            MenuBuilder menu = new MenuBuilder();
            IDictionary <int, string> menuCache = LocalCache.Instance.Get <IDictionary <int, string> >(ASSEMBLY_NAME);

            if (menuCache != null)
            {
                IdsAndNamesOfClasses = menuCache;
            }
            else
            {
                IdsAndNamesOfClasses = menu.BuildMenu <IPatternExecutor>(PatternTypeEnum.Structural);
                LocalCache.Instance.Add <IDictionary <int, string> >(IdsAndNamesOfClasses, ASSEMBLY_NAME);
            }

            foreach (var item in IdsAndNamesOfClasses)
            {
                Console.WriteLine("[{0}]. {1}.", item.Key, item.Value);
            }

            base.DrawList();
        }
Exemplo n.º 4
0
        private void m_glControl_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.F5)
            {
                MenuBuilder mb = new MenuBuilder(m_puzzleTree, this.puzzleToolStripMenuItem,
                                                 this.menuShowPuzzleTree_Click, this.menuPuzzle_Click);
                mb.BuildMenu();
                UpdateNumPuzzles(mb.NumPuzzles, mb.NumTilings);
            }

            if (e.KeyCode == Keys.F6)
            {
                m_settings.SurfaceDisplay = !m_settings.SurfaceDisplay;
            }

            if (e.KeyCode == Keys.F7)
            {
                if (m_puzzle != null && m_puzzle.Config != null)
                {
                    if (m_puzzle.Config.Geometry == Geometry.Spherical)
                    {
                        m_settings.SphericalModel = (SphericalModel)((int)(m_settings.SphericalModel + 1) % 3);
                    }

                    if (m_puzzle.Config.Geometry == Geometry.Hyperbolic)
                    {
                        m_settings.HyperbolicModel = (HModel)(((int)m_settings.HyperbolicModel + 1) % 2);
                    }
                }
            }

            if (e.KeyCode == Keys.F12)
            {
                m_renderer.SaveToSvg();
            }

            if (e.KeyCode == Keys.Escape)
            {
                TwistHandler handler = m_renderer.TwistHandler;
                if (handler.Solving)
                {
                    handler.Solving = false;
                }

                m_renderer.TwistHandler.m_setupMoves.Reset();
                m_renderer.TwistHandler.m_workingMacro.Reset();
                UpdateStatus2();
            }

            if (e.KeyCode == Keys.X)
            {
                if (ShiftDown)
                {
                    m_settings.XLevels += 2;
                }
                else
                {
                    m_settings.XLevels -= 2;
                }
            }

            if (e.KeyCode == Keys.Y)
            {
                if (ShiftDown)
                {
                    m_settings.YLevels += 2;
                }
                else
                {
                    m_settings.YLevels -= 2;
                }
            }

            if (e.KeyCode == Keys.Z)
            {
                if (ShiftDown)
                {
                    m_settings.ZLevels += 2;
                }
                else
                {
                    m_settings.ZLevels -= 2;
                }
            }

            // Slicemask
            if (e.KeyCode == Keys.NumPad1 || e.KeyCode == Keys.D1)
            {
                m_renderer.SliceMask |= SliceMask.SLICEMASK_1;
            }
            if (e.KeyCode == Keys.NumPad2 || e.KeyCode == Keys.D2)
            {
                m_renderer.SliceMask |= SliceMask.SLICEMASK_2;
            }
            if (e.KeyCode == Keys.NumPad3 || e.KeyCode == Keys.D3)
            {
                m_renderer.SliceMask |= SliceMask.SLICEMASK_3;
            }
            if (e.KeyCode == Keys.NumPad4 || e.KeyCode == Keys.D4)
            {
                m_renderer.SliceMask |= SliceMask.SLICEMASK_4;
            }
            if (e.KeyCode == Keys.NumPad5 || e.KeyCode == Keys.D5)
            {
                m_renderer.SliceMask |= SliceMask.SLICEMASK_5;
            }
            if (e.KeyCode == Keys.NumPad6 || e.KeyCode == Keys.D6)
            {
                m_renderer.SliceMask |= SliceMask.SLICEMASK_6;
            }
            if (e.KeyCode == Keys.NumPad7 || e.KeyCode == Keys.D7)
            {
                m_renderer.SliceMask |= SliceMask.SLICEMASK_7;
            }
            if (e.KeyCode == Keys.NumPad8 || e.KeyCode == Keys.D8)
            {
                m_renderer.SliceMask |= SliceMask.SLICEMASK_8;
            }
            if (e.KeyCode == Keys.NumPad9 || e.KeyCode == Keys.D9)
            {
                m_renderer.SliceMask |= SliceMask.SLICEMASK_9;
            }

            m_settings.ClampLevels();
            m_propertyGrid.SelectedObject = m_settings;
            m_glControl.Invalidate();
        }