Example #1
0
        protected override void UpdateDrawNode(DrawNode node)
        {
            if (transformDirty)
            {
                CacheTransform();
            }
            if (colorDirty)
            {
                CacheColor();
            }

            if (spriteNameDirty)
            {
                spriteNameDirty = false;

                spriteData          = file.spriteDict[spriteName];
                originalAspectRatio = spriteData.size.x / spriteData.size.y;
            }

            var n = (Node)node;

            n.color  = cachedColor;
            n.uvQuad = spriteData.uvQuad;
            if (useLayout)
            {
                n.quad = cachedMatConcat * new Quad(0, 0, cachedSize.x, cachedSize.y);
            }
            else
            {
                n.quad = cachedMatConcat * new Quad(spriteData.rect);
            }
        }
Example #2
0
        public override BaseNode AddNode(DrawNode drawNode, float x, float y, string title)
        {
            BaseNode n = base.AddNode(drawNode, x, y, title);

            n.BehaviourGraph = this;
            return(n);
        }
Example #3
0
        protected override void ApplyDrawNode(DrawNode node)
        {
            base.ApplyDrawNode(node);

            var scalingMatrix = Matrix3.CreateScale(DrawSize.X, DrawSize.Y, 1.0f);

            foreach (var part in parts)
            {
                part.ScreenSpaceQuad = part.Quad * scalingMatrix * DrawInfo.Matrix;
            }

            LaserDrawNode n = node as LaserDrawNode;

            n.ScreenSpaceDrawQuad = ScreenSpaceDrawQuad;
            n.DrawRectangle       = DrawRectangle;
            n.Texture             = Texture.WhitePixel;
            n.WrapTexture         = WrapTexture;
            n.Parts = parts;

            n.DrawInfo             = DrawInfo;
            n.InvalidationID       = 0;
            n.TextureShader        = TextureShader;
            n.RoundedTextureShader = RoundedTextureShader;
            n.InflationAmount      = InflationAmount;
        }
Example #4
0
        protected override void AddedToScene()
        {
            base.AddedToScene();
            DrawNode.Clear();

            var blocks = HelpText.Split(new[] { "$" }, StringSplitOptions.RemoveEmptyEntries);

            var   rects  = new CCRect[blocks.Length];
            float margin = VisibleBoundsWorldspace.Size.Width / 1080 * 10;
            float width  = VisibleBoundsWorldspace.Size.Width - margin * 2;
            float height = VisibleBoundsWorldspace.Size.Height / blocks.Length;


            for (int i = 0; i < blocks.Length; i++)
            {
                float x = VisibleBoundsWorldspace.MinX + margin;
                float y = VisibleBoundsWorldspace.MaxY - margin - height * (i + 1);
                rects[i] = new CCRect(x, y, width, height);
            }

            for (int i = 0; i < rects.Length; i++)
            {
                DrawNode.DrawText(rects[i].Center, blocks[i].Replace("$", ""), Font.ArialFonts[VisualSettings.HelpTextFontSize], rects[i].Size * 0.95f);
            }
        }
Example #5
0
        public override void Update(float dt)
        {
            base.Update(dt);
            if (!RedrawRequested)
            {
                return;
            }
            RedrawRequested = false;

            DrawNode.Clear();
            List <HexagonNode> handledPositions = new List <HexagonNode>();

            foreach (var structure in World.StructureManager)
            {
                if (structure is Construction)
                {
                    continue;
                }
                handledPositions.Add(structure.Position);
                foreach (var accessibleNode in structure.Position.GetAccessibleAdjacentHexagonNodes(World.HexagonManager).Where(h => !handledPositions.Contains(h)))
                {
                    var p1    = structure.Position.GetWorldPosition(World.GameSettings.LayoutSettings.HexagonRadius, World.GameSettings.LayoutSettings.HexagonMargin);
                    var p2    = accessibleNode.GetWorldPosition(World.GameSettings.LayoutSettings.HexagonRadius, World.GameSettings.LayoutSettings.HexagonMargin);
                    var color = World.GameSettings.VisualSettings.ColorCollection.EdgeBackground;
                    DrawNode.DrawSegment(p1, p2, World.GameSettings.VisualSettings.EdgeThickness, color);
                }
            }
        }
