예제 #1
0
 private static void FillDesignerInfo(DesignerInfo desInfo, IApplyFormEditor editor)
 {
     desInfo.Declarations.AddRange(editor.Declarations);
     desInfo.ISupportInitializeBegin.AddRange(editor.ISupportInitializeBegin);
     desInfo.ISupportInitializeEnd.AddRange(editor.ISupportInitializeEnd);
     desInfo.PropsSetup.AddRange(editor.PropsSetup);
     desInfo.Instantiations.AddRange(editor.Instantiations);
 }
예제 #2
0
 private void VisitFormEditor(List <IEditorVisitor> editorVisitors, IApplyFormEditor editor)
 {
     foreach (var visitor in editorVisitors)
     {
         if (editor is IEditorVisitable)
         {
             (editor as IEditorVisitable).Accept(visitor);
         }
     }
 }
    public void Visit(IApplyFormEditor editor)
    {
        if (editor is IIgnoreVisit)
        {
            return;
        }

        if (editor is BaseEditor)
        {
            _editors.Add(editor.LayoutName);
        }
    }
    public void Visit(IApplyFormEditor editor)
    {
        if (editor is BindingSourceEditor)
        {
            var data = $@"this.{editor.ControlName}.DataSource = this.{ControlName};";
            editor.PropsSetup.Insert(0, data);
        }

        if (editor is IIgnoreVisit)
        {
            return;
        }
    }
예제 #5
0
    public void Visit(IApplyFormEditor editor)
    {
        if (editor is IIgnoreVisit)
        {
            return;
        }

        if (editor is BaseEditor)
        {
            var data = $@"this.{editor.ControlName}.StyleController = this.{ControlName};";
            editor.PropsSetup.Add(data);

            _editors.Add(editor.ControlName);
        }
    }
예제 #6
0
    public void Visit(IApplyFormEditor editor)
    {
        if (editor is ErrorProviderEditor)
        {
            var data = $@"this.{editor.ControlName}.DataSource = this.{ControlName};";
            editor.PropsSetup.Insert(0, data);
            return;
        }

        if (editor is IIgnoreVisit)
        {
            return;
        }

        if (editor is BaseEditor)
        {
            var data = $@"this.{editor.ControlName}.DataBindings.Add(new System.Windows.Forms.Binding(""EditValue"", this.{ControlName}, ""{editor.Name}"", true));";
            editor.PropsSetup.Insert(0, data);
        }
    }
예제 #7
0
    public Task <string> GenerateFormDesigner(FormGenInfo data)
    {
        var desInfo        = new DesignerInfo();
        var editorVisitors = new List <IEditorVisitor>();

        IFormEditorFactory formEditorFactory;

        if (data.IsGlxSchema)
        {
            slsSchemaTable schemaTable = new slsSchemaTableParser(data.TableXmlPath).GetSchemaTable();
            formEditorFactory = new GlxFormEditorFactory(schemaTable);
            desInfo.ClassName = schemaTable.Name + "F";

            var gxControls         = data.PropertiesInfo[0].FormEditor.StartsWith("gx");
            var safeCollectionName = schemaTable.Name.Remove(0, 2);
            data.PropertiesInfo.Insert(0, new FormEditorInfo {
                Name = safeCollectionName, FormEditor = gxControls ? "gxObjectCollectionSource" : "cmObjectCollectionSource"
            });
            data.PropertiesInfo.Insert(1, new FormEditorInfo {
                Name = safeCollectionName, FormEditor = gxControls ? "gxBindingSource" : "cmBindingSource"
            });
            data.PropertiesInfo.Insert(2, new FormEditorInfo {
                Name = safeCollectionName, FormEditor = gxControls ? "gxErrorProvider" : "cmErrorProvider"
            });

            data.PropertiesInfo.Add(new FormEditorInfo {
                FormEditor = "MainLayout"
            });
            data.PropertiesInfo.Add(new FormEditorInfo {
                FormEditor = "MainLayoutGroup"
            });
            data.PropertiesInfo.Add(new FormEditorInfo {
                FormEditor = "MainPanel"
            });
        }
        else
        {
            formEditorFactory = new PocoFormEditorFactory();
            var classFullNameSplit = data.ClassFullName.Split('.');
            desInfo.ClassName = classFullNameSplit[classFullNameSplit.Length - 1] + "F";
        }

        var editors = new List <IApplyFormEditor>();

        foreach (var info in data.PropertiesInfo)
        {
            IApplyFormEditor editor = formEditorFactory.Create(info);
            editors.Add(editor);
            if (editor is IEditorVisitor)
            {
                editorVisitors.Add(editor as IEditorVisitor);
            }
        }

        foreach (var editor in editors)
        {
            editor.Apply();
            VisitFormEditor(editorVisitors, editor);
            FillDesignerInfo(desInfo, editor);
        }

        var des = new CsDesignerTemplate();
        var res = des.GenerateDesigner(desInfo);

        return(Task.FromResult(res));
    }