Monthly Archives: September 2012

poster conference.net

Conference.net the poster !

Advertisements

poster conference.net

In 2001, I have assisted the conference.net event where MS guys and kids presented the .NET Framework. Amazing.

http://ultrafluid.codeplex.com

The entire application is available at http://ultrafluid.codeplex.com

2 new features : multiple selection and clipboard / and serialization !

Now, I can select multiple elements (with the SHIFT key) and make a right click to have clipboard support. The feature of copy/paste is very usefull.

Another feature is the XML serialization. I can load and save XML diagram with the boost::serialization.

Managing the Gdi+ drawing context

For drawing stuff, I rely on Gdi+ which is easier to use for advanced graphics rather than Gdi. Transformation and scaling operations are provided with appropriate methods.


#pragma once
#include "Element.h"

class CDrawingContext
{
public:
// Drawing Attributes are built in the ctor
CDrawingContext(std::shared_ptr<CElement> pElement);
virtual ~CDrawingContext(void);

public:
Graphics * GetGraphics() { return m_pGraphics; }
// Methods for Drawing Attributes
public:
Color & GetColorWhite() { return m_gdiColorWhite; }
Color & GetColorBlack() { return m_gdiColorBlack; }
Color & GetColorLine() { return m_gdiColorLine; }
Color & GetColorFill() {     return m_gdiColorFill; }
Pen & GetPenBlack() { return m_gdiPenBlack; }
Pen & GetPenColor() { return m_gdiPenColor; }
SolidBrush & GetBrushColor() { return m_gdiBrushColor; }
SolidBrush & GetBrushBlack() { return m_gdiBrushBlack; }
LinearGradientBrush & GetGradientBrushColor() { return m_gdiGradientBrush; }
CPoint GetTopLeft() { return m_pointTopLeft; }
CPoint GetBottomRight() { return m_pointBottomRight; }

public:
Graphics * m_pGraphics;

public:
// GDI+ Drawing objects
Color m_gdiColorWhite;
Color m_gdiColorBlack;
Color m_gdiColorLine;
Color m_gdiColorFill;
Pen m_gdiPenBlack;
Pen m_gdiPenColor;
SolidBrush m_gdiBrushColor;
SolidBrush m_gdiBrushBlack;
LinearGradientBrush m_gdiGradientBrush;

// MFC Drawing objects
CPoint m_pointTopLeft;
CPoint m_pointBottomRight;
};

#include "StdAfx.h"
#include "DrawingContext.h"

CDrawingContext::CDrawingContext(std::shared_ptr<CElement> pElement)
: m_gdiPenBlack(Color(255, 0, 0, 0)),
m_gdiPenColor(Color(255, 0, 0, 0)),
m_gdiBrushColor(m_gdiColorBlack),
m_gdiBrushBlack(m_gdiColorBlack),
m_gdiGradientBrush(
Point(pElement->m_rect.left, pElement->m_rect.top),
Point(pElement->m_rect.right, pElement->m_rect.bottom),
m_gdiColorBlack,
m_gdiColorBlack)
{
m_gdiColorWhite.SetFromCOLORREF(Color::White);
m_gdiColorBlack.SetFromCOLORREF(Color::Black);
m_gdiColorLine.SetValue(Color::MakeARGB(255, GetRValue(pElement->m_colorLine), GetGValue(pElement->m_colorLine), GetBValue(pElement->m_colorLine)));
m_gdiColorFill.SetValue(Color::MakeARGB(255, GetRValue(pElement->m_colorFill), GetGValue(pElement->m_colorFill), GetBValue(pElement->m_colorFill)));
m_gdiPenBlack.SetColor(m_gdiColorBlack);
m_gdiPenColor.SetColor(m_gdiColorLine);
m_gdiPenColor.SetWidth(pElement->m_lineWidth);
m_pointTopLeft = pElement->m_rect.TopLeft();
m_pointBottomRight = pElement->m_rect.BottomRight();
m_gdiBrushColor.SetColor(m_gdiColorFill);

Color color1(255, 241, 247, 255);
m_gdiGradientBrush.SetLinearColors(color1, m_gdiColorFill);

}

CDrawingContext::~CDrawingContext(void)
{
}

Using Boost for XML serialization

In UltraFluid, I add a feature that enable users to save and load diagrams as XML files. The jobs is done using boost 1.51 and its inner library called boost::serialization. It took me some time to adopt the library but is ok now. I made a clone of my objects with only C++ types because boost cannot handle my MFC types like CRect of CPoint. My XML document is a simple: vector<boost::shared_ptr<CSimpleShape> > m_shapes;

I have just transferred my own data type to the boost data type. To avoid namespace collision, I have put std:: prefix on every shared_ptr of my program. The problem is now that I handled two versions of STL in my applications. I should find a solution to use only boost STL.