feat: 初始化NewLife Studio项目,完成基础框架与数据管理模块
何炳宏 authored at 2026-05-26 12:09:09
986.00 B
NewLife.Studio
using Avalonia.Controls;
using NewLife.Studio.Modules.DataStudio.ViewModels;
using NewLife.Studio.Core;
using NewLife.Studio.Store;
using NewLife.Studio.Data;

namespace NewLife.Studio.Modules.DataStudio.Views;

public partial class DataStudioView : UserControl
{
    private readonly DataStudioViewModel _viewModel;

    public DataStudioView()
    {
        InitializeComponent();

        var storeService = StudioServices.GetService<IStoreService>() ?? new StoreService();
        var dataProvider = StudioServices.GetService<IDataProvider>() ?? new Data.Providers.SQLite.SQLiteProvider();

        _viewModel = new DataStudioViewModel(storeService, dataProvider);
        DataContext = _viewModel;

        ConnectionListControl.DataContext = _viewModel.ConnectionList;
        ObjectTreeControl.DataContext = _viewModel.ObjectTree;
        SqlEditorControl.DataContext = _viewModel.SqlEditor;

        Loaded += async (_, _) => await _viewModel.ConnectionList.LoadAsync();
    }
}