예제 #1
0
        void AddNew(ApplicationViewModel addThis)
        {
            if (addThis == null)
            {
                throw new ArgumentNullException("addThis");
            }

            ServiceManager.GetService <IViewService>().OpenDialog(addThis);
            if (addThis.Result != MessageResult.Okay)
            {
                return; // Cancelled add
            }
            // Check if any other applications have the same title.
            if (Tabs.Any(tabElem => tabElem.Applications.Any(
                             applicationElem => applicationElem.Title == addThis.Title)))
            {
                ServiceManager.GetService <IMessageBoxService>().Show(
                    "Application already exists with that title",
                    "Astounding Dock", MessageIcon.Error);

                // Re-open dialog.
                AddNew(addThis);
                return;
            }

            var addToThis = Tabs.Single(tabElem => tabElem.Title == addThis.Tab);

            Add(addThis, addToThis);
        }
예제 #2
0
        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);
        }
예제 #3
0
        private void Tabs_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            IsVisible = Tabs.Any();

            if (e.Action == NotifyCollectionChangedAction.Reset)
            {
                tabControl.Tabs.Clear();
                return;
            }

            if (e.OldItems != null)
            {
                foreach (TabItem item in e.OldItems)
                {
                    tabControl.Tabs.Remove(item);
                }
            }

            if (e.NewItems != null)
            {
                foreach (TabItem item in e.NewItems)
                {
                    tabControl.Tabs.Add(item);
                }
            }
        }
예제 #4
0
        private void AddTab(string path)
        {
            var type = routeService.GetComponent(path);

            if (type == null)
            {
                if (path != "/")
                {
                    MessageService.Show($"路由为 {path} 的页面未找到", MessageType.Warning);
                }
                return;
            }
            ActiveTabName = path;
            if (!Tabs.Any(x => x.Name == ActiveTabName))
            {
                var model = (MenuModel)CurrentMenu.Model;
                Tabs.Add(new TabModel()
                {
                    Title   = model.Title ?? model.Label,
                    Name    = ActiveTabName,
                    Content = type
                });
            }
            StateHasChanged();
        }
예제 #5
0
        public void InsertTab(IProfilingTab newTab, IProfilingTab after)
        {
            if (newTab == null)
            {
                throw new ArgumentNullException(nameof(newTab));
            }
            if (after == null && newTab.GetType() != typeof(HomeTab))            //We don't want anyone to remove Home tab
            {
                throw new ArgumentNullException(nameof(after));
            }
            if (after != null && !Tabs.Select(t => t.Tab).Contains(after))
            {
                throw new ArgumentOutOfRangeException($"Tab '{after.GetType().Name}' not present in current tabs.");
            }
            //Remove everything after 'after'(if after is null remove everything)
            while (Tabs.Any() && Tabs.Last().Tab != after)
            {
                TabsOnLeft.Items.Remove(TabsOnLeft.Items.Last());
            }
            newTab.InsertTab += InsertTab;
            var tabView = new TabView(newTab);

            tabView.Clicked += TabView_Clicked;
            TabsOnLeft.Items.Add(tabView);
            Select(tabView);
        }
예제 #6
0
        void Edit(TabViewModel toEdit)
        {
            if (toEdit == null)
            {
                throw new ArgumentNullException("toEdit");
            }

            TabViewModel editTab = new TabViewModel();

            editTab.UpdateWith(toEdit);

            ServiceManager.GetService <IViewService>().OpenDialog(editTab);

            if (editTab.Result != MessageResult.Okay)
            {
                return; // Cancelled edit
            }
            if (!editTab.Title.Equals(toEdit.Title, StringComparison.InvariantCultureIgnoreCase))
            {
                // Tab title changed, check if any other tabs have this title.
                if (Tabs.Any(t => t.Title == editTab.Title))
                {
                    ServiceManager.GetService <IMessageBoxService>().Show(
                        "Tab wit that title already exists", "Astounding Dock", MessageIcon.Error);

                    // Re-open dialog.
                    Edit(toEdit);
                    return;
                }
            }

            toEdit.UpdateWith(editTab);
            Messenger.Default.Send <DatabaseMessage>(DatabaseMessage.Update(toEdit.Model));
        }
예제 #7
0
        void Add(TabViewModel addThis)
        {
            if (addThis == null)
            {
                throw new ArgumentNullException("addThis");
            }

            ServiceManager.GetService <IViewService>().OpenDialog(addThis);
            if (addThis.Result != MessageResult.Okay)
            {
                return; // Cancelled add
            }
            // Check if any other tabs have this title.
            if (Tabs.Any(sectionElem => sectionElem.Title == addThis.Title))
            {
                ServiceManager.GetService <IMessageBoxService>().Show(
                    "Tab with that title already exists", "Astounding Dock", MessageIcon.Error);

                // Re-open dialog.
                Add(addThis);
                return;
            }

            addThis.TabOrder = Tabs.Max(x => x.TabOrder) + 1;

            Tabs.Add(addThis);
        }
