コード例 #1
0
ファイル: TileGridViewer.cs プロジェクト: Drenn1/LynnaLab
        protected void OnMoveMouse(object o, MotionNotifyEventArgs args)
        {
            int x, y;

            Gdk.ModifierType state;
            args.Event.Window.GetPointer(out x, out y, out state);

            int nextHoveringIndex;

            if (IsInBounds(x, y))
            {
                Cairo.Point p = GetGridPosition(x, y);
                nextHoveringIndex = p.X + p.Y * Width;
            }
            else
            {
                nextHoveringIndex = -1;
            }

            if (nextHoveringIndex != hoveringIndex)
            {
                // Update hovering cursor
                Cairo.Rectangle rect = GetTileRectWithPadding(HoveringX, HoveringY);
                this.QueueDrawArea((int)rect.X, (int)rect.Y, (int)rect.Width, (int)rect.Height);
                hoveringIndex = nextHoveringIndex;
                rect          = GetTileRectWithPadding(HoveringX, HoveringY);
                this.QueueDrawArea((int)rect.X, (int)rect.Y, (int)rect.Width, (int)rect.Height);

                if (HoverChangedEvent != null)
                {
                    HoverChangedEvent(this, hoveringIndex);
                }

                // Drag actions
                if (activeAction != null && activeAction.mod.HasFlag(MouseModifier.Drag) && IsInBounds(x, y))
                {
                    HandleTileGridAction(activeAction, nextHoveringIndex);
                }
            }
        }
コード例 #2
0
        private static ButtonStates GetState(double argsX, double argsY, Cairo.Point point, bool mouseDown, ButtonStates previousState)
        {
            ButtonStates result = ButtonStates.Outside;
            bool         inside = argsX >= point.X && argsX <= point.X + ButtonWidth &&
                                  argsY >= point.Y && argsY <= point.Y + ButtonHeight;

            if (inside)
            {
                result = ButtonStates.Inside;
                if (mouseDown)
                {
                    result = ButtonStates.DownInside;
                }
            }
            else
            {
                if (mouseDown && previousState == ButtonStates.Inside)
                {
                    result = ButtonStates.DownOutside;
                }
            }
            return(result);
        }
コード例 #3
0
 public static Gdk.Size ToSize(this Cairo.Point point)
 {
     return(new Gdk.Size(point.X, point.Y));
 }
コード例 #4
0
 /// <summary>
 /// Converts a point to a ScreenPoint.
 /// </summary>
 /// <param name="pt">The point.</param>
 /// <returns>A screen point.</returns>
 public static ScreenPoint ToScreenPoint(this Point pt)
 {
     return(new ScreenPoint(pt.X, pt.Y));
 }
コード例 #5
0
ファイル: TileGridViewer.cs プロジェクト: Drenn1/LynnaLab
 // Convert a "real" position (in pixels) to an index.
 public int GetGridIndex(int x, int y)
 {
     Cairo.Point p = GetGridPosition(x, y);
     return(p.X + p.Y * Width);
 }
