コード例 #1
0
        public MainForm(string[] args)
        {
            InitializeComponent();
            // Init graph drawing
            Graphics graphTargetGraphics = editorPictureBox.CreateGraphics();

            graphBuffer = BufferedGraphicsManager.Current.Allocate(graphTargetGraphics, new Rectangle(0, 0, Screen.FromControl(this).Bounds.Width, Screen.FromControl(this).Bounds.Height));
            graphBuffer.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
            graphRenderer = new PuzzleGraphRenderer(graphBuffer.Graphics);
            // Init tetris template drawing
            Graphics tetrisTemplateTargetGraphics = tetrisTemplatePictureBox.CreateGraphics();

            tetrisTemplateBuffer = BufferedGraphicsManager.Current.Allocate(tetrisTemplateTargetGraphics, new Rectangle(0, 0, Screen.FromControl(this).Bounds.Width, Screen.FromControl(this).Bounds.Height));
            tetrisTemplateBuffer.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
            tetrisTemplateRenderer = new TetrisTemplateRenderer(tetrisTemplateBuffer.Graphics);
            // Init preview graph box
            Graphics decoratorPreviewGraphics = decoratorPreviewPictureBox.CreateGraphics();

            decoratorPreviewBuffer = BufferedGraphicsManager.Current.Allocate(decoratorPreviewGraphics, new Rectangle(0, 0, Screen.FromControl(this).Bounds.Width, Screen.FromControl(this).Bounds.Height));
            decoratorPreviewBuffer.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
            // Init other stuff
            editorPictureBox.MouseWheel           += EditorPictureBox_MouseWheel;
            decoratorPreviewPictureBox.MouseWheel += DecoratorPreviewPictureBox_MouseWheel;
            InitToolkit();
            UpdateToolkitListView();
            if (args.Length >= 1)
            {
                string fileName = args[0];
                try
                {
                    Graph graph = Graph.LoadFromFile(fileName);
                    if (ObsolateFormatFixer.FixObsoletedTetrisFormat(graph))
                    {
                        Console.WriteLine("[Info] We have automatically upgraded the obsoleted file format. Please remember to save.");
                    }
                    editView = new EditView(graph, editorPictureBox.Width, editorPictureBox.Height, tetrisTemplatePictureBox.Width, tetrisTemplatePictureBox.Height);
                    UpdateGraphDrawing();
                    UpdateTetrisTemplateDrawing();
                    savePath = fileName;
                }
                catch
                {
                    MessageBox.Show(Resources.Lang.Warnings_FailToLoad + fileName);
                    savePath = null;
                    editView = null;
                }
            }
        }
コード例 #2
0
        private void OpenToolStripMenuItem_Click(object sender, EventArgs e)
        {
            openInfoFileDialog.InitialDirectory = Path.Combine(Application.StartupPath, "Puzzles");
            if (openInfoFileDialog.ShowDialog() == DialogResult.Cancel)
            {
                return;
            }
            savePath = openInfoFileDialog.FileName;
            Graph graph = Graph.LoadFromFile(savePath);

            if (ObsolateFormatFixer.FixObsoletedTetrisFormat(graph))
            {
                Console.WriteLine("[Info] We have automatically upgraded the obsoleted file format. Please remember to save.");
            }
            editView = new EditView(graph, editorPictureBox.Width, editorPictureBox.Height, tetrisTemplatePictureBox.Width, tetrisTemplatePictureBox.Height);
            UpdateGraphDrawing();
            UpdateTetrisTemplateDrawing();
            ToolkitListView.SelectedItems.Clear();
        }