private static bool LoadPath(SkinImage skinImage, out Bitmap image, ref StringBuilder msg, string skinName) { if (skinName == "") { LoadAssemblyImage(skinImage, out image); return(false); } else { string path = Directory.GetCurrentDirectory() + "\\Skin\\" + skinName + "\\" + skinImage.ToString().ToLower() + ".png"; try { if (File.Exists(path)) { using (FileStream stream = new FileStream(path, FileMode.Open)) { image = new Bitmap(stream); } } else { msg.AppendLine("\'" + path + "\'"); LoadAssemblyImage(skinImage, out image); } return(true); } catch (Exception e) { Console.WriteLine("LoadPath:" + e.Message); image = null; return(false); } } }
public static void On_Skin_Init(Skin self) { if ((graphicsTex == null) || (graphicsTex.GraphicsDevice != GnomanEmpire.Instance.GraphicsDevice) || graphicsTex.IsDisposed) { graphicsTex = CustomTextureManager.GetFromAssemblyResource(Assembly.GetExecutingAssembly(), "Faark.Gnomoria.Mods.Resources.maxButtons.png"); //Texture2D.FromStream(GnomanEmpire.Instance.GraphicsDevice, Assembly.GetExecutingAssembly().GetManifestResourceStream( "Faark.Gnomoria.Mods.Resources.maxButtons.png")); } var maxImg = new SkinImage(); maxImg.Resource = graphicsTex; // warning have to load it here! maxImg.Name = "Window.MaximizeButton"; self.Images.Add(maxImg); var mySkinLayer = new SkinLayer(); mySkinLayer.Name = "Control"; mySkinLayer.Alignment = Alignment.MiddleLeft; mySkinLayer.ContentMargins = new Margins(6); mySkinLayer.SizingMargins = new Margins(6); mySkinLayer.Image = maxImg; mySkinLayer.Height = 28; mySkinLayer.Width = 28; mySkinLayer.States.Disabled.Index = 2; mySkinLayer.States.Enabled.Index = 2; mySkinLayer.States.Focused.Index = 0; mySkinLayer.States.Hovered.Index = 0; mySkinLayer.States.Pressed.Index = 2; mySkinLayer.Text = new SkinText(self.Controls["Window.CloseButton"].Layers[0].Text); var mySkinControl = new SkinControl(); mySkinControl.Inherits = "Button"; mySkinControl.ResizerSize = 4; mySkinControl.DefaultSize = new Size(28, 28); mySkinControl.Name = "Window.MaximizeButton"; mySkinControl.Layers.Add(mySkinLayer); self.Controls.Add(mySkinControl); }
/// <summary> /// コンストラクタ /// </summary> /// <param name="skin">画像の種類</param> /// <param name="windowType">画像の分類</param> public GHIcon(SkinImage skin, FormType windowType) { this.windowType = windowType; Skin.GetSkinImage(skin, out image); Init(); }
/// <summary> /// スキンの画像を描画 (拡大・縮小) /// </summary> /// <param name="graph">描画先</param> /// <param name="skinImage">描画する画像</param> /// <param name="rect">描画する位置とサイズ</param> public static void DrawingSkinImage(ref Graphics graph, SkinImage skinImage, Rectangle rect) { try { graph.DrawImage(Images[(int)skinImage], rect); } catch (Exception e) { Console.WriteLine("DrawingSkinImage:" + e.Message); } }
/// <summary> /// 指定のスキンの画像を取得 /// </summary> /// <param name="skinImage">取得する画像</param> /// <param name="image">画像を格納する変数</param> public static void GetSkinImage(SkinImage skinImage, out Bitmap image) { try { image = (Bitmap)Images[(int)skinImage].Clone(); } catch (Exception e) { image = null; Console.WriteLine("GetSkinImage:" + e.Message); } }
private static bool LoadAssemblyImage(SkinImage skinImage, out Bitmap image) { try { image = ((Bitmap)(Properties.Resources.ResourceManager.GetObject(skinImage.ToString().ToLower(), Properties.Resources.Culture))); return(true); } catch (Exception e) { Console.WriteLine("LoadPath:" + e.Message); image = null; return(false); } }
public static void LoadTempSkinImages() { StringBuilder msg = new StringBuilder(1024); for (int i = 0; i < (int)SkinImage.Kind_Null; ++i) { SkinImage skinImage = (SkinImage)Enum.ToObject(typeof(SkinImage), i); LoadPath(skinImage, out Images[i], ref msg, GHManager.TempSettings.SkinName); } if (msg.Length > 0) { MessageBox.Show(msg.ToString(), "File Not Found."); } }
/// <summary> /// スキンの画像を描画 (繰り返し) /// </summary> /// <param name="graph">描画先</param> /// <param name="skinImage">描画する画像</param> /// <param name="rect">描画する位置とサイズ</param> public static void DrawingSkinImageRepeat(ref Graphics graph, SkinImage skinImage, Rectangle rect) { using (Image img = (Image)Images[(int)skinImage].Clone()) { Point imgPos = new Point(0, 0); while (imgPos.X < rect.Width) { imgPos.Y = 0; while (imgPos.Y < rect.Height) { graph.DrawImageUnscaled(img, imgPos); imgPos.Y += img.Height; } imgPos.X += img.Width; } } }
public static void On_Skin_Init(Skin self) { if ((graphicsTex == null) || (graphicsTex.GraphicsDevice != GnomanEmpire.Instance.GraphicsDevice) || graphicsTex.IsDisposed) { graphicsTex = CustomTextureManager.GetFromAssemblyResource(Assembly.GetExecutingAssembly(), "Faark.Gnomoria.Mods.Resources.maxButtons.png"); //Texture2D.FromStream(GnomanEmpire.Instance.GraphicsDevice, Assembly.GetExecutingAssembly().GetManifestResourceStream( "Faark.Gnomoria.Mods.Resources.maxButtons.png")); } var maxImg = new SkinImage(); maxImg.Resource = graphicsTex; // warning have to load it here! maxImg.Name = "Window.MaximizeButton"; self.Images.Add(maxImg); var mySkinLayer = new SkinLayer(); mySkinLayer.Name = "Control"; mySkinLayer.Alignment = Alignment.MiddleLeft; mySkinLayer.ContentMargins = new Margins(6); mySkinLayer.SizingMargins = new Margins(6); mySkinLayer.Image = maxImg; mySkinLayer.Height = 28; mySkinLayer.Width = 28; mySkinLayer.States.Disabled.Index = 2; mySkinLayer.States.Enabled.Index = 2; mySkinLayer.States.Focused.Index = 0; mySkinLayer.States.Hovered.Index = 0; mySkinLayer.States.Pressed.Index = 2; mySkinLayer.Text = new SkinText(self.Controls["Window.CloseButton"].Layers[0].Text); var mySkinControl = new SkinControl(); mySkinControl.Inherits = "Button"; mySkinControl.ResizerSize = 4; mySkinControl.DefaultSize = new Size(28, 28); mySkinControl.Name = "Window.MaximizeButton"; mySkinControl.Layers.Add(mySkinLayer); self.Controls.Add(mySkinControl); }
/// <summary> /// アイコンの描画 /// </summary> /// <param name="graph">描画先</param> public void Draw(ref Graphics graph, bool open) { GHPadding padding = GHManager.GetStyle(windowType).ItemPadding; Rectangle rect = new Rectangle { X = control.Location.X + padding.Left, Y = control.Location.Y + padding.Top, Width = control.Width - padding.WSize, Height = control.Height - padding.HSize }; if (open) { SkinImage skin = opened ? OpendImage : ClosedImage; Skin.GetSkinImage(skin, out Bitmap bmp); graph.DrawImage(bmp, rect); bmp.Dispose(); bmp = null; } else { Draw(ref graph); } }
public GHIconEx(SkinImage opened, SkinImage closed, FormType windowType) : base(closed, windowType) { OpendImage = opened; ClosedImage = closed; Init(); }
public GHItemIcon(SkinImage skin, FormType windowType) : base(skin, windowType) { Init(); }
public GHIconEx(ref Icon hIcon, FormType windowType) : base(ref hIcon, windowType) { OpendImage = ClosedImage = SkinImage.Kind_Null; Init(); }
protected override void DrawSkinImage(SkinElementInfo elementInfo, SkinImage skinImage) { base.DrawSkinImage(elementInfo, skinImage); }
public GHIconEx(Bitmap bmp, FormType windowType) : base(ref bmp, windowType) { OpendImage = ClosedImage = SkinImage.Kind_Null; Init(); }
/// <summary> /// スキンの読み込み /// </summary> /// <param name="skinImage">スキン画像の種類</param> /// <param name="image">画像の読み込み先</param> private static bool LoadPath(SkinImage skinImage, out Bitmap image, ref StringBuilder msg) { return(LoadPath(skinImage, out image, ref msg, GHManager.Settings.SkinName)); }
public GHIconEx(SkinImage skin, FormType windowType) : base(skin, windowType) { OpendImage = ClosedImage = skin; Init(); }