コード例 #1
0
 void SetButtonColor(DrawingArea area, Color color)
 {
     Gdk.Color gcolor = Misc.ToGdkColor(color);
     area.ModifyBg(StateType.Normal, gcolor);
     area.ModifyBg(StateType.Active, gcolor);
     area.ModifyBg(StateType.Insensitive, gcolor);
     area.ModifyBg(StateType.Prelight, gcolor);
     area.ModifyBg(StateType.Selected, gcolor);
 }
コード例 #2
0
        /// <summary>Initializes a new instance of the <see cref="DirectedGraphView" /> class.</summary>
        public DirectedGraphView(ViewBase owner = null) : base(owner)
        {
            drawable = new DrawingArea();

            drawable.AddEvents(
                (int)Gdk.EventMask.PointerMotionMask
                | (int)Gdk.EventMask.ButtonPressMask
                | (int)Gdk.EventMask.ButtonReleaseMask);

            drawable.ExposeEvent        += OnDrawingAreaExpose;
            drawable.ButtonPressEvent   += OnMouseButtonPress;
            drawable.ButtonReleaseEvent += OnMouseButtonRelease;
            drawable.MotionNotifyEvent  += OnMouseMove;

            ScrolledWindow scroller = new ScrolledWindow(new Adjustment(0, 0, 100, 1, 1, 1), new Adjustment(0, 0, 100, 1, 1, 1))
            {
                HscrollbarPolicy = PolicyType.Always,
                VscrollbarPolicy = PolicyType.Always
            };

            scroller.AddWithViewport(drawable);

            _mainWidget = scroller;
            drawable.ModifyBg(StateType.Normal, new Gdk.Color(255, 255, 255));
            drawable.Realized += OnRealized;
        }
コード例 #3
0
ファイル: DrawManager.cs プロジェクト: Gilaad-Elstein/mlEco
        private void InitDrawables()
        {
            drawingArea = new DrawingArea();
            drawingArea.WidthRequest  = 720;
            drawingArea.HeightRequest = 450;
            drawingArea.ExposeEvent  += OnExpose;
            drawingArea.ModifyBg(Gtk.StateType.Normal, new Gdk.Color(250, 250, 250));

            //Add(drawingArea);
        }
コード例 #4
0
        public MainWindow()
            : base("Overlaytest")
        {
            VBox vBox = new VBox();

            _da = new DrawingArea();
            _da.ModifyBg(Gtk.StateType.Normal, new Gdk.Color(0, 0, 0));
            _da.SetSizeRequest(400, 300);
            _da.DoubleBuffered = false;
            vBox.PackStart(_da, false, false, 0);

            _scale               = new HScale(0, 1, 0.01);
            _scale.DrawValue     = false;
            _scale.ValueChanged += ScaleValueChanged;
            vBox.PackStart(_scale, false, false, 0);

            HBox hBox = new HBox();

            Button btnOpen = new Button();

            btnOpen.Label    = "Open";
            btnOpen.Clicked += ButtonOpenClicked;

            hBox.PackStart(btnOpen, false, false, 0);

            Button btnPlay = new Button();

            btnPlay.Label    = "Play";
            btnPlay.Clicked += ButtonPlayClicked;

            hBox.PackStart(btnPlay, false, false, 0);

            Button btnPause = new Button();

            btnPause.Label    = "Pause";
            btnPause.Clicked += ButtonPauseClicked;

            hBox.PackStart(btnPause, false, false, 0);

            _lbl      = new Label();
            _lbl.Text = "00:00 / 00:00";

            hBox.PackEnd(_lbl, false, false, 0);

            vBox.PackStart(hBox, false, false, 3);

            Add(vBox);

            WindowPosition = Gtk.WindowPosition.Center;
            DeleteEvent   += OnDeleteEvent;

            GLib.Timeout.Add(1000, new GLib.TimeoutHandler(UpdatePos));
        }