Example #6
0
        internal void UpdateDrawNode()
        {
            var         bounds         = VisibleBoundsWorldspace;
            const float LINE_WIDTH     = 20f;
            const float BAR_WIDTH      = 40f;
            const float BAR_BOX_HEIGHT = BAR_WIDTH + LINE_WIDTH * 2;
            float       barBoxWidth    = bounds.Size.Width - MULTIPL_BOX_SIZE.Width;

            DrawNode.Clear();
            // draw the combo bar box and the multiplier box
            DrawNode.DrawRect(new CCRect(0, 0, barBoxWidth, BAR_BOX_HEIGHT), CCColor4B.White);
            DrawNode.DrawRect(new CCRect(barBoxWidth, 0, MULTIPL_BOX_SIZE.Width, MULTIPL_BOX_SIZE.Height), CCColor4B.White);
            DrawNode.DrawRect(new CCRect(barBoxWidth + LINE_WIDTH, LINE_WIDTH, MULTIPL_BOX_SIZE.Width - 2 * LINE_WIDTH, MULTIPL_BOX_SIZE.Height - 2 * LINE_WIDTH), CCColor4B.Black);
            // draw the combo bar
            CCRect barFull = new CCRect(LINE_WIDTH, LINE_WIDTH, barBoxWidth - 2 * LINE_WIDTH, BAR_WIDTH);
            CCRect bar     = new CCRect(LINE_WIDTH, LINE_WIDTH, barFull.Size.Width * MultiplProgressVisible, BAR_WIDTH);
            // choose the color
            var barColor       = MultiplierBarColor(Multiplier);
            var barColorBehind = MultiplierBarColor(Multiplier - 1);

            DrawNode.DrawRect(barFull, barColorBehind);
            DrawNode.DrawRect(bar, barColor);
            //DrawNode.DrawPolygon(new CCPoint[] { CCPoint.Zero, new CCPoint(barBoxWidth, 0), new CCPoint(barBoxWidth, 0), new CCPoint(barBoxWidth, BAR_BOX_HEIGHT), new CCPoint(0, BAR_BOX_HEIGHT) }, 4, CCColor4B.Transparent, LINE_WIDTH, CCColor4B.White);    // bar box
            //DrawNode.DrawPolygon(new CCPoint[] { new CCPoint(barBoxWidth, 0), new CCPoint(bounds.Size.Width, 0), new CCPoint(bounds.Size.Width, MULTIPL_BOX_SIZE.Height), new CCPoint(barBoxWidth, MULTIPL_BOX_SIZE.Height) }, 4, CCColor4B.Transparent, LINE_WIDTH, CCColor4B.White);    // multiplier box
        }
Example #7
0
        private void updateLoop()
        {
            //this was added due to the dependency on GLWrapper.MaxTextureSize begin initialised.
            while (!GLWrapper.IsInitialized)
            {
                Thread.Sleep(1);
            }

            while (!exitRequested)
            {
                UpdateMonitor.NewFrame(UpdateClock);

                using (UpdateMonitor.BeginCollecting(PerformanceCollectionType.Scheduler))
                {
                    updateScheduler.Update();
                }

                using (UpdateMonitor.BeginCollecting(PerformanceCollectionType.Update))
                {
                    UpdateSubTree();
                    pendingRootNode = GenerateDrawNodeSubtree();
                }

                using (UpdateMonitor.BeginCollecting(PerformanceCollectionType.Sleep))
                {
                    UpdateClock.ProcessFrame();
                }
            }
        }
Example #8
0
        protected override void ApplyDrawNode(DrawNode node)
        {
            PathDrawNode n = (PathDrawNode)node;

            n.Texture              = Texture;
            n.TextureShader        = textureShader;
            n.RoundedTextureShader = roundedTextureShader;
            n.Width    = PathWidth;
            n.DrawSize = DrawSize;

            n.Shared = pathDrawNodeSharedData;

            n.Segments.Clear();

            if (positions.Count > 1)
            {
                Vector2 offset = new Vector2(minX, minY);
                for (int i = 0; i < positions.Count - 1; ++i)
                {
                    n.Segments.Add(new Line(positions[i] - offset, positions[i + 1] - offset));
                }
            }

            base.ApplyDrawNode(node);
        }
Example #9
0
        protected override void ApplyDrawNode(DrawNode node)
        {
            PathDrawNode n = node as PathDrawNode;

            n.NeedsDepthTest       = true;
            n.Texture              = Texture;
            n.TextureShader        = textureShader;
            n.RoundedTextureShader = roundedTextureShader;
            n.Width = PathWidth;

            n.Shared = pathDrawNodeSharedData;

            n.Segments.Clear();

            if (positions.Count > 1)
            {
                Vector2 offset = new Vector2(minX, minY);
                for (int i = 0; i < positions.Count - 1; ++i)
                {
                    Line line = new Line(positions[i] - offset, positions[i + 1] - offset);
                    n.Segments.Add(new Line(line.StartPoint, line.EndPoint));
                }
            }

            base.ApplyDrawNode(node);
        }
Example #10
0
        /// <summary>
        /// Draw a single node
        /// </summary>
        protected override void Draw(DrawNode node)
        {
            var shader = GetDefaultShader(node.image);

            if (_batch.Image != node.image || _batch.Shader != shader || _batch.DrawNodeType != node.Type)
            {
                _batch.Commit();
            }

            switch (node.Type)
            {
            case DrawNodeType.Quad:
                _batch.Image        = node.image as OpenGLImage;
                _batch.DrawNodeType = node.Type;
                _batch.Shader       = shader;
                if (!_batch.Add(node.quad, node.color))
                {
                    _batch.Commit();
                    _batch.Add(node.quad, node.color);
                }
                break;

            case DrawNodeType.DebugLine:
                _batch.Image        = null;
                _batch.DrawNodeType = node.Type;
                _batch.Shader       = shader;
                if (!_batch.Add(node.quad.TL, node.quad.TR, node.color))
                {
                    _batch.Add(node.quad.TL, node.quad.TR, node.color);
                    _batch.Commit();
                }
                break;
            }
        }
