Пример #1
0
        public static Frame AddMapButton(Frame parent, SpriteFont font, int x, int y, int w, int h, string img, string text, Action action)
        {
            var button = new Frame(parent.Game, x, y, w, h, text, Color.Zero)
            {
                Image = parent.Game.Content.Load<Texture2D>(img),
                ImageColor = Color.Orange,
                ImageMode = FrameImageMode.Stretched,
                Font = font,
                ImageOffsetX = 0,
                TextAlignment = Alignment.MiddleCenter,
                TextOffsetY = 0,
                TextOffsetX = 0,
                Anchor = FrameAnchor.Top | FrameAnchor.Left,
                ForeColor = Color.Red,
                TextEffect = TextEffect.Shadow
            };
            button.StatusChanged += (s, e) =>
            {
                if (e.Status == FrameStatus.None) { button.ImageColor = new Color(255, 255, 255, 128); button.ForeColor = Color.Black; button.BackColor = Color.Zero; }
                if (e.Status == FrameStatus.Hovered) { button.ImageColor = Color.Orange; button.ForeColor = Color.White; button.BackColor = Color.Zero; }
                if (e.Status == FrameStatus.Pushed) { button.ImageColor = Color.LightGray; button.ForeColor = Color.White; button.BackColor = Color.Zero; }
            };

            if (action != null)
            {
                button.Click += (s, e) => action();
            }
            parent.Add(button);
            return button;
        }
Пример #2
0
        public static Frame AddButton(Frame parent, SpriteFont font, int x, int y, int w, int h, string text, FrameAnchor anchor, Action action, Color bcol, bool visibility = true)
        {
            var button = new Frame(parent.Game, x, y, w, h, text, Color.White)
            {
                Anchor = anchor,
                TextAlignment = Alignment.MiddleCenter,
                PaddingLeft = 0,
                Font = font,
                Visible = visibility,
            };

            if (action != null)
            {
                button.Click += (s, e) =>
                {
                    action();
                };
            }
            button.StatusChanged += (s, e) =>
            {
                if (e.Status == FrameStatus.None) { button.BackColor = bcol; }
                if (e.Status == FrameStatus.Hovered) { button.BackColor = new Color(25, 71, 138, 255); }
                if (e.Status == FrameStatus.Pushed) { button.BackColor = new Color(99, 132, 181, 255); }
            };
            parent.Add(button);
            return button;
        }
Пример #3
0
        Rectangle CalculateStringSize(string text, SpriteFont font, out string[] lines)
        {
            var rec = new Rectangle();
               lines = text.Split('\n');
               float width = 0;
               foreach (var line in lines) {
                var curRec = font.MeasureString(line);

                if (curRec.Width > width) width = curRec.Width;

               }

               float height = (lines.Length-2)*font.LineHeight + font.CapHeight;

               rec.Width = (int)width ;
               rec.Height = (int)height ;

               return rec;
        }
Пример #4
0
        /// <summary>
        /// Initializes game :
        /// </summary>
        protected override void Initialize()
        {
            //	initialize services :
            base.Initialize();

            var cam = GetService<Camera>();
            cam.Config.FreeCamEnabled = false;
            selectedNodeIndex = 0;
            selectedNodePos = new Vector3();
            isSelected = false;
            time = 0;
            //	add keyboard handler :
            InputDevice.KeyDown += InputDevice_KeyDown;
            InputDevice.MouseScroll += inputDevice_MouseScroll;
            //	load content & create graphics and audio resources here:
            headerFont = Content.Load<SpriteFont>("segoeLight34");
        }
Пример #5
0
        /// <summary>
        /// Initializes game :
        /// </summary>
        protected override void Initialize()
        {
            //	initialize services :
            base.Initialize();
            font1 = Content.Load<SpriteFont>("headerFont");
            labelFontNormal = Content.Load<SpriteFont>("alsNormal");
            var cam = GetService<Camera>();
            cam.Config.FreeCamEnabled = false;
            selectedNodeIndex = 0;
            selectedNodePos = new Vector3();
            isSelected = false;
            //add gui interface
            var ui = GetService<UserInterface>();
            mainPanel = new MainFrame(this, 0, 0, this.GraphicsDevice.DisplayBounds.Width, this.GraphicsDevice.DisplayBounds.Height, "", new Color(20, 20, 20, 0f));
            ui.RootFrame = mainPanel;
            ui.SettleControls();
            GraphicsDevice.DisplayBoundsChanged += (s, e) =>
            {
                mainPanel.resizePanel();
            };

            InputDevice.KeyDown += InputDevice_KeyDown;
            InputDevice.MouseScroll += inputDevice_MouseScroll;
        }
