Exemple #1
0
        /// <summary>
        /// Apply the base configuration for all <see cref="TabItem"/> <see langword="objects"/> in the <see cref="TabCollection"/>
        /// </summary>
        /// <param name="_tab">The tab to configure</param>
        /// <param name="_showContent">Whether or not to show the tab after configuration</param>
        private void ConfigurateTab(TabItem _tab, bool _showContent)
        {
            #region On Click Behaviour
            _tab.OnClick = (o, e) =>
            {
                ITabItem other = FindTab(item => item.IsVisible == true);
                if (other != null)
                {
                    MinimizeTab(other);
                }

                OpenTab(_tab);
            };
            #endregion

            #region On Close Behaviour
            _tab.OnCloseClick = (o, e) =>
            {
                CloseTab(_tab);
            };
            #endregion

            Tabs.Add(_tab);

            _tab.Construct(tabDisplay, contentArea);

            if (_showContent)
            {
                MinimizeTab(FindTab(item => item.IsVisible == true && item.ID != _tab.ID));
            }
        }
Exemple #2
0
 protected override void RemoveContent(ITabItem tab, View content, int index)
 {
     if (Content == _contentContainer.Content)
     {
         _contentContainer.Content = null;
     }
 }
        private View GetOrCreateConent(ITabItem tab)
        {
            if (!(Tabs?.Any() == true && ContentTemplate != null))
            {
                return(null);
            }
            View element = null;

            if (!(_tabViews.TryGetValue(tab, out element)))
            {
                var selector = ContentTemplate as DataTemplateSelector;
                if (selector != null)
                {
                    var template = selector.SelectTemplate(tab, this);
                    element = template?.CreateContent() as View;
                }
                else
                {
                    element = (View)ContentTemplate.CreateContent();
                }
                if (element == null)
                {
                    throw new InvalidOperationException(
                              "Could not instantiate content. Please make sure that your ContentTemplate is configured correctly.");
                }
                _tabViews[tab]         = element;
                element.BindingContext = tab;
            }
            return(element);
        }
Exemple #4
0
        protected override void InsertTitle(ITabItem tab, int index)
        {
            var title = CreateTitle(tab);

            _titleContainer.Children.Insert(index, title);
            UpdateTabLayout(CurrentTab);
        }
Exemple #5
0
        private ViewButton CreateTitle(ITabItem tabItem)
        {
            View title    = null;
            var  selector = TitleTemplate as DataTemplateSelector;

            if (selector != null)
            {
                var template = selector.SelectTemplate(tabItem, this);
                title = template?.CreateContent() as View;
            }
            else
            {
                title = (View)TitleTemplate.CreateContent();
            }
            if (title == null)
            {
                throw new InvalidOperationException(
                          "Could not instantiate title. Please make sure that your TitleTemplate is configured correctly.");
            }

            title.BindingContext = tabItem;
            var button = new ViewButton()
            {
                VerticalOptions = LayoutOptions.FillAndExpand
            };

            button.Content  = title;
            button.Clicked += ViewButtonOnClicked;
            return(button);
        }
Exemple #6
0
 public TabItemView Item(ITabItem item)
 {
     this.item = item;
     text.Text(item.TabName);
     UpdateTabState();
     return(this);
 }
Exemple #7
0
        public void Find(string word = null)
        {
            if (word != null)
            {
                TB_Input.Text = word;
            }
            Initialize(false);
            if (TB_Input.Text.Length <= 0)
            {
                return;
            }
            switch (Mode)
            {
            case MODE_CURRENT:
                ITabItem currenttab = parent.MainTabControl.SelectedItem;
                if (currenttab is FuncBlockViewModel)
                {
                    FuncBlockViewModel fbvmodel = (FuncBlockViewModel)currenttab;
                    Find(fbvmodel);
                }
                break;

            case MODE_ALL:
                ProjectModel pmodel = parent.ProjectModel;
                Find(pmodel.LibFuncBlock);
                foreach (FuncBlockViewModel fbvmodel in pmodel.FuncBlocks)
                {
                    Find(fbvmodel);
                }
                break;
            }
            PropertyChanged(this, new PropertyChangedEventArgs("Items"));
        }
Exemple #8
0
        /// <summary>
        /// 查找
        /// </summary>
        private void Find()
        {
            Initialize();
            if (TB_Input.Text.Length <= 0)
            {
                return;
            }
            switch (Mode)
            {
            // 当前文本
            case MODE_CURRENT:
                ITabItem currenttab = parent.MainTabControl.SelectedItem;
                if (currenttab is FuncBlockViewModel)
                {
                    FuncBlockViewModel fbvmodel = (FuncBlockViewModel)currenttab;
                    Find(fbvmodel);
                }
                break;

            // 所有文本
            case MODE_ALL:
                ProjectModel pmodel = parent.ProjectModel;
                Find(pmodel.LibFuncBlock);
                foreach (FuncBlockViewModel fbvmodel in pmodel.FuncBlocks)
                {
                    Find(fbvmodel);
                }
                break;
            }
            PropertyChanged(this, new PropertyChangedEventArgs("Items"));
        }