Example #11
0
 public Scene(string name)
 {
     _name = name;
     _root = new DrawNode();
     _eventManager = new EventManager();
     //Add the default event;
     _eventManager.AddEventType(new EventController(Constants.TIME_TICKS_EVENT));
 }
Example #12
0
        protected override void ApplyDrawNode(DrawNode node)
        {
            ContainerDrawNode n = node as ContainerDrawNode;

            n.MaskingRect = Masking ? ScreenSpaceDrawQuad.AABB : (Rectangle?)null;

            base.ApplyDrawNode(node);
        }
Example #13
0
 private static void RemoveHandlers(DrawNode node, ISignal signal)
 {
     if (node == null || signal == null)
         return;
     SignalHandler element;
     if (Handlers.TryGetValue(node, out element))
         element.RemoveHandlers(signal);
 }
Example #14
0
 private void Render()
 {
     DrawNode.Clear();
     foreach (var hexagon in World.HexagonManager)
     {
         RenderHexagon(hexagon);
     }
 }
        protected override void ApplyDrawNode(DrawNode node)
        {
            base.ApplyDrawNode(node);

            var testNode = (TestDrawNode)node;

            testNode.TestSharedData = sharedData;
            testNode.Iterations     = iterationsBindable.Value;
        }
Example #16
0
        protected override void ApplyDrawNode(DrawNode node)
        {
            base.ApplyDrawNode(node);
            HoldDrawNode n = node as HoldDrawNode;

            n.HoldShader = holdShader;

            base.ApplyDrawNode(node);
        }
Example #17
0
        public void DrawCircle(CCPoint position, float radius, CCColor4B fillColor, float borderThickness, CCColor4B borderColor, CircleBorderPosition borderPosition = CircleBorderPosition.HalfHalf)
        {
            float borderOffset = borderPosition == CircleBorderPosition.Inside ? 0 : (borderPosition == CircleBorderPosition.Outside ? borderThickness : borderThickness / 2);
            float radiusOffset = borderPosition == CircleBorderPosition.Inside ? -borderThickness : (borderPosition == CircleBorderPosition.Outside ? 0 : -borderThickness / 2);

            // Border Circle
            DrawNode.DrawSolidCircle(position, radius + borderOffset, borderColor);
            // Normal Circle
            DrawNode.DrawSolidCircle(position, radius + radiusOffset, fillColor);
        }
Example #18
0
        protected override void ApplyDrawNode(DrawNode node)
        {
            BoxDrawNode n = node as BoxDrawNode;

            n.ScreenSpaceDrawQuad = ScreenSpaceDrawQuad;
            n.Batch = quadBatch;
            n.Game  = Game;

            base.ApplyDrawNode(node);
        }
Example #19
0
        private void Render()
        {
            DrawNode.Clear();
            var settings = World.GameSettings;

            foreach (var structure in Structures)
            {
                structure.Render(DrawNode, structure.Position.GetWorldPosition(settings.LayoutSettings.HexagonRadius, settings.LayoutSettings.HexagonMargin), settings.VisualSettings.BuildingRadius);
            }
        }
Example #20
0
        internal void SetSize(CCSize size)
        {
            ContentSize = size;
            DrawNode.Clear();
            DrawNode.DrawRect(new CCRect(0, 0, size.Width, size.Height), CCColor4B.White);
            DrawNode.DrawRect(new CCRect(BORDER, BORDER, size.Width - 2 * BORDER, size.Height - 2 * BORDER), CCColor4B.Black);
            var mathSize = new CCSize(size.Width - 12 * BORDER, size.Height - 12 * BORDER);

            MathSprite.FitToBox(mathSize);
            MathSprite.Position = (CCPoint)ContentSize / 2;
        }
        protected override void ApplyDrawNode(DrawNode node)
        {
            BufferedContainerDrawNode n = node as BufferedContainerDrawNode;

            n.ScreenSpaceDrawQuad = ScreenSpaceDrawQuad;
            n.Batch       = quadBatch;
            n.FrameBuffer = frameBuffer;
            n.Formats     = new List <RenderbufferInternalFormat>(attachedFormats);

            base.ApplyDrawNode(node);
        }
Example #22
0
            protected override void ApplyDrawNode(DrawNode node)
            {
                base.ApplyDrawNode(node);

                var flashNode = (FlashlightDrawNode)node;

                flashNode.Shader = shader;
                flashNode.ScreenSpaceDrawQuad = ScreenSpaceDrawQuad;
                flashNode.FlashlightPosition  = Vector2Extensions.Transform(FlashlightPosition, DrawInfo.Matrix);
                flashNode.FlashlightSize      = Vector2Extensions.Transform(FlashlightSize, DrawInfo.Matrix);
            }
        public override BaseNode AddNode(DrawNode drawNode, float x, float y, string title)
        {
            BaseNode n = base.AddNode(drawNode, x, y, title);

            n.DialogGraph = this;
            if (firstSubtitles.transitions.Count == 0)
            {
                SetAsEnterState(firstSubtitles, n, Colors.ORANGE);
            }
            return(n);
        }
