Esempio n. 1
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();
 }
Esempio n. 2
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;
                        });
                    }
                }
            }
        }
Esempio n. 3
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);
            }
        }
Esempio n. 4
0
        public Home()
        {
            InitializeComponent();
            try
            {
                background.Background = Styles.theme();
                appName.Foreground    = Styles.text();
                appVersion.Foreground = Styles.text();
                appNameLine.Stroke    = Styles.gBWHorizontal;
                string[] appVersionSS = FileVersionInfo.GetVersionInfo(AppDomain.CurrentDomain.BaseDirectory + "kOFRRepo.dll").FileVersion.Split('.');
                appVersion.Text = $"v{appVersionSS[0]}.{appVersionSS[1]}.{appVersionSS[2]}";

                List <notices> noticesInfo = JsonConvert.DeserializeObject <List <notices> >(AppLibaryWindow.updateInfoJSON);
                foreach (var noticeData in noticesInfo)
                {
                    if (noticeData.show == true || AppLibaryWindow.startupArgs.Contains("showall"))
                    {
                        Grid grid = new Grid();
                        grid.Margin = new Thickness(15, 15, 0, 0);
                        grid.Width  = 175;
                        grid.Height = 210;

                        Rectangle rectangle = new Rectangle();
                        rectangle.Fill    = Styles.button();
                        rectangle.RadiusX = 10;
                        rectangle.RadiusY = 10;

                        WrapPanel wrappanel = new WrapPanel();
                        wrappanel.Width               = 175;
                        wrappanel.Orientation         = Orientation.Vertical;
                        wrappanel.HorizontalAlignment = HorizontalAlignment.Left;
                        wrappanel.VerticalAlignment   = VerticalAlignment.Top;

                        TextBlock Title = new TextBlock();
                        Title.Margin       = new Thickness(10, 10, 0, 0);
                        Title.Width        = 155;
                        Title.TextWrapping = TextWrapping.Wrap;
                        Title.Text         = noticeData.title;
                        Title.FontFamily   = new FontFamily("Century Gothic");
                        Title.FontSize     = 18;
                        Title.Foreground   = Styles.text();

                        TextBlock body = new TextBlock();
                        body.Margin       = new Thickness(10, 5, 0, 0);
                        body.Width        = 155;
                        body.Height       = double.NaN;
                        body.TextWrapping = TextWrapping.Wrap;
                        body.Text         = noticeData.body;
                        body.FontFamily   = new FontFamily("Century Gothic");
                        body.FontSize     = 12;
                        body.Foreground   = Styles.text();

                        wrappanel.Children.Add(Title);
                        wrappanel.Children.Add(body);
                        grid.Children.Add(rectangle);
                        grid.Children.Add(wrappanel);
                        updateWrapPanel.Children.Insert(0, grid);
                    }
                }
            }
            catch (Exception ex) { LogWriter.CreateLog(ex); msgBox.Show("Failed to get alerts from server."); }
        }