예제 #8
0
 private void Initialize()
 {
     _tabViews = new Dictionary <ITabItem, View>();
     SetupCollection();
     SetupContent();
     SetupTitles();
     if (Tabs?.Any() == true)
     {
         CurrentTab = Tabs.First();
     }
 }
        void ProcessFile(string fileName)
        {
            if (Log.IsDebugEnabled)
            {
                Log.DebugFormat("Trying to load {0}", fileName);
            }

            if (PathEx.HasExtension(fileName, FileExtensions.Executable) ||
                PathEx.HasExtension(fileName, FileExtensions.Shortcut) ||
                PathEx.HasExtension(fileName, FileExtensions.ClickOnce))
            {
                try
                {
                    ApplicationModel model = ApplicationModel.FromFile(fileName, SelectedTab.Title, true);

                    if (model == null)
                    {
                        return;
                    }

                    if (model.FilePath.StartsWith(@"C:\Windows", StringComparison.InvariantCultureIgnoreCase))
                    {
                        return; // Don't add anything from the windows directory
                    }
                    if (!PathEx.HasExtension(model.FilePath, FileExtensions.Executable))
                    {
                        return; // Only take executable files
                    }
                    if (model.Title.Contains("Install", StringComparison.InvariantCultureIgnoreCase))
                    {
                        return; // Ignore installers
                    }
                    if (model.Title.Contains("Uninstall", StringComparison.InvariantCultureIgnoreCase))
                    {
                        return; // Ignore uninstallers
                    }
                    ApplicationViewModel application = new ApplicationViewModel(model);
                    if (Tabs.Any(obj => obj.Applications.Contains(application)))
                    {
                        return; // Ignore applications already added to the dock
                    }
                    AddApplication(new ApplicationViewModel(model));
                }
                catch (Exception ex)
                {
                    if (Log.IsDebugEnabled)
                    {
                        Log.DebugFormat("Failed to add file to search view - {0}", ex.Message);
                    }
                }
            }
        }
예제 #10
0
 protected override void SetupTitles()
 {
     ClearTitles();
     if (Tabs?.Any() != true)
     {
         return;
     }
     foreach (var tabItem in Tabs)
     {
         var button = CreateTitle(tabItem);
         _titleContainer.Children.Add(button);
     }
 }
예제 #11
0
        private static string GenerateNewTabName()
        {
            int  newFolderCounter = 1;
            bool exists           = true;

            while (exists)
            {
                exists = Tabs.Any(o => o.Content.CasesCanvasVM.TabHeader == $"New Tab {newFolderCounter}");
                if (exists)
                {
                    newFolderCounter++;
                }
            }
            return($"New Tab {newFolderCounter}");
        }
예제 #12
0
        void Edit(ApplicationViewModel toEdit)
        {
            if (toEdit == null)
            {
                throw new ArgumentNullException("toEdit");
            }

            ApplicationViewModel editApplication = new ApplicationViewModel();

            editApplication.UpdateWith(toEdit);

            ServiceManager.GetService <IViewService>().OpenDialog(editApplication);

            if (editApplication.Result != MessageResult.Okay)
            {
                return; // Cancelled edit.
            }
            if (!editApplication.Title.Equals(toEdit.Title, StringComparison.InvariantCultureIgnoreCase))
            {
                // Application title has changed, check if any other applications have the new title
                if (Tabs.Any(t => t.Applications.Any(a => a.Title == editApplication.Title)))
                {
                    ServiceManager.GetService <IMessageBoxService>().Show(
                        "Already exists with the title " + editApplication.Title,
                        "Astounding Dock", MessageIcon.Error);

                    // Re-open dialog.
                    Edit(toEdit);
                    return;
                }
            }

            toEdit.UpdateWith(editApplication);
            if (toEdit.Tab != toEdit.OldTab)
            {
                // Moving to a new tab.
                var newTab = Tabs.Single(t => t.Title == toEdit.Tab);
                Move(toEdit, newTab);
            }
            else
            {
                Messenger.Default.Send <DatabaseMessage>(DatabaseMessage.Update(toEdit.Model));
            }

            // Refresh the view to reapply the sort in case the application was renamed.
            // Needs to be done after 'UpdateWith' is called.
            Tabs.Single(t => t.Title == editApplication.Tab).ApplicationsView.Refresh();
        }
