예제 #1
0
 public void DeleteFromBin(DeletedAppCollection recycleBin, DeletedAppCollection deletedApp)
 {
     for (int i = 0; i < deletedApp.Count; i++)
     {
         recycleBin.Remove(deletedApp[i] as DeletedApp);
     }
 }
예제 #2
0
 public void AddToBin(DeletedAppCollection recycleBin, IEnumerable <AppInfo> apps, AppInfoCollection allApps)
 {
     foreach (var app in apps)
     {
         recycleBin.AddApp(null, app, false);
         if (allApps != null)
         {
             allApps.Remove(app);
         }
     }
 }
예제 #3
0
        public MainWorkItem()
        {
            AMSetttingsFactory.WorkItem = this;
            _Settings = AMSetttingsFactory.DefaultSettingsBag.Settings;
            _Commands = new AppCommands(this);
            _KbrdHook = new KeyboardHook();

//#if RELEASE
            //_MsHook = new MouseHook();
//#endif
            _ImageLoader  = new AsyncImageLoader();
            _MainWindow   = new MainWindow(this);
            _TrayIcon     = new WinForms.NotifyIcon();
            _AppData      = new AppGroup();
            _RecycleBin   = new DeletedAppCollection();
            UpdateRunning = false;
        }
예제 #4
0
        public static void SaveRecycleBin(string xmlPath, DeletedAppCollection recycleBin)
        {
            XmlWriterSettings sett = new XmlWriterSettings();

            sett.Indent = true;

            using (XmlWriter writer = XmlWriter.Create(xmlPath, sett))
            {
                writer.WriteStartElement("RecycleBin");

                foreach (var item in recycleBin)
                {
                    WriteDeletedApp(writer, item);
                }

                writer.WriteEndElement();
            }
        }
예제 #5
0
        public static DeletedAppCollection LoadRecycleBin(string xmlPath)
        {
            var result             = new DeletedAppCollection();
            XmlReaderSettings sett = new XmlReaderSettings();

            sett.IgnoreWhitespace = true;
            sett.IgnoreComments   = true;

            if (!File.Exists(xmlPath))
            {
                return(result);
            }

            using (XmlReader reader = XmlReader.Create(xmlPath, sett))
            {
                reader.ReadStartElement("RecycleBin");

                while (reader.IsStartElement())
                {
                    reader.ReadStartElement("DeletedApp");

                    var appInfo = ReadAppInfo2(reader);
                    reader.Read();

                    AppType appType = null;
                    if (reader.IsStartElement() && reader.Name == "AppType")
                    {
                        appType = ReadAppType2(reader);
                    }

                    result.Add(new DeletedApp
                    {
                        App         = appInfo,
                        DeletedFrom = appType
                    });

                    reader.ReadEndElement();
                }
            }

            return(result);
        }
예제 #6
0
        public void Init(
            MainWorkItem workItem,
            AppGroup appGroup,
            AppInfo appInfo,
            AppType appType,
            DeletedAppCollection deletedApps,
            AppStatCollection stat)
        {
            _AppGroup                   = appGroup;
            _Controller                 = new AppManagerController(workItem);
            AppTypes.ItemsSource        = appGroup.AppTypes;
            _AppTypes                   = appGroup.AppTypes;
            AppTypeSelector.ItemsSource = appGroup.AppTypes;
            DeletedAppList.ItemsSource  = deletedApps;
            _DeletedApps                = deletedApps;
            StatList.ItemsSource        = stat;
            //AppScanType.ItemsSource = appGroup.AppTypes;

            if (appInfo != null)
            {
                AppType selAppType = appGroup.FindAppType(appInfo);
                AppTypes.SelectedItem        = selAppType;
                AppTypeSelector.SelectedItem = selAppType;

                _ItemToSelect        = appInfo;
                AppList.SelectedItem = appInfo;

                AppTabs.SelectedIndex = 1;
            }

            if (appType != null)
            {
                AppType selAppType = appGroup.AppTypes.FindBySource(appType);
                AppTypes.SelectedItem        = selAppType;
                AppTypeSelector.SelectedItem = selAppType;

                _ItemToSelect        = appGroup.CreateNewAppInfo(selAppType);
                AppList.SelectedItem = _ItemToSelect;

                AppTabs.SelectedIndex = 1;
            }
        }
