public async Task <IActionResult> AddCategory([FromBody] AppCategory model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var addedCategory = await categoryRepo.AddCategory(model);

                    if (addedCategory != null)
                    {
                        return(Ok(addedCategory));
                    }
                    else
                    {
                        return(NotFound());
                    }
                }
                catch (Exception excp)
                {
                    return(BadRequest(excp));
                }
            }

            return(BadRequest());
        }
Example #2
0
        //---------------------------------------------------------------------------------------------


        public virtual void EditStatus(long id)
        {
            target(UpdateStatus, id);

            AppInstaller installer = cdb.findById <AppInstaller>(id);

            if (installer == null)
            {
                throw new NullReferenceException();
            }

            set("installer.Name", installer.Name);
            set("installer.Description", installer.Description);


            List <AppCategory> cats = new List <AppCategory>();

            if (installer.CatId == AppCategory.General)
            {
                cats = AppCategory.GetAllWithoutGeneral();
            }
            else
            {
                cats.Add(AppCategory.GetByCatId(installer.CatId));
            }
            checkboxList("appCheckboxList", cats, "Name=TypeFullName", installer.StatusValue);

            radioList("closeMode", AppCloseMode.GetAllMode(), "Name=Id", installer.CloseMode);
        }
Example #3
0
 public static AppCategoryDataContract ToAppCategoryDataContract(this AppCategory app)
 {
     return(new AppCategoryDataContract()
     {
         Id = app.Id,
         Title = app.Title,
         AppType = app.AppType
     });
 }
Example #4
0
 public static AppCategoryDataContract GetAppCategoryDC(this AppCategory appCategory)
 {
     return(new AppCategoryDataContract()
     {
         Id = appCategory.Id,
         Title = appCategory.Title,
         AppType = (WindowsStore.Client.User.Service.UserService.AppType)appCategory.AppType
     });
 }
Example #5
0
        public ServerApiClient(CommonRequestParams @params, CancellationToken cancellationToken = default(CancellationToken))
        {
            _http = new Http.Http(cancellationToken);
            _requestParameters = CommonRequestParams.ToRequestParameters(@params);

            Auth   = new AuthCategory(this);
            App    = new AppCategory(this);
            Data   = new DataCategory(this);
            Notice = new NoticeCategory(this);
        }
 public static Category ToCategory(this AppCategory cat)
 {
     return(new Category()
     {
         Id = cat.Id.GetValueOrDefault(),
         CategoryParentId = cat.ParentId,
         Name = cat.CategoryName,
         Reports = null
     });
 }
        public async Task <AppCategory> UpdateCategory(AppCategory category)
        {
            if (db != null)
            {
                //Delete that post
                db.AppCategory.Update(category);

                //Commit the transaction
                await db.SaveChangesAsync();
            }

            return(category);
        }
        public async Task <AppCategory> AddCategory(AppCategory category)
        {
            if (db != null)
            {
                category.AppCategoryId = Guid.NewGuid();
                category.CreatedDate   = DateTime.Now;
                await db.AppCategory.AddAsync(category);

                await db.SaveChangesAsync();

                return(category);
            }

            return(category);
        }
        protected virtual TabSection CreateCategorySection(AppCategory cat)
        {
            var section = m_TabFactoryService.CreateTabSection(cat.MenuViewModelType);

            if (section != null)
            {
                if (!string.IsNullOrEmpty(cat.ImageNameSmall))
                {
                    section.Info.IconImageSmallName = cat.ImageNameSmall;
                }

                if (!string.IsNullOrEmpty(cat.ImageNameBig))
                {
                    section.Info.IconImageBigName = cat.ImageNameBig;
                }

                if (!string.IsNullOrEmpty(cat.MenuColor))
                {
                    try
                    {
                        var bc = new BrushConverter();
                        section.Info.Background = (SolidColorBrush)bc.ConvertFromString(cat.MenuColor);
                    }
                    catch
                    {
                        //too bad
                    }
                }

                if (!string.IsNullOrEmpty(cat.MenuButtonColor))
                {
                    try
                    {
                        var bc = new BrushConverter();
                        section.Info.ButtonBrush = ((SolidColorBrush)bc.ConvertFromString(cat.MenuButtonColor)).Color;
                    }
                    catch
                    {
                        //too bad
                    }
                }

                section.Info.Description  = cat.Title;
                section.Info.SectionWidth = m_Parms.MenuSectionsWidth;
            }

            return(section);
        }