예제 #13
0
        private void UpdateTabLayout(ITabItem tab)
        {
            if (Tabs?.Any() != true || tab == null)
            {
                return;
            }
            var index = Tabs.IndexOf(tab);

            if (index < 0)
            {
                return;
            }
            var title = _titleContainer.Children[index];
            var rect  = title.Bounds;
            var x     = _header.Width / 2 - rect.X - rect.Width / 2;
            var y     = _header.Height / 2 - _titleContainer.Height / 2;
            var frame = new Rectangle(x, 0.5, AbsoluteLayout.AutoSize, AbsoluteLayout.AutoSize);

            AbsoluteLayout.SetLayoutBounds(_titleContainer, frame);
        }
예제 #14
0
        /// <summary>予約一覧からのジャンプ先を番組表タブから探す</summary>
        public bool SearchJumpTargetProgram(SearchItem trg, bool dryrun = false)
        {
            try
            {
                if (trg == null)
                {
                    return(false);
                }

                var data = (AutoAddTargetData)trg.ReserveInfo ?? trg.EventInfo;
                if (data == null)
                {
                    return(false);
                }

                if (Tabs.Any() == false)//dryrun以外でここに来るときは本当にタブが無い
                {
                    var infoList = Settings.Instance.UseCustomEpgView == false?
                                   CommonManager.CreateDefaultTabInfo() : Settings.Instance.CustomEpgTabList.ToList();

                    return(infoList.Where(info => info.IsVisible == true)
                           .SelectMany(info => info.ViewServiceList).Contains(data.Create64Key()));
                }
                var tab = Tabs.OrderBy(tb => tb.IsSelected ? 0 : 1).FirstOrDefault(tb =>
                {
                    bool ret = tb.Info.ViewServiceList.Contains(data.Create64Key());
                    if (ret == true && tb.view != null && tb.IsEpgLoaded == true)
                    {
                        return(tb.view.IsEnabledJumpTab(trg));
                    }
                    return(ret);
                });
                if (tab != null && dryrun == false)
                {
                    tab.IsSelected = true;
                }
                return(tab != null);
            }
            catch (Exception ex) { MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace); }
            return(false);
        }
        /// <summary>
        /// Add new tab based on some Neblio address
        /// </summary>
        /// <param name="address"></param>
        /// <returns>true and string with serialized tabs list as json string</returns>
        public async Task <(bool, string)> AddTab(string address)
        {
            if (!Tabs.Any(t => t.Address == address))
            {
                var tab = new CoruzantTab(address);
                tab.Selected = true;

                foreach (var t in Tabs)
                {
                    t.Selected = false;
                }

                await tab.Reload();

                Tabs.Add(tab);
            }
            else
            {
                return(false, "Already Exists.");
            }

            return(true, JsonConvert.SerializeObject(Tabs));
        }
예제 #16
0
 private void Tabs_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
 {
     IsVisible = Tabs.Any();
 }
 private void Tabs_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
 {
     Visibility = Tabs.Any() ? Visibility.Visible : Visibility.Collapsed;
 }
        protected override void LoadApplications(object sender, System.ComponentModel.DoWorkEventArgs e)
        {
            foreach (string key in new[] { InstalledApps32Bit, InstalledApps64Bit })
            {
                RegistryKey registryKey = Registry.LocalMachine.OpenSubKey(key);

                if (registryKey == null)
                {
                    continue; // The InstalledApps64Bit registry key won't exist on 32 bit machines
                }
                for (int i = 0; i < registryKey.GetSubKeyNames().Length; i++)
                {
                    string subKey = registryKey.GetSubKeyNames()[i];

                    if (_loadWorker.CancellationPending)
                    {
                        e.Cancel = true;
                        return;
                    }

                    // Only care about steam applications (i.e. "Steam App 10143")
                    Match match = Regex.Match(subKey, "^Steam App ([0-9]*)");
                    if (!match.Success)
                    {
                        continue;
                    }

                    RegistryKey propertyKey = registryKey.OpenSubKey(subKey);
                    if (propertyKey == null)
                    {
                        continue;
                    }

                    string title = propertyKey.GetValue("DisplayName", null) as string;
                    string icon  = propertyKey.GetValue("DisplayIcon", null) as string;

                    if (title.IsNullOrWhiteSpace())
                    {
                        continue;
                    }

                    try
                    {
                        int appNumber = Int32.Parse(match.Groups[1].Value);

                        ApplicationModel     applicationModel = ApplicationModel.FromSteamApp(title, appNumber, icon, SelectedTab.Title);
                        ApplicationViewModel application      = new ApplicationViewModel(applicationModel);

                        // Ignore applications already added to the dock
                        if (!Tabs.Any(obj => obj.Applications.Contains(application)))
                        {
                            AddApplication(application);
                        }
                    }
                    catch (FileNotFoundException ex)
                    {
                        Log.DebugFormat("Failed to add steam application to search view - {0}", ex.Message);
                    }
                } // for
            }     // foreach
        }