コード例 #1
0
        protected override string GenDateColumn(Item item, int counter, CodeGenProperties codeGenProperties)
        {
            string result = "";

            Position labelPosition = FormsUtility.CalculateLabelPosition(item);

            var resourceName = "FMBExplorer.Templates.DateFormField.txt";

            using (Stream stream = assembly.GetManifestResourceStream(resourceName))
                using (StreamReader reader = new StreamReader(stream))
                {
                    string template = reader.ReadToEnd();
                    result = Engine.Razor.RunCompile(template, "dateFieldTemplateKey", null, new {
                        ViewModelName       = codeGenProperties.ViewModelName,
                        EnabledPropertyName = codeGenProperties.EnabledPropertyName,
                        Name          = item.Name, CollectionViewSourceName = codeGenProperties.CollectionViewSourceName,
                        BindingSource = codeGenProperties.BindingSource, Row = counter, TextBox_Name = "txb_" + item.ColumnName,
                        FieldName     = item.ColumnName, Width = item.WpfWidth, Height = item.WpfHeight,
                        Prompt        = item.Prompt, Left = item.WpfXPosition, LabelLeft = labelPosition.Left, LabelTop = labelPosition.Top,
                        Top           = item.WpfYPosition
                    });
                }

            return(result);
        }
コード例 #2
0
        public static string Generate(Block block, CodeGenProperties codeGenProperties)
        {
            StringBuilder rowDefs = new StringBuilder();

            block.Items.ForEach(item =>
            {
                rowDefs.Append("<RowDefinition Height=\"Auto\"/>");
            });

            var    columns = new GenerateDataFormFields().Generate(block, codeGenProperties);
            string result  = "";

            var resourceName = "FMBExplorer.Templates.DataForm.txt";

            using (Stream stream = assembly.GetManifestResourceStream(resourceName))
                using (StreamReader reader = new StreamReader(stream))
                {
                    string template = reader.ReadToEnd();
                    result = HttpUtility.HtmlDecode(Engine.Razor.RunCompile(template, "dataFormTemplateKey", null, new {
                        ViewModelName            = codeGenProperties.ViewModelName,
                        WindowName               = codeGenProperties.WindowName,
                        RowDefs                  = rowDefs, DataFormFields = columns,
                        CollectionViewSourceName = codeGenProperties.CollectionViewSourceName,
                        BindingSource            = codeGenProperties.BindingSource
                    }));
                }

            return(result);
        }
コード例 #3
0
        protected override string GenDateColumn(Item item, int counter, CodeGenProperties codeGenProperties)
        {
            string result = "";

            var resourceName = "FMBExplorer.Templates.DateColumn.txt";

            using (Stream stream = assembly.GetManifestResourceStream(resourceName))
                using (StreamReader reader = new StreamReader(stream))
                {
                    string template = reader.ReadToEnd();
                    result = Engine.Razor.RunCompile(template, "dateColumnKey", null, new { Name = item.Name, Prompt = item.Prompt, FieldName = item.ColumnName });
                }

            return(result);
        }
コード例 #4
0
        public static string Generate(Block block, CodeGenProperties codeGenProperties)
        {
            string result = "";

            var resourceName = "FMBExplorer.Templates.ViewModelClass.txt";

            using (Stream stream = assembly.GetManifestResourceStream(resourceName))
                using (StreamReader reader = new StreamReader(stream))
                {
                    string template = reader.ReadToEnd();
                    result = Engine.Razor.RunCompile(template, "VMtemplateKey", null, new
                    {
                        ViewModelName       = codeGenProperties.ViewModelName,
                        EnabledPropertyName = codeGenProperties.EnabledPropertyName
                    });
                }

            return(result);
        }
