Showing posts with label Document. Show all posts
Showing posts with label Document. Show all posts

Saturday, February 14, 2015

How to create a document with LinsUIWPF Suite

Download   Demonstration  Question?   Contact Us


1.     Follow the link How to create a new project to create your project with LinsUIWPF Suite.
2.     Project->Add New Item …, it should bring up the following dialog.

Choose “WPF” as Category and “User Control (WPF)” as Template. Use “MyDocument” as the class name. Click “Add” button.
3.     Open MyDocument.xaml. Change the following code,
<UserControl x:Class="MyDemo.MyDocument"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Height="300" Width="300">
<Grid>
           
</Grid>
</UserControl>
to as follows, and assign a unique ID to it. The unique ID is for layout persistent. It should be between 1,000 and 10,000,000.
<src:FlexDocument x:Class="MyDemo.MyDocument"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:src="clr-namespace:LinsUIWPF;assembly=LinsUIWPF"
Height="300" Width="300" ID="1001">
<Grid>
            
</Grid>
</src:FlexDocument>
4.     Open MyDocument.xaml.cs.
Add the following line,
using LinsUIWPF;
and change the following code,
public partial class MyDocument : UserControl
{
public MyDocument()
{
InitializeComponent();
}
}
to as follows,
public partial class MyDocument : FlexDocument
{
public MyDocument()
{
InitializeComponent();
}
}
5.     Open Window1.xaml.cs.
Add the following code,
public partial class Window1 : LinsMDIWindow
{
public Window1()
{
InitializeComponent();

MyDocument doc = new MyDocument();
doc.ShowDocument();
}
}


Friday, February 13, 2015

FlexDocument


FlexDocument class
It is a customized dockable FlexDocument object. The user can drag a FlexDocument object and dock it at any place. Can also drag a FlexDocument object into a sheet and make it one of the pages of the sheet.
Examples
The following example shows how to create a FlexDocument object.
public partial class MyChildDocument : FlexDocument
{
// ***** //
} 
public partial class Window1 : LinsMDIWindow
{
public Window1()
{
InitializeComponent();

// Create a child document.
MyChildDocument myChild = new MyChildDocument();
// Show the document.
MyChild.ShowDocument();
}
}