Example #24
0
        protected override void ApplyDrawNode(DrawNode node)
        {
            SpriteDrawNode n = node as SpriteDrawNode;

            n.ScreenSpaceDrawQuad = ScreenSpaceDrawQuad;
            n.Texture             = Texture;
            n.WrapTexture         = WrapTexture;
            n.Game = Game;

            base.ApplyDrawNode(node);
        }
Example #25
0
        protected override void ApplyDrawNode(DrawNode node)
        {
            base.ApplyDrawNode(node);

            var visNode = (VisualisationDrawNode)node;

            visNode.Shader    = shader;
            visNode.Texture   = texture;
            visNode.Size      = DrawSize.X;
            visNode.Colour    = AccentColour;
            visNode.AudioData = frequencyAmplitudes;
        }
Example #26
0
        private static void ProccessSignal(DrawNode node, ISignal signal)
        {
            SignalHandler handler;
            if (Handlers.TryGetValue(node, out handler))
                handler.TryHandleSignal(signal);

            if (node.ChildrenCount == 0)
                return;

            foreach (var child in node.Children)
                ProccessSignal(child, signal);
        }
Example #27
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Client.Common.Views.WorldLayerHex"/> class.
        /// </summary>
        /// <param name="gameScene">Game scene.</param>
        public WorldLayerHex(GameScene gameScene)
            : base()
        {
            m_gameScene = gameScene;

            ViewMode = ViewModes.CurrentGPSPosition;

            m_currentWorldPoint = PositionHelper.PositionToWorldspace(Geolocation.Instance.CurrentGamePosition);
            m_regionViewHexDic = new Dictionary<RegionPosition, RegionViewHex>();
            m_geolocationPositionNode = new DrawNode();
            m_touchHandler = new TileTouchHandler(this);
            this.AddChild(m_geolocationPositionNode);
        }
        protected override void ApplyDrawNode(DrawNode node)
        {
            var n = (WaveformDrawNode)node;

            n.Shader   = shader;
            n.Texture  = texture;
            n.DrawSize = DrawSize;
            n.Shared   = sharedData;
            n.Points   = generatedWaveform?.GetPoints();
            n.Channels = generatedWaveform?.GetChannels() ?? 0;

            base.ApplyDrawNode(node);
        }
Example #29
0
        private static void AddHandler(DrawNode node, ISignal signal, Action handler)
        {
            if (handler == null)
                return;

            SignalHandler element;
            if (!Handlers.TryGetValue(node, out element))
            {
                element = new SignalHandler();
                Handlers.Add(node, element);
            }
            element.AddHandler(signal, handler);
        }
Example #30
0
 private void Render()
 {
     DrawNode.Clear();
     foreach (var kvp in Packages)
     {
         var package  = kvp.Key;
         var radius   = World.GameSettings.VisualSettings.ResourcePackageRadius;
         var position = package.GetWorldPosition(World.GameSettings.LayoutSettings.HexagonRadius, World.GameSettings.LayoutSettings.HexagonMargin);
         //DrawNode.DrawCircle(position, radius, World.GameSettings.VisualSettings.ColorCollection.ResourcePackageBackground, 3, World.GameSettings.VisualSettings.ColorCollection.ResourcePackageBorder);
         kvp.Value.Position    = position;
         kvp.Value.ContentSize = new CCSize(radius * 2, radius * 2) * 1f;
     }
 }
Example #31
0
        protected virtual void UpdateDrawNode(DrawNode node)
        {
            node.age = age;

            if (transformDirty)
            {
                CacheTransform();
            }
            if (colorDirty)
            {
                CacheColor();
            }
        }
Example #32
0
 public void DrawTriangle(CCV3F_C4B[] corners, float borderThickness, CCColor4B borderColor)
 {
     DrawNode.DrawTriangleList(corners);
     if (borderThickness > 0)
     {
         for (int i = 0; i < 3; i++)
         {
             var p1 = corners[i].Vertices;
             var p2 = corners[(i + 1) % 3].Vertices;
             DrawNode.DrawLine(new CCPoint(p1.X, p1.Y), new CCPoint(p2.X, p2.Y), borderThickness, borderColor);
         }
     }
 }