Exemple #9
0
        public async Task <ITabHandler> add(string title, string position = LocalConstant.TabPositionBottom)
        {
            if (this._addonInfomation is null)
            {
                throw new InvalidOperationException("Not Initialized!");
            }

            var     tabInfo = DIFactory.Provider.GetRequiredService <ITabInfomation>();
            TabType type    = position switch
            {
                LocalConstant.TabPositionTop => TabType.Top,
                _ => TabType.Bottom
            };

            tabInfo.Initialize(this._addonInfomation, title, type);

            ITabItem item    = this._container.AddTab(tabInfo);
            var      handler = new TabHandler(item);

            await item.WaitUntilInitialize();

            if (this._addonInfomation.HasPermission(PermissionNames.Resource))
            {
                var path = Path.Combine(AppContext.BaseDirectory, FileFolder.AddonsFolder, this._addonInfomation.PackageID.Value, AddonConstant.ResourceDirectoryName);
                if (Directory.Exists(path))
                {
                    item.SetVirtualHostName(AddonConstant.ResourceHost, path);
                }
            }

            return(handler);
        }

        #endregion
    }
Exemple #10
0
 private void SaveCommand(object sender, System.Windows.Input.ExecutedRoutedEventArgs e)
 {
     if (MainTabControl.Items.Count == 0)
     {
         MessageBox.Show("No tab opened.", "Information", MessageBoxButton.OK, MessageBoxImage.Information);
     }
     else
     {
         ITabItem current = (ITabItem)MainTabControl.SelectedContent;
         string   text    = current.GetPlainText();
         Console.WriteLine(text);
         SaveFileDialog saveDialog = new SaveFileDialog();
         saveDialog.Filter   = "Encrypted File (*.*)|*.*|Plain File (*.*)|*.*";
         saveDialog.Title    = "Save As";
         saveDialog.FileName = ((TabItem)MainTabControl.Items[MainTabControl.SelectedIndex]).Header as string;
         if (saveDialog.ShowDialog() == true)
         {
             try
             {
                 if (saveDialog.FilterIndex == 1)
                 {
                     Crypt.EncryptToFile(saveDialog.FileName, text, FDF1Checkbox.IsChecked, GetSelectedKeyIndex());
                 }
                 else
                 {
                     File.WriteAllText(saveDialog.FileName, text);
                 }
             }
             catch (Exception ex)
             {
                 MessageBox.Show("Something went wrong.\n" + ex, "Error", MessageBoxButton.OK, MessageBoxImage.Warning);
             }
         }
     }
 }
 public void CloseItem(ITabItem item)
 {
     if (_lDocDict.ContainsKey(item))
     {
         item.FloatClosed -= OnTabFloatClosed;
         LayoutDocument ldoc = _lDocDict[item];
         _lDocDict.Remove(item);
         TabItemCollection.Remove(item);
         if (item.IsFloat)
         {
             LayoutFloatingWindowControl fwctrl = item.FloatControl;
             fwctrl.Close();
             item.IsFloat = false;
         }
         else
         {
             Children.Remove(ldoc);
         }
         if (item is LadderDiagramViewModel)
         {
             IEnumerable <MainTabDiagramItem> fit = DiagramCollection.Where(
                 (MainTabDiagramItem _mtditem) => { return(_mtditem.LDVM_ladder == item); });
             MainTabDiagramItem mtditem = null;
             if (fit.Count() > 0)
             {
                 mtditem = fit.First();
                 DiagramCollection.Remove(mtditem);
             }
         }
         CloseTabItem(this, new RoutedEventArgs());
     }
 }
        /// <summary>
        /// Called when the implementer has been navigated to.
        /// </summary>
        /// <param name="navigationContext">The navigation context.</param>
        public void OnNavigatedTo(NavigationContext navigationContext)
        {
            if (navigationContext != null && navigationContext.Parameters.Any(p => p.Key.EqualsIgnoreCase("TabIndex")))
            {
                var tabIndex = navigationContext.Parameters["TabIndex"];
                ActiveTabItemIndex = !string.IsNullOrEmpty(tabIndex) ? int.Parse(tabIndex) : 0;
            }
            else
            {
                ActiveTabItemIndex = 0;
            }

            ITabItem tab = TabItems[ActiveTabItemIndex];

            if (tab != null)
            {
                if (!tab.IsActive)
                {
                    tab.IsActive = true;
                }
                else
                {
                    tab.OnIsActive();
                }
            }

            if (ActiveTabItemIndex == 0)
            {
                EventAggregator.GetEvent <SetContextualHelpContextEvent>().Publish("MANAGING YOUR DATASETS LIBRARY");
            }
        }
 private void InsertTab(ITabItem tab, int index)
 {
     InsertTitle(tab, index);
     if (tab.IsSelected)
     {
         CurrentTab = Tabs?.FirstOrDefault();
     }
 }
 private void SelectTab(ITabItem tab)
 {
     if (tab != null)
     {
         SelectTitle(tab);
         SelectContent(tab);
     }
 }
 public void RenameItem(ITabItem item)
 {
     if (_lDocDict.ContainsKey(item))
     {
         LayoutDocument ldoc = _lDocDict[item];
         ldoc.Title = item.TabHeader;
     }
 }
