using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using SFML;
using SFML.Audio;
using SFML.Window;
using SFML.Graphics;
namespace _01_AddingRibbonSupport
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
}
using System;
using System.Windows.Forms;
using RibbonLib;
using RibbonLib.Interop;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SFML;
using SFML.Audio;
using SFML.Window;
using SFML.Graphics;
namespace _01_AddingRibbonSupport
{
public partial class Form1 : Form, IRibbonForm
{
public class DrawingSurface : System.Windows.Forms.Control
{
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
{
// don't call base.OnPaint(e) to prevent forground painting
// base.OnPaint(e);
}
protected override void OnPaintBackground(System.Windows.Forms.PaintEventArgs pevent)
{
// don't call base.OnPaintBackground(e) to prevent background painting
//base.OnPaintBackground(pevent);
}
}
private Ribbon _ribbon = new Ribbon();
public Form1()
{
InitializeComponent();
DrawingSurface rendersurface = new DrawingSurface(); // our control for SFML to draw on
rendersurface.Size = new System.Drawing.Size(400, 400); // set our SFML surface control size to be 500 width & 500 height
lblPlaceHolderDescription.Controls.Add(rendersurface); // add the SFML surface control to our form
rendersurface.Location = new System.Drawing.Point(100, 100); // center our control on the form
// initialize sfml
SFML.Graphics.RenderWindow renderwindow = new SFML.Graphics.RenderWindow(rendersurface.Handle); // creates our SFML RenderWindow on our surface control
// drawing loop
while (lblPlaceHolderDescription.Visible) // loop while the window is open
{
System.Windows.Forms.Application.DoEvents(); // handle form events
renderwindow.DispatchEvents(); // handle SFML events - NOTE this is still required when SFML is hosted in another window
renderwindow.Clear(SFML.Graphics.Color.Yellow); // clear our SFML RenderWindow
renderwindow.Display(); // display what SFML has drawn to the screen
}
}
#region IRibbonForm Members
public IntPtr WindowHandle
{
get
{
return this.Handle;
}
}
public void RibbonHeightUpdated(int newHeight)
{
this.splitContainer1.SplitterDistance = newHeight;
}
#endregion
private void Form1_Load(object sender, EventArgs e)
{
_ribbon.InitFramework(this);
}
private void Form1_FormClosed(object sender, FormClosedEventArgs e)
{
_ribbon.DestroyFramework();
}
}
}
I'm using window 64-bit.SFML.Net and CSFML DLLs must match the architecture of your project, not your OS. We don't care about the OS, it can handle both architectures fine.
So I've change all SFML's dll from 32-bit to 64-bit.
I wonder that handling in label is the right way to show in WinForm?I guess you can do it in any kind of control. I've seen people using a Picture control as well. But again, this problem has nothing to do with your code. Any other SFML code would fail with the same error.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using SFML;
using SFML.Audio;
using SFML.Window;
using SFML.Graphics;
namespace _01_AddingRibbonSupport
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
}
using System;
using System.Windows.Forms;
using RibbonLib;
using RibbonLib.Interop;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SFML;
using SFML.Audio;
using SFML.Window;
using SFML.Graphics;
namespace _01_AddingRibbonSupport
{
public partial class Form1 : Form, IRibbonForm
{
public class DrawingSurface : System.Windows.Forms.Control
{
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
{
// don't call base.OnPaint(e) to prevent forground painting
// base.OnPaint(e);
}
protected override void OnPaintBackground(System.Windows.Forms.PaintEventArgs pevent)
{
// don't call base.OnPaintBackground(e) to prevent background painting
//base.OnPaintBackground(pevent);
}
}
private Ribbon _ribbon = new Ribbon();
public Form1()
{
InitializeComponent();
DrawingSurface rendersurface = new DrawingSurface(); // our control for SFML to draw on
rendersurface.Size = new System.Drawing.Size(400, 400); // set our SFML surface control size to be 500 width & 500 height
lblPlaceHolderDescription.Controls.Add(rendersurface); // add the SFML surface control to our form
rendersurface.Location = new System.Drawing.Point(100, 100); // center our control on the form
// initialize sfml
SFML.Graphics.RenderWindow renderwindow = new SFML.Graphics.RenderWindow(rendersurface.Handle); // creates our SFML RenderWindow on our surface control
// drawing loop
while (lblPlaceHolderDescription.Visible) // loop while the window is open
{
System.Windows.Forms.Application.DoEvents(); // handle form events
renderwindow.DispatchEvents(); // handle SFML events - NOTE this is still required when SFML is hosted in another window
renderwindow.Clear(SFML.Graphics.Color.Yellow); // clear our SFML RenderWindow
renderwindow.Display(); // display what SFML has drawn to the screen
}
}
#region IRibbonForm Members
public IntPtr WindowHandle
{
get
{
return this.Handle;
}
}
public void RibbonHeightUpdated(int newHeight)
{
this.splitContainer1.SplitterDistance = newHeight;
}
#endregion
private void Form1_Load(object sender, EventArgs e)
{
_ribbon.InitFramework(this);
}
private void Form1_FormClosed(object sender, FormClosedEventArgs e)
{
_ribbon.DestroyFramework();
}
}
}