]> O.S.I.I.S - jp/crow.git/commitdiff
implement Crow.LoadFromStream and filenotfound catch
authorjp <jp_bruyere@hotmail.com>
Sat, 23 Jul 2016 14:50:32 +0000 (16:50 +0200)
committerjp <jp_bruyere@hotmail.com>
Sat, 23 Jul 2016 14:50:32 +0000 (16:50 +0200)
modifié :         Tests/OpenGL/Texture.cs

debug window resize bugs
modifié :         src/GraphicObjects/GraphicObject.cs
modifié :         src/GraphicObjects/Window.cs

Tests/OpenGL/Texture.cs
src/GraphicObjects/GraphicObject.cs
src/GraphicObjects/Window.cs

index 5e3a350a96af26fd48a237f55bb463d5dd5071fc..ce24808b4daab8e55a852ea890946052190c7a99 100644 (file)
@@ -37,30 +37,31 @@ namespace Crow
                        
                public Texture(string _mapPath, bool flipY = true)
         {
-                       if (!File.Exists (_mapPath))
-                               throw new FileNotFoundException ("Texture not found", _mapPath);
-                       try {
-                   Map = _mapPath;
+                       using (Stream s = Interface.GetStreamFromPath (_mapPath)) {
 
-                               Bitmap bitmap = new Bitmap(_mapPath);                           
+                               try {
+                                       Map = _mapPath;
 
-                               if(flipY)
-                                       bitmap.RotateFlip(RotateFlipType.RotateNoneFlipY);
+                                       Bitmap bitmap = new Bitmap (s);
 
-                               BitmapData data = bitmap.LockBits(new System.Drawing.Rectangle(0, 0, bitmap.Width, bitmap.Height),
-                                       ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
+                                       if (flipY)
+                                               bitmap.RotateFlip (RotateFlipType.RotateNoneFlipY);
 
-                               createTexture (data.Scan0, data.Width, data.Height);
+                                       BitmapData data = bitmap.LockBits (new System.Drawing.Rectangle (0, 0, bitmap.Width, bitmap.Height),
+                                               ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
 
-                               bitmap.UnlockBits(data);
+                                       createTexture (data.Scan0, data.Width, data.Height);
 
-                               GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.LinearMipmapLinear);
-                               GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear);
+                                       bitmap.UnlockBits (data);
 
-                               GL.GenerateMipmap(GenerateMipmapTarget.Texture2D);
+                                       GL.TexParameter (TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.LinearMipmapLinear);
+                                       GL.TexParameter (TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear);
 
-                       } catch (Exception ex) {
-                               Debug.WriteLine ("Error loading texture: " + Map + ":" + ex.Message); 
+                                       GL.GenerateMipmap (GenerateMipmapTarget.Texture2D);
+
+                               } catch (Exception ex) {
+                                       Debug.WriteLine ("Error loading texture: " + Map + ":" + ex.Message);
+                               }
                        }
                }
 
index 59b4be18125048cbf79d3fff45860673573837ed..2838f6cd118b29865998e5d586149155e5522581 100644 (file)
@@ -239,6 +239,10 @@ namespace Crow
                        set {
                                if (_width == value)
                                        return;
+                               if (value.IsFixed) {
+                                       if (value < MinimumSize.Width || (value > MaximumSize.Width && MaximumSize.Width > 0))
+                                               return;
+                               }
 
                                _width = value;
                                NotifyValueChanged ("Width", _width);
@@ -253,6 +257,10 @@ namespace Crow
                        set {
                                if (_height == value)
                                        return;
+                               if (value.IsFixed) {
+                                       if (value < MinimumSize.Height || (value > MaximumSize.Height && MaximumSize.Height > 0))
+                                               return;
+                               }
 
                                _height = value;
                                NotifyValueChanged ("Height", _height);
@@ -1239,6 +1247,8 @@ namespace Crow
                        }
                }
                void applyStyle(){
+                       //The first place searched for a style is in the style propery of this instance
+                       //this field may contains the path to a Style file for the object.
                        if (string.IsNullOrEmpty (style))
                                return;
                        Stream s = Interface.GetStreamFromPath (style);
index 7b5f7c9ac3345fecc04a0d00bcc8f76029e4c067..afb4f4f2e5ea3c8710934eba661398bab28c83bd 100644 (file)
@@ -101,20 +101,18 @@ namespace Crow
                        }
 
                        if (this.HasFocus) {
-                               
-                               if (e.Mouse.IsButtonDown (MouseButton.Left)) {                          
-
+                               if (e.Mouse.IsButtonDown (MouseButton.Left)) {
                                        int currentLeft = this.Left;
                                        int currentTop = this.Top;
                                        int currentWidth, currentHeight;
 
                                        if (currentLeft == 0) {
                                                currentLeft = this.Slot.Left;
-                                               //this.Left = currentLeft;
+                                               this.Left = currentLeft;
                                        }
                                        if (currentTop == 0) {
                                                currentTop = this.Slot.Top;
-                                               //this.Top = currentTop;
+                                               this.Top = currentTop;
                                        }
                                        if (this.Width.IsFixed)
                                                currentWidth = this.Width;
@@ -132,38 +130,44 @@ namespace Crow
                                                this.Top = currentTop + e.YDelta;
                                                break;
                                        case Direction.N:
-                                               this.Top = currentTop + e.YDelta;
                                                this.Height = currentHeight - e.YDelta;
+                                               if (this.Height == currentHeight - e.YDelta)
+                                                       this.Top = currentTop + e.YDelta;
                                                break;
                                        case Direction.S:
                                                this.Height = currentHeight + e.YDelta;
                                                break;
                                        case Direction.W:
-                                               this.Left = currentLeft + e.XDelta;
                                                this.Width = currentWidth - e.XDelta;
+                                               if (this.Width == currentWidth - e.XDelta)
+                                                       this.Left = currentLeft + e.XDelta;
                                                break;
                                        case Direction.E:
                                                this.Width = currentWidth + e.XDelta;
                                                break;
                                        case Direction.NW:
-                                               this.Left = currentLeft + e.XDelta;
-                                               this.Top = currentTop + e.YDelta;
-                                               this.Width = currentWidth - e.XDelta;
                                                this.Height = currentHeight - e.YDelta;
+                                               if (this.Height == currentHeight - e.YDelta)
+                                                       this.Top = currentTop + e.YDelta;
+                                               this.Width = currentWidth - e.XDelta;
+                                               if (this.Width == currentWidth - e.XDelta)
+                                                       this.Left = currentLeft + e.XDelta;
                                                break;
                                        case Direction.NE:
-                                               this.Width = currentWidth + e.XDelta;
-                                               this.Top = currentTop + e.YDelta;
                                                this.Height = currentHeight - e.YDelta;
+                                               if (this.Height == currentHeight - e.YDelta)
+                                                       this.Top = currentTop + e.YDelta;
+                                               this.Width = currentWidth + e.XDelta;
                                                break;
                                        case Direction.SW:
-                                               this.Left = currentLeft + e.XDelta;
                                                this.Width = currentWidth - e.XDelta;
+                                               if (this.Width == currentWidth - e.XDelta)
+                                                       this.Left = currentLeft + e.XDelta;
                                                this.Height = currentHeight + e.YDelta;
                                                break;
                                        case Direction.SE:
-                                               this.Width = currentWidth + e.XDelta;
                                                this.Height = currentHeight + e.YDelta;
+                                               this.Width = currentWidth + e.XDelta;
                                                break;
                                        }
                                        return;