Exemple #16
0
 protected override void RemoveTitle(ITabItem tab, int index)
 {
     if (index >= 0)
     {
         _titleContainer.Children.RemoveAt(index);
     }
     UpdateTabLayout(CurrentTab);
 }
Exemple #17
0
        public void OpenTab(string header, ITabItem content)
        {
            TabItem tab = new TabItem();

            tab.Header  = header;
            tab.Content = content;
            MainTabControl.Items.Add(tab);
            MainTabControl.SelectedIndex = MainTabControl.Items.IndexOf(tab);
        }
        public void ShowItem(ITabItem item)
        {
            //bool isnew = false;
            LayoutDocument ldoc = null;

            if (item is FuncBlockViewModel)
            {
                FuncBlockViewModel fbvmodel = (FuncBlockViewModel)item;
                fbvmodel.CodeTextBox.Focus();
            }
            if (item.IsFloat)
            {
                LayoutFloatingWindowControl fwctrl = item.FloatControl;
                fwctrl.Focus();
                return;
            }
            if (!TabItemCollection.Contains(item))
            {
                TabItemCollection.Add(item);
                item.FloatClosed += OnTabFloatClosed;
                ldoc              = new LayoutDocument();
                ldoc.Title        = item.TabHeader;
                if (item is LadderDiagramViewModel)
                {
                    IEnumerable <MainTabDiagramItem> fit = DiagramCollection.Where(
                        (MainTabDiagramItem _mtditem) => { return(_mtditem.LDVM_ladder == item); });
                    MainTabDiagramItem mtditem = null;
                    if (fit.Count() == 0)
                    {
                        mtditem = new MainTabDiagramItem((IProgram)item, ViewMode);
                        DiagramCollection.Add(mtditem);
                    }
                    else
                    {
                        mtditem = fit.First();
                    }
                    ldoc.Content = mtditem;
                }
                else
                {
                    ldoc.Content = item;
                }
                ldoc.IsActiveChanged += OnActiveChanged;
                Children.Add(ldoc);
                _lDocDict.Add(item, ldoc);
                //isnew = true;
            }
            else
            {
                ldoc = _lDocDict[item];
            }
            int ldocid = Children.IndexOf(ldoc);

            SelectedItem         = item;
            SelectedContentIndex = ldocid;
        }
Exemple #19
0
        /// <summary>
        /// <inheritdoc/>
        /// </summary>
        /// <param name="_tab">The tab to open</param>
        /// <returns><inheritdoc/></returns>
        public override bool OpenTab(ITabItem _tab)
        {
            if (_tab != null)
            {
                _tab.Show();
                return(true);
            }

            return(false);
        }
Exemple #20
0
        /// <summary>
        /// <inheritdoc/>
        /// </summary>
        /// <param name="_tab">The tab to minimize</param>
        /// <returns><see langword="True"/> if the tab could be minimized; Otherwise, if not, <see langword="false"/></returns>
        public override bool MinimizeTab(ITabItem _tab)
        {
            if (_tab != null)
            {
                _tab.Show(false);
                return(true);
            }

            return(false);
        }
Exemple #21
0
        /// <summary>
        /// Determines whether the specified <see cref="iFactr.UI.ITabItem"/> is equal to this instance.
        /// </summary>
        /// <param name="other">The <see cref="iFactr.UI.ITabItem"/> to compare with this instance.</param>
        /// <returns><c>true</c> if the specified <see cref="iFactr.UI.ITabItem"/> is equal to this instance;
        /// otherwise, <c>false</c>.</returns>
        public bool Equals(ITabItem other)
        {
            TabItem item = other as TabItem;

            if (item != null)
            {
                return(Pair == item.Pair);
            }

            return(Pair == other);
        }