コード例 #5
0
    public MainWindow()
        : base(WindowType.Toplevel)
    {
        VBox vBox = new VBox ();

        _da = new DrawingArea ();
        _da.ModifyBg (Gtk.StateType.Normal, new Gdk.Color (0, 0, 0));
        _da.SetSizeRequest (400, 300);
        _da.DoubleBuffered = false;
        vBox.PackStart (_da, true, true, 0);

        _scale = new HScale (0, 1, 0.01);
        _scale.DrawValue = false;
        _scale.ValueChanged += ScaleValueChanged;
        vBox.PackStart (_scale, false, false, 0);

        HBox hBox = new HBox ();

        Button btnOpen = new Button ();
        btnOpen.Label = "Open";
        btnOpen.Clicked += ButtonOpenClicked;

        hBox.PackStart (btnOpen, false, false, 0);

        Button btnPlay = new Button ();
        btnPlay.Label = "Play";
        btnPlay.Clicked += ButtonPlayClicked;

        hBox.PackStart (btnPlay, false, false, 0);

        Button btnPause = new Button ();
        btnPause.Label = "Pause";
        btnPause.Clicked += ButtonPauseClicked;

        hBox.PackStart (btnPause, false, false, 0);

        _lbl = new Label ();
        _lbl.Text = "00:00 / 00:00";

        hBox.PackEnd (_lbl, false, false, 0);

        vBox.PackStart (hBox, false, false, 3);

        Add (vBox);

        WindowPosition = Gtk.WindowPosition.Center;
        DeleteEvent += OnDeleteEvent;

        GLib.Timeout.Add (1000, new GLib.TimeoutHandler (UpdatePos));
    }
コード例 #6
0
        public DemoRotatedText() : base("Rotated text")
        {
            DrawingArea drawingArea = new DrawingArea();

            Gdk.Color white = new Gdk.Color(0xff, 0xff, 0xff);

            // This overrides the background color from the theme
            drawingArea.ModifyBg(StateType.Normal, white);
            drawingArea.ExposeEvent += new ExposeEventHandler(RotatedTextExposeEvent);

            this.Add(drawingArea);
            this.DeleteEvent += new DeleteEventHandler(OnWinDelete);
            this.SetDefaultSize(2 * RADIUS, 2 * RADIUS);
            this.ShowAll();
        }
コード例 #7
0
        public void BackGroundColorChangeMenuBar()
        {
            try {
                da1              = new DrawingArea();
                da1.ExposeEvent += OnExposed1;

                Gdk.Color col = new Gdk.Color();
                Gdk.Color.Parse("#3b5998", ref col);

                ModifyBg(StateType.Normal, col);
                da1.ModifyBg(StateType.Normal, col);
            } catch (Exception ex) {
                Console.Write(ex.Message);
            }
        }
コード例 #8
0
        /// <summary>Initializes a new instance of the <see cref="DirectedGraphView" /> class.</summary>
        public DirectedGraphView(ViewBase owner = null) : base(owner)
        {
            DrawingArea drawingArea = new DrawingArea();

            drawingArea.AddEvents(
            (int)Gdk.EventMask.PointerMotionMask
            | (int)Gdk.EventMask.ButtonPressMask
            | (int)Gdk.EventMask.ButtonReleaseMask);

            drawingArea.ExposeEvent += OnDrawingAreaExpose;
            drawingArea.ButtonPressEvent += OnMouseButtonPress;
            drawingArea.ButtonReleaseEvent += OnMouseButtonRelease; ;
            drawingArea.MotionNotifyEvent += OnMouseMove; ;
            _mainWidget = drawingArea;
            drawingArea.ModifyBg(StateType.Normal, new Gdk.Color(255, 255, 255));
        }
コード例 #9
0
        void AddExtraControlsSeparator()
        {
            projectConfigurationTable.NRows++;

            extraControlsSeparator = new DrawingArea();
            extraControlsSeparator.HeightRequest = 1;
            extraControlsSeparator.ModifyBg(StateType.Normal, separatorColor);
            projectConfigurationTable.Attach(
                extraControlsSeparator,
                0,
                3,
                defaultTableRows,
                defaultTableRows + 1,
                AttachOptions.Fill,
                (AttachOptions)0,
                0,
                10);
        }
コード例 #10
0
ファイル: Program.cs プロジェクト: MFGookey/Strawberries
        ColourExample()
        {
            FindColors();
            win = new Window("Strawberry Reds");
            win.SetDefaultSize(610, 70);
            win.DeleteEvent += OnWinDelete;

            da              = new DrawingArea();
            da.ExposeEvent += OnExposed;

            Gdk.Color col = new Gdk.Color();
            Gdk.Color.Parse("red", ref col);
            win.ModifyBg(StateType.Normal, col);
            da.ModifyBg(StateType.Normal, new Gdk.Color(128, 128, 128));

            win.Add(da);
            win.ShowAll();
        }
