コード例 #1
0
        /// <summary>
        /// Current tab is closing - remove presenter from our presenters list
        /// </summary>
        /// <param name="sender">Sender of event</param>
        /// <param name="e">Event arguments</param>
        private void OnTabClosing(object sender, TabClosingEventArgs e)
        {
            if (e.LeftTabControl)
            {
                IPresenter presenter = presenters1[e.Index - 1];
                e.AllowClose = true;
                if (presenter.GetType() == typeof(ExplorerPresenter))
                {
                    e.AllowClose = ((ExplorerPresenter)presenter).SaveIfChanged();
                }
                if (e.AllowClose)
                {
                    presenter.Detach();
                    this.presenters1.RemoveAt(e.Index - 1);
                }
            }
            else
            {
                IPresenter presenter = presenters2[e.Index - 1];
                e.AllowClose = true;
                if (presenter.GetType() == typeof(ExplorerPresenter))
                {
                    e.AllowClose = ((ExplorerPresenter)presenter).SaveIfChanged();
                }
                if (e.AllowClose)
                {
                    presenter.Detach();
                    this.presenters2.RemoveAt(e.Index - 1);
                }
            }

            // We've just closed Simulations
            // This is a good time to force garbage collection
            GC.Collect(2, GCCollectionMode.Forced, true);
        }
コード例 #2
0
        private async void TabControl_TabClosing(object sender, TabClosingEventArgs e)
        {
            lock (SyncRootProvider.SyncRoot)
            {
                if (IsClosing)
                {
                    e.Cancel = true;
                    return;
                }
                IsClosing = true;
            }

            if (TabCollection.Count == 1)
            {
                e.Cancel = true;
                CreateNewTab(new Uri("about:blank"));
                TabControl.SelectedIndex = 1;
                await Task.Delay(900);

                TabCollection.Remove(e.Tab);
            }

            (e.Tab.Content as WebPage)?.Dispose();
            e.Tab.Content = null;

            IsClosing = false;
        }
コード例 #3
0
        /// <summary>
        /// Current tab is closing - remove presenter from our presenters list
        /// </summary>
        /// <param name="sender">Sender of event</param>
        /// <param name="e">Event arguments</param>
        private void OnTabClosing(object sender, TabClosingEventArgs e)
        {
            if (e.LeftTabControl)
            {
                e.AllowClose = this.presenters1[e.Index - 1].SaveIfChanged();
                if (e.AllowClose)
                {
                    this.presenters1[e.Index - 1].Detach();
                    this.presenters1.RemoveAt(e.Index - 1);
                }
            }
            else
            {
                e.AllowClose = this.presenters2[e.Index - 1].SaveIfChanged();
                if (e.AllowClose)
                {
                    this.presenters2[e.Index - 1].Detach();
                    this.presenters2.RemoveAt(e.Index - 1);
                }
            }

            // We've just closed Simulations
            // This is a good time to force garbage collection
            GC.Collect(2, GCCollectionMode.Forced, true);
        }
コード例 #4
0
 private void CloseTab(TabClosingEventArgs args)
 {
     if (args.Item is RunnerInstanceViewModel item)
     {
         Items.Remove(item);
     }
 }
コード例 #5
0
 private void TabStrip_TabClosing(object sender, TabClosingEventArgs e)
 {
     e.Tab.Content = null;
     if (TabStrip.Items.Count == 1)
     {
         CoreApplication.Exit();
     }
 }
コード例 #6
0
 private void UtcTabs_TabClosing(object sender, TabClosingEventArgs e)
 {
     if (_utcTabs.Tabs.Count == 1)
     {
         e.Cancel = true;
         Dialog.ShowDialog(Application.ProductName,
                           "Invalid action. You cannot close the last query results tab.", string.Empty);
     }
 }
コード例 #7
0
 private async void MainTabs_OnTabClosing(object sender, TabClosingEventArgs e)
 {
     if (!(e.Tab.Content is LabPage content))
     {
         return;
     }
     e.Cancel = true;
     if (await content.CanClose())
     {
         ViewModel.CloseTab.Execute(e.Tab);
     }
 }
コード例 #8
0
        private void tabControl_TabClosing(object sender, TabClosingEventArgs e)
        {
            ITabDocument document = (sender as FlatTabControl).DocumentFromPage(e.page);

            if (document is IWorkbenchDocument)
            {
                e.canClose = (document as IWorkbenchDocument).CanCloseDocument();
            }
            else
            if (document is MySQL.Forms.AppViewDockContent)
            {
                MySQL.Forms.AppViewDockContent content = document as MySQL.Forms.AppViewDockContent;
                e.canClose = content.CanCloseDocument();
            }
        }