コード例 #6
0
        public TemplateWindow(string title)
            : base(Gtk.WindowType.Toplevel)
        {
            this.Decorated = false;

            global::Stetic.Gui.Initialize(this);
            // Widget CrossPlatformWebServer.TemplateWindow
            //this.WidthRequest = 550;
            //this.HeightRequest = 350;
            this.Name           = "CrossPlatformWebServer.TemplateWindow";
            this.Title          = global::Mono.Unix.Catalog.GetString("MainWindow");
            this.WindowPosition = ((global::Gtk.WindowPosition)(3));

            // Container child CrossPlatformWebServer.TemplateWindow.Gtk.Container+ContainerChild
            this.gridMain           = new global::Gtk.Fixed();
            this.gridMain.Name      = "gridMain";
            this.gridMain.HasWindow = false;
            // Container child gridMain.Gtk.Fixed+FixedChild
            this.border      = new global::Gtk.DrawingArea();
            this.border.Name = "border";
            this.gridMain.Add(this.border);
            // Container child gridMain.Gtk.Fixed+FixedChild
            this.titlebar      = new global::Gtk.DrawingArea();
            this.titlebar.Name = "titlebar";
            this.gridMain.Add(this.titlebar);
            global::Gtk.Fixed.FixedChild w2 = ((global::Gtk.Fixed.FixedChild)(this.gridMain[this.titlebar]));
            w2.X = 1;
            w2.Y = 1;
            // Container child gridMain.Gtk.Fixed+FixedChild
            this.borderleft      = new global::Gtk.DrawingArea();
            this.borderleft.Name = "borderleft";
            this.gridMain.Add(this.borderleft);
            // Container child gridMain.Gtk.Fixed+FixedChild
            this.bordertop      = new global::Gtk.DrawingArea();
            this.bordertop.Name = "bordertop";
            this.gridMain.Add(this.bordertop);
            // Container child gridMain.Gtk.Fixed+FixedChild
            this.borderright      = new global::Gtk.DrawingArea();
            this.borderright.Name = "borderright";
            this.gridMain.Add(this.borderright);
            // Container child gridMain.Gtk.Fixed+FixedChild
            this.borderbottom      = new global::Gtk.DrawingArea();
            this.borderbottom.Name = "borderbottom";
            this.gridMain.Add(this.borderbottom);
            this.Add(this.gridMain);

            this._closeState    = ButtonStates.Outside;
            this._minimizeState = ButtonStates.Outside;

            _closeStart    = new Cairo.Point(this.WidthRequest - ButtonOffSet - ButtonWidth, ButtonOffSet);
            _minimizeStart = new Cairo.Point(this.WidthRequest - ButtonOffSet - ButtonWidth - ButtonWidth,
                                             ButtonOffSet);

            w2 = null;

            this.ModifyBg(StateType.Normal, new Gdk.Color(255, 255, 255));
            this.titlebar.WidthRequest  = this.WidthRequest - 2;
            this.titlebar.HeightRequest = 60;
            this.titlebar.AddEvents((int)Gdk.EventMask.ButtonPressMask |
                                    (int)Gdk.EventMask.PointerMotionMask |
                                    (int)Gdk.EventMask.ButtonReleaseMask);
            this.titlebar.ButtonPressEvent   += TitlebarButtonPressEvent;
            this.titlebar.ExposeEvent        += OnTitlebarExpose;
            this.titlebar.MotionNotifyEvent  += OnTitlebarMotionNotifyEvent;
            this.titlebar.ButtonReleaseEvent += OnTitlebarButtonReleaseEvent;

            titleLayout                 = new Pango.Layout(this.PangoContext);
            titleLayout.Alignment       = Pango.Alignment.Left;
            titleLayout.FontDescription = new Pango.FontDescription();

            switch (Environment.OSVersion.Platform)
            {
            case PlatformID.Win32NT:
            case PlatformID.Win32S:
            case PlatformID.Win32Windows:
            case PlatformID.WinCE:
                titleLayout.FontDescription.Family = "Segoe UI Light";
                break;

            case PlatformID.Unix:
                titleLayout.FontDescription.Family = "Ubuntu";
                break;

            default:
                //Unknown OS, use default font family
                break;
            }
            titleLayout.FontDescription.Size = 17000;
            titleLayout.SetText(title.ToLower());

            borderleft.WidthRequest  = 1;
            borderleft.HeightRequest = this.HeightRequest;
            borderleft.ModifyBg(StateType.Normal, new Gdk.Color(65, 177, 225));

            bordertop.WidthRequest  = this.WidthRequest;
            bordertop.HeightRequest = 1;
            bordertop.ModifyBg(StateType.Normal, new Gdk.Color(65, 177, 225));

            borderright.WidthRequest  = 1;
            borderright.HeightRequest = this.HeightRequest;
            borderright.ModifyBg(StateType.Normal, new Gdk.Color(65, 177, 225));
            w2   = ((global::Gtk.Fixed.FixedChild)(this.gridMain[this.borderright]));
            w2.X = this.WidthRequest - 1;
            w2.Y = 0;

            borderbottom.WidthRequest  = this.WidthRequest;
            borderbottom.HeightRequest = 1;
            borderbottom.ModifyBg(StateType.Normal, new Gdk.Color(65, 177, 225));
            w2   = ((global::Gtk.Fixed.FixedChild)(this.gridMain[this.borderbottom]));
            w2.X = 0;
            w2.Y = this.HeightRequest - 1;

            if ((this.Child != null))
            {
                this.Child.ShowAll();
            }
            this.Show();
            this.DeleteEvent += new global::Gtk.DeleteEventHandler(this.OnDeleteEvent);
        }
コード例 #7
0
ファイル: HitPointsChart.cs プロジェクト: manicolosi/questar
        private void CreatePath(Context context)
        {
            Rectangle alloc = base.Allocation;
            Point center = new Point (alloc.Width / 2, alloc.Height / 2);
            double radius = (Math.Min (alloc.Width, alloc.Height) - 10) / 2;
            double angle_in_radians = angle * (Math.PI / 180);

            context.Arc (center.X, center.Y, radius,
                -angle_in_radians + (-0.5 * Math.PI), -0.5 * Math.PI);
            context.LineTo (center.X, center.Y);
            context.ClosePath ();
        }
コード例 #8
0
ファイル: guiEquipment.cs プロジェクト: odnanref/snrviewer
        void preLoad()
        {
            Offset.X = width/2;
            Offset.Y = height/2;
            this.AddEvents ((int) EventMask.ButtonPressMask);

            this.ButtonPressEvent += delegate(object o, ButtonPressEventArgs args) {
                //Console.WriteLine(">> " + args.Event.X + " args.Event.Y " + args.Event.Y);
                Cairo.Point world = new Cairo.Point(Convert.ToInt32(args.Event.X), Convert.ToInt32(args.Event.Y));
                hasInterface(world);
            };

            this.ExposeEvent += OnExpose;
        }
コード例 #9
0
ファイル: guiEquipment.cs プロジェクト: odnanref/snrviewer
        public Cairo.Point WorldToScreen( Cairo.Point world )
        {
            var p = new Cairo.Point();
            p.X = Convert.ToInt32((world.X - Offset.X) * Zoom);

            p.Y = Convert.ToInt32((world.Y - Offset.Y) * Zoom);
            return p;
        }