Пример #6
0
        /// <summary>
        /// 
        /// </summary>
        void LoadContent()
        {
            texture		=	Content.Load<Texture2D>("lena");
            texture2	=	Content.Load<Texture2D>("manul" );
            font1		=	Content.Load<SpriteFont>("segoe80");
            font2		=	Content.Load<SpriteFont>("segoe40");

            atlas		=	Content.Load<TextureAtlas>("sprites");

            foreach ( var name in atlas.SubImageNames ) {
                Log.Message( "...{0}", name );
            }
        }
Пример #7
0
        /// <summary>
        /// Initializes game :
        /// </summary>
        protected override void Initialize()
        {
            //	initialize services :
            base.Initialize();

            //	add keyboard handler :
            InputDevice.KeyDown += InputDevice_KeyDown;

            //	load content & create graphics and audio resources here:

            // Add graphical user interface:
            font = Content.Load<SpriteFont>("alsNormal");
            var UI = GetService<UserInterface>();
            UI.RootFrame = new Frame(this, 0, 0, 800, 600, "", Color.Zero);

            GraphicsDevice.DisplayBoundsChanged += (s, e) =>
            {
                UI.RootFrame.Width = GraphicsDevice.DisplayBounds.Width;
                UI.RootFrame.Height = GraphicsDevice.DisplayBounds.Height;

                rightPanel.X = GraphicsDevice.DisplayBounds.Width - rightPanel.Width;
                rightPanel.Height = GraphicsDevice.DisplayBounds.Height;
            };

            rightPanel = new Frame(this, GraphicsDevice.DisplayBounds.Width - 300, 0, 300, 600, "", new Color (255, 255, 255, 30));
            UI.RootFrame.Add(rightPanel);

            //Buttons / кнопки
            int x = 10;
            int y = 10; // отступ сверху offset
            int btnWidth = 200;
            int btnHeight = 30;
            int padding = 5;
            int i = 0;
            AddButton(UI.RootFrame, this, x, y + i++ * (btnHeight + padding), btnWidth, btnHeight, "блокировка YAP", Color.Zero, () => startPropagate("PKCa"));
            AddButton(UI.RootFrame, this, x, y + i++ * (btnHeight + padding), btnWidth, btnHeight, "блокировка LAT1/2", Color.Zero, () => startPropagate("Ecad"));
            AddButton(UI.RootFrame, this, x, y + i++ * (btnHeight + padding), btnWidth, btnHeight, "блокировка GSK3b", Color.Zero, () => startPropagate("FZD"));
            AddButton(UI.RootFrame, this, x, y + i++ * (btnHeight + padding), btnWidth, btnHeight, "исходное состояние", Color.Zero,
                () => ResetGraph() );
            UI.SettleControls();

            var gs = GetService<GraphSystem>();
            gs.BackgroundColor = Color.Black;
            gs.BlendMode = BlendState.AlphaBlend;

            protGraph.ReadFromFile("../../../../signalling_table.csv");

            // setting colors:
            protGraph.HighlightNodesColorPos = nodeHighlightColorPos;
            protGraph.HighlightNodesColorNeg = nodeHighlightColorNeg;
            protGraph.EdgePosColor = nodeHighlightColorPos;
            protGraph.EdgeNegColor = nodeHighlightColorNeg;
            protGraph.EdgeNeutralColor = Color.White;

            ResetGraph();

            var graphSys = GetService<GraphSystem>();

            // add categories of nodes with different localization:
            // category 1 (membrane):
            graphSys.AddCategory(membrane, new Vector3(0, 0, 0), 500);

            // category 2 (cytoplasm):
            graphSys.AddCategory(cytoplasm, new Vector3(0, 0, 0), 200);

            // category 3 (nucleus):
            graphSys.AddCategory(nucleus, new Vector3(0, 0, 0), 100);

            graphSys.AddGraph(protGraph);
            var gr = graphSys.GetGraph();
            gr.ReadLayoutFromFile("../../../../graph.gr");
            graphSys.UpdateGraph(gr);
            graphSys.Unpause();
        }