コード例 #11
0
        public SharpApp() : base()
        {
            Console.WriteLine("ROJO: cercano");
            Console.WriteLine("VERDE: menos concurrido");
            Console.WriteLine("AZUL: al azar");
            ventana = this;
            ventana.Maximize();
            SetPosition(WindowPosition.Center);
            DeleteEvent += delegate {
                Application.Quit();
            };
            GLib.Timeout.Add(Constantes.milisegundos_iteracion, new GLib.TimeoutHandler(OnTimer));
            darea              = new DrawingArea();
            darea.ExposeEvent += OnExpose;
            int displayX, displayY;

            ventana.Title = "Flocking 3.0";

            ventana.menub.ModifyBg(Gtk.StateType.Normal, new Gdk.Color(240, 240, 240));
            ventana.tb1.ModifyBg(Gtk.StateType.Normal, new Gdk.Color(240, 240, 240));
            ventana.tb2.ModifyBg(Gtk.StateType.Normal, new Gdk.Color(240, 240, 240));
            //ventana.tb3.ModifyBg (Gtk.StateType.Normal, new Gdk.Color (240, 240, 240));
            darea.ModifyBg(Gtk.StateType.Normal, new Gdk.Color(255, 255, 255));

            //ventana.GetSize(out displayX, out displayY);
            //Constantes.limites = new System.Drawing.Rectangle(0, 0, displayX, displayY);

            Constantes.limites = new System.Drawing.Rectangle(0, 0, 1500, 1500);

            Logica.grilla = new Grilla();

            //Constantes.viewSurface = new ImageSurface (Format.ARGB32, displayX, displayY);

            Constantes.viewSurface = new ImageSurface(Format.ARGB32, 1500, 1500);

//			Constantes.escenarioSurface = new ImageSurface (Format.ARGB32, displayX, displayY);



            ventana.scrollw.AddWithViewport(darea);
            ventana.ShowAll();
        }
コード例 #12
0
        public override Gtk.Widget GetDisplayWidget()
        {
            DrawingArea colorPreview = new DrawingArea();

            colorPreview.ModifyBg(StateType.Normal, GetColor());
            colorPreview.WidthRequest = 15;

            Alignment colorPreviewAlign = new Alignment(0, 0, 0, 1);

            colorPreviewAlign.SetPadding(2, 2, 2, 2);
            colorPreviewAlign.Add(colorPreview);

            string labelText;

            System.Drawing.Color color = (System.Drawing.Color)parentRow.PropertyValue;
            //TODO: dropdown known color selector so this does something
            if (color.IsKnownColor)
            {
                labelText = color.Name;
            }
            else if (color.IsEmpty)
            {
                labelText = "[empty]";
            }
            else
            {
                labelText = String.Format("#{0:x2}{1:x2}{2:x2}", color.R, color.G, color.B);
            }

            //we use StringValue as it auto-bolds the text for non-default values
            Label theLabel = (Label)base.StringValue(labelText);

            theLabel.Xalign = 0;
            theLabel.Xpad   = 3;

            HBox hbox = new HBox();

            hbox.PackStart(colorPreviewAlign, false, false, 0);
            hbox.PackStart(theLabel, true, true, 0);

            return(hbox);
        }
コード例 #13
0
ファイル: TestColorSelection.cs プロジェクト: shana/gtk-sharp
        static void Display_Result(Gdk.Color color)
        {
            dialog              = new Dialog();
            dialog.Title        = "Selected Color: " + HexFormat(color);
            dialog.HasSeparator = true;

            DrawingArea da = new DrawingArea();

            da.ModifyBg(StateType.Normal, color);

            dialog.VBox.BorderWidth = 10;
            dialog.VBox.PackStart(da, true, true, 10);
            dialog.SetDefaultSize(200, 200);

            Button button = new Button(Stock.Ok);

            button.Clicked   += new EventHandler(Dialog_Ok);
            button.CanDefault = true;
            dialog.ActionArea.PackStart(button, true, true, 0);
            button.GrabDefault();

            dialog.ShowAll();
        }
コード例 #14
0
        public TopographyViewerApp() : base("TopographyViewer")
        {
            SetSizeRequest(720, 450);
            SetPosition(WindowPosition.Center);
            Resizable    = false;
            DeleteEvent += delegate { Application.Quit(); };
            //ButtonPressEvent += ButtonPress;
            //KeyPressEvent += KeyPress;
            KeyReleaseEvent += OnKeyPress;
            AddEvents((int)Gdk.EventMask.ButtonPressMask);

            drawingArea = new DrawingArea();
            drawingArea.WidthRequest  = 720;
            drawingArea.HeightRequest = 450;
            drawingArea.ModifyBg(Gtk.StateType.Normal, new Gdk.Color(125, 125, 125));
            drawingArea.ExposeEvent += OnExpose;

            Add(drawingArea);
            currentAgent = new NeatAgent();

            ShowAll();

            XorAgents();
        }
