Exemplo n.º 1
0
    //public event EventHandler<EventArgs> OnSelectionChanged;

    public TabControlMyParams(TabInstance tabInstance, MyParams myParams)
    {
        TabInstance = tabInstance;
        MyParams    = myParams;

        InitializeControls();
    }
Exemplo n.º 2
0
    // How to set the main Content
    public TabInstance AddTab(ITab tab)
    {
        TabInstance tabInstance = tab.Create();

        tabInstance.Model.Name = "Start";
        tabInstance.iTab       = tab;
        tabInstance.Project    = Project;
        if (LoadBookmarkUri != null)
        {
            // Wait until Bookmarks tab has been created
            Dispatcher.UIThread.Post(() => ImportBookmark(new Call(), LoadBookmarkUri, false), DispatcherPriority.SystemIdle);
        }
        else if (LoadBookmark != null)
        {
            tabInstance.TabBookmark = LoadBookmark.TabBookmark;
        }
        else if (Project.UserSettings.AutoLoad)         // did we load successfully last time?
        {
            tabInstance.LoadDefaultBookmark();
        }

        TabView = new TabView(tabInstance);
        TabView.Load();

        //scrollViewer.Content = tabView;
        ContentGrid.Children.Add(TabView);

        return(tabInstance);
    }
Exemplo n.º 3
0
    public TabViewContextMenu(TabView tabView, TabInstance tabInstance)
    {
        TabView     = tabView;
        TabInstance = tabInstance;

        Initialize();
    }
Exemplo n.º 4
0
    public TabInstance Create()
    {
        if (Bookmark.Type == null)
        {
            return(null);
        }

        if (!typeof(ITab).IsAssignableFrom(Bookmark.Type))
        {
            throw new Exception("Bookmark.Type must implement ITab");
        }

        var      call         = new Call();
        Bookmark bookmarkCopy = Bookmark.DeepClone(call, true);         // This will get modified as users navigate

        ITab tab = bookmarkCopy.TabBookmark.Tab;

        if (tab == null)
        {
            tab = (ITab)Activator.CreateInstance(bookmarkCopy.Type);
        }

        if (tab is IReload reloadable)
        {
            reloadable.Reload();
        }

        TabInstance tabInstance = tab.Create();

        tabInstance.Project = Project.Open(bookmarkCopy);
        tabInstance.iTab    = this;
        tabInstance.IsRoot  = true;
        tabInstance.SelectBookmark(bookmarkCopy.TabBookmark);
        return(tabInstance);
    }
Exemplo n.º 5
0
    public async Task LoadAsync(Call call, TabModel model)
    {
        ITab iTab = await CreatorAsync.CreateAsync(call);

        _innerChildInstance = CreateChildTab(iTab);
        if (_innerChildInstance is ITabAsync tabAsync)
        {
            await tabAsync.LoadAsync(call, model);
        }
    }
Exemplo n.º 6
0
    public void AddControl(TabInstance tabInstance, TabControlSplitContainer container, object obj)
    {
        var chartSettings = (ChartSettings)obj;

        foreach (var listGroupPair in chartSettings.ListGroups)
        {
            var tabChart = new TabControlChart(tabInstance, listGroupPair.Value, true);

            container.AddControl(tabChart, true, SeparatorType.Spacer);
            //tabChart.OnSelectionChanged += ListData_OnSelectionChanged;
        }
    }
