Beispiel #1
0
    public static void Main(string[] args)
    {
        Console.WriteLine("Example started");

        var types = new Types();
        var bnd   = new MyBindings();

        bnd.Register(types);

        var bytes = new MemoryStream(File.ReadAllBytes(args[0]));

        var vm = new VM(types, new ModuleLoader(types, bytes));

        vm.LoadModule("example");
        vm.Start("Unit");

        //NOTE: emulating update game loop
        Time.dt = 0.016f;
        float time_accum = 0;

        while (true)
        {
            vm.Tick();
            Thread.Sleep((int)(Time.dt * 1000));
            time_accum += Time.dt;
            if (time_accum > 10)
            {
                break;
            }
        }

        Console.WriteLine("Example finished");
    }
Beispiel #2
0
        public OverlayCPView(OverlayControlPoint ocp) : base(ocp)
        {
            Width  = 10;
            Height = 10;
            Fill   = Brushes.Gray;
            SetStdColor();
            Canvas.SetZIndex(lineToOrigin1, -1);
            Canvas.SetZIndex(lineToOrigin2, -1);

            var sp1 = BindingFactory.CreateProvider(ocp, "Origin1", oc => oc.Origin1, false);
            var sp2 = BindingFactory.CreateProvider(ocp, "Origin2", oc => oc.Origin2, false);

            MyBindings.Add(sp1); MyBindings.Add(sp2);
            MyBindings.Add(BindingFactory.CreateBindingSP(sp1, "BB", vm => UpdateLinePos(lineToOrigin1, vm.Center), () => lineToOrigin1.Visibility = Visibility.Collapsed, false));
            MyBindings.Add(BindingFactory.CreateBindingSP(sp2, "BB", vm => UpdateLinePos(lineToOrigin2, vm.Center), () => lineToOrigin2.Visibility = Visibility.Collapsed, false));

            MyBindings.Add(BindingFactory.CreateBinding(ocp, "BB", vm =>
            {
                if (vm.Origin1 != null)
                {
                    UpdateLinePos(lineToOrigin1, vm.Origin1.Center);
                }
                if (vm.Origin2 != null)
                {
                    UpdateLinePos(lineToOrigin2, vm.Origin2.Center);
                }
            }, null, false));
        }
Beispiel #3
0
        public RasterControl()
        {
            InitializeComponent();

            if (DesignMode)
            {
                return;
            }

            disablerPanel = new Panel()
            {
                Dock = DockStyle.Fill, BackColor = Color.Transparent, Visible = false, Cursor = Cursors.No
            };
            toolTip1.SetToolTip(disablerPanel, "Overlay out of sync. WYSIWYG editing is disabled");
            //toolTip1.SetToolTip(this, "The WYSIWYG area");
            //toolTip1.Popup += new PopupEventHandler(toolTip1_Popup);
            //toolTip1.ReshowDelay = 50;
            //toolTip1.InitialDelay = 100;
            //toolTip1.ShowAlways = true;
            toolTip1.Active = true;

            this.MouseHover += new EventHandler(RasterControl_MouseHover);

            this.Controls.Add(disablerPanel);

            CreateContextMenu();

            //this.CanFocus = true;
            this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.DoubleBuffer | ControlStyles.Selectable, true);

            TheRasterModel = new RasterControlModel(this);

            IPdfToBmp <Bitmap> Pdf2Bmp;

            if (CompilerSettings.Instance.UseExternalRenderer)
            {
                Pdf2Bmp = new PdfToBmpExtWinForms();
            }
            else
            {
                Pdf2Bmp = new PdfToBmp();
            }
            TheDisplayModel = new TikzDisplayModel <Bitmap>(this, Pdf2Bmp);

            TheOverlayModel = new PdfOverlayModel(this, this);
            TheOverlayModel.DisplayTree.DisplayTreeChanged += new EventHandler <TikzDisplayTree.DisplayTreeChangedEventArgs>(DisplayTree_DisplayTreeChanged);

            MarkObject_Timer.Interval = 500;
            MarkObject_Timer.Tick    += new EventHandler(MarkObject_Timer_Tick);

            // listen to Bitmap changes
            MyBindings.Add(BindingFactory.CreateBinding(TheDisplayModel, "Bmp", (o) => this.Invalidate(), null));
        }
Beispiel #4
0
        public OverlayScopeView(OverlayScope os) : base(os)
        {
            SetStdColor(); //os.Stroke = new SolidColorBrush(Color.FromArgb(100, 0, 255, 0));
            StrokeThickness = 10;
            //os.Fill = new SolidColorBrush(Color.FromArgb(100, 0, 255, 0));

            MyBindings.Add(BindingFactory.CreateBinding(os, "IsCurEditing", vm => { if (vm.IsCurEditing)
                                                                                    {
                                                                                        ShowAdorner();
                                                                                    }
                                                                                    else
                                                                                    {
                                                                                        RemoveAdorner();
                                                                                    } }, null, false));
            MyBindings.Add(BindingFactory.CreateBinding(os, "BB", vm => { Width = vm.BB.Width; Height = vm.BB.Height; }, null, false));
        }
Beispiel #5
0
        public RasterControl(EventBox parent)
        {
            ParentBox = parent;

            disablerPanel             = new DrawingArea();//{ Opacit = Color.Transparent, Visible = false, Curso = Cursors.No };
            disablerPanel.TooltipText = "Overlay out of sync. WYSIWYG editing is disabled";
            //toolTip1.SetToolTip(disablerPanel, "Overlay out of sync. WYSIWYG editing is disabled");
            //        this.PackStart(disablerPanel, true, true,0);


            //toolTip1.SetToolTip(this, "The WYSIWYG area");
            //toolTip1.Popup += new PopupEventHandler(toolTip1_Popup);
            //toolTip1.ReshowDelay = 50;
            //toolTip1.InitialDelay = 100;
            //toolTip1.ShowAlways = true;
            toolTip1.Active = true;

            //todo this.MouseHover += new EventHandler(RasterControl_MouseHover);



            CreateContextMenu();

            //this.CanFocus = true;
            //this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.DoubleBuffer | ControlStyles.Selectable, true);
            DoubleBuffered = true;

            TheRasterModel = new RasterControlModel(this);

            TheDisplayModel = new TikzDisplayModel <Cairo.ImageSurface>(this, new PdfToBmpExtGTK());

            TheOverlayModel = new PdfOverlayModel(this, this);

            MarkObject_Timer.Interval = 500;
            MarkObject_Timer.Tick    += new EventHandler(MarkObject_Timer_Tick);

            // listen to Bitmap changes
            MyBindings.Add(BindingFactory.CreateBinding(TheDisplayModel, "Bmp", (o) => this.Invalidate(), null));

            parent.ButtonPressEvent   += OnButtonPress;
            parent.ButtonReleaseEvent += OnButtonRelease;
            parent.MotionNotifyEvent  += OnMotionNotify;
            parent.KeyPressEvent      += OnKeyPress;
            parent.KeyReleaseEvent    += OnKeyRelease;
        }