コード例 #15
0
 HermitePoint CreateHermitePoint(Color col)
 {
     var cp1 = new DrawingArea ();
     cp1.ModifyBg (StateType.Normal, col);
     cp1.SetSizeRequest (20, 20);
     cp1.AddEvents ((int)EventMask.AllEventsMask);
     fixed3.Add (cp1);
     cp1.Show ();
     bool drag = false;
     Point p = new Point();
     cp1.MotionNotifyEvent += (o, args) => {
         if (drag) {
             int x, y;
             cp1.GdkWindow.GetPosition (out x, out y);
             cp1.GdkWindow.Move (
                 (int)args.Event.X + x - p.X,
                 (int)args.Event.Y + y - p.Y
             );
         }
         canvas.QueueDraw ();
     };
     cp1.ButtonPressEvent += (o, args) => {
         drag = true;
         p = new Point ((int)args.Event.X, (int)args.Event.Y);
     };
     cp1.ButtonReleaseEvent += (o, args) => {
         drag = false;
     };
     return new HermitePoint (){Area = cp1 };
 }
コード例 #16
0
        private static void Init()
        {
            _random = new Random();

            InitializeLua();

            Application.Init();
            if (!GLib.Thread.Supported)
            {
                GLib.Thread.Init();
            }
            Gdk.Threads.Init();

            Gdk.Threads.Enter();

            _window = new Gtk.Window(Globals.WINDOW_NAME);
            _window.SetDefaultSize(Globals.WIDTH, Globals.HEIGHT);
            _window.AppPaintable     = true;
            _window.DoubleBuffered   = false;
            _window.DeleteEvent     += OnWinDelete;
            _window.KeyPressEvent   += OnKeyPress;
            _window.KeyReleaseEvent += OnKeyRelease;
            //_window.ConfigureEvent += OnWindowConfigure;

            DrawingArea da = new DrawingArea();

            da.ExposeEvent += OnExposed;

            Gdk.Color col = new Gdk.Color(0, 0, 0);
            _window.ModifyBg(StateType.Normal, col);
            da.ModifyBg(StateType.Normal, col);

            GLib.Timeout.Add(33, new GLib.TimeoutHandler(Graphics.TimedDraw));

            _window.Add(da);
            _window.ShowAll();

            Gdk.Threads.Leave();

            Graphics.Init();    // depends on _window being initialized
            Item.Init();
            Enemy.Init();       // depends on Globals ctor
            Weapon.Init();      // depends on Globals ctor
            Armor.Init();       // depends on Globals ctor
            Accessory.Init();   // depends on Globals ctor
            Materia.Init();     // depends on Globals ctor
            Character.Init();   // depends on [Weapons|Armor|Materia].Init()
            Globals.Init();     // depends on Character.Init()
            MenuScreen.Init();  // depends on Globals.Init()
            Inventory.Init();   // depends on a whole lot of things
            Spell.Init();       // depends on Globals ctor
            Materiatory.Init(); // depends on Materia.Init()

            int time = Int32.Parse(Globals.SaveGame.SelectSingleNode("//time").InnerText);

            _clock = new Clock(time); // depends on Globals ctor

            // Go to Main Menu
            _state = MainMenu;

            // Go to new Battle
            //GoToBattleState();

            // Go to Post-Battle
            //List<IItem> i = new List<IItem>();
            //i.Add(Item.ItemTable["powersource"]);
            //i.Add(Item.ItemTable["powersource"]);
            //i.Add(Item.ItemTable["potion"]);
            //PostBattle = new PostBattleState(234, 12, 1200, i);
            //_state = PostBattle;

            _state.Init();

            if (Globals.Party[0] == null && Globals.Party[1] == null && Globals.Party[2] == null)
            {
                throw new GamedataException("No character in party!");
            }

            // Level-up demo
            //using (StreamWriter w = new StreamWriter(@"c:\scripts\test.txt"))
            //{
            //    while (Character.Cloud.Level < 98)
            //    {
            //        Character.Cloud.GainExperience(Character.Cloud.ToNextLevel + 10);
            //        w.WriteLine(Character.Cloud.ToString());
            //    }
            //    w.Flush();
            //}
        }
コード例 #17
0
 private void updateColor()
 {
     colorView.ModifyBg(Gtk.StateType.Normal, color);
 }