예제 #1
0
 private void setStyles()
 {
     background.Background     = Styles.theme();
     aTitle.Foreground         = Styles.text();
     aDescription.Foreground   = Styles.text();
     appFunctionTXT.Foreground = Styles.text();
     appFunction.Background    = Styles.accent();
     //moreOptionsTXT.Foreground = Styles.text();
 }
예제 #2
0
 private void setStyles()
 {
     windowTitle.Foreground   = Styles.text();
     titleBar.Background      = Styles.accent();
     windowBorder.BorderBrush = Styles.accent();
     messageBox.Foreground    = Styles.text();
     messageBox.CaretBrush    = Styles.text();
     background.Background    = Styles.theme();
     btnYes.Background        = Styles.button();
     btnCancel.Background     = Styles.button();
     btnNo.Background         = Styles.button();
     btnOk.Background         = Styles.button();
     btnYes.Foreground        = Styles.text();
     btnCancel.Foreground     = Styles.text();
     btnNo.Foreground         = Styles.text();
     btnOk.Foreground         = Styles.text();
 }
예제 #3
0
        private void Page_Loaded(object sender, RoutedEventArgs e)
        {
            BitmapImage appIconImage = new BitmapImage();

            appIconImage.BeginInit();
            appIconImage.StreamSource = new MemoryStream(Convert.FromBase64String(aImage));
            appIconImage.EndInit();

            aIcon.Source      = appIconImage;
            aTitle.Content    = aAppName;
            aDescription.Text = aDesc;

            if (File.Exists(AppDomain.CurrentDomain.BaseDirectory + $"\\{aNameSub}\\{aNameSub}.dll"))
            {
                appFunctionTXT.Content = "Launch";
            }
            else
            {
                appFunctionTXT.Content = "Install";
            }

            if (AppLibaryPage.runningPrograms.Contains(aNameSub))
            {
                appFunctionTXT.Content = "Running";
                appFunction.Background = Styles.button();
                appFunction.MouseDown -= appFunction_Click;
                System.Timers.Timer waitForExit = new System.Timers.Timer();
                waitForExit.Elapsed += WaitForExit_Elapsed;
                waitForExit.Interval = 100;
                waitForExit.Start();

                void WaitForExit_Elapsed(object s, System.Timers.ElapsedEventArgs ea)
                {
                    if (!AppLibaryPage.runningPrograms.Contains(aNameSub))
                    {
                        Dispatcher.Invoke(() =>
                        {
                            appFunctionTXT.Content = "Launch";
                            appFunction.Background = Styles.accent();
                            appFunction.MouseDown += appFunction_Click;
                        });
                    }
                }
            }
        }
예제 #4
0
 public NotificationBox(string text, string title, int time)
 {
     InitializeComponent();
     windowBorder.Visibility  = Visibility.Visible;
     background.Background    = Styles.theme();
     nTitle.Foreground        = Styles.text();
     nBody.Foreground         = Styles.text();
     backBTN.Foreground       = Styles.text();
     windowBorder.BorderBrush = Styles.accent();
     Left                   = SystemParameters.WorkArea.Width - Width - 10;
     Top                    = SystemParameters.WorkArea.Height - Height - 10;
     nTitle.Content         = title;
     nBody.Text             = text;
     timeOpen               = time;
     timeTillClose.Interval = 1000;
     timeTillClose.Tick    += TimeTillClose_Tick;
     timeTillClose.Start();
     Visibility = Visibility.Visible;
     Activate();
 }