コード例 #9
0
 private void TabClosing(object sender, TabClosingEventArgs e)
 {
     if (AppData.ChapterCount() == 1)
     {
         AppData.SaveChapters();
         CoreApplication.Exit();
     }
     else if (e.Item is TabViewItem closedTabItem)
     {
         bool selectedClosed = (AppData.CustomTabViewItems[AppData.SelectedIndex].TabItem == closedTabItem);
         AppData.RemoveChapter(closedTabItem);
         if (!selectedClosed)
         {
             AppData.SetSelectedItem(closedTabItem);
         }
     }
 }
コード例 #10
0
        private async void SongVersionTabs_TabClosing(object sender, TabClosingEventArgs e)
        {
            e.Cancel = true;
            var tab = (TabViewItem)e.Tab;

            MessageDialog dialog = new MessageDialog("Are you sure you want to delete this playlist?");

            dialog.Commands.Add(new UICommand("Yes", null));
            dialog.Commands.Add(new UICommand("No", null));
            dialog.DefaultCommandIndex = 0;
            dialog.CancelCommandIndex  = 1;
            var cmd = await dialog.ShowAsync();

            if (cmd.Label == "Yes")
            {
                if (tab.Tag is long flavourid)
                {
                    e.Cancel = false;
                    try
                    {
                        var flavour = SongListStorage.PlaylistDict[flavourid];
                        if (flavour.isflavour)
                        {
                            SongListStorage.AlbumDict[CurrentAlbum].RemoveFlavour(flavourid);
                        }
                        await flavour.DeleteFile();

                        TabItems.Remove(tab);
                        SongListStorage.PlaylistDict.Remove(flavourid, out flavour);

                        await App.GetForCurrentView().LoadPinnedFlavours();

                        if (!flavour.isflavour)
                        {
                            this.Frame.Navigate(typeof(AlbumList));
                        }
                    }
                    catch { }
                }
            }
        }
コード例 #11
0
 /// <summary>
 /// Current tab is closing - remove presenter from our presenters list
 /// </summary>
 /// <param name="sender">Sender of event</param>
 /// <param name="e">Event arguments</param>
 private void OnTabClosing(object sender, TabClosingEventArgs e)
 {
     if (e.LeftTabControl)
     {
         e.AllowClose = this.presenters1[e.Index - 1].SaveIfChanged();
         if (e.AllowClose)
         {
             this.presenters1[e.Index - 1].Detach();
             this.presenters1.RemoveAt(e.Index - 1);
         }
     }
     else
     {
         e.AllowClose = this.presenters2[e.Index - 1].SaveIfChanged();
         if (e.AllowClose)
         {
             this.presenters2[e.Index - 1].Detach();
             this.presenters2.RemoveAt(e.Index - 1);
         }
     }
 }
コード例 #12
0
ファイル: MainPresenter.cs プロジェクト: byzheng/ApsimX
 /// <summary>
 /// Current tab is closing - remove presenter from our presenters list
 /// </summary>
 /// <param name="sender">Sender of event</param>
 /// <param name="e">Event arguments</param>
 private void OnTabClosing(object sender, TabClosingEventArgs e)
 {
     if (e.LeftTabControl)
     {
         e.AllowClose = this.presenters1[e.Index - 1].SaveIfChanged();
         if (e.AllowClose)
             this.presenters1.RemoveAt(e.Index - 1);
     }
     else
     {
         e.AllowClose = this.presenters2[e.Index - 1].SaveIfChanged();
         if (e.AllowClose)
             this.presenters2.RemoveAt(e.Index - 1);
     }
 }
コード例 #13
0
 private void Tabs_TabClosing(object sender, TabClosingEventArgs e)
 {
     TabViewNotification.Show("You're closing the '" + e.Tab.Header + "' tab.", 2000);
 }
コード例 #14
0
 private void utcMain_TabClosing(object sender, TabClosingEventArgs e)
 {
     MdiChildren[utcMain.ActiveTab.Index].Close();
 }