Example #33
0
        private void Render()
        {
            {
                DrawNode.Clear();
                var   visualSettings = World.GameSettings.VisualSettings;
                int   fontSize       = visualSettings.StatisticsFontSize;
                var   spriteSize     = fontSize * 2f;
                var   margin         = 10;
                float x  = visualSettings.StatisticsMargin;
                float y0 = VisibleBoundsWorldspace.MaxY - visualSettings.StatisticsMargin - spriteSize * 0 - margin * 0;
                float y1 = VisibleBoundsWorldspace.MaxY - visualSettings.StatisticsMargin - spriteSize * 1 - margin * 1;
                float y2 = VisibleBoundsWorldspace.MaxY - visualSettings.StatisticsMargin - spriteSize * 2 - margin * 2;
                float y3 = VisibleBoundsWorldspace.MaxY - visualSettings.StatisticsMargin - spriteSize * 3 - margin * 3;

                var resourceManager = World.GlobalResourceManager;

                var s0 = resourceManager.EnvironmentResource.Energy.ToString(CultureInfo.InvariantCulture);
                var s1 = resourceManager.Knowledge.Knowledge1.ToString();
                var s2 = resourceManager.Knowledge.Knowledge2.ToString();
                var s3 = resourceManager.Knowledge.Knowledge3.ToString();
                DrawNode.DrawText(x + spriteSize - spriteSize / 8 + (float)Sqrt(s0.Length) / 1.5f * fontSize, y0, s0, Font.ArialFonts[fontSize], CCSize.Zero);
                DrawNode.DrawText(x + spriteSize - spriteSize / 8 + (float)Sqrt(s1.Length) / 1.5f * fontSize, y1, s1, Font.ArialFonts[fontSize], CCSize.Zero);
                DrawNode.DrawText(x + spriteSize - spriteSize / 8 + (float)Sqrt(s2.Length) / 1.5f * fontSize, y2, s2, Font.ArialFonts[fontSize], CCSize.Zero);
                DrawNode.DrawText(x + spriteSize - spriteSize / 8 + (float)Sqrt(s3.Length) / 1.5f * fontSize, y3, s3, Font.ArialFonts[fontSize], CCSize.Zero);

                DrawNode.DrawCircle(new CCPoint(x, y0), spriteSize / 2, CCColor4B.White);
                DrawNode.DrawCircle(new CCPoint(x, y1), spriteSize / 2, CCColor4B.White);
                DrawNode.DrawCircle(new CCPoint(x, y2), spriteSize / 2, CCColor4B.White);
                DrawNode.DrawCircle(new CCPoint(x, y3), spriteSize / 2, CCColor4B.White);

                EnergySprite.Position     = new CCPoint(x, y0);
                Knowledge1Sprite.Position = new CCPoint(x, y1);
                Knowledge2Sprite.Position = new CCPoint(x, y2);
                Knowledge3Sprite.Position = new CCPoint(x, y3);

                EnergySprite.ContentSize = Knowledge1Sprite.ContentSize = Knowledge2Sprite.ContentSize = Knowledge3Sprite.ContentSize = new CCSize(spriteSize * 0.8f, spriteSize * 0.8f);
            }
            {
                var colorCollection = World.GameSettings.VisualSettings.ColorCollection;
                var margin          = World.GameSettings.VisualSettings.StatisticsMargin;
                var radius          = 45;
                var x        = VisibleBoundsWorldspace.MaxX - margin;
                var y        = VisibleBoundsWorldspace.MaxY - margin;
                var position = new CCPoint(x, y);
                DrawNode.DrawCircle(position, radius, colorCollection.FastForewardBackground, 2, colorCollection.FastForewardBorder);
                FastForewardSprite.Color       = new CCColor3B(World.GameSpeed.GetColor(colorCollection));
                FastForewardSprite.Position    = position + new CCPoint(2, 0);
                FastForewardSprite.ContentSize = new CCSize(radius * 2, radius * 2) * 0.8f;
            }
            RenderEnvironmentValues();
        }
        private void disposeRecursively(DrawNode drawNode)
        {
            drawNode.Dispose();

            if (!(drawNode is ICompositeDrawNode composite))
            {
                return;
            }

            foreach (var child in composite.Children)
            {
                disposeRecursively(child);
            }
        }
Example #35
0
        protected override void ApplyDrawNode(DrawNode node)
        {
            base.ApplyDrawNode(node);

            var trianglesNode = (TrianglesDrawNode)node;

            trianglesNode.Shader  = shader;
            trianglesNode.Texture = texture;
            trianglesNode.Size    = DrawSize;
            trianglesNode.Shared  = sharedData;

            trianglesNode.Parts.Clear();
            trianglesNode.Parts.AddRange(parts);
        }
Example #36
0
        protected override void ApplyDrawNode(DrawNode node)
        {
            base.ApplyDrawNode(node);

            TrailDrawNode tNode = node as TrailDrawNode;
            tNode.Shader = shader;
            tNode.Texture = texture;
            tNode.Size = size;
            tNode.Time = time;
            tNode.Shared = trailDrawNodeSharedData;

            for (int i = 0; i < parts.Length; ++i)
                if (parts[i].InvalidationID > tNode.Parts[i].InvalidationID)
                    tNode.Parts[i] = parts[i];
        }
