Exemplo n.º 1
0
 private void MetroTabControl_TabItemClosingEvent(object sender, BaseMetroTabControl.TabItemClosingEventArgs e)
 {
     if (e.ClosingTabItem.Header.ToString().StartsWith("sizes"))
     {
         e.Cancel = true;
     }
 }
Exemplo n.º 2
0
        private void MetroTabControl_TabItemClosingEvent(object sender, BaseMetroTabControl.TabItemClosingEventArgs e)
        {
            if (showDialogwhenDeleteAPPGroup.IsChecked == true)
            {
                String message = e.ClosingTabItem.Header.ToString();
                message  = "Ready to remove Apps Group: " + message + " ?";
                message += "\nNote: Subordinate Apps will be removed also, be sure that all subordinate Apps is closed!";
                MetroDialogSettings mysetting = new MetroDialogSettings()
                {
                    AffirmativeButtonText = "Remove",
                    NegativeButtonText    = "Cancel",
                    ColorScheme           = MetroDialogOptions.ColorScheme,
                    DefaultButtonFocus    = MessageDialogResult.Negative
                };
                MessageDialogResult result = this.ShowModalMessageExternal("Warning", message, MessageDialogStyle.AffirmativeAndNegative, mysetting);

                if (result == MessageDialogResult.Negative)
                {
                    e.Cancel = true;
                    return;
                }
            }
            //删除该AppGroup下的所有子项
            AppGroup appgroup = getAppsModel[appTabControl.SelectedIndex];
            string   target   = string.Empty;

            for (int i = appgroup.appItems.Count - 1; i >= 0; i--)
            {
                //对于直接运行程序的类型,删除记录即可;路径为绝对路径
                //对于从.appZip包解压过来的类型,还需要删除文件夹;路径为相对路径-appexplorer根目录\AppsData\+app Name
                target = appgroup.appItems[i].AppPath;
                if (!System.IO.Path.IsPathRooted(target))
                {
                    //.appZIP导过来的程序
                    try
                    {
                        target = pathConverter.getAbsolutePathDefault(appgroup.appItems[i].AppZipPath);//app文件夹位置
                        if (appgroup.appItems[i].ProcessID != null)
                        {
                            if (!appgroup.appItems[i].ProcessID.HasExited)
                            {
                                appgroup.appItems[i].ProcessID.Kill();
                                appgroup.appItems[i].ProcessID.WaitForExit();
                            }
                        }
                        if (Directory.Exists(target))
                        {
                            Directory.Delete(target, true);
                        }
                    }
                    catch (Exception ex)
                    {
                        this.ShowModalMessageExternal("Error", "Error occurs while trying to remove APP:\n" + appgroup.appItems[i].AppName + "\nError Message: " + ex.Message, MessageDialogStyle.AffirmativeAndNegative);
                        e.Cancel = true;
                        return;
                    }
                }
                appgroup.appItems.RemoveAt(i);
            }
        }
Exemplo n.º 3
0
        private void MetroTabControl_TabItemClosingEvent(object sender, BaseMetroTabControl.TabItemClosingEventArgs e)
        {
            var headerString = e.ClosingTabItem.Header?.ToString();

            if (headerString is not null &&
                headerString.StartsWith("sizes"))
            {
                e.Cancel = true;
            }
        }
Exemplo n.º 4
0
        public void CloseTab(BaseMetroTabControl.TabItemClosingEventArgs args)
        {
            var pane = (LogPaneViewModel)args.ClosingTabItem.Content;

            pane.TryClose();
        }