コード例 #5
0
        private void treeView_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs <object> e)
        {
            if (e.NewValue is Block)
            {
                Block block = e.NewValue as Block;
                vm.selectedBlock = block;

                genCodeBtn.IsEnabled = true;

                CodeGenProperties codeGenProps = new CodeGenProperties();
                codeGenProps.BindingSource            = vm.selectedBlock.Name;
                codeGenProps.Name                     = vm.selectedBlock.Name;
                codeGenProps.CollectionViewSourceName = vm.selectedBlock.Name + "_ViewSource";
                codeGenProps.EnabledPropertyName      = vm.selectedBlock.Name + "_TxEnabled";
                codeGenProps.ViewModelName            = "ViewModel." + vm.selectedBlock.Name + "_VM";
                codeGenProps.CodebehindNamespace      = "Forms." + vm.selectedBlock.Name;
                codeGenProps.WindowName               = vm.selectedBlock.Name + "_Window";
                codeGenProps.EntityName               = vm.selectedBlock.Name + "_V";

                if (FormsUtility.IsGrid(vm.selectedBlock))
                {
                    codeGenProps.DataEntryStyle = CodeGenProperties.DataEntry.Grid;
                }
                else if (FormsUtility.IsForm(vm.selectedBlock))
                {
                    codeGenProps.DataEntryStyle = CodeGenProperties.DataEntry.Form;
                }
                else
                {
                    codeGenProps.DataEntryStyle = CodeGenProperties.DataEntry.Simple;
                }

                vm.CodeGenProperties         = codeGenProps;
                PropertyGrid1.SelectedObject = vm.CodeGenProperties;
            }
            else
            {
                vm.GeneratedCode     = "";
                vm.GeneratedXAML     = "";
                genCodeBtn.IsEnabled = false;
            }
        }
コード例 #6
0
        public static string Generate(Block block, CodeGenProperties codeGenProperties)
        {
            var    columns = new GenerateDataGridColumns().Generate(block, codeGenProperties);
            string result  = "";

            var resourceName = "FMBExplorer.Templates.DataGrid.txt";

            using (Stream stream = assembly.GetManifestResourceStream(resourceName))
                using (StreamReader reader = new StreamReader(stream))
                {
                    string template = reader.ReadToEnd();
                    result = Engine.Razor.RunCompile(template, "templateKey", null, new {
                        ViewModelName            = codeGenProperties.ViewModelName,
                        Name                     = codeGenProperties.Name,
                        WindowName               = codeGenProperties.WindowName,
                        CollectionViewSourceName = codeGenProperties.CollectionViewSourceName,
                        BindingSource            = codeGenProperties.BindingSource, Columns = columns
                    });
                }

            return(result);
        }
コード例 #7
0
 protected abstract string GenDateColumn(Item item, int counter, CodeGenProperties codeGenProperties);
コード例 #8
0
        public string Generate(FormsElement.Block block, CodeGenProperties codeGenProperties)
        {
            StringBuilder result  = new StringBuilder("");
            int           counter = 0;

            block.Items.ForEach(item =>
            {
                if ((!String.IsNullOrEmpty(item.ColumnName)) && ((item.Visible == true) || (!String.IsNullOrEmpty(item.Canvas))))
                {
                    counter++;

                    if (!string.IsNullOrEmpty(item.ItemType))
                    {
                        switch (item.ItemType)
                        {
                        case "Text Item":
                            {
                                result.Append(GenTextColumn(item, counter, codeGenProperties)).AppendLine();
                                break;
                            }

                        default:
                            {
                                result.Append(GenTextColumn(item, counter, codeGenProperties)).AppendLine();
                                break;
                            }
                        }
                    }
                    else if (!string.IsNullOrEmpty(item.DataType))
                    {
                        switch (item.DataType)
                        {
                        case "Date":
                            {
                                result.Append(GenDateColumn(item, counter, codeGenProperties)).AppendLine();
                                break;
                            }

                        case "Char":
                            {
                                result.Append(GenTextColumn(item, counter, codeGenProperties)).AppendLine();
                                break;
                            }

                        default:
                            {
                                result.Append(GenTextColumn(item, counter, codeGenProperties)).AppendLine();
                                break;
                            }
                        }
                    }
                    else if ((string.IsNullOrEmpty(item.ItemType) && (string.IsNullOrEmpty(item.DataType))))
                    {
                        result.Append(GenTextColumn(item, counter, codeGenProperties));
                    }
                    else
                    {
                        throw new InvalidDataException(string.Format("Unknown Item found. {0} ", item.ToString()));
                    }
                }
            });

            return(result.ToString());
        }