Example #37
0
        /// <summary>
        /// Слушатель событий
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private new void Events(object sender, FPBTreeEventArgs e)
        {
            if (e is SplitEventArgs)
            {
                var temp = e as SplitEventArgs;
                listBox1.Invoke(new Action(() =>
                    {
                        listBox1.Items.Add(string.Format("{0}, In-Page? {1}", temp.Message, temp.IsInPage));
                        listBox1.SelectedIndex = listBox1.Items.Count - 1;
                    }));
            }
            if (e is TransferEventArgs)
            {
                if (!happyEnd)
                {
                    var temp = e as TransferEventArgs;
                    if (temp.IsTuple)
                    {
                        pictureBox1.Invoke(new Action(() =>
                            {
                                Graphics gc1 = Graphics.FromImage(pictureBox1Image);
                                Draw.DrawPair(currentGeneralNode, currentGeneralNode.ChildrenList[temp.NumberOfChild], gc1, false);
                                currentGeneralNode = currentGeneralNode.ChildrenList[temp.NumberOfChild];
                                pictureBox1.Image = pictureBox1Image;
                                UpdateTB(currentGeneralNode.Node.Root);
                            }));
                        pictureBox2.Invoke(new Action(() =>
                            {
                                Graphics gc1 = Graphics.FromImage(pictureBox1Image);
                                Draw.DrawNode(currentGeneralNode, gc1);
                                pictureBox1.Image = pictureBox1Image;
                                inPageRoot = new DrawNode();
                                inPageZone.Clear();
                                pictureBox2Image = new Bitmap(730, 260);
                                Graphics gc = Graphics.FromImage(pictureBox2Image);
                                Draw.Preparing<FPBTreeNode.InPageNode>(currentGeneralNode.Node.Root, gc, inPageZone, inPageRoot, true);
                                pictureBox2.Image = pictureBox2Image;
                                trace.Clear();
                                UpdateTB(currentInPageNode.InPageNode);
                            }));
                    }
                    else
                    {
                        pictureBox2.Invoke(new Action(() =>
                            {
                                Graphics gc1 = Graphics.FromImage(pictureBox1Image);
                                Draw.DrawNode(currentGeneralNode, gc1);
                                pictureBox1.Image = pictureBox1Image;
                                inPageZone.Clear();
                                currentInPageNode.ChildrenList.Clear();
                                Draw.Preparing<FPBTreeNode.InPageNode>(currentGeneralNode.Node.Root, null, inPageZone, currentInPageNode, false);
                                foreach (var i in trace)
                                    currentInPageNode = currentInPageNode.ChildrenList[i];
                                trace.Add(temp.NumberOfChild);
                                var gc2 = Graphics.FromImage(pictureBox2Image);
                                Draw.DrawPair(currentInPageNode, currentInPageNode.ChildrenList[temp.NumberOfChild], gc2, false);
                                currentInPageNode = currentInPageNode.ChildrenList[temp.NumberOfChild];
                                pictureBox2.Image = pictureBox2Image;
                                UpdateTB(currentInPageNode.InPageNode);
                            }));
                    }
                    listBox1.Invoke(new Action(() =>
                        {
                            listBox1.Items.Add(string.Format("{0}", temp.Message));
                            listBox1.Items.Add(string.Format("Номер ребенка:{0}", temp.NumberOfChild));
                            listBox1.SelectedIndex = listBox1.Items.Count - 1;
                        }));
                    if (manualStep)
                    {
                        add.Invoke(new Action(() => add.Enabled = false));
                        delete.Invoke(new Action(() => delete.Enabled = false));
                        find.Invoke(new Action(() => find.Enabled = false));
                        checkBox1.Invoke(new Action(() => checkBox1.Enabled = false));
                        are.WaitOne();
                    }
                    else
                        Thread.Sleep(ms);
                }
            }
            if (e is RemoveEventArgs)
            {
                var temp = e as RemoveEventArgs;
                listBox1.Invoke(new Action(() =>
                    {
                        if (temp.Data == int.MaxValue)
                            listBox1.Items.Add(string.Format("{0}.", temp.Message));
                        else
                        {
                            listBox1.Items.Add(string.Format("{0}", temp.Message));
                            listBox1.Items.Add(string.Format("{0} удалено.", temp.Data));
                        }
                        listBox1.SelectedIndex = listBox1.Items.Count - 1;
                    }));

                if (manualStep)
                {
                    add.Invoke(new Action(() => add.Enabled = false));
                    delete.Invoke(new Action(() => delete.Enabled = false));
                    find.Invoke(new Action(() => find.Enabled = false));
                    checkBox1.Invoke(new Action(() => checkBox1.Enabled = false));
                    are.WaitOne();
                }
                else
                    Thread.Sleep(ms);
            }
            if (e is BalanceEventArgs)
            {
                var temp = e as BalanceEventArgs;
                listBox1.Invoke(new Action(() =>
                    {
                        listBox1.Items.Add(temp.Message);
                        listBox1.SelectedIndex = listBox1.Items.Count - 1;
                    }));
            }
            if (e is EndEventArgs)
            {
                happyEnd = true;
                var temp = e as EndEventArgs;
                var st = temp.Message.Split('-');
                if (st.Length == 1)
                {
                    listBox1.Invoke(new Action(() =>
                        {
                            if (int.MaxValue == temp.Data)
                                listBox1.Items.Add(string.Format("{0}", temp.Message));
                            else
                                if (int.MinValue != temp.Data)
                                    listBox1.Items.Add(string.Format("{0} {1}", temp.Message, temp.Data));
                            listBox1.SelectedIndex = listBox1.Items.Count - 1;
                        }));
                }
                else
                    listBox1.Invoke(new Action(() =>
                        {
                            listBox1.Items.Add(st[0]);
                            listBox1.Items.Add(st[1]);
                            listBox1.SelectedIndex = listBox1.Items.Count - 1;
                        }));
                add.Invoke(new Action(() => add.Enabled = true));
                delete.Invoke(new Action(() => delete.Enabled = true));
                find.Invoke(new Action(() => find.Enabled = true));
                checkBox1.Invoke(new Action(() => checkBox1.Enabled = true));
            }
        }