예제 #5
0
        private void appFunction_Click(object sender, MouseButtonEventArgs e)
        {
            if (File.Exists(AppDomain.CurrentDomain.BaseDirectory + $"\\{aNameSub}\\{aNameSub}.dll"))
            {
                if (e.ChangedButton == MouseButton.Left)
                {
                    Label installedText = null;
                    foreach (Label l in AppLibaryPage.statusTexts)
                    {
                        if (l.Tag.ToString() == aNameSub)
                        {
                            installedText = l; break;
                        }
                    }

                    if (mainOption)
                    {
                        if (!AppLibaryPage.runningPrograms.Contains(aNameSub))
                        {
                            try
                            {
                                var    mw   = Application.Current.MainWindow as AppLibaryWindow;
                                string args = string.Empty;
                                AppLibaryPage.runningPrograms.Add(aNameSub);
                                appFunctionTXT.Content = "Running";
                                installedText.Content  = "Running";
                                appFunction.Background = Styles.button();
                                mw.hideWindow();
                                //appFunction.Click += (s, ea) => { };
                                appFunction.MouseDown -= appFunction_Click;
                                Task.Run(() =>
                                {
                                    try
                                    {
                                        AppDomain appDLL = AppDomain.CreateDomain($"{aNameSub}DLL");
                                        Assembly appdll  = appDLL.Load(aNameSub);
                                        Type[] DLL       = appdll.GetTypes();
                                        int classToLoad  = 0;
                                        foreach (var type in DLL)
                                        {
                                            if (type.ToString().Contains("Startup"))
                                            {
                                                break;
                                            }
                                            else
                                            {
                                                classToLoad += 1;
                                            }
                                        }
                                        dynamic startup = Activator.CreateInstance(DLL[classToLoad]);
                                        //fromUpdaterDLL.tasks(args);

                                        Thread t = new Thread(() =>
                                        {
                                            startup.tasks(args);
                                            AppDomain.Unload(appDLL);
                                            Dispatcher.Invoke(() =>
                                            {
                                                AppLibaryPage.runningPrograms.Remove(aNameSub);
                                                appFunctionTXT.Content = "Launch";
                                                installedText.Content  = "Installed";
                                                appFunction.Background = Styles.accent();
                                                appFunction.MouseDown += appFunction_Click;
                                                mw.showWindow();
                                            });
                                        });
                                        t.SetApartmentState(ApartmentState.STA);
                                        t.Start();
                                    }
                                    catch (Exception ex)
                                    {
                                        LogWriter.CreateLog(ex);
                                        msgBox.Show("An error occured while hosting the DLL.", $"Error Hosting {aAppName}.");
                                        try { AppLibaryPage.runningPrograms.Remove(aNameSub); } catch { }
                                    }
                                });
                            }
                            catch (Exception ex) { LogWriter.CreateLog(ex); msgBox.Show($"Error Launching {aAppName}", "Error Launching App"); }
                        }
                        else
                        {
                            appFunction.MouseDown -= appFunction_Click;
                        }
                    }
                    else
                    {
                        Directory.Delete(AppDomain.CurrentDomain.BaseDirectory + $"\\{aNameSub}", true);
                        appFunction.Background = Styles.accent();
                        appFunctionTXT.Content = "Install";
                        installedText.Content  = "Install";
                    }
                }
                if (e.ChangedButton == MouseButton.Right)
                {
                    if (mainOption)
                    {
                        appFunction.Background = Styles.b("#FFFF0000");
                        appFunctionTXT.Content = "Uninstall";
                        mainOption             = false;
                    }
                    else
                    {
                        appFunction.Background = Styles.accent();
                        appFunctionTXT.Content = "Launch";
                        mainOption             = true;
                    }
                }
            }
            else
            {
                var mw = Application.Current.MainWindow as AppLibaryWindow;
                mw.downloadFile(aAppName, aVersion);
            }
        }