Example #10
0
        public string GetAppDir(AppCategory category)
        {
            string dir = string.Empty;

            switch (category)
            {
            case AppCategory.WebApp:
                dir = GetWebAppDir();
                break;

            case AppCategory.WinApp:
                dir = GetWinAppDir();
                break;

            default:
                break;
            }
            return(dir);
        }
Example #11
0
        public static AppCategory ToAppCategory(this Category cat)
        {
            var t =
                new AppCategory()
            {
                Id              = cat.Id,
                CategoryName    = cat.Name,
                ParentId        = cat.CategoryParentId,
                ParentCategory  = cat.ParentCategory == null ? null : cat.ParentCategory.ToAppCategory(),
                ChildCount      = (cat.ChildCategory != null) ? cat.ChildCategory.Count() : 0,
                ChildCategories = cat.ChildCategory == null? null: cat.ChildCategory.Select(_ => new AppCategory()
                {
                    Id = _.Id, CategoryName = _.Name, ParentId = _.CategoryParentId
                }),
                Reports = cat.Reports.Select(_ => _.ToAppReport())
            };

            return(t);
        }
Example #12
0
        //Update manage interface according to category
        void Lb_Manage_AddAppCategory_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            try
            {
                //Get the currently selected category
                AppCategory selectedCategory = (AppCategory)lb_Manage_AddAppCategory.SelectedIndex;

                //Check if the application is UWP
                bool uwpApplication = false;
                if (vEditAppDataBind != null)
                {
                    uwpApplication = vEditAppDataBind.Type == ProcessType.UWP;
                }

                if (uwpApplication || selectedCategory != AppCategory.Emulator)
                {
                    sp_AddAppPathRoms.Visibility = Visibility.Collapsed;
                }
                else
                {
                    sp_AddAppPathRoms.Visibility = Visibility.Visible;
                }

                if (uwpApplication || selectedCategory != AppCategory.App)
                {
                    checkbox_AddLaunchFilePicker.Visibility = Visibility.Collapsed;
                }
                else
                {
                    checkbox_AddLaunchFilePicker.Visibility = Visibility.Visible;
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Failed to switch app category: " + ex.Message);
            }
        }
        public async Task <IActionResult> UpdateCategory([FromBody] AppCategory Category)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    await categoryRepo.UpdateCategory(Category);

                    return(Ok());
                }
                catch (Exception excp)
                {
                    if (excp.GetType().FullName ==
                        "Microsoft.EntityFrameworkCore.DbUpdateConcurrencyException")
                    {
                        return(NotFound());
                    }

                    return(BadRequest(excp));
                }
            }

            return(BadRequest());
        }