예제 #7
0
        protected void ShowWndManager(object parameter)
        {
            var appManager = new WndAppManager();
            var mangerData = _WorkItem.AppData.CloneEntity();

            mangerData.NeedAppImage += (s, e) =>
                                       _WorkItem.ImageLoader.RequestImage(s as AppInfo);
            mangerData.ReInitImages();
            var appStat     = new AppStatCollection(mangerData);
            var deletedData = new DeletedAppCollection(_WorkItem.RecycleBin.Copy());

            deletedData.RegisterSource(mangerData, false);
            foreach (DeletedApp item in deletedData)
            {
                _WorkItem.ImageLoader.RequestImage(item.App);
            }

            appManager.Init(
                _WorkItem,
                mangerData,
                parameter as AppInfo,
                parameter as AppType,
                deletedData,
                appStat
                );

            _WorkItem.Commands.Activate.Execute(null);
            appManager.Owner = _WorkItem.MainWindow;

            if (appManager.ShowDialog() ?? false)
            {
                _WorkItem.AppData.MergeEntity(mangerData);
                _WorkItem.RecycleBin.MergeCollection(deletedData);
                _WorkItem.Commands.Save.Execute(null);
            }

            foreach (DeletedApp item in deletedData)
            {
                item.App.AppImage = null;
            }
        }
예제 #8
0
        public void RestoreApp(AppGroup appGroup, DeletedAppCollection deletedApp, DeletedAppCollection recycleBin, AppType restore, string newAppTypeName)
        {
            if (deletedApp == null)
            {
                return;
            }

            if (newAppTypeName != null)
            {
                restore = new AppType()
                {
                    AppTypeName = newAppTypeName
                };
                appGroup.AppTypes.Add(restore);
            }

            for (int i = 0; i < deletedApp.Count; i++)
            {
                var item        = deletedApp[i] as DeletedApp;
                var appTypeName = (item.DeletedFrom ?? restore).AppTypeName;
                var at          = appGroup.FindAppType(appTypeName);

                if (at == null)
                {
                    at = new AppType {
                        AppTypeName = appTypeName
                    };
                    appGroup.AppTypes.Add(at);
                }

                var ai = appGroup.CreateNewAppInfo(
                    at,
                    item.App.AppName,
                    item.App.ExecPath,
                    item.App.ImagePath);

                recycleBin.Remove(item);
            }
        }
예제 #9
0
        public AppInfoCollection FindApps(
            IEnumerable <string> pathList,
            IEnumerable <string> extList,
            AppGroup appData,
            DeletedAppCollection recycleBin,
            bool excludeExisting,
            bool excludeBin)
        {
            var result = FindApps(
                pathList,
                extList,
                true);

            if (excludeExisting && result != null)
            {
                for (int i = result.Count - 1; i >= 0; i--)
                {
                    if (appData.FindAppByExecPath(result[i].ExecPath) != null)
                    {
                        result.RemoveAt(i);
                    }
                }
            }

            if (excludeBin && result != null)
            {
                for (int i = result.Count - 1; i >= 0; i--)
                {
                    if (recycleBin.FindByApp(null, result[i]) != null)
                    {
                        result.RemoveAt(i);
                    }
                }
            }

            return(result);
        }
예제 #10
0
        public AppInfoCollection FindApps(
            SearchLocation location,
            AppGroup appData,
            DeletedAppCollection recycleBin,
            bool excludeExisting,
            bool excludeBin)
        {
            if (location == SearchLocation.None)
            {
                return(new AppInfoCollection());
            }

            var searchPaths = new List <string>();

            if ((location & SearchLocation.QuickLaunch) == SearchLocation.QuickLaunch)
            {
                searchPaths.AddRange(_SearchPaths[SearchLocation.QuickLaunch]);
            }

            if ((location & SearchLocation.AllProgramsMenu) == SearchLocation.AllProgramsMenu)
            {
                searchPaths.AddRange(_SearchPaths[SearchLocation.AllProgramsMenu]);
            }

            return(FindApps(
                       searchPaths,
                       new List <string>()
            {
                "lnk"
            },
                       appData,
                       recycleBin,
                       excludeExisting,
                       excludeBin
                       ));
        }