예제 #6
0
        private void getApps()
        {
            Task.Run(async() =>
            {
                if (AppLibaryWindow.startupArgs.Contains("noupdate"))
                {
                    getOfflineModeApps();
                }
                else
                {
                    try
                    {
                        IReadOnlyList <Octokit.Repository> repos = await httpGit.githubClient.Repository.GetAllForUser("kOFReadie");
                        foreach (Octokit.Repository repo in repos)
                        {
                            try
                            {
                                HttpResponseMessage response = await httpGit.httpClient.GetAsync
                                                                   ($"https://raw.githubusercontent.com/kOFReadie/{repo.Name}/master/AppInfo.json");
                                response.EnsureSuccessStatusCode();
                                try
                                {
                                    string responseContent = await response.Content.ReadAsStringAsync();
                                    appDataInfo.Add(JsonConvert.DeserializeObject <List <appData> >(responseContent)[0]);
                                }
                                catch (Exception ex) { msgBox.Show("Failed to get app information"); LogWriter.CreateLog(ex); }
                            }
                            catch { continue; }
                        }
                    }
                    catch (Exception ex)
                    {
                        LogWriter.CreateLog(ex);
                        getOfflineModeApps();
                        msgBox.Show("Failed to get apps. Attempting to run in offline mode.\nError written to log file.");
                    }
                }
            }).Wait();

            if (appDataInfo == null)
            {
                msgBox.Show("Failed to get installed apps, no apps found.\nThis app will now close."); Environment.Exit(0);
            }
            foreach (var appInfo in appDataInfo)
            {
                if (appInfo.show == true || AppLibaryWindow.startupArgs.Contains("showall"))
                {
                    string   aNameSub = string.Empty;
                    string[] sName    = appInfo.appName.Split(' ');
                    foreach (string s in sName)
                    {
                        aNameSub = aNameSub + s;
                    }

                    Grid appTilePlate = new Grid();
                    appTilePlate.Width = 105;
                    appTilePlate.HorizontalAlignment = HorizontalAlignment.Left;
                    appTilePlate.VerticalAlignment   = VerticalAlignment.Top;
                    appTilePlate.Tag        = appInfo.appName;
                    appTilePlate.Margin     = new Thickness(5, 5, 5, 5);
                    appTilePlate.MouseDown += appPage;

                    ProgressBar progressBar = new ProgressBar();
                    progressBar.Visibility  = Visibility.Hidden;
                    progressBar.Background  = null;
                    progressBar.BorderBrush = null;
                    progressBar.Foreground  = Styles.accent();
                    progressBar.Tag         = $"pg{appInfo.appName}";

                    WrapPanel appTile = new WrapPanel();
                    appTile.Tag         = appInfo.appName;
                    appTile.Orientation = Orientation.Vertical;
                    appTile.MouseLeave += appTile_MouseLeave;
                    appTile.MouseEnter += appTile_MouseEnter;

                    #region App Icon
                    BitmapImage appIconImage = new BitmapImage();
                    appIconImage.BeginInit();
                    appIconImage.StreamSource = new MemoryStream(Convert.FromBase64String(appInfo.icon));
                    appIconImage.EndInit();

                    Image appIcon = new Image();
                    appIcon.Height = 100;
                    appIcon.Width  = 100;
                    appIcon.Margin = new Thickness(2.5, 0, 0, 0);
                    appIcon.Source = appIconImage;
                    #endregion

                    TextBlock appName = new TextBlock();
                    appName.FontWeight   = FontWeights.Bold;
                    appName.Margin       = new Thickness(5, 0, 0, 0);
                    appName.FontSize     = 14;
                    appName.TextWrapping = TextWrapping.Wrap;
                    if (appInfo.appName.Length > 12)
                    {
                        appName.Text = appInfo.appName.Substring(0, 12) + "...";
                    }
                    else
                    {
                        appName.Text = appInfo.appName;
                    }
                    appName.Foreground = Styles.text();

                    string installStatus;
                    if (File.Exists(AppDomain.CurrentDomain.BaseDirectory + $"\\{aNameSub}\\{aNameSub}.dll"))
                    {
                        installStatus = "Installed";
                    }
                    else
                    {
                        installStatus = "Install";
                    }

                    Label statusText = new Label();
                    statusText.FontSize   = 11;
                    statusText.Margin     = new Thickness(0, -5, 0, 0);
                    statusText.Content    = installStatus;
                    statusText.Foreground = Styles.text();
                    statusText.Tag        = appInfo.appName.ToLower().Replace(" ", "");

                    #region Tile Assembly
                    appTile.Children.Add(appIcon);
                    appTile.Children.Add(appName);
                    appTile.Children.Add(statusText);

                    appTilePlate.Children.Add(progressBar);
                    appTilePlate.Children.Add(appTile);
                    appTilesPane.Children.Insert(0, appTilePlate);
                    #endregion

                    appTiles.Add(appTilePlate);
                    wrapPanels.Add(appTile);
                    progressBars.Add(progressBar);
                    statusTexts.Add(statusText);
                }
            }
        }
예제 #7
0
        private void appTile_MouseEnter(object sender, MouseEventArgs e)
        {
            var appTile = sender as WrapPanel;

            appTile.Background = Styles.accent();
        }