private void MainPanel_Paint(object sender, PaintEventArgs e)
        {
            if (obj == null)
            {
                return;
            }

            e.Graphics.Clear(Color.Black);

            image = new Bitmap(e.ClipRectangle.Width, e.ClipRectangle.Height);

            provider = new BitmapProvider(image);
            graphics = new MyGraphics(provider);
            //graphics.Fill(Color.Black);

            int Width  = e.ClipRectangle.Width;
            int Height = e.ClipRectangle.Height;

            Vec3f zero = new Vec3f(0, 0, 0);

            Vec3f ligth = new Vec3f(
                ((float)e.ClipRectangle.Width / 2 - x) / (Width / 2),
                (y - (float)e.ClipRectangle.Height / 2) / (Height / 2),
                z);

            ligth = zero - ligth;

            ligth.Normalize();

            //graphics.DrawLine(new Vec2i(200, 200), new Vec2i(x, y), Color.White);
            graphics.DrawObject(obj, Color.White, ligth, c);
            graphics.DrawLight(ligth, Width / 2);
            e.Graphics.DrawImage(image, 0, 0);
        }
Beispiel #2
0
        public Frame Create(string name = null,
                            IGraphicsProvider component          = null,
                            Vector3 localPosition                = default(Vector3),
                            Euler localRotationEuler             = default(Euler),
                            Vector3 localScale                   = default(Vector3),
                            Action <Frame, float> updateCallback = null)
        {
            if (name == null)
            {
                if (component != null && component is INameable)
                {
                    name = ((INameable)component).Name;
                }
                else
                {
                    name = "Node" + _nodes.Count;
                }
            }

            var node = new Frame(name, component);

            node.LocalPosition = localPosition;
            node.LocalEuler    = localRotationEuler;
            node.LocalScale    = localScale == default(Vector3) ? Vector3.One : localScale;
            node.ComputeLocalPose();
            node.CommitChanges();
            _nodes.Add(node);
            if (updateCallback != null)
            {
                _dynamics.Add(new Dynamic(x => updateCallback(node, x)));
            }
            node.OnSceneAttach(this);
            return(node);
        }
Beispiel #3
0
        public Frame CreateChild(string name, IGraphicsProvider component)
        {
            var node = new Frame(name, component);

            _nodes.Add(node);
            return(node);
        }
 public CaptchaService(ICaptchaStore captchaStore,
                       IGraphicsProvider graphicsStrategy,
                       IRandomProvider randomProvider)
 {
     _captchaStore     = captchaStore;
     _graphicsStrategy = graphicsStrategy;
     _randomProvider   = randomProvider;
 }
Beispiel #5
0
        public static Frame CreateNode(string name, IGraphicsProvider component, Matrix localPose)
        {
            var node = new Frame(name, component);

            node.LocalPose = localPose;
            node.CommitChanges();
            return(node);
        }
Beispiel #6
0
 public BBTextParser(IGraphicsProvider gfxProvider, float defaultFontSize,
                     IColor linkColor, IColor textColor)
 {
     fGfxProvider     = gfxProvider;
     fChunks          = new List <BBTextChunk>();
     fDefaultFontSize = defaultFontSize;
     fLinkColor       = linkColor;
     fTextColor       = textColor;
 }
Beispiel #7
0
        public Frame CreateChild(string name, IGraphicsProvider component, Vector3 localPosition, Matrix localRotation, Vector3 localScale)
        {
            var node = new Frame(name, component);

            node.ComputeLocalPose(localScale, localRotation, localPosition);
            node.CommitChanges();
            Childrens.Add(node);
            return(node);
        }
Beispiel #8
0
        public static Frame CreateNode(string name, IGraphicsProvider component, Vector3 localPosition = default(Vector3),
                                       Matrix localRotation = default(Matrix), Vector3 localScale = default(Vector3))
        {
            var node = new Frame(name, component);

            node.LocalPosition = localPosition;
            node.LocalRotation = localRotation.IsZero ? Matrix.Identity : localRotation;
            node.LocalScale    = localScale == Vector3.Zero ? Vector3.One : localScale;
            node.ComputeLocalPose();
            node.CommitChanges();
            return(node);
        }