コード例 #15
0
        private async void TabClosingAsync(object sender, TabClosingEventArgs e)   //Closing A tab, Check if it's edited
        {
            //localization
            var resourceLoader = Windows.ApplicationModel.Resources.ResourceLoader.GetForCurrentView();

            //Cancel Closing
            e.Cancel = true;

            //Detact if it's a Setting Page
            if ((e.Tab.Content) is SettingPage)
            {
                //remove this tab
                this.TabBar.Items.Remove(e.Tab);
                //If all tab closed, exit the app
                if (this.TabBar.Items.Count == 0)
                {
                    Application.Current.Exit();
                }
                //Setting Page Closed, return
                return;
            }

            //If file is edited, show dialog
            if (((TabContent)(e.Tab.Content)).isEdited == true)
            {
                ContentDialog saveDialog = new ContentDialog
                {
                    Title               = resourceLoader.GetString("FileUnsavedDialogTitle"),
                    Content             = resourceLoader.GetString("FileUnsavedDialogContent") + e.Tab.Header.ToString().Substring(1) + "\"?",
                    CloseButtonText     = resourceLoader.GetString("FileUnsavedDialogCancel"),
                    PrimaryButtonText   = resourceLoader.GetString("FileUnsavedDialogSave"),
                    SecondaryButtonText = resourceLoader.GetString("FileUnsavedDialogNotSave"),
                    DefaultButton       = ContentDialogButton.Primary
                };
                ContentDialogResult result = await saveDialog.ShowAsync();

                switch (result)
                {
                //if clicked Save
                case ContentDialogResult.Primary:
                {
                    if (((TabContent)(e.Tab.Content)).file == null)
                    {
                        FileSavePicker fileSavePicker = new FileSavePicker();
                        fileSavePicker.SuggestedStartLocation = PickerLocationId.Desktop;
                        fileSavePicker.FileTypeChoices.Add(resourceLoader.GetString("TextFile"), new List <string>()
                            {
                                ".txt"
                            });
                        fileSavePicker.SuggestedFileName   = e.Tab.Header.ToString().Substring(1);
                        ((TabContent)(e.Tab.Content)).file = await fileSavePicker.PickSaveFileAsync();

                        //if noting chosen, return, not closing the tab
                        if (((TabContent)(e.Tab.Content)).file == null)
                        {
                            return;
                        }

                        //prevent upload until saved (onedrive, etc)
                        Windows.Storage.CachedFileManager.DeferUpdates(((TabContent)(e.Tab.Content)).file);

                        //Write to file
                        await Windows.Storage.FileIO.WriteTextAsync(((TabContent)(e.Tab.Content)).file, ((TabContent)(e.Tab.Content)).TabTextBox.Text);

                        //let windows know we finished writing
                        await Windows.Storage.CachedFileManager.CompleteUpdatesAsync(((TabContent)(e.Tab.Content)).file);

                        //save complete, remove the tab
                        this.TabBar.Items.Remove(e.Tab);

                        //save complete
                        //If all tab closed, exit the app
                        if (this.TabBar.Items.Count == 0)
                        {
                            Application.Current.Exit();
                        }
                        return;
                    }
                    else
                    {
                        //if not a new file
                        //prevent upload until saved (onedrive, etc)
                        Windows.Storage.CachedFileManager.DeferUpdates(((TabContent)(e.Tab.Content)).file);

                        //Write to file
                        await Windows.Storage.FileIO.WriteTextAsync(((TabContent)(e.Tab.Content)).file, ((TabContent)(e.Tab.Content)).TabTextBox.Text);

                        //let windows know we finished writing
                        await Windows.Storage.CachedFileManager.CompleteUpdatesAsync(((TabContent)(e.Tab.Content)).file);

                        //save complete, remove the tab
                        this.TabBar.Items.Remove(e.Tab);
                        if (this.TabBar.Items.Count == 0)
                        {
                            Application.Current.Exit();
                        }
                        return;
                    }
                }

                //if clicked not Save, close tab
                case ContentDialogResult.Secondary:
                {
                    //remove this tab
                    this.TabBar.Items.Remove(e.Tab);
                    //If all tab closed, exit the app
                    if (this.TabBar.Items.Count == 0)
                    {
                        Application.Current.Exit();
                    }
                    return;
                }

                //if clicked cancel - return
                case ContentDialogResult.None:
                {
                    return;
                }
                }
            }

            //If file not edited. close the tab
            this.TabBar.Items.Remove(e.Tab);

            //If all tab closed, exit the app
            if (this.TabBar.Items.Count == 0)
            {
                Application.Current.Exit();
            }
        }