§  Constructors
1)  public FlexDocument()
Remarks
Initialize a new instance of FlexDocument. 
§  Members
1)  public Rect Bounds { get; }
Remarks
Retrieve both the size and the location of the document including its non-client elements, in pixels, relative to its parent.
2)  public Rect BoundsAtMDIFrame { get; }
Remarks
Retrieve both the size and the location of the document including its non-client elements, in pixels, relative to MDI frame.
3)  public UIElement Content { get; set; }
Remarks
Gets or sets the content of the document.
4)  public virtual FLEX_DOCKING_ALIGN Dock { get; set; }
Remarks
Gets or sets which border of the main frame is to be docked to and determines how a control is resized with its parent. It can be one of the following values,
§   NONE:             
The control is not docked.
§   TOP:                
The control's top edge is docked to the top of its containing control.
§   BOTTOM:         
The control's bottom edge is docked to the bottom of its containing control.
§   LEFT:              
The control's left edge is docked to the left edge of its containing control.
§   RIGHT:             
The control's right edge is docked to the right edge of its containing control.
5)  public virtual WindowState DocumentState { get; set; }
Remarks
Gets or sets the state of the document; it can be one of the following values
§   Normal:             
The document is restored.
§   Minimized:                
The document is minimized.
§   Maximized:         
The document is maximized.
6)  public FLEX_DOCUMENTSTYLE DocumentStyle { get; }
Remarks
Retrieve the style of the document; it can be one of the following values
§   FLEX_DOCUMENT_REGULAR:             
The document is a normal document.
§   FLEX_DOCUMENT_TABPAGE:         
The document is one page of a FlexDocumentTabSheet sheet.
7)  public double Height { get; set; }
Remarks
Gets or sets the height of the document. UpdateSize() needs to be called for performing the size change.  This field will be ignored, if one of the following conditions is true,
a)  The Dock attribute of the document is FLEX_DOCKING_ALIGN .LEFT or FLEX_DOCKING_ALIGN .RIGHT.
b)  The document is one page of a FlexDocumentTabSheet.
8)  public virtual ImageSource Icon { get; set; }
Remarks
Gets or sets the icon of the document.
9)  public long ID { get; set; }               
Remarks
Every FlexDocument object should have a unique ID. If the user does not assign a number to the ID, a unique number which is larger than FlexConstants.m_nUserDefinedControlStartID (10,000,000) will be automatically generated and assigned to it. If the ID is between FlexConstants.m_nUserDefinedControlStartID (1000) and
FlexConstants.m_nUserDefinedControlStartID (10,000,000), then its layout will be persistent; otherwise, its layout will not be saved. You can always use LinsUIWPFDockingManager.GetDocumentFromAllPlacesByID() to retrieve its instance, once it is created
10)public FlexMenu MainMenu { get; set; }               
Remarks
Set the menu of this document. If it is set to null, the menu will be removed from the document.
11)public FlexRibbonMenu MainRibbonMenu { get; set; }               
Remarks
Set the ribbon menu of this document. If it is set to null, the ribbon menu will be removed from the document.
12)public virtual bool NoAnimate { get; set; }
Remarks
Gets or sets the animation ability of the document.
13)public virtual string Title { get; set; }
Remarks
Gets or sets the caption of the document.
14)public double Width { get; set; }
Remarks
Gets or sets the width of the document. UpdateSize() needs to be called for performing the size change.  This field will be ignored, if one of the following conditions is true,
a)  The Dock attribute of the document is FLEX_DOCKING_ALIGN .TOP or FLEX_DOCKING_ALIGN .BOTTOM.
b)  The document is one page of a FlexDocumentTabSheet.
§  Methods
1)  public virtual void Close()                   
Remarks
Close the document. 
2)  public void EnsureVisible()                 
Remarks
Move the document into view area if it is outside the view area.
3)  public virtual bool HitTest(
Point ptMousePosAtMDIFrame)                 
Parameters
ptMousePosAtMDIFrame
Type: Point
A location which is in MDI Frame coordinate. 
Remarks
Test whether the point, ptMousePosAtMDIFrame, which is in MDI Frame coordinate, is inside this document includes the non-client area.
4)  public virtual void RemoveToolBar(
FlexToolBar toolbar)                 
Parameters
toolbar
Type: FlexToolBar
The toolbar is going to be removed from this document. 
Remarks
This removes a toolbar from this document. 
5)  public void SetLocation(
Point ptLoc)
Parameters
ptLoc
Type: Point
A location which is relative its parent coordinates. 
Remarks
Set the location of the document, in pixels, relative to its parent. When the document is docked or is a page of a sheet, this method will be invalid.
6)  public void SetLocationAtMDIFrame(
Point ptMousePosAtMDIFrame)                 
Parameters
ptMousePosAtMDIFrame
Type: Point
A location which is relative to MDI Frame coordinates. 
Remarks
Set the location of the document, in pixels, relative to MDI Frame. When the document is docked or is a page of a sheet, this method will be invalid.
7)  public virtual bool ShowDocument()               
Remarks
This make the FlexDocument object visible.
8)  public virtual void UpdateSize()                 
Remarks
When width or height of a document is changed, this method needs to be called to performing the change.
 §  Events
1)     public event ContentChangedEventhandler ContentChanged              
Remarks
This event is fired when the content is changed.  


References:
Create a Document,
Features,
FlexDocumentTabSheet,
How To,
Index,
Instruction,
LinsUIWPFDockingManager,
LinsUIWPFUtil

FlexDocumentTabSheet




FlexDocumentTabSheet class
It represents a container that contains multiple documents which share the same space on the screen.
Remarks
The FlexDocumentTabSheet is useful for minimizing screen space usage while allowing an application to expose a large amount of data. A FlexDocumentTabSheet consists of at least two FlexDocument objects that share the same screen space. Only one FlexDocument in a FlexDocumentTabSheet is visible at a time. When a user select the tab of a FlexDocument, the contents of that FlexDocument become visible and the contents of the other FlexDocument objects are hidden.
This class enable user to do the following,
§   Drag a FlexDocument object into another FlexDocument object to form a new FlexDocumentTabSheet sheet.
§   Drag a page out of the sheet by dragging the tab.
§   Drag a FlexDocument into a sheet to make it one page of the sheet.
§   Group several sheets together by click “Group” button at the right upper corner of the sheet. Once sheets are grouped together, user can activate one page of a sheet; the pages with the same page index of all other grouped sheets will be activated.
§   Drag a FlexDocumentTabSheet object and dock it at any place during run time.
Examples
The following example shows how to create a FlexDocumentTabSheet object.
public partial class MyChildDocument1 : FlexDocument
{
// ***** //
} 
public partial class MyChildDocument2 : FlexDocument
{
// ***** //
} 
public partial class Window1 : LinsMDIWindow
      {
public Window1()
{
InitializeComponent();

// Create a child document.
MyChildDocument1 myChild1 = new MyChildDocument1();
// Show the document.
MyChild1.ShowDocument();

// Create another child document.
MyChildDocument2 myChild2 = new MyChildDocument2();
// Show the document.
myChild2.ShowDocument();

// Create a document tabsheet
FlexDocumentTabSheet sheet = new FlexDocumentTabSheet();
// Add child document 1 as one of its pages
sheet.AddPage( myChild1, false );
// Insert child document 2 as the first page
sheet.InsertPage( 0, myChild2, false );
// Show the sheet
sheet.ShowDocument();
}
}