Beispiel #9
0
        public Frame(string name,
                     Vector3 localPosition,
                     Matrix localRotation,
                     Vector3 localScale,
                     IGraphicsProvider component) : this(name, component)
        {
            LocalPosition = localPosition;
            LocalRotation = localRotation;
            LocalScale    = localScale;

            ComputeLocalPose();
            CommitChanges();
        }
Beispiel #10
0
 public bool IsSupported()
 {
     _graphicsProvider = ServiceRegistry.Registry.GetService <IGraphicsProvider>();
     if (_graphicsProvider != null)
     {
         _graphicsProvider.OnGraphicsInit += GraphicsInit;
         return(true);
     }
     else
     {
         return(false);
     }
 }
Beispiel #11
0
        public Frame Create(string name, IGraphicsProvider component, Matrix localPose, Action <Frame, float> updateCallback = null)
        {
            var node = new Frame(name, component);

            node.LocalPose = localPose;
            node.CommitChanges();
            _nodes.Add(node);
            if (updateCallback != null)
            {
                _dynamics.Add(new Dynamic(x => updateCallback(node, x)));
            }
            node.OnSceneAttach(this);
            return(node);
        }
Beispiel #12
0
        public void TextTest()
        {
            IGraphicsProvider gp = Registry.GetService <IGraphicsProvider>();

            gp.OnGraphicsInit += provider =>
            {
                IWindow window = new Window(
                    provider.MakeRect2D(100, 100, 800, 600));
                IImage   happyFace = provider.LoadImage("Assets/thumbs-up.png");
                GUIImage img       = new GUIImage(window, happyFace);
                img.LocalXform.Translate(provider.MakePoint2D(100, 100));
                img.LocalXform.Rotate(72f);
                IFont fnt       = gp.MakeFont("courier", 28);
                Label testLabel = new Label(window, "Test Label", fnt);
                testLabel.LocalXform.Translate(provider.MakePoint2D(100, 100));
            };
            gp.Start();
        }
Beispiel #13
0
        public void DrawCommonLayers()
        {
            XElement commonLayers = symbolManager.GetCommonLayers();

            foreach (XElement commonLayer in commonLayers.Elements())
            {
                string plugin = commonLayer.Attribute("plugin").Value;

                IGraphicsProvider tool = this.GetPlugin(plugin);

                if (tool != null)
                {
                    tool.Chart  = chartBox;
                    tool.Data   = commonLayer;
                    tool.Config = new ConfigManager(plugin);
                    tool.ActivateCommon();
                }
            }
        }
Beispiel #14
0
        public GtkDrawspace(GraphicsProvider provider, Rect2D subrect)
        {
            Provider             = provider;
            _lastPaintTime       = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond;
            _window              = new Window("Drawspace");
            _window.DeleteEvent += OnWindowDeleteEvent;
            _window.SetDefaultSize((int)subrect.Size.X, (int)subrect.Size.Y);
            _window.Move((int)subrect.Position.X, (int)subrect.Position.Y);
            _skiaView = new SKDrawingArea();
            _skiaView.PaintSurface += OnPaintSurface;
            _skiaView.Show();
            _window.Child = _skiaView;

            TEXTALIGN[(int)IDrawspace.HORIZONTAL_ALIGNMENT.LEFT]   = SKTextAlign.Left;
            TEXTALIGN[(int)IDrawspace.HORIZONTAL_ALIGNMENT.CENTER] = SKTextAlign.Center;
            TEXTALIGN[(int)IDrawspace.HORIZONTAL_ALIGNMENT.RIGHT]  = SKTextAlign.Right;
            _skiaView.PaintSurface += OnPaintSurface;
            // init matrix stack
            _xformStack.Push(SKMatrix.MakeIdentity());
            _window.ShowAll();
        }