Exemple #22
0
        public bool Equals(ITabItem other)
        {
            var item = other as iFactr.UI.TabItem;

            if (item != null)
            {
                return(item.Equals(this));
            }

            return(base.Equals(other));
        }
        public async void ReopenClosedTab(object sender, RoutedEventArgs e)
        {
            if (!isRestoringClosedTab && RecentlyClosedTabs.Any())
            {
                isRestoringClosedTab = true;
                ITabItem lastTab = RecentlyClosedTabs.Last();
                RecentlyClosedTabs.Remove(lastTab);
                await MainPageViewModel.AddNewTabByParam(lastTab.TabItemArguments.InitialPageType, lastTab.TabItemArguments.NavigationArg);

                isRestoringClosedTab = false;
            }
        }
 private void OnActiveChanged(object sender, EventArgs e)
 {
     if (sender is LayoutDocument)
     {
         LayoutDocument ldoc = (LayoutDocument)(sender);
         if (ldoc.Content != SelectedItem)
         {
             ITabItem _SelectedItem = SelectedItem;
             SelectedItem = (ITabItem)(ldoc.Content);
         }
     }
 }
        public void AddTabItem(ITabItem tabItem)
        {
            if (!TabItems.Any(item => item.Id == tabItem.Id))
            {
                InvokeAsync(() =>
                {
                    this.TabItems.Add(tabItem);
                    this.TabEvents.Add(AddedEvent);

                    StateHasChanged();
                });
            }
        }
 protected override void OnChildrenCollectionChanged()
 {
     base.OnChildrenCollectionChanged();
     foreach (ITabItem tab in TabItemCollection)
     {
         if (tab.IsFloat)
         {
             continue;
         }
         if (!_lDocDict.ContainsKey(tab))
         {
             continue;
         }
         LayoutDocument ldoc = _lDocDict[tab];
         if (!Children.Contains(ldoc))
         {
             CloseItem(tab);
             return;
         }
     }
     foreach (var child in Children)
     {
         ITabItem tab = null;
         if (child.Content is MainTabDiagramItem)
         {
             tab = ((MainTabDiagramItem)(child.Content)).LDVM_ladder;
         }
         else if (child.Content is ITabItem)
         {
             tab = (ITabItem)(child.Content);
         }
         if (tab != null && !TabItemCollection.Contains(tab))
         {
             TabItemCollection.Add(tab);
             _lDocDict.Add(tab, (LayoutDocument)child);
         }
         if (child.IconSource == null && child.Content is MainTabDiagramItem)
         {
             child.ImageSource = IconManager.RoutineImage;
         }
         else if (child.IconSource == null && child.Content is FuncBlockViewModel)
         {
             child.ImageSource = IconManager.FuncImage;
         }
         else if (child.IconSource == null && child.Content is ModbusTableViewModel)
         {
             child.ImageSource = IconManager.ModbusImage;
         }
     }
 }
        private void RemoveTab(ITabItem tab, int index)
        {
            RemoveTitle(tab, index);
            View content = null;

            if (_tabViews.TryGetValue(tab, out content))
            {
                RemoveContent(tab, content, index);
                _tabViews.Remove(tab);
            }
            if (tab.IsSelected)
            {
                CurrentTab = Tabs?.FirstOrDefault();
            }
        }
Exemple #28
0
        private void OnCurrentTabChanged(object sender, SelectionChangedEventArgs e)
        {
            ITabItem currenttab = parent.MainTabControl.SelectedItem;

            if (currenttab is FuncBlockViewModel)
            {
                Visibility = Visibility.Visible;
                if (Mode == MODE_CURRENT)
                {
                    Find();
                }
            }
            else
            {
                Visibility = Visibility.Hidden;
            }
        }
Exemple #29
0
        public void SetLoadingIndicatorStatus(ITabItem item, bool loading)
        {
            var tabItem = ContainerFromItem(item) as Control;

            if (tabItem is null)
            {
                return;
            }

            if (loading)
            {
                VisualStateManager.GoToState(tabItem, "Loading", false);
            }
            else
            {
                VisualStateManager.GoToState(tabItem, "NotLoading", false);
            }
        }
Exemple #30
0
        public Controls.ITabItem CreateTabItem(string filename, IHighlightsHelper hightlightsHelper)
        {
            IRequest req = Kernel.CreateRequest(typeof(ITabItem), null, new IParameter[] { new Parameter("filename", filename, false), new Parameter("hightlightsHelper", hightlightsHelper, false) }, false, false);

            if (!Kernel.CanResolve(req))
            {
                Kernel.Bind <ITabItem>()
                .To <FileWatcherTabItem>()
                .WithConstructorArgument("filename", filename)
                .WithConstructorArgument("hightlightsHelper", hightlightsHelper);
            }

            ITabItem tab = Kernel.Get <ITabItem>();

            Kernel.Unbind <ITabItem>();

            return(tab);
        }
 /// <summary>
 /// Removes the tab from the current collection.
 /// </summary>
 /// <param name="tab">The tab.</param>
 public void RemoveTab(ITabItem tab)
 {
     Tabs.Remove(tab);
 }