§  Constructors
1)  public FlexDocumentTabSheet()
Remarks
Initialize a new instance of FlexDocumentTabSheet. 
§  Members
1)  public Rect Bounds { get; }
Remarks
Retrieve both the size and the location of the document sheet including its non-client elements, in pixels, relative to its parent.
2)  public Rect BoundsAtMDIFrame { get; }
Remarks
Retrieve both the size and the location of the document sheet including its non-client elements, in pixels, relative to MDI frame.
3)  public UIElement Content { get; set; }
Remarks
Gets or sets the content of the document sheet. 
4)  public virtual FLEX_DOCKING_ALIGN Dock { get; set; }
Remarks
Gets or sets which border of the main frame is to be docked to and determines how a control is resized with its parent. It can be one of the following values,
§   NONE:             
The control is not docked.
§   TOP:                
The control's top edge is docked to the top of its containing control.
§   BOTTOM:         
The control's bottom edge is docked to the bottom of its containing control.
§   LEFT:              
The control's left edge is docked to the left edge of its containing control.
§   RIGHT:             
The control's right edge is docked to the right edge of its containing control.
5)  public override WindowState DocumentState { get; set; }
Remarks
Gets or sets the state of the document sheet; it can be one of the following values
§   Normal:             
The document sheet is restored.
§   Minimized:                
The document sheet is minimized.
§   Maximized:         
The document sheet is maximized.
6)  public FLEX_DOCUMENTSTYLE DocumentStyle { get; }
Remarks
Retrieve the style of the document sheet; it must be FLEX_DOCUMENT_TABSHEET.
7)  public double Height { get; set; }
Remarks
Gets or sets the height of the sheet. UpdateSize() needs to be called for performing the size change.  This field will be ignored, if the Dock attribute of the sheet is FLEX_DOCKING_ALIGN .LEFT or FLEX_DOCKING_ALIGN .RIGHT.
8)  public virtual ImageSource Icon { get; set; }
Remarks
Gets or sets the icon of the document sheet.
9)  public long ID { get; set; }               
Remarks
A unique number which is larger than FlexConstants.m_nUserDefinedControlStartID (10,000,000) will be automatically generated and assigned to it. If the sheet has at least two pages, then it will never been destroyed, and its layout will be persistent. You can always use LinsUIWPFDockingManager.GetDocumentFromAllPlacesByID() to retrieve its instance, once it is created.
10)public FlexMenu MainMenu { get; set; }               
Remarks
Set the menu of this sheet. If it is set to null, the menu will be removed from the sheet.
11)public FlexRibbonMenu MainRibbonMenu { get; set; }               
Remarks
Set the ribbon menu of this sheet. If it is set to null, the ribbon menu will be removed from the sheet.
12)public override bool NoAnimate { get; set; }
Remarks
Gets or sets the animation ability of the document sheet.
13)public virtual int SelectedIndex { get; set; }
Remarks
Gets or sets the index of the selected page.
14)public virtual FlexDocument SelectedTab { get; }
Remarks
Retrieve the selected page.
15)public int TabCount { get; }
Remarks
Retrieve the number of pages. 
16)public FlexCollection<FlexDocument> TabPages { get; }
Remarks
Retrieve all pages. 
17)public override string Title { get; }
Remarks
Retrieve the caption of the active page.
18)public double Width { get; set; }
Remarks
Gets or sets the width of the sheet. UpdateSize() needs to be called for performing the size change.  This field will be ignored, if the Dock attribute of the sheet is FLEX_DOCKING_ALIGN .TOP or FLEX_DOCKING_ALIGN .BOTTOM.
§  Methods
1)  public void AddPage(
FlexDocument doc,
bool bUsingFirstChildInfo)
Parameters
doc
Type: FlexDocument
The FlexDocument is going to be added into the sheet.
bUsingFirstChildInfo
Type: bool
If the doc is the first and the only page of the sheet at the time, and bUsingFirstChildInfo is true, the sheet will use the doc.’s parameters, such as size, location, and docking style, to create it. If the sheet already has other pages, then this parameter will be ignored. 
Remarks
Add doc into the sheet as a page, and append the page at the bottom.
2)  public virtual void Close()                   
Remarks
Close the sheet. 
3)  public void ClosePage(
int nIndex)
Parameters
nIndex
Type: int
The page index of the page which is going to be close.
Remarks
Close a page.
4)  public void EnsureVisible()                 
Remarks
Move the document sheet into view area if it is outside the view area.
5)  public FlexDocument GetPage (
int nIndex)
Parameters
nIndex
Type: int
The page index.
Remarks
Retrieve the page by its specific position. It will return null, if the index exceeds the range.
6)  public int GetPageIndex(
FlexDocument doc)
Parameters
doc
Type: FlexDocument
A page of the sheet.
Remarks
Retrieve the page index of the page doc. It will return -1, if it is no one of the pages of the sheet.
7)  public int GetPageIndex(
long nPageID)
Parameters
nPageID
Type: long
The page id.
Remarks
Retrieve the page index of a page by its ID. It will return -1, if it is no one of the pages of the sheet.
8)  public FlexDocument[] GetTabPages()
Remarks
Retrieve all pages of the sheet.
9)  public virtual bool HitTest(
Point ptMousePosAtMDIFrame)                 
Parameters
ptMousePosAtMDIFrame
Type: Point
A location which is in MDI Frame coordinate. 
Remarks
Test whether the point, ptMousePosAtMDIFrame, which is in MDI Frame coordinate, is inside this document sheet includes the non-client area.
10)public void InsertPage(
int nIndex,
FlexDocument doc,
bool bUsingFirstChildInfo)
Parameters
nIndex
Type: int
The specific location where the FlexDocument is going to be inserted into the sheet.
doc
Type: FlexDocument
The FlexDocument is going to be added into the sheet.
bUsingFirstChildInfo
Type: bool
If the doc is the first and the only page of the sheet at the time, and bUsingFirstChildInfo is true, the sheet will use the doc.’s parameters, such as size, location, and docking style, to create it. If the sheet already has other pages, then this parameter will be ignored. 
Remarks
Insert doc into the sheet as a page at a specific position.
11)public void RemovePage(
FlexDocument doc)
Parameters
doc
Type: FlexDocument
The page will be removed from the sheet.
Remarks
Remove doc from the sheet.
12)public virtual void RemoveToolBar(
FlexToolBar toolbar)                 
Parameters
toolbar
Type: FlexToolBar
The toolbar is going to be removed from this sheet. 
Remarks
This removes a toolbar from this sheet. 
13)public void SetLocation(
Point ptLoc)
Parameters
ptLoc
Type: Point
A location which is relative its parent coordinates. 
Remarks
Set the location of the sheet, in pixels, relative to its parent. When the sheet is docked, this method will be invalid.
14)public void SetLocationAtMDIFrame(
Point ptMousePosAtMDIFrame)                 
Parameters
ptMousePosAtMDIFrame
Type: Point
A location which is relative to MDI Frame coordinates. 
Remarks
Set the location of the sheet, in pixels, relative to MDI Frame. When the sheet is docked, this method will be invalid.
15)public override bool ShowDocument()               
Remarks
This makes the sheet visible. 
16)public void SwitchPages(
FlexDocument doc1,
FlexDocument doc2)
Parameters
doc1
Type: FlexDocument
The first page whose position will be changed.
doc2
Type: FlexDocument
The second page whose position will be changed.
Remarks
Switch doc1 ‘s position with doc2 ‘s position.
17)public virtual void UpdateSize()                 
Remarks
When width or height of a sheet is changed, this method needs to be called to perform the change.
 §  Events
1)     public event ContentChangedEventhandler ContentChanged              
Remarks
This event is fired when the content is changed. 
2)     public event SelectedIndexChangedEventhandler SelectedIndexChanged              
Remarks
This event is fired when the active page is changed.  


Demo



References: