Ejemplo n.º 1
0
        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;
        }
Ejemplo n.º 2
0
 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;
         }
     }
 }