agate-svn-commit Mailing List for AgateLib (Page 14)
Status: Alpha
Brought to you by:
kanato
You can subscribe to this list here.
| 2009 |
Jan
|
Feb
|
Mar
|
Apr
(86) |
May
(77) |
Jun
|
Jul
(1) |
Aug
(31) |
Sep
(12) |
Oct
(31) |
Nov
(53) |
Dec
(39) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2010 |
Jan
(53) |
Feb
(14) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(2) |
Sep
|
Oct
|
Nov
(7) |
Dec
(13) |
| 2011 |
Jan
(17) |
Feb
(5) |
Mar
(1) |
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
(10) |
Nov
(21) |
Dec
|
| 2012 |
Jan
(6) |
Feb
(14) |
Mar
(5) |
Apr
(4) |
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2013 |
Jan
(1) |
Feb
(8) |
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
(2) |
Sep
(1) |
Oct
(5) |
Nov
(9) |
Dec
(5) |
| 2014 |
Jan
(3) |
Feb
(2) |
Mar
(4) |
Apr
(3) |
May
|
Jun
(5) |
Jul
(33) |
Aug
(69) |
Sep
(35) |
Oct
(4) |
Nov
(1) |
Dec
|
|
From: <ka...@us...> - 2010-01-30 18:12:02
|
Revision: 1212
http://agate.svn.sourceforge.net/agate/?rev=1212&view=rev
Author: kanato
Date: 2010-01-30 18:11:55 +0000 (Sat, 30 Jan 2010)
Log Message:
-----------
Move user controls to DataBaseEditor project.
Modified Paths:
--------------
trunk/Tools/AgateDataLib/AgateDataLib.csproj
trunk/Tools/AgateDataLib/CodeGenerator.cs
trunk/Tools/DatabaseEditor/DatabaseEditor.csproj
trunk/Tools/DatabaseEditor/Program.cs
trunk/Tools/DatabaseEditor/Properties/Resources.Designer.cs
trunk/Tools/DatabaseEditor/Properties/Settings.Designer.cs
trunk/Tools/DatabaseEditor/frmCodeGenerator.Designer.cs
trunk/Tools/DatabaseEditor/frmCodeGenerator.cs
trunk/Tools/DatabaseEditor/frmEditor.Designer.cs
trunk/Tools/DatabaseEditor/frmEditor.cs
trunk/Tools/DatabaseEditor/frmImportTable.Designer.cs
trunk/Tools/DatabaseEditor/frmImportTable.cs
Added Paths:
-----------
trunk/Tools/DatabaseEditor/DatabaseEditor.Designer.cs
trunk/Tools/DatabaseEditor/DatabaseEditor.cs
trunk/Tools/DatabaseEditor/DatabaseEditor.resx
trunk/Tools/DatabaseEditor/TableEditor.Designer.cs
trunk/Tools/DatabaseEditor/TableEditor.cs
trunk/Tools/DatabaseEditor/TableEditor.resx
trunk/Tools/DatabaseEditor/frmDesignTable.Designer.cs
trunk/Tools/DatabaseEditor/frmDesignTable.cs
trunk/Tools/DatabaseEditor/frmDesignTable.resx
Removed Paths:
-------------
trunk/Tools/AgateDataLib/DatabaseEditor.Designer.cs
trunk/Tools/AgateDataLib/DatabaseEditor.cs
trunk/Tools/AgateDataLib/DatabaseEditor.resx
trunk/Tools/AgateDataLib/TableEditor.Designer.cs
trunk/Tools/AgateDataLib/TableEditor.cs
trunk/Tools/AgateDataLib/TableEditor.resx
trunk/Tools/AgateDataLib/frmDesignTable.Designer.cs
trunk/Tools/AgateDataLib/frmDesignTable.cs
trunk/Tools/AgateDataLib/frmDesignTable.resx
Modified: trunk/Tools/AgateDataLib/AgateDataLib.csproj
===================================================================
--- trunk/Tools/AgateDataLib/AgateDataLib.csproj 2010-01-30 18:08:50 UTC (rev 1211)
+++ trunk/Tools/AgateDataLib/AgateDataLib.csproj 2010-01-30 18:11:55 UTC (rev 1212)
@@ -84,26 +84,8 @@
</ItemGroup>
<ItemGroup>
<Compile Include="CodeGenerator.cs" />
- <Compile Include="DatabaseEditor.cs">
- <SubType>UserControl</SubType>
- </Compile>
- <Compile Include="DatabaseEditor.Designer.cs">
- <DependentUpon>DatabaseEditor.cs</DependentUpon>
- </Compile>
<Compile Include="DatabaseWriter.cs" />
- <Compile Include="frmDesignTable.cs">
- <SubType>Form</SubType>
- </Compile>
- <Compile Include="frmDesignTable.Designer.cs">
- <DependentUpon>frmDesignTable.cs</DependentUpon>
- </Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
- <Compile Include="TableEditor.cs">
- <SubType>UserControl</SubType>
- </Compile>
- <Compile Include="TableEditor.Designer.cs">
- <DependentUpon>TableEditor.cs</DependentUpon>
- </Compile>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\AgateLib\AgateLib.csproj">
@@ -112,20 +94,6 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
- <EmbeddedResource Include="DatabaseEditor.resx">
- <DependentUpon>DatabaseEditor.cs</DependentUpon>
- <SubType>Designer</SubType>
- </EmbeddedResource>
- <EmbeddedResource Include="frmDesignTable.resx">
- <DependentUpon>frmDesignTable.cs</DependentUpon>
- <SubType>Designer</SubType>
- </EmbeddedResource>
- <EmbeddedResource Include="TableEditor.resx">
- <DependentUpon>TableEditor.cs</DependentUpon>
- <SubType>Designer</SubType>
- </EmbeddedResource>
- </ItemGroup>
- <ItemGroup>
<Content Include="Images\NewTable.png" />
<Content Include="Images\NewTableLarge.png" />
<Content Include="Images\TableHS.png" />
Modified: trunk/Tools/AgateDataLib/CodeGenerator.cs
===================================================================
--- trunk/Tools/AgateDataLib/CodeGenerator.cs 2010-01-30 18:08:50 UTC (rev 1211)
+++ trunk/Tools/AgateDataLib/CodeGenerator.cs 2010-01-30 18:11:55 UTC (rev 1212)
@@ -8,7 +8,7 @@
using System.Text;
using AgateLib.Data;
-namespace DatabaseEditor
+namespace AgateDataLib
{
public class CodeGenerator
{
Deleted: trunk/Tools/AgateDataLib/DatabaseEditor.Designer.cs
===================================================================
--- trunk/Tools/AgateDataLib/DatabaseEditor.Designer.cs 2010-01-30 18:08:50 UTC (rev 1211)
+++ trunk/Tools/AgateDataLib/DatabaseEditor.Designer.cs 2010-01-30 18:11:55 UTC (rev 1212)
@@ -1,237 +0,0 @@
-namespace AgateDataLib
-{
- partial class DatabaseEditor
- {
- /// <summary>
- /// Required designer variable.
- /// </summary>
- private System.ComponentModel.IContainer components = null;
-
- /// <summary>
- /// Clean up any resources being used.
- /// </summary>
- /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
- protected override void Dispose(bool disposing)
- {
- if (disposing && (components != null))
- {
- components.Dispose();
- }
- base.Dispose(disposing);
- }
-
- #region Component Designer generated code
-
- /// <summary>
- /// Required method for Designer support - do not modify
- /// the contents of this method with the code editor.
- /// </summary>
- private void InitializeComponent()
- {
- this.components = new System.ComponentModel.Container();
- System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(DatabaseEditor));
- this.lstTables = new System.Windows.Forms.ListView();
- this.largeImages = new System.Windows.Forms.ImageList(this.components);
- this.smallImages = new System.Windows.Forms.ImageList(this.components);
- this.tabs = new System.Windows.Forms.TabControl();
- this.tabContextMenu = new System.Windows.Forms.ContextMenuStrip(this.components);
- this.closeTabToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.splitContainer1 = new System.Windows.Forms.SplitContainer();
- this.lvContextMenu = new System.Windows.Forms.ContextMenuStrip(this.components);
- this.viewToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.largeIconsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.smallIconsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.listToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.tableContextMenu = new System.Windows.Forms.ContextMenuStrip(this.components);
- this.renameToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.deleteToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.duplicateToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.tabContextMenu.SuspendLayout();
- this.splitContainer1.Panel1.SuspendLayout();
- this.splitContainer1.Panel2.SuspendLayout();
- this.splitContainer1.SuspendLayout();
- this.lvContextMenu.SuspendLayout();
- this.tableContextMenu.SuspendLayout();
- this.SuspendLayout();
- //
- // lstTables
- //
- this.lstTables.Dock = System.Windows.Forms.DockStyle.Fill;
- this.lstTables.LabelEdit = true;
- this.lstTables.LargeImageList = this.largeImages;
- this.lstTables.Location = new System.Drawing.Point(0, 0);
- this.lstTables.Name = "lstTables";
- this.lstTables.Size = new System.Drawing.Size(172, 538);
- this.lstTables.SmallImageList = this.smallImages;
- this.lstTables.TabIndex = 6;
- this.lstTables.UseCompatibleStateImageBehavior = false;
- this.lstTables.View = System.Windows.Forms.View.SmallIcon;
- this.lstTables.AfterLabelEdit += new System.Windows.Forms.LabelEditEventHandler(this.lstTables_AfterLabelEdit);
- this.lstTables.DoubleClick += new System.EventHandler(this.lstTables_DoubleClick);
- this.lstTables.MouseUp += new System.Windows.Forms.MouseEventHandler(this.lstTables_MouseUp);
- this.lstTables.MouseDown += new System.Windows.Forms.MouseEventHandler(this.lstTables_MouseDown);
- this.lstTables.KeyDown += new System.Windows.Forms.KeyEventHandler(this.lstTables_KeyDown);
- //
- // largeImages
- //
- this.largeImages.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("largeImages.ImageStream")));
- this.largeImages.TransparentColor = System.Drawing.Color.Transparent;
- this.largeImages.Images.SetKeyName(0, "TableHSLarge.png");
- this.largeImages.Images.SetKeyName(1, "NewTableLarge.png");
- //
- // smallImages
- //
- this.smallImages.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("smallImages.ImageStream")));
- this.smallImages.TransparentColor = System.Drawing.Color.Transparent;
- this.smallImages.Images.SetKeyName(0, "TableHS.png");
- this.smallImages.Images.SetKeyName(1, "NewTable.png");
- //
- // tabs
- //
- this.tabs.ContextMenuStrip = this.tabContextMenu;
- this.tabs.Dock = System.Windows.Forms.DockStyle.Fill;
- this.tabs.Location = new System.Drawing.Point(0, 0);
- this.tabs.Name = "tabs";
- this.tabs.SelectedIndex = 0;
- this.tabs.Size = new System.Drawing.Size(441, 538);
- this.tabs.TabIndex = 7;
- this.tabs.MouseUp += new System.Windows.Forms.MouseEventHandler(this.tabs_MouseUp);
- //
- // tabContextMenu
- //
- this.tabContextMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
- this.closeTabToolStripMenuItem});
- this.tabContextMenu.Name = "tabContextMenu";
- this.tabContextMenu.Size = new System.Drawing.Size(104, 26);
- //
- // closeTabToolStripMenuItem
- //
- this.closeTabToolStripMenuItem.Name = "closeTabToolStripMenuItem";
- this.closeTabToolStripMenuItem.Size = new System.Drawing.Size(103, 22);
- this.closeTabToolStripMenuItem.Text = "Close";
- this.closeTabToolStripMenuItem.Click += new System.EventHandler(this.closeTabToolStripMenuItem_Click);
- //
- // splitContainer1
- //
- this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
- this.splitContainer1.FixedPanel = System.Windows.Forms.FixedPanel.Panel1;
- this.splitContainer1.Location = new System.Drawing.Point(0, 0);
- this.splitContainer1.Name = "splitContainer1";
- //
- // splitContainer1.Panel1
- //
- this.splitContainer1.Panel1.Controls.Add(this.lstTables);
- //
- // splitContainer1.Panel2
- //
- this.splitContainer1.Panel2.Controls.Add(this.tabs);
- this.splitContainer1.Size = new System.Drawing.Size(617, 538);
- this.splitContainer1.SplitterDistance = 172;
- this.splitContainer1.TabIndex = 8;
- //
- // lvContextMenu
- //
- this.lvContextMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
- this.viewToolStripMenuItem});
- this.lvContextMenu.Name = "lvContextMenu";
- this.lvContextMenu.Size = new System.Drawing.Size(100, 26);
- //
- // viewToolStripMenuItem
- //
- this.viewToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
- this.largeIconsToolStripMenuItem,
- this.smallIconsToolStripMenuItem,
- this.listToolStripMenuItem});
- this.viewToolStripMenuItem.Name = "viewToolStripMenuItem";
- this.viewToolStripMenuItem.Size = new System.Drawing.Size(99, 22);
- this.viewToolStripMenuItem.Text = "View";
- //
- // largeIconsToolStripMenuItem
- //
- this.largeIconsToolStripMenuItem.Name = "largeIconsToolStripMenuItem";
- this.largeIconsToolStripMenuItem.Size = new System.Drawing.Size(134, 22);
- this.largeIconsToolStripMenuItem.Text = "Large Icons";
- this.largeIconsToolStripMenuItem.Click += new System.EventHandler(this.largeIconsToolStripMenuItem_Click);
- //
- // smallIconsToolStripMenuItem
- //
- this.smallIconsToolStripMenuItem.Checked = true;
- this.smallIconsToolStripMenuItem.CheckState = System.Windows.Forms.CheckState.Checked;
- this.smallIconsToolStripMenuItem.Name = "smallIconsToolStripMenuItem";
- this.smallIconsToolStripMenuItem.Size = new System.Drawing.Size(134, 22);
- this.smallIconsToolStripMenuItem.Text = "Small Icons";
- this.smallIconsToolStripMenuItem.Click += new System.EventHandler(this.smallIconsToolStripMenuItem_Click);
- //
- // listToolStripMenuItem
- //
- this.listToolStripMenuItem.Name = "listToolStripMenuItem";
- this.listToolStripMenuItem.Size = new System.Drawing.Size(134, 22);
- this.listToolStripMenuItem.Text = "List";
- this.listToolStripMenuItem.Click += new System.EventHandler(this.listToolStripMenuItem_Click);
- //
- // tableContextMenu
- //
- this.tableContextMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
- this.renameToolStripMenuItem,
- this.duplicateToolStripMenuItem,
- this.deleteToolStripMenuItem});
- this.tableContextMenu.Name = "tableContextMenu";
- this.tableContextMenu.Size = new System.Drawing.Size(153, 92);
- //
- // renameToolStripMenuItem
- //
- this.renameToolStripMenuItem.Name = "renameToolStripMenuItem";
- this.renameToolStripMenuItem.Size = new System.Drawing.Size(126, 22);
- this.renameToolStripMenuItem.Text = "Rename...";
- this.renameToolStripMenuItem.Click += new System.EventHandler(this.renameToolStripMenuItem_Click);
- //
- // deleteToolStripMenuItem
- //
- this.deleteToolStripMenuItem.Name = "deleteToolStripMenuItem";
- this.deleteToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
- this.deleteToolStripMenuItem.Text = "Delete";
- this.deleteToolStripMenuItem.Click += new System.EventHandler(this.deleteToolStripMenuItem_Click);
- //
- // duplicateToolStripMenuItem
- //
- this.duplicateToolStripMenuItem.Name = "duplicateToolStripMenuItem";
- this.duplicateToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
- this.duplicateToolStripMenuItem.Text = "Duplicate";
- //
- // DatabaseEditor
- //
- this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.Controls.Add(this.splitContainer1);
- this.Name = "DatabaseEditor";
- this.Size = new System.Drawing.Size(617, 538);
- this.tabContextMenu.ResumeLayout(false);
- this.splitContainer1.Panel1.ResumeLayout(false);
- this.splitContainer1.Panel2.ResumeLayout(false);
- this.splitContainer1.ResumeLayout(false);
- this.lvContextMenu.ResumeLayout(false);
- this.tableContextMenu.ResumeLayout(false);
- this.ResumeLayout(false);
-
- }
-
- #endregion
-
- private System.Windows.Forms.ListView lstTables;
- private System.Windows.Forms.TabControl tabs;
- private System.Windows.Forms.SplitContainer splitContainer1;
- private System.Windows.Forms.ImageList smallImages;
- private System.Windows.Forms.ImageList largeImages;
- private System.Windows.Forms.ContextMenuStrip lvContextMenu;
- private System.Windows.Forms.ToolStripMenuItem viewToolStripMenuItem;
- private System.Windows.Forms.ToolStripMenuItem largeIconsToolStripMenuItem;
- private System.Windows.Forms.ToolStripMenuItem smallIconsToolStripMenuItem;
- private System.Windows.Forms.ToolStripMenuItem listToolStripMenuItem;
- private System.Windows.Forms.ContextMenuStrip tableContextMenu;
- private System.Windows.Forms.ToolStripMenuItem renameToolStripMenuItem;
- private System.Windows.Forms.ToolStripMenuItem deleteToolStripMenuItem;
- private System.Windows.Forms.ContextMenuStrip tabContextMenu;
- private System.Windows.Forms.ToolStripMenuItem closeTabToolStripMenuItem;
- private System.Windows.Forms.ToolStripMenuItem duplicateToolStripMenuItem;
- }
-}
Deleted: trunk/Tools/AgateDataLib/DatabaseEditor.cs
===================================================================
--- trunk/Tools/AgateDataLib/DatabaseEditor.cs 2010-01-30 18:08:50 UTC (rev 1211)
+++ trunk/Tools/AgateDataLib/DatabaseEditor.cs 2010-01-30 18:11:55 UTC (rev 1212)
@@ -1,272 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Drawing;
-using System.Data;
-using System.Linq;
-using System.Text;
-using System.Windows.Forms;
-using AgateLib.Data;
-
-namespace AgateDataLib
-{
- public partial class DatabaseEditor : UserControl
- {
- AgateDatabase mDatabase;
-
- public DatabaseEditor()
- {
- InitializeComponent();
- }
-
- public AgateDatabase Database
- {
- get
- {
- return mDatabase;
- }
- set
- {
- mDatabase = value;
-
- DatabaseRefresh();
- }
- }
-
- public void DatabaseRefresh()
- {
- lstTables.Clear();
- lstTables.Groups.Clear();
-
- if (Database == null)
- {
- tabs.TabPages.Clear();
-
- return;
- }
-
- ListViewGroup taskGroup = new ListViewGroup("Tasks");
- ListViewGroup tableGroup = new ListViewGroup("Tables");
-
- lstTables.Groups.Add(taskGroup);
- lstTables.Groups.Add(tableGroup);
-
- ListViewItem newTable = new ListViewItem("New Table");
- newTable.ImageIndex = 1;
- newTable.Tag = new InvokeDelegate(NewTable);
- newTable.Group = taskGroup;
-
- lstTables.Items.Add(newTable);
-
-
- foreach (var table in Database.Tables)
- {
- ListViewItem item = new ListViewItem(table.Name);
- item.ImageIndex = 0;
- item.Tag = table;
- item.Group = tableGroup;
-
- lstTables.Items.Add(item);
- }
-
- List<TabPage> pagesToRemove = new List<TabPage>();
-
- foreach (TabPage tab in tabs.TabPages)
- {
- TableEditor ed = tab.Controls[0] as TableEditor;
-
- if (ed == null)
- continue;
-
- if (Database.Tables.Contains(ed.AgateTable) == false)
- {
- pagesToRemove.Add(tab);
- }
- }
-
- foreach (var tab in pagesToRemove)
- tabs.TabPages.Remove(tab);
- }
-
- private void lstTables_DoubleClick(object sender, EventArgs e)
- {
- if (lstTables.SelectedItems.Count == 0)
- return;
-
- object obj = lstTables.SelectedItems[0].Tag ;
- AgateTable table = obj as AgateTable;
- InvokeDelegate method = obj as InvokeDelegate;
-
- if (table != null)
- {
- OpenTableTab(table);
- }
- if (method != null)
- {
- method();
- }
- }
-
- private void OpenTableTab(AgateTable table)
- {
- foreach (TabPage tab in tabs.TabPages)
- {
- Control ctrl = tab.Controls[0];
-
- if (ctrl is TableEditor)
- {
- TableEditor tb = (TableEditor)ctrl;
-
- if (tb.AgateTable == table)
- {
- tabs.SelectedTab = tab;
- return;
- }
- }
- }
-
- TabPage page = new TabPage(table.Name);
-
- TableEditor editor = new TableEditor();
- editor.Database = Database;
- editor.AgateTable = table;
- editor.Dock = DockStyle.Fill;
-
- page.Controls.Add(editor);
-
- tabs.TabPages.Add(page);
-
- tabs.SelectedTab = page;
- }
-
- private void NewTable()
- {
- MessageBox.Show("Creating new table");
- }
-
- private void closeTabToolStripMenuItem_Click(object sender, EventArgs e)
- {
- TableEditor editor = tabs.SelectedTab.Controls[0] as TableEditor;
-
- if (editor != null)
- {
- editor.FinalizeData();
- }
-
- tabs.TabPages.Remove(tabs.SelectedTab);
- }
-
- private void largeIconsToolStripMenuItem_Click(object sender, EventArgs e)
- {
- lstTables.View = View.LargeIcon;
-
- smallIconsToolStripMenuItem.Checked = false;
- largeIconsToolStripMenuItem.Checked = true;
- listToolStripMenuItem.Checked = false;
- }
-
- private void smallIconsToolStripMenuItem_Click(object sender, EventArgs e)
- {
- lstTables.View = View.SmallIcon;
-
- smallIconsToolStripMenuItem.Checked = true;
- largeIconsToolStripMenuItem.Checked = false;
- listToolStripMenuItem.Checked = false;
- }
-
- private void listToolStripMenuItem_Click(object sender, EventArgs e)
- {
- lstTables.View = View.List;
-
- smallIconsToolStripMenuItem.Checked = false;
- largeIconsToolStripMenuItem.Checked = false;
- listToolStripMenuItem.Checked = true;
- }
-
- private void lstTables_MouseDown(object sender, MouseEventArgs e)
- {
-
- }
-
- private void lstTables_MouseUp(object sender, MouseEventArgs e)
- {
- if (e.Button == MouseButtons.Right)
- {
- ContextMenuStrip menu = null;
-
- if (lstTables.SelectedItems.Count == 0)
- menu = lvContextMenu;
- else if (lstTables.SelectedItems.Count == 1)
- {
- if (lstTables.SelectedItems[0].Tag is AgateTable)
- {
- menu = tableContextMenu;
- }
- }
-
- if (menu != null)
- menu.Show(lstTables, e.Location);
- }
- }
-
- private void tabs_MouseUp(object sender, MouseEventArgs e)
- {
- closeTabToolStripMenuItem.Text = "Close " + tabs.SelectedTab.Text;
- }
-
- private void renameToolStripMenuItem_Click(object sender, EventArgs e)
- {
- if (lstTables.SelectedItems.Count == 0)
- return;
-
- lstTables.SelectedItems[0].BeginEdit();
-
- }
-
- private void lstTables_AfterLabelEdit(object sender, LabelEditEventArgs e)
- {
- object obj = lstTables.SelectedItems[0].Tag;
- AgateTable table = obj as AgateTable;
-
- if (Database.Tables.ContainsTable(e.Label))
- {
- e.CancelEdit = true;
- }
- else
- table.Name = e.Label;
- }
-
- private void lstTables_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.KeyCode == Keys.F2)
- {
- if (lstTables.SelectedItems.Count == 0)
- return;
-
- lstTables.SelectedItems[0].BeginEdit();
- }
- }
-
- private void deleteToolStripMenuItem_Click(object sender, EventArgs e)
- {
- if (lstTables.SelectedItems.Count == 0)
- return;
-
- object obj = lstTables.SelectedItems[0].Tag;
- AgateTable table = obj as AgateTable;
-
- if (MessageBox.Show(this,
- "Really delete table " + table.Name + "?" + Environment.NewLine + Environment.NewLine +
- "This operation cannot be undone.",
- "Delete Table?", MessageBoxButtons.YesNo, MessageBoxIcon.Question,
- MessageBoxDefaultButton.Button2) == DialogResult.Yes)
- {
- Database.Tables.Remove(table);
- }
- }
-
- }
-
- delegate void InvokeDelegate();
-
-}
Deleted: trunk/Tools/AgateDataLib/DatabaseEditor.resx
===================================================================
--- trunk/Tools/AgateDataLib/DatabaseEditor.resx 2010-01-30 18:08:50 UTC (rev 1211)
+++ trunk/Tools/AgateDataLib/DatabaseEditor.resx 2010-01-30 18:11:55 UTC (rev 1212)
@@ -1,243 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<root>
- <!--
- Microsoft ResX Schema
-
- Version 2.0
-
- The primary goals of this format is to allow a simple XML format
- that is mostly human readable. The generation and parsing of the
- various data types are done through the TypeConverter classes
- associated with the data types.
-
- Example:
-
- ... ado.net/XML headers & schema ...
- <resheader name="resmimetype">text/microsoft-resx</resheader>
- <resheader name="version">2.0</resheader>
- <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
- <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
- <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
- <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
- <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
- <value>[base64 mime encoded serialized .NET Framework object]</value>
- </data>
- <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
- <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
- <comment>This is a comment</comment>
- </data>
-
- There are any number of "resheader" rows that contain simple
- name/value pairs.
-
- Each data row contains a name, and value. The row also contains a
- type or mimetype. Type corresponds to a .NET class that support
- text/value conversion through the TypeConverter architecture.
- Classes that don't support this are serialized and stored with the
- mimetype set.
-
- The mimetype is used for serialized objects, and tells the
- ResXResourceReader how to depersist the object. This is currently not
- extensible. For a given mimetype the value must be set accordingly:
-
- Note - application/x-microsoft.net.object.binary.base64 is the format
- that the ResXResourceWriter will generate, however the reader can
- read any of the formats listed below.
-
- mimetype: application/x-microsoft.net.object.binary.base64
- value : The object must be serialized with
- : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
- : and then encoded with base64 encoding.
-
- mimetype: application/x-microsoft.net.object.soap.base64
- value : The object must be serialized with
- : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
- : and then encoded with base64 encoding.
-
- mimetype: application/x-microsoft.net.object.bytearray.base64
- value : The object must be serialized into a byte array
- : using a System.ComponentModel.TypeConverter
- : and then encoded with base64 encoding.
- -->
- <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
- <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
- <xsd:element name="root" msdata:IsDataSet="true">
- <xsd:complexType>
- <xsd:choice maxOccurs="unbounded">
- <xsd:element name="metadata">
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element name="value" type="xsd:string" minOccurs="0" />
- </xsd:sequence>
- <xsd:attribute name="name" use="required" type="xsd:string" />
- <xsd:attribute name="type" type="xsd:string" />
- <xsd:attribute name="mimetype" type="xsd:string" />
- <xsd:attribute ref="xml:space" />
- </xsd:complexType>
- </xsd:element>
- <xsd:element name="assembly">
- <xsd:complexType>
- <xsd:attribute name="alias" type="xsd:string" />
- <xsd:attribute name="name" type="xsd:string" />
- </xsd:complexType>
- </xsd:element>
- <xsd:element name="data">
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
- <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
- <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
- <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
- <xsd:attribute ref="xml:space" />
- </xsd:complexType>
- </xsd:element>
- <xsd:element name="resheader">
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required" />
- </xsd:complexType>
- </xsd:element>
- </xsd:choice>
- </xsd:complexType>
- </xsd:element>
- </xsd:schema>
- <resheader name="resmimetype">
- <value>text/microsoft-resx</value>
- </resheader>
- <resheader name="version">
- <value>2.0</value>
- </resheader>
- <resheader name="reader">
- <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
- </resheader>
- <resheader name="writer">
- <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
- </resheader>
- <metadata name="largeImages.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
- <value>241, 17</value>
- </metadata>
- <data name="largeImages.ImageStream" mimetype="application/x-microsoft.net.object.binary.base64">
- <value>
- AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj0yLjAuMC4w
- LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
- ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAAAs
- DAAAAk1TRnQBSQFMAgEBAgEAASgBAAEoAQABIAEAASABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo
- AwABgAMAASADAAEBAQABCAYAARAYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA
- AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5
- AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA
- AWYDAAGZAwABzAIAATMDAAIzAgABMwFmAgABMwGZAgABMwHMAgABMwH/AgABZgMAAWYBMwIAAmYCAAFm
- AZkCAAFmAcwCAAFmAf8CAAGZAwABmQEzAgABmQFmAgACmQIAAZkBzAIAAZkB/wIAAcwDAAHMATMCAAHM
- AWYCAAHMAZkCAALMAgABzAH/AgAB/wFmAgAB/wGZAgAB/wHMAQABMwH/AgAB/wEAATMBAAEzAQABZgEA
- ATMBAAGZAQABMwEAAcwBAAEzAQAB/wEAAf8BMwIAAzMBAAIzAWYBAAIzAZkBAAIzAcwBAAIzAf8BAAEz
- AWYCAAEzAWYBMwEAATMCZgEAATMBZgGZAQABMwFmAcwBAAEzAWYB/wEAATMBmQIAATMBmQEzAQABMwGZ
- AWYBAAEzApkBAAEzAZkBzAEAATMBmQH/AQABMwHMAgABMwHMATMBAAEzAcwBZgEAATMBzAGZAQABMwLM
- AQABMwHMAf8BAAEzAf8BMwEAATMB/wFmAQABMwH/AZkBAAEzAf8BzAEAATMC/wEAAWYDAAFmAQABMwEA
- AWYBAAFmAQABZgEAAZkBAAFmAQABzAEAAWYBAAH/AQABZgEzAgABZgIzAQABZgEzAWYBAAFmATMBmQEA
- AWYBMwHMAQABZgEzAf8BAAJmAgACZgEzAQADZgEAAmYBmQEAAmYBzAEAAWYBmQIAAWYBmQEzAQABZgGZ
- AWYBAAFmApkBAAFmAZkBzAEAAWYBmQH/AQABZgHMAgABZgHMATMBAAFmAcwBmQEAAWYCzAEAAWYBzAH/
- AQABZgH/AgABZgH/ATMBAAFmAf8BmQEAAWYB/wHMAQABzAEAAf8BAAH/AQABzAEAApkCAAGZATMBmQEA
- AZkBAAGZAQABmQEAAcwBAAGZAwABmQIzAQABmQEAAWYBAAGZATMBzAEAAZkBAAH/AQABmQFmAgABmQFm
- ATMBAAGZATMBZgEAAZkBZgGZAQABmQFmAcwBAAGZATMB/wEAApkBMwEAApkBZgEAA5kBAAKZAcwBAAKZ
- Af8BAAGZAcwCAAGZAcwBMwEAAWYBzAFmAQABmQHMAZkBAAGZAswBAAGZAcwB/wEAAZkB/wIAAZkB/wEz
- AQABmQHMAWYBAAGZAf8BmQEAAZkB/wHMAQABmQL/AQABzAMAAZkBAAEzAQABzAEAAWYBAAHMAQABmQEA
- AcwBAAHMAQABmQEzAgABzAIzAQABzAEzAWYBAAHMATMBmQEAAcwBMwHMAQABzAEzAf8BAAHMAWYCAAHM
- AWYBMwEAAZkCZgEAAcwBZgGZAQABzAFmAcwBAAGZAWYB/wEAAcwBmQIAAcwBmQEzAQABzAGZAWYBAAHM
- ApkBAAHMAZkBzAEAAcwBmQH/AQACzAIAAswBMwEAAswBZgEAAswBmQEAA8wBAALMAf8BAAHMAf8CAAHM
- Af8BMwEAAZkB/wFmAQABzAH/AZkBAAHMAf8BzAEAAcwC/wEAAcwBAAEzAQAB/wEAAWYBAAH/AQABmQEA
- AcwBMwIAAf8CMwEAAf8BMwFmAQAB/wEzAZkBAAH/ATMBzAEAAf8BMwH/AQAB/wFmAgAB/wFmATMBAAHM
- AmYBAAH/AWYBmQEAAf8BZgHMAQABzAFmAf8BAAH/AZkCAAH/AZkBMwEAAf8BmQFmAQAB/wKZAQAB/wGZ
- AcwBAAH/AZkB/wEAAf8BzAIAAf8BzAEzAQAB/wHMAWYBAAH/AcwBmQEAAf8CzAEAAf8BzAH/AQAC/wEz
- AQABzAH/AWYBAAL/AZkBAAL/AcwBAAJmAf8BAAFmAf8BZgEAAWYC/wEAAf8CZgEAAf8BZgH/AQAC/wFm
- AQABIQEAAaUBAANfAQADdwEAA4YBAAOWAQADywEAA7IBAAPXAQAD3QEAA+MBAAPqAQAD8QEAA/gBAAHw
- AfsB/wEAAaQCoAEAA4ADAAH/AgAB/wMAAv8BAAH/AwAB/wEAAf8BAAL/AgAD/yUAAvcaZmQAAvcaZmQA
- AvcCvAYHAu8CtQTvBLUE9wJmZAAC9wK8BgcC7wK1BO8EtQT3AmZCAAL3GmYGAAL3Bv8CBwT0AhkC7wIZ
- At0CCQL3AmZCAAL3GmYGAAL3Bv8CBwT0AhkC7wIZAt0CCQL3AmZCAAL3ArwGBwLvArUE7wS1BPcCZgYA
- AvcG/wIHAv8E9AK1BBkC3QK1AmZCAAL3ArwGBwLvArUE7wS1BPcCZgYAAvcG/wIHAv8E9AK1BBkC3QK1
- AmZCAAL3Bv8CBwT0AhkC7wIZAt0CCQL3AmYGAAL3AvAEvAgHAu8CtQTvArUCZkIAAvcG/wIHBPQCGQLv
- AhkC3QIJAvcCZgYAAvcC8AS8CAcC7wK1BO8CtQJmQgAC9wb/AgcC/wT0ArUEGQLdArUCZgYAArUG/wK8
- Bv8CBwL0BBkC7wJmQgAC9wb/AgcC/wT0ArUEGQLdArUCZgYAArUG/wK8Bv8CBwL0BBkC7wJmQgAC9wLw
- BLwIBwLvArUE7wK1AmYGAALvBv8CvAb/AgcE9AIZAu8CZkIAAvcC8AS8CAcC7wK1BO8CtQJmBgAC7wb/
- ArwG/wIHBPQCGQLvAmZCAAK1Bv8CvAb/AgcC9AQZAu8CZgYAArUC8Qq8CAcC7wK1AmZCAAK1Bv8CvAb/
- AgcC9AQZAu8CZgYAArUC8Qq8CAcC7wK1AmZCAALvBv8CvAb/AgcE9AIZAu8CZgQAAhoCeQIyAlkC5QKg
- Bv8CBwT/AvQC7wJmQgAC7wb/ArwG/wIHBPQCGQLvAmYEAAIaAnkCMgJZAuUCoAb/AgcE/wL0Au8CZkIA
- ArUC8Qq8CAcC7wK1AmYCAAKgAiwCoAIyAjgCoAIsAqAE/wK8Bv8CBwJmQgACtQLxCrwIBwLvArUCZgIA
- AqACLAKgAjICOAKgAiwCoAT/ArwG/wIHAmZCAAK7Bv8CvAb/AgcE/wL0Au8CZgIABKACLAIyAjgCLAKg
- AuUEtAytQgACuwb/ArwG/wIHBP8C9ALvAmYCAASgAiwCMgI4AiwCoALlBLQMrUIAArsG/wK8Bv8CvAb/
- AgcCZgIABDgCMgY4Al4CWQLcAtYK1QKtQgACuwb/ArwG/wK8Bv8CBwJmAgAEOAIyBjgCXgJZAtwC1grV
- Aq1CAAjWAtUGtAytAgAGMgL/AqACOAQyAtUGtAKzBq1CAAjWAtUGtAytAgAGMgL/AqACOAQyAtUGtAKz
- Bq1CAALWAgkK3ALWCtUCrQIAAnoCoAIsAjICOAIsAqACWVIAAtYCCQrcAtYK1QKtAgACegKgAiwCMgI4
- AiwCoAJZUgAK1gTVBrQCswatAgACmgIsAqAEOAKgAiwCoFIACtYE1Qa0ArMGrQIAApoCLAKgBDgCoAIs
- AqByAATlAjICOATldAAE5QIyAjgE5VIAAUIBTQE+BwABPgMAASgDAAGAAwABIAMAAQEBAAEBBgABAhYA
- A/8BAAT/AfALAAT/AfALAAT/AfALAAT/AfALAAHAAgABAwHwCwABwAIAAQMB8AsAAcACAAEDAfALAAHA
- AgABAwHwCwABwAIAAQMB8AsAAcACAAEDAfALAAHAAgABAwHwCwABwAIAAQMB8AsAAcACAAEDAfALAAHA
- AgABAwHwCwABwAIAAQMB8AsAAcACAAEDAfALAAHAAgABAwHACwABwAIAAQMBwAsAAcACAAEDDAABwAIA
- AQMMAAHAAgABAwwAAcACAAEDDAABwAIAAQMMAAHAAgABAwwAAcACAAEDDAABwAIAAQMMAAHAAgABAwIA
- Av8IAAHAAgABAwIAAv8IAAHAAgABAwIAAv8IAAHAAgABAwIAAv8IAAT/AcABAwL/CAAE/wHAAQMC/wgA
- Cw==
-</value>
- </data>
- <metadata name="smallImages.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
- <value>122, 17</value>
- </metadata>
- <data name="smallImages.ImageStream" mimetype="application/x-microsoft.net.object.binary.base64">
- <value>
- AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj0yLjAuMC4w
- LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
- ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAABs
- CQAAAk1TRnQBSQFMAgEBAgEAATABAAEwAQABEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo
- AwABQAMAARADAAEBAQABCAYAAQQYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA
- AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5
- AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA
- AWYDAAGZAwABzAIAATMDAAIzAgABMwFmAgABMwGZAgABMwHMAgABMwH/AgABZgMAAWYBMwIAAmYCAAFm
- AZkCAAFmAcwCAAFmAf8CAAGZAwABmQEzAgABmQFmAgACmQIAAZkBzAIAAZkB/wIAAcwDAAHMATMCAAHM
- AWYCAAHMAZkCAALMAgABzAH/AgAB/wFmAgAB/wGZAgAB/wHMAQABMwH/AgAB/wEAATMBAAEzAQABZgEA
- ATMBAAGZAQABMwEAAcwBAAEzAQAB/wEAAf8BMwIAAzMBAAIzAWYBAAIzAZkBAAIzAcwBAAIzAf8BAAEz
- AWYCAAEzAWYBMwEAATMCZgEAATMBZgGZAQABMwFmAcwBAAEzAWYB/wEAATMBmQIAATMBmQEzAQABMwGZ
- AWYBAAEzApkBAAEzAZkBzAEAATMBmQH/AQABMwHMAgABMwHMATMBAAEzAcwBZgEAATMBzAGZAQABMwLM
- AQABMwHMAf8BAAEzAf8BMwEAATMB/wFmAQABMwH/AZkBAAEzAf8BzAEAATMC/wEAAWYDAAFmAQABMwEA
- AWYBAAFmAQABZgEAAZkBAAFmAQABzAEAAWYBAAH/AQABZgEzAgABZgIzAQABZgEzAWYBAAFmATMBmQEA
- AWYBMwHMAQABZgEzAf8BAAJmAgACZgEzAQADZgEAAmYBmQEAAmYBzAEAAWYBmQIAAWYBmQEzAQABZgGZ
- AWYBAAFmApkBAAFmAZkBzAEAAWYBmQH/AQABZgHMAgABZgHMATMBAAFmAcwBmQEAAWYCzAEAAWYBzAH/
- AQABZgH/AgABZgH/ATMBAAFmAf8BmQEAAWYB/wHMAQABzAEAAf8BAAH/AQABzAEAApkCAAGZATMBmQEA
- AZkBAAGZAQABmQEAAcwBAAGZAwABmQIzAQABmQEAAWYBAAGZATMBzAEAAZkBAAH/AQABmQFmAgABmQFm
- ATMBAAGZATMBZgEAAZkBZgGZAQABmQFmAcwBAAGZATMB/wEAApkBMwEAApkBZgEAA5kBAAKZAcwBAAKZ
- Af8BAAGZAcwCAAGZAcwBMwEAAWYBzAFmAQABmQHMAZkBAAGZAswBAAGZAcwB/wEAAZkB/wIAAZkB/wEz
- AQABmQHMAWYBAAGZAf8BmQEAAZkB/wHMAQABmQL/AQABzAMAAZkBAAEzAQABzAEAAWYBAAHMAQABmQEA
- AcwBAAHMAQABmQEzAgABzAIzAQABzAEzAWYBAAHMATMBmQEAAcwBMwHMAQABzAEzAf8BAAHMAWYCAAHM
- AWYBMwEAAZkCZgEAAcwBZgGZAQABzAFmAcwBAAGZAWYB/wEAAcwBmQIAAcwBmQEzAQABzAGZAWYBAAHM
- ApkBAAHMAZkBzAEAAcwBmQH/AQACzAIAAswBMwEAAswBZgEAAswBmQEAA8wBAALMAf8BAAHMAf8CAAHM
- Af8BMwEAAZkB/wFmAQABzAH/AZkBAAHMAf8BzAEAAcwC/wEAAcwBAAEzAQAB/wEAAWYBAAH/AQABmQEA
- AcwBMwIAAf8CMwEAAf8BMwFmAQAB/wEzAZkBAAH/ATMBzAEAAf8BMwH/AQAB/wFmAgAB/wFmATMBAAHM
- AmYBAAH/AWYBmQEAAf8BZgHMAQABzAFmAf8BAAH/AZkCAAH/AZkBMwEAAf8BmQFmAQAB/wKZAQAB/wGZ
- AcwBAAH/AZkB/wEAAf8BzAIAAf8BzAEzAQAB/wHMAWYBAAH/AcwBmQEAAf8CzAEAAf8BzAH/AQAC/wEz
- AQABzAH/AWYBAAL/AZkBAAL/AcwBAAJmAf8BAAFmAf8BZgEAAWYC/wEAAf8CZgEAAf8BZgH/AQAC/wFm
- AQABIQEAAaUBAANfAQADdwEAA4YBAAOWAQADywEAA7IBAAPXAQAD3QEAA+MBAAPqAQAD8QEAA/gBAAHw
- AfsB/wEAAaQCoAEAA4ADAAH/AgAB/wMAAv8BAAH/AwAB/wEAAf8BAAL/AgAD/xMAAfcNZjIAAfcBvAMH
- Ae8BtQLvArUC9wFmIQAB9w1mAwAB9wP/AQcC9AEZAe8BGQHdAQkB9wFmIQAB9wG8AwcB7wG1Au8CtQL3
- AWYDAAH3A/8BBwH/AvQBtQIZAd0BtQFmIQAB9wP/AQcC9AEZAe8BGQHdAQkB9wFmAwAB9wHwArwEBwHv
- AbUC7wG1AWYhAAH3A/8BBwH/AvQBtQIZAd0BtQFmAwABtQP/AbwD/wEHAfQCGQHvAWYhAAH3AfACvAQH
- Ae8BtQLvAbUBZgMAAe8D/wG8A/8BBwL0ARkB7wFmIQABtQP/AbwD/wEHAfQCGQHvAWYDAAG1AfEFvAQH
- Ae8BtQFmIQAB7wP/AbwD/wEHAvQBGQHvAWYCAAEaAXkBMgFZAeUBoAP/AQcC/wH0Ae8BZiEAAbUB8QW8
- BAcB7wG1AWYBAAGgASwBoAEyATgBoAEsAaAC/wG8A/8BBwFmIQABuwP/AbwD/wEHAv8B9AHvAWYBAAKg
- ASwBMgE4ASwBoAHlArQGrSEAAbsD/wG8A/8BvAP/AQcBZgEAAjgBMgM4AV4BWQHcAdYF1QGtIQAE1gHV
- A7QGrQEAAzIB/wGgATgCMgHVA7QBswOtIQAB1gEJBdwB1gXVAa0BAAF6AaABLAEyATgBLAGgAVkpAAXW
- AtUDtAGzA60BAAGaASwBoAI4AaABLAGgOQAC5QEyATgC5SkAAUIBTQE+BwABPgMAASgDAAFAAwABEAMA
- AQEBAAEBBQABgBcAA/8BAAL/AcAFAAL/AcAFAAGAAQEBwAUAAYABAQHABQABgAEBAcAFAAGAAQEBwAUA
- AYABAQHABQABgAEBAcAFAAGAAQEBgAUAAYABAQYAAYABAQYAAYABAQYAAYABAQYAAYABAQEAAf8EAAGA
- AQEBAAH/BAAC/wGBAf8EAAs=
-</value>
- </data>
- <metadata name="tabContextMenu.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
- <value>646, 17</value>
- </metadata>
- <metadata name="lvContextMenu.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
- <value>359, 17</value>
- </metadata>
- <metadata name="tableContextMenu.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
- <value>493, 17</value>
- </metadata>
-</root>
\ No newline at end of file
Deleted: trunk/Tools/AgateDataLib/TableEditor.Designer.cs
===================================================================
--- trunk/Tools/AgateDataLib/TableEditor.Designer.cs 2010-01-30 18:08:50 UTC (rev 1211)
+++ trunk/Tools/AgateDataLib/TableEditor.Designer.cs 2010-01-30 18:11:55 UTC (rev 1212)
@@ -1,92 +0,0 @@
-namespace AgateDataLib
-{
- partial class TableEditor
- {
- /// <summary>
- /// Required designer variable.
- /// </summary>
- private System.ComponentModel.IContainer components = null;
-
- /// <summary>
- /// Clean up any resources being used.
- /// </summary>
- /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
- protected override void Dispose(bool disposing)
- {
- if (disposing && (components != null))
- {
- components.Dispose();
- }
- base.Dispose(disposing);
- }
-
- #region Component Designer generated code
-
- /// <summary>
- /// Required method for Designer support - do not modify
- /// the contents of this method with the code editor.
- /// </summary>
- private void InitializeComponent()
- {
- this.components = new System.ComponentModel.Container();
- this.gridView = new System.Windows.Forms.DataGridView();
- this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);
- this.editColumnsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- ((System.ComponentModel.ISupportInitialize)(this.gridView)).BeginInit();
- this.contextMenuStrip1.SuspendLayout();
- this.SuspendLayout();
- //
- // gridView
- //
- this.gridView.AllowUserToOrderColumns = true;
- this.gridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
- this.gridView.ContextMenuStrip = this.contextMenuStrip1;
- this.gridView.Dock = System.Windows.Forms.DockStyle.Fill;
- this.gridView.Location = new System.Drawing.Point(0, 0);
- this.gridView.Name = "gridView";
- this.gridView.Size = new System.Drawing.Size(150, 150);
- this.gridView.TabIndex = 8;
- this.gridView.VirtualMode = true;
- this.gridView.UserDeletingRow += new System.Windows.Forms.DataGridViewRowCancelEventHandler(this.gridView_UserDeletingRow);
- this.gridView.CancelRowEdit += new System.Windows.Forms.QuestionEventHandler(this.gridView_CancelRowEdit);
- this.gridView.CellValueNeeded += new System.Windows.Forms.DataGridViewCellValueEventHandler(this.gridView_CellValueNeeded);
- this.gridView.RowValidated += new System.Windows.Forms.DataGridViewCellEventHandler(this.gridView_RowValidated);
- this.gridView.RowDirtyStateNeeded += new System.Windows.Forms.QuestionEventHandler(this.gridView_RowDirtyStateNeeded);
- this.gridView.CellValuePushed += new System.Windows.Forms.DataGridViewCellValueEventHandler(this.gridView_CellValuePushed);
- this.gridView.NewRowNeeded += new System.Windows.Forms.DataGridViewRowEventHandler(this.gridView_NewRowNeeded);
- this.gridView.ColumnWidthChanged += new System.Windows.Forms.DataGridViewColumnEventHandler(this.gridView_ColumnWidthChanged);
- this.gridView.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.gridView_CellContentClick);
- //
- // contextMenuStrip1
- //
- this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
- this.editColumnsToolStripMenuItem});
- this.contextMenuStrip1.Name = "contextMenuStrip1";
- this.contextMenuStrip1.Size = new System.Drawing.Size(155, 26);
- //
- // editColumnsToolStripMenuItem
- //
- this.editColumnsToolStripMenuItem.Name = "editColumnsToolStripMenuItem";
- this.editColumnsToolStripMenuItem.Size = new System.Drawing.Size(154, 22);
- this.editColumnsToolStripMenuItem.Text = "Edit Columns...";
- this.editColumnsToolStripMenuItem.Click += new System.EventHandler(this.editColumnsToolStripMenuItem_Click);
- //
- // TableEditor
- //
- this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.Controls.Add(this.gridView);
- this.Name = "TableEditor";
- ((System.ComponentModel.ISupportInitialize)(this.gridView)).EndInit();
- this.contextMenuStrip1.ResumeLayout(false);
- this.ResumeLayout(false);
-
- }
-
- #endregion
-
- private System.Windows.Forms.DataGridView gridView;
- private System.Windows.Forms.ContextMenuStrip contextMenuStrip1;
- private System.Windows.Forms.ToolStripMenuItem editColumnsToolStripMenuItem;
- }
-}
Deleted: trunk/Tools/AgateDataLib/TableEditor.cs
===================================================================
--- trunk/Tools/AgateDataLib/TableEditor.cs 2010-01-30 18:08:50 UTC (rev 1211)
+++ trunk/Tools/AgateDataLib/TableEditor.cs 2010-01-30 18:11:55 UTC (rev 1212)
@@ -1,228 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Drawing;
-using System.Linq;
-using System.Text;
-using System.Windows.Forms;
-using AgateLib.Data;
-
-namespace AgateDataLib
-{
- public partial class TableEditor : UserControl
- {
- AgateDatabase mDatabase;
- AgateTable mTable;
-
- AgateRow mEditingRow;
- int mEditingRowIndex = -1;
-
- public TableEditor()
- {
- InitializeComponent();
- }
-
- public AgateDatabase Database
- {
- get { return mDatabase; }
- set { mDatabase = value;
- AgateTable = null;
- }
- }
- public AgateTable AgateTable
- {
- get { return mTable; }
- set
- {
- mTable = value;
- TableReset();
- }
- }
-
- internal void FinalizeData()
- {
- gridView.CommitEdit(DataGridViewDataErrorContexts.Commit);
- gridView.EndEdit();
-
- DataGridViewCellEventArgs e = new DataGridViewCellEventArgs(gridView.CurrentCell.ColumnIndex, gridView.CurrentCell.RowIndex);
-
- gridView_RowValidated(gridView, e);
- }
-
- private void TableReset()
- {
- gridView.SuspendLayout();
- gridView.Columns.Clear();
-
- if (mTable == null)
- {
- gridView.ResumeLayout();
-
- return;
- }
-
- int index = 0;
- foreach (var column in mTable.Columns)
- {
- DataGridViewColumn col = new DataGridViewColumn();
-
- col.Name = column.Name;
- col.ReadOnly = column.FieldType == FieldType.AutoNumber;
-
- if (string.IsNullOrEmpty(column.TableLookup))
- {
- col.CellTemplate = new DataGridViewTextBoxCell();
- }
-
- if (column.ColumnWidth > 10)
- col.Width = column.ColumnWidth;
-
- gridView.Columns.Add(col);
-
- index++;
- }
-
- UpdateGridViewRowCount();
- gridView.ResumeLayout();
- }
-
- private void UpdateGridViewRowCount()
- {
- gridView.RowCount = mTable.Rows.Count + 1;
- }
-
- AgateColumn GetColumn(int columnIndex)
- {
- return mTable.Columns[columnIndex];
- }
- string ColumnName(int columnIndex)
- {
- return GetColumn(columnIndex).Name;
- }
-
- private void gridView_CellValueNeeded(object sender, DataGridViewCellValueEventArgs e)
- {
- if (e.RowIndex == gridView.RowCount - 1)
- return;
-
- AgateRow row = null;
-
- if (e.RowIndex == mEditingRowIndex)
- row = mEditingRow;
- else
- row = mTable.Rows[e.RowIndex];
-
- e.Value = row[ColumnName(e.ColumnIndex)];
- }
- private void gridView_CellValuePushed(object sender, DataGridViewCellValueEventArgs e)
- {
- AgateRow row = null;
-
- // Store the reference to the row being edited.
- if (e.RowIndex < mTable.Rows.Count)
- {
- // the user is editing an existing row, so make a copy of
- // it in case they want to cancel.
- if (this.mEditingRow == null)
- {
- this.mEditingRow = mTable.Rows[e.RowIndex].Clone();
- }
-
- mEditingRowIndex = e.RowIndex;
- }
-
- row = this.mEditingRow;
-
- try
- {
- row[ColumnName(e.ColumnIndex)] = e.Value.ToString();
- }
- catch (FormatException)
- {
- MessageBox.Show(this,
- "The value you entered for this field is not valid." + Environment.NewLine +
- "The field data type is " + mTable.Columns[e.ColumnIndex].FieldType.ToString() + ".",
- "Invalid data", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- }
- }
- private void gridView_NewRowNeeded(object sender, DataGridViewRowEventArgs e)
- {
- mEditingRow = new AgateRow(mTable);
- mEditingRowIndex = gridView.Rows.Count - 1;
- }
- private void gridView_RowValidated(object sender, DataGridViewCellEventArgs e)
- {
- if (e.RowIndex >= mTable.Rows.Count &&
- e.RowIndex != gridView.Rows.Count-1)
- {
- mTable.Rows.Add(mEditingRow);
- mEditingRow = null;
- mEditingRowIndex = -1;
- }
- else if (mEditingRow != null &&
- e.RowIndex < mTable.Rows.Count)
- {
- mTable.Rows[e.RowIndex] = mEditingRow;
- mEditingRow = null;
- mEditingRowIndex = -1;
- }
- else if (gridView.ContainsFocus)
- {
- mEditingRow = null;
- mEditingRowIndex = -1;
- }
- }
- private void gridView_RowDirtyStateNeeded(object sender, QuestionEventArgs e)
- {
- }
- private void gridView_CancelRowEdit(object sender, QuestionEventArgs e)
- {
- if (mEditingRowIndex == gridView.Rows.Count - 2 &&
- mEditingRowIndex == mTable.Rows.Count)
- {
- // If the user has canceled the edit of a newly created row,
- // replace the corresponding Customer object with a new, empty one.
- this.mEditingRow = new AgateRow(mTable);
- }
- else
- {
- // If the user has canceled the edit of an existing row,
- // release the corresponding Customer object.
- this.mEditingRow = null;
- this.mEditingRowIndex = -1;
- }
-
- }
- private void gridView_UserDeletingRow(object sender, DataGridViewRowCancelEventArgs e)
- {
- if (e.Row.Index < mTable.Rows.Count)
- {
- mTable.Rows.RemoveAt(e.Row.Index);
- }
-
- if (e.Row.Index == mEditingRowIndex)
- {
- // user has deleted a newly created row.
- mEditingRowIndex = -1;
- mEditingRow = null;
- }
- }
- private void gridView_CellContentClick(object sender, DataGridViewCellEventArgs e)
- {
-
- }
- private void gridView_ColumnWidthChanged(object sender, DataGridViewColumnEventArgs e)
- {
- mTable.Columns[e.Column.Index].ColumnWidth = e.Column.Width;
- }
-
- private void editColumnsToolStripMenuItem_Click(object sender, EventArgs e)
- {
- frmDesignTable.EditColumns(mTable);
-
- TableReset();
- }
-
-
- }
-}
Deleted: trunk/Tools/AgateDataLib/TableEditor.resx
===================================================================
--- trunk/Tools/AgateDataLib/TableEditor.resx 2010-01-30 18:08:50 UTC (rev 1211)
+++ trunk/Tools/AgateDataLib/TableEditor.resx 2010-01-30 18:11:55 UTC (rev 1212)
@@ -1,123 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<root>
- <!--
- Microsoft ResX Schema
-
- Version 2.0
-
- The primary goals of this format is to allow a simple XML format
- that is mostly human readable. The generation and parsing of the
- various data types are done through the TypeConverter classes
- associated with the data types.
-
- Example:
-
- ... ado.net/XML headers & schema ...
- <resheader name="resmimetype">text/microsoft-resx</resheader>
- <resheader name="version">2.0</resheader>
- <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
- <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
- <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
- <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
- <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
- <value>[base64 mime encoded serialized .NET Framework object]</value>
- </data>
- <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
- <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
- <comment>This is a comment</comment>
- </data>
-
- There are any number of "resheader" rows that contain simple
- name/value pairs.
-
- Each data row contains a name, and value. The row also contains a
- type or mimetype. Type corresponds to a .NET class that support
- text/value conversion through the TypeConverter architecture.
- Classes that don't support this are serialized and stored with the
- mimetype set.
-
- The mimetype is used for serialized objects, and tells the
- ResXResourceReader how to depersist the object. This is currently not
- extensible. For a given mimetype the value must be set accordingly:
-
- Note - application/x-microsoft.net.object.binary.base64 is the format
- that the ResXResourceWriter will generate, however the reader can
- read any of the formats listed below.
-
- mimetype: application/x-microsoft.net.object.binary.base64
- value : The object must be serialized with
- : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
- : and then encoded with base64 encoding.
-
- mimetype: application/x-microsoft.net.object.soap.base64
- value : The object must be serialized with
- : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
- : and then encoded with base64 encoding.
-
- mimetype: application/x-microsoft.net.object.bytearray.base64
- value : The object must be serialized into a byte array
- : using a System.ComponentModel.TypeConverter
- : and then encoded with base64 encoding.
- -->
- <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
- <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
- <xsd:element name="root" msdata:IsDataSet="true">
- <xsd:complexType>
- <xsd:choice maxOccurs="unbounded">
- <xsd:element name="metadata">
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element name="value" type="xsd:string" minOccurs="0" />
- </xsd:sequence>
- <xsd:attribute name="name" use="required" type="xsd:string" />
- <xsd:attribute name="type" type="xsd:string" />
- <xsd:attribute name="mimetype" type="xsd:string" />
- <xsd:attribute ref="xml:space" />
- </xsd:complexType>
- </xsd:element>
- <xsd:element name="assembly">
- <xsd:complexType>
- <xsd:attribute name="alias" type="xsd:string" />
- <xsd:attribute name="name" type="xsd:string" />
- </xsd:complexType>
- </xsd:element>
- <xsd:element name="data">
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
- <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
- <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
- <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
- <xsd:attribute ref="xml:space" />
- </xsd:complexType>
- </xsd:element>
- <xsd:element name="resheader">
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required" />
- </xsd:complexType>
- </xsd:element>
- </xsd:choice>
- </xsd:complexType>
- </xsd:element>
- </xsd:schema>
- <resheader name="resmimetype">
- <value>text/microsoft-resx</value>
- </resheader>
- <resheader name="version">
- <value>2.0</value>
- </resheader>
- <resheader name="reader">
- <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
- </resheader>
- <resheader name="writer">
- <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
- </resheader>
- <metadata name="contextMenuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
- <value>17, 17</value>
- </metadata>
-</root>
\ No newline at end of file
Deleted: trunk/Tools/AgateDataLib/frmDesignTable.Designer.cs
===================================================================
--- trunk/Tools/AgateDataLib/frmDesignTable.Designer.cs 2010-01-30 18:08:50 UTC (rev 1211)
+++ trunk/Tools/AgateDataLib/frmDesignTable.Designer.cs 2010-01-30 18:11:55 UTC (rev 1212)
@@ -1,141 +0,0 @@
-namespace AgateDataLib
-{
- partial class frmDesignTable
- {
- /// <summary>
- /// Required designer variable.
- /// </summary>
- private System.ComponentModel.IContainer components = null;
-
- /// <summary>
- /// Clean up any resources being used.
- /// </summary>
- /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
- protected override void Dispose(bool disposing)
- {
- if (disposing && (components != null))
- {
- components.Dispose();
- }
- base.Dispose(disposing);
- }
-
- #region Windows Form Designer generated code
-
- /// <summary>
- /// Required method for Designer support - do not modify
- /// the contents of this method with the code editor.
- /// </summary>
- private void InitializeComponent()
- {
- this.gridColumns = new System.Windows.Forms.DataGridView();
- this.colName = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.colDataType = new System.Windows.Forms.DataGridViewComboBoxColumn();
- this.colDescription = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.groupBox1 = new System.Windows.Forms.GroupBox();
- this.panel1 = new System.Windows.Forms.Panel();
- this.btnOK = new System.Windows.Forms.Button();
- ((System.ComponentModel.ISupportInitialize)(this.gridColumns)).BeginInit();
- this.panel1.SuspendLayout();
- this.SuspendLayout();
- //
- // gridColumns
- //
- this.gridColumns.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
- this.gridColumns.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
- this.colName,
- this.colDataType,
- this.colDescription});
- this.gridColumns.Dock = System.Windows.Forms.DockStyle.Fill;
- this.gridColumns.Location = new System.Drawing.Point(0, 0);
- this.gridColumns.Name = "gridColumns";
- this.gridColumns.Size = new System.Drawing.Size(765, 345);
- this.gridColumns.TabIndex = 0;
- this.gridColumns.VirtualMode = true;
- this.gridColumns.UserDeletingRow += new System.Windows.Forms.DataGridViewRowCancelEventHandler(this.gridColumns_UserDeletingRow);
- this.gridColumns.CancelRowEdit += new System.Windows.Forms.QuestionEventHandler(this.gridColumns_CancelRowEdit);
- this.gridColumns.CellValueNeeded += new System.Windows.Forms.DataGridViewCellValueEventHandler(this.gridColumns_CellValueNeeded);
- this.gridColumns.RowValidated += new System.Windows.Forms.DataGridViewCellEventHandler(this.gridColumns_RowValidated);
- this.gridColumns.RowDirtyStateNeeded += new System.Windows.Forms.QuestionEventHandler(this.gridColumns_RowDirtyStateNeeded);
- this.gridColumns.CellValuePushed += new System.Windows.Forms.DataGridViewCellValueEventHandler(this.gridColumns_CellValuePushed);
- this.gridColumns.NewRowNeeded += new System.Windows.Forms.DataGridViewRowEventHandler(this.gridColumns_NewRowNeeded);
- //
- // colName
- //
- this.colName.HeaderText = "Name";
- this.colName.Name = "colName";
- //
- // colDataType
- //
- this.colDataType.HeaderText = "Data Type";
- this.colDataType.Name = "colDataType";
- //
- // colDescription
- //
- this.colDescription.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
- this.colDescription.HeaderText = "Description";
- this.colDescription.Name = "colDescription";
- //
- // groupBox1
- //
- this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
- | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.groupBox1.Location = new System.Drawing.Point(12, 6);
- this.groupBox1.Name = "groupBox1";
- this.groupBox1.Size = new System.Drawing.Size(741, 183);
- this.groupBox1.TabIndex = 1;
- this.groupBox1.TabStop = false;
- this.groupBox1.Text = "Column Properties";
- //
- // panel1
- //
- this.panel1.Controls.Add(this.btnOK);
- this.panel1.Controls.Add(this.groupBox1);
- this.panel1.Dock = System.Windows.Forms.DockStyle.Bottom;
- this.panel1.Location = new System.Drawing.Point(0, 345);
- this.panel1.Name = "panel1";
- this.panel1.Size = new System.Drawing.Size(765, 239);
- this.panel1.TabIndex = 0;
- //
- // btnOK
- //
- this.btnOK.DialogResult = System.Windows.Forms.DialogResult.OK;
- this.btnOK.Location = new System.Drawing.Point(678, 204);
- this.btnOK.Name = "btnOK";
- this.btnOK.Size = new System.Drawing.Size(75, 23);
- this.btnOK.TabIndex = 0;
- this.btnOK.Text = "OK";
- this.btnOK.UseVisualStyleBackColor = true;
- //
- // frmDesignTable
- //
- this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(765, 584);
- this.Controls.Add(this.gridColumns);
- this.Controls.Add(this.panel1);
- this.MaximizeBox = false;
- this.MinimizeBox = false;
- this.Name = "frmDesignTable";
- this.ShowIcon = false;
- this.ShowInTaskbar = false;
- this.Text = "Table Design";
- ((System.ComponentModel.ISupportInitialize)(this.gridColumns)).EndInit();
- this.panel1.ResumeLayout(false);
- this.ResumeLayout(false);
-
- }
-
- #endregion
-
- private System.Windows.Forms.DataGridView gridColumns;
- private System.Windows.Forms.DataGridViewTextBoxColumn colName;
- private System.Windows.Forms.DataGridViewComboBoxColumn colDataType;
- p...
[truncated message content] |
|
From: <ka...@us...> - 2010-01-30 18:08:59
|
Revision: 1211
http://agate.svn.sourceforge.net/agate/?rev=1211&view=rev
Author: kanato
Date: 2010-01-30 18:08:50 +0000 (Sat, 30 Jan 2010)
Log Message:
-----------
Include missing CodeGenerator.cs file.
Allow deleting of tables.
Modified Paths:
--------------
trunk/Tools/AgateDataLib/DatabaseEditor.Designer.cs
trunk/Tools/AgateDataLib/DatabaseEditor.cs
Added Paths:
-----------
trunk/Tools/AgateDataLib/CodeGenerator.cs
Added: trunk/Tools/AgateDataLib/CodeGenerator.cs
===================================================================
--- trunk/Tools/AgateDataLib/CodeGenerator.cs (rev 0)
+++ trunk/Tools/AgateDataLib/CodeGenerator.cs 2010-01-30 18:08:50 UTC (rev 1211)
@@ -0,0 +1,325 @@
+using System;
+using System.CodeDom;
+using System.CodeDom.Compiler;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Reflection;
+using System.Text;
+using AgateLib.Data;
+
+namespace DatabaseEditor
+{
+ public class CodeGenerator
+ {
+ public CodeGenerator()
+ {
+ DataStoreClass = "AgateDataImport";
+ MakePublicClasses = true;
+ }
+
+ public CodeDomProvider Provider { get; set; }
+ public string Directory { get; set; }
+ public string Namespace { get; set; }
+ public bool MakePublicClasses { get; set; }
+ public string DataStoreClass { get; set; }
+
+ public string Filename
+ {
+ get
+ {
+ return Path.Combine(Directory, "Data." + Provider.FileExtension);
+ }
+ }
+
+ CodeTypeDeclaration mDataStore;
+ List<CodeTypeDeclaration> mTables = new List<CodeTypeDeclaration>();
+ const string rowParameterName = "row";
+
+ public void Run(AgateDatabase dbase)
+ {
+ var compileUnit = new CodeCompileUnit();
+ var ns = new CodeNamespace(Namespace);
+
+ compileUnit.Namespaces.Add(ns);
+
+ ns.Imports.Add(new CodeNamespaceImport("System"));
+ ns.Imports.Add(new CodeNamespaceImport("System.Collections.Generic"));
+ ns.Imports.Add(new CodeNamespaceImport("AgateLib.Data"));
+
+ dbase.LoadAllTables();
+
+ CreateDataStoreClass();
+
+ ns.Types.Add(mDataStore);
+
+ foreach (var table in dbase.Tables)
+ {
+ GenerateTableClass(ns, table);
+ }
+
+ CodeGeneratorOptions options = new CodeGeneratorOptions();
+ options.BracingStyle = "C";
+ options.BlankLinesBetweenMembers = false;
+
+ CreateDataStoreConstructor();
+ CreateDataStoreProperties();
+
+ using (StreamWriter sourceWriter = new StreamWriter(Filename))
+ {
+ Provider.GenerateCodeFromCompileUnit(
+ compileUnit, sourceWriter, options);
+ }
+ }
+
+ private void CreateDataStoreConstructor()
+ {
+ CodeConstructor c = new CodeConstructor();
+ c.Parameters.Add(
+ new CodeParameterDeclarationExpression("AgateDatabase", "dbase"));
+
+ c.Statements.Add(new CodeVariableDeclarationStatement("Int32", "i"));
+ CodeVariableReferenceExpression iref = new CodeVariableReferenceExpression(
+ "i");
+
+ CodeArgumentReferenceExpression dbaseRef = new CodeArgumentReferenceExpression("dbase");
+
+ foreach (var table in mTables)
+ {
+ var tableRef = new CodeIndexerExpression(
+ new CodePropertyReferenceExpression(dbaseRef, "Tables"),
+ new CodePrimitiveExpression(table.Name));
+
+ CodeIterationStatement forst = new CodeIterationStatement();
+
+ forst.InitStatement = new CodeAssignStatement(iref, new CodePrimitiveExpression(0));
+ forst.TestExpression = new CodeBinaryOperatorExpression(
+ iref, CodeBinaryOperatorType.LessThan,
+ new CodePropertyReferenceExpression(
+ new CodePropertyReferenceExpression(tableRef, "Rows"),
+ "Count"));
+
+ forst.IncrementStatement = new CodeAssignStatement(
+ iref, new CodeBinaryOperatorExpression(iref, CodeBinaryOperatorType.Add, new CodePrimitiveExpression(1)));
+
+ forst.Statements.Add(
+ new CodeMethodInvokeExpression(
+ new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), FieldTableName(table)),
+ "Add",
+ new CodeObjectCreateExpression(
+ new CodeTypeReference(table.Name),
+ new CodeIndexerExpression(
+ new CodePropertyReferenceExpression(
+ tableRef, "Rows"),
+ iref))));
+
+
+
+ c.Statements.Add(forst);
+ }
+
+ c.Attributes = MemberAttributes.Public;
+
+ mDataStore.Members.Add(c);
+ }
+
+ /// <summary>
+ /// Creates properties in the data store class that contain the
+ /// data from the database.
+ /// </summary>
+ private void CreateDataStoreProperties()
+ {
+ foreach (var table in mTables)
+ {
+ CodeMemberField field = new CodeMemberField();
+
+ field.Name = FieldTableName(table);
+ field.Type = new CodeTypeReference(
+ "List", new CodeTypeReference(new CodeTypeParameter(table.Name)));
+ field.Attributes = MemberAttributes.Private;
+ field.InitExpression = new CodeObjectCreateExpression(field.Type);
+
+ CodeMemberProperty prop = new CodeMemberProperty();
+ prop.Name = table.Name + "List";
+ prop.Type = field.Type;
+ prop.HasSet = false;
+ prop.HasGet = true;
+
+ prop.GetStatements.Add(new CodeMethodReturnStatement(
+ new CodeFieldReferenceExpression(
+ new CodeThisReferenceExpression(), field.Name)));
+
+ if (MakePublicClasses)
+ prop.Attributes = MemberAttributes.Public;
+ else
+ prop.Attributes = MemberAttributes.Assembly;
+
+ prop.Attributes |= MemberAttributes.Final;
+
+ mDataStore.Members.Add(field);
+ mDataStore.Members.Add(prop);
+ }
+ }
+
+ private static string FieldTableName(CodeTypeDeclaration table)
+ {
+ return "m" + table.Name + "List";
+ }
+
+ private void CreateDataStoreClass()
+ {
+ mDataStore = new CodeTypeDeclaration(this.DataStoreClass);
+ mDataStore.IsClass = true;
+ mDataStore.TypeAttributes = TypeAttributes.Sealed;
+
+ if (MakePublicClasses)
+ mDataStore.TypeAttributes |= TypeAttributes.Public;
+ }
+
+ private void GenerateTableClass(CodeNamespace ns, AgateTable table)
+ {
+ CodeTypeDeclaration cls = new CodeTypeDeclaration(table.Name);
+
+ cls.IsClass = true;
+ cls.TypeAttributes = TypeAttributes.Sealed;
+
+ if (MakePublicClasses)
+ cls.TypeAttributes |= TypeAttributes.Public;
+
+ CodeConstructor constructor = new CodeConstructor();
+
+ constructor.Parameters.Add(new CodeParameterDeclarationExpression(
+ typeof(AgateLib.Data.AgateRow), rowParameterName));
+
+ constructor.Attributes = MemberAttributes.Assembly;
+
+ cls.Members.Add(constructor);
+
+ foreach (var column in table.Columns)
+ {
+ CreateColumnProperty(cls, constructor, column);
+ }
+
+ ns.Types.Add(cls);
+
+ mTables.Add(cls);
+
+ }
+
+ private void CreateColumnProperty(CodeTypeDeclaration cls, CodeConstructor constructor, AgateColumn column)
+ {
+ string fieldName = "m" + column.Name;
+
+ CodeMemberField field = new CodeMemberField();
+ CodeMemberProperty prop = new CodeMemberProperty();
+
+ field.Attributes = MemberAttributes.Private;
+ field.Name = fieldName;
+ field.Type = new CodeTypeReference(column.FieldTypeDataType);
+
+ prop.Attributes = MemberAttributes.Public | MemberAttributes.Final;
+ prop.Name = column.Name;
+ prop.Type = new CodeTypeReference(column.FieldTypeDataType);
+ prop.HasGet = true;
+ prop.HasSet = false;
+
+ prop.GetStatements.Add(new CodeMethodReturnStatement(
+ new CodeFieldReferenceExpression(
+ new CodeThisReferenceExpression(), fieldName)));
+
+ prop.Comments.Add(new CodeCommentStatement("<summary>", true));
+ prop.Comments.Add(new CodeCommentStatement(column.Name + " column.", true));
+ if (string.IsNullOrEmpty(column.Description) == false)
+ prop.Comments.Add(new CodeCommentStatement("<br />" + column.Description, true));
+
+ prop.Comments.Add(new CodeCommentStatement("</summary>", true));
+
+ cls.Members.Add(field);
+ cls.Members.Add(prop);
+
+ CodeFieldReferenceExpression fieldRef = new CodeFieldReferenceExpression(
+ new CodeThisReferenceExpression(), fieldName);
+ CodeArgumentReferenceExpression argRef = new CodeArgumentReferenceExpression(
+ rowParameterName);
+
+ constructor.Statements.Add(
+ new CodeAssignStatement(fieldRef, ConvertStringStatement(column.FieldType,
+ new CodeIndexerExpression(argRef, new CodePrimitiveExpression(column.Name)))));
+ }
+
+ private CodeExpression ConvertStringStatement(FieldType type, CodeExpression codeExpression)
+ {
+ if (type == FieldType.String)
+ return codeExpression;
+
+ CodeMethodInvokeExpression method = new CodeMethodInvokeExpression();
+
+ method.Parameters.Add(codeExpression);
+
+ switch (type)
+ {
+ case FieldType.Int32:
+ case FieldType.AutoNumber:
+ method.Method = new CodeMethodReferenceExpression(
+ new CodeTypeReferenceExpression("Int32"), "Parse");
+ break;
+
+ case FieldType.Int16:
+ method.Method = new CodeMethodReferenceExpression(
+ new CodeTypeReferenceExpression("Int16"), "Parse");
+ break;
+
+ case FieldType.Byte:
+ method.Method = new CodeMethodReferenceExpression(
+ new CodeTypeReferenceExpression("Byte"), "Parse");
+ break;
+
+ case FieldType.Boolean:
+ method.Method = new CodeMethodReferenceExpression(
+ new CodeTypeReferenceExpression("Boolean"), "Parse");
+ break;
+
+ case FieldType.DateTime:
+ method.Method = new CodeMethodReferenceExpression(
+ new CodeTypeReferenceExpression("DateTime"), "Parse");
+ break;
+
+ case FieldType.Decimal:
+ method.Method = new CodeMethodReferenceExpression(
+ new CodeTypeReferenceExpression("Decimal"), "Parse");
+ break;
+
+ case FieldType.Double:
+ method.Method = new CodeMethodReferenceExpression(
+ new CodeTypeReferenceExpression("Double"), "Parse");
+ break;
+
+ case FieldType.SByte:
+ method.Method = new CodeMethodReferenceExpression(
+ new CodeTypeReferenceExpression("SByte"), "Parse");
+ break;
+
+ case FieldType.Single:
+ method.Method = new CodeMethodReferenceExpression(
+ new CodeTypeReferenceExpression("Single"), "Parse");
+ break;
+
+ case FieldType.UInt16:
+ method.Method = new CodeMethodReferenceExpression(
+ new CodeTypeReferenceExpression("UInt16"), "Parse");
+ break;
+
+ case FieldType.UInt32:
+ method.Method = new CodeMethodReferenceExpression(
+ new CodeTypeReferenceExpression("UInt32"), "Parse");
+ break;
+
+ default:
+ throw new NotSupportedException();
+ }
+
+ return method;
+
+ }
+ }
+}
Modified: trunk/Tools/AgateDataLib/DatabaseEditor.Designer.cs
===================================================================
--- trunk/Tools/AgateDataLib/DatabaseEditor.Designer.cs 2010-01-30 18:08:10 UTC (rev 1210)
+++ trunk/Tools/AgateDataLib/DatabaseEditor.Designer.cs 2010-01-30 18:08:50 UTC (rev 1211)
@@ -45,6 +45,7 @@
this.tableContextMenu = new System.Windows.Forms.ContextMenuStrip(this.components);
this.renameToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.deleteToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.duplicateToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.tabContextMenu.SuspendLayout();
this.splitContainer1.Panel1.SuspendLayout();
this.splitContainer1.Panel2.SuspendLayout();
@@ -172,9 +173,10 @@
//
this.tableContextMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.renameToolStripMenuItem,
+ this.duplicateToolStripMenuItem,
this.deleteToolStripMenuItem});
this.tableContextMenu.Name = "tableContextMenu";
- this.tableContextMenu.Size = new System.Drawing.Size(127, 48);
+ this.tableContextMenu.Size = new System.Drawing.Size(153, 92);
//
// renameToolStripMenuItem
//
@@ -186,9 +188,16 @@
// deleteToolStripMenuItem
//
this.deleteToolStripMenuItem.Name = "deleteToolStripMenuItem";
- this.deleteToolStripMenuItem.Size = new System.Drawing.Size(126, 22);
+ this.deleteToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.deleteToolStripMenuItem.Text = "Delete";
+ this.deleteToolStripMenuItem.Click += new System.EventHandler(this.deleteToolStripMenuItem_Click);
//
+ // duplicateToolStripMenuItem
+ //
+ this.duplicateToolStripMenuItem.Name = "duplicateToolStripMenuItem";
+ this.duplicateToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
+ this.duplicateToolStripMenuItem.Text = "Duplicate";
+ //
// DatabaseEditor
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@@ -223,5 +232,6 @@
private System.Windows.Forms.ToolStripMenuItem deleteToolStripMenuItem;
private System.Windows.Forms.ContextMenuStrip tabContextMenu;
private System.Windows.Forms.ToolStripMenuItem closeTabToolStripMenuItem;
+ private System.Windows.Forms.ToolStripMenuItem duplicateToolStripMenuItem;
}
}
Modified: trunk/Tools/AgateDataLib/DatabaseEditor.cs
===================================================================
--- trunk/Tools/AgateDataLib/DatabaseEditor.cs 2010-01-30 18:08:10 UTC (rev 1210)
+++ trunk/Tools/AgateDataLib/DatabaseEditor.cs 2010-01-30 18:08:50 UTC (rev 1211)
@@ -247,6 +247,24 @@
}
}
+ private void deleteToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ if (lstTables.SelectedItems.Count == 0)
+ return;
+
+ object obj = lstTables.SelectedItems[0].Tag;
+ AgateTable table = obj as AgateTable;
+
+ if (MessageBox.Show(this,
+ "Really delete table " + table.Name + "?" + Environment.NewLine + Environment.NewLine +
+ "This operation cannot be undone.",
+ "Delete Table?", MessageBoxButtons.YesNo, MessageBoxIcon.Question,
+ MessageBoxDefaultButton.Button2) == DialogResult.Yes)
+ {
+ Database.Tables.Remove(table);
+ }
+ }
+
}
delegate void InvokeDelegate();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2010-01-30 18:08:17
|
Revision: 1210
http://agate.svn.sourceforge.net/agate/?rev=1210&view=rev
Author: kanato
Date: 2010-01-30 18:08:10 +0000 (Sat, 30 Jan 2010)
Log Message:
-----------
Implement ICollection in AgateTableDictionary.
Modified Paths:
--------------
trunk/AgateLib/Data/AgateTableDictionary.cs
Modified: trunk/AgateLib/Data/AgateTableDictionary.cs
===================================================================
--- trunk/AgateLib/Data/AgateTableDictionary.cs 2010-01-30 09:08:07 UTC (rev 1209)
+++ trunk/AgateLib/Data/AgateTableDictionary.cs 2010-01-30 18:08:10 UTC (rev 1210)
@@ -6,7 +6,7 @@
namespace AgateLib.Data
{
- public class AgateTableDictionary : IEnumerable<AgateTable>, IDisposable
+ public class AgateTableDictionary : ICollection<AgateTable>, IDisposable
{
List<AgateTable> mTables = new List<AgateTable>();
AgateDatabase mParentDatabase;
@@ -131,6 +131,8 @@
return false;
}
+
+
#region IEnumerable<Table> Members
public IEnumerator<AgateTable> GetEnumerator()
@@ -151,6 +153,39 @@
#endregion
+ #region ICollection<AgateTable> Members
+
+ public void Clear()
+ {
+ mTables.Clear();
+ }
+
+ public bool Contains(AgateTable item)
+ {
+ return mTables.Contains(item);
+ }
+
+ public void CopyTo(AgateTable[] array, int arrayIndex)
+ {
+ mTables.CopyTo(array, arrayIndex);
+ }
+
+ public int Count
+ {
+ get { return mTables.Count; }
+ }
+
+ public bool IsReadOnly
+ {
+ get { return false; }
+ }
+
+ public bool Remove(AgateTable table)
+ {
+ return mTables.Remove(table);
+ }
+
+ #endregion
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2010-01-30 09:08:13
|
Revision: 1209
http://agate.svn.sourceforge.net/agate/?rev=1209&view=rev
Author: kanato
Date: 2010-01-30 09:08:07 +0000 (Sat, 30 Jan 2010)
Log Message:
-----------
Some UI improvements for database editor.
Modified Paths:
--------------
trunk/Tools/AgateDataLib/DatabaseEditor.Designer.cs
trunk/Tools/AgateDataLib/DatabaseEditor.cs
trunk/Tools/AgateDataLib/TableEditor.Designer.cs
trunk/Tools/AgateDataLib/TableEditor.cs
Modified: trunk/Tools/AgateDataLib/DatabaseEditor.Designer.cs
===================================================================
--- trunk/Tools/AgateDataLib/DatabaseEditor.Designer.cs 2010-01-30 09:07:41 UTC (rev 1208)
+++ trunk/Tools/AgateDataLib/DatabaseEditor.Designer.cs 2010-01-30 09:08:07 UTC (rev 1209)
@@ -60,7 +60,7 @@
this.lstTables.LargeImageList = this.largeImages;
this.lstTables.Location = new System.Drawing.Point(0, 0);
this.lstTables.Name = "lstTables";
- this.lstTables.Size = new System.Drawing.Size(133, 538);
+ this.lstTables.Size = new System.Drawing.Size(172, 538);
this.lstTables.SmallImageList = this.smallImages;
this.lstTables.TabIndex = 6;
this.lstTables.UseCompatibleStateImageBehavior = false;
@@ -92,7 +92,7 @@
this.tabs.Location = new System.Drawing.Point(0, 0);
this.tabs.Name = "tabs";
this.tabs.SelectedIndex = 0;
- this.tabs.Size = new System.Drawing.Size(480, 538);
+ this.tabs.Size = new System.Drawing.Size(441, 538);
this.tabs.TabIndex = 7;
this.tabs.MouseUp += new System.Windows.Forms.MouseEventHandler(this.tabs_MouseUp);
//
@@ -125,7 +125,7 @@
//
this.splitContainer1.Panel2.Controls.Add(this.tabs);
this.splitContainer1.Size = new System.Drawing.Size(617, 538);
- this.splitContainer1.SplitterDistance = 133;
+ this.splitContainer1.SplitterDistance = 172;
this.splitContainer1.TabIndex = 8;
//
// lvContextMenu
Modified: trunk/Tools/AgateDataLib/DatabaseEditor.cs
===================================================================
--- trunk/Tools/AgateDataLib/DatabaseEditor.cs 2010-01-30 09:07:41 UTC (rev 1208)
+++ trunk/Tools/AgateDataLib/DatabaseEditor.cs 2010-01-30 09:08:07 UTC (rev 1209)
@@ -36,6 +36,7 @@
public void DatabaseRefresh()
{
lstTables.Clear();
+ lstTables.Groups.Clear();
if (Database == null)
{
@@ -44,18 +45,27 @@
return;
}
+ ListViewGroup taskGroup = new ListViewGroup("Tasks");
+ ListViewGroup tableGroup = new ListViewGroup("Tables");
+
+ lstTables.Groups.Add(taskGroup);
+ lstTables.Groups.Add(tableGroup);
+
ListViewItem newTable = new ListViewItem("New Table");
newTable.ImageIndex = 1;
newTable.Tag = new InvokeDelegate(NewTable);
+ newTable.Group = taskGroup;
lstTables.Items.Add(newTable);
+
foreach (var table in Database.Tables)
{
ListViewItem item = new ListViewItem(table.Name);
item.ImageIndex = 0;
item.Tag = table;
-
+ item.Group = tableGroup;
+
lstTables.Items.Add(item);
}
@@ -125,6 +135,8 @@
page.Controls.Add(editor);
tabs.TabPages.Add(page);
+
+ tabs.SelectedTab = page;
}
private void NewTable()
Modified: trunk/Tools/AgateDataLib/TableEditor.Designer.cs
===================================================================
--- trunk/Tools/AgateDataLib/TableEditor.Designer.cs 2010-01-30 09:07:41 UTC (rev 1208)
+++ trunk/Tools/AgateDataLib/TableEditor.Designer.cs 2010-01-30 09:08:07 UTC (rev 1209)
@@ -54,6 +54,7 @@
this.gridView.RowDirtyStateNeeded += new System.Windows.Forms.QuestionEventHandler(this.gridView_RowDirtyStateNeeded);
this.gridView.CellValuePushed += new System.Windows.Forms.DataGridViewCellValueEventHandler(this.gridView_CellValuePushed);
this.gridView.NewRowNeeded += new System.Windows.Forms.DataGridViewRowEventHandler(this.gridView_NewRowNeeded);
+ this.gridView.ColumnWidthChanged += new System.Windows.Forms.DataGridViewColumnEventHandler(this.gridView_ColumnWidthChanged);
this.gridView.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.gridView_CellContentClick);
//
// contextMenuStrip1
@@ -61,7 +62,7 @@
this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.editColumnsToolStripMenuItem});
this.contextMenuStrip1.Name = "contextMenuStrip1";
- this.contextMenuStrip1.Size = new System.Drawing.Size(155, 48);
+ this.contextMenuStrip1.Size = new System.Drawing.Size(155, 26);
//
// editColumnsToolStripMenuItem
//
Modified: trunk/Tools/AgateDataLib/TableEditor.cs
===================================================================
--- trunk/Tools/AgateDataLib/TableEditor.cs 2010-01-30 09:07:41 UTC (rev 1208)
+++ trunk/Tools/AgateDataLib/TableEditor.cs 2010-01-30 09:08:07 UTC (rev 1209)
@@ -74,6 +74,9 @@
col.CellTemplate = new DataGridViewTextBoxCell();
}
+ if (column.ColumnWidth > 10)
+ col.Width = column.ColumnWidth;
+
gridView.Columns.Add(col);
index++;
@@ -208,6 +211,10 @@
{
}
+ private void gridView_ColumnWidthChanged(object sender, DataGridViewColumnEventArgs e)
+ {
+ mTable.Columns[e.Column.Index].ColumnWidth = e.Column.Width;
+ }
private void editColumnsToolStripMenuItem_Click(object sender, EventArgs e)
{
@@ -216,5 +223,6 @@
TableReset();
}
+
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2010-01-30 09:07:47
|
Revision: 1208
http://agate.svn.sourceforge.net/agate/?rev=1208&view=rev
Author: kanato
Date: 2010-01-30 09:07:41 +0000 (Sat, 30 Jan 2010)
Log Message:
-----------
Add ColumnWidth field to AgateColumn.
Modified Paths:
--------------
trunk/AgateLib/Data/AgateColumn.cs
Modified: trunk/AgateLib/Data/AgateColumn.cs
===================================================================
--- trunk/AgateLib/Data/AgateColumn.cs 2010-01-30 08:49:14 UTC (rev 1207)
+++ trunk/AgateLib/Data/AgateColumn.cs 2010-01-30 09:07:41 UTC (rev 1208)
@@ -9,59 +9,66 @@
{
public class AgateColumn : IXleSerializable
{
- private string name;
- private string description;
- private string tableLookup;
- private string lookupField;
- private bool primaryKey;
- private int nextAutoIncrementValue = 1;
- private FieldType fieldType;
+ private string mName;
+ private string mDescription;
+ private string mTableLookup;
+ private string mLookupField;
+ private bool mPrimaryKey;
+ private int mNextAutoIncrementValue = 1;
+ private FieldType mFieldType;
+ private int mColumnWidth;
+ #region --- Construction and Serialization ---
+
public AgateColumn Clone()
{
AgateColumn retval = new AgateColumn();
- retval.name = name;
- retval.description = description;
- retval.tableLookup = tableLookup;
- retval.lookupField = lookupField;
- retval.primaryKey = primaryKey;
- retval.nextAutoIncrementValue = nextAutoIncrementValue;
- retval.fieldType = fieldType;
+ retval.mName = mName;
+ retval.mDescription = mDescription;
+ retval.mTableLookup = mTableLookup;
+ retval.mLookupField = mLookupField;
+ retval.mPrimaryKey = mPrimaryKey;
+ retval.mNextAutoIncrementValue = mNextAutoIncrementValue;
+ retval.mFieldType = mFieldType;
return retval;
}
- #region IXleSerializable Members
-
void IXleSerializable.WriteData(XleSerializationInfo info)
{
- info.Write("Name", name, true);
- info.WriteEnum("FieldType", fieldType, true);
+ info.Write("Name", mName, true);
+ info.WriteEnum("FieldType", mFieldType, true);
- if (fieldType == FieldType.AutoNumber)
- info.Write("NextValue", nextAutoIncrementValue, true);
- if (primaryKey)
- info.Write("PrimaryKey", primaryKey, true);
+ if (mFieldType == FieldType.AutoNumber)
+ info.Write("NextValue", mNextAutoIncrementValue, true);
+ if (mPrimaryKey)
+ info.Write("PrimaryKey", mPrimaryKey, true);
- info.Write("Description", description);
+ info.Write("Description", mDescription);
- if (string.IsNullOrEmpty(tableLookup) == false)
+ if (string.IsNullOrEmpty(mTableLookup) == false)
{
- info.Write("TableLookup", tableLookup);
- info.Write("LookupField", lookupField);
+ info.Write("TableLookup", mTableLookup);
+ info.Write("LookupField", mLookupField);
}
+
+ if (mColumnWidth > 0)
+ {
+ info.Write("ColumnWidth", mColumnWidth);
+ }
}
void IXleSerializable.ReadData(XleSerializationInfo info)
{
- name = info.ReadString("Name");
- fieldType = info.ReadEnum<FieldType>("FieldType");
- nextAutoIncrementValue = info.ReadInt32("NextValue", 1);
- primaryKey = info.ReadBoolean("PrimaryKey", false);
- description = info.ReadString("Description");
- tableLookup = info.ReadString("TableLookup", string.Empty);
- lookupField = info.ReadString("LookupField", string.Empty);
+ mName = info.ReadString("Name");
+ mFieldType = info.ReadEnum<FieldType>("FieldType");
+ mNextAutoIncrementValue = info.ReadInt32("NextValue", 1);
+ mPrimaryKey = info.ReadBoolean("PrimaryKey", false);
+ mDescription = info.ReadString("Description");
+ mTableLookup = info.ReadString("TableLookup", string.Empty);
+ mLookupField = info.ReadString("LookupField", string.Empty);
+ mColumnWidth = info.ReadInt32("ColumnWidth", 0);
}
#endregion
@@ -69,9 +76,16 @@
[Browsable(false)]
public int NextAutoIncrementValue
{
- get { return nextAutoIncrementValue; }
+ get { return mNextAutoIncrementValue; }
}
+ [Browsable(false)]
+ public int ColumnWidth
+ {
+ get { return mColumnWidth; }
+ set { mColumnWidth = value; }
+ }
+
public string DefaultValue
{
get
@@ -85,23 +99,22 @@
internal void IncrementNextAutoIncrementValue()
{
- nextAutoIncrementValue++;
+ mNextAutoIncrementValue++;
}
-
public string Name
{
- get { return name; }
+ get { return mName; }
set
{
AssertIsValidName(value);
- name = value;
+ mName = value;
}
}
public FieldType FieldType
{
- get { return fieldType; }
- set { fieldType = value; }
+ get { return mFieldType; }
+ set { mFieldType = value; }
}
[Browsable(false)]
public Type FieldTypeDataType
@@ -113,23 +126,23 @@
}
public bool IsPrimaryKey
{
- get { return primaryKey; }
- set { primaryKey = value; }
+ get { return mPrimaryKey; }
+ set { mPrimaryKey = value; }
}
public string TableLookup
{
- get { return tableLookup; }
- set { tableLookup = value; }
+ get { return mTableLookup; }
+ set { mTableLookup = value; }
}
public string TableDisplayField
{
- get { return lookupField; }
- set { lookupField = value; }
+ get { return mLookupField; }
+ set { mLookupField = value; }
}
public string Description
{
- get { return description; }
- set { description = value; }
+ get { return mDescription; }
+ set { mDescription = value; }
}
public override string ToString()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2010-01-30 08:49:20
|
Revision: 1207
http://agate.svn.sourceforge.net/agate/?rev=1207&view=rev
Author: kanato
Date: 2010-01-30 08:49:14 +0000 (Sat, 30 Jan 2010)
Log Message:
-----------
Add dialog when code generation is completed.
Modified Paths:
--------------
trunk/Tools/DatabaseEditor/frmEditor.cs
Modified: trunk/Tools/DatabaseEditor/frmEditor.cs
===================================================================
--- trunk/Tools/DatabaseEditor/frmEditor.cs 2010-01-30 08:45:23 UTC (rev 1206)
+++ trunk/Tools/DatabaseEditor/frmEditor.cs 2010-01-30 08:49:14 UTC (rev 1207)
@@ -137,6 +137,10 @@
databaseEditor1.Database.CodeNamespace = frm.Namespace;
GenerateCode(frm.CodeDomProviderType, frm.Directory, frm.Namespace);
+
+ MessageBox.Show("Code generation completed.",
+ "Code Generation", MessageBoxButtons.OK,
+ MessageBoxIcon.Information);
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2010-01-30 08:45:29
|
Revision: 1206
http://agate.svn.sourceforge.net/agate/?rev=1206&view=rev
Author: kanato
Date: 2010-01-30 08:45:23 +0000 (Sat, 30 Jan 2010)
Log Message:
-----------
Minor UI fixes.
Modified Paths:
--------------
trunk/Tools/AgateDataLib/DatabaseEditor.Designer.cs
trunk/Tools/AgateDataLib/DatabaseEditor.resx
trunk/Tools/DatabaseEditor/frmEditor.Designer.cs
trunk/Tools/DatabaseEditor/frmEditor.resx
Modified: trunk/Tools/AgateDataLib/DatabaseEditor.Designer.cs
===================================================================
--- trunk/Tools/AgateDataLib/DatabaseEditor.Designer.cs 2010-01-30 08:44:52 UTC (rev 1205)
+++ trunk/Tools/AgateDataLib/DatabaseEditor.Designer.cs 2010-01-30 08:45:23 UTC (rev 1206)
@@ -113,6 +113,7 @@
// splitContainer1
//
this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.splitContainer1.FixedPanel = System.Windows.Forms.FixedPanel.Panel1;
this.splitContainer1.Location = new System.Drawing.Point(0, 0);
this.splitContainer1.Name = "splitContainer1";
//
@@ -178,14 +179,14 @@
// renameToolStripMenuItem
//
this.renameToolStripMenuItem.Name = "renameToolStripMenuItem";
- this.renameToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
+ this.renameToolStripMenuItem.Size = new System.Drawing.Size(126, 22);
this.renameToolStripMenuItem.Text = "Rename...";
this.renameToolStripMenuItem.Click += new System.EventHandler(this.renameToolStripMenuItem_Click);
//
// deleteToolStripMenuItem
//
this.deleteToolStripMenuItem.Name = "deleteToolStripMenuItem";
- this.deleteToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
+ this.deleteToolStripMenuItem.Size = new System.Drawing.Size(126, 22);
this.deleteToolStripMenuItem.Text = "Delete";
//
// DatabaseEditor
Modified: trunk/Tools/AgateDataLib/DatabaseEditor.resx
===================================================================
--- trunk/Tools/AgateDataLib/DatabaseEditor.resx 2010-01-30 08:44:52 UTC (rev 1205)
+++ trunk/Tools/AgateDataLib/DatabaseEditor.resx 2010-01-30 08:45:23 UTC (rev 1206)
@@ -125,7 +125,7 @@
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj0yLjAuMC4w
LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAAAs
- DAAAAk1TRnQBSQFMAgEBAgEAASABAAEgAQABIAEAASABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo
+ DAAAAk1TRnQBSQFMAgEBAgEAASgBAAEoAQABIAEAASABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo
AwABgAMAASADAAEBAQABCAYAARAYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA
AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5
AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA
@@ -188,7 +188,7 @@
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj0yLjAuMC4w
LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAABs
- CQAAAk1TRnQBSQFMAgEBAgEAASgBAAEoAQABEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo
+ CQAAAk1TRnQBSQFMAgEBAgEAATABAAEwAQABEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo
AwABQAMAARADAAEBAQABCAYAAQQYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA
AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5
AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA
Modified: trunk/Tools/DatabaseEditor/frmEditor.Designer.cs
===================================================================
--- trunk/Tools/DatabaseEditor/frmEditor.Designer.cs 2010-01-30 08:44:52 UTC (rev 1205)
+++ trunk/Tools/DatabaseEditor/frmEditor.Designer.cs 2010-01-30 08:45:23 UTC (rev 1206)
@@ -36,14 +36,14 @@
this.saveDatabaseToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.saveDatabaseAsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
+ this.quitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.importDataToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();
this.generateCodeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.openDatabase = new System.Windows.Forms.OpenFileDialog();
this.saveDatabase = new System.Windows.Forms.SaveFileDialog();
- this.importDataToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.quitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.databaseEditor1 = new AgateDataLib.DatabaseEditor();
- this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();
this.menuStrip1.SuspendLayout();
this.SuspendLayout();
//
@@ -112,6 +112,13 @@
this.toolStripSeparator1.Name = "toolStripSeparator1";
this.toolStripSeparator1.Size = new System.Drawing.Size(168, 6);
//
+ // quitToolStripMenuItem
+ //
+ this.quitToolStripMenuItem.Name = "quitToolStripMenuItem";
+ this.quitToolStripMenuItem.Size = new System.Drawing.Size(171, 22);
+ this.quitToolStripMenuItem.Text = "Quit";
+ this.quitToolStripMenuItem.Click += new System.EventHandler(this.quitToolStripMenuItem_Click);
+ //
// toolsToolStripMenuItem
//
this.toolsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
@@ -122,6 +129,18 @@
this.toolsToolStripMenuItem.Size = new System.Drawing.Size(48, 20);
this.toolsToolStripMenuItem.Text = "Tools";
//
+ // importDataToolStripMenuItem
+ //
+ this.importDataToolStripMenuItem.Name = "importDataToolStripMenuItem";
+ this.importDataToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
+ this.importDataToolStripMenuItem.Text = "Import Data...";
+ this.importDataToolStripMenuItem.Click += new System.EventHandler(this.importDataToolStripMenuItem_Click);
+ //
+ // toolStripSeparator2
+ //
+ this.toolStripSeparator2.Name = "toolStripSeparator2";
+ this.toolStripSeparator2.Size = new System.Drawing.Size(149, 6);
+ //
// generateCodeToolStripMenuItem
//
this.generateCodeToolStripMenuItem.Name = "generateCodeToolStripMenuItem";
@@ -136,22 +155,8 @@
// saveDatabase
//
this.saveDatabase.DefaultExt = "adb";
- this.saveDatabase.Filter = "*.adb|Agate Database|*.*|All files";
+ this.saveDatabase.Filter = "Agate Database (*.adb)|*.adb|All files|*.*";
//
- // importDataToolStripMenuItem
- //
- this.importDataToolStripMenuItem.Name = "importDataToolStripMenuItem";
- this.importDataToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
- this.importDataToolStripMenuItem.Text = "Import Data...";
- this.importDataToolStripMenuItem.Click += new System.EventHandler(this.importDataToolStripMenuItem_Click);
- //
- // quitToolStripMenuItem
- //
- this.quitToolStripMenuItem.Name = "quitToolStripMenuItem";
- this.quitToolStripMenuItem.Size = new System.Drawing.Size(171, 22);
- this.quitToolStripMenuItem.Text = "Quit";
- this.quitToolStripMenuItem.Click += new System.EventHandler(this.quitToolStripMenuItem_Click);
- //
// databaseEditor1
//
this.databaseEditor1.Database = null;
@@ -162,11 +167,6 @@
this.databaseEditor1.TabIndex = 3;
this.databaseEditor1.Visible = false;
//
- // toolStripSeparator2
- //
- this.toolStripSeparator2.Name = "toolStripSeparator2";
- this.toolStripSeparator2.Size = new System.Drawing.Size(149, 6);
- //
// frmEditor
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
Modified: trunk/Tools/DatabaseEditor/frmEditor.resx
===================================================================
--- trunk/Tools/DatabaseEditor/frmEditor.resx 2010-01-30 08:44:52 UTC (rev 1205)
+++ trunk/Tools/DatabaseEditor/frmEditor.resx 2010-01-30 08:45:23 UTC (rev 1206)
@@ -127,6 +127,6 @@
<value>289, 17</value>
</metadata>
<metadata name="saveDatabase.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
- <value>483, 17</value>
+ <value>413, 27</value>
</metadata>
</root>
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2010-01-30 08:44:58
|
Revision: 1205
http://agate.svn.sourceforge.net/agate/?rev=1205&view=rev
Author: kanato
Date: 2010-01-30 08:44:52 +0000 (Sat, 30 Jan 2010)
Log Message:
-----------
Fix reading of quote surrounded strings.
Modified Paths:
--------------
trunk/AgateLib/Data/AgateTable.cs
Modified: trunk/AgateLib/Data/AgateTable.cs
===================================================================
--- trunk/AgateLib/Data/AgateTable.cs 2010-01-30 08:35:27 UTC (rev 1204)
+++ trunk/AgateLib/Data/AgateTable.cs 2010-01-30 08:44:52 UTC (rev 1205)
@@ -77,7 +77,14 @@
int i = 0;
foreach (var column in Columns)
{
- row.WriteWithoutValidation(column, data[i]);
+ string val = data[i];
+
+ if (val.StartsWith("\"") && val.EndsWith("\""))
+ {
+ val = val.Substring(1, val.Length - 2);
+ }
+
+ row.WriteWithoutValidation(column, val);
i++;
}
@@ -129,28 +136,6 @@
mRows.ForEach(x => x.ValidateData(this));
}
- public override string ToString()
- {
- StringBuilder b = new StringBuilder();
-
- b.Append("Name:");
- b.AppendLine(Name);
-
- foreach (var column in mColumns)
- {
- b.AppendLine(column.ToString());
- }
-
- b.AppendLine("Rows:");
-
- foreach (var row in mRows)
- {
- b.AppendLine(row.ToString());
- }
-
- return b.ToString();
- }
-
internal void Validate()
{
foreach (var row in mRows)
@@ -158,27 +143,6 @@
}
- private static void ReadRows(AgateTable table, StreamReader r)
- {
- while (r.EndOfStream == false)
- {
- string line = r.ReadLine();
-
- string[] data = AgateDataHelper.Split(line);
-
- AgateRow row = new AgateRow(table);
-
- int i = 0;
- foreach (var column in table.Columns)
- {
- row[column] = data[i];
- i++;
- }
-
- table.Rows.Add(row);
- }
- }
-
public void RemoveColumn(int index)
{
throw new NotImplementedException();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2010-01-30 08:35:33
|
Revision: 1204
http://agate.svn.sourceforge.net/agate/?rev=1204&view=rev
Author: kanato
Date: 2010-01-30 08:35:27 +0000 (Sat, 30 Jan 2010)
Log Message:
-----------
Update AgateLib project file for renamed database classes.
Modified Paths:
--------------
trunk/AgateLib/AgateLib.csproj
trunk/Tools/AgateDataLib/DatabaseEditor.cs
trunk/Tools/AgateDataLib/DatabaseWriter.cs
trunk/Tools/AgateDataLib/TableEditor.cs
trunk/Tools/AgateDataLib/frmDesignTable.cs
Modified: trunk/AgateLib/AgateLib.csproj
===================================================================
--- trunk/AgateLib/AgateLib.csproj 2010-01-30 08:33:58 UTC (rev 1203)
+++ trunk/AgateLib/AgateLib.csproj 2010-01-30 08:35:27 UTC (rev 1204)
@@ -143,15 +143,15 @@
<SubType>Code</SubType>
</Compile>
<Compile Include="Data\AgateDatabaseException.cs" />
- <Compile Include="Data\Column.cs" />
+ <Compile Include="Data\AgateColumn.cs" />
<Compile Include="Data\AgateDatabase.cs" />
- <Compile Include="Data\Row.cs" />
- <Compile Include="Data\Table.cs" />
- <Compile Include="Data\ColumnDictionary.cs" />
- <Compile Include="Data\DataHelper.cs" />
+ <Compile Include="Data\AgateRow.cs" />
+ <Compile Include="Data\AgateTable.cs" />
+ <Compile Include="Data\AgateColumnDictionary.cs" />
+ <Compile Include="Data\AgateDataHelper.cs" />
<Compile Include="Data\FieldType.cs" />
- <Compile Include="Data\RowList.cs" />
- <Compile Include="Data\TableDictionary.cs" />
+ <Compile Include="Data\AgateRowList.cs" />
+ <Compile Include="Data\AgateTableDictionary.cs" />
<Compile Include="DisplayLib\FrameBuffer.cs" />
<Compile Include="DisplayLib\Shaders\AgateBuiltInShaders.cs" />
<Compile Include="DisplayLib\Shaders\Basic2DShader.cs" />
Modified: trunk/Tools/AgateDataLib/DatabaseEditor.cs
===================================================================
--- trunk/Tools/AgateDataLib/DatabaseEditor.cs 2010-01-30 08:33:58 UTC (rev 1203)
+++ trunk/Tools/AgateDataLib/DatabaseEditor.cs 2010-01-30 08:35:27 UTC (rev 1204)
@@ -84,7 +84,7 @@
return;
object obj = lstTables.SelectedItems[0].Tag ;
- Table table = obj as Table;
+ AgateTable table = obj as AgateTable;
InvokeDelegate method = obj as InvokeDelegate;
if (table != null)
@@ -97,7 +97,7 @@
}
}
- private void OpenTableTab(Table table)
+ private void OpenTableTab(AgateTable table)
{
foreach (TabPage tab in tabs.TabPages)
{
@@ -186,7 +186,7 @@
menu = lvContextMenu;
else if (lstTables.SelectedItems.Count == 1)
{
- if (lstTables.SelectedItems[0].Tag is Table)
+ if (lstTables.SelectedItems[0].Tag is AgateTable)
{
menu = tableContextMenu;
}
@@ -214,7 +214,7 @@
private void lstTables_AfterLabelEdit(object sender, LabelEditEventArgs e)
{
object obj = lstTables.SelectedItems[0].Tag;
- Table table = obj as Table;
+ AgateTable table = obj as AgateTable;
if (Database.Tables.ContainsTable(e.Label))
{
Modified: trunk/Tools/AgateDataLib/DatabaseWriter.cs
===================================================================
--- trunk/Tools/AgateDataLib/DatabaseWriter.cs 2010-01-30 08:33:58 UTC (rev 1203)
+++ trunk/Tools/AgateDataLib/DatabaseWriter.cs 2010-01-30 08:35:27 UTC (rev 1204)
@@ -62,7 +62,7 @@
ZipEntry catalog = zip.AddEntry("catalog.txt", ms);
// now do each table
- XleSerializer tableSer = new XleSerializer(typeof(Table));
+ XleSerializer tableSer = new XleSerializer(typeof(AgateTable));
foreach (var table in Database.Tables)
{
Modified: trunk/Tools/AgateDataLib/TableEditor.cs
===================================================================
--- trunk/Tools/AgateDataLib/TableEditor.cs 2010-01-30 08:33:58 UTC (rev 1203)
+++ trunk/Tools/AgateDataLib/TableEditor.cs 2010-01-30 08:35:27 UTC (rev 1204)
@@ -12,9 +12,9 @@
public partial class TableEditor : UserControl
{
AgateDatabase mDatabase;
- Table mTable;
+ AgateTable mTable;
- Row mEditingRow;
+ AgateRow mEditingRow;
int mEditingRowIndex = -1;
public TableEditor()
@@ -29,7 +29,7 @@
AgateTable = null;
}
}
- public Table AgateTable
+ public AgateTable AgateTable
{
get { return mTable; }
set
@@ -88,7 +88,7 @@
gridView.RowCount = mTable.Rows.Count + 1;
}
- Column GetColumn(int columnIndex)
+ AgateColumn GetColumn(int columnIndex)
{
return mTable.Columns[columnIndex];
}
@@ -102,7 +102,7 @@
if (e.RowIndex == gridView.RowCount - 1)
return;
- Row row = null;
+ AgateRow row = null;
if (e.RowIndex == mEditingRowIndex)
row = mEditingRow;
@@ -113,7 +113,7 @@
}
private void gridView_CellValuePushed(object sender, DataGridViewCellValueEventArgs e)
{
- Row row = null;
+ AgateRow row = null;
// Store the reference to the row being edited.
if (e.RowIndex < mTable.Rows.Count)
@@ -144,7 +144,7 @@
}
private void gridView_NewRowNeeded(object sender, DataGridViewRowEventArgs e)
{
- mEditingRow = new Row(mTable);
+ mEditingRow = new AgateRow(mTable);
mEditingRowIndex = gridView.Rows.Count - 1;
}
private void gridView_RowValidated(object sender, DataGridViewCellEventArgs e)
@@ -179,7 +179,7 @@
{
// If the user has canceled the edit of a newly created row,
// replace the corresponding Customer object with a new, empty one.
- this.mEditingRow = new Row(mTable);
+ this.mEditingRow = new AgateRow(mTable);
}
else
{
Modified: trunk/Tools/AgateDataLib/frmDesignTable.cs
===================================================================
--- trunk/Tools/AgateDataLib/frmDesignTable.cs 2010-01-30 08:33:58 UTC (rev 1203)
+++ trunk/Tools/AgateDataLib/frmDesignTable.cs 2010-01-30 08:35:27 UTC (rev 1204)
@@ -21,11 +21,11 @@
}
}
- Table mTable;
- Column mColumnInEdit;
+ AgateTable mTable;
+ AgateColumn mColumnInEdit;
int mRowInEdit = -1;
- public Table TheTable
+ public AgateTable TheTable
{
get { return mTable; }
set
@@ -36,7 +36,7 @@
}
}
- internal static void EditColumns(AgateLib.Data.Table mTable)
+ internal static void EditColumns(AgateLib.Data.AgateTable mTable)
{
frmDesignTable d = new frmDesignTable();
@@ -49,7 +49,7 @@
{
if (e.RowIndex == gridColumns.RowCount - 1) return;
- Column col = null;
+ AgateColumn col = null;
if (e.RowIndex == mRowInEdit)
col = mColumnInEdit;
@@ -72,7 +72,7 @@
private void gridColumns_CellValuePushed(object sender, DataGridViewCellValueEventArgs e)
{
- Column col = null;
+ AgateColumn col = null;
if (e.RowIndex < mTable.Columns.Count)
{
@@ -104,7 +104,7 @@
private void gridColumns_NewRowNeeded(object sender, DataGridViewRowEventArgs e)
{
- this.mColumnInEdit = new Column();
+ this.mColumnInEdit = new AgateColumn();
this.mRowInEdit = gridColumns.Rows.Count - 1;
}
@@ -147,7 +147,7 @@
{
// If the user has canceled the edit of a newly created row,
// replace the corresponding Column object with a new, empty one.
- mColumnInEdit = new Column();
+ mColumnInEdit = new AgateColumn();
}
else
{
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2010-01-30 08:34:06
|
Revision: 1203
http://agate.svn.sourceforge.net/agate/?rev=1203&view=rev
Author: kanato
Date: 2010-01-30 08:33:58 +0000 (Sat, 30 Jan 2010)
Log Message:
-----------
Add missing frmImportTable and warning icon.
Modified Paths:
--------------
trunk/Tools/DatabaseEditor/DatabaseEditor.csproj
Added Paths:
-----------
trunk/Tools/DatabaseEditor/Resources/
trunk/Tools/DatabaseEditor/Resources/warning1.png
trunk/Tools/DatabaseEditor/frmImportTable.Designer.cs
trunk/Tools/DatabaseEditor/frmImportTable.cs
trunk/Tools/DatabaseEditor/frmImportTable.resx
Modified: trunk/Tools/DatabaseEditor/DatabaseEditor.csproj
===================================================================
--- trunk/Tools/DatabaseEditor/DatabaseEditor.csproj 2010-01-30 08:32:40 UTC (rev 1202)
+++ trunk/Tools/DatabaseEditor/DatabaseEditor.csproj 2010-01-30 08:33:58 UTC (rev 1203)
@@ -148,9 +148,6 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
- <None Include="Resources\Warning.png" />
- </ItemGroup>
- <ItemGroup>
<None Include="Resources\warning1.png" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
Added: trunk/Tools/DatabaseEditor/Resources/warning1.png
===================================================================
(Binary files differ)
Property changes on: trunk/Tools/DatabaseEditor/Resources/warning1.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/Tools/DatabaseEditor/frmImportTable.Designer.cs
===================================================================
--- trunk/Tools/DatabaseEditor/frmImportTable.Designer.cs (rev 0)
+++ trunk/Tools/DatabaseEditor/frmImportTable.Designer.cs 2010-01-30 08:33:58 UTC (rev 1203)
@@ -0,0 +1,391 @@
+namespace DatabaseEditor
+{
+ partial class frmImportTable
+ {
+ /// <summary>
+ /// Required designer variable.
+ /// </summary>
+ private System.ComponentModel.IContainer components = null;
+
+ /// <summary>
+ /// Clean up any resources being used.
+ /// </summary>
+ /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ /// <summary>
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ /// </summary>
+ private void InitializeComponent()
+ {
+ this.txtFileContents = new System.Windows.Forms.TextBox();
+ this.btnOK = new System.Windows.Forms.Button();
+ this.btnCancel = new System.Windows.Forms.Button();
+ this.hSeparator1 = new ERY.NotebookLib.HSeparator();
+ this.openFile = new System.Windows.Forms.OpenFileDialog();
+ this.groupBox1 = new System.Windows.Forms.GroupBox();
+ this.txtOther = new System.Windows.Forms.TextBox();
+ this.chkOther = new System.Windows.Forms.CheckBox();
+ this.chkSpace = new System.Windows.Forms.CheckBox();
+ this.chkTab = new System.Windows.Forms.CheckBox();
+ this.chkSemicolon = new System.Windows.Forms.CheckBox();
+ this.chkComma = new System.Windows.Forms.CheckBox();
+ this.cboTextQualifier = new System.Windows.Forms.ComboBox();
+ this.label1 = new System.Windows.Forms.Label();
+ this.backgroundWorker1 = new System.ComponentModel.BackgroundWorker();
+ this.chkFirstRow = new System.Windows.Forms.CheckBox();
+ this.label2 = new System.Windows.Forms.Label();
+ this.txtName = new System.Windows.Forms.TextBox();
+ this.pnlTableWarning = new System.Windows.Forms.Panel();
+ this.label3 = new System.Windows.Forms.Label();
+ this.pictureBox1 = new System.Windows.Forms.PictureBox();
+ this.lstColumns = new System.Windows.Forms.ListBox();
+ this.label4 = new System.Windows.Forms.Label();
+ this.propColumns = new System.Windows.Forms.PropertyGrid();
+ this.panel1 = new System.Windows.Forms.Panel();
+ this.groupBox1.SuspendLayout();
+ this.pnlTableWarning.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
+ this.panel1.SuspendLayout();
+ this.SuspendLayout();
+ //
+ // txtFileContents
+ //
+ this.txtFileContents.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.txtFileContents.Location = new System.Drawing.Point(12, 93);
+ this.txtFileContents.Multiline = true;
+ this.txtFileContents.Name = "txtFileContents";
+ this.txtFileContents.ReadOnly = true;
+ this.txtFileContents.ScrollBars = System.Windows.Forms.ScrollBars.Both;
+ this.txtFileContents.Size = new System.Drawing.Size(533, 138);
+ this.txtFileContents.TabIndex = 0;
+ //
+ // btnOK
+ //
+ this.btnOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
+ this.btnOK.DialogResult = System.Windows.Forms.DialogResult.OK;
+ this.btnOK.Location = new System.Drawing.Point(389, 512);
+ this.btnOK.Name = "btnOK";
+ this.btnOK.Size = new System.Drawing.Size(75, 23);
+ this.btnOK.TabIndex = 1;
+ this.btnOK.Text = "OK";
+ this.btnOK.UseVisualStyleBackColor = true;
+ this.btnOK.Click += new System.EventHandler(this.btnOK_Click);
+ //
+ // btnCancel
+ //
+ this.btnCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
+ this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
+ this.btnCancel.Location = new System.Drawing.Point(470, 512);
+ this.btnCancel.Name = "btnCancel";
+ this.btnCancel.Size = new System.Drawing.Size(75, 23);
+ this.btnCancel.TabIndex = 2;
+ this.btnCancel.Text = "Cancel";
+ this.btnCancel.UseVisualStyleBackColor = true;
+ //
+ // hSeparator1
+ //
+ this.hSeparator1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.hSeparator1.Location = new System.Drawing.Point(12, 235);
+ this.hSeparator1.Margin = new System.Windows.Forms.Padding(3, 1, 3, 1);
+ this.hSeparator1.MaximumSize = new System.Drawing.Size(10000, 4);
+ this.hSeparator1.MinimumSize = new System.Drawing.Size(0, 4);
+ this.hSeparator1.Name = "hSeparator1";
+ this.hSeparator1.Size = new System.Drawing.Size(533, 4);
+ this.hSeparator1.TabIndex = 3;
+ this.hSeparator1.TabStop = true;
+ //
+ // openFile
+ //
+ this.openFile.FileName = "openFileDialog1";
+ this.openFile.Filter = "Text Files (*.txt,*.csv)|*.txt;*.csv|All Files|*.*";
+ //
+ // groupBox1
+ //
+ this.groupBox1.Controls.Add(this.txtOther);
+ this.groupBox1.Controls.Add(this.chkOther);
+ this.groupBox1.Controls.Add(this.chkSpace);
+ this.groupBox1.Controls.Add(this.chkTab);
+ this.groupBox1.Controls.Add(this.chkSemicolon);
+ this.groupBox1.Controls.Add(this.chkComma);
+ this.groupBox1.Location = new System.Drawing.Point(12, 12);
+ this.groupBox1.Name = "groupBox1";
+ this.groupBox1.Size = new System.Drawing.Size(354, 75);
+ this.groupBox1.TabIndex = 4;
+ this.groupBox1.TabStop = false;
+ this.groupBox1.Text = "Delimiters";
+ //
+ // txtOther
+ //
+ this.txtOther.Location = new System.Drawing.Point(287, 23);
+ this.txtOther.MaxLength = 1;
+ this.txtOther.Name = "txtOther";
+ this.txtOther.Size = new System.Drawing.Size(23, 20);
+ this.txtOther.TabIndex = 5;
+ this.txtOther.TextChanged += new System.EventHandler(this.DelimiterCheck_CheckedChanged);
+ //
+ // chkOther
+ //
+ this.chkOther.AutoSize = true;
+ this.chkOther.Location = new System.Drawing.Point(226, 25);
+ this.chkOther.Name = "chkOther";
+ this.chkOther.Size = new System.Drawing.Size(55, 17);
+ this.chkOther.TabIndex = 4;
+ this.chkOther.Text = "Other:";
+ this.chkOther.UseVisualStyleBackColor = true;
+ this.chkOther.CheckedChanged += new System.EventHandler(this.DelimiterCheck_CheckedChanged);
+ //
+ // chkSpace
+ //
+ this.chkSpace.AutoSize = true;
+ this.chkSpace.Location = new System.Drawing.Point(113, 48);
+ this.chkSpace.Name = "chkSpace";
+ this.chkSpace.Size = new System.Drawing.Size(57, 17);
+ this.chkSpace.TabIndex = 3;
+ this.chkSpace.Text = "Space";
+ this.chkSpace.UseVisualStyleBackColor = true;
+ this.chkSpace.CheckedChanged += new System.EventHandler(this.DelimiterCheck_CheckedChanged);
+ //
+ // chkTab
+ //
+ this.chkTab.AutoSize = true;
+ this.chkTab.Location = new System.Drawing.Point(17, 48);
+ this.chkTab.Name = "chkTab";
+ this.chkTab.Size = new System.Drawing.Size(45, 17);
+ this.chkTab.TabIndex = 2;
+ this.chkTab.Text = "Tab";
+ this.chkTab.UseVisualStyleBackColor = true;
+ this.chkTab.CheckedChanged += new System.EventHandler(this.DelimiterCheck_CheckedChanged);
+ //
+ // chkSemicolon
+ //
+ this.chkSemicolon.AutoSize = true;
+ this.chkSemicolon.Location = new System.Drawing.Point(113, 25);
+ this.chkSemicolon.Name = "chkSemicolon";
+ this.chkSemicolon.Size = new System.Drawing.Size(75, 17);
+ this.chkSemicolon.TabIndex = 1;
+ this.chkSemicolon.Text = "Semicolon";
+ this.chkSemicolon.UseVisualStyleBackColor = true;
+ this.chkSemicolon.CheckedChanged += new System.EventHandler(this.DelimiterCheck_CheckedChanged);
+ //
+ // chkComma
+ //
+ this.chkComma.AutoSize = true;
+ this.chkComma.Checked = true;
+ this.chkComma.CheckState = System.Windows.Forms.CheckState.Checked;
+ this.chkComma.Location = new System.Drawing.Point(17, 25);
+ this.chkComma.Name = "chkComma";
+ this.chkComma.Size = new System.Drawing.Size(61, 17);
+ this.chkComma.TabIndex = 0;
+ this.chkComma.Text = "Comma";
+ this.chkComma.UseVisualStyleBackColor = true;
+ this.chkComma.CheckedChanged += new System.EventHandler(this.DelimiterCheck_CheckedChanged);
+ //
+ // cboTextQualifier
+ //
+ this.cboTextQualifier.FormattingEnabled = true;
+ this.cboTextQualifier.Items.AddRange(new object[] {
+ "{none}",
+ "\'",
+ "\""});
+ this.cboTextQualifier.Location = new System.Drawing.Point(456, 22);
+ this.cboTextQualifier.Name = "cboTextQualifier";
+ this.cboTextQualifier.Size = new System.Drawing.Size(61, 21);
+ this.cboTextQualifier.TabIndex = 5;
+ this.cboTextQualifier.Text = "\"";
+ this.cboTextQualifier.TextChanged += new System.EventHandler(this.comboBox1_TextChanged);
+ //
+ // label1
+ //
+ this.label1.AutoSize = true;
+ this.label1.Location = new System.Drawing.Point(378, 25);
+ this.label1.Name = "label1";
+ this.label1.Size = new System.Drawing.Size(72, 13);
+ this.label1.TabIndex = 6;
+ this.label1.Text = "Text Qualifier:";
+ //
+ // backgroundWorker1
+ //
+ this.backgroundWorker1.DoWork += new System.ComponentModel.DoWorkEventHandler(this.backgroundWorker1_DoWork);
+ this.backgroundWorker1.RunWorkerCompleted += new System.ComponentModel.RunWorkerCompletedEventHandler(this.backgroundWorker1_RunWorkerCompleted);
+ //
+ // chkFirstRow
+ //
+ this.chkFirstRow.AutoSize = true;
+ this.chkFirstRow.Checked = true;
+ this.chkFirstRow.CheckState = System.Windows.Forms.CheckState.Checked;
+ this.chkFirstRow.Location = new System.Drawing.Point(381, 60);
+ this.chkFirstRow.Name = "chkFirstRow";
+ this.chkFirstRow.Size = new System.Drawing.Size(164, 17);
+ this.chkFirstRow.TabIndex = 7;
+ this.chkFirstRow.Text = "First row contains field names";
+ this.chkFirstRow.UseVisualStyleBackColor = true;
+ this.chkFirstRow.CheckedChanged += new System.EventHandler(this.chkFirstRow_CheckedChanged);
+ //
+ // label2
+ //
+ this.label2.AutoSize = true;
+ this.label2.Location = new System.Drawing.Point(12, 255);
+ this.label2.Name = "label2";
+ this.label2.Size = new System.Drawing.Size(68, 13);
+ this.label2.TabIndex = 8;
+ this.label2.Text = "Table Name:";
+ //
+ // txtName
+ //
+ this.txtName.Location = new System.Drawing.Point(86, 252);
+ this.txtName.Name = "txtName";
+ this.txtName.Size = new System.Drawing.Size(157, 20);
+ this.txtName.TabIndex = 9;
+ this.txtName.TextChanged += new System.EventHandler(this.txtName_TextChanged);
+ //
+ // pnlTableWarning
+ //
+ this.pnlTableWarning.Controls.Add(this.label3);
+ this.pnlTableWarning.Controls.Add(this.pictureBox1);
+ this.pnlTableWarning.Location = new System.Drawing.Point(250, 243);
+ this.pnlTableWarning.Name = "pnlTableWarning";
+ this.pnlTableWarning.Size = new System.Drawing.Size(295, 37);
+ this.pnlTableWarning.TabIndex = 10;
+ this.pnlTableWarning.Visible = false;
+ //
+ // label3
+ //
+ this.label3.AutoSize = true;
+ this.label3.Location = new System.Drawing.Point(27, 12);
+ this.label3.Name = "label3";
+ this.label3.Size = new System.Drawing.Size(226, 13);
+ this.label3.TabIndex = 1;
+ this.label3.Text = "There is already a table by the specified name.";
+ //
+ // pictureBox1
+ //
+ this.pictureBox1.Image = global::DatabaseEditor.Properties.Resources.warning;
+ this.pictureBox1.Location = new System.Drawing.Point(5, 9);
+ this.pictureBox1.Name = "pictureBox1";
+ this.pictureBox1.Size = new System.Drawing.Size(16, 16);
+ this.pictureBox1.TabIndex = 0;
+ this.pictureBox1.TabStop = false;
+ //
+ // lstColumns
+ //
+ this.lstColumns.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
+ | System.Windows.Forms.AnchorStyles.Left)));
+ this.lstColumns.Enabled = false;
+ this.lstColumns.FormattingEnabled = true;
+ this.lstColumns.Location = new System.Drawing.Point(3, 16);
+ this.lstColumns.Name = "lstColumns";
+ this.lstColumns.Size = new System.Drawing.Size(120, 199);
+ this.lstColumns.TabIndex = 11;
+ this.lstColumns.SelectedIndexChanged += new System.EventHandler(this.lstColumns_SelectedIndexChanged);
+ //
+ // label4
+ //
+ this.label4.AutoSize = true;
+ this.label4.Location = new System.Drawing.Point(3, 0);
+ this.label4.Name = "label4";
+ this.label4.Size = new System.Drawing.Size(47, 13);
+ this.label4.TabIndex = 12;
+ this.label4.Text = "Columns";
+ //
+ // propColumns
+ //
+ this.propColumns.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
+ | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.propColumns.CommandsVisibleIfAvailable = false;
+ this.propColumns.Enabled = false;
+ this.propColumns.HelpVisible = false;
+ this.propColumns.Location = new System.Drawing.Point(129, 16);
+ this.propColumns.Name = "propColumns";
+ this.propColumns.Size = new System.Drawing.Size(401, 201);
+ this.propColumns.TabIndex = 13;
+ //
+ // panel1
+ //
+ this.panel1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
+ | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.panel1.Controls.Add(this.label4);
+ this.panel1.Controls.Add(this.propColumns);
+ this.panel1.Controls.Add(this.lstColumns);
+ this.panel1.Location = new System.Drawing.Point(12, 286);
+ this.panel1.Name = "panel1";
+ this.panel1.Size = new System.Drawing.Size(533, 220);
+ this.panel1.TabIndex = 14;
+ //
+ // frmImportTable
+ //
+ this.AcceptButton = this.btnOK;
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.CancelButton = this.btnCancel;
+ this.ClientSize = new System.Drawing.Size(557, 547);
+ this.Controls.Add(this.panel1);
+ this.Controls.Add(this.pnlTableWarning);
+ this.Controls.Add(this.txtName);
+ this.Controls.Add(this.label2);
+ this.Controls.Add(this.chkFirstRow);
+ this.Controls.Add(this.label1);
+ this.Controls.Add(this.cboTextQualifier);
+ this.Controls.Add(this.groupBox1);
+ this.Controls.Add(this.hSeparator1);
+ this.Controls.Add(this.btnCancel);
+ this.Controls.Add(this.btnOK);
+ this.Controls.Add(this.txtFileContents);
+ this.Name = "frmImportTable";
+ this.Text = "Import Data";
+ this.Load += new System.EventHandler(this.frmImportData_Load);
+ this.groupBox1.ResumeLayout(false);
+ this.groupBox1.PerformLayout();
+ this.pnlTableWarning.ResumeLayout(false);
+ this.pnlTableWarning.PerformLayout();
+ ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
+ this.panel1.ResumeLayout(false);
+ this.panel1.PerformLayout();
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.TextBox txtFileContents;
+ private System.Windows.Forms.Button btnOK;
+ private System.Windows.Forms.Button btnCancel;
+ private ERY.NotebookLib.HSeparator hSeparator1;
+ private System.Windows.Forms.OpenFileDialog openFile;
+ private System.Windows.Forms.GroupBox groupBox1;
+ private System.Windows.Forms.TextBox txtOther;
+ private System.Windows.Forms.CheckBox chkOther;
+ private System.Windows.Forms.CheckBox chkSpace;
+ private System.Windows.Forms.CheckBox chkTab;
+ private System.Windows.Forms.CheckBox chkSemicolon;
+ private System.Windows.Forms.CheckBox chkComma;
+ private System.Windows.Forms.ComboBox cboTextQualifier;
+ private System.Windows.Forms.Label label1;
+ private System.ComponentModel.BackgroundWorker backgroundWorker1;
+ private System.Windows.Forms.CheckBox chkFirstRow;
+ private System.Windows.Forms.Label label2;
+ private System.Windows.Forms.TextBox txtName;
+ private System.Windows.Forms.Panel pnlTableWarning;
+ private System.Windows.Forms.PictureBox pictureBox1;
+ private System.Windows.Forms.Label label3;
+ private System.Windows.Forms.ListBox lstColumns;
+ private System.Windows.Forms.Label label4;
+ private System.Windows.Forms.PropertyGrid propColumns;
+ private System.Windows.Forms.Panel panel1;
+ }
+}
\ No newline at end of file
Added: trunk/Tools/DatabaseEditor/frmImportTable.cs
===================================================================
--- trunk/Tools/DatabaseEditor/frmImportTable.cs (rev 0)
+++ trunk/Tools/DatabaseEditor/frmImportTable.cs 2010-01-30 08:33:58 UTC (rev 1203)
@@ -0,0 +1,426 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Windows.Forms;
+using AgateLib.Data;
+
+namespace DatabaseEditor
+{
+ public partial class frmImportTable : Form
+ {
+ string fileContents;
+
+ public frmImportTable()
+ {
+ InitializeComponent();
+
+ UpdateDelimiters();
+ textQualifier = cboTextQualifier.Text;
+ }
+
+ public AgateDatabase Database { get; set; }
+ char[] Delimiters;
+ string textQualifier;
+ bool firstRowFieldNames = true;
+ AgateTable importedTable;
+
+ private void frmImportData_Load(object sender, EventArgs e)
+ {
+ if (openFile.ShowDialog() == DialogResult.Cancel)
+ {
+ Close();
+ return;
+ }
+
+ fileContents = System.IO.File.ReadAllText(openFile.FileName);
+
+ txtName.Text = System.IO.Path.GetFileNameWithoutExtension(openFile.FileName);
+ txtFileContents.Text = fileContents;
+
+ RedoImport();
+ }
+
+ private void DelimiterCheck_CheckedChanged(object sender, EventArgs e)
+ {
+ UpdateDelimiters();
+ RedoImport();
+ }
+
+ private void UpdateDelimiters()
+ {
+ List<char> delim = new List<char>();
+
+ if (chkComma.Checked) delim.Add(',');
+ if (chkSemicolon.Checked) delim.Add(';');
+ if (chkSpace.Checked) delim.Add(' ');
+ if (chkTab.Checked) delim.Add('\t');
+ if (chkOther.Checked && txtOther.Text.Length > 0)
+ delim.Add(txtOther.Text[0]);
+
+ Delimiters = delim.ToArray();
+ }
+
+ private void comboBox1_TextChanged(object sender, EventArgs e)
+ {
+ if (cboTextQualifier.Text != "{none}")
+ {
+ textQualifier = cboTextQualifier.Text;
+ }
+ else
+ textQualifier = null;
+
+ RedoImport();
+ }
+
+ private void chkFirstRow_CheckedChanged(object sender, EventArgs e)
+ {
+ firstRowFieldNames = chkFirstRow.Checked;
+
+ RedoImport();
+ }
+ private void RedoImport()
+ {
+ btnOK.Enabled = false;
+ lstColumns.Enabled = false;
+ propColumns.Enabled = false;
+ lstColumns.Items.Clear();
+
+ if (backgroundWorker1.IsBusy)
+ backgroundWorker1.CancelAsync();
+
+ backgroundWorker1.RunWorkerAsync();
+ }
+
+ private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
+ {
+ importedTable = null;
+
+ string[] lines = fileContents.Split('\n');
+ for (int i = 0; i < lines.Length; i++)
+ {
+ if (lines[i].EndsWith("\r"))
+ {
+ lines[i] = lines[i].Substring(0, lines[i].Length - 1);
+ }
+ }
+
+ List<AgateColumn> cols = new List<AgateColumn>();
+ DetectColumnTypes(lines, cols);
+
+ if (firstRowFieldNames)
+ SetColumnNames(lines[0], cols);
+ else
+ SetDefaultColumnNames(cols);
+
+
+
+ AgateTable tbl = ImportTable(lines, cols);
+
+ importedTable = tbl;
+ }
+
+ private void backgroundWorker1_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
+ {
+ lstColumns.Items.AddRange(importedTable.Columns.ToArray());
+ lstColumns.Enabled = true;
+ propColumns.Enabled = true;
+
+ if (importedTable == null)
+ return;
+
+ if (string.IsNullOrEmpty(txtName.Text))
+ return;
+
+ if (Database.Tables.ContainsTable(txtName.Text))
+ return;
+
+ btnOK.Enabled = true;
+ }
+
+ private void txtName_TextChanged(object sender, EventArgs e)
+ {
+ if (Database.Tables.ContainsTable(txtName.Text))
+ pnlTableWarning.Visible = true;
+ else
+ pnlTableWarning.Visible = false;
+
+ }
+
+ private void SetDefaultColumnNames(List<AgateColumn> cols)
+ {
+ for (int i = 0; i < cols.Count; i++)
+ {
+ cols[i].Name = "Column" + (i + 1).ToString();
+ }
+ }
+
+ private AgateTable ImportTable(string[] lines, List<AgateColumn> cols)
+ {
+ AgateTable retval = new AgateTable();
+
+ foreach (var col in cols)
+ {
+ retval.AddColumn(col);
+ }
+
+ int start = 0;
+
+ if (firstRowFieldNames)
+ start = 1;
+
+ for (int i = start; i < lines.Length; i++)
+ {
+ bool boolTrial;
+ int intTrial;
+ double doubleTrial;
+ decimal decimalTrial;
+ DateTime dateTrial;
+
+ if (lines[i].Trim().Length == 0)
+ continue;
+
+ string[] text = SplitLine(lines[i]);
+
+ AgateRow r = new AgateRow(retval);
+
+ for (int k = 0; k < text.Length; k++)
+ {
+ if (cols[k].FieldType == FieldType.Boolean)
+ {
+ if (text[k] == "0" || text[k] == "1")
+ {
+ r[cols[k]] = text[k] == "1" ? "true" : "false";
+ continue;
+ }
+ }
+
+ string value = StripTextQualifier(text[k]);
+
+ if (string.IsNullOrEmpty(value))
+ value = cols[k].DefaultValue;
+
+ r[cols[k]] = value;
+ }
+
+ retval.Rows.Add(r);
+ }
+
+ return retval;
+ }
+
+ private void SetColumnNames(string line, List<AgateColumn> cols)
+ {
+ string[] text = SplitLine(line);
+
+ for (int i = 0; i < text.Length; i++)
+ {
+ if (i < cols.Count)
+ {
+ try
+ {
+ cols[i].Name = StripTextQualifier(text[i]);
+ }
+ catch
+ {
+ cols[i].Name = "Column" + (i + 1).ToString();
+ }
+ }
+ else
+ {
+ cols.Add(new AgateColumn { Name = StripTextQualifier(text[i]) });
+ }
+ }
+ }
+
+ private string StripTextQualifier(string p)
+ {
+ if (textQualifier == null)
+ return p;
+
+ if (p.StartsWith(textQualifier) && p.EndsWith(textQualifier))
+ {
+ return p.Substring(textQualifier.Length, p.Length - textQualifier.Length * 2);
+ }
+ else if (p.StartsWith(textQualifier))
+ {
+ return p.Substring(textQualifier.Length);
+ }
+
+ return p;
+ }
+
+ private void DetectColumnTypes(string[] lines, List<AgateColumn> cols)
+ {
+ int start = 0;
+
+ if (firstRowFieldNames)
+ start = 1;
+
+ for (int i = start; i < lines.Length; i++)
+ {
+ int intTrial;
+ double doubleTrial;
+ decimal decimalTrial;
+ DateTime dateTrial;
+
+ if (lines[i].Trim().Length == 0)
+ continue;
+
+ string[] text = SplitLine(lines[i]);
+
+ for (int j = 0; j < text.Length; j++)
+ {
+ if (text[j] == "")
+ continue;
+
+ if (j < cols.Count && cols[j].FieldType == FieldType.String)
+ continue;
+
+ if (IsBoolCompatible(text[j]))
+ {
+ ColumnType(FieldType.Boolean, cols, j);
+ }
+ else if (int.TryParse(text[j], out intTrial))
+ {
+ ColumnType(FieldType.Int32, cols, j);
+ }
+ else if (double.TryParse(text[j], out doubleTrial))
+ {
+ ColumnType(FieldType.Double, cols, j);
+ }
+ else if (decimal.TryParse(text[j], out decimalTrial))
+ {
+ ColumnType(FieldType.Decimal, cols, j);
+ }
+ else if (DateTime.TryParse(text[j], out dateTrial))
+ {
+ ColumnType(FieldType.DateTime, cols, j);
+ }
+ else
+ {
+ ColumnType(FieldType.String, cols, j);
+ }
+ }
+ }
+ }
+
+ private static bool IsBoolCompatible(string text)
+ {
+ if (text == "0" || text == "1")
+ return true;
+
+ bool trial;
+ return bool.TryParse(text, out trial);
+
+ }
+
+ private void ColumnType(FieldType fieldType, List<AgateColumn> cols, int j)
+ {
+ if (j < cols.Count)
+ {
+ if (cols[j].FieldType == fieldType)
+ return;
+
+ // check to see if the data type can be promoted to what type is already in the field
+ if (CanPromoteFieldType(fieldType, cols[j].FieldType))
+ return;
+
+ // check to see if the field type can be promoted to the data type of the current data being imported.
+ if (CanPromoteFieldType(cols[j].FieldType, fieldType))
+ {
+ cols[j].FieldType = fieldType;
+ }
+ else
+ {
+ cols[j].FieldType = FieldType.String;
+ }
+ }
+ else
+ {
+ AgateColumn newCol = new AgateColumn();
+
+ newCol.FieldType = fieldType;
+
+ cols.Add(newCol);
+ }
+ }
+
+ private bool CanPromoteFieldType(FieldType currentType, FieldType toType)
+ {
+ if (toType == FieldType.DateTime)
+ return false;
+
+ switch (currentType)
+ {
+ case FieldType.Boolean:
+ return true;
+
+ case FieldType.Int32:
+ switch (toType)
+ {
+ case FieldType.Double:
+ case FieldType.Decimal:
+ return true;
+ }
+
+ return false;
+
+ case FieldType.Double:
+ switch (toType)
+ {
+ case FieldType.Decimal:
+ return true;
+ }
+
+ return false;
+ }
+
+ return false;
+ }
+
+ private string[] SplitLine(string line)
+ {
+ List<string> retval = new List<string>();
+
+ bool inString = false;
+
+ int pos = 0;
+ int start = pos;
+ while (pos < line.Length)
+ {
+ if (Delimiters.Contains(line[pos]) && inString == false)
+ {
+ retval.Add(line.Substring(start, pos - start));
+
+ start = pos + 1;
+ }
+ else if (textQualifier != null && line.Substring(pos, textQualifier.Length) == textQualifier)
+ {
+ inString = !inString;
+ }
+
+ pos++;
+ }
+
+ retval.Add(line.Substring(start));
+
+ return retval.ToArray();
+ }
+
+ private void lstColumns_SelectedIndexChanged(object sender, EventArgs e)
+ {
+ propColumns.SelectedObject = lstColumns.SelectedItem;
+ }
+
+ private void btnOK_Click(object sender, EventArgs e)
+ {
+ importedTable.Name = txtName.Text;
+
+ Database.Tables.Add(importedTable);
+ }
+
+ }
+}
Added: trunk/Tools/DatabaseEditor/frmImportTable.resx
===================================================================
--- trunk/Tools/DatabaseEditor/frmImportTable.resx (rev 0)
+++ trunk/Tools/DatabaseEditor/frmImportTable.resx 2010-01-30 08:33:58 UTC (rev 1203)
@@ -0,0 +1,126 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+ <!--
+ Microsoft ResX Schema
+
+ Version 2.0
+
+ The primary goals of this format is to allow a simple XML format
+ that is mostly human readable. The generation and parsing of the
+ various data types are done through the TypeConverter classes
+ associated with the data types.
+
+ Example:
+
+ ... ado.net/XML headers & schema ...
+ <resheader name="resmimetype">text/microsoft-resx</resheader>
+ <resheader name="version">2.0</resheader>
+ <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+ <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+ <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+ <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+ <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+ <value>[base64 mime encoded serialized .NET Framework object]</value>
+ </data>
+ <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+ <comment>This is a comment</comment>
+ </data>
+
+ There are any number of "resheader" rows that contain simple
+ name/value pairs.
+
+ Each data row contains a name, and value. The row also contains a
+ type or mimetype. Type corresponds to a .NET class that support
+ text/value conversion through the TypeConverter architecture.
+ Classes that don't support this are serialized and stored with the
+ mimetype set.
+
+ The mimetype is used for serialized objects, and tells the
+ ResXResourceReader how to depersist the object. This is currently not
+ extensible. For a given mimetype the value must be set accordingly:
+
+ Note - application/x-microsoft.net.object.binary.base64 is the format
+ that the ResXResourceWriter will generate, however the reader can
+ read any of the formats listed below.
+
+ mimetype: application/x-microsoft.net.object.binary.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.soap.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.bytearray.base64
+ value : The object must be serialized into a byte array
+ : using a System.ComponentModel.TypeConverter
+ : and then encoded with base64 encoding.
+ -->
+ <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+ <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
+ <xsd:element name="root" msdata:IsDataSet="true">
+ <xsd:complexType>
+ <xsd:choice maxOccurs="unbounded">
+ <xsd:element name="metadata">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" />
+ </xsd:sequence>
+ <xsd:attribute name="name" use="required" type="xsd:string" />
+ <xsd:attribute name="type" type="xsd:string" />
+ <xsd:attribute name="mimetype" type="xsd:string" />
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="assembly">
+ <xsd:complexType>
+ <xsd:attribute name="alias" type="xsd:string" />
+ <xsd:attribute name="name" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="data">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
+ <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+ <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="resheader">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" />
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:choice>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:schema>
+ <resheader name="resmimetype">
+ <value>text/microsoft-resx</value>
+ </resheader>
+ <resheader name="version">
+ <value>2.0</value>
+ </resheader>
+ <resheader name="reader">
+ <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <resheader name="writer">
+ <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <metadata name="openFile.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+ <value>17, 17</value>
+ </metadata>
+ <metadata name="backgroundWorker1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+ <value>115, 17</value>
+ </metadata>
+</root>
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2010-01-30 08:32:46
|
Revision: 1202
http://agate.svn.sourceforge.net/agate/?rev=1202&view=rev
Author: kanato
Date: 2010-01-30 08:32:40 +0000 (Sat, 30 Jan 2010)
Log Message:
-----------
Remove unnecessary TestData class.
Modified Paths:
--------------
trunk/Tools/DatabaseEditor/DatabaseEditor.csproj
trunk/Tools/DatabaseEditor/Program.cs
Removed Paths:
-------------
trunk/Tools/DatabaseEditor/TestData.cs
Modified: trunk/Tools/DatabaseEditor/DatabaseEditor.csproj
===================================================================
--- trunk/Tools/DatabaseEditor/DatabaseEditor.csproj 2010-01-30 08:27:12 UTC (rev 1201)
+++ trunk/Tools/DatabaseEditor/DatabaseEditor.csproj 2010-01-30 08:32:40 UTC (rev 1202)
@@ -132,7 +132,6 @@
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
- <Compile Include="TestData.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\AgateLib\AgateLib.csproj">
Modified: trunk/Tools/DatabaseEditor/Program.cs
===================================================================
--- trunk/Tools/DatabaseEditor/Program.cs 2010-01-30 08:27:12 UTC (rev 1201)
+++ trunk/Tools/DatabaseEditor/Program.cs 2010-01-30 08:32:40 UTC (rev 1202)
@@ -13,9 +13,6 @@
[STAThread]
static void Main()
{
- TestData r = new TestData();
- r.Run();
-
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new frmEditor());
Deleted: trunk/Tools/DatabaseEditor/TestData.cs
===================================================================
--- trunk/Tools/DatabaseEditor/TestData.cs 2010-01-30 08:27:12 UTC (rev 1201)
+++ trunk/Tools/DatabaseEditor/TestData.cs 2010-01-30 08:32:40 UTC (rev 1202)
@@ -1,61 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using AgateLib.Data;
-
-namespace DatabaseEditor
-{
- class TestData
- {
- public void Run()
- {
- try
- {
- AgateDatabase dbase1 = AgateDatabase.FromFile("test.zip");
- dbase1.LoadAllTables();
- dbase1.Dispose();
- }
- catch (System.IO.FileNotFoundException)
- { }
-
- Table tbl = new Table();
- tbl.Name = "TestTable";
-
- for (int i = 0; i < 10; i++)
- {
- Column c = new Column { Name = "Column" + i };
- tbl.AddColumn(c);
-
- if (i == 0)
- {
- c.IsPrimaryKey = true;
- c.FieldType = FieldType.AutoNumber;
- }
- }
-
- for (int j = 0; j < 10; j++)
- {
- Row row = new Row(tbl);
-
- for (int i = 0; i < 10; i++)
- {
- if (tbl.Columns[i].FieldType == FieldType.AutoNumber)
- continue;
-
- row[tbl.Columns[i]] = (j * 100 + i).ToString();
- }
-
- tbl.Rows.Add(row);
- }
-
- AgateDatabase dbase = new AgateDatabase();
- dbase.Tables.Add(tbl);
-
- AgateDataLib.DatabaseWriter writer = new AgateDataLib.DatabaseWriter();
-
- writer.Database = dbase;
- writer.WriteData("test.zip");
- }
- }
-}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2010-01-30 08:27:19
|
Revision: 1201
http://agate.svn.sourceforge.net/agate/?rev=1201&view=rev
Author: kanato
Date: 2010-01-30 08:27:12 +0000 (Sat, 30 Jan 2010)
Log Message:
-----------
Rename types to have Agate prefix.
Modified Paths:
--------------
trunk/AgateLib/Data/AgateDatabase.cs
Added Paths:
-----------
trunk/AgateLib/Data/AgateColumn.cs
trunk/AgateLib/Data/AgateColumnDictionary.cs
trunk/AgateLib/Data/AgateDataHelper.cs
trunk/AgateLib/Data/AgateRow.cs
trunk/AgateLib/Data/AgateRowList.cs
trunk/AgateLib/Data/AgateTable.cs
trunk/AgateLib/Data/AgateTableDictionary.cs
Removed Paths:
-------------
trunk/AgateLib/Data/Column.cs
trunk/AgateLib/Data/ColumnDictionary.cs
trunk/AgateLib/Data/DataHelper.cs
trunk/AgateLib/Data/Row.cs
trunk/AgateLib/Data/RowList.cs
trunk/AgateLib/Data/Table.cs
trunk/AgateLib/Data/TableDictionary.cs
Copied: trunk/AgateLib/Data/AgateColumn.cs (from rev 1200, trunk/AgateLib/Data/Column.cs)
===================================================================
--- trunk/AgateLib/Data/AgateColumn.cs (rev 0)
+++ trunk/AgateLib/Data/AgateColumn.cs 2010-01-30 08:27:12 UTC (rev 1201)
@@ -0,0 +1,156 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using AgateLib.Serialization.Xle;
+using System.ComponentModel;
+
+namespace AgateLib.Data
+{
+ public class AgateColumn : IXleSerializable
+ {
+ private string name;
+ private string description;
+ private string tableLookup;
+ private string lookupField;
+ private bool primaryKey;
+ private int nextAutoIncrementValue = 1;
+ private FieldType fieldType;
+
+ public AgateColumn Clone()
+ {
+ AgateColumn retval = new AgateColumn();
+
+ retval.name = name;
+ retval.description = description;
+ retval.tableLookup = tableLookup;
+ retval.lookupField = lookupField;
+ retval.primaryKey = primaryKey;
+ retval.nextAutoIncrementValue = nextAutoIncrementValue;
+ retval.fieldType = fieldType;
+
+ return retval;
+ }
+
+ #region IXleSerializable Members
+
+ void IXleSerializable.WriteData(XleSerializationInfo info)
+ {
+ info.Write("Name", name, true);
+ info.WriteEnum("FieldType", fieldType, true);
+
+ if (fieldType == FieldType.AutoNumber)
+ info.Write("NextValue", nextAutoIncrementValue, true);
+ if (primaryKey)
+ info.Write("PrimaryKey", primaryKey, true);
+
+ info.Write("Description", description);
+
+ if (string.IsNullOrEmpty(tableLookup) == false)
+ {
+ info.Write("TableLookup", tableLookup);
+ info.Write("LookupField", lookupField);
+ }
+ }
+
+ void IXleSerializable.ReadData(XleSerializationInfo info)
+ {
+ name = info.ReadString("Name");
+ fieldType = info.ReadEnum<FieldType>("FieldType");
+ nextAutoIncrementValue = info.ReadInt32("NextValue", 1);
+ primaryKey = info.ReadBoolean("PrimaryKey", false);
+ description = info.ReadString("Description");
+ tableLookup = info.ReadString("TableLookup", string.Empty);
+ lookupField = info.ReadString("LookupField", string.Empty);
+ }
+
+ #endregion
+
+ [Browsable(false)]
+ public int NextAutoIncrementValue
+ {
+ get { return nextAutoIncrementValue; }
+ }
+
+ public string DefaultValue
+ {
+ get
+ {
+ if (FieldType == FieldType.String)
+ return string.Empty;
+
+ return Activator.CreateInstance(FieldTypeDataType).ToString();
+ }
+ }
+
+ internal void IncrementNextAutoIncrementValue()
+ {
+ nextAutoIncrementValue++;
+ }
+
+ public string Name
+ {
+ get { return name; }
+ set
+ {
+ AssertIsValidName(value);
+
+ name = value;
+ }
+ }
+ public FieldType FieldType
+ {
+ get { return fieldType; }
+ set { fieldType = value; }
+ }
+ [Browsable(false)]
+ public Type FieldTypeDataType
+ {
+ get
+ {
+ return AgateDataHelper.FromFieldType(FieldType);
+ }
+ }
+ public bool IsPrimaryKey
+ {
+ get { return primaryKey; }
+ set { primaryKey = value; }
+ }
+ public string TableLookup
+ {
+ get { return tableLookup; }
+ set { tableLookup = value; }
+ }
+ public string TableDisplayField
+ {
+ get { return lookupField; }
+ set { lookupField = value; }
+ }
+ public string Description
+ {
+ get { return description; }
+ set { description = value; }
+ }
+
+ public override string ToString()
+ {
+ return "Column: " + Name;
+ }
+
+ private void AssertIsValidName(string value)
+ {
+ if (IsValidColumnName(value))
+ return;
+
+ throw new ArgumentException(string.Format(
+ "Invalid name \"{0}\" supplied. Column name should be a valid C# or VB identifier.", value));
+ }
+
+ public static bool IsValidColumnName(string value)
+ {
+ return AgateDataHelper.IsValidIdentifier(value);
+ }
+
+
+ }
+}
Copied: trunk/AgateLib/Data/AgateColumnDictionary.cs (from rev 1192, trunk/AgateLib/Data/ColumnDictionary.cs)
===================================================================
--- trunk/AgateLib/Data/AgateColumnDictionary.cs (rev 0)
+++ trunk/AgateLib/Data/AgateColumnDictionary.cs 2010-01-30 08:27:12 UTC (rev 1201)
@@ -0,0 +1,94 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using AgateLib.Serialization.Xle;
+
+namespace AgateLib.Data
+{
+ public class AgateColumnDictionary : IEnumerable<AgateColumn>
+ {
+ AgateTable mParentTable;
+ List<AgateColumn> mColumns = new List<AgateColumn>();
+
+ private AgateColumnDictionary() { }
+ internal AgateColumnDictionary(AgateTable parentTable)
+ {
+ mParentTable = parentTable;
+ }
+ internal AgateColumnDictionary(AgateTable parentTable, List<AgateColumn> columns)
+ {
+ mParentTable = parentTable;
+ mColumns = columns;
+ }
+ internal AgateTable ParentTable
+ {
+ get { return mParentTable; }
+ set { mParentTable = value; }
+ }
+
+ public AgateColumn this[string name]
+ {
+ get
+ {
+ var result = mColumns.First(x => x.Name == name);
+
+ if (result == null)
+ throw new ArgumentException("Column does not exist.");
+
+ return result;
+ }
+ }
+ public AgateColumn this[int index]
+ {
+ get { return mColumns[index]; }
+ internal set
+ {
+ mColumns[index] = value;
+ }
+ }
+
+ internal void Add(AgateColumn col)
+ {
+ if (mColumns.Any(x => x.Name == col.Name))
+ throw new ArgumentException("Column " + col.Name + " already exists.");
+
+ mColumns.Add(col);
+ }
+
+ public override string ToString()
+ {
+ return "Columns: " + mColumns.Count;
+ }
+
+ internal List<AgateColumn> ColumnList
+ {
+ get { return mColumns; }
+ }
+
+ public int Count
+ {
+ get { return mColumns.Count; }
+ }
+
+ #region IEnumerable<AgateColumn> Members
+
+ public IEnumerator<AgateColumn> GetEnumerator()
+ {
+ return mColumns.GetEnumerator();
+ }
+
+ #endregion
+
+ #region IEnumerable Members
+
+ System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
+ {
+ return GetEnumerator();
+ }
+
+ #endregion
+
+
+ }
+}
Copied: trunk/AgateLib/Data/AgateDataHelper.cs (from rev 1200, trunk/AgateLib/Data/DataHelper.cs)
===================================================================
--- trunk/AgateLib/Data/AgateDataHelper.cs (rev 0)
+++ trunk/AgateLib/Data/AgateDataHelper.cs 2010-01-30 08:27:12 UTC (rev 1201)
@@ -0,0 +1,128 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Reflection;
+using System.Text;
+using System.Text.RegularExpressions;
+
+namespace AgateLib.Data
+{
+ static class AgateDataHelper
+ {
+ public static string FixString(string value)
+ {
+ if (value == null)
+ return null;
+
+ // replace single quotes with double quotes.
+ value = value.Replace("\"", "\"\"");
+
+ if (value.Contains(" ") || value.Contains(",") || value.Contains("\""))
+ {
+ value = "\"" + value + "\"";
+ }
+
+ return value;
+ }
+
+ public static string UnfixString(string value)
+ {
+ if (value == null)
+ return null;
+
+ // replace double quotes with single
+ value = value.Replace("\"\"", "\"");
+
+ if (value.StartsWith("\"") && value.EndsWith("\""))
+ {
+ value = value.Substring(1, value.Length - 2);
+ }
+
+ return value;
+ }
+
+ internal static Type FromFieldType(FieldType fieldType)
+ {
+ DataTypeAttribute[] dataType = (DataTypeAttribute[])
+ typeof(FieldType).GetField(fieldType.ToString()).GetCustomAttributes(typeof(DataTypeAttribute), false);
+
+ return dataType[0].DataType;
+ }
+
+ static Regex identifier = new Regex(@"[a-zA-Z_][a-zA-Z_0-9]*");
+
+ internal static bool IsValidIdentifier(string value)
+ {
+ var match = identifier.Match(value);
+
+ if (match == null || match.Success == false)
+ return false;
+
+ if (match.Index == 0 && match.Length == value.Length)
+ return true;
+
+ return false;
+ }
+
+ internal static string LineType(string line)
+ {
+ int colon = line.IndexOf(":");
+
+ return line.Substring(0, colon);
+ }
+
+ internal static string LineData(string line)
+ {
+ int colon = line.IndexOf(":");
+
+ return line.Substring(colon + 1);
+ }
+
+ internal static string[] Split(string p)
+ {
+ List<string> data = new List<string>();
+
+ int start = 0;
+ bool inQuotes = false;
+
+ for (int i = 0; i < p.Length; i++)
+ {
+ if (p[i] == '"')
+ {
+ inQuotes = !inQuotes;
+ }
+
+ if (inQuotes == false && p[i] == ',')
+ {
+ string value = p.Substring(start, i - start);
+ data.Add(value);
+ start = i + 1;
+ }
+ }
+
+ data.Add(p.Substring(start));
+
+ return data.ToArray();
+ }
+
+ internal static string CreatePrefixedLine(string p, params object[] values)
+ {
+ StringBuilder b = new StringBuilder();
+
+ b.AppendFormat("{0}:", p);
+
+ for (int i = 0; i < values.Length; i++)
+ {
+ if (i > 0)
+ b.Append(",");
+
+ if (values[i] != null)
+ {
+ b.Append(values[i].ToString());
+ }
+ }
+
+ return b.ToString();
+ }
+ }
+}
Modified: trunk/AgateLib/Data/AgateDatabase.cs
===================================================================
--- trunk/AgateLib/Data/AgateDatabase.cs 2010-01-30 07:54:25 UTC (rev 1200)
+++ trunk/AgateLib/Data/AgateDatabase.cs 2010-01-30 08:27:12 UTC (rev 1201)
@@ -22,11 +22,11 @@
/// </remarks>
public class AgateDatabase : IDisposable , IXleSerializable
{
- private TableDictionary mTables;
+ private AgateTableDictionary mTables;
public AgateDatabase()
{
- mTables = new TableDictionary(this);
+ mTables = new AgateTableDictionary(this);
}
public static AgateDatabase FromFile(string filename)
{
@@ -113,7 +113,7 @@
/// <summary>
/// Gets the dictionary of tables in the database.
/// </summary>
- public TableDictionary Tables
+ public AgateTableDictionary Tables
{
get { return mTables; }
}
Copied: trunk/AgateLib/Data/AgateRow.cs (from rev 1200, trunk/AgateLib/Data/Row.cs)
===================================================================
--- trunk/AgateLib/Data/AgateRow.cs (rev 0)
+++ trunk/AgateLib/Data/AgateRow.cs 2010-01-30 08:27:12 UTC (rev 1201)
@@ -0,0 +1,154 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace AgateLib.Data
+{
+ public class AgateRow
+ {
+ Dictionary<string, string> values = new Dictionary<string, string>();
+ AgateTable parentTable;
+
+ public AgateRow(AgateTable parentTable)
+ {
+ this.parentTable = parentTable;
+
+ foreach (var column in parentTable.Columns)
+ {
+ values[column.Name] = null;
+ }
+ }
+
+ public AgateRow Clone()
+ {
+ AgateRow retval = new AgateRow(parentTable);
+
+ foreach (var value in values)
+ retval.values[value.Key] = value.Value;
+
+ return retval;
+ }
+ public AgateTable ParentTable
+ {
+ get { return parentTable; }
+ internal set
+ {
+ parentTable = value;
+
+ if (parentTable != null)
+ {
+ ValidateData(parentTable);
+ }
+ }
+ }
+
+ /// <summary>
+ /// Shortcut for this[column.Name].
+ /// </summary>
+ /// <param name="column"></param>
+ /// <returns></returns>
+ public string this[AgateColumn column]
+ {
+ get { return values[column.Name]; }
+ set
+ {
+ ValidateTypeOrThrow(column.Name, value);
+
+ if (column.FieldType == FieldType.AutoNumber)
+ throw new AgateDatabaseException("Cannot write to autonumber field.");
+
+ values[column.Name] = value;
+ }
+ }
+ public string this[string key]
+ {
+ get { return values[key]; }
+ set
+ {
+ this[parentTable.Columns[key]] = value;
+
+ values[key] = value;
+ }
+ }
+
+ internal void WriteWithoutValidation(AgateColumn column, string value)
+ {
+ values[column.Name] = value;
+ }
+
+ public override string ToString()
+ {
+ StringBuilder b = new StringBuilder();
+ int count = 0;
+
+ foreach (var column in parentTable.Columns)
+ {
+ string value = AgateDataHelper.FixString(this[column.Name]);
+
+ if (count > 0)
+ b.Append(",");
+
+ b.Append(value);
+
+ count++;
+ }
+
+ return b.ToString();
+ }
+
+ private void ValidateTypeOrThrow(string key, string value)
+ {
+ Convert.ChangeType(value, AgateDataHelper.FromFieldType(parentTable.Columns[key].FieldType));
+ }
+
+ internal void ValidateData(AgateTable agateTable)
+ {
+ foreach (var column in agateTable.Columns)
+ {
+ if (column.FieldType == FieldType.AutoNumber &&
+ (values.ContainsKey(column.Name) == false ||
+ values[column.Name] == null))
+ {
+ int value = column.NextAutoIncrementValue;
+ column.IncrementNextAutoIncrementValue();
+
+ values[column.Name] = value.ToString();
+ }
+
+ if (values.ContainsKey(column.Name))
+ {
+ ValidateTypeOrThrow(column.Name, values[column.Name]);
+ }
+ else
+ {
+ values.Add(column.Name, null);
+ }
+
+ if (column.IsPrimaryKey)
+ {
+ var matches = from x in agateTable.Rows
+ where x != null && x[column] == this[column]
+ select x;
+
+ List<AgateRow> l = matches.ToList();
+ l.Remove(this);
+
+ if (l.Count > 0)
+ {
+ throw new AgateDatabaseException("The primary key is alread present.");
+ }
+ }
+ }
+ }
+
+
+ internal void OnColumnNameChange(string oldName, string newName)
+ {
+ string value = values[oldName];
+ values[newName] = value;
+
+ values.Remove(oldName);
+ }
+ }
+}
Copied: trunk/AgateLib/Data/AgateRowList.cs (from rev 1192, trunk/AgateLib/Data/RowList.cs)
===================================================================
--- trunk/AgateLib/Data/AgateRowList.cs (rev 0)
+++ trunk/AgateLib/Data/AgateRowList.cs 2010-01-30 08:27:12 UTC (rev 1201)
@@ -0,0 +1,160 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using AgateLib.Serialization.Xle;
+
+namespace AgateLib.Data
+{
+ public class AgateRowList : IList<AgateRow>
+ {
+ AgateTable mParentTable;
+ List<AgateRow> mRows = new List<AgateRow>();
+
+ private AgateRowList() { }
+ internal AgateRowList(AgateTable parentTable)
+ {
+ mParentTable = parentTable;
+ }
+ internal AgateRowList(AgateTable parentTable, List<AgateRow> rows)
+ {
+ mParentTable = parentTable;
+ mRows = rows;
+ }
+
+ internal AgateTable ParentTable
+ {
+ get { return mParentTable; }
+ set { mParentTable = value; }
+ }
+
+
+ public void ForEach(Action<AgateRow> action)
+ {
+ mRows.ForEach(action);
+ }
+
+ public override string ToString()
+ {
+ return "Rows: " + mRows.Count;
+ }
+
+ #region IList<AgateRow> Members
+
+ public int IndexOf(AgateRow item)
+ {
+ return mRows.IndexOf(item);
+ }
+
+ public void Insert(int index, AgateRow item)
+ {
+ item.ValidateData(mParentTable);
+ item.ParentTable = mParentTable;
+
+ mRows.Insert(index, item);
+ }
+
+ public void RemoveAt(int index)
+ {
+ this[index].ParentTable = null;
+ mRows.RemoveAt(index);
+ }
+
+ public AgateRow this[int index]
+ {
+ get
+ {
+ return mRows[index];
+ }
+ set
+ {
+ AgateRow old = mRows[index];
+
+ try
+ {
+ mRows[index] = null;
+
+ value.ValidateData(mParentTable);
+ }
+ catch
+ {
+ mRows[index] = old;
+ throw;
+ }
+
+ mRows[index] = value;
+ }
+ }
+
+ #endregion
+
+ #region ICollection<AgateRow> Members
+
+ public void Add(AgateRow row)
+ {
+ row.ParentTable.Rows.Remove(row);
+ row.ParentTable = mParentTable;
+
+ mRows.Add(row);
+ }
+
+ public void Clear()
+ {
+ mRows.Clear();
+ }
+
+ public bool Contains(AgateRow item)
+ {
+ return mRows.Contains(item);
+ }
+
+ public void CopyTo(AgateRow[] array, int arrayIndex)
+ {
+ mRows.CopyTo(array, arrayIndex);
+ }
+
+ public int Count
+ {
+ get { return mRows.Count; }
+ }
+
+ public bool IsReadOnly
+ {
+ get { return false; }
+ }
+
+ public bool Remove(AgateRow item)
+ {
+ return mRows.Remove(item);
+ }
+
+ #endregion
+
+ #region IEnumerable<AgateRow> Members
+
+ public IEnumerator<AgateRow> GetEnumerator()
+ {
+ return mRows.GetEnumerator();
+ }
+
+ #endregion
+
+ #region IEnumerable Members
+
+ System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
+ {
+ return GetEnumerator();
+ }
+
+ #endregion
+
+
+ internal void OnColumnNameChange(string oldName, string newName)
+ {
+ foreach (var row in this)
+ {
+ row.OnColumnNameChange(oldName, newName);
+ }
+ }
+ }
+}
Copied: trunk/AgateLib/Data/AgateTable.cs (from rev 1192, trunk/AgateLib/Data/Table.cs)
===================================================================
--- trunk/AgateLib/Data/AgateTable.cs (rev 0)
+++ trunk/AgateLib/Data/AgateTable.cs 2010-01-30 08:27:12 UTC (rev 1201)
@@ -0,0 +1,218 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using AgateLib.Serialization.Xle;
+
+namespace AgateLib.Data
+{
+ public class AgateTable : IXleSerializable
+ {
+ string mName;
+ AgateRowList mRows;
+ AgateColumnDictionary mColumns;
+
+ #region --- Construction and Serialization ---
+
+ public AgateTable()
+ {
+ mColumns = new AgateColumnDictionary(this);
+ mRows = new AgateRowList(this);
+ }
+
+ internal static AgateTable FromStream(Stream stream)
+ {
+ XleSerializer ser = new XleSerializer(typeof(AgateTable));
+
+ return (AgateTable)ser.Deserialize(stream);
+ }
+
+ void IXleSerializable.WriteData(XleSerializationInfo info)
+ {
+ info.Write("Name", mName);
+ info.Write("Version", "0.4.0");
+ info.Write("Columns", mColumns.ColumnList);
+ info.Write("Rows", RowString());
+ }
+
+ void IXleSerializable.ReadData(XleSerializationInfo info)
+ {
+ mName = info.ReadString("Name");
+
+ string version = info.ReadString("Version");
+
+ if (version == "0.4.0")
+ {
+ mColumns = new AgateColumnDictionary(this, info.ReadList<AgateColumn>("Columns"));
+ mRows = new AgateRowList(this, ReadRows(info.ReadString("Rows")));
+ }
+ else
+ throw new AgateDatabaseException("Unsupported database version.");
+ }
+
+ private string RowString()
+ {
+ StringBuilder b = new StringBuilder();
+
+ mRows.ForEach(x => b.AppendLine(x.ToString()));
+
+ return b.ToString();
+ }
+
+ static readonly char[] lineSplitChars = new char[] { '\n', '\r' };
+
+ private List<AgateRow> ReadRows(string rows)
+ {
+ List<AgateRow> retval = new List<AgateRow>();
+
+ string[] lines = rows.Split(lineSplitChars, StringSplitOptions.RemoveEmptyEntries);
+
+ foreach (string line in lines)
+ {
+ string[] data = AgateDataHelper.Split(line);
+
+ AgateRow row = new AgateRow(this);
+
+ int i = 0;
+ foreach (var column in Columns)
+ {
+ row.WriteWithoutValidation(column, data[i]);
+ i++;
+ }
+
+ retval.Add(row);
+ }
+
+ return retval;
+ }
+
+ #endregion
+
+ public string Name
+ {
+ get { return mName; }
+ set
+ {
+ AssertIsValidName(value);
+
+ mName = value;
+ }
+ }
+
+ private void AssertIsValidName(string value)
+ {
+ if (IsValidTableName(value))
+ return;
+
+ throw new ArgumentException("Invalid name. Table name should be a valid C# or VB identifier.");
+ }
+
+ public static bool IsValidTableName(string value)
+ {
+ return AgateDataHelper.IsValidIdentifier(value);
+ }
+
+ public AgateColumnDictionary Columns
+ {
+ get { return mColumns; }
+ }
+ public AgateRowList Rows
+ {
+ get { return mRows; }
+ }
+
+ public void AddColumn(AgateColumn col)
+ {
+ mColumns.Add(col);
+
+ mRows.ForEach(x => x.ValidateData(this));
+ }
+
+ public override string ToString()
+ {
+ StringBuilder b = new StringBuilder();
+
+ b.Append("Name:");
+ b.AppendLine(Name);
+
+ foreach (var column in mColumns)
+ {
+ b.AppendLine(column.ToString());
+ }
+
+ b.AppendLine("Rows:");
+
+ foreach (var row in mRows)
+ {
+ b.AppendLine(row.ToString());
+ }
+
+ return b.ToString();
+ }
+
+ internal void Validate()
+ {
+ foreach (var row in mRows)
+ row.ValidateData(this);
+ }
+
+
+ private static void ReadRows(AgateTable table, StreamReader r)
+ {
+ while (r.EndOfStream == false)
+ {
+ string line = r.ReadLine();
+
+ string[] data = AgateDataHelper.Split(line);
+
+ AgateRow row = new AgateRow(table);
+
+ int i = 0;
+ foreach (var column in table.Columns)
+ {
+ row[column] = data[i];
+ i++;
+ }
+
+ table.Rows.Add(row);
+ }
+ }
+
+ public void RemoveColumn(int index)
+ {
+ throw new NotImplementedException();
+ }
+
+ public void OverwriteColumn(int index, AgateColumn newColumn)
+ {
+ AgateColumn old = Columns[index];
+
+ Columns[index] = newColumn;
+
+ if (old.Name != newColumn.Name)
+ {
+ Rows.OnColumnNameChange(old.Name, newColumn.Name);
+ }
+
+ if (old.FieldType != newColumn.FieldType)
+ {
+ try
+ {
+ Validate();
+ }
+ catch
+ {
+ // validation of the data failed, so
+ // undo the column change and rethrow.
+ Columns[index] = old;
+
+ Rows.OnColumnNameChange(newColumn.Name, old.Name);
+
+ throw;
+ }
+ }
+
+ }
+ }
+}
Copied: trunk/AgateLib/Data/AgateTableDictionary.cs (from rev 1200, trunk/AgateLib/Data/TableDictionary.cs)
===================================================================
--- trunk/AgateLib/Data/AgateTableDictionary.cs (rev 0)
+++ trunk/AgateLib/Data/AgateTableDictionary.cs 2010-01-30 08:27:12 UTC (rev 1201)
@@ -0,0 +1,156 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+
+namespace AgateLib.Data
+{
+ public class AgateTableDictionary : IEnumerable<AgateTable>, IDisposable
+ {
+ List<AgateTable> mTables = new List<AgateTable>();
+ AgateDatabase mParentDatabase;
+ List<string> mUnloadedTables = new List<string>();
+
+ internal AgateTableDictionary(AgateDatabase parentDatabase)
+ {
+ mParentDatabase = parentDatabase;
+ }
+
+ void IDisposable.Dispose()
+ {
+ DisposeFileHandle();
+ }
+
+
+ internal void DisposeFileHandle()
+ {
+ if (OwnFileProvider)
+ {
+ AgateLib.Utility.ZipFileProvider zip = FileProvider as AgateLib.Utility.ZipFileProvider;
+
+ if (zip != null)
+ {
+ zip.Dispose();
+ }
+ }
+ }
+
+ internal IFileProvider FileProvider { get; set; }
+ internal bool OwnFileProvider { get; set; }
+
+ public AgateTable this[string name]
+ {
+ get
+ {
+ bool loaded = false;
+
+ if (mUnloadedTables.Contains(name))
+ {
+ loaded = true;
+ LoadTable(name);
+ mUnloadedTables.Remove(name);
+ }
+
+ var result = mTables.First(x => x.Name == name);
+
+ if (result == null)
+ {
+ if (loaded)
+ throw new AgateException(
+ "BUG: Table was loaded but did not exist in database." +
+ "Probably, the table is corrupt, but an exception should have been thrown.");
+
+ throw new ArgumentException("Table does not exist.");
+ }
+
+ return result;
+ }
+ }
+ public AgateTable this[int index]
+ {
+ get { return mTables[index]; }
+ }
+
+ private void LoadTable(string name)
+ {
+ string filename = string.Format("data/{0}.txt", name);
+
+ using (Stream r = FileProvider.OpenRead(filename))
+ {
+ AgateTable tbl = AgateTable.FromStream(r);
+
+ mTables.Add(tbl);
+ }
+ }
+
+
+ internal void LoadAllTables()
+ {
+ foreach (var table in mUnloadedTables)
+ {
+ LoadTable(table);
+ }
+
+ mUnloadedTables.Clear();
+ }
+
+
+ public void Add(AgateTable tbl)
+ {
+ if (tbl == null)
+ throw new ArgumentNullException("tbl", "Passed table cannot be null.");
+
+ if (mTables.Any(x => x.Name == tbl.Name))
+ throw new ArgumentException("Table " + tbl.Name + " already exists.");
+
+ mTables.Add(tbl);
+ }
+
+ internal void AddUnloadedTable(string name)
+ {
+ mUnloadedTables.Add(name);
+ }
+ internal void AddUnloadedTable(IEnumerable<string> tables)
+ {
+ mUnloadedTables.AddRange(tables);
+ }
+ public override string ToString()
+ {
+ return "Tables: " + mTables.Count;
+ }
+
+ public bool ContainsTable(string name)
+ {
+ if (mUnloadedTables.Any(x => string.Compare(x, name, true) == 0))
+ return true;
+
+ if (mTables.Any(x => string.Compare(x.Name, name, true) == 0))
+ return true;
+
+ return false;
+ }
+
+ #region IEnumerable<Table> Members
+
+ public IEnumerator<AgateTable> GetEnumerator()
+ {
+ LoadAllTables();
+
+ return mTables.GetEnumerator();
+ }
+
+ #endregion
+
+ #region IEnumerable Members
+
+ System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
+ {
+ return GetEnumerator();
+ }
+
+ #endregion
+
+
+ }
+}
Deleted: trunk/AgateLib/Data/Column.cs
===================================================================
--- trunk/AgateLib/Data/Column.cs 2010-01-30 07:54:25 UTC (rev 1200)
+++ trunk/AgateLib/Data/Column.cs 2010-01-30 08:27:12 UTC (rev 1201)
@@ -1,156 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using AgateLib.Serialization.Xle;
-using System.ComponentModel;
-
-namespace AgateLib.Data
-{
- public class Column : IXleSerializable
- {
- private string name;
- private string description;
- private string tableLookup;
- private string lookupField;
- private bool primaryKey;
- private int nextAutoIncrementValue = 1;
- private FieldType fieldType;
-
- public Column Clone()
- {
- Column retval = new Column();
-
- retval.name = name;
- retval.description = description;
- retval.tableLookup = tableLookup;
- retval.lookupField = lookupField;
- retval.primaryKey = primaryKey;
- retval.nextAutoIncrementValue = nextAutoIncrementValue;
- retval.fieldType = fieldType;
-
- return retval;
- }
-
- #region IXleSerializable Members
-
- void IXleSerializable.WriteData(XleSerializationInfo info)
- {
- info.Write("Name", name, true);
- info.WriteEnum("FieldType", fieldType, true);
-
- if (fieldType == FieldType.AutoNumber)
- info.Write("NextValue", nextAutoIncrementValue, true);
- if (primaryKey)
- info.Write("PrimaryKey", primaryKey, true);
-
- info.Write("Description", description);
-
- if (string.IsNullOrEmpty(tableLookup) == false)
- {
- info.Write("TableLookup", tableLookup);
- info.Write("LookupField", lookupField);
- }
- }
-
- void IXleSerializable.ReadData(XleSerializationInfo info)
- {
- name = info.ReadString("Name");
- fieldType = info.ReadEnum<FieldType>("FieldType");
- nextAutoIncrementValue = info.ReadInt32("NextValue", 1);
- primaryKey = info.ReadBoolean("PrimaryKey", false);
- description = info.ReadString("Description");
- tableLookup = info.ReadString("TableLookup", string.Empty);
- lookupField = info.ReadString("LookupField", string.Empty);
- }
-
- #endregion
-
- [Browsable(false)]
- public int NextAutoIncrementValue
- {
- get { return nextAutoIncrementValue; }
- }
-
- public string DefaultValue
- {
- get
- {
- if (FieldType == FieldType.String)
- return string.Empty;
-
- return Activator.CreateInstance(FieldTypeDataType).ToString();
- }
- }
-
- internal void IncrementNextAutoIncrementValue()
- {
- nextAutoIncrementValue++;
- }
-
- public string Name
- {
- get { return name; }
- set
- {
- AssertIsValidName(value);
-
- name = value;
- }
- }
- public FieldType FieldType
- {
- get { return fieldType; }
- set { fieldType = value; }
- }
- [Browsable(false)]
- public Type FieldTypeDataType
- {
- get
- {
- return DataHelper.FromFieldType(FieldType);
- }
- }
- public bool IsPrimaryKey
- {
- get { return primaryKey; }
- set { primaryKey = value; }
- }
- public string TableLookup
- {
- get { return tableLookup; }
- set { tableLookup = value; }
- }
- public string TableDisplayField
- {
- get { return lookupField; }
- set { lookupField = value; }
- }
- public string Description
- {
- get { return description; }
- set { description = value; }
- }
-
- public override string ToString()
- {
- return "Column: " + Name;
- }
-
- private void AssertIsValidName(string value)
- {
- if (IsValidColumnName(value))
- return;
-
- throw new ArgumentException(string.Format(
- "Invalid name \"{0}\" supplied. Column name should be a valid C# or VB identifier.", value));
- }
-
- public static bool IsValidColumnName(string value)
- {
- return DataHelper.IsValidIdentifier(value);
- }
-
-
- }
-}
Deleted: trunk/AgateLib/Data/ColumnDictionary.cs
===================================================================
--- trunk/AgateLib/Data/ColumnDictionary.cs 2010-01-30 07:54:25 UTC (rev 1200)
+++ trunk/AgateLib/Data/ColumnDictionary.cs 2010-01-30 08:27:12 UTC (rev 1201)
@@ -1,94 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using AgateLib.Serialization.Xle;
-
-namespace AgateLib.Data
-{
- public class ColumnDictionary : IEnumerable<Column>
- {
- Table mParentTable;
- List<Column> mColumns = new List<Column>();
-
- private ColumnDictionary() { }
- internal ColumnDictionary(Table parentTable)
- {
- mParentTable = parentTable;
- }
- internal ColumnDictionary(Table parentTable, List<Column> columns)
- {
- mParentTable = parentTable;
- mColumns = columns;
- }
- internal Table ParentTable
- {
- get { return mParentTable; }
- set { mParentTable = value; }
- }
-
- public Column this[string name]
- {
- get
- {
- var result = mColumns.First(x => x.Name == name);
-
- if (result == null)
- throw new ArgumentException("Column does not exist.");
-
- return result;
- }
- }
- public Column this[int index]
- {
- get { return mColumns[index]; }
- internal set
- {
- mColumns[index] = value;
- }
- }
-
- internal void Add(Column col)
- {
- if (mColumns.Any(x => x.Name == col.Name))
- throw new ArgumentException("Column " + col.Name + " already exists.");
-
- mColumns.Add(col);
- }
-
- public override string ToString()
- {
- return "Columns: " + mColumns.Count;
- }
-
- internal List<Column> ColumnList
- {
- get { return mColumns; }
- }
-
- public int Count
- {
- get { return mColumns.Count; }
- }
-
- #region IEnumerable<AgateColumn> Members
-
- public IEnumerator<Column> GetEnumerator()
- {
- return mColumns.GetEnumerator();
- }
-
- #endregion
-
- #region IEnumerable Members
-
- System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
- {
- return GetEnumerator();
- }
-
- #endregion
-
-
- }
-}
Deleted: trunk/AgateLib/Data/DataHelper.cs
===================================================================
--- trunk/AgateLib/Data/DataHelper.cs 2010-01-30 07:54:25 UTC (rev 1200)
+++ trunk/AgateLib/Data/DataHelper.cs 2010-01-30 08:27:12 UTC (rev 1201)
@@ -1,128 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Reflection;
-using System.Text;
-using System.Text.RegularExpressions;
-
-namespace AgateLib.Data
-{
- static class DataHelper
- {
- public static string FixString(string value)
- {
- if (value == null)
- return null;
-
- // replace single quotes with double quotes.
- value = value.Replace("\"", "\"\"");
-
- if (value.Contains(" ") || value.Contains(",") || value.Contains("\""))
- {
- value = "\"" + value + "\"";
- }
-
- return value;
- }
-
- public static string UnfixString(string value)
- {
- if (value == null)
- return null;
-
- // replace double quotes with single
- value = value.Replace("\"\"", "\"");
-
- if (value.StartsWith("\"") && value.EndsWith("\""))
- {
- value = value.Substring(1, value.Length - 2);
- }
-
- return value;
- }
-
- internal static Type FromFieldType(FieldType fieldType)
- {
- DataTypeAttribute[] dataType = (DataTypeAttribute[])
- typeof(FieldType).GetField(fieldType.ToString()).GetCustomAttributes(typeof(DataTypeAttribute), false);
-
- return dataType[0].DataType;
- }
-
- static Regex identifier = new Regex(@"[a-zA-Z_][a-zA-Z_0-9]*");
-
- internal static bool IsValidIdentifier(string value)
- {
- var match = identifier.Match(value);
-
- if (match == null || match.Success == false)
- return false;
-
- if (match.Index == 0 && match.Length == value.Length)
- return true;
-
- return false;
- }
-
- internal static string LineType(string line)
- {
- int colon = line.IndexOf(":");
-
- return line.Substring(0, colon);
- }
-
- internal static string LineData(string line)
- {
- int colon = line.IndexOf(":");
-
- return line.Substring(colon + 1);
- }
-
- internal static string[] Split(string p)
- {
- List<string> data = new List<string>();
-
- int start = 0;
- bool inQuotes = false;
-
- for (int i = 0; i < p.Length; i++)
- {
- if (p[i] == '"')
- {
- inQuotes = !inQuotes;
- }
-
- if (inQuotes == false && p[i] == ',')
- {
- string value = p.Substring(start, i - start);
- data.Add(value);
- start = i + 1;
- }
- }
-
- data.Add(p.Substring(start));
-
- return data.ToArray();
- }
-
- internal static string CreatePrefixedLine(string p, params object[] values)
- {
- StringBuilder b = new StringBuilder();
-
- b.AppendFormat("{0}:", p);
-
- for (int i = 0; i < values.Length; i++)
- {
- if (i > 0)
- b.Append(",");
-
- if (values[i] != null)
- {
- b.Append(values[i].ToString());
- }
- }
-
- return b.ToString();
- }
- }
-}
Deleted: trunk/AgateLib/Data/Row.cs
===================================================================
--- trunk/AgateLib/Data/Row.cs 2010-01-30 07:54:25 UTC (rev 1200)
+++ trunk/AgateLib/Data/Row.cs 2010-01-30 08:27:12 UTC (rev 1201)
@@ -1,154 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-
-namespace AgateLib.Data
-{
- public class Row
- {
- Dictionary<string, string> values = new Dictionary<string, string>();
- Table parentTable;
-
- public Row(Table parentTable)
- {
- this.parentTable = parentTable;
-
- foreach (var column in parentTable.Columns)
- {
- values[column.Name] = null;
- }
- }
-
- public Row Clone()
- {
- Row retval = new Row(parentTable);
-
- foreach (var value in values)
- retval.values[value.Key] = value.Value;
-
- return retval;
- }
- public Table ParentTable
- {
- get { return parentTable; }
- internal set
- {
- parentTable = value;
-
- if (parentTable != null)
- {
- ValidateData(parentTable);
- }
- }
- }
-
- /// <summary>
- /// Shortcut for this[column.Name].
- /// </summary>
- /// <param name="column"></param>
- /// <returns></returns>
- public string this[Column column]
- {
- get { return values[column.Name]; }
- set
- {
- ValidateTypeOrThrow(column.Name, value);
-
- if (column.FieldType == FieldType.AutoNumber)
- throw new AgateDatabaseException("Cannot write to autonumber field.");
-
- values[column.Name] = value;
- }
- }
- public string this[string key]
- {
- get { return values[key]; }
- set
- {
- this[parentTable.Columns[key]] = value;
-
- values[key] = value;
- }
- }
-
- internal void WriteWithoutValidation(Column column, string value)
- {
- values[column.Name] = value;
- }
-
- public override string ToString()
- {
- StringBuilder b = new StringBuilder();
- int count = 0;
-
- foreach (var column in parentTable.Columns)
- {
- string value = DataHelper.FixString(this[column.Name]);
-
- if (count > 0)
- b.Append(",");
-
- b.Append(value);
-
- count++;
- }
-
- return b.ToString();
- }
-
- private void ValidateTypeOrThrow(string key, string value)
- {
- Convert.ChangeType(value, DataHelper.FromFieldType(parentTable.Columns[key].FieldType));
- }
-
- internal void ValidateData(Table agateTable)
- {
- foreach (var column in agateTable.Columns)
- {
- if (column.FieldType == FieldType.AutoNumber &&
- (values.ContainsKey(column.Name) == false ||
- values[column.Name] == null))
- {
- int value = column.NextAutoIncrementValue;
- column.IncrementNextAutoIncrementValue();
-
- values[column.Name] = value.ToString();
- }
-
- if (values.ContainsKey(column.Name))
- {
- ValidateTypeOrThrow(column.Name, values[column.Name]);
- }
- else
- {
- values.Add(column.Name, null);
- }
-
- if (column.IsPrimaryKey)
- {
- var matches = from x in agateTable.Rows
- where x != null && x[column] == this[column]
- select x;
-
- List<Row> l = matches.ToList();
- l.Remove(this);
-
- if (l.Count > 0)
- {
- throw new AgateDatabaseException("The primary key is alread present.");
- }
- }
- }
- }
-
-
- internal void OnColumnNameChange(string oldName, string newName)
- {
- string value = values[oldName];
- values[newName] = value;
-
- values.Remove(oldName);
- }
- }
-}
Deleted: trunk/AgateLib/Data/RowList.cs
===================================================================
--- trunk/AgateLib/Data/RowList.cs 2010-01-30 07:54:25 UTC (rev 1200)
+++ trunk/AgateLib/Data/RowList.cs 2010-01-30 08:27:12 UTC (rev 1201)
@@ -1,160 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using AgateLib.Serialization.Xle;
-
-namespace AgateLib.Data
-{
- public class RowList : IList<Row>
- {
- Table mParentTable;
- List<Row> mRows = new List<Row>();
-
- private RowList() { }
- internal RowList(Table parentTable)
- {
- mParentTable = parentTable;
- }
- internal RowList(Table parentTable, List<Row> rows)
- {
- mParentTable = parentTable;
- mRows = rows;
- }
-
- internal Table ParentTable
- {
- get { return mParentTable; }
- set { mParentTable = value; }
- }
-
-
- public void ForEach(Action<Row> action)
- {
- mRows.ForEach(action);
- }
-
- public override string ToString()
- {
- return "Rows: " + mRows.Count;
- }
-
- #region IList<AgateRow> Members
-
- public int IndexOf(Row item)
- {
- return mRows.IndexOf(item);
- }
-
- public void Insert(int index, Row item)
- {
- item.ValidateData(mParentTable);
- item.ParentTable = mParentTable;
-
- mRows.Insert(index, item);
- }
-
- public void RemoveAt(int index)
- {
- this[index].ParentTable = null;
- mRows.RemoveAt(index);
- }
-
- public Row this[int index]
- {
- get
- {
- return mRows[index];
- }
- set
- {
- Row old = mRows[index];
-
- try
- {
- mRows[index] = null;
-
- value.ValidateData(mParentTable);
- }
- catch
- {
- mRows[index] = old;
- throw;
- }
-
- mRows[index] = value;
- }
- }
-
- #endregion
-
- #region ICollection<AgateRow> Members
-
- public void Add(Row row)
- {
- row.ParentTable.Rows.Remove(row);
- row.ParentTable = mParentTable;
-
- mRows.Add(row);
- }
-
- public void Clear()
- {
- mRows.Clear();
- }
-
- public bool Contains(Row item)
- {
- return mRows.Contains(item);
- }
-
- public void CopyTo(Row[] array, int arrayIndex)
- {
- mRows.CopyTo(array, arrayIndex);
- }
-
- public int Count
- {
- get { return mRows.Count; }
- }
-
- public bool IsReadOnly
- {
- get { return false; }
- }
-
- public bool Remove(Row item)
- {
- return mRows.Remove(item);
- }
-
- #endregion
-
- #region IEnumerable<AgateRow> Members
-
- public IEnumerator<Row> GetEnumerator()
- {
- return mRows.GetEnumerator();
- }
-
- #endregion
-
- #region IEnumerable Members
-
- System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
- {
- return GetEnumerator();
- }
-
- #endregion
-
-
- internal void OnColumnNameChange(string oldName, string newName)
- {
- foreach (var row in this)
- {
- row.OnColumnNameChange(oldName, newName);
- }
- }
- }
-}
Deleted: trunk/AgateLib/Data/Table.cs
===================================================================
--- trunk/AgateLib/Data/Table.cs 2010-01-30 07:54:25 UTC (rev 1200)
+++ trunk/AgateLib/Data/Table.cs 2010-01-30 08:27:12 UTC (rev 1201)
@@ -1,218 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using System.Text;
-using AgateLib.Serialization.Xle;
-
-namespace AgateLib.Data
-{
- public class Table : IXleSerializable
- {
- string mName;
- RowList mRows;
- ColumnDictionary mColumns;
-
- #region --- Construction and Serialization ---
-
- public Table()
- {
- mColumns = new ColumnDictionary(this);
- mRows = new RowList(this);
- }
-
- internal static Table FromStream(Stream stream)
- {
- XleSerializer ser = new XleSerializer(typeof(Table));
-
- return (Table)ser.Deserialize(stream);
- }
-
- void IXleSerializable.WriteData(XleSerializationInfo info)
- {
- info.Write("Name", mName);
- info.Write("Version", "0.4.0");
- info.Write("Columns", mColumns.ColumnList);
- info.Write("Rows", RowString());
- }
-
- void IXleSerializable.ReadData(XleSerializationInfo info)
- {
- mName = info.ReadString("Name");
-
- string version = info.ReadString("Version");
-
- if (version == "0.4.0")
- {
- mColumns = new ColumnDictionary(this, info.ReadList<Column>("Columns"));
- mRows = new RowList(this, ReadRows(info.ReadString("Rows")));
- }
- else
- throw new AgateDatabaseException("Unsupported database version.");
- }
-
- private string RowString()
- {
- StringBuilder b = new StringBuilder();
-
- mRows.ForEach(x => b.AppendLine(x.ToString()));
-
- return b.ToString();
- }
-
- static readonly char[] lineSplitChars = new char[] { '\n', '\r' };
-
- private List<Row> ReadRows(string rows)
- {
- List<Row> retval = new List<Row>();
-
- string[] lines = rows.Split(lineSplitChars, StringSplitOptions.RemoveEmptyEntries);
-
- foreach (string line in lines)
- {
- string[] data = DataHelper.Split(line);
-
- Row row = new Row(this);
-
- int i = 0;
- foreach (var column in Columns)
- {
- row.WriteWithoutValidation(column, data[i]);
- i++;
- }
-
- retval.Add(row);
- }
-
- return retval;
- }
-
- #endregion
-
- public string Name
- {
- get { return mName; }
- set
- {
- AssertIsValidName(value);
-
- mName = value;
- }
- }
-
- private void AssertIsValidName(string value)
- {
- if (IsValidTableName(value))
- return;
-
- throw new ArgumentException("Invalid name. Table name should be a valid C# or VB identifier.");
- }
-
- public static bool IsValidTableName(string value)
- {
- return DataHelper.IsValidIdentifier(value);
- }
-
- public ColumnDictionary Columns
- {
- get { return mColumns; }
- }
- public RowList Rows
- {
- get { return mRows; }
- }
-
- public void AddColumn(Column col)
- {
- mColumns.Add(col);
-
- mRows.ForEach(x => x.ValidateData(this));
- }
-
- public override string ToString()
- {
- StringBuilder b = new StringBuilder();
-
- b.Append("Name:");
- b.AppendLine(Name);
-
- foreach (var column in mColumns)
- {
- b.AppendLine(column.ToString());
- }
-
- b.AppendLine("Rows:");
-
- foreach (var row in mRows)
- {
- b.AppendLine(row.ToString());
- }
-
- return b.ToString();
- }
-
- internal void Validate()
- {
- foreach (var row in mRows)
- row.ValidateData(this);
- }
-
-
- private static void ReadRows(Table table, StreamReader r)
- {
- while (r.EndOfStream == false)
- {
- string line = r.ReadLine();
-
- string[] data = DataHelper.Split(line);
-
- Row row = new Row(table);
-
- int i = 0;
- foreach (var column in table.Columns)
- {
- row[column] = data[i];
- i++;
- }
-
- table.Rows.Add(row);
- }
- }
-
- public void RemoveColumn(int index)
- {
- throw new NotImplementedException();
- }
-
- public void OverwriteColumn(int index, Column newColumn)
- {
- Column old = Columns[index];
-
- Columns[index] = newColumn;
-
- if (old.Name != newColumn.Name)
- {
- Rows.OnColumnNameChange(old.Name, newColumn.Name);
- }
-
- if (old.FieldType != newColumn.FieldType)
- {
- try
- {
- Validate();
- }
- catch
- {
- // validation of the data failed, so
- // undo the column change and rethrow.
- Columns[index] = old;
-
- Rows.OnColumnNameChange(newColumn.Name, old.Name);
-
- throw;
- }
- }
-
- }
- }
-}
Deleted: trunk/AgateLib/Data/TableDictionary.cs
===================================================================
--- trunk/AgateLib/Data/TableDictionary.cs 2010-01-30 07:54:25 UTC (rev 1200)
+++ trunk/AgateLib/Data/TableDictionary.cs 2010-01-30 08:27:12 UTC (rev 1201)
@@ -1,156 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using System.Text;
-
-namespace AgateLib.Data
-{
- public class TableDictionary : IEnumerable<Table>, IDisposable
- {
- List<Table> mTables = new List<Table>();
- AgateDatabase mParentDatabase;
- List<string> mUnloadedTables = new List<string>();
-
- internal TableDictionary(AgateDatabase parentDatabase)
- {
- mParentDatabase = parentDatabase;
- }
-
- void IDisposable.Dispose()
- {
- DisposeFileHandle();
- }
-
-
- internal void DisposeFileHandle()
- {
- if (OwnFileProvider)
- {
- AgateLib.Utility.ZipFileProvider zip = FileProvider as AgateLib.Utility.ZipFileProvider;
-
- if (zip != null)
- {
- zip.Dispose();
- }
- }
- }
-
- internal IFileProvider FileProvider { get; set; }
- internal bool OwnFileProvider { get; set; }
-
- public Table this[string name]
- {
- get
- {
- bool loaded = false;
-
- if (mUnloadedTables.Contains(name))
- {
- loaded = true;
- LoadTable(name);
- mUnloadedTables.Remove(name);
- }
-
- var result = mTables.First(x => x.Name == name);
-
- if (result == null)
- {
- if (loaded)
- throw new AgateException(
- "BUG: Table was loaded but did not exist in database." +
- "Probably, the table is corrupt, but an exception should have been thrown.");
-
- throw new ArgumentException("Table does not exist.");
- }
-
- return result;
- }
- }
- public Table this[int index]
- {
- get { return mTables[index]; }
- }
-
- private void LoadTable(string name)
- {
- string filename = string.Format("data/{0}.txt", name);
-
- using (Stream r = FileProvider.OpenRead(filename))
- {
- Table tbl = Table.FromStream(r);
-
- mTables.Add(tbl);
- }
- }
-
-
- internal void LoadAllTables()
- {
- foreach (var table in mUnloadedTables)
- {
- LoadTable(table);
- }
-
- mUnloadedTables.Clear();
- }
-
-
- public void Add(Table tbl)
- {
- if (tbl == null)
- throw new ArgumentNullException("tbl", "Passed table cannot be null.");
-
- if (mTables.Any(x => x.Name == tbl.Name))
- throw new ArgumentException("Table " + tbl.Name + " already exists.");
-
- mTables.Add(tbl);
- }
-
- internal void AddUnloadedTable(string name)
- {
- mUnloadedTables.Add(name);
- }
- internal void AddUnloadedTable(IEnumerable<string> tables)
- {
- mUnloadedTables.AddRange(tables);
- }
- public override string ToString()
- {
- return "Tables: " + mTables.Count;
- }
-
- public bool ContainsTable(string name)
- {
- if (mUnloadedTables.Any(x => string.Compare(x, name, true) == 0))
- return true;
-
- if (mTables.Any(x => string.Compare(x.Name, name, true) == 0))
- return true;
-
- return false;
- }
-
- #region IEnumerable<Table> Members
-
- public IEnumerator<Table> GetEnumerator()
- {
- LoadAllTables();
-
- return mTables.GetEnumerator();
- }
-
- #endregion
-
- #region IEnumerable Members
-
- System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
- {
- return GetEnumerator();
- }
-
- #endregion
-
-
- }
-}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2010-01-30 07:54:33
|
Revision: 1200
http://agate.svn.sourceforge.net/agate/?rev=1200&view=rev
Author: kanato
Date: 2010-01-30 07:54:25 +0000 (Sat, 30 Jan 2010)
Log Message:
-----------
Include database editor/code generator into repository.
Modified Paths:
--------------
trunk/AgateLib/Data/AgateDatabase.cs
trunk/AgateLib/Data/Column.cs
trunk/AgateLib/Data/DataHelper.cs
trunk/AgateLib/Data/Row.cs
trunk/AgateLib/Data/TableDictionary.cs
trunk/AgateTools.sln
Added Paths:
-----------
trunk/Tools/AgateDataLib/
trunk/Tools/AgateDataLib/AgateDataLib.csproj
trunk/Tools/AgateDataLib/DatabaseEditor.Designer.cs
trunk/Tools/AgateDataLib/DatabaseEditor.cs
trunk/Tools/AgateDataLib/DatabaseEditor.resx
trunk/Tools/AgateDataLib/DatabaseWriter.cs
trunk/Tools/AgateDataLib/Images/
trunk/Tools/AgateDataLib/Images/NewTable.png
trunk/Tools/AgateDataLib/Images/NewTableLarge.png
trunk/Tools/AgateDataLib/Images/TableHS.png
trunk/Tools/AgateDataLib/Images/TableHSLarge.png
trunk/Tools/AgateDataLib/Properties/
trunk/Tools/AgateDataLib/Properties/AssemblyInfo.cs
trunk/Tools/AgateDataLib/TableEditor.Designer.cs
trunk/Tools/AgateDataLib/TableEditor.cs
trunk/Tools/AgateDataLib/TableEditor.resx
trunk/Tools/AgateDataLib/frmDesignTable.Designer.cs
trunk/Tools/AgateDataLib/frmDesignTable.cs
trunk/Tools/AgateDataLib/frmDesignTable.resx
trunk/Tools/DatabaseEditor/
trunk/Tools/DatabaseEditor/DatabaseEditor.csproj
trunk/Tools/DatabaseEditor/Program.cs
trunk/Tools/DatabaseEditor/Properties/
trunk/Tools/DatabaseEditor/Properties/AssemblyInfo.cs
trunk/Tools/DatabaseEditor/Properties/Resources.Designer.cs
trunk/Tools/DatabaseEditor/Properties/Resources.resx
trunk/Tools/DatabaseEditor/Properties/Settings.Designer.cs
trunk/Tools/DatabaseEditor/Properties/Settings.settings
trunk/Tools/DatabaseEditor/TestData.cs
trunk/Tools/DatabaseEditor/frmCodeGenerator.Designer.cs
trunk/Tools/DatabaseEditor/frmCodeGenerator.cs
trunk/Tools/DatabaseEditor/frmCodeGenerator.resx
trunk/Tools/DatabaseEditor/frmEditor.Designer.cs
trunk/Tools/DatabaseEditor/frmEditor.cs
trunk/Tools/DatabaseEditor/frmEditor.resx
Modified: trunk/AgateLib/Data/AgateDatabase.cs
===================================================================
--- trunk/AgateLib/Data/AgateDatabase.cs 2010-01-28 22:15:12 UTC (rev 1199)
+++ trunk/AgateLib/Data/AgateDatabase.cs 2010-01-30 07:54:25 UTC (rev 1200)
@@ -66,10 +66,10 @@
void IXleSerializable.WriteData(XleSerializationInfo info)
{
info.Write("Version", "0.4.0");
+ info.Write("CodeNamespace", CodeNamespace);
info.Write("Tables", TableList.ToList());
}
-
void IXleSerializable.ReadData(XleSerializationInfo info)
{
string version = info.ReadString("Version");
@@ -78,6 +78,8 @@
{
List<string> tables = info.ReadList<string>("Tables");
mTables.AddUnloadedTable(tables);
+
+ CodeNamespace = info.ReadString("CodeNamespace", null);
}
else
throw new AgateDatabaseException("Unsupported database version.");
@@ -86,6 +88,8 @@
#endregion
+ public string CodeNamespace { get; set; }
+
private IEnumerable<string> TableList
{
get
Modified: trunk/AgateLib/Data/Column.cs
===================================================================
--- trunk/AgateLib/Data/Column.cs 2010-01-28 22:15:12 UTC (rev 1199)
+++ trunk/AgateLib/Data/Column.cs 2010-01-30 07:54:25 UTC (rev 1200)
@@ -3,6 +3,7 @@
using System.Linq;
using System.Text;
using AgateLib.Serialization.Xle;
+using System.ComponentModel;
namespace AgateLib.Data
{
@@ -16,7 +17,6 @@
private int nextAutoIncrementValue = 1;
private FieldType fieldType;
-
public Column Clone()
{
Column retval = new Column();
@@ -66,11 +66,23 @@
#endregion
+ [Browsable(false)]
public int NextAutoIncrementValue
{
get { return nextAutoIncrementValue; }
}
+ public string DefaultValue
+ {
+ get
+ {
+ if (FieldType == FieldType.String)
+ return string.Empty;
+
+ return Activator.CreateInstance(FieldTypeDataType).ToString();
+ }
+ }
+
internal void IncrementNextAutoIncrementValue()
{
nextAutoIncrementValue++;
@@ -91,6 +103,14 @@
get { return fieldType; }
set { fieldType = value; }
}
+ [Browsable(false)]
+ public Type FieldTypeDataType
+ {
+ get
+ {
+ return DataHelper.FromFieldType(FieldType);
+ }
+ }
public bool IsPrimaryKey
{
get { return primaryKey; }
Modified: trunk/AgateLib/Data/DataHelper.cs
===================================================================
--- trunk/AgateLib/Data/DataHelper.cs 2010-01-28 22:15:12 UTC (rev 1199)
+++ trunk/AgateLib/Data/DataHelper.cs 2010-01-30 07:54:25 UTC (rev 1200)
@@ -41,7 +41,7 @@
return value;
}
- internal static Type GetType(FieldType fieldType)
+ internal static Type FromFieldType(FieldType fieldType)
{
DataTypeAttribute[] dataType = (DataTypeAttribute[])
typeof(FieldType).GetField(fieldType.ToString()).GetCustomAttributes(typeof(DataTypeAttribute), false);
@@ -53,7 +53,15 @@
internal static bool IsValidIdentifier(string value)
{
- return identifier.IsMatch(value);
+ var match = identifier.Match(value);
+
+ if (match == null || match.Success == false)
+ return false;
+
+ if (match.Index == 0 && match.Length == value.Length)
+ return true;
+
+ return false;
}
internal static string LineType(string line)
Modified: trunk/AgateLib/Data/Row.cs
===================================================================
--- trunk/AgateLib/Data/Row.cs 2010-01-28 22:15:12 UTC (rev 1199)
+++ trunk/AgateLib/Data/Row.cs 2010-01-30 07:54:25 UTC (rev 1200)
@@ -99,7 +99,7 @@
private void ValidateTypeOrThrow(string key, string value)
{
- Convert.ChangeType(value, DataHelper.GetType(parentTable.Columns[key].FieldType));
+ Convert.ChangeType(value, DataHelper.FromFieldType(parentTable.Columns[key].FieldType));
}
internal void ValidateData(Table agateTable)
Modified: trunk/AgateLib/Data/TableDictionary.cs
===================================================================
--- trunk/AgateLib/Data/TableDictionary.cs 2010-01-28 22:15:12 UTC (rev 1199)
+++ trunk/AgateLib/Data/TableDictionary.cs 2010-01-30 07:54:25 UTC (rev 1200)
@@ -67,6 +67,10 @@
return result;
}
}
+ public Table this[int index]
+ {
+ get { return mTables[index]; }
+ }
private void LoadTable(string name)
{
@@ -91,13 +95,12 @@
mUnloadedTables.Clear();
}
- public Table this[int index]
- {
- get { return mTables[index]; }
- }
public void Add(Table tbl)
{
+ if (tbl == null)
+ throw new ArgumentNullException("tbl", "Passed table cannot be null.");
+
if (mTables.Any(x => x.Name == tbl.Name))
throw new ArgumentException("Table " + tbl.Name + " already exists.");
@@ -117,7 +120,17 @@
return "Tables: " + mTables.Count;
}
+ public bool ContainsTable(string name)
+ {
+ if (mUnloadedTables.Any(x => string.Compare(x, name, true) == 0))
+ return true;
+ if (mTables.Any(x => string.Compare(x.Name, name, true) == 0))
+ return true;
+
+ return false;
+ }
+
#region IEnumerable<Table> Members
public IEnumerator<Table> GetEnumerator()
Modified: trunk/AgateTools.sln
===================================================================
--- trunk/AgateTools.sln 2010-01-28 22:15:12 UTC (rev 1199)
+++ trunk/AgateTools.sln 2010-01-30 07:54:25 UTC (rev 1200)
@@ -21,6 +21,10 @@
TODO.txt = TODO.txt
EndProjectSection
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AgateDataLib", "Tools\AgateDataLib\AgateDataLib.csproj", "{2F7A686B-2272-4803-9EF9-0B34BA7802DC}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DatabaseEditor", "Tools\DatabaseEditor\DatabaseEditor.csproj", "{685E7B82-4609-4ABB-B25B-0DC7C58BD45F}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -115,6 +119,30 @@
{91F57346-B574-4D52-9EB0-AA191B552C94}.Release|x64.Build.0 = Release|x64
{91F57346-B574-4D52-9EB0-AA191B552C94}.Release|x86.ActiveCfg = Release|x86
{91F57346-B574-4D52-9EB0-AA191B552C94}.Release|x86.Build.0 = Release|x86
+ {2F7A686B-2272-4803-9EF9-0B34BA7802DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {2F7A686B-2272-4803-9EF9-0B34BA7802DC}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {2F7A686B-2272-4803-9EF9-0B34BA7802DC}.Debug|x64.ActiveCfg = Debug|x64
+ {2F7A686B-2272-4803-9EF9-0B34BA7802DC}.Debug|x64.Build.0 = Debug|x64
+ {2F7A686B-2272-4803-9EF9-0B34BA7802DC}.Debug|x86.ActiveCfg = Debug|x86
+ {2F7A686B-2272-4803-9EF9-0B34BA7802DC}.Debug|x86.Build.0 = Debug|x86
+ {2F7A686B-2272-4803-9EF9-0B34BA7802DC}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {2F7A686B-2272-4803-9EF9-0B34BA7802DC}.Release|Any CPU.Build.0 = Release|Any CPU
+ {2F7A686B-2272-4803-9EF9-0B34BA7802DC}.Release|x64.ActiveCfg = Release|x64
+ {2F7A686B-2272-4803-9EF9-0B34BA7802DC}.Release|x64.Build.0 = Release|x64
+ {2F7A686B-2272-4803-9EF9-0B34BA7802DC}.Release|x86.ActiveCfg = Release|x86
+ {2F7A686B-2272-4803-9EF9-0B34BA7802DC}.Release|x86.Build.0 = Release|x86
+ {685E7B82-4609-4ABB-B25B-0DC7C58BD45F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {685E7B82-4609-4ABB-B25B-0DC7C58BD45F}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {685E7B82-4609-4ABB-B25B-0DC7C58BD45F}.Debug|x64.ActiveCfg = Debug|x64
+ {685E7B82-4609-4ABB-B25B-0DC7C58BD45F}.Debug|x64.Build.0 = Debug|x64
+ {685E7B82-4609-4ABB-B25B-0DC7C58BD45F}.Debug|x86.ActiveCfg = Debug|x86
+ {685E7B82-4609-4ABB-B25B-0DC7C58BD45F}.Debug|x86.Build.0 = Debug|x86
+ {685E7B82-4609-4ABB-B25B-0DC7C58BD45F}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {685E7B82-4609-4ABB-B25B-0DC7C58BD45F}.Release|Any CPU.Build.0 = Release|Any CPU
+ {685E7B82-4609-4ABB-B25B-0DC7C58BD45F}.Release|x64.ActiveCfg = Release|x64
+ {685E7B82-4609-4ABB-B25B-0DC7C58BD45F}.Release|x64.Build.0 = Release|x64
+ {685E7B82-4609-4ABB-B25B-0DC7C58BD45F}.Release|x86.ActiveCfg = Release|x86
+ {685E7B82-4609-4ABB-B25B-0DC7C58BD45F}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Property changes on: trunk/Tools/AgateDataLib
___________________________________________________________________
Added: svn:ignore
+ [Bb]in
obj
[Dd]ebug
[Rr]elease
*.user
*.aps
*.eto
Added: trunk/Tools/AgateDataLib/AgateDataLib.csproj
===================================================================
--- trunk/Tools/AgateDataLib/AgateDataLib.csproj (rev 0)
+++ trunk/Tools/AgateDataLib/AgateDataLib.csproj 2010-01-30 07:54:25 UTC (rev 1200)
@@ -0,0 +1,142 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>9.0.21022</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{2F7A686B-2272-4803-9EF9-0B34BA7802DC}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>DataLib</RootNamespace>
+ <AssemblyName>DataLib</AssemblyName>
+ <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
+ <DebugSymbols>true</DebugSymbols>
+ <OutputPath>bin\x64\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <DebugType>full</DebugType>
+ <PlatformTarget>x64</PlatformTarget>
+ <ErrorReport>prompt</ErrorReport>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
+ <OutputPath>bin\x64\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <Optimize>true</Optimize>
+ <DebugType>pdbonly</DebugType>
+ <PlatformTarget>x64</PlatformTarget>
+ <ErrorReport>prompt</ErrorReport>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
+ <DebugSymbols>true</DebugSymbols>
+ <OutputPath>bin\x86\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <DebugType>full</DebugType>
+ <PlatformTarget>x86</PlatformTarget>
+ <ErrorReport>prompt</ErrorReport>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
+ <OutputPath>bin\x86\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <Optimize>true</Optimize>
+ <DebugType>pdbonly</DebugType>
+ <PlatformTarget>x86</PlatformTarget>
+ <ErrorReport>prompt</ErrorReport>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="Ionic.Zip.Reduced, Version=1.9.1.2, Culture=neutral, PublicKeyToken=edbe51ad942a3f5c, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>.\Ionic.Zip.Reduced.dll</HintPath>
+ </Reference>
+ <Reference Include="System" />
+ <Reference Include="System.Core">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="System.Drawing" />
+ <Reference Include="System.Windows.Forms" />
+ <Reference Include="System.Xml.Linq">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="System.Data.DataSetExtensions">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="CodeGenerator.cs" />
+ <Compile Include="DatabaseEditor.cs">
+ <SubType>UserControl</SubType>
+ </Compile>
+ <Compile Include="DatabaseEditor.Designer.cs">
+ <DependentUpon>DatabaseEditor.cs</DependentUpon>
+ </Compile>
+ <Compile Include="DatabaseWriter.cs" />
+ <Compile Include="frmDesignTable.cs">
+ <SubType>Form</SubType>
+ </Compile>
+ <Compile Include="frmDesignTable.Designer.cs">
+ <DependentUpon>frmDesignTable.cs</DependentUpon>
+ </Compile>
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="TableEditor.cs">
+ <SubType>UserControl</SubType>
+ </Compile>
+ <Compile Include="TableEditor.Designer.cs">
+ <DependentUpon>TableEditor.cs</DependentUpon>
+ </Compile>
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\..\AgateLib\AgateLib.csproj">
+ <Project>{9490B719-829E-43A7-A5FE-8001F8A81759}</Project>
+ <Name>AgateLib</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <ItemGroup>
+ <EmbeddedResource Include="DatabaseEditor.resx">
+ <DependentUpon>DatabaseEditor.cs</DependentUpon>
+ <SubType>Designer</SubType>
+ </EmbeddedResource>
+ <EmbeddedResource Include="frmDesignTable.resx">
+ <DependentUpon>frmDesignTable.cs</DependentUpon>
+ <SubType>Designer</SubType>
+ </EmbeddedResource>
+ <EmbeddedResource Include="TableEditor.resx">
+ <DependentUpon>TableEditor.cs</DependentUpon>
+ <SubType>Designer</SubType>
+ </EmbeddedResource>
+ </ItemGroup>
+ <ItemGroup>
+ <Content Include="Images\NewTable.png" />
+ <Content Include="Images\NewTableLarge.png" />
+ <Content Include="Images\TableHS.png" />
+ <Content Include="Images\TableHSLarge.png" />
+ </ItemGroup>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
\ No newline at end of file
Added: trunk/Tools/AgateDataLib/DatabaseEditor.Designer.cs
===================================================================
--- trunk/Tools/AgateDataLib/DatabaseEditor.Designer.cs (rev 0)
+++ trunk/Tools/AgateDataLib/DatabaseEditor.Designer.cs 2010-01-30 07:54:25 UTC (rev 1200)
@@ -0,0 +1,226 @@
+namespace AgateDataLib
+{
+ partial class DatabaseEditor
+ {
+ /// <summary>
+ /// Required designer variable.
+ /// </summary>
+ private System.ComponentModel.IContainer components = null;
+
+ /// <summary>
+ /// Clean up any resources being used.
+ /// </summary>
+ /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Component Designer generated code
+
+ /// <summary>
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ /// </summary>
+ private void InitializeComponent()
+ {
+ this.components = new System.ComponentModel.Container();
+ System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(DatabaseEditor));
+ this.lstTables = new System.Windows.Forms.ListView();
+ this.largeImages = new System.Windows.Forms.ImageList(this.components);
+ this.smallImages = new System.Windows.Forms.ImageList(this.components);
+ this.tabs = new System.Windows.Forms.TabControl();
+ this.tabContextMenu = new System.Windows.Forms.ContextMenuStrip(this.components);
+ this.closeTabToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.splitContainer1 = new System.Windows.Forms.SplitContainer();
+ this.lvContextMenu = new System.Windows.Forms.ContextMenuStrip(this.components);
+ this.viewToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.largeIconsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.smallIconsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.listToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.tableContextMenu = new System.Windows.Forms.ContextMenuStrip(this.components);
+ this.renameToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.deleteToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.tabContextMenu.SuspendLayout();
+ this.splitContainer1.Panel1.SuspendLayout();
+ this.splitContainer1.Panel2.SuspendLayout();
+ this.splitContainer1.SuspendLayout();
+ this.lvContextMenu.SuspendLayout();
+ this.tableContextMenu.SuspendLayout();
+ this.SuspendLayout();
+ //
+ // lstTables
+ //
+ this.lstTables.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.lstTables.LabelEdit = true;
+ this.lstTables.LargeImageList = this.largeImages;
+ this.lstTables.Location = new System.Drawing.Point(0, 0);
+ this.lstTables.Name = "lstTables";
+ this.lstTables.Size = new System.Drawing.Size(133, 538);
+ this.lstTables.SmallImageList = this.smallImages;
+ this.lstTables.TabIndex = 6;
+ this.lstTables.UseCompatibleStateImageBehavior = false;
+ this.lstTables.View = System.Windows.Forms.View.SmallIcon;
+ this.lstTables.AfterLabelEdit += new System.Windows.Forms.LabelEditEventHandler(this.lstTables_AfterLabelEdit);
+ this.lstTables.DoubleClick += new System.EventHandler(this.lstTables_DoubleClick);
+ this.lstTables.MouseUp += new System.Windows.Forms.MouseEventHandler(this.lstTables_MouseUp);
+ this.lstTables.MouseDown += new System.Windows.Forms.MouseEventHandler(this.lstTables_MouseDown);
+ this.lstTables.KeyDown += new System.Windows.Forms.KeyEventHandler(this.lstTables_KeyDown);
+ //
+ // largeImages
+ //
+ this.largeImages.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("largeImages.ImageStream")));
+ this.largeImages.TransparentColor = System.Drawing.Color.Transparent;
+ this.largeImages.Images.SetKeyName(0, "TableHSLarge.png");
+ this.largeImages.Images.SetKeyName(1, "NewTableLarge.png");
+ //
+ // smallImages
+ //
+ this.smallImages.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("smallImages.ImageStream")));
+ this.smallImages.TransparentColor = System.Drawing.Color.Transparent;
+ this.smallImages.Images.SetKeyName(0, "TableHS.png");
+ this.smallImages.Images.SetKeyName(1, "NewTable.png");
+ //
+ // tabs
+ //
+ this.tabs.ContextMenuStrip = this.tabContextMenu;
+ this.tabs.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.tabs.Location = new System.Drawing.Point(0, 0);
+ this.tabs.Name = "tabs";
+ this.tabs.SelectedIndex = 0;
+ this.tabs.Size = new System.Drawing.Size(480, 538);
+ this.tabs.TabIndex = 7;
+ this.tabs.MouseUp += new System.Windows.Forms.MouseEventHandler(this.tabs_MouseUp);
+ //
+ // tabContextMenu
+ //
+ this.tabContextMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
+ this.closeTabToolStripMenuItem});
+ this.tabContextMenu.Name = "tabContextMenu";
+ this.tabContextMenu.Size = new System.Drawing.Size(104, 26);
+ //
+ // closeTabToolStripMenuItem
+ //
+ this.closeTabToolStripMenuItem.Name = "closeTabToolStripMenuItem";
+ this.closeTabToolStripMenuItem.Size = new System.Drawing.Size(103, 22);
+ this.closeTabToolStripMenuItem.Text = "Close";
+ this.closeTabToolStripMenuItem.Click += new System.EventHandler(this.closeTabToolStripMenuItem_Click);
+ //
+ // splitContainer1
+ //
+ this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.splitContainer1.Location = new System.Drawing.Point(0, 0);
+ this.splitContainer1.Name = "splitContainer1";
+ //
+ // splitContainer1.Panel1
+ //
+ this.splitContainer1.Panel1.Controls.Add(this.lstTables);
+ //
+ // splitContainer1.Panel2
+ //
+ this.splitContainer1.Panel2.Controls.Add(this.tabs);
+ this.splitContainer1.Size = new System.Drawing.Size(617, 538);
+ this.splitContainer1.SplitterDistance = 133;
+ this.splitContainer1.TabIndex = 8;
+ //
+ // lvContextMenu
+ //
+ this.lvContextMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
+ this.viewToolStripMenuItem});
+ this.lvContextMenu.Name = "lvContextMenu";
+ this.lvContextMenu.Size = new System.Drawing.Size(100, 26);
+ //
+ // viewToolStripMenuItem
+ //
+ this.viewToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
+ this.largeIconsToolStripMenuItem,
+ this.smallIconsToolStripMenuItem,
+ this.listToolStripMenuItem});
+ this.viewToolStripMenuItem.Name = "viewToolStripMenuItem";
+ this.viewToolStripMenuItem.Size = new System.Drawing.Size(99, 22);
+ this.viewToolStripMenuItem.Text = "View";
+ //
+ // largeIconsToolStripMenuItem
+ //
+ this.largeIconsToolStripMenuItem.Name = "largeIconsToolStripMenuItem";
+ this.largeIconsToolStripMenuItem.Size = new System.Drawing.Size(134, 22);
+ this.largeIconsToolStripMenuItem.Text = "Large Icons";
+ this.largeIconsToolStripMenuItem.Click += new System.EventHandler(this.largeIconsToolStripMenuItem_Click);
+ //
+ // smallIconsToolStripMenuItem
+ //
+ this.smallIconsToolStripMenuItem.Checked = true;
+ this.smallIconsToolStripMenuItem.CheckState = System.Windows.Forms.CheckState.Checked;
+ this.smallIconsToolStripMenuItem.Name = "smallIconsToolStripMenuItem";
+ this.smallIconsToolStripMenuItem.Size = new System.Drawing.Size(134, 22);
+ this.smallIconsToolStripMenuItem.Text = "Small Icons";
+ this.smallIconsToolStripMenuItem.Click += new System.EventHandler(this.smallIconsToolStripMenuItem_Click);
+ //
+ // listToolStripMenuItem
+ //
+ this.listToolStripMenuItem.Name = "listToolStripMenuItem";
+ this.listToolStripMenuItem.Size = new System.Drawing.Size(134, 22);
+ this.listToolStripMenuItem.Text = "List";
+ this.listToolStripMenuItem.Click += new System.EventHandler(this.listToolStripMenuItem_Click);
+ //
+ // tableContextMenu
+ //
+ this.tableContextMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
+ this.renameToolStripMenuItem,
+ this.deleteToolStripMenuItem});
+ this.tableContextMenu.Name = "tableContextMenu";
+ this.tableContextMenu.Size = new System.Drawing.Size(127, 48);
+ //
+ // renameToolStripMenuItem
+ //
+ this.renameToolStripMenuItem.Name = "renameToolStripMenuItem";
+ this.renameToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
+ this.renameToolStripMenuItem.Text = "Rename...";
+ this.renameToolStripMenuItem.Click += new System.EventHandler(this.renameToolStripMenuItem_Click);
+ //
+ // deleteToolStripMenuItem
+ //
+ this.deleteToolStripMenuItem.Name = "deleteToolStripMenuItem";
+ this.deleteToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
+ this.deleteToolStripMenuItem.Text = "Delete";
+ //
+ // DatabaseEditor
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.Controls.Add(this.splitContainer1);
+ this.Name = "DatabaseEditor";
+ this.Size = new System.Drawing.Size(617, 538);
+ this.tabContextMenu.ResumeLayout(false);
+ this.splitContainer1.Panel1.ResumeLayout(false);
+ this.splitContainer1.Panel2.ResumeLayout(false);
+ this.splitContainer1.ResumeLayout(false);
+ this.lvContextMenu.ResumeLayout(false);
+ this.tableContextMenu.ResumeLayout(false);
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.ListView lstTables;
+ private System.Windows.Forms.TabControl tabs;
+ private System.Windows.Forms.SplitContainer splitContainer1;
+ private System.Windows.Forms.ImageList smallImages;
+ private System.Windows.Forms.ImageList largeImages;
+ private System.Windows.Forms.ContextMenuStrip lvContextMenu;
+ private System.Windows.Forms.ToolStripMenuItem viewToolStripMenuItem;
+ private System.Windows.Forms.ToolStripMenuItem largeIconsToolStripMenuItem;
+ private System.Windows.Forms.ToolStripMenuItem smallIconsToolStripMenuItem;
+ private System.Windows.Forms.ToolStripMenuItem listToolStripMenuItem;
+ private System.Windows.Forms.ContextMenuStrip tableContextMenu;
+ private System.Windows.Forms.ToolStripMenuItem renameToolStripMenuItem;
+ private System.Windows.Forms.ToolStripMenuItem deleteToolStripMenuItem;
+ private System.Windows.Forms.ContextMenuStrip tabContextMenu;
+ private System.Windows.Forms.ToolStripMenuItem closeTabToolStripMenuItem;
+ }
+}
Added: trunk/Tools/AgateDataLib/DatabaseEditor.cs
===================================================================
--- trunk/Tools/AgateDataLib/DatabaseEditor.cs (rev 0)
+++ trunk/Tools/AgateDataLib/DatabaseEditor.cs 2010-01-30 07:54:25 UTC (rev 1200)
@@ -0,0 +1,242 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Drawing;
+using System.Data;
+using System.Linq;
+using System.Text;
+using System.Windows.Forms;
+using AgateLib.Data;
+
+namespace AgateDataLib
+{
+ public partial class DatabaseEditor : UserControl
+ {
+ AgateDatabase mDatabase;
+
+ public DatabaseEditor()
+ {
+ InitializeComponent();
+ }
+
+ public AgateDatabase Database
+ {
+ get
+ {
+ return mDatabase;
+ }
+ set
+ {
+ mDatabase = value;
+
+ DatabaseRefresh();
+ }
+ }
+
+ public void DatabaseRefresh()
+ {
+ lstTables.Clear();
+
+ if (Database == null)
+ {
+ tabs.TabPages.Clear();
+
+ return;
+ }
+
+ ListViewItem newTable = new ListViewItem("New Table");
+ newTable.ImageIndex = 1;
+ newTable.Tag = new InvokeDelegate(NewTable);
+
+ lstTables.Items.Add(newTable);
+
+ foreach (var table in Database.Tables)
+ {
+ ListViewItem item = new ListViewItem(table.Name);
+ item.ImageIndex = 0;
+ item.Tag = table;
+
+ lstTables.Items.Add(item);
+ }
+
+ List<TabPage> pagesToRemove = new List<TabPage>();
+
+ foreach (TabPage tab in tabs.TabPages)
+ {
+ TableEditor ed = tab.Controls[0] as TableEditor;
+
+ if (ed == null)
+ continue;
+
+ if (Database.Tables.Contains(ed.AgateTable) == false)
+ {
+ pagesToRemove.Add(tab);
+ }
+ }
+
+ foreach (var tab in pagesToRemove)
+ tabs.TabPages.Remove(tab);
+ }
+
+ private void lstTables_DoubleClick(object sender, EventArgs e)
+ {
+ if (lstTables.SelectedItems.Count == 0)
+ return;
+
+ object obj = lstTables.SelectedItems[0].Tag ;
+ Table table = obj as Table;
+ InvokeDelegate method = obj as InvokeDelegate;
+
+ if (table != null)
+ {
+ OpenTableTab(table);
+ }
+ if (method != null)
+ {
+ method();
+ }
+ }
+
+ private void OpenTableTab(Table table)
+ {
+ foreach (TabPage tab in tabs.TabPages)
+ {
+ Control ctrl = tab.Controls[0];
+
+ if (ctrl is TableEditor)
+ {
+ TableEditor tb = (TableEditor)ctrl;
+
+ if (tb.AgateTable == table)
+ {
+ tabs.SelectedTab = tab;
+ return;
+ }
+ }
+ }
+
+ TabPage page = new TabPage(table.Name);
+
+ TableEditor editor = new TableEditor();
+ editor.Database = Database;
+ editor.AgateTable = table;
+ editor.Dock = DockStyle.Fill;
+
+ page.Controls.Add(editor);
+
+ tabs.TabPages.Add(page);
+ }
+
+ private void NewTable()
+ {
+ MessageBox.Show("Creating new table");
+ }
+
+ private void closeTabToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ TableEditor editor = tabs.SelectedTab.Controls[0] as TableEditor;
+
+ if (editor != null)
+ {
+ editor.FinalizeData();
+ }
+
+ tabs.TabPages.Remove(tabs.SelectedTab);
+ }
+
+ private void largeIconsToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ lstTables.View = View.LargeIcon;
+
+ smallIconsToolStripMenuItem.Checked = false;
+ largeIconsToolStripMenuItem.Checked = true;
+ listToolStripMenuItem.Checked = false;
+ }
+
+ private void smallIconsToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ lstTables.View = View.SmallIcon;
+
+ smallIconsToolStripMenuItem.Checked = true;
+ largeIconsToolStripMenuItem.Checked = false;
+ listToolStripMenuItem.Checked = false;
+ }
+
+ private void listToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ lstTables.View = View.List;
+
+ smallIconsToolStripMenuItem.Checked = false;
+ largeIconsToolStripMenuItem.Checked = false;
+ listToolStripMenuItem.Checked = true;
+ }
+
+ private void lstTables_MouseDown(object sender, MouseEventArgs e)
+ {
+
+ }
+
+ private void lstTables_MouseUp(object sender, MouseEventArgs e)
+ {
+ if (e.Button == MouseButtons.Right)
+ {
+ ContextMenuStrip menu = null;
+
+ if (lstTables.SelectedItems.Count == 0)
+ menu = lvContextMenu;
+ else if (lstTables.SelectedItems.Count == 1)
+ {
+ if (lstTables.SelectedItems[0].Tag is Table)
+ {
+ menu = tableContextMenu;
+ }
+ }
+
+ if (menu != null)
+ menu.Show(lstTables, e.Location);
+ }
+ }
+
+ private void tabs_MouseUp(object sender, MouseEventArgs e)
+ {
+ closeTabToolStripMenuItem.Text = "Close " + tabs.SelectedTab.Text;
+ }
+
+ private void renameToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ if (lstTables.SelectedItems.Count == 0)
+ return;
+
+ lstTables.SelectedItems[0].BeginEdit();
+
+ }
+
+ private void lstTables_AfterLabelEdit(object sender, LabelEditEventArgs e)
+ {
+ object obj = lstTables.SelectedItems[0].Tag;
+ Table table = obj as Table;
+
+ if (Database.Tables.ContainsTable(e.Label))
+ {
+ e.CancelEdit = true;
+ }
+ else
+ table.Name = e.Label;
+ }
+
+ private void lstTables_KeyDown(object sender, KeyEventArgs e)
+ {
+ if (e.KeyCode == Keys.F2)
+ {
+ if (lstTables.SelectedItems.Count == 0)
+ return;
+
+ lstTables.SelectedItems[0].BeginEdit();
+ }
+ }
+
+ }
+
+ delegate void InvokeDelegate();
+
+}
Added: trunk/Tools/AgateDataLib/DatabaseEditor.resx
===================================================================
--- trunk/Tools/AgateDataLib/DatabaseEditor.resx (rev 0)
+++ trunk/Tools/AgateDataLib/DatabaseEditor.resx 2010-01-30 07:54:25 UTC (rev 1200)
@@ -0,0 +1,243 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+ <!--
+ Microsoft ResX Schema
+
+ Version 2.0
+
+ The primary goals of this format is to allow a simple XML format
+ that is mostly human readable. The generation and parsing of the
+ various data types are done through the TypeConverter classes
+ associated with the data types.
+
+ Example:
+
+ ... ado.net/XML headers & schema ...
+ <resheader name="resmimetype">text/microsoft-resx</resheader>
+ <resheader name="version">2.0</resheader>
+ <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+ <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+ <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+ <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+ <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+ <value>[base64 mime encoded serialized .NET Framework object]</value>
+ </data>
+ <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+ <comment>This is a comment</comment>
+ </data>
+
+ There are any number of "resheader" rows that contain simple
+ name/value pairs.
+
+ Each data row contains a name, and value. The row also contains a
+ type or mimetype. Type corresponds to a .NET class that support
+ text/value conversion through the TypeConverter architecture.
+ Classes that don't support this are serialized and stored with the
+ mimetype set.
+
+ The mimetype is used for serialized objects, and tells the
+ ResXResourceReader how to depersist the object. This is currently not
+ extensible. For a given mimetype the value must be set accordingly:
+
+ Note - application/x-microsoft.net.object.binary.base64 is the format
+ that the ResXResourceWriter will generate, however the reader can
+ read any of the formats listed below.
+
+ mimetype: application/x-microsoft.net.object.binary.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.soap.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.bytearray.base64
+ value : The object must be serialized into a byte array
+ : using a System.ComponentModel.TypeConverter
+ : and then encoded with base64 encoding.
+ -->
+ <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+ <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
+ <xsd:element name="root" msdata:IsDataSet="true">
+ <xsd:complexType>
+ <xsd:choice maxOccurs="unbounded">
+ <xsd:element name="metadata">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" />
+ </xsd:sequence>
+ <xsd:attribute name="name" use="required" type="xsd:string" />
+ <xsd:attribute name="type" type="xsd:string" />
+ <xsd:attribute name="mimetype" type="xsd:string" />
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="assembly">
+ <xsd:complexType>
+ <xsd:attribute name="alias" type="xsd:string" />
+ <xsd:attribute name="name" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="data">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
+ <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+ <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="resheader">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" />
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:choice>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:schema>
+ <resheader name="resmimetype">
+ <value>text/microsoft-resx</value>
+ </resheader>
+ <resheader name="version">
+ <value>2.0</value>
+ </resheader>
+ <resheader name="reader">
+ <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <resheader name="writer">
+ <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <metadata name="largeImages.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+ <value>241, 17</value>
+ </metadata>
+ <data name="largeImages.ImageStream" mimetype="application/x-microsoft.net.object.binary.base64">
+ <value>
+ AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj0yLjAuMC4w
+ LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
+ ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAAAs
+ DAAAAk1TRnQBSQFMAgEBAgEAASABAAEgAQABIAEAASABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo
+ AwABgAMAASADAAEBAQABCAYAARAYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA
+ AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5
+ AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA
+ AWYDAAGZAwABzAIAATMDAAIzAgABMwFmAgABMwGZAgABMwHMAgABMwH/AgABZgMAAWYBMwIAAmYCAAFm
+ AZkCAAFmAcwCAAFmAf8CAAGZAwABmQEzAgABmQFmAgACmQIAAZkBzAIAAZkB/wIAAcwDAAHMATMCAAHM
+ AWYCAAHMAZkCAALMAgABzAH/AgAB/wFmAgAB/wGZAgAB/wHMAQABMwH/AgAB/wEAATMBAAEzAQABZgEA
+ ATMBAAGZAQABMwEAAcwBAAEzAQAB/wEAAf8BMwIAAzMBAAIzAWYBAAIzAZkBAAIzAcwBAAIzAf8BAAEz
+ AWYCAAEzAWYBMwEAATMCZgEAATMBZgGZAQABMwFmAcwBAAEzAWYB/wEAATMBmQIAATMBmQEzAQABMwGZ
+ AWYBAAEzApkBAAEzAZkBzAEAATMBmQH/AQABMwHMAgABMwHMATMBAAEzAcwBZgEAATMBzAGZAQABMwLM
+ AQABMwHMAf8BAAEzAf8BMwEAATMB/wFmAQABMwH/AZkBAAEzAf8BzAEAATMC/wEAAWYDAAFmAQABMwEA
+ AWYBAAFmAQABZgEAAZkBAAFmAQABzAEAAWYBAAH/AQABZgEzAgABZgIzAQABZgEzAWYBAAFmATMBmQEA
+ AWYBMwHMAQABZgEzAf8BAAJmAgACZgEzAQADZgEAAmYBmQEAAmYBzAEAAWYBmQIAAWYBmQEzAQABZgGZ
+ AWYBAAFmApkBAAFmAZkBzAEAAWYBmQH/AQABZgHMAgABZgHMATMBAAFmAcwBmQEAAWYCzAEAAWYBzAH/
+ AQABZgH/AgABZgH/ATMBAAFmAf8BmQEAAWYB/wHMAQABzAEAAf8BAAH/AQABzAEAApkCAAGZATMBmQEA
+ AZkBAAGZAQABmQEAAcwBAAGZAwABmQIzAQABmQEAAWYBAAGZATMBzAEAAZkBAAH/AQABmQFmAgABmQFm
+ ATMBAAGZATMBZgEAAZkBZgGZAQABmQFmAcwBAAGZATMB/wEAApkBMwEAApkBZgEAA5kBAAKZAcwBAAKZ
+ Af8BAAGZAcwCAAGZAcwBMwEAAWYBzAFmAQABmQHMAZkBAAGZAswBAAGZAcwB/wEAAZkB/wIAAZkB/wEz
+ AQABmQHMAWYBAAGZAf8BmQEAAZkB/wHMAQABmQL/AQABzAMAAZkBAAEzAQABzAEAAWYBAAHMAQABmQEA
+ AcwBAAHMAQABmQEzAgABzAIzAQABzAEzAWYBAAHMATMBmQEAAcwBMwHMAQABzAEzAf8BAAHMAWYCAAHM
+ AWYBMwEAAZkCZgEAAcwBZgGZAQABzAFmAcwBAAGZAWYB/wEAAcwBmQIAAcwBmQEzAQABzAGZAWYBAAHM
+ ApkBAAHMAZkBzAEAAcwBmQH/AQACzAIAAswBMwEAAswBZgEAAswBmQEAA8wBAALMAf8BAAHMAf8CAAHM
+ Af8BMwEAAZkB/wFmAQABzAH/AZkBAAHMAf8BzAEAAcwC/wEAAcwBAAEzAQAB/wEAAWYBAAH/AQABmQEA
+ AcwBMwIAAf8CMwEAAf8BMwFmAQAB/wEzAZkBAAH/ATMBzAEAAf8BMwH/AQAB/wFmAgAB/wFmATMBAAHM
+ AmYBAAH/AWYBmQEAAf8BZgHMAQABzAFmAf8BAAH/AZkCAAH/AZkBMwEAAf8BmQFmAQAB/wKZAQAB/wGZ
+ AcwBAAH/AZkB/wEAAf8BzAIAAf8BzAEzAQAB/wHMAWYBAAH/AcwBmQEAAf8CzAEAAf8BzAH/AQAC/wEz
+ AQABzAH/AWYBAAL/AZkBAAL/AcwBAAJmAf8BAAFmAf8BZgEAAWYC/wEAAf8CZgEAAf8BZgH/AQAC/wFm
+ AQABIQEAAaUBAANfAQADdwEAA4YBAAOWAQADywEAA7IBAAPXAQAD3QEAA+MBAAPqAQAD8QEAA/gBAAHw
+ AfsB/wEAAaQCoAEAA4ADAAH/AgAB/wMAAv8BAAH/AwAB/wEAAf8BAAL/AgAD/yUAAvcaZmQAAvcaZmQA
+ AvcCvAYHAu8CtQTvBLUE9wJmZAAC9wK8BgcC7wK1BO8EtQT3AmZCAAL3GmYGAAL3Bv8CBwT0AhkC7wIZ
+ At0CCQL3AmZCAAL3GmYGAAL3Bv8CBwT0AhkC7wIZAt0CCQL3AmZCAAL3ArwGBwLvArUE7wS1BPcCZgYA
+ AvcG/wIHAv8E9AK1BBkC3QK1AmZCAAL3ArwGBwLvArUE7wS1BPcCZgYAAvcG/wIHAv8E9AK1BBkC3QK1
+ AmZCAAL3Bv8CBwT0AhkC7wIZAt0CCQL3AmYGAAL3AvAEvAgHAu8CtQTvArUCZkIAAvcG/wIHBPQCGQLv
+ AhkC3QIJAvcCZgYAAvcC8AS8CAcC7wK1BO8CtQJmQgAC9wb/AgcC/wT0ArUEGQLdArUCZgYAArUG/wK8
+ Bv8CBwL0BBkC7wJmQgAC9wb/AgcC/wT0ArUEGQLdArUCZgYAArUG/wK8Bv8CBwL0BBkC7wJmQgAC9wLw
+ BLwIBwLvArUE7wK1AmYGAALvBv8CvAb/AgcE9AIZAu8CZkIAAvcC8AS8CAcC7wK1BO8CtQJmBgAC7wb/
+ ArwG/wIHBPQCGQLvAmZCAAK1Bv8CvAb/AgcC9AQZAu8CZgYAArUC8Qq8CAcC7wK1AmZCAAK1Bv8CvAb/
+ AgcC9AQZAu8CZgYAArUC8Qq8CAcC7wK1AmZCAALvBv8CvAb/AgcE9AIZAu8CZgQAAhoCeQIyAlkC5QKg
+ Bv8CBwT/AvQC7wJmQgAC7wb/ArwG/wIHBPQCGQLvAmYEAAIaAnkCMgJZAuUCoAb/AgcE/wL0Au8CZkIA
+ ArUC8Qq8CAcC7wK1AmYCAAKgAiwCoAIyAjgCoAIsAqAE/wK8Bv8CBwJmQgACtQLxCrwIBwLvArUCZgIA
+ AqACLAKgAjICOAKgAiwCoAT/ArwG/wIHAmZCAAK7Bv8CvAb/AgcE/wL0Au8CZgIABKACLAIyAjgCLAKg
+ AuUEtAytQgACuwb/ArwG/wIHBP8C9ALvAmYCAASgAiwCMgI4AiwCoALlBLQMrUIAArsG/wK8Bv8CvAb/
+ AgcCZgIABDgCMgY4Al4CWQLcAtYK1QKtQgACuwb/ArwG/wK8Bv8CBwJmAgAEOAIyBjgCXgJZAtwC1grV
+ Aq1CAAjWAtUGtAytAgAGMgL/AqACOAQyAtUGtAKzBq1CAAjWAtUGtAytAgAGMgL/AqACOAQyAtUGtAKz
+ Bq1CAALWAgkK3ALWCtUCrQIAAnoCoAIsAjICOAIsAqACWVIAAtYCCQrcAtYK1QKtAgACegKgAiwCMgI4
+ AiwCoAJZUgAK1gTVBrQCswatAgACmgIsAqAEOAKgAiwCoFIACtYE1Qa0ArMGrQIAApoCLAKgBDgCoAIs
+ AqByAATlAjICOATldAAE5QIyAjgE5VIAAUIBTQE+BwABPgMAASgDAAGAAwABIAMAAQEBAAEBBgABAhYA
+ A/8BAAT/AfALAAT/AfALAAT/AfALAAT/AfALAAHAAgABAwHwCwABwAIAAQMB8AsAAcACAAEDAfALAAHA
+ AgABAwHwCwABwAIAAQMB8AsAAcACAAEDAfALAAHAAgABAwHwCwABwAIAAQMB8AsAAcACAAEDAfALAAHA
+ AgABAwHwCwABwAIAAQMB8AsAAcACAAEDAfALAAHAAgABAwHACwABwAIAAQMBwAsAAcACAAEDDAABwAIA
+ AQMMAAHAAgABAwwAAcACAAEDDAABwAIAAQMMAAHAAgABAwwAAcACAAEDDAABwAIAAQMMAAHAAgABAwIA
+ Av8IAAHAAgABAwIAAv8IAAHAAgABAwIAAv8IAAHAAgABAwIAAv8IAAT/AcABAwL/CAAE/wHAAQMC/wgA
+ Cw==
+</value>
+ </data>
+ <metadata name="smallImages.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+ <value>122, 17</value>
+ </metadata>
+ <data name="smallImages.ImageStream" mimetype="application/x-microsoft.net.object.binary.base64">
+ <value>
+ AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj0yLjAuMC4w
+ LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
+ ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAABs
+ CQAAAk1TRnQBSQFMAgEBAgEAASgBAAEoAQABEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo
+ AwABQAMAARADAAEBAQABCAYAAQQYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA
+ AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5
+ AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA
+ AWYDAAGZAwABzAIAATMDAAIzAgABMwFmAgABMwGZAgABMwHMAgABMwH/AgABZgMAAWYBMwIAAmYCAAFm
+ AZkCAAFmAcwCAAFmAf8CAAGZAwABmQEzAgABmQFmAgACmQIAAZkBzAIAAZkB/wIAAcwDAAHMATMCAAHM
+ AWYCAAHMAZkCAALMAgABzAH/AgAB/wFmAgAB/wGZAgAB/wHMAQABMwH/AgAB/wEAATMBAAEzAQABZgEA
+ ATMBAAGZAQABMwEAAcwBAAEzAQAB/wEAAf8BMwIAAzMBAAIzAWYBAAIzAZkBAAIzAcwBAAIzAf8BAAEz
+ AWYCAAEzAWYBMwEAATMCZgEAATMBZgGZAQABMwFmAcwBAAEzAWYB/wEAATMBmQIAATMBmQEzAQABMwGZ
+ AWYBAAEzApkBAAEzAZkBzAEAATMBmQH/AQABMwHMAgABMwHMATMBAAEzAcwBZgEAATMBzAGZAQABMwLM
+ AQABMwHMAf8BAAEzAf8BMwEAATMB/wFmAQABMwH/AZkBAAEzAf8BzAEAATMC/wEAAWYDAAFmAQABMwEA
+ AWYBAAFmAQABZgEAAZkBAAFmAQABzAEAAWYBAAH/AQABZgEzAgABZgIzAQABZgEzAWYBAAFmATMBmQEA
+ AWYBMwHMAQABZgEzAf8BAAJmAgACZgEzAQADZgEAAmYBmQEAAmYBzAEAAWYBmQIAAWYBmQEzAQABZgGZ
+ AWYBAAFmApkBAAFmAZkBzAEAAWYBmQH/AQABZgHMAgABZgHMATMBAAFmAcwBmQEAAWYCzAEAAWYBzAH/
+ AQABZgH/AgABZgH/ATMBAAFmAf8BmQEAAWYB/wHMAQABzAEAAf8BAAH/AQABzAEAApkCAAGZATMBmQEA
+ AZkBAAGZAQABmQEAAcwBAAGZAwABmQIzAQABmQEAAWYBAAGZATMBzAEAAZkBAAH/AQABmQFmAgABmQFm
+ ATMBAAGZATMBZgEAAZkBZgGZAQABmQFmAcwBAAGZATMB/wEAApkBMwEAApkBZgEAA5kBAAKZAcwBAAKZ
+ Af8BAAGZAcwCAAGZAcwBMwEAAWYBzAFmAQABmQHMAZkBAAGZAswBAAGZAcwB/wEAAZkB/wIAAZkB/wEz
+ AQABmQHMAWYBAAGZAf8BmQEAAZkB/wHMAQABmQL/AQABzAMAAZkBAAEzAQABzAEAAWYBAAHMAQABmQEA
+ AcwBAAHMAQABmQEzAgABzAIzAQABzAEzAWYBAAHMATMBmQEAAcwBMwHMAQABzAEzAf8BAAHMAWYCAAHM
+ AWYBMwEAAZkCZgEAAcwBZgGZAQABzAFmAcwBAAGZAWYB/wEAAcwBmQIAAcwBmQEzAQABzAGZAWYBAAHM
+ ApkBAAHMAZkBzAEAAcwBmQH/AQACzAIAAswBMwEAAswBZgEAAswBmQEAA8wBAALMAf8BAAHMAf8CAAHM
+ Af8BMwEAAZkB/wFmAQABzAH/AZkBAAHMAf8BzAEAAcwC/wEAAcwBAAEzAQAB/wEAAWYBAAH/AQABmQEA
+ AcwBMwIAAf8CMwEAAf8BMwFmAQAB/wEzAZkBAAH/ATMBzAEAAf8BMwH/AQAB/wFmAgAB/wFmATMBAAHM
+ AmYBAAH/AWYBmQEAAf8BZgHMAQABzAFmAf8BAAH/AZkCAAH/AZkBMwEAAf8BmQFmAQAB/wKZAQAB/wGZ
+ AcwBAAH/AZkB/wEAAf8BzAIAAf8BzAEzAQAB/wHMAWYBAAH/AcwBmQEAAf8CzAEAAf8BzAH/AQAC/wEz
+ AQABzAH/AWYBAAL/AZkBAAL/AcwBAAJmAf8BAAFmAf8BZgEAAWYC/wEAAf8CZgEAAf8BZgH/AQAC/wFm
+ AQABIQEAAaUBAANfAQADdwEAA4YBAAOWAQADywEAA7IBAAPXAQAD3QEAA+MBAAPqAQAD8QEAA/gBAAHw
+ AfsB/wEAAaQCoAEAA4ADAAH/AgAB/wMAAv8BAAH/AwAB/wEAAf8BAAL/AgAD/xMAAfcNZjIAAfcBvAMH
+ Ae8BtQLvArUC9wFmIQAB9w1mAwAB9wP/AQcC9AEZAe8BGQHdAQkB9wFmIQAB9wG8AwcB7wG1Au8CtQL3
+ AWYDAAH3A/8BBwH/AvQBtQIZAd0BtQFmIQAB9wP/AQcC9AEZAe8BGQHdAQkB9wFmAwAB9wHwArwEBwHv
+ AbUC7wG1AWYhAAH3A/8BBwH/AvQBtQIZAd0BtQFmAwABtQP/AbwD/wEHAfQCGQHvAWYhAAH3AfACvAQH
+ Ae8BtQLvAbUBZgMAAe8D/wG8A/8BBwL0ARkB7wFmIQABtQP/AbwD/wEHAfQCGQHvAWYDAAG1AfEFvAQH
+ Ae8BtQFmIQAB7wP/AbwD/wEHAvQBGQHvAWYCAAEaAXkBMgFZAeUBoAP/AQcC/wH0Ae8BZiEAAbUB8QW8
+ BAcB7wG1AWYBAAGgASwBoAEyATgBoAEsAaAC/wG8A/8BBwFmIQABuwP/AbwD/wEHAv8B9AHvAWYBAAKg
+ ASwBMgE4ASwBoAHlArQGrSEAAbsD/wG8A/8BvAP/AQcBZgEAAjgBMgM4AV4BWQHcAdYF1QGtIQAE1gHV
+ A7QGrQEAAzIB/wGgATgCMgHVA7QBswOtIQAB1gEJBdwB1gXVAa0BAAF6AaABLAEyATgBLAGgAVkpAAXW
+ AtUDtAGzA60BAAGaASwBoAI4AaABLAGgOQAC5QEyATgC5SkAAUIBTQE+BwABPgMAASgDAAFAAwABEAMA
+ AQEBAAEBBQABgBcAA/8BAAL/AcAFAAL/AcAFAAGAAQEBwAUAAYABAQHABQABgAEBAcAFAAGAAQEBwAUA
+ AYABAQHABQABgAEBAcAFAAGAAQEBgAUAAYABAQYAAYABAQYAAYABAQYAAYABAQYAAYABAQEAAf8EAAGA
+ AQEBAAH/BAAC/wGBAf8EAAs=
+</value>
+ </data>
+ <metadata name="tabContextMenu.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+ <value>646, 17</value>
+ </metadata>
+ <metadata name="lvContextMenu.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+ <value>359, 17</value>
+ </metadata>
+ <metadata name="tableContextMenu.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+ <value>493, 17</value>
+ </metadata>
+</root>
\ No newline at end of file
Added: trunk/Tools/AgateDataLib/DatabaseWriter.cs
===================================================================
--- trunk/Tools/AgateDataLib/DatabaseWriter.cs (rev 0)
+++ trunk/Tools/AgateDataLib/DatabaseWriter.cs 2010-01-30 07:54:25 UTC (rev 1200)
@@ -0,0 +1,94 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using AgateLib.Data;
+using AgateLib.Serialization.Xle;
+using Ionic.Zip;
+
+namespace AgateDataLib
+{
+ public class DatabaseWriter
+ {
+ public DatabaseWriter()
+ {
+ }
+
+ public DatabaseWriter(AgateDatabase database)
+ {
+ this.Database = database;
+ }
+ public AgateDatabase Database { get; set; }
+
+ /// <summary>
+ /// Writes the database to the specified file.
+ /// The Database property must not be null, and its validate
+ /// property must return without throwing an exception.
+ /// </summary>
+ /// <param name="filename">The output file to write to.</param>
+ public void WriteData(string filename)
+ {
+ if (Database == null)
+ {
+ throw new InvalidOperationException("The database to write is empty.");
+ }
+
+ Database.LoadAllTables();
+ Database.Validate();
+
+ bool overwriting = File.Exists(filename);
+
+ string tempfilename = Path.GetTempFileName();
+
+ try
+ {
+ if (overwriting)
+ {
+ File.Copy(filename, tempfilename, true);
+ File.Delete(filename);
+ }
+
+ using (ZipFile zip = new ZipFile(filename))
+ {
+ // serialize the catalog first.
+ XleSerializer baseSer = new XleSerializer(typeof(AgateDatabase));
+ MemoryStream ms = new MemoryStream();
+
+ baseSer.Serialize(ms, Database);
+
+ ms.Position = 0;
+
+ ZipEntry catalog = zip.AddEntry("catalog.txt", ms);
+
+ // now do each table
+ XleSerializer tableSer = new XleSerializer(typeof(Table));
+
+ foreach (var table in Database.Tables)
+ {
+ string name = string.Format("data/{0}.txt", table.Name);
+
+ ms = new MemoryStream();
+ tableSer.Serialize(ms, table);
+ ms.Position = 0;
+
+ ZipEntry f = zip.AddEntry(name, ms);
+ }
+
+ zip.Save();
+ }
+ }
+ catch
+ {
+ if (overwriting)
+ {
+ File.Delete(filename);
+ File.Copy(tempfilename, filename);
+ File.Delete(tempfilename);
+ }
+
+ throw;
+ }
+ }
+ }
+}
Added: trunk/Tools/AgateDataLib/Images/NewTable.png
===================================================================
(Binary files differ)
Property changes on: trunk/Tools/AgateDataLib/Images/NewTable.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/Tools/AgateDataLib/Images/NewTableLarge.png
===================================================================
(Binary files differ)
Property changes on: trunk/Tools/AgateDataLib/Images/NewTableLarge.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/Tools/AgateDataLib/Images/TableHS.png
===================================================================
(Binary files differ)
Property changes on: trunk/Tools/AgateDataLib/Images/TableHS.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/Tools/AgateDataLib/Images/TableHSLarge.png
===================================================================
(Binary files differ)
Property changes on: trunk/Tools/AgateDataLib/Images/TableHSLarge.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/Tools/AgateDataLib/Properties/AssemblyInfo.cs
===================================================================
--- trunk/Tools/AgateDataLib/Properties/AssemblyInfo.cs (rev 0)
+++ trunk/Tools/AgateDataLib/Properties/AssemblyInfo.cs 2010-01-30 07:54:25 UTC (rev 1200)
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("DataLib")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Microsoft")]
+[assembly: AssemblyProduct("DataLib")]
+[assembly: AssemblyCopyright("Copyright © Microsoft 2010")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("2e29b255-4c4c-4290-a10e-5af8888dfa30")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
Added: trunk/Tools/AgateDataLib/TableEditor.Designer.cs
===================================================================
--- trunk/Tools/AgateDataLib/TableEditor.Designer.cs (rev 0)
+++ trunk/Tools/AgateDataLib/TableEditor.Designer.cs 2010-01-30 07:54:25 UTC (rev 1200)
@@ -0,0 +1,91 @@
+namespace AgateDataLib
+{
+ partial class TableEditor
+ {
+ /// <summary>
+ /// Required designer variable.
+ /// </summary>
+ private System.ComponentModel.IContainer components = null;
+
+ /// <summary>
+ /// Clean up any resources being used.
+ /// </summary>
+ /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Component Designer generated code
+
+ /// <summary>
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ /// </summary>
+ private void InitializeComponent()
+ {
+ this.components = new System.ComponentModel.Container();
+ this.gridView = new System.Windows.Forms.DataGridView();
+ this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);
+ this.editColumnsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ ((System.ComponentModel.ISupportInitialize)(this.gridView)).BeginInit();
+ this.contextMenuStrip1.SuspendLayout();
+ this.SuspendLayout();
+ //
+ // gridView
+ //
+ this.gridView.AllowUserToOrderColumns = true;
+ this.gridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ this.gridView.ContextMenuStrip = this.contextMenuStrip1;
+ this.gridView.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.gridView.Location = new System.Drawing.Point(0, 0);
+ this.gridView.Name = "gridView";
+ this.gridView.Size = new System.Drawing.Size(150, 150);
+ this.gridView.TabIndex = 8;
+ this.gridView.VirtualMode = true;
+ this.gridView.UserDeletingRow += new System.Windows.Forms.DataGridViewRowCancelEventHandler(this.gridView_UserDeletingRow);
+ this.gridView.CancelRowEdit += new System.Windows.Forms.QuestionEventHandler(this.gridView_CancelRowEdit);
+ this.gridView.CellValueNeeded += new System.Windows.Forms.DataGridViewCellValueEventHandler(this.gridView_CellValueNeeded);
+ this.gridView.RowValidated += new System.Windows.Forms.DataGridViewCellEventHandler(this.gridView_RowValidated);
+ this.gridView.RowDirtyStateNeeded += new System.Windows.Forms.QuestionEventHandler(this.gridView_RowDirtyStateNeeded);
+ this.gridView.CellValuePushed += new System.Windows.Forms.DataGridViewCellValueEventHandler(this.gridView_CellValuePushed);
+ this.gridView.NewRowNeeded += new System.Windows.Forms.DataGridViewRowEventHandler(this.gridView_NewRowNeeded);
+ this.gridView.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.gridView_CellContentClick);
+ //
+ // contextMenuStrip1
+ //
+ this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
+ this.editColumnsToolStripMenuItem});
+ this.contextMenuStrip1.Name = "contextMenuStrip1";
+ this.contextMenuStrip1.Size = new System.Drawing.Size(155, 48);
+ //
+ // editColumnsToolStripMenuItem
+ //
+ this.editColumnsToolStripMenuItem.Name = "editColumnsToolStripMenuItem";
+ this.editColumnsToolStripMenuItem.Size = new System.Drawing.Size(154, 22);
+ this.editColumnsToolStripMenuItem.Text = "Edit Columns...";
+ this.editColumnsToolStripMenuItem.Click += new System.EventHandler(this.editColumnsToolStripMenuItem_Click);
+ //
+ // TableEditor
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.Controls.Add(this.gridView);
+ this.Name = "TableEditor";
+ ((System.ComponentModel.ISupportInitialize)(this.gridView)).EndInit();
+ this.contextMenuStrip1.ResumeLayout(false);
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.DataGridView gridView;
+ private System.Windows.Forms.ContextMenuStrip contextMenuStrip1;
+ private System.Windows.Forms.ToolStripMenuItem editColumnsToolStripMenuItem;
+ }
+}
Added: trunk/Tools/AgateDataLib/TableEditor.cs
===================================================================
--- trunk/Tools/AgateDataLib/TableEditor.cs (rev 0)
+++ trunk/Tools/AgateDataLib/TableEditor.cs 2010-01-30 07:54:25 UTC (rev 1200)
@@ -0,0 +1,220 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Windows.Forms;
+using AgateLib.Data;
+
+namespace AgateDataLib
+{
+ public partial class TableEditor : UserControl
+ {
+ AgateDatabase mDatabase;
+ Table mTable;
+
+ Row mEditingRow;
+ int mEditingRowIndex = -1;
+
+ public TableEditor()
+ {
+ InitializeComponent();
+ }
+
+ public AgateDatabase Database
+ {
+ get { return mDatabase; }
+ set { mDatabase = value;
+ AgateTable = null;
+ }
+ }
+ public Table AgateTable
+ {
+ get { return mTable; }
+ set
+ {
+ mTable = value;
+ TableReset();
+ }
+ }
+
+ internal void FinalizeData()
+ {
+ gridView.CommitEdit(DataGridViewDataErrorContexts.Commit);
+ gridView.EndEdit();
+
+ DataGridViewCellEventArgs e = new DataGridViewCellEventArgs(gridView.CurrentCell.ColumnIndex, gridView.CurrentCell.RowIndex);
+
+ gridView_RowValidated(gridView, e);
+ }
+
+ private void TableReset()
+ {
+ gridView.SuspendLayout();
+ gridView.Columns.Clear();
+
+ if (mTable == null)
+ {
+ gridView.ResumeLayout();
+
+ return;
+ }
+
+ int index = 0;
+ foreach (var column in mTable.Columns)
+ {
+ DataGridViewColumn col = new DataGridViewColumn();
+
+ col.Name = column.Name;
+ col.ReadOnly = column.FieldType == FieldType.AutoNumber;
+
+ if (string.IsNullOrEmpty(column.TableLookup))
+ {
+ col.CellTemplate = new DataGridViewTextBoxCell();
+ ...
[truncated message content] |
|
From: <ka...@us...> - 2010-01-28 22:15:18
|
Revision: 1199
http://agate.svn.sourceforge.net/agate/?rev=1199&view=rev
Author: kanato
Date: 2010-01-28 22:15:12 +0000 (Thu, 28 Jan 2010)
Log Message:
-----------
Hack for escape key bug.
Modified Paths:
--------------
trunk/Drivers/AgateOTK/GL_GameWindow.cs
Modified: trunk/Drivers/AgateOTK/GL_GameWindow.cs
===================================================================
--- trunk/Drivers/AgateOTK/GL_GameWindow.cs 2010-01-28 22:14:49 UTC (rev 1198)
+++ trunk/Drivers/AgateOTK/GL_GameWindow.cs 2010-01-28 22:15:12 UTC (rev 1199)
@@ -144,7 +144,7 @@
keyMap.Add(OpenTK.Input.Key.ScrollLock, KeyCode.ScrollLock);
keyMap.Add(OpenTK.Input.Key.Semicolon, KeyCode.Semicolon);
keyMap.Add(OpenTK.Input.Key.ShiftLeft, KeyCode.Shift);
- //keyMap.Add(OpenTK.Input.Key.ShiftRight, KeyCode.Shift);
+ keyMap.Add(OpenTK.Input.Key.ShiftRight, KeyCode.Shift);
keyMap.Add(OpenTK.Input.Key.Slash, KeyCode.Slash);
keyMap.Add(OpenTK.Input.Key.Sleep, KeyCode.Sleep);
keyMap.Add(OpenTK.Input.Key.Space, KeyCode.Space);
@@ -235,6 +235,12 @@
{
KeyCode code = TransformKey(e.Key);
+ // Hack because sometimes escape key does not get a keydown event on windows?
+ if (code == KeyCode.Escape && Keyboard.Keys[code] == false)
+ {
+ Keyboard.Keys[code] = true;
+ }
+
Keyboard.Keys[code] = false;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2010-01-28 22:14:55
|
Revision: 1198
http://agate.svn.sourceforge.net/agate/?rev=1198&view=rev
Author: kanato
Date: 2010-01-28 22:14:49 +0000 (Thu, 28 Jan 2010)
Log Message:
-----------
Fix FontSurface crash if null is passed as an argument to a format string.
Modified Paths:
--------------
trunk/AgateLib/DisplayLib/FontSurface.cs
Modified: trunk/AgateLib/DisplayLib/FontSurface.cs
===================================================================
--- trunk/AgateLib/DisplayLib/FontSurface.cs 2010-01-28 20:15:17 UTC (rev 1197)
+++ trunk/AgateLib/DisplayLib/FontSurface.cs 2010-01-28 22:14:49 UTC (rev 1198)
@@ -473,6 +473,12 @@
};
}
+ for (int i = 0; i < args.Length; i++)
+ {
+ if (args[i] == null)
+ args[i] = "null";
+ }
+
int lastIndex = 0;
string result = string.Empty;
PointF dest;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2010-01-28 20:15:23
|
Revision: 1197
http://agate.svn.sourceforge.net/agate/?rev=1197&view=rev
Author: kanato
Date: 2010-01-28 20:15:17 +0000 (Thu, 28 Jan 2010)
Log Message:
-----------
Correct full screen test class name.
Modified Paths:
--------------
trunk/Tests/DisplayTests/FullScreen.cs
Modified: trunk/Tests/DisplayTests/FullScreen.cs
===================================================================
--- trunk/Tests/DisplayTests/FullScreen.cs 2010-01-28 19:14:25 UTC (rev 1196)
+++ trunk/Tests/DisplayTests/FullScreen.cs 2010-01-28 20:15:17 UTC (rev 1197)
@@ -7,7 +7,7 @@
namespace Tests.DisplayTests
{
- class HelloWorldProgram : IAgateTest
+ class FullscreenTest : IAgateTest
{
public string Name
{
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2010-01-28 19:14:33
|
Revision: 1196
http://agate.svn.sourceforge.net/agate/?rev=1196&view=rev
Author: kanato
Date: 2010-01-28 19:14:25 +0000 (Thu, 28 Jan 2010)
Log Message:
-----------
Replace OpenTK with version that reports correct window size.
Modified Paths:
--------------
trunk/Drivers/AgateOTK/OpenTK.dll
trunk/Tests/DisplayTests/FullScreen.cs
Modified: trunk/Drivers/AgateOTK/OpenTK.dll
===================================================================
(Binary files differ)
Modified: trunk/Tests/DisplayTests/FullScreen.cs
===================================================================
--- trunk/Tests/DisplayTests/FullScreen.cs 2010-01-28 18:37:38 UTC (rev 1195)
+++ trunk/Tests/DisplayTests/FullScreen.cs 2010-01-28 19:14:25 UTC (rev 1196)
@@ -31,7 +31,8 @@
Surface mySurface = new Surface("jellybean.png");
// Run the program while the window is open.
- while (!(Display.CurrentWindow.IsClosed || Keyboard.Keys[KeyCode.Escape]))
+ while (Display.CurrentWindow.IsClosed == false &&
+ Keyboard.Keys[KeyCode.Escape] == false)
{
Display.BeginFrame();
Display.Clear(Color.DarkGreen);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2010-01-28 18:37:53
|
Revision: 1195
http://agate.svn.sourceforge.net/agate/?rev=1195&view=rev
Author: kanato
Date: 2010-01-28 18:37:38 +0000 (Thu, 28 Jan 2010)
Log Message:
-----------
Correct creation of full screen DisplayWindow in AgateOTK.
Modified Paths:
--------------
trunk/Drivers/AgateOTK/GL_Display.cs
trunk/Drivers/AgateOTK/GL_GameWindow.cs
trunk/Drivers/AgateOTK/OpenTK.dll
trunk/Drivers/AgateOTK/OpenTK.xml
Modified: trunk/Drivers/AgateOTK/GL_Display.cs
===================================================================
--- trunk/Drivers/AgateOTK/GL_Display.cs 2010-01-28 17:31:52 UTC (rev 1194)
+++ trunk/Drivers/AgateOTK/GL_Display.cs 2010-01-28 18:37:38 UTC (rev 1195)
@@ -94,7 +94,10 @@
}
public override DisplayWindowImpl CreateDisplayWindow(CreateWindowParams windowParams)
{
- return new GL_DisplayControl(windowParams);
+ if (windowParams.IsFullScreen && windowParams.RenderToControl == false)
+ return new GL_GameWindow(windowParams);
+ else
+ return new GL_DisplayControl(windowParams);
//if (windowParams.RenderToControl)
//{
Modified: trunk/Drivers/AgateOTK/GL_GameWindow.cs
===================================================================
--- trunk/Drivers/AgateOTK/GL_GameWindow.cs 2010-01-28 17:31:52 UTC (rev 1194)
+++ trunk/Drivers/AgateOTK/GL_GameWindow.cs 2010-01-28 18:37:38 UTC (rev 1195)
@@ -174,7 +174,7 @@
bool mHasFrame;
WindowPosition mCreatePosition;
GLDrawBuffer mDrawBuffer;
- GL_FrameBuffer mFrameBuffer;
+ ContextFB mFrameBuffer;
public GL_GameWindow(CreateWindowParams windowParams)
{
@@ -196,6 +196,9 @@
else
CreateWindowedDisplay();
+ mFrameBuffer = new ContextFB(mWindow.Context, mWindow.WindowInfo,
+ new Size(mWindow.ClientSize.Width, mWindow.ClientSize.Height ));
+
mDisplay = Display.Impl as GL_Display;
mDisplay.ProcessEventsEvent += new EventHandler(mDisplay_ProcessEventsEvent);
Modified: trunk/Drivers/AgateOTK/OpenTK.dll
===================================================================
(Binary files differ)
Modified: trunk/Drivers/AgateOTK/OpenTK.xml
===================================================================
--- trunk/Drivers/AgateOTK/OpenTK.xml 2010-01-28 17:31:52 UTC (rev 1194)
+++ trunk/Drivers/AgateOTK/OpenTK.xml 2010-01-28 18:37:38 UTC (rev 1195)
@@ -9845,6 +9845,10 @@
<summary>
Gets the GraphicsContext that is current in the calling thread.
</summary>
+ <remarks>
+ Note: this property will not function correctly when both desktop and EGL contexts are
+ available in the same process. This scenario is very unlikely to appear in practice.
+ </remarks>
</member>
<member name="P:OpenTK.Graphics.GraphicsContext.ShareContexts">
<summary>Gets or sets a System.Boolean, indicating whether GraphicsContext resources are shared</summary>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2010-01-28 17:31:59
|
Revision: 1194
http://agate.svn.sourceforge.net/agate/?rev=1194&view=rev
Author: kanato
Date: 2010-01-28 17:31:52 +0000 (Thu, 28 Jan 2010)
Log Message:
-----------
Fix crash with AgateGame if window is closed during Update method.
Modified Paths:
--------------
trunk/AgateLib/AgateGame.cs
trunk/Drivers/AgateOTK/GL_DisplayControl.cs
Modified: trunk/AgateLib/AgateGame.cs
===================================================================
--- trunk/AgateLib/AgateGame.cs 2010-01-28 17:19:40 UTC (rev 1193)
+++ trunk/AgateLib/AgateGame.cs 2010-01-28 17:31:52 UTC (rev 1194)
@@ -96,10 +96,14 @@
{
Update(Display.DeltaTime);
+ if (MainWindow.IsClosed)
+ break;
+
if (GuiRoot != null)
GuiRoot.DoUpdate();
+
- Display.RenderTarget = mWindow.FrameBuffer;
+ Display.RenderTarget = MainWindow.FrameBuffer;
Display.BeginFrame();
Render();
Modified: trunk/Drivers/AgateOTK/GL_DisplayControl.cs
===================================================================
--- trunk/Drivers/AgateOTK/GL_DisplayControl.cs 2010-01-28 17:19:40 UTC (rev 1193)
+++ trunk/Drivers/AgateOTK/GL_DisplayControl.cs 2010-01-28 17:31:52 UTC (rev 1194)
@@ -347,6 +347,12 @@
{
mDisplay.ProcessEventsEvent -= mDisplay_ProcessEventsEvent;
+ if (mFrameBuffer != null)
+ {
+ mFrameBuffer.Dispose();
+ mFrameBuffer = null;
+ }
+
if (mContext != null)
{
mContext.Dispose();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2010-01-28 17:19:47
|
Revision: 1193
http://agate.svn.sourceforge.net/agate/?rev=1193&view=rev
Author: kanato
Date: 2010-01-28 17:19:40 +0000 (Thu, 28 Jan 2010)
Log Message:
-----------
Add AudioCapsInfo class and interfaces.
Correct setting of DisplayWindow.Height.
Disable fake window in SDX so that fullscreen works.
Modified Paths:
--------------
trunk/AgateLib/AgateLib.csproj
trunk/AgateLib/AudioLib/Audio.cs
trunk/AgateLib/AudioLib/ImplementationBase/AudioImpl.cs
trunk/AgateLib/DisplayLib/DisplayWindow.cs
trunk/AgateLib/Drivers/NullSoundImpl.cs
trunk/Drivers/AgateFMOD/FMOD_Audio.cs
trunk/Drivers/AgateSDL/Audio/SDL_Audio.cs
trunk/Drivers/AgateSDX/AgateSDX.csproj
trunk/Drivers/AgateSDX/SDX_Display.cs
trunk/Drivers/AgateSDX/SDX_DisplayWindow.cs
trunk/Drivers/AgateSDX/Shaders/FixedFunction/SDX_FF_Basic2DShader.cs
trunk/Drivers/AgateSDX/Shaders/FixedFunction/SDX_FF_Lighting3D.cs
trunk/Drivers/AgateSDX/XAud2/XAudio2_Audio.cs
trunk/Tests/CoreTests/App.cs
Added Paths:
-----------
trunk/AgateLib/AudioLib/AudioCapsInfo.cs
Modified: trunk/AgateLib/AgateLib.csproj
===================================================================
--- trunk/AgateLib/AgateLib.csproj 2010-01-26 06:53:51 UTC (rev 1192)
+++ trunk/AgateLib/AgateLib.csproj 2010-01-28 17:19:40 UTC (rev 1193)
@@ -132,6 +132,7 @@
<Compile Include="AppInitParameters.cs">
<SubType>Code</SubType>
</Compile>
+ <Compile Include="AudioLib\AudioCapsInfo.cs" />
<Compile Include="AudioLib\ImplementationBase\MusicImpl.cs" />
<Compile Include="AudioLib\ImplementationBase\SoundBufferImpl.cs" />
<Compile Include="AudioLib\ImplementationBase\SoundBufferSessionImpl.cs" />
Modified: trunk/AgateLib/AudioLib/Audio.cs
===================================================================
--- trunk/AgateLib/AudioLib/Audio.cs 2010-01-26 06:53:51 UTC (rev 1192)
+++ trunk/AgateLib/AudioLib/Audio.cs 2010-01-28 17:19:40 UTC (rev 1193)
@@ -33,8 +33,16 @@
public static class Audio
{
private static AudioImpl impl;
+ private static AudioCapsInfo caps = new AudioCapsInfo();
/// <summary>
+ /// Gets the capabilities querying object for the audio subsystem.
+ /// </summary>
+ public static AudioCapsInfo Caps
+ {
+ get { return caps; }
+ }
+ /// <summary>
/// Gets the object which handles all of the actual calls to Audio functions.
/// </summary>
public static AudioImpl Impl
Added: trunk/AgateLib/AudioLib/AudioCapsInfo.cs
===================================================================
--- trunk/AgateLib/AudioLib/AudioCapsInfo.cs (rev 0)
+++ trunk/AgateLib/AudioLib/AudioCapsInfo.cs 2010-01-28 17:19:40 UTC (rev 1193)
@@ -0,0 +1,39 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using AgateLib.Geometry;
+
+namespace AgateLib.AudioLib
+{
+ /// <summary>
+ /// Class which can be used to query information about what features are supported
+ /// by the audio driver.
+ /// </summary>
+ public class AudioCapsInfo
+ {
+ internal AudioCapsInfo()
+ { }
+
+ /// <summary>
+ /// Indicates whether or not the application can stream audio to the
+ /// audio system by creating a StreamingSoundBuffer.
+ /// </summary>
+ public bool SupportsStreamingAudio
+ {
+ get { return Audio.Impl.CapsBool(AudioBoolCaps.StreamingSoundBuffer); }
+ }
+ }
+
+ /// <summary>
+ /// Testable boolean capabilities.
+ /// </summary>
+ public enum AudioBoolCaps
+ {
+ /// <summary>
+ /// Indicates whether or not the audio driver supports streaming audio
+ /// generated by the application.
+ /// </summary>
+ StreamingSoundBuffer,
+ }
+}
Modified: trunk/AgateLib/AudioLib/ImplementationBase/AudioImpl.cs
===================================================================
--- trunk/AgateLib/AudioLib/ImplementationBase/AudioImpl.cs 2010-01-26 06:53:51 UTC (rev 1192)
+++ trunk/AgateLib/AudioLib/ImplementationBase/AudioImpl.cs 2010-01-28 17:19:40 UTC (rev 1193)
@@ -94,6 +94,13 @@
}
+ /// <summary>
+ /// This function is called when a Caps property is inspected.
+ /// It should return false for any unknown value.
+ /// </summary>
+ /// <param name="audioBoolCaps"></param>
+ /// <returns></returns>
+ protected internal abstract bool CapsBool(AudioBoolCaps audioBoolCaps);
}
}
Modified: trunk/AgateLib/DisplayLib/DisplayWindow.cs
===================================================================
--- trunk/AgateLib/DisplayLib/DisplayWindow.cs 2010-01-26 06:53:51 UTC (rev 1192)
+++ trunk/AgateLib/DisplayLib/DisplayWindow.cs 2010-01-28 17:19:40 UTC (rev 1193)
@@ -245,7 +245,7 @@
get { return Size.Height; }
set
{
- Size = new Size(Size.Width, Size.Height);
+ Size = new Size(Size.Width, value);
}
}
Modified: trunk/AgateLib/Drivers/NullSoundImpl.cs
===================================================================
--- trunk/AgateLib/Drivers/NullSoundImpl.cs 2010-01-26 06:53:51 UTC (rev 1192)
+++ trunk/AgateLib/Drivers/NullSoundImpl.cs 2010-01-28 17:19:40 UTC (rev 1193)
@@ -168,5 +168,9 @@
return new NullMusicImpl();
}
+ protected internal override bool CapsBool(AgateLib.AudioLib.AudioBoolCaps audioBoolCaps)
+ {
+ return false;
+ }
}
}
Modified: trunk/Drivers/AgateFMOD/FMOD_Audio.cs
===================================================================
--- trunk/Drivers/AgateFMOD/FMOD_Audio.cs 2010-01-26 06:53:51 UTC (rev 1192)
+++ trunk/Drivers/AgateFMOD/FMOD_Audio.cs 2010-01-28 17:19:40 UTC (rev 1193)
@@ -118,6 +118,14 @@
CheckFMODResult(mSystem.update());
}
+ protected override bool CapsBool(AgateLib.AudioLib.AudioBoolCaps audioBoolCaps)
+ {
+ switch (audioBoolCaps)
+ {
+ default:
+ return false;
+ }
+ }
public override MusicImpl CreateMusic(System.IO.Stream musicStream)
{
string filename = SaveStreamToTempFile(musicStream);
Modified: trunk/Drivers/AgateSDL/Audio/SDL_Audio.cs
===================================================================
--- trunk/Drivers/AgateSDL/Audio/SDL_Audio.cs 2010-01-26 06:53:51 UTC (rev 1192)
+++ trunk/Drivers/AgateSDL/Audio/SDL_Audio.cs 2010-01-28 17:19:40 UTC (rev 1193)
@@ -61,6 +61,15 @@
tempfiles.Clear();
}
+ protected override bool CapsBool(AgateLib.AudioLib.AudioBoolCaps audioBoolCaps)
+ {
+ switch (audioBoolCaps)
+ {
+ default:
+ return false;
+ }
+ }
+
public override MusicImpl CreateMusic(string filename)
{
return new SDL_Music(filename);
Modified: trunk/Drivers/AgateSDX/AgateSDX.csproj
===================================================================
--- trunk/Drivers/AgateSDX/AgateSDX.csproj 2010-01-26 06:53:51 UTC (rev 1192)
+++ trunk/Drivers/AgateSDX/AgateSDX.csproj 2010-01-28 17:19:40 UTC (rev 1193)
@@ -1,7 +1,7 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
<PropertyGroup>
<ProjectType>Local</ProjectType>
- <ProductVersion>9.0.21022</ProductVersion>
+ <ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{EF993B30-D9A9-4962-80BB-6826D39B3465}</ProjectGuid>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@@ -205,6 +205,9 @@
<Name>AgateLib.WinForms</Name>
</ProjectReference>
</ItemGroup>
+ <ItemGroup>
+ <Folder Include="Shaders\Hlsl\" />
+ </ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
<PropertyGroup>
<PreBuildEvent>
Modified: trunk/Drivers/AgateSDX/SDX_Display.cs
===================================================================
--- trunk/Drivers/AgateSDX/SDX_Display.cs 2010-01-26 06:53:51 UTC (rev 1192)
+++ trunk/Drivers/AgateSDX/SDX_Display.cs 2010-01-28 17:19:40 UTC (rev 1193)
@@ -89,7 +89,7 @@
{
mDirect3Dobject = new SlimDX.Direct3D9.Direct3D();
- CreateFakeWindow();
+ //CreateFakeWindow();
Report("SlimDX driver instantiated for display.");
@@ -146,8 +146,10 @@
}
catch
{
- mHasDepth = false;
+ mHasDepth = true;
mHasStencil = false;
+
+ SetHaveDepthStencil(Format.D16);
}
//device.DeviceLost += new EventHandler(mDevice_DeviceLost);
@@ -192,8 +194,11 @@
public override void Dispose()
{
- mFakeDisplayWindow.Dispose();
- mFakeWindow.Dispose();
+ if (mFakeWindow != null)
+ {
+ mFakeDisplayWindow.Dispose();
+ mFakeWindow.Dispose();
+ }
mDevice.Dispose();
}
@@ -617,8 +622,8 @@
PresentParameters present = new PresentParameters();
present.BackBufferCount = 1;
- present.AutoDepthStencilFormat = GetDepthFormat(Format.A8R8G8B8);
- present.EnableAutoDepthStencil = true;
+ present.AutoDepthStencilFormat = Format.Unknown;
+ present.EnableAutoDepthStencil = false;
present.DeviceWindowHandle = displayWindow.RenderTarget.Handle;
present.BackBufferWidth = displayWindow.Width;
present.BackBufferHeight = displayWindow.Height;
Modified: trunk/Drivers/AgateSDX/SDX_DisplayWindow.cs
===================================================================
--- trunk/Drivers/AgateSDX/SDX_DisplayWindow.cs 2010-01-26 06:53:51 UTC (rev 1192)
+++ trunk/Drivers/AgateSDX/SDX_DisplayWindow.cs 2010-01-28 17:19:40 UTC (rev 1193)
@@ -296,6 +296,8 @@
frm.Show();
}
+
+ frm.ClientSize = new System.Drawing.Size(mChooseWidth, mChooseHeight);
}
private void CreateWindowedDisplay()
{
Modified: trunk/Drivers/AgateSDX/Shaders/FixedFunction/SDX_FF_Basic2DShader.cs
===================================================================
--- trunk/Drivers/AgateSDX/Shaders/FixedFunction/SDX_FF_Basic2DShader.cs 2010-01-26 06:53:51 UTC (rev 1192)
+++ trunk/Drivers/AgateSDX/Shaders/FixedFunction/SDX_FF_Basic2DShader.cs 2010-01-28 17:19:40 UTC (rev 1193)
@@ -16,7 +16,7 @@
public SDX_FF_Basic2DShader()
{
- mDevice = (AgateLib.DisplayLib.Display.Impl as SDX_Display).D3D_Device.Device;
+
}
public override AgateLib.Geometry.Rectangle CoordinateSystem
@@ -27,6 +27,8 @@
public void Set2DDrawState()
{
+ mDevice = (AgateLib.DisplayLib.Display.Impl as SDX_Display).D3D_Device.Device;
+
mDevice.SetRenderState(RenderState.SourceBlend, Blend.SourceAlpha);
mDevice.SetRenderState(RenderState.DestinationBlend, Blend.InverseSourceAlpha);
Modified: trunk/Drivers/AgateSDX/Shaders/FixedFunction/SDX_FF_Lighting3D.cs
===================================================================
--- trunk/Drivers/AgateSDX/Shaders/FixedFunction/SDX_FF_Lighting3D.cs 2010-01-26 06:53:51 UTC (rev 1192)
+++ trunk/Drivers/AgateSDX/Shaders/FixedFunction/SDX_FF_Lighting3D.cs 2010-01-28 17:19:40 UTC (rev 1193)
@@ -22,7 +22,8 @@
public SDX_FF_Lighting3D()
{
mDisplay = (SDX_Display)AgateLib.DisplayLib.Display.Impl;
- mLights = new AgateLib.DisplayLib.Shaders.Light[mDisplay.D3D_Device.Device.Capabilities.MaxActiveLights];
+ //mLights = new AgateLib.DisplayLib.Shaders.Light[mDisplay.D3D_Device.Device.Capabilities.MaxActiveLights];
+ mLights = new AgateLib.DisplayLib.Shaders.Light[8];
}
public override Color AmbientLight
{
Modified: trunk/Drivers/AgateSDX/XAud2/XAudio2_Audio.cs
===================================================================
--- trunk/Drivers/AgateSDX/XAud2/XAudio2_Audio.cs 2010-01-26 06:53:51 UTC (rev 1192)
+++ trunk/Drivers/AgateSDX/XAud2/XAudio2_Audio.cs 2010-01-28 17:19:40 UTC (rev 1193)
@@ -156,6 +156,16 @@
mDevice.Dispose();
}
+ protected override bool CapsBool(AgateLib.AudioLib.AudioBoolCaps audioBoolCaps)
+ {
+ switch (audioBoolCaps)
+ {
+ case AudioBoolCaps.StreamingSoundBuffer:
+ return true;
+ default:
+ return false;
+ }
+ }
public override SoundBufferImpl CreateSoundBuffer(Stream inStream)
{
return new XAudio2_SoundBuffer(this, inStream);
Modified: trunk/Tests/CoreTests/App.cs
===================================================================
--- trunk/Tests/CoreTests/App.cs 2010-01-26 06:53:51 UTC (rev 1192)
+++ trunk/Tests/CoreTests/App.cs 2010-01-28 17:19:40 UTC (rev 1193)
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using AgateLib;
+using AgateLib.InputLib;
namespace Tests.AppTester
{
@@ -17,11 +18,20 @@
initParams.AllowResize = true;
}
+
#region IAgateTest Members
public string Name { get { return "App Tester"; } }
public string Category { get { return "Core"; } }
#endregion
+
+ protected override void Update(double time_ms)
+ {
+ base.Update(time_ms);
+
+ if (Keyboard.Keys[KeyCode.Space])
+ Quit();
+ }
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2010-01-26 06:53:57
|
Revision: 1192
http://agate.svn.sourceforge.net/agate/?rev=1192&view=rev
Author: kanato
Date: 2010-01-26 06:53:51 +0000 (Tue, 26 Jan 2010)
Log Message:
-----------
Add boilerplate code for database editor.
Modified Paths:
--------------
trunk/AgateLib/Data/Column.cs
trunk/AgateLib/Data/ColumnDictionary.cs
trunk/AgateLib/Data/Row.cs
trunk/AgateLib/Data/RowList.cs
trunk/AgateLib/Data/Table.cs
Modified: trunk/AgateLib/Data/Column.cs
===================================================================
--- trunk/AgateLib/Data/Column.cs 2010-01-25 22:05:36 UTC (rev 1191)
+++ trunk/AgateLib/Data/Column.cs 2010-01-26 06:53:51 UTC (rev 1192)
@@ -16,6 +16,22 @@
private int nextAutoIncrementValue = 1;
private FieldType fieldType;
+
+ public Column Clone()
+ {
+ Column retval = new Column();
+
+ retval.name = name;
+ retval.description = description;
+ retval.tableLookup = tableLookup;
+ retval.lookupField = lookupField;
+ retval.primaryKey = primaryKey;
+ retval.nextAutoIncrementValue = nextAutoIncrementValue;
+ retval.fieldType = fieldType;
+
+ return retval;
+ }
+
#region IXleSerializable Members
void IXleSerializable.WriteData(XleSerializationInfo info)
@@ -98,29 +114,9 @@
public override string ToString()
{
- return DataHelper.CreatePrefixedLine(
- "Column",
- Name, FieldType, IsPrimaryKey, TableLookup, TableDisplayField, Description);
+ return "Column: " + Name;
}
- internal static Column FromString(string text)
- {
- if (text.StartsWith("Column:") == false)
- throw new AgateDatabaseException("Could not understand column text.");
- string[] data = DataHelper.Split(DataHelper.LineData(text));
-
- Column retval = new Column();
-
- retval.Name = data[0];
- retval.FieldType = (FieldType)Enum.Parse(typeof(FieldType), data[1]);
- retval.IsPrimaryKey = bool.Parse(data[2]);
- retval.TableLookup = data[3];
- retval.TableDisplayField = data[4];
- retval.Description = data[5];
-
- return retval;
- }
-
private void AssertIsValidName(string value)
{
if (IsValidColumnName(value))
@@ -135,5 +131,6 @@
return DataHelper.IsValidIdentifier(value);
}
+
}
}
Modified: trunk/AgateLib/Data/ColumnDictionary.cs
===================================================================
--- trunk/AgateLib/Data/ColumnDictionary.cs 2010-01-25 22:05:36 UTC (rev 1191)
+++ trunk/AgateLib/Data/ColumnDictionary.cs 2010-01-26 06:53:51 UTC (rev 1192)
@@ -42,6 +42,10 @@
public Column this[int index]
{
get { return mColumns[index]; }
+ internal set
+ {
+ mColumns[index] = value;
+ }
}
internal void Add(Column col)
@@ -61,6 +65,12 @@
{
get { return mColumns; }
}
+
+ public int Count
+ {
+ get { return mColumns.Count; }
+ }
+
#region IEnumerable<AgateColumn> Members
public IEnumerator<Column> GetEnumerator()
Modified: trunk/AgateLib/Data/Row.cs
===================================================================
--- trunk/AgateLib/Data/Row.cs 2010-01-25 22:05:36 UTC (rev 1191)
+++ trunk/AgateLib/Data/Row.cs 2010-01-26 06:53:51 UTC (rev 1192)
@@ -142,5 +142,13 @@
}
}
+
+ internal void OnColumnNameChange(string oldName, string newName)
+ {
+ string value = values[oldName];
+ values[newName] = value;
+
+ values.Remove(oldName);
+ }
}
}
Modified: trunk/AgateLib/Data/RowList.cs
===================================================================
--- trunk/AgateLib/Data/RowList.cs 2010-01-25 22:05:36 UTC (rev 1191)
+++ trunk/AgateLib/Data/RowList.cs 2010-01-26 06:53:51 UTC (rev 1192)
@@ -148,5 +148,13 @@
#endregion
+
+ internal void OnColumnNameChange(string oldName, string newName)
+ {
+ foreach (var row in this)
+ {
+ row.OnColumnNameChange(oldName, newName);
+ }
+ }
}
}
Modified: trunk/AgateLib/Data/Table.cs
===================================================================
--- trunk/AgateLib/Data/Table.cs 2010-01-25 22:05:36 UTC (rev 1191)
+++ trunk/AgateLib/Data/Table.cs 2010-01-26 06:53:51 UTC (rev 1192)
@@ -178,5 +178,41 @@
table.Rows.Add(row);
}
}
+
+ public void RemoveColumn(int index)
+ {
+ throw new NotImplementedException();
+ }
+
+ public void OverwriteColumn(int index, Column newColumn)
+ {
+ Column old = Columns[index];
+
+ Columns[index] = newColumn;
+
+ if (old.Name != newColumn.Name)
+ {
+ Rows.OnColumnNameChange(old.Name, newColumn.Name);
+ }
+
+ if (old.FieldType != newColumn.FieldType)
+ {
+ try
+ {
+ Validate();
+ }
+ catch
+ {
+ // validation of the data failed, so
+ // undo the column change and rethrow.
+ Columns[index] = old;
+
+ Rows.OnColumnNameChange(newColumn.Name, old.Name);
+
+ throw;
+ }
+ }
+
+ }
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2010-01-25 22:05:43
|
Revision: 1191
http://agate.svn.sourceforge.net/agate/?rev=1191&view=rev
Author: kanato
Date: 2010-01-25 22:05:36 +0000 (Mon, 25 Jan 2010)
Log Message:
-----------
Introduce the AgateLib.Data namespace with database implementation.
Modified Paths:
--------------
trunk/AgateLib/AgateLib.csproj
Added Paths:
-----------
trunk/AgateLib/Data/
trunk/AgateLib/Data/AgateDatabase.cs
trunk/AgateLib/Data/AgateDatabaseException.cs
trunk/AgateLib/Data/Column.cs
trunk/AgateLib/Data/ColumnDictionary.cs
trunk/AgateLib/Data/DataHelper.cs
trunk/AgateLib/Data/FieldType.cs
trunk/AgateLib/Data/Row.cs
trunk/AgateLib/Data/RowList.cs
trunk/AgateLib/Data/Table.cs
trunk/AgateLib/Data/TableDictionary.cs
Modified: trunk/AgateLib/AgateLib.csproj
===================================================================
--- trunk/AgateLib/AgateLib.csproj 2010-01-25 21:22:25 UTC (rev 1190)
+++ trunk/AgateLib/AgateLib.csproj 2010-01-25 22:05:36 UTC (rev 1191)
@@ -141,6 +141,16 @@
<Compile Include="Core.cs">
<SubType>Code</SubType>
</Compile>
+ <Compile Include="Data\AgateDatabaseException.cs" />
+ <Compile Include="Data\Column.cs" />
+ <Compile Include="Data\AgateDatabase.cs" />
+ <Compile Include="Data\Row.cs" />
+ <Compile Include="Data\Table.cs" />
+ <Compile Include="Data\ColumnDictionary.cs" />
+ <Compile Include="Data\DataHelper.cs" />
+ <Compile Include="Data\FieldType.cs" />
+ <Compile Include="Data\RowList.cs" />
+ <Compile Include="Data\TableDictionary.cs" />
<Compile Include="DisplayLib\FrameBuffer.cs" />
<Compile Include="DisplayLib\Shaders\AgateBuiltInShaders.cs" />
<Compile Include="DisplayLib\Shaders\Basic2DShader.cs" />
Added: trunk/AgateLib/Data/AgateDatabase.cs
===================================================================
--- trunk/AgateLib/Data/AgateDatabase.cs (rev 0)
+++ trunk/AgateLib/Data/AgateDatabase.cs 2010-01-25 22:05:36 UTC (rev 1191)
@@ -0,0 +1,168 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using AgateLib.Serialization.Xle;
+
+namespace AgateLib.Data
+{
+ /// <summary>
+ /// AgateDatabase implements a basic cross-platform relational database.
+ /// </summary>
+ /// <remarks>
+ /// This class is meant to meet not terribly complex needs to
+ /// retrieve type safe data stored in a relational database format at runtime.
+ /// The data is entirely loaded into memory when a database is loaded, thus
+ /// you would not want to use this to parse through a gigabyte of data.
+ /// It also does not handle any of the "usual" things you get with a real database system,
+ /// for instance there is no support for concurrent access.
+ /// There is no SQL query engine, however LINQ should be adequate
+ /// for any query needs.
+ /// </remarks>
+ public class AgateDatabase : IDisposable , IXleSerializable
+ {
+ private TableDictionary mTables;
+
+ public AgateDatabase()
+ {
+ mTables = new TableDictionary(this);
+ }
+ public static AgateDatabase FromFile(string filename)
+ {
+ AgateDatabase db = ReadDatabase(new AgateLib.Utility.ZipFileProvider(filename));
+ db.mTables.OwnFileProvider = true;
+
+ return db;
+ }
+ public static AgateDatabase FromProvider(IFileProvider provider)
+ {
+ return ReadDatabase(provider);
+ }
+
+ public void Dispose()
+ {
+ ((IDisposable)mTables).Dispose();
+ }
+
+
+ private static AgateDatabase ReadDatabase(IFileProvider provider)
+ {
+ XleSerializer ser = new XleSerializer(typeof(AgateDatabase));
+
+ using (Stream x = provider.OpenRead("catalog.txt"))
+ {
+ AgateDatabase retval = (AgateDatabase)ser.Deserialize(x);
+
+ retval.mTables.FileProvider = provider;
+
+ return retval;
+ }
+ }
+
+
+ #region IXleSerializable Members
+
+ void IXleSerializable.WriteData(XleSerializationInfo info)
+ {
+ info.Write("Version", "0.4.0");
+
+ info.Write("Tables", TableList.ToList());
+ }
+
+ void IXleSerializable.ReadData(XleSerializationInfo info)
+ {
+ string version = info.ReadString("Version");
+
+ if (version == "0.4.0")
+ {
+ List<string> tables = info.ReadList<string>("Tables");
+ mTables.AddUnloadedTable(tables);
+ }
+ else
+ throw new AgateDatabaseException("Unsupported database version.");
+
+ }
+
+ #endregion
+
+ private IEnumerable<string> TableList
+ {
+ get
+ {
+ return from x in mTables select x.Name;
+ }
+ }
+
+ /// <summary>
+ /// Forces all tables to load into memory, rather than
+ /// lazily loading them when requested.
+ /// </summary>
+ public void LoadAllTables()
+ {
+ mTables.LoadAllTables();
+
+ mTables.DisposeFileHandle();
+ }
+
+
+ /// <summary>
+ /// Gets the dictionary of tables in the database.
+ /// </summary>
+ public TableDictionary Tables
+ {
+ get { return mTables; }
+ }
+
+ public string CatalogString()
+ {
+ StringBuilder b = new StringBuilder();
+
+ b.AppendLine("Version:0.4.0");
+
+ foreach (var table in mTables)
+ {
+ b.Append("Table:");
+ b.Append(table.Name);
+ b.AppendLine();
+ }
+
+ return b.ToString();
+ }
+
+ /// <summary>
+ /// Validates the database to make sure it is correctly formed.
+ /// An AgateDatabaseException is thrown if it is not.
+ /// </summary>
+ public void Validate()
+ {
+ int errorCount = 0;
+ StringBuilder errors = new StringBuilder();
+
+ foreach (var table in mTables)
+ {
+
+ try
+ {
+ table.Validate();
+ }
+ catch (AgateDatabaseException e)
+ {
+ errorCount += e.ErrorCount;
+ errors.Append(e.Message);
+ }
+ }
+
+ if (errorCount > 0)
+ {
+ throw new AgateDatabaseException(
+ "There {0} {1} error{2} in validating the database:{3}{4}",
+ errorCount == 1 ? "was" : "were",
+ errorCount,
+ errorCount == 1 ? "" : "s",
+ Environment.NewLine,
+ errors);
+ }
+ }
+ }
+}
Added: trunk/AgateLib/Data/AgateDatabaseException.cs
===================================================================
--- trunk/AgateLib/Data/AgateDatabaseException.cs (rev 0)
+++ trunk/AgateLib/Data/AgateDatabaseException.cs 2010-01-25 22:05:36 UTC (rev 1191)
@@ -0,0 +1,42 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace AgateLib.Data
+{
+ [global::System.Serializable]
+ public class AgateDatabaseException : AgateException
+ {
+ //
+ // For guidelines regarding the creation of new exception types, see
+ // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconerrorraisinghandlingguidelines.asp
+ // and
+ // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dncscol/html/csharp07192001.asp
+ //
+
+ public AgateDatabaseException() { ErrorCount = 1; }
+ public AgateDatabaseException(string message) : base(message) { ErrorCount = 1; }
+ public AgateDatabaseException(string message, Exception inner) : base(message, inner) { ErrorCount = 1; }
+ public AgateDatabaseException(string format, params object[] args)
+ : base(format, args)
+ { ErrorCount = 1; }
+ internal AgateDatabaseException(int errorCount, string message)
+ : base(message)
+ {
+ ErrorCount = errorCount;
+ }
+ internal AgateDatabaseException(int errorCount, string format, params object[] args)
+ : base(format, args)
+ {
+ ErrorCount = errorCount;
+ }
+
+ protected AgateDatabaseException(
+ System.Runtime.Serialization.SerializationInfo info,
+ System.Runtime.Serialization.StreamingContext context)
+ : base(info, context) { }
+
+ internal int ErrorCount { get; set; }
+ }
+}
Added: trunk/AgateLib/Data/Column.cs
===================================================================
--- trunk/AgateLib/Data/Column.cs (rev 0)
+++ trunk/AgateLib/Data/Column.cs 2010-01-25 22:05:36 UTC (rev 1191)
@@ -0,0 +1,139 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using AgateLib.Serialization.Xle;
+
+namespace AgateLib.Data
+{
+ public class Column : IXleSerializable
+ {
+ private string name;
+ private string description;
+ private string tableLookup;
+ private string lookupField;
+ private bool primaryKey;
+ private int nextAutoIncrementValue = 1;
+ private FieldType fieldType;
+
+ #region IXleSerializable Members
+
+ void IXleSerializable.WriteData(XleSerializationInfo info)
+ {
+ info.Write("Name", name, true);
+ info.WriteEnum("FieldType", fieldType, true);
+
+ if (fieldType == FieldType.AutoNumber)
+ info.Write("NextValue", nextAutoIncrementValue, true);
+ if (primaryKey)
+ info.Write("PrimaryKey", primaryKey, true);
+
+ info.Write("Description", description);
+
+ if (string.IsNullOrEmpty(tableLookup) == false)
+ {
+ info.Write("TableLookup", tableLookup);
+ info.Write("LookupField", lookupField);
+ }
+ }
+
+ void IXleSerializable.ReadData(XleSerializationInfo info)
+ {
+ name = info.ReadString("Name");
+ fieldType = info.ReadEnum<FieldType>("FieldType");
+ nextAutoIncrementValue = info.ReadInt32("NextValue", 1);
+ primaryKey = info.ReadBoolean("PrimaryKey", false);
+ description = info.ReadString("Description");
+ tableLookup = info.ReadString("TableLookup", string.Empty);
+ lookupField = info.ReadString("LookupField", string.Empty);
+ }
+
+ #endregion
+
+ public int NextAutoIncrementValue
+ {
+ get { return nextAutoIncrementValue; }
+ }
+
+ internal void IncrementNextAutoIncrementValue()
+ {
+ nextAutoIncrementValue++;
+ }
+
+ public string Name
+ {
+ get { return name; }
+ set
+ {
+ AssertIsValidName(value);
+
+ name = value;
+ }
+ }
+ public FieldType FieldType
+ {
+ get { return fieldType; }
+ set { fieldType = value; }
+ }
+ public bool IsPrimaryKey
+ {
+ get { return primaryKey; }
+ set { primaryKey = value; }
+ }
+ public string TableLookup
+ {
+ get { return tableLookup; }
+ set { tableLookup = value; }
+ }
+ public string TableDisplayField
+ {
+ get { return lookupField; }
+ set { lookupField = value; }
+ }
+ public string Description
+ {
+ get { return description; }
+ set { description = value; }
+ }
+
+ public override string ToString()
+ {
+ return DataHelper.CreatePrefixedLine(
+ "Column",
+ Name, FieldType, IsPrimaryKey, TableLookup, TableDisplayField, Description);
+ }
+ internal static Column FromString(string text)
+ {
+ if (text.StartsWith("Column:") == false)
+ throw new AgateDatabaseException("Could not understand column text.");
+
+ string[] data = DataHelper.Split(DataHelper.LineData(text));
+
+ Column retval = new Column();
+
+ retval.Name = data[0];
+ retval.FieldType = (FieldType)Enum.Parse(typeof(FieldType), data[1]);
+ retval.IsPrimaryKey = bool.Parse(data[2]);
+ retval.TableLookup = data[3];
+ retval.TableDisplayField = data[4];
+ retval.Description = data[5];
+
+ return retval;
+ }
+
+ private void AssertIsValidName(string value)
+ {
+ if (IsValidColumnName(value))
+ return;
+
+ throw new ArgumentException(string.Format(
+ "Invalid name \"{0}\" supplied. Column name should be a valid C# or VB identifier.", value));
+ }
+
+ public static bool IsValidColumnName(string value)
+ {
+ return DataHelper.IsValidIdentifier(value);
+ }
+
+ }
+}
Added: trunk/AgateLib/Data/ColumnDictionary.cs
===================================================================
--- trunk/AgateLib/Data/ColumnDictionary.cs (rev 0)
+++ trunk/AgateLib/Data/ColumnDictionary.cs 2010-01-25 22:05:36 UTC (rev 1191)
@@ -0,0 +1,84 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using AgateLib.Serialization.Xle;
+
+namespace AgateLib.Data
+{
+ public class ColumnDictionary : IEnumerable<Column>
+ {
+ Table mParentTable;
+ List<Column> mColumns = new List<Column>();
+
+ private ColumnDictionary() { }
+ internal ColumnDictionary(Table parentTable)
+ {
+ mParentTable = parentTable;
+ }
+ internal ColumnDictionary(Table parentTable, List<Column> columns)
+ {
+ mParentTable = parentTable;
+ mColumns = columns;
+ }
+ internal Table ParentTable
+ {
+ get { return mParentTable; }
+ set { mParentTable = value; }
+ }
+
+ public Column this[string name]
+ {
+ get
+ {
+ var result = mColumns.First(x => x.Name == name);
+
+ if (result == null)
+ throw new ArgumentException("Column does not exist.");
+
+ return result;
+ }
+ }
+ public Column this[int index]
+ {
+ get { return mColumns[index]; }
+ }
+
+ internal void Add(Column col)
+ {
+ if (mColumns.Any(x => x.Name == col.Name))
+ throw new ArgumentException("Column " + col.Name + " already exists.");
+
+ mColumns.Add(col);
+ }
+
+ public override string ToString()
+ {
+ return "Columns: " + mColumns.Count;
+ }
+
+ internal List<Column> ColumnList
+ {
+ get { return mColumns; }
+ }
+ #region IEnumerable<AgateColumn> Members
+
+ public IEnumerator<Column> GetEnumerator()
+ {
+ return mColumns.GetEnumerator();
+ }
+
+ #endregion
+
+ #region IEnumerable Members
+
+ System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
+ {
+ return GetEnumerator();
+ }
+
+ #endregion
+
+
+ }
+}
Added: trunk/AgateLib/Data/DataHelper.cs
===================================================================
--- trunk/AgateLib/Data/DataHelper.cs (rev 0)
+++ trunk/AgateLib/Data/DataHelper.cs 2010-01-25 22:05:36 UTC (rev 1191)
@@ -0,0 +1,120 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Reflection;
+using System.Text;
+using System.Text.RegularExpressions;
+
+namespace AgateLib.Data
+{
+ static class DataHelper
+ {
+ public static string FixString(string value)
+ {
+ if (value == null)
+ return null;
+
+ // replace single quotes with double quotes.
+ value = value.Replace("\"", "\"\"");
+
+ if (value.Contains(" ") || value.Contains(",") || value.Contains("\""))
+ {
+ value = "\"" + value + "\"";
+ }
+
+ return value;
+ }
+
+ public static string UnfixString(string value)
+ {
+ if (value == null)
+ return null;
+
+ // replace double quotes with single
+ value = value.Replace("\"\"", "\"");
+
+ if (value.StartsWith("\"") && value.EndsWith("\""))
+ {
+ value = value.Substring(1, value.Length - 2);
+ }
+
+ return value;
+ }
+
+ internal static Type GetType(FieldType fieldType)
+ {
+ DataTypeAttribute[] dataType = (DataTypeAttribute[])
+ typeof(FieldType).GetField(fieldType.ToString()).GetCustomAttributes(typeof(DataTypeAttribute), false);
+
+ return dataType[0].DataType;
+ }
+
+ static Regex identifier = new Regex(@"[a-zA-Z_][a-zA-Z_0-9]*");
+
+ internal static bool IsValidIdentifier(string value)
+ {
+ return identifier.IsMatch(value);
+ }
+
+ internal static string LineType(string line)
+ {
+ int colon = line.IndexOf(":");
+
+ return line.Substring(0, colon);
+ }
+
+ internal static string LineData(string line)
+ {
+ int colon = line.IndexOf(":");
+
+ return line.Substring(colon + 1);
+ }
+
+ internal static string[] Split(string p)
+ {
+ List<string> data = new List<string>();
+
+ int start = 0;
+ bool inQuotes = false;
+
+ for (int i = 0; i < p.Length; i++)
+ {
+ if (p[i] == '"')
+ {
+ inQuotes = !inQuotes;
+ }
+
+ if (inQuotes == false && p[i] == ',')
+ {
+ string value = p.Substring(start, i - start);
+ data.Add(value);
+ start = i + 1;
+ }
+ }
+
+ data.Add(p.Substring(start));
+
+ return data.ToArray();
+ }
+
+ internal static string CreatePrefixedLine(string p, params object[] values)
+ {
+ StringBuilder b = new StringBuilder();
+
+ b.AppendFormat("{0}:", p);
+
+ for (int i = 0; i < values.Length; i++)
+ {
+ if (i > 0)
+ b.Append(",");
+
+ if (values[i] != null)
+ {
+ b.Append(values[i].ToString());
+ }
+ }
+
+ return b.ToString();
+ }
+ }
+}
Added: trunk/AgateLib/Data/FieldType.cs
===================================================================
--- trunk/AgateLib/Data/FieldType.cs (rev 0)
+++ trunk/AgateLib/Data/FieldType.cs 2010-01-25 22:05:36 UTC (rev 1191)
@@ -0,0 +1,50 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace AgateLib.Data
+{
+ public enum FieldType
+ {
+ [DataType(typeof(String))]
+ String,
+ [DataType(typeof(Boolean))]
+ Boolean,
+ [DataType(typeof(Int16))]
+ Int16,
+ [DataType(typeof(Int32))]
+ Int32,
+ [DataType(typeof(UInt16))]
+ UInt16,
+ [DataType(typeof(UInt32))]
+ UInt32,
+ [DataType(typeof(Byte))]
+ Byte,
+ [DataType(typeof(SByte))]
+ SByte,
+ [DataType(typeof(Single))]
+ Single,
+ [DataType(typeof(Double))]
+ Double,
+ [DataType(typeof(Decimal))]
+ Decimal,
+ [DataType(typeof(DateTime))]
+ DateTime,
+ [DataType(typeof(Int32))]
+ AutoNumber,
+ }
+
+ [global::System.AttributeUsage(AttributeTargets.Field, Inherited = false, AllowMultiple = true)]
+ sealed class DataTypeAttribute : Attribute
+ {
+ readonly Type dataType;
+
+ public DataTypeAttribute(Type dataType)
+ {
+ this.dataType = dataType;
+ }
+
+ public Type DataType { get { return dataType; } }
+ }
+}
Added: trunk/AgateLib/Data/Row.cs
===================================================================
--- trunk/AgateLib/Data/Row.cs (rev 0)
+++ trunk/AgateLib/Data/Row.cs 2010-01-25 22:05:36 UTC (rev 1191)
@@ -0,0 +1,146 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace AgateLib.Data
+{
+ public class Row
+ {
+ Dictionary<string, string> values = new Dictionary<string, string>();
+ Table parentTable;
+
+ public Row(Table parentTable)
+ {
+ this.parentTable = parentTable;
+
+ foreach (var column in parentTable.Columns)
+ {
+ values[column.Name] = null;
+ }
+ }
+
+ public Row Clone()
+ {
+ Row retval = new Row(parentTable);
+
+ foreach (var value in values)
+ retval.values[value.Key] = value.Value;
+
+ return retval;
+ }
+ public Table ParentTable
+ {
+ get { return parentTable; }
+ internal set
+ {
+ parentTable = value;
+
+ if (parentTable != null)
+ {
+ ValidateData(parentTable);
+ }
+ }
+ }
+
+ /// <summary>
+ /// Shortcut for this[column.Name].
+ /// </summary>
+ /// <param name="column"></param>
+ /// <returns></returns>
+ public string this[Column column]
+ {
+ get { return values[column.Name]; }
+ set
+ {
+ ValidateTypeOrThrow(column.Name, value);
+
+ if (column.FieldType == FieldType.AutoNumber)
+ throw new AgateDatabaseException("Cannot write to autonumber field.");
+
+ values[column.Name] = value;
+ }
+ }
+ public string this[string key]
+ {
+ get { return values[key]; }
+ set
+ {
+ this[parentTable.Columns[key]] = value;
+
+ values[key] = value;
+ }
+ }
+
+ internal void WriteWithoutValidation(Column column, string value)
+ {
+ values[column.Name] = value;
+ }
+
+ public override string ToString()
+ {
+ StringBuilder b = new StringBuilder();
+ int count = 0;
+
+ foreach (var column in parentTable.Columns)
+ {
+ string value = DataHelper.FixString(this[column.Name]);
+
+ if (count > 0)
+ b.Append(",");
+
+ b.Append(value);
+
+ count++;
+ }
+
+ return b.ToString();
+ }
+
+ private void ValidateTypeOrThrow(string key, string value)
+ {
+ Convert.ChangeType(value, DataHelper.GetType(parentTable.Columns[key].FieldType));
+ }
+
+ internal void ValidateData(Table agateTable)
+ {
+ foreach (var column in agateTable.Columns)
+ {
+ if (column.FieldType == FieldType.AutoNumber &&
+ (values.ContainsKey(column.Name) == false ||
+ values[column.Name] == null))
+ {
+ int value = column.NextAutoIncrementValue;
+ column.IncrementNextAutoIncrementValue();
+
+ values[column.Name] = value.ToString();
+ }
+
+ if (values.ContainsKey(column.Name))
+ {
+ ValidateTypeOrThrow(column.Name, values[column.Name]);
+ }
+ else
+ {
+ values.Add(column.Name, null);
+ }
+
+ if (column.IsPrimaryKey)
+ {
+ var matches = from x in agateTable.Rows
+ where x != null && x[column] == this[column]
+ select x;
+
+ List<Row> l = matches.ToList();
+ l.Remove(this);
+
+ if (l.Count > 0)
+ {
+ throw new AgateDatabaseException("The primary key is alread present.");
+ }
+ }
+ }
+ }
+
+ }
+}
Added: trunk/AgateLib/Data/RowList.cs
===================================================================
--- trunk/AgateLib/Data/RowList.cs (rev 0)
+++ trunk/AgateLib/Data/RowList.cs 2010-01-25 22:05:36 UTC (rev 1191)
@@ -0,0 +1,152 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using AgateLib.Serialization.Xle;
+
+namespace AgateLib.Data
+{
+ public class RowList : IList<Row>
+ {
+ Table mParentTable;
+ List<Row> mRows = new List<Row>();
+
+ private RowList() { }
+ internal RowList(Table parentTable)
+ {
+ mParentTable = parentTable;
+ }
+ internal RowList(Table parentTable, List<Row> rows)
+ {
+ mParentTable = parentTable;
+ mRows = rows;
+ }
+
+ internal Table ParentTable
+ {
+ get { return mParentTable; }
+ set { mParentTable = value; }
+ }
+
+
+ public void ForEach(Action<Row> action)
+ {
+ mRows.ForEach(action);
+ }
+
+ public override string ToString()
+ {
+ return "Rows: " + mRows.Count;
+ }
+
+ #region IList<AgateRow> Members
+
+ public int IndexOf(Row item)
+ {
+ return mRows.IndexOf(item);
+ }
+
+ public void Insert(int index, Row item)
+ {
+ item.ValidateData(mParentTable);
+ item.ParentTable = mParentTable;
+
+ mRows.Insert(index, item);
+ }
+
+ public void RemoveAt(int index)
+ {
+ this[index].ParentTable = null;
+ mRows.RemoveAt(index);
+ }
+
+ public Row this[int index]
+ {
+ get
+ {
+ return mRows[index];
+ }
+ set
+ {
+ Row old = mRows[index];
+
+ try
+ {
+ mRows[index] = null;
+
+ value.ValidateData(mParentTable);
+ }
+ catch
+ {
+ mRows[index] = old;
+ throw;
+ }
+
+ mRows[index] = value;
+ }
+ }
+
+ #endregion
+
+ #region ICollection<AgateRow> Members
+
+ public void Add(Row row)
+ {
+ row.ParentTable.Rows.Remove(row);
+ row.ParentTable = mParentTable;
+
+ mRows.Add(row);
+ }
+
+ public void Clear()
+ {
+ mRows.Clear();
+ }
+
+ public bool Contains(Row item)
+ {
+ return mRows.Contains(item);
+ }
+
+ public void CopyTo(Row[] array, int arrayIndex)
+ {
+ mRows.CopyTo(array, arrayIndex);
+ }
+
+ public int Count
+ {
+ get { return mRows.Count; }
+ }
+
+ public bool IsReadOnly
+ {
+ get { return false; }
+ }
+
+ public bool Remove(Row item)
+ {
+ return mRows.Remove(item);
+ }
+
+ #endregion
+
+ #region IEnumerable<AgateRow> Members
+
+ public IEnumerator<Row> GetEnumerator()
+ {
+ return mRows.GetEnumerator();
+ }
+
+ #endregion
+
+ #region IEnumerable Members
+
+ System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
+ {
+ return GetEnumerator();
+ }
+
+ #endregion
+
+ }
+}
Added: trunk/AgateLib/Data/Table.cs
===================================================================
--- trunk/AgateLib/Data/Table.cs (rev 0)
+++ trunk/AgateLib/Data/Table.cs 2010-01-25 22:05:36 UTC (rev 1191)
@@ -0,0 +1,182 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using AgateLib.Serialization.Xle;
+
+namespace AgateLib.Data
+{
+ public class Table : IXleSerializable
+ {
+ string mName;
+ RowList mRows;
+ ColumnDictionary mColumns;
+
+ #region --- Construction and Serialization ---
+
+ public Table()
+ {
+ mColumns = new ColumnDictionary(this);
+ mRows = new RowList(this);
+ }
+
+ internal static Table FromStream(Stream stream)
+ {
+ XleSerializer ser = new XleSerializer(typeof(Table));
+
+ return (Table)ser.Deserialize(stream);
+ }
+
+ void IXleSerializable.WriteData(XleSerializationInfo info)
+ {
+ info.Write("Name", mName);
+ info.Write("Version", "0.4.0");
+ info.Write("Columns", mColumns.ColumnList);
+ info.Write("Rows", RowString());
+ }
+
+ void IXleSerializable.ReadData(XleSerializationInfo info)
+ {
+ mName = info.ReadString("Name");
+
+ string version = info.ReadString("Version");
+
+ if (version == "0.4.0")
+ {
+ mColumns = new ColumnDictionary(this, info.ReadList<Column>("Columns"));
+ mRows = new RowList(this, ReadRows(info.ReadString("Rows")));
+ }
+ else
+ throw new AgateDatabaseException("Unsupported database version.");
+ }
+
+ private string RowString()
+ {
+ StringBuilder b = new StringBuilder();
+
+ mRows.ForEach(x => b.AppendLine(x.ToString()));
+
+ return b.ToString();
+ }
+
+ static readonly char[] lineSplitChars = new char[] { '\n', '\r' };
+
+ private List<Row> ReadRows(string rows)
+ {
+ List<Row> retval = new List<Row>();
+
+ string[] lines = rows.Split(lineSplitChars, StringSplitOptions.RemoveEmptyEntries);
+
+ foreach (string line in lines)
+ {
+ string[] data = DataHelper.Split(line);
+
+ Row row = new Row(this);
+
+ int i = 0;
+ foreach (var column in Columns)
+ {
+ row.WriteWithoutValidation(column, data[i]);
+ i++;
+ }
+
+ retval.Add(row);
+ }
+
+ return retval;
+ }
+
+ #endregion
+
+ public string Name
+ {
+ get { return mName; }
+ set
+ {
+ AssertIsValidName(value);
+
+ mName = value;
+ }
+ }
+
+ private void AssertIsValidName(string value)
+ {
+ if (IsValidTableName(value))
+ return;
+
+ throw new ArgumentException("Invalid name. Table name should be a valid C# or VB identifier.");
+ }
+
+ public static bool IsValidTableName(string value)
+ {
+ return DataHelper.IsValidIdentifier(value);
+ }
+
+ public ColumnDictionary Columns
+ {
+ get { return mColumns; }
+ }
+ public RowList Rows
+ {
+ get { return mRows; }
+ }
+
+ public void AddColumn(Column col)
+ {
+ mColumns.Add(col);
+
+ mRows.ForEach(x => x.ValidateData(this));
+ }
+
+ public override string ToString()
+ {
+ StringBuilder b = new StringBuilder();
+
+ b.Append("Name:");
+ b.AppendLine(Name);
+
+ foreach (var column in mColumns)
+ {
+ b.AppendLine(column.ToString());
+ }
+
+ b.AppendLine("Rows:");
+
+ foreach (var row in mRows)
+ {
+ b.AppendLine(row.ToString());
+ }
+
+ return b.ToString();
+ }
+
+ internal void Validate()
+ {
+ foreach (var row in mRows)
+ row.ValidateData(this);
+ }
+
+
+ private static void ReadRows(Table table, StreamReader r)
+ {
+ while (r.EndOfStream == false)
+ {
+ string line = r.ReadLine();
+
+ string[] data = DataHelper.Split(line);
+
+ Row row = new Row(table);
+
+ int i = 0;
+ foreach (var column in table.Columns)
+ {
+ row[column] = data[i];
+ i++;
+ }
+
+ table.Rows.Add(row);
+ }
+ }
+ }
+}
Added: trunk/AgateLib/Data/TableDictionary.cs
===================================================================
--- trunk/AgateLib/Data/TableDictionary.cs (rev 0)
+++ trunk/AgateLib/Data/TableDictionary.cs 2010-01-25 22:05:36 UTC (rev 1191)
@@ -0,0 +1,143 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+
+namespace AgateLib.Data
+{
+ public class TableDictionary : IEnumerable<Table>, IDisposable
+ {
+ List<Table> mTables = new List<Table>();
+ AgateDatabase mParentDatabase;
+ List<string> mUnloadedTables = new List<string>();
+
+ internal TableDictionary(AgateDatabase parentDatabase)
+ {
+ mParentDatabase = parentDatabase;
+ }
+
+ void IDisposable.Dispose()
+ {
+ DisposeFileHandle();
+ }
+
+
+ internal void DisposeFileHandle()
+ {
+ if (OwnFileProvider)
+ {
+ AgateLib.Utility.ZipFileProvider zip = FileProvider as AgateLib.Utility.ZipFileProvider;
+
+ if (zip != null)
+ {
+ zip.Dispose();
+ }
+ }
+ }
+
+ internal IFileProvider FileProvider { get; set; }
+ internal bool OwnFileProvider { get; set; }
+
+ public Table this[string name]
+ {
+ get
+ {
+ bool loaded = false;
+
+ if (mUnloadedTables.Contains(name))
+ {
+ loaded = true;
+ LoadTable(name);
+ mUnloadedTables.Remove(name);
+ }
+
+ var result = mTables.First(x => x.Name == name);
+
+ if (result == null)
+ {
+ if (loaded)
+ throw new AgateException(
+ "BUG: Table was loaded but did not exist in database." +
+ "Probably, the table is corrupt, but an exception should have been thrown.");
+
+ throw new ArgumentException("Table does not exist.");
+ }
+
+ return result;
+ }
+ }
+
+ private void LoadTable(string name)
+ {
+ string filename = string.Format("data/{0}.txt", name);
+
+ using (Stream r = FileProvider.OpenRead(filename))
+ {
+ Table tbl = Table.FromStream(r);
+
+ mTables.Add(tbl);
+ }
+ }
+
+
+ internal void LoadAllTables()
+ {
+ foreach (var table in mUnloadedTables)
+ {
+ LoadTable(table);
+ }
+
+ mUnloadedTables.Clear();
+ }
+
+ public Table this[int index]
+ {
+ get { return mTables[index]; }
+ }
+
+ public void Add(Table tbl)
+ {
+ if (mTables.Any(x => x.Name == tbl.Name))
+ throw new ArgumentException("Table " + tbl.Name + " already exists.");
+
+ mTables.Add(tbl);
+ }
+
+ internal void AddUnloadedTable(string name)
+ {
+ mUnloadedTables.Add(name);
+ }
+ internal void AddUnloadedTable(IEnumerable<string> tables)
+ {
+ mUnloadedTables.AddRange(tables);
+ }
+ public override string ToString()
+ {
+ return "Tables: " + mTables.Count;
+ }
+
+
+ #region IEnumerable<Table> Members
+
+ public IEnumerator<Table> GetEnumerator()
+ {
+ LoadAllTables();
+
+ return mTables.GetEnumerator();
+ }
+
+ #endregion
+
+ #region IEnumerable Members
+
+ System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
+ {
+ return GetEnumerator();
+ }
+
+ #endregion
+
+
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2010-01-25 21:22:31
|
Revision: 1190
http://agate.svn.sourceforge.net/agate/?rev=1190&view=rev
Author: kanato
Date: 2010-01-25 21:22:25 +0000 (Mon, 25 Jan 2010)
Log Message:
-----------
Make ZipFileProvider disposable.
Modified Paths:
--------------
trunk/AgateLib/Utility/ZipFileProvider.cs
Modified: trunk/AgateLib/Utility/ZipFileProvider.cs
===================================================================
--- trunk/AgateLib/Utility/ZipFileProvider.cs 2010-01-25 21:21:56 UTC (rev 1189)
+++ trunk/AgateLib/Utility/ZipFileProvider.cs 2010-01-25 21:22:25 UTC (rev 1190)
@@ -14,7 +14,7 @@
/// ZipFileProvider is the deflate method, so you must make sure that any compressed
/// data in the zip file is compressed with deflate.
/// </summary>
- public class ZipFileProvider : IFileProvider
+ public class ZipFileProvider : IFileProvider, IDisposable
{
string zipFilename;
Stream inFile;
@@ -161,11 +161,15 @@
ScanArchive();
}
+ public void Dispose()
+ {
+ inFile.Dispose();
+ }
+
private void ScanArchive()
{
ReadHeaders();
}
-
private void ReadHeaders()
{
FileHeader header;
@@ -193,7 +197,6 @@
} while (inFile.Position < inFile.Length);
}
-
private void ReadFileHeader(BinaryReader reader, out FileHeader header)
{
short ver = reader.ReadInt16();
@@ -314,6 +317,7 @@
}
#endregion
+
}
enum ZipStorageType
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2010-01-25 21:22:02
|
Revision: 1189
http://agate.svn.sourceforge.net/agate/?rev=1189&view=rev
Author: kanato
Date: 2010-01-25 21:21:56 +0000 (Mon, 25 Jan 2010)
Log Message:
-----------
Add ReadBoolean overload with default parameter.
Modified Paths:
--------------
trunk/AgateLib/Serialization/Xle/XleSerializationInfo.cs
Modified: trunk/AgateLib/Serialization/Xle/XleSerializationInfo.cs
===================================================================
--- trunk/AgateLib/Serialization/Xle/XleSerializationInfo.cs 2010-01-25 20:58:52 UTC (rev 1188)
+++ trunk/AgateLib/Serialization/Xle/XleSerializationInfo.cs 2010-01-25 21:21:56 UTC (rev 1189)
@@ -878,6 +878,21 @@
/// <returns></returns>
public bool ReadBoolean(string name)
{
+ return ReadBooleanImpl(name, false, false);
+ }
+ /// <summary>
+ /// Reads a boolean value from the XML data. If the name is not present
+ /// the default value is returned.
+ /// </summary>
+ /// <param name="name">Name of the field.</param>
+ /// <param name="defaultValue">Default value to return if the field is not present.</param>
+ /// <returns></returns>
+ public bool ReadBoolean(string name, bool defaultValue)
+ {
+ return ReadBooleanImpl(name, true, defaultValue);
+ }
+ private bool ReadBooleanImpl(string name, bool hasDefault, bool defaultValue)
+ {
string attribute = CurrentNode.GetAttribute(name);
if (string.IsNullOrEmpty(attribute) == false)
@@ -886,7 +901,12 @@
XmlElement element = (XmlElement)CurrentNode[name];
if (element == null)
- throw new XleSerializationException("Node " + name + " not found.");
+ {
+ if (hasDefault)
+ return defaultValue;
+ else
+ throw new XleSerializationException("Node " + name + " not found.");
+ }
return bool.Parse(element.InnerText);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ka...@us...> - 2010-01-25 20:59:02
|
Revision: 1188
http://agate.svn.sourceforge.net/agate/?rev=1188&view=rev
Author: kanato
Date: 2010-01-25 20:58:52 +0000 (Mon, 25 Jan 2010)
Log Message:
-----------
Add writing enums.
Disable gl3 stuff which isn't working yet.
Modified Paths:
--------------
trunk/AgateLib/Serialization/Xle/XleSerializationInfo.cs
trunk/Drivers/AgateOTK/GL_Display.cs
trunk/TODO.txt
Modified: trunk/AgateLib/Serialization/Xle/XleSerializationInfo.cs
===================================================================
--- trunk/AgateLib/Serialization/Xle/XleSerializationInfo.cs 2010-01-24 22:16:52 UTC (rev 1187)
+++ trunk/AgateLib/Serialization/Xle/XleSerializationInfo.cs 2010-01-25 20:58:52 UTC (rev 1188)
@@ -189,7 +189,22 @@
WriteImpl(name, value ?? string.Empty, asAttribute);
}
+
/// <summary>
+ /// Writes an enum field to the XML data as an element or an attribute.
+ /// </summary>
+ /// <typeparam name="T">Type of the enum. If this is not an enum type, an exception is thrown</typeparam>
+ /// <param name="name">The name of the XML element used.</param>
+ /// <param name="value">The value to write.</param>
+ /// <param name="asAttribute">Pass true to write the field as an attribute in the parent element.</param>
+ public void WriteEnum<T>(string name, T value, bool asattribute) where T : struct
+ {
+ if (typeof(T).IsEnum == false)
+ throw new XleSerializationException("Type passed is not an enum.");
+
+ WriteImpl(name, value.ToString(), asattribute);
+ }
+ /// <summary>
/// Writes a field to the XML data as an element or an attribute.
/// </summary>
/// <param name="name">The name of the XML element used.</param>
@@ -918,7 +933,34 @@
return int.Parse(element.InnerText);
}
+
/// <summary>
+ /// Reads an enum field from the XML data.
+ /// </summary>
+ /// <typeparam name="T">Type of the enum. If this is not an enum type, an exception is thrown.</typeparam>
+ /// <param name="name">The name of the XML element used.</param>
+ public T ReadEnum<T>(string name) where T : struct
+ {
+ if (typeof(T).IsEnum == false)
+ throw new XleSerializationException("Type passed is not an enum.");
+
+ return (T)Enum.Parse(typeof(T), ReadStringImpl(name, false, string.Empty));
+ }
+ /// <summary>
+ /// Reads an enum field from the XML data.
+ /// </summary>
+ /// <typeparam name="T">Type of the enum. If this is not an enum type, an exception is thrown.</typeparam>
+ /// <param name="name">The name of the XML element used.</param>
+ /// <param name="defaultValue">Value returned if the key is not present in the XML data.</param>
+ public T ReadEnum<T>(string name, T defaultValue) where T : struct
+ {
+ if (typeof(T).IsEnum == false)
+ throw new XleSerializationException("Type passed is not an enum.");
+
+ return (T)Enum.Parse(typeof(T), ReadStringImpl(name, true, defaultValue.ToString()));
+ }
+
+ /// <summary>
/// Reads a double value from the XML data. If the name is not present
/// an XleSerializationException is thrown.
/// </summary>
@@ -1164,6 +1206,8 @@
}
+
+
#endregion
#region --- Dealing with streams ---
Modified: trunk/Drivers/AgateOTK/GL_Display.cs
===================================================================
--- trunk/Drivers/AgateOTK/GL_Display.cs 2010-01-24 22:16:52 UTC (rev 1187)
+++ trunk/Drivers/AgateOTK/GL_Display.cs 2010-01-25 20:58:52 UTC (rev 1188)
@@ -284,6 +284,7 @@
if (mGLVersion >= 3m)
{
//mGL3 = true;
+ mGL3 = false;
mGL3 = false;
mGLVersion = 2.1m;
Modified: trunk/TODO.txt
===================================================================
--- trunk/TODO.txt 2010-01-24 22:16:52 UTC (rev 1187)
+++ trunk/TODO.txt 2010-01-25 20:58:52 UTC (rev 1188)
@@ -23,7 +23,7 @@
Surfaces
D Fix bug with rotation where ScaleWidth or ScaleHeight are less than zero.
Drivers
- * Update AgateOTK to not call GL functions in finalizers.
+ D Update AgateOTK to not call GL functions in finalizers.
Input
* Add support for POV hats on joysticks.
@@ -41,9 +41,9 @@
* GP2X
Medium priority
- * Convert AgateMDX to use SlimDX instead and deprecate the use of AgateMDX.
- * Interface to allow audio to be generated at runtime.
- * Convert AgateOTK to use vertex buffers instead of vertex arrays.
+ D Convert AgateMDX to use SlimDX instead and deprecate the use of AgateMDX.
+ D Interface to allow audio to be generated at runtime.
+ D Convert AgateOTK to use vertex buffers instead of vertex arrays.
Gui
* Document GUI classes
* Develop data-driven skinning system for the GUI
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|