Example #14
0
 /// <summary>
 /// 根据提供的程序类型【web或者桌面应用程序】获取当前目录
 /// </summary>
 /// <param name="category"></param>
 /// <returns></returns>
 public static string GetNowAppDir(AppCategory category)
 {
     return((new AppDirHelper()).GetAppDir(category));
 }
        public void Seed(WindowsStoreContext context)
        {
            #region Platform
            var platform1 = new Platform
            {
                PlatformCategory = PlatformCategory.Windows10Universal,
                Title            = "ویندوز 10، یونیورسال"
            };
            var platform2 = new Platform
            {
                PlatformCategory = PlatformCategory.Windows10Desktop,
                Title            = "ویندوز 10، خانواده دسکتاپ"
            };
            var platform3 = new Platform
            {
                PlatformCategory = PlatformCategory.Windows10Mobile,
                Title            = "ویندوز 10، خانواده موبایل"
            };
            var platform4 = new Platform
            {
                PlatformCategory = PlatformCategory.Windows10XBox,
                Title            = "ویندوز 10، خانواده XBox"
            };
            var platform5 = new Platform
            {
                PlatformCategory = PlatformCategory.Windows10Iot,
                Title            = "ویندوز 10، خانواده IOT"
            };
            var platform6 = new Platform
            {
                PlatformCategory = PlatformCategory.Windows10HoloLens,
                Title            = "ویندوز 10، خانواده HoloLens"
            };

            context.Platforms.AddRange(
                new Platform[] { platform1, platform2, platform3, platform4, platform5, platform6 });

            #endregion

            #region AppCategory
            var appCategory1 = new AppCategory {
                AppType = AppType.Application, Title = "کسب و کار"
            };
            var appCategory2 = new AppCategory {
                AppType = AppType.Application, Title = "توسعه نرم افزار"
            };
            var appCategory3 = new AppCategory {
                AppType = AppType.Application, Title = "غذا و آشپزی"
            };
            var appCategory4 = new AppCategory {
                AppType = AppType.Application, Title = "خانواده"
            };
            var appCategory5 = new AppCategory {
                AppType = AppType.Application, Title = "سبک زندگی"
            };
            var appCategory6 = new AppCategory {
                AppType = AppType.Application, Title = "موسیقی"
            };
            var appCategory7 = new AppCategory {
                AppType = AppType.Application, Title = "مسافرت-نقشه"
            };
            var appCategory8 = new AppCategory {
                AppType = AppType.Application, Title = "خبر-آب‌ و‌ هوا"
            };
            var appCategory9 = new AppCategory {
                AppType = AppType.Application, Title = "تصویر و ویدیو"
            };
            var appCategory10 = new AppCategory {
                AppType = AppType.Application, Title = "خرید"
            };
            var appCategory11 = new AppCategory {
                AppType = AppType.Application, Title = "ابزار"
            };
            var appCategory12 = new AppCategory {
                AppType = AppType.Application, Title = "کتاب‌ها و مراجع"
            };
            var appCategory13 = new AppCategory {
                AppType = AppType.Application, Title = "خرید"
            };
            var appCategory14 = new AppCategory {
                AppType = AppType.Application, Title = "اجتماعی"
            };
            var appCategory15 = new AppCategory {
                AppType = AppType.Application, Title = "ورزش"
            };
            var appCategory16 = new AppCategory {
                AppType = AppType.Application, Title = "ابزار"
            };
            var appCategory17 = new AppCategory {
                AppType = AppType.Game, Title = "اکشن"
            };
            var appCategory18 = new AppCategory {
                AppType = AppType.Game, Title = "کارت و تخته"
            };
            var appCategory19 = new AppCategory {
                AppType = AppType.Game, Title = "آموزشی"
            };
            var appCategory20 = new AppCategory {
                AppType = AppType.Game, Title = "پلتفرمر"
            };
            var appCategory21 = new AppCategory {
                AppType = AppType.Game, Title = "معمایی"
            };
            var appCategory22 = new AppCategory {
                AppType = AppType.Game, Title = "پرواز"
            };
            var appCategory23 = new AppCategory {
                AppType = AppType.Game, Title = "تیراندازی"
            };
            var appCategory24 = new AppCategory {
                AppType = AppType.Game, Title = "شبیه‌سازی"
            };
            var appCategory25 = new AppCategory {
                AppType = AppType.Game, Title = "استراتژی"
            };
            var appCategory26 = new AppCategory {
                AppType = AppType.Game, Title = "کلمات"
            };

            context.AppCategories.AddRange(new AppCategory[] {
                appCategory1, appCategory2, appCategory3, appCategory4, appCategory5,
                appCategory6, appCategory7, appCategory8, appCategory9, appCategory10,
                appCategory11, appCategory12, appCategory13, appCategory14, appCategory15,
                appCategory16, appCategory17, appCategory18, appCategory19, appCategory20,
                appCategory21, appCategory22, appCategory23, appCategory24, appCategory25,
                appCategory26
            }
                                           );
            #endregion

            #region Role
            var AdminRole = new Role {
                Title = "Admin", Name = "Admin"
            };
            var developerRole = new Role {
                Title = "Developer", Name = "Developer"
            };
            context.Roles.AddRange(new Role[] { AdminRole, developerRole });
            #endregion

            #region LegalPerson
            var paasteelCompany = new LegalPerson
            {
                PrimaryEmail = "*****@*****.**",
                Name         = "پاستیل",
                Membership   = new Membership
                {
                    CreateDate = DateTime.Now,
                    FailedPasswordAttemptCount = 0,
                    IsApproved                   = true,
                    IsIdentityVerified           = true,
                    IsLockedOut                  = true,
                    Password                     = SecurityHelper.ComputeSha256Hash("12345"),
                    VerificationCodeLastSendDate = DateTime.Now,
                    VerificationCode             = 0
                }
            };

            var paasteelAppProvider = new LegalPerson
            {
                PrimaryEmail = "*****@*****.**",
                Name         = "(گرد آورنده: پاستیل)",
                Membership   = new Membership
                {
                    CreateDate = DateTime.Now,
                    FailedPasswordAttemptCount = 0,
                    IsApproved                   = true,
                    IsIdentityVerified           = true,
                    IsLockedOut                  = true,
                    Password                     = SecurityHelper.ComputeSha256Hash("12345"),
                    VerificationCodeLastSendDate = DateTime.Now,
                    VerificationCode             = 0
                }
            };
            context.LegalPeople.AddRange(new LegalPerson[] { paasteelCompany, paasteelAppProvider });
            #endregion

            #region Natural Person
            var mehrdad = new NaturalPerson
            {
                PrimaryEmail = "*****@*****.**",
                FirstName    = "مهرداد",
                LastName     = "تاجدینی",
                Age          = 29,
                Sexuality    = Sexuality.Male,
                Membership   = new Membership
                {
                    CreateDate = DateTime.Now,
                    FailedPasswordAttemptCount = 0,
                    IsApproved                   = true,
                    IsIdentityVerified           = true,
                    IsLockedOut                  = true,
                    Password                     = SecurityHelper.ComputeSha256Hash("12345"),
                    VerificationCodeLastSendDate = DateTime.Now,
                    VerificationCode             = 0
                }
            };
            mehrdad.Roles.Add(AdminRole);
            mehrdad.Roles.Add(developerRole);

            var vahid = new NaturalPerson
            {
                PrimaryEmail = "*****@*****.**",
                FirstName    = "وحید",
                LastName     = "انصاری",
                Age          = 29,
                Sexuality    = Sexuality.Male,
                Membership   = new Membership
                {
                    CreateDate = DateTime.Now,
                    FailedPasswordAttemptCount = 0,
                    IsApproved                   = true,
                    IsIdentityVerified           = true,
                    IsLockedOut                  = true,
                    Password                     = SecurityHelper.ComputeSha256Hash("12345"),
                    VerificationCodeLastSendDate = DateTime.Now,
                    VerificationCode             = 0
                }
            };
            vahid.Roles.Add(AdminRole);
            vahid.Roles.Add(developerRole);

            context.NaturalPeople.AddRange(new NaturalPerson[] { mehrdad, vahid });
            #endregion

            #region App
            var paasteelApp = new App
            {
                Guid                 = Guid.Empty,
                Developer            = paasteelCompany,
                Name                 = "پاستیل",
                Description          = "پاستیل",
                Icon128X128          = new byte[1],
                Icon256X256          = new byte[1],
                AppCategory          = appCategory16,
                State                = AppState.Unpublished,
                CpuArchitectureFlags = CpuArchitecture.Arm,
            };
            paasteelApp.Platforms.Add(platform1);
            paasteelApp.AppVersions.Add(new AppVersion()
            {
                Downloads   = 0,
                PublishDate = DateTime.Now,
                Description = "پاستیل",
                Version     = "1.0.0.0",
                Size        = 0
            });
            context.Apps.Add(paasteelApp);
            #endregion

            context.SaveChanges();
        }
