Beispiel #1
0
 public PopUpViewModel()
 {
     DisplayName = "Popup";
     TabItems.Add(new TabItem1ViewModel());
     TabItems.Add(new TabItem2ViewModel());
     SelectedTab = TabItems.FirstOrDefault();
 }
Beispiel #2
0
        private TabItemModel HasItemByNamespace(string itemNamespace)
        {
            var hasItem =
                TabItems.FirstOrDefault(item => string.Equals(item.ItemNamespace, itemNamespace, StringComparison.CurrentCultureIgnoreCase));

            return(hasItem);
        }
Beispiel #3
0
        /// <summary>
        /// Opens new tab or reloads content if tab already exist.
        /// </summary>
        private void OpenFileTab()
        {
            var dialog = new OpenFileDialog
            {
                DefaultExt = ".txt",
                Filter     = "txt files (.txt)|*.txt"
            };

            if (!dialog.ShowDialog().GetValueOrDefault(false))
            {
                //if user fails to select a file
                return;
            }

            var path    = Path.GetFullPath(dialog.FileName);
            var name    = Path.GetFileNameWithoutExtension(dialog.FileName);
            var content = File.ReadAllText($"{dialog.FileName}");

            var doesTabAlreadyExist = TabItems.FirstOrDefault(i => i.Program != null && i.Program.Path == path);

            if (!Equals(doesTabAlreadyExist, null))
            {
                //if this file is already open reload it's content and set is as current tab
                doesTabAlreadyExist.ProgramEditor.Text = doesTabAlreadyExist.Program.Content;
                doesTabAlreadyExist.UnsavedChanged     = false;
                SelectedTabItem = doesTabAlreadyExist;
                return;
            }

            OpenTab(new Program(name)
            {
                Path = path, Content = content
            });
            Session.Instance.SavePrograms(TabItems);
        }
Beispiel #4
0
        private void ViewContent_CloseByEvent(object sender, EventArgs e)
        {
            if (sender is UserControlViewObject content && TabItems.FirstOrDefault(x => x.Content == content) is LoggedInWindowTabItem tabItem)
            {
                content.RemoveByEvent -= ViewContent_CloseByEvent;

                TabItems.Remove(tabItem);
            }
        }
Beispiel #5
0
        private TabItemModel HasItemByDataNum(int dataNum)
        {
            if (dataNum < 0)
            {
                return(null);
            }
            var hasItem = TabItems.FirstOrDefault(item => item.DataNum == dataNum);

            return(hasItem);
        }
Beispiel #6
0
        private string GetName(byte id)
        {
            var name = $"Вкладка {++id}";

            if (TabItems.FirstOrDefault(t => Common.IsSameName(t.Text, name)) != null)
            {
                name = "Новая вкладка";
            }
            return(name);
        }
Beispiel #7
0
        /// <summary>
        /// 树选择
        /// </summary>
        /// <param name="treeNode"></param>
        private void SelectedTreeItemChanged(TreeNode treeNode)
        {
            var tabItem = TabItems.FirstOrDefault(a => a.Header == treeNode.Name);

            if (tabItem == null)
            {
                tabItem = new TabItemModel(WebUtility.HtmlDecode(treeNode.IconPath), treeNode.Name, treeNode.Source, CloseTabCommand, Visibility.Visible);
                TabItems.Add(tabItem);
            }
            SelectedTabItem = tabItem;
        }
Beispiel #8
0
        private TabItem AddToTabItems(string name)
        {
            if (TabItems.FirstOrDefault(t => t.Header.ToString() == name) != null)
            {
                return(null);
            }
            var tab = CreateTabItem(name);

            TabItems.Add(tab);
            return(tab);
        }
Beispiel #9
0
        public void RemoveItem(MyTabItem tabItem)
        {
            var selector = TabItems.FirstOrDefault(t => t.Id == tabItem.Id);

            if (selector == null)
            {
                return;
            }

            TabItems.Remove(selector);
        }
Beispiel #10
0
 private byte GetId()
 {
     for (byte i = 0; i < byte.MaxValue; i++)
     {
         if (TabItems.FirstOrDefault(t => t.Id == i) != null)
         {
             continue;
         }
         return(i);
     }
     return(byte.MaxValue);
 }
Beispiel #11
0
        private void CreateNewTabItem(DISP_Car car)
        {
            var excar = TabItems.FirstOrDefault(o => o.Header.Equals(car.CarModel.CarNumber));

            if (excar == null)
            {
                CarsHandler.Instance.GetCarDetails(car.CarModel.CarNumber);
            }
            else
            {
                SelectedTab = excar;
            }
            //InfoBlock = _buttonsform;
        }
Beispiel #12
0
        public void OneTimeSetUp()
        {
            this.manager.Launch(sourceFile);
            var tabView = this.manager.Window?.FindTabView();

            Assume.That(tabView, Is.Not.Null);

            this.tab = tabView !.TabItems.FirstOrDefault();
            Assume.That(this.tab, Is.Not.Null, "Editor tab not automatically shown");

            var scintilla = this.tab.FindFirstDescendant("Editor").AsScintilla();

            Assume.That(scintilla, Is.Not.Null);
            this.editor = scintilla !;

            this.originalCode = this.editor.Text;
            Assume.That(this.originalCode, Is.Not.Empty);
        }
Beispiel #13
0
        public void AddItem(byte id = byte.MaxValue, string text = null)
        {
            if (id == byte.MaxValue)
            {
                id = GetId();
            }

            if (string.IsNullOrEmpty(text))
            {
                text = GetName(id);
            }
            if (TabItems.FirstOrDefault(t => t.Id == id) != null)
            {
                return;
            }

            TabItems.Add(new MyTabItem(id, text, _dataProvider));
        }
Beispiel #14
0
        private void OnOpenWebLogs(object obj)
        {
            TabItem tab;

            if (!TabItems.Any(t => t.Header.Equals("Web Logs")))
            {
                tab = new TabItem
                {
                    Header      = "Web Logs",
                    Content     = new WebLogView(),
                    DataContext = new WebLogViewModel(this)
                };

                TabItems.Add(tab);
            }
            else
            {
                tab = TabItems.FirstOrDefault(t => t.Header.Equals("Web Logs"));
            }

            SelectedTabIndex = TabItems.IndexOf(tab);
        }
Beispiel #15
0
        private void OnAgentInteract(object obj)
        {
            TabItem tab;

            if (!TabItems.Any(t => t.Header.Equals(SelectedAgent.AgentId)))
            {
                tab = new TabItem
                {
                    Header      = SelectedAgent.AgentId,
                    Content     = new AgentInteractView(),
                    DataContext = new AgentInteractViewModel(this, SelectedAgent.AgentId)
                };

                TabItems.Add(tab);
            }
            else
            {
                tab = TabItems.FirstOrDefault(t => t.Header.Equals(SelectedAgent.AgentId));
            }

            SelectedTabIndex = TabItems.IndexOf(tab);
        }
Beispiel #16
0
        private static int GetTabIndex(Actor actor)
        {
            var existsItem = TabItems.FirstOrDefault(x => x.Header.ToString() == actor.ShortName);

            return(TabItems.IndexOf(existsItem));
        }