Example #38
0
        /// <summary>
        /// Метод для передачи в System.Thread
        /// Поиск элемента
        /// </summary>
        /// <returns></returns>
        private void FindElement()
        {
            happyEnd = false;
            trace.Clear();

            currentGeneralNode = generalRoot;
            currentInPageNode = inPageRoot;

            tree.FindElement(tree.Root.Root, int.Parse(textBox1.Text));

            pictureBox1Image = new Bitmap(730, 260);
            pictureBox2Image = new Bitmap(730, 260);

            if (lastInPageChoice != null)
                UpdateTB(lastInPageChoice.InPageNode);

            generalZone.Clear();
            generalRoot = new DrawNode();
            Graphics gc = Graphics.FromImage(pictureBox1Image);
            Draw.Preparing<FPBTreeNode.Node>(tree.Root, gc, generalZone, generalRoot, true);
            currentGeneralNode = generalRoot;
            pictureBox1.Image = pictureBox1Image;

            inPageZone.Clear();
            inPageRoot = new DrawNode();
            Graphics temp = Graphics.FromImage(pictureBox2Image);
            Draw.Preparing<FPBTreeNode.InPageNode>(generalRoot.Node.Root, temp, inPageZone, inPageRoot, true);
            currentInPageNode = inPageRoot;
            pictureBox2.Image = pictureBox2Image;
        }
Example #39
0
        public void ChangeTree(int nonLeafNodeMaxSize, int LeafNodeMaxSize, int inPageLeafNodeMaxSize, int inPageNonLeafNodeMaxSize)
        {
            this.NonLeafNodeMaxSize = nonLeafNodeMaxSize;
            this.LeafNodeMaxSize = LeafNodeMaxSize;
            this.InPageLeafNodeMaxSize = inPageLeafNodeMaxSize;
            this.InPageNonLeafMaxSize = inPageNonLeafNodeMaxSize;
            tree = new FPBTree.FPBTree(this.NonLeafNodeMaxSize, this.LeafNodeMaxSize, this.InPageLeafNodeMaxSize, this.InPageNonLeafMaxSize);
            tree.events += this.Events;
            pictureBox1Image = new Bitmap(730, 260);
            pictureBox2Image = new Bitmap(730, 260);
            Draw.MakeDrawTree<FPBTreeNode.Node>(tree.Root, generalRoot, 0);
            Draw.MakeDrawTree<FPBTreeNode.InPageNode>(generalRoot.Node.Root, inPageRoot, 0);
            generalZone.Clear();
            generalRoot = new DrawNode();
            Graphics gc = Graphics.FromImage(pictureBox1Image);
            Draw.Preparing<FPBTreeNode.Node>(tree.Root, gc, generalZone, generalRoot, true);
            currentGeneralNode = generalRoot;
            pictureBox1.Image = pictureBox1Image;

            inPageZone.Clear();
            inPageRoot = new DrawNode();
            Graphics temp = Graphics.FromImage(pictureBox2Image);
            Draw.Preparing<FPBTreeNode.InPageNode>(generalRoot.Node.Root, temp, inPageZone, inPageRoot, true);
            currentInPageNode = inPageRoot;
            pictureBox2.Image = pictureBox2Image;
            UpdateTB(currentInPageNode.InPageNode);
            listBox1.Items.Clear();
        }
Example #40
0
 /// <summary>
 /// Обработка координат нажатия мыши по пикчбоксу 
 /// Поиск вершины, которая могла бы быть выбрана
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void chooseNode_Click(object sender, EventArgs e)
 {
     float xx = MousePosition.X;
     float yy = MousePosition.Y;
     foreach (Zone z in generalZone)
     {
         if (xx - x - 8 >= z.X1 && xx - x - 8 <= z.X2 && yy - y - 57 >= z.Y1 && yy - y - 57 <= z.Y2)
         {
             inPageRoot = new DrawNode();
             inPageZone.Clear();
             pictureBox2Image = new Bitmap(730, 260);
             Graphics gc = Graphics.FromImage(pictureBox2Image);
             Draw.Preparing<FPBTreeNode.InPageNode>(z.Node.Root, gc, inPageZone, inPageRoot, true);
             pictureBox2.Image = pictureBox2Image;
             lastPageChoice = z;
             UpdateTB(z.Node.Root);
             foreach (var t in inPageZone)
                 if (t.InPageNode == z.Node.Root)
                     lastInPageChoice = t;
             break;
         }
     }
 }
