예제 #1
0
        public void Init(ToolTab tab, Context context)
        {
            this.context = context;
            openFileDialog.InitialDirectory = Directory.GetCurrentDirectory();
            openFileDialog.Filter           = "obj files (*.obj)|*.obj";
            openFileDialog.RestoreDirectory = true;

            Item.AddButton(tab.AddButton(Properties.Resources.Point, true), GeneratePoint, context);
            Item.AddButton(tab.AddButton(Properties.Resources.Cube, true), GenerateCube, context);
            Item.AddButton(tab.AddButton(Properties.Resources.Octahedron, true), GenerateOcta, context);
            Item.AddButton(tab.AddButton(Properties.Resources.Tetrahedron, true), GenerateTetra, context);
            Item.AddButton(tab.AddButton(Properties.Resources.Icosahedron, true), GenerateIcosa, context);
            Item.AddButton(tab.AddButton(Properties.Resources.Dodecahedron, true), GenerateDodeca, context);
            tab.AddButton(Properties.Resources.SplineBezier, false).ButtonClick += (a) => GenerateBezier();
            MultiItem <Spline, Spline> .AddButton(tab.AddButton(Properties.Resources.Spline),
                                                  () => new Spline(),
                                                  (total, partial) => total.Add(partial.points.First()),
                                                  GeneratePoint,
                                                  context
                                                  );

            var load = tab.AddButton(Properties.Resources.Load, true);

            load.ButtonClick += b => ChangeFile();
            Item.AddButton(load, GenerateObj, context);

            Polytope sun = Primitives.Octahedron(1);

            sun.Matreial = new SolidMaterial(Color.Yellow);
            sun.Apply(Matrix.Move(context.world.Sun));
            var lastPos     = context.world.Sun;
            var sunSettings = SunControl.Settings(point =>
            {
                var newPos = point * (context.camera.location.Length() / 3);
                sun.Apply(Matrix.Move(newPos - lastPos));
                lastPos           = newPos;
                context.world.Sun = point;
                context.Redraw();
            });

            tab.Settings.Controls.Add(sunSettings);
            var sunButton = tab.AddButton(Properties.Resources.Sun);

            sunButton.ButtonClick += button =>
            {
                sunSettings.Visible = true;
                context.world.entities.Add(sun);
                context.Redraw();
            };
            sunButton.ButtonDisable += button =>
            {
                sunSettings.Visible = false;
                context.world.entities.Remove(sun);
                context.Redraw();
            };
        }
예제 #2
0
        public static void AddButton(TabButton button,
                                     Func <TotalEntity> newTotalEntity,
                                     Action <TotalEntity, PartialEntity> append,
                                     Func <PartialEntity> newPartialEntity, Context context)
        {
            var item = new MultiItem <TotalEntity, PartialEntity>(newTotalEntity, append, newPartialEntity, context);

            button.ButtonClick += b =>
            {
                item.New();
                context.pictureBox.MouseClick += item.MouseClick;
            };

            button.ButtonDisable += b =>
            {
                item.Flush();
                context.pictureBox.MouseClick -= item.MouseClick;
                context.Redraw();
            };
        }