Пример #8
0
        /// <summary>
        /// Initializes game :
        /// </summary>
        protected override void Initialize()
        {
            //	initialize services :
            base.Initialize();

            //	add keyboard handler :
            InputDevice.KeyDown += InputDevice_KeyDown;

            //	load content & create graphics and audio resources here:

            // Add graphical user interface:
            font = Content.Load<SpriteFont>("stencil");
            var UI = GetService<UserInterface>();
            UI.RootFrame = new Frame(this, 0, 0, 800, 600, "", Color.Zero);

            int x = 10;
            int y = 100;
            int btnWidth = 60;
            int btnHeight = 40;
            int padding = 5;
            button1 = new Frame(this,x,y,btnWidth,btnHeight,"1",Color.Zero)
            {
                Font = font,
                Border = 1,
                BorderColor = Color.Red,
                TextAlignment = Alignment.MiddleCenter
            };
            button2 = new Frame(this,x, y + (btnHeight + padding), btnWidth, btnHeight, "2", Color.Zero)
            {
                Font = font,
                Border = 1,
                BorderColor = Color.Red,
                TextAlignment = Alignment.MiddleCenter
            };
            button3 = new Frame(this, x, y + 2*(btnHeight + padding), btnWidth, btnHeight, "3", Color.Zero)
            {
                Font = font,
                Border = 1,
                BorderColor = Color.Red,
                TextAlignment = Alignment.MiddleCenter
            };
            button4 = new Frame(this, x, y + 3*(btnHeight + padding), btnWidth, btnHeight, "4", Color.Zero)
            {
                Font = font,
                Border = 1,
                BorderColor = Color.Red,
                TextAlignment = Alignment.MiddleCenter
            };
            button5 = new Frame(this, x, y + 4*(btnHeight + padding), btnWidth, btnHeight, "5", Color.Zero)
            {
                Font = font,
                Border = 1,
                BorderColor = Color.Red,
                TextAlignment = Alignment.MiddleCenter
            };
            button6 = new Frame(this, x, y + 5*(btnHeight + padding), btnWidth, btnHeight, "6", Color.Zero)
            {
                Font = font,
                Border = 1,
                BorderColor = Color.Red,
                TextAlignment = Alignment.MiddleCenter
            };
            resetBtn = new Frame(this, x, y + 6 * (btnHeight + padding), btnWidth, btnHeight, "R", Color.Zero)
            {
                Font = font,
                Border = 1,
                BorderColor = Color.Red,
                TextAlignment = Alignment.MiddleCenter
            };
            UI.RootFrame.Add(button1);
            UI.RootFrame.Add(button2);
            UI.RootFrame.Add(button3);
            UI.RootFrame.Add(button4);
            UI.RootFrame.Add(button5);
            UI.RootFrame.Add(button6);
            UI.RootFrame.Add(resetBtn);

            button1.Click += (s, e) => action1();
            button2.Click += (s, e) => action2();
            button3.Click += (s, e) => action3();
            button4.Click += (s, e) => action4();
            button5.Click += (s, e) => action5();
            button6.Click += (s, e) => action6();
            resetBtn.Click += (s, e) => ResetGraph();

            var gs = GetService<GraphSystem>();
            gs.BackgroundColor = Color.Black;
            gs.BlendMode = BlendState.Additive;

            protGraph.ReadFromFile("../../../../signalling_table.csv");

            // setting colors:
            protGraph.HighlightNodesColorPos = nodeHighlightColorPos;
            protGraph.HighlightNodesColorNeg = nodeHighlightColorNeg;
            protGraph.EdgePosColor = nodeHighlightColorPos;
            protGraph.EdgeNegColor = nodeHighlightColorNeg;
            protGraph.EdgeNeutralColor = Color.White;

            ResetGraph();

            var graphSys = GetService<GraphSystem>();

            // add categories of nodes with different localization:
            // category 1 (membrane):
            graphSys.AddCategory(membrane, new Vector3(0, 0, 0), 700);

            // category 2 (cytoplasm):
            graphSys.AddCategory(cytoplasm, new Vector3(0, 0, 0), 300);

            // category 3 (nucleus):
            graphSys.AddCategory(nucleus, new Vector3(0, 0, 0), 100);

            graphSys.AddGraph(protGraph);
            var gr = graphSys.GetGraph();
            gr.ReadLayoutFromFile("../../../../graph.gr");
            graphSys.UpdateGraph(gr);
            graphSys.Unpause();
        }