Example #16
0
 public AppCategoryModel(AppCategory category)
 {
     ID   = category.ID;
     Name = category.Name;
 }
Example #17
0
        //Add or edit application to list apps and Json file
        async void Button_Manage_SaveEditApp_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                //Check the selected application category
                AppCategory selectedAddCategory = (AppCategory)lb_Manage_AddAppCategory.SelectedIndex;

                //Check if there is an application name set
                if (string.IsNullOrWhiteSpace(tb_AddAppName.Text) || tb_AddAppName.Text == "Select application executable file first")
                {
                    List <DataBindString> Answers = new List <DataBindString>();
                    DataBindString        Answer1 = new DataBindString();
                    Answer1.ImageBitmap = FileToBitmapImage(new string[] { "Assets/Default/Icons/Check.png" }, vImageSourceFolders, vImageBackupSource, IntPtr.Zero, -1, 0);
                    Answer1.Name        = "Ok";
                    Answers.Add(Answer1);

                    await Popup_Show_MessageBox("Please enter an application name first", "", "", Answers);

                    return;
                }

                //Check if there is an application exe set
                if (string.IsNullOrWhiteSpace(tb_AddAppExePath.Text))
                {
                    List <DataBindString> Answers = new List <DataBindString>();
                    DataBindString        Answer1 = new DataBindString();
                    Answer1.ImageBitmap = FileToBitmapImage(new string[] { "Assets/Default/Icons/Check.png" }, vImageSourceFolders, vImageBackupSource, IntPtr.Zero, -1, 0);
                    Answer1.Name        = "Ok";
                    Answers.Add(Answer1);

                    await Popup_Show_MessageBox("Please select an application executable file first", "", "", Answers);

                    return;
                }

                //Prevent CtrlUI from been added to the list
                if (tb_AddAppExePath.Text.Contains("CtrlUI.exe") || tb_AddAppExePath.Text.Contains("CtrlUI-Launcher.exe"))
                {
                    List <DataBindString> Answers = new List <DataBindString>();
                    DataBindString        Answer1 = new DataBindString();
                    Answer1.ImageBitmap = FileToBitmapImage(new string[] { "Assets/Default/Icons/Check.png" }, vImageSourceFolders, vImageBackupSource, IntPtr.Zero, -1, 0);
                    Answer1.Name        = "Ok";
                    Answers.Add(Answer1);

                    await Popup_Show_MessageBox("Sorry, you can't add CtrlUI as an application", "", "", Answers);

                    return;
                }

                //Check if the application paths exist for Win32 apps
                if (vEditAppDataBind == null || (vEditAppDataBind != null && vEditAppDataBind.Type == ProcessType.Win32))
                {
                    //Validate the launch target
                    if (!File.Exists(tb_AddAppExePath.Text))
                    {
                        List <DataBindString> Answers = new List <DataBindString>();
                        DataBindString        Answer1 = new DataBindString();
                        Answer1.ImageBitmap = FileToBitmapImage(new string[] { "Assets/Default/Icons/Check.png" }, vImageSourceFolders, vImageBackupSource, IntPtr.Zero, -1, 0);
                        Answer1.Name        = "Ok";
                        Answers.Add(Answer1);

                        await Popup_Show_MessageBox("Application executable not found, please select another one", "", "", Answers);

                        return;
                    }

                    //Validate the launch path
                    if (!string.IsNullOrWhiteSpace(tb_AddAppPathLaunch.Text) && !Directory.Exists(tb_AddAppPathLaunch.Text))
                    {
                        List <DataBindString> Answers = new List <DataBindString>();
                        DataBindString        Answer1 = new DataBindString();
                        Answer1.ImageBitmap = FileToBitmapImage(new string[] { "Assets/Default/Icons/Check.png" }, vImageSourceFolders, vImageBackupSource, IntPtr.Zero, -1, 0);
                        Answer1.Name        = "Ok";
                        Answers.Add(Answer1);

                        await Popup_Show_MessageBox("Launch folder not found, please select another one", "", "", Answers);

                        return;
                    }

                    //Check if application is emulator and validate the rom path
                    if (selectedAddCategory == AppCategory.Emulator && !(bool)checkbox_AddLaunchSkipRom.IsChecked)
                    {
                        if (string.IsNullOrWhiteSpace(tb_AddAppPathRoms.Text))
                        {
                            List <DataBindString> Answers = new List <DataBindString>();
                            DataBindString        Answer1 = new DataBindString();
                            Answer1.ImageBitmap = FileToBitmapImage(new string[] { "Assets/Default/Icons/Check.png" }, vImageSourceFolders, vImageBackupSource, IntPtr.Zero, -1, 0);
                            Answer1.Name        = "Ok";
                            Answers.Add(Answer1);

                            await Popup_Show_MessageBox("Please select an emulator rom folder first", "", "", Answers);

                            return;
                        }
                        if (!Directory.Exists(tb_AddAppPathRoms.Text))
                        {
                            List <DataBindString> Answers = new List <DataBindString>();
                            DataBindString        Answer1 = new DataBindString();
                            Answer1.ImageBitmap = FileToBitmapImage(new string[] { "Assets/Default/Icons/Check.png" }, vImageSourceFolders, vImageBackupSource, IntPtr.Zero, -1, 0);
                            Answer1.Name        = "Ok";
                            Answers.Add(Answer1);

                            await Popup_Show_MessageBox("Rom folder not found, please select another one", "", "", Answers);

                            return;
                        }
                    }

                    //Check if application needs to be edited or added
                    string BtnTextContent = (sender as Button).Content.ToString();
                    if (BtnTextContent == "Add the application as filled in above")
                    {
                        //Check if new application already exists
                        if (CombineAppLists(false, false, false).Any(x => x.Name.ToLower() == tb_AddAppName.Text.ToLower() || x.PathExe.ToLower() == tb_AddAppExePath.Text.ToLower()))
                        {
                            List <DataBindString> Answers = new List <DataBindString>();
                            DataBindString        Answer1 = new DataBindString();
                            Answer1.ImageBitmap = FileToBitmapImage(new string[] { "Assets/Default/Icons/Check.png" }, vImageSourceFolders, vImageBackupSource, IntPtr.Zero, -1, 0);
                            Answer1.Name        = "Ok";
                            Answers.Add(Answer1);

                            await Popup_Show_MessageBox("This application already exists", "", "", Answers);

                            return;
                        }

                        await Notification_Send_Status("Plus", "Added " + tb_AddAppName.Text);

                        Debug.WriteLine("Adding Win32 app: " + tb_AddAppName.Text + " to the list.");
                        DataBindApp dataBindApp = new DataBindApp()
                        {
                            Type = ProcessType.Win32, Category = selectedAddCategory, Name = tb_AddAppName.Text, PathExe = tb_AddAppExePath.Text, PathLaunch = tb_AddAppPathLaunch.Text, PathRoms = tb_AddAppPathRoms.Text, Argument = tb_AddAppArgument.Text, NameExe = tb_AddAppNameExe.Text, LaunchFilePicker = (bool)checkbox_AddLaunchFilePicker.IsChecked, LaunchSkipRom = (bool)checkbox_AddLaunchSkipRom.IsChecked, LaunchKeyboard = (bool)checkbox_AddLaunchKeyboard.IsChecked
                        };
                        await AddAppToList(dataBindApp, true, true);

                        //Close the open popup
                        await Popup_Close_Top();

                        //Focus on the application list
                        if (selectedAddCategory == AppCategory.Game)
                        {
                            await ListboxFocusIndex(lb_Games, false, true, -1, vProcessCurrent.MainWindowHandle);
                        }
                        else if (selectedAddCategory == AppCategory.App)
                        {
                            await ListboxFocusIndex(lb_Apps, false, true, -1, vProcessCurrent.MainWindowHandle);
                        }
                        else if (selectedAddCategory == AppCategory.Emulator)
                        {
                            await ListboxFocusIndex(lb_Emulators, false, true, -1, vProcessCurrent.MainWindowHandle);
                        }
                    }
                    else
                    {
                        //Check if application name already exists
                        if (vEditAppDataBind.Name.ToLower() == tb_AddAppName.Text.ToLower())
                        {
                            Debug.WriteLine("Application name has not changed or just caps.");
                        }
                        else if (CombineAppLists(false, false, false).Any(x => x.Name.ToLower() == tb_AddAppName.Text.ToLower()))
                        {
                            List <DataBindString> Answers = new List <DataBindString>();
                            DataBindString        Answer1 = new DataBindString();
                            Answer1.ImageBitmap = FileToBitmapImage(new string[] { "Assets/Default/Icons/Check.png" }, vImageSourceFolders, vImageBackupSource, IntPtr.Zero, -1, 0);
                            Answer1.Name        = "Ok";
                            Answers.Add(Answer1);

                            await Popup_Show_MessageBox("This application name already exists, please use another one", "", "", Answers);

                            return;
                        }

                        //Check if application executable already exists
                        if (vEditAppDataBind.PathExe == tb_AddAppExePath.Text)
                        {
                            Debug.WriteLine("Application executable has not changed.");
                        }
                        else if (CombineAppLists(false, false, false).Any(x => x.PathExe.ToLower() == tb_AddAppExePath.Text.ToLower()))
                        {
                            List <DataBindString> Answers = new List <DataBindString>();
                            DataBindString        Answer1 = new DataBindString();
                            Answer1.ImageBitmap = FileToBitmapImage(new string[] { "Assets/Default/Icons/Check.png" }, vImageSourceFolders, vImageBackupSource, IntPtr.Zero, -1, 0);
                            Answer1.Name        = "Ok";
                            Answers.Add(Answer1);

                            await Popup_Show_MessageBox("This application executable already exists, please select another one", "", "", Answers);

                            return;
                        }

                        //Rename application logo based on name and reload it
                        string imageFileNameOld = "Assets/User/Apps/" + vEditAppDataBind.Name + ".png";
                        if (vEditAppDataBind.Name != tb_AddAppName.Text && File.Exists(imageFileNameOld))
                        {
                            Debug.WriteLine("App name changed and application logo file exists.");
                            string imageFileNameNew = "Assets/User/Apps/" + tb_AddAppName.Text + ".png";
                            File_Move(imageFileNameOld, imageFileNameNew, true);
                        }

                        //Edit application in the list
                        vEditAppDataBind.Category         = selectedAddCategory;
                        vEditAppDataBind.Name             = tb_AddAppName.Text;
                        vEditAppDataBind.PathExe          = tb_AddAppExePath.Text;
                        vEditAppDataBind.PathLaunch       = tb_AddAppPathLaunch.Text;
                        vEditAppDataBind.PathRoms         = tb_AddAppPathRoms.Text;
                        vEditAppDataBind.Argument         = tb_AddAppArgument.Text;
                        vEditAppDataBind.NameExe          = tb_AddAppNameExe.Text;
                        vEditAppDataBind.LaunchFilePicker = (bool)checkbox_AddLaunchFilePicker.IsChecked;
                        vEditAppDataBind.LaunchSkipRom    = (bool)checkbox_AddLaunchSkipRom.IsChecked;
                        vEditAppDataBind.LaunchKeyboard   = (bool)checkbox_AddLaunchKeyboard.IsChecked;
                        vEditAppDataBind.ImageBitmap      = FileToBitmapImage(new string[] { vEditAppDataBind.Name, vEditAppDataBind.PathExe, vEditAppDataBind.PathImage }, vImageSourceFolders, vImageBackupSource, IntPtr.Zero, 90, 0);

                        //Reset the application status
                        vEditAppDataBind.StatusAvailable       = Visibility.Collapsed;
                        vEditAppDataBind.StatusRunning         = Visibility.Collapsed;
                        vEditAppDataBind.StatusSuspended       = Visibility.Collapsed;
                        vEditAppDataBind.RunningProcessCount   = string.Empty;
                        vEditAppDataBind.RunningTimeLastUpdate = 0;
                        vEditAppDataBind.ProcessMulti.Clear();

                        await Notification_Send_Status("Edit", "Edited " + vEditAppDataBind.Name);

                        Debug.WriteLine("Editing application: " + vEditAppDataBind.Name + " in the list.");

                        //Save changes to Json file
                        JsonSaveApplications();

                        //Close the open popup
                        await Popup_Close_Top();

                        await Task.Delay(500);

                        //Focus on the application list
                        if (vEditAppCategoryPrevious != vEditAppDataBind.Category)
                        {
                            Debug.WriteLine("App category changed to: " + vEditAppDataBind.Category);

                            //Remove app from previous category
                            if (vEditAppCategoryPrevious == AppCategory.Game)
                            {
                                await ListBoxRemoveItem(lb_Games, List_Games, vEditAppDataBind, false);
                            }
                            else if (vEditAppCategoryPrevious == AppCategory.App)
                            {
                                await ListBoxRemoveItem(lb_Apps, List_Apps, vEditAppDataBind, false);
                            }
                            else if (vEditAppCategoryPrevious == AppCategory.Emulator)
                            {
                                await ListBoxRemoveItem(lb_Emulators, List_Emulators, vEditAppDataBind, false);
                            }

                            //Add application to new category
                            if (vEditAppDataBind.Category == AppCategory.Game)
                            {
                                await ListBoxAddItem(lb_Games, List_Games, vEditAppDataBind, false, false);
                            }
                            else if (vEditAppDataBind.Category == AppCategory.App)
                            {
                                await ListBoxAddItem(lb_Apps, List_Apps, vEditAppDataBind, false, false);
                            }
                            else if (vEditAppDataBind.Category == AppCategory.Emulator)
                            {
                                await ListBoxAddItem(lb_Emulators, List_Emulators, vEditAppDataBind, false, false);
                            }

                            //Focus on the edited item listbox
                            if (vSearchOpen)
                            {
                                await ListboxFocusIndex(lb_Search, false, false, -1, vProcessCurrent.MainWindowHandle);
                            }
                            else
                            {
                                if (vEditAppDataBind.Category == AppCategory.Game)
                                {
                                    await ListboxFocusIndex(lb_Games, false, true, -1, vProcessCurrent.MainWindowHandle);
                                }
                                else if (vEditAppDataBind.Category == AppCategory.App)
                                {
                                    await ListboxFocusIndex(lb_Apps, false, true, -1, vProcessCurrent.MainWindowHandle);
                                }
                                else if (vEditAppDataBind.Category == AppCategory.Emulator)
                                {
                                    await ListboxFocusIndex(lb_Emulators, false, true, -1, vProcessCurrent.MainWindowHandle);
                                }
                            }
                        }
                        else
                        {
                            //Focus on the item listbox
                            if (vSearchOpen)
                            {
                                await ListboxFocusIndex(lb_Search, false, false, -1, vProcessCurrent.MainWindowHandle);
                            }
                            else
                            {
                                if (vEditAppDataBind.Category == AppCategory.Game)
                                {
                                    await ListboxFocusIndex(lb_Games, false, false, -1, vProcessCurrent.MainWindowHandle);
                                }
                                else if (vEditAppDataBind.Category == AppCategory.App)
                                {
                                    await ListboxFocusIndex(lb_Apps, false, false, -1, vProcessCurrent.MainWindowHandle);
                                }
                                else if (vEditAppDataBind.Category == AppCategory.Emulator)
                                {
                                    await ListboxFocusIndex(lb_Emulators, false, false, -1, vProcessCurrent.MainWindowHandle);
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine("App edit failed: " + ex.Message);
            }
        }
Example #18
0
 public SyncTicketDataManage(AppCategory category, string connString)
 {
     appType      = category;
     dbConnString = connString;
 }