Beispiel #15
0
        public Frame(string name, IGraphicsProvider component)
        {
            Name = name;

            this._nodeObject = component;
            if (component != null)
            {
                component.OnNodeAttach(this);
            }

            var notiServ = Service.Get <INotificationService>();

            if (notiServ != null)
            {
                notiServ.OnObjectCreated(this);
            }

            var logServ = Service.Get <ILogService>();

            if (logServ != null)
            {
                logServ.WriteLine("SceneNode Created :" + name ?? "");
            }
        }
Beispiel #16
0
        //
        // GetPlugin
        //

        private IGraphicsProvider GetPlugin(string FileName)
        {
            Assembly pluginAssembly = Assembly.LoadFrom(@"Plugins\" + FileName + ".dll");

            foreach (Type pluginType in pluginAssembly.GetTypes())
            {
                if (pluginType.IsPublic)
                {
                    if (!pluginType.IsAbstract)
                    {
                        Type typeInterface = pluginType.GetInterface("GraphicsInterface.IGraphicsProvider", true);

                        if (typeInterface != null)
                        {
                            IGraphicsProvider plugin = (IGraphicsProvider)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
                            pluginAssembly = null;
                            return(plugin);
                        }
                    }
                }
            }

            return(null);
        }
Beispiel #17
0
 /// <summary>
 /// Creates a new <see cref="DisplayProperties"/> instance with the given
 /// <see cref="IGraphicsProvider"/>.
 /// </summary>
 /// <param name="graphicsProvider"></param>
 public DisplayProperties(IGraphicsProvider graphicsProvider)
 {
     _graphicsProvider = graphicsProvider.ThrowIfNull(nameof(graphicsProvider));
 }
 public GraphicsProviderObserver(IGraphicsProvider graphicsProvider, GraphicsOverlay overlay)
 {
     _graphicsProvider = graphicsProvider;
     _overlay          = overlay;
 }
Beispiel #19
0
        /*public void RedrawLayers()
         * {
         *      chartBox.Image = (Bitmap)chartBox.PureImage.Clone();
         *
         *      foreach(IGraphicsProvider plugin in instances)
         *      {
         *              plugin.Activate();
         *      }
         * }*/

        public void DrawLayers()
        {
            chartBox.SizeChanged -= sizeChanged;

            chartBox.Image = (Bitmap)chartBox.PureImage.Clone();
            instances      = new List <IGraphicsProvider>();

            foreach (XElement x in layers.Elements())
            {
                //
                // New in Alpha-2
                //

                // Не хочет нормально итерировать layers

                if ((bool)x.Attribute("chart") == true)
                {
                    Guid uid = (Guid)x.Attribute("uid");

                    if (panel.DisplayedUIDs.Contains(uid))
                    {
                        return;
                    }
                }

                // end

                string plugin = x.Attribute("plugin").Value;

                IGraphicsProvider tool = this.GetPlugin(plugin);

                if (tool != null)
                {
                    tool.Chart  = chartBox;
                    tool.Data   = x;
                    tool.Config = new ConfigManager(plugin);

                    panel.DisplayedUIDs.Add((Guid)x.Attribute("uid"));
                    instances.Add(tool);

                    tool.Activate();

                    if ((bool)x.Attribute("chart") == true)
                    {
                        chartBox.CalculateAll();
                        this.DrawCommonLayers();
                        chartBox.DrawAll();

                        chartBox.Image = (Bitmap)chartBox.PureImage.Clone();

                        chartBox.DisposePrice();
                        chartBox.DrawPrice();
                    }
                }
                else
                {
                    MessageBox.Show("Can not find plugin: " + x.Attribute("plugin").Value);
                }
            }

            chartBox.SizeChanged += sizeChanged;
        }
Beispiel #20
0
 public MapViewModel(IGraphicsProvider graphicsProvider)
 {
     _graphicsProvider = graphicsProvider;
     CreateOverlays();
 }
Beispiel #21
0
 public void GraphicsInit(IGraphicsProvider graphicsProvider)
 {
     OnGUInit?.Invoke(this);
 }