Example #41
0
        /// <summary>
        /// Обработчик события нажатия кнопки
        /// Удаляем элемент, введенный в textBox
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void deleteElement_Click(object sender, EventArgs e)
        {
            ms = 0;
            if (!checkBox1.Checked && !checkBox2.Checked)
                DeleteElement();
            else
            {
                if (checkBox1.Checked)
                {
                    ms = int.Parse(textBox3.Text);
                    manualStep = false;
                    if (tree.thread == null || !tree.thread.IsAlive)
                    {
                        tree.thread = new Thread(DeleteElement);
                        tree.thread.Start();
                    }
                }
                else
                {
                    manualStep = true;
                    if (tree.thread == null || !tree.thread.IsAlive)
                    {
                        tree.thread = new Thread(DeleteElement);
                        tree.thread.Start();
                    }
                }
            }

            if (lastPageChoice != null)
            {
                pictureBox2.Invoke(new Action(() =>
                    {
                        inPageZone.Clear();
                        inPageRoot = new DrawNode();
                        pictureBox2Image = new Bitmap(730, 260);
                        Graphics gc1 = Graphics.FromImage(pictureBox2Image);
                        Draw.Preparing<FPBTreeNode.InPageNode>(lastPageChoice.Node.Root, gc1, inPageZone, inPageRoot, true);
                        pictureBox2.Image = pictureBox2Image;
                    }
                ));
            }
        }
Example #42
0
 public void Initialize()
 {
     _root = new DrawNode();
     _defaultEffect = new DefaultEffect(XNADevicesManager.Instance.GraphicsDevice);
     _effectManager = EffectManager.Instance;
     _effectManager.Add(_defaultEffect);
     _input = InputManager.Instance;
     _sceneManager = SceneManager.Instance;
 }
Example #43
0
        private void очиститьДеревоToolStripMenuItem_Click(object sender, EventArgs e)
        {
            tree = new FPBTree.FPBTree(this.NonLeafNodeMaxSize, this.LeafNodeMaxSize, this.InPageLeafNodeMaxSize, this.InPageNonLeafMaxSize);
            tree.events += this.Events;
            pictureBox1Image = new Bitmap(730, 260);
            pictureBox2Image = new Bitmap(730, 260);
            Draw.MakeDrawTree<FPBTreeNode.Node>(tree.Root, generalRoot, 0);
            Draw.MakeDrawTree<FPBTreeNode.InPageNode>(generalRoot.Node.Root, inPageRoot, 0);
            generalZone.Clear();
            generalRoot = new DrawNode();
            Graphics gc = Graphics.FromImage(pictureBox1Image);
            Draw.Preparing<FPBTreeNode.Node>(tree.Root, gc, generalZone, generalRoot, true);
            currentGeneralNode = generalRoot;
            pictureBox1.Image = pictureBox1Image;

            inPageZone.Clear();
            inPageRoot = new DrawNode();
            Graphics temp = Graphics.FromImage(pictureBox2Image);
            Draw.Preparing<FPBTreeNode.InPageNode>(generalRoot.Node.Root, temp, inPageZone, inPageRoot, true);
            currentInPageNode = inPageRoot;
            pictureBox2.Image = pictureBox2Image;
            UpdateTB(currentInPageNode.InPageNode);
            listBox1.Items.Clear();
        }
Example #44
0
        /// <summary>
        /// Метод для передачи в System.Thread
        /// Удаление элемента
        /// </summary>
        private void DeleteElement()
        {
            happyEnd = false;
            trace.Clear();

            currentGeneralNode = generalRoot;
            currentInPageNode = inPageRoot;

            tree.DeleteElement(tree.Root, int.Parse(textBox1.Text));

            pictureBox1Image = new Bitmap(730, 260);
            pictureBox2Image = new Bitmap(730, 260);

            generalZone.Clear();
            generalRoot = new DrawNode();
            Graphics gc = Graphics.FromImage(pictureBox1Image);
            Draw.Preparing<FPBTreeNode.Node>(tree.Root, gc, generalZone, generalRoot, true);
            currentGeneralNode = generalRoot;
            pictureBox1.Image = pictureBox1Image;

            inPageZone.Clear();
            inPageRoot = new DrawNode();
            Graphics temp = Graphics.FromImage(pictureBox2Image);
            Draw.Preparing<FPBTreeNode.InPageNode>(generalRoot.Node.Root, temp, inPageZone, inPageRoot, true);
            currentInPageNode = inPageRoot;
            /* foreach (var t in trace)
                 if (currentInPageNode.ChildrenList != null && currentInPageNode.ChildrenList.Count>t)
                     currentInPageNode = currentInPageNode.ChildrenList[t]; */
            pictureBox2.Image = pictureBox2Image;

            if (lastPageChoice != null)
            {
                pictureBox2.Invoke(new Action(() =>
                {
                    inPageZone.Clear();
                    inPageRoot = new DrawNode();
                    pictureBox2Image = new Bitmap(730, 260);
                    Graphics gc1 = Graphics.FromImage(pictureBox2Image);
                    Draw.Preparing<FPBTreeNode.InPageNode>(lastPageChoice.Node.Root, gc1, inPageZone, inPageRoot, true);
                    pictureBox2.Image = pictureBox2Image;
                }
            ));
            }
            UpdateTB(currentInPageNode.InPageNode);
        }
Example #45
0
 public SendSignalActionState(DrawNode target, SendSignal action)
     : base(target, action)
 {
     _signal = action.Signal;
     _node = target;
 }