Esempio n. 1
0
        protected void Button_Clicked(object sender, EventArgs e)
        {
            string name = (sender as Button).Name;

            switch (name)
            {
            case "plus":
                ratio.Text = "X" + drawing.IncreasSpeed();
                break;

            case "minus":
                ratio.Text = "X" + drawing.IDecreasSpeed();
                break;

            case "add":
                DataAtom    temp = new DataAtom();
                XmlDocument doc  = new XmlDocument();
                doc.Load(xmlDocument);
                XmlElement eml  = doc.DocumentElement;   //gets root element of xmldocument
                XmlNode    data = eml.SelectSingleNode(string.Format("element[name='{0}']", atomSelect.SelectedItem as string));
                temp.Name        = data["name"].InnerText;
                temp.Shells      = (int.Parse(data["shells"].InnerText));
                temp.Weight      = int.Parse(data["weight"].InnerText);
                temp.OuterWeight = int.Parse(data["outerweight"].InnerText);
                temp.Mol         = int.Parse(data["molecule"].InnerText);
                drawing.Add(temp);
                break;

            case "clear":
                for (int i = 0; i < drawing.Childrens.Count(); i++)
                {
                    drawing.Childrens[i] = null;
                }
                drawing.Childrens.Clear();
                break;

            case "path":
                drawing.ActivatePath();
                break;

            case "pause":
                drawing.pause();
                break;

            case "clean":
                drawing.Clean();
                break;

            case "regular":
                drawing.regView();
                break;
            }
        }
Esempio n. 2
0
    void CreateWindow()
    {
        window = new Gtk.Window("animation viewer");
        window.SetDefaultSize(640, 480);

        drawing_area = new Gtk.DrawingArea();

        painter = new Painter(drawing_area, 200);
        painter.Add(Layer.Background, DrawFrame);

        window.Add(drawing_area);
        window.ShowAll();
    }
Esempio n. 3
0
    public static void Main(string[] args)
    {
        MpqContainer mpq = new MpqContainer();

        mpq.Add(new MpqArchive("/home/toshok/src/starcraft/sc-cd/install.exe"));
        mpq.Add(new MpqArchive("/home/toshok/src/starcraft/starcraft/StarDat.mpq"));

        Fnt fnt = (Fnt)mpq.GetResource("files\\font\\font16.fnt");

        Console.WriteLine("loading font palette");
        Stream palStream = (Stream)mpq.GetResource("glue\\Palmm\\tFont.pcx");
        Pcx    pcx1      = new Pcx();

        pcx1.ReadFromStream(palStream, -1, -1);

        Painter.InitializePainter(false, 300);

        Surface textSurf1 = GuiUtil.ComposeText(str1, fnt, pcx1.Palette);
        Surface textSurf2 = GuiUtil.ComposeText(str2, fnt, pcx1.Palette);
        Surface textSurf3 = GuiUtil.ComposeText(str3, fnt, pcx1.Palette);
        Surface textSurf4 = GuiUtil.ComposeText(str4, fnt, pcx1.Palette);

        Surface backgroundSurface = new Surface(Painter.SCREEN_RES_X, Painter.SCREEN_RES_Y);

        backgroundSurface.Fill(new Rectangle(new Point(0, 0), backgroundSurface.Size), Color.Red);

        Painter.Add(Layer.UI,
                    delegate(DateTime now) {
            int y = 0;
            Painter.Blit(textSurf1, new Point(0, y)); y += textSurf1.Height;
            Painter.Blit(textSurf2, new Point(0, y)); y += textSurf2.Height;
            Painter.Blit(textSurf3, new Point(0, y)); y += textSurf3.Height;
            Painter.Blit(textSurf4, new Point(0, y)); y += textSurf4.Height;
        });

        Painter.Add(Layer.Background,
                    delegate(DateTime now) {
            Painter.Blit(backgroundSurface);
        });

        Events.KeyboardUp += delegate(object o, KeyboardEventArgs keyargs) {
            if (keyargs.Key == Key.Escape)
            {
                Events.QuitApplication();
            }
        };

        Events.Run();
    }
Esempio n. 4
0
    private void HandleMouseEvent(InputEventMouse eventMouse)
    {
        var mousePos = eventMouse.Position;

        switch (eventMouse)
        {
        case InputEventMouseButton eventMouseButton:
            if (eventMouseButton.ButtonIndex == (int)ButtonList.Left)
            {
                if (!_drawingLine && eventMouseButton.Pressed)
                {
                    if (_brushMode == PaintControls.BrushMode.Pencil ||
                        _brushMode == PaintControls.BrushMode.Eraser)
                    {
                        _painter.Add(
                            new Painter.Line(color: _color,
                                             thickness: (int)_brushSize), mousePos);
                        // Console.WriteLine($"New point {mousePos}");
                    }
                }
                else if (_drawingLine && !eventMouseButton.Pressed)
                {
                    if (ShouldAcceptMousePos(mousePos))
                    {
                        _painter.AddPoint(mousePos);
                    }
                }

                _drawingLine = eventMouseButton.Pressed;
            }

            break;

        case InputEventMouseMotion eventMouseMotion:
            if (!ShouldAcceptMousePos(mousePos))
            {
                break;
            }
            if (_drawingLine && mousePos.DistanceSquaredTo(_lastMousePos) >= 1f)
            {
                _painter.AddPoint(mousePos);
            }

            break;
        }

        _lastMousePos = mousePos;
    }