public void BrowseWorkspaceFolderOnClick(object sender, EventArgs e) { Form.FolderBrowserWorkspace.RootFolder = Environment.SpecialFolder.MyComputer; Form.FolderBrowserWorkspace.SelectedPath = this.WorkspaceFolder; DialogResult result = Form.FolderBrowserWorkspace.ShowDialog(); if (result == DialogResult.OK) { WorkspaceFolder = Form.FolderBrowserWorkspace.SelectedPath; FormModelBinder.BindTextForEachTaggedControl(); } }
public void IntegratedSecurityOnCheckedChanged(object sender, EventArgs e) { IntegratedSecurity = ((CheckBox)sender).CheckState; if (IntegratedSecurity == CheckState.Checked) { FormModelBinder.Disable(Form.TextBoxUserName); FormModelBinder.Disable(Form.TextBoxPassword); } else if (IntegratedSecurity == CheckState.Unchecked) { FormModelBinder.Enable(Form.TextBoxUserName); FormModelBinder.Enable(Form.TextBoxPassword); } }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); LaoTzuForm laoTzu = new LaoTzuForm(); List <MenuStrip> toolStrips = new List <MenuStrip>(); toolStrips.Add(laoTzu.MenuStripMain); FormModelBinder modelBinder = new FormModelBinder(laoTzu.Controls, toolStrips); LaoTzuViewModel viewModel = new LaoTzuViewModel(modelBinder, laoTzu); modelBinder.ViewModel = viewModel; modelBinder.Bind(); Application.Run(laoTzu); }
public LaoTzuViewModel(FormModelBinder binder, LaoTzuForm form) { DefaultConfiguration.SetProperties(this, false); if (string.IsNullOrEmpty(ExtractorFolder)) { ExtractorFolder = "."; } this.Form = form; this.FormModelBinder = binder; this.MappedSchemaDefinition = new MappedSchemaDefinition(".\\LaoTzu.{0}"._Format(MappedSchemaExtension)); this.Form.ListViewTables.ItemSelectionChanged += (o, a) => { PopulateColumnNameMapList(); }; }
private void PopulateTableNameMapList() { TryOrShowMessage(() => { FormModelBinder.ForListView(Form.ListViewTables, (lv) => { lv.Items.Clear(); SchemaNameMap schemaNameMap = MappedSchemaDefinition.SchemaNameMap; schemaNameMap.TableNamesToClassNames.Each(map => { ListViewItem tableItem = new ListViewItem(new string[] { map.ClassName, map.TableName }); tableItem.Tag = new TableNameToClassName { TableName = map.TableName, ClassName = map.ClassName }; lv.Items.Add(tableItem); }); }); }); }
public void LoadSettingsOnClick(object sender, EventArgs e) { Form.OpenFileDialog.InitialDirectory = this.WorkspaceFolder; Form.OpenFileDialog.Filter = LaoTzuFileFilter; Form.OpenFileDialog.DefaultExt = LaoTzuFileExtension; DialogResult result = Form.OpenFileDialog.ShowDialog(); if (result == DialogResult.OK) { FileInfo file = new FileInfo(Form.OpenFileDialog.FileName); LaoTzuViewModel loaded = file.FromJsonFile <LaoTzuViewModel>(); this.GetType().GetPropertiesWithAttributeOfType <ModelSetting>().Each(pi => { FormModelBinder.SetByTag(pi.Name, pi.GetValue(loaded).ToString()); }); SetSettingsStatus("Settings file: {0}"._Format(file.FullName)); } }
private DaoAssemblyGenerator GetDaoAssemblyGenerator() { DaoAssemblyGenerator generator = new DaoAssemblyGenerator(this.MappedSchemaDefinition.SchemaDefinition, this.MappedSchemaDefinition.SchemaNameMap); generator.Namespace = Namespace ?? DefaultNamespace; generator.OnTableStarted += (ns, table) => { FormModelBinder.SetByTag("SchemaStatus", "Generating: {0}.{1}"._Format(ns, table.Name)); }; generator.OnGenerateStarted += (gen, sd) => { FormModelBinder.SetByTag("SchemaStatus", "Generation started..."); }; generator.OnGenerateComplete += (gen, sd) => { FormModelBinder.SetByTag("SchemaStatus", "Genertion complete"); }; return(generator); }
public void GenerateCSharpOnClick(object sender, EventArgs e) { DaoGenerator generator = new DaoGenerator(); generator.Namespace = Namespace ?? DefaultNamespace; generator.BeforeClassStreamResolved += (s, t) => FormModelBinder.SetByTag("SchemaStatus", "Writing code for {0}"._Format(t.Name)); DirectoryInfo srcDir = GetSourceDir(true); if (MappedSchemaDefinition.SchemaDefinition.Tables.Length == 0) { MessageBox.Show("No tables were found in the current schema.\r\n\r\nExtract or load a schema first.", "No Tables Found", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { MappedSchemaDefinition.MapSchemaClassAndPropertyNames(); generator.Generate(MappedSchemaDefinition.SchemaDefinition, srcDir.FullName); } string text = "Code generated to: {0}"._Format(srcDir.FullName); SetStatus(text); }
public void ExtractSchemaOnClick(object sender, EventArgs e) { try { SchemaExtractor extractor = GetExtractor(); extractor.NameMap = MappedSchemaDefinition.SchemaNameMap; extractor.ProcessingTable += (o, args) => { FormModelBinder.AppendText(Form.TextBoxOutput, "Reading meta data for table {0}\r\n"._Format(((SchemaExtractorEventArgs)args).Table)); Form.TextBoxOutput.Refresh(); Thread.Sleep(3); }; extractor.ProcessingColumn += (o, args) => { FormModelBinder.AppendText(Form.TextBoxOutput, " Reading meta data for column {0}\r\n"._Format(((SchemaExtractorEventArgs)args).Column)); Form.TextBoxOutput.Refresh(); Thread.Sleep(3); }; FormModelBinder.SetText(Form.TextBoxOutput, ""); DisableInputs(); SchemaDefinition schema = extractor.Extract(); schema.Save(Path.Combine(extractor.SchemaTempPathProvider(schema), "{0}.schema.json"._Format(schema.Name))); MappedSchemaDefinition.SchemaDefinition = schema; MappedSchemaDefinition.SchemaNameMap = extractor.NameMap; FormModelBinder.AppendText(Form.TextBoxOutput, "\r\n... Extraction Done ..."); FormModelBinder.AppendText(Form.TextBoxOutput, "\r\nPopulating schema tab ..."); Task.Run(() => { PopulateTableNameMapList(); FormModelBinder.AppendText(Form.TextBoxOutput, "\r\n... Schema tab populated ..."); }); EnableInputs(); Form.TabControlMain.SelectedTab = Form.TabPageSchemaInfo; } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public bool IsMatch(Type modelType) { return(FormModelBinder.TypeIsIForm(modelType)); }
private void DisableInputs() { FormModelBinder.Disable <Button>(); FormModelBinder.Disable <TextBox>(); FormModelBinder.Disable <CheckBox>(); }