Exemplo n.º 7
0
    public static Control CreateChildControl(TabInstance parentTabInstance, object obj, string label = null, ITabSelector tabControl = null)
    {
        object value = obj.GetInnerValue();

        if (value == null || value is bool)
        {
            return(null);
        }

        if (label == null)
        {
            // use object? or inner value?
            label = obj.Formatted();
            if (label.IsNullOrEmpty())
            {
                label = "(" + obj.GetType().Name + ")";
            }
        }

        TabBookmark tabBookmark = null;         // Also assigned to child TabView's, tabView.tabInstance.tabBookmark = tabBookmark;

        if (parentTabInstance.TabBookmark != null && parentTabInstance.TabBookmark.ChildBookmarks != null)
        {
            if (parentTabInstance.TabBookmark.ChildBookmarks.TryGetValue(label, out tabBookmark))
            {
                // FindMatches only
                if (tabBookmark.TabModel != null)
                {
                    value = tabBookmark.TabModel;
                }
            }
        }

        string labelOverride = null;

        if (value is Exception)
        {
        }
        else if (parentTabInstance is ITabCreator parentTabCreator)
        {
            value = parentTabCreator.CreateControl(value, out labelOverride);
        }
        else if (tabControl is ITabCreator tabCreator)
        {
            value = tabCreator.CreateControl(value, out labelOverride);
        }
        if (value == null)
        {
            return(null);
        }

        if (labelOverride != null)
        {
            label = labelOverride;
        }

        Type type = value.GetType();

        if (value is string || value is decimal || type.IsPrimitive)
        {
            value = new TabText(value.ToString());             // create an ITab
        }

        /*else if (value is Uri uri)
         * {
         *      var tabWebBrowser = new TabWebBrowser(uri);
         *      value = tabWebBrowser;
         * }*/

        if (value is ILoadAsync loadAsync)
        {
            var childTabInstance = new TabInstanceLoadAsync(loadAsync)
            {
                Project     = parentTabInstance.Project,
                TabBookmark = tabBookmark,
            };
            childTabInstance.Model.Name = label;
            value = new TabView(childTabInstance);
        }

        if (value is ITabCreatorAsync creatorAsync)
        {
            //value = new TabCreatorAsync(creatorAsync);
            // todo: move elsewhere, we shouldn't be blocking during creation
            value = Task.Run(() => creatorAsync.CreateAsync(new Call())).GetAwaiter().GetResult();
        }

        if (value is ITab iTab)
        {
            // Custom controls implement ITab
            TabInstance childTabInstance = parentTabInstance.CreateChildTab(iTab);
            if (childTabInstance == null)
            {
                return(null);
            }

            childTabInstance.TabBookmark ??= tabBookmark;
            //childTabInstance.Reintialize(); // todo: fix, called in TabView
            childTabInstance.Model.Name = label;
            var tabView = new TabView(childTabInstance);
            tabView.Load();
            return(tabView);
        }
        else if (value is TabView tabView)
        {
            tabView.Instance.ParentTabInstance = parentTabInstance;
            tabView.Instance.TabBookmark       = tabBookmark ?? tabView.Instance.TabBookmark;
            tabView.Label = label;
            tabView.Load();
            return(tabView);
        }
        else if (value is Control control)
        {
            return(control);
        }

        /*else if (value is FilePath filePath)
         * {
         *      var tabAvalonEdit = new TabAvalonEdit(name);
         *      tabAvalonEdit.Load(filePath.path);
         *      return tabAvalonEdit;
         * }*/
        else
        {
            if (value is Enum && parentTabInstance.Model.Object.GetType().IsEnum)
            {
                return(null);
            }

            TabModel childTabModel;
            if (value is TabModel tabModel)
            {
                childTabModel      = tabModel;
                childTabModel.Name = label;
            }
            else
            {
                childTabModel = TabModel.Create(label, value);
                if (childTabModel == null)
                {
                    return(null);
                }
            }
            childTabModel.Editing = parentTabInstance.Model.Editing;

            TabInstance childTabInstance = parentTabInstance.CreateChild(childTabModel);
            childTabInstance.Label = label;

            var tabModelView = new TabView(childTabInstance);
            tabModelView.Load();
            return(tabModelView);
        }
    }
Exemplo n.º 8
0
 public TabControlSearchToolbar(TabInstance tabInstance) : base(tabInstance)
 {
     InitializeControls();
 }
Exemplo n.º 9
0
 public TabControlAvaloniaEdit(TabInstance tabInstance)
 {
     TabInstance = tabInstance;
     InitializeControls();
 }
Exemplo n.º 10
0
    public TabControl(TabInstance tabInstance)
    {
        TabInstance = tabInstance;

        InitializeControls();
    }
Exemplo n.º 11
0
 public void Dispose()
 {
     TabView     = null;
     TabInstance = null;
     Items       = null;
 }