Example #1
0
        private void InitializeTrayIcon()
        {
            TrayIcon = new TrayIndicator
            {
                Title   = "Titan",
                Image   = SharedResources.TITAN_ICON,
                Visible = true,
                Menu    = new ContextMenu
                {
                    Items =
                    {
                        new Command((sender, args) => ShowForm(UIType.General))
                        {
                            MenuText = "Show"
                        },
                        new Command((sender, args) => Environment.Exit(0))
                        {
                            MenuText = "Exit"
                        }
                    }
                }
            };

            GetForm <General.GeneralUI>(UIType.General).Closing += (sender, args) =>
            {
                HideForm(UIType.General);

                SendNotification("Titan", "Titan will continue to run in the background " +
                                 "and will notify you as soon as a victim got banned.",
                                 () => ShowForm(UIType.General));

                args.Cancel = true;
            };
        }
Example #2
0
        //Everything has to be sent in on the constructor since things do not auto-refresh / update this is a limitation
        public LinuxTrayIcon(string TooTip, string IconPath, Avalonia.Controls.ContextMenu _menu)
        {
            Dispatcher.UIThread.Post(() =>
            {
                var ctxMnu = new Eto.Forms.ContextMenu();
                foreach (var x in _menu.Items.Cast <Avalonia.Controls.MenuItem>())
                {
                    ButtonMenuItem bmi = new ButtonMenuItem();
                    bmi.Text           = x.Header.ToString();
                    bmi.Command        = new Command((s, e) => { Dispatcher.UIThread.Post(() =>
                        {
                            x.Command.Execute(null);
                        }); });
                    ctxMnu.Items.Add(bmi);
                }

                ClientSize = new Size(200, 200);
                _tray      = new TrayIndicator
                {
                    Image = Eto.Drawing.Icon.FromResource(IconPath.Replace("resm:", "")),
                    Menu  = ctxMnu,
                    Title = ToolTip
                };

                _tray.Show();
                _tray.Visible = true;
            });
        }
        public void Show(TrayIndicator indicator = null)
        {
            if (!init)
            {
                return;
            }

            // Empty string will show the default icon, while an incorrect one will show no icon
            var notification = new NotificationWrapper(notify_notification_new(Title, Message, iconPath ?? "???"));
            var data         = Marshal.StringToHGlobalUni(ID + (char)1 + UserData);

#if !GTK2
            notification.Closed += (sender, e) =>
            {
                Marshal.FreeHGlobal(data);
                notification.Dispose();
            };
#endif

            if (allowactions)
            {
                // Undocumented AFAIK: If action is "default" it will not create a button.
                notify_notification_add_action(
                    notification.Handle,
                    "default",
                    "default",
                    Delegate.CreateDelegate(typeof(ActivatedDelegate), activatedmethod),
                    data,
                    IntPtr.Zero
                    );
            }

            notify_notification_show(notification.Handle, IntPtr.Zero);
        }
Example #4
0
        public void Show(TrayIndicator indicator = null)
        {
            if (!init)
            {
                return;
            }

            // Empty string will show the default icon, while an incorrect one will show no icon
            notify_notification_update(Control.Handle, Title, Message, iconPath ?? "???");
            notify_notification_show(Control.Handle, IntPtr.Zero);
        }
Example #5
0
 TrayIndicator GetSharedIndicator()
 {
     if (s_sharedIndicator == null)
     {
         s_sharedIndicator = new TrayIndicator
         {
             Image = Application.Instance?.MainForm?.Icon ?? sd.SystemIcons.Application.ToEto()
         };
     }
     s_sharedIndicator.Show();
     return(s_sharedIndicator);
 }
Example #6
0
        public TrayIcon(MainForm window)
        {
            var showWindow = new ButtonMenuItem
            {
                Text = "Show Window"
            };

            showWindow.Click += (sender, e) =>
            {
                window.Show();
                window.WindowState = WindowState.Normal;
                window.BringToFront();
                window.WindowStyle = WindowStyle.Default;
            };

            var restart = new ButtonMenuItem
            {
                Text = "Restart"
            };

            restart.Click += (sender, e) => Application.Instance.Restart();

            var close = new ButtonMenuItem
            {
                Text = "Close"
            };

            close.Click += (sender, e) => window.Close();

            indicator = new TrayIndicator
            {
                Title = "OpenTabletDriver",
                Image = App.Logo,
                Menu  = new ContextMenu
                {
                    Items =
                    {
                        showWindow,
                        restart,
                        close
                    }
                }
            };
            indicator.Activated += (object sender, System.EventArgs e) =>
            {
                window.Show();
                window.WindowState = WindowState.Normal;
                window.BringToFront();
                window.WindowStyle = WindowStyle.Default;
            };
            indicator.Show();
        }
Example #7
0
        private TrayIndicator CreateTrayIndicator()
        {
            var tray = new TrayIndicator
            {
                Image = !Platform.IsGtk ? DesktopAppResources.DevAppIcon : DesktopAppResources.DevAppLogo,
                Title = CoreApp.AssemblyProduct
            };

            var menu = new ContextMenu();

            menu.Items.Add(_menuItemAbout);
            menu.Items.Add(_menuItemPreferences);
            menu.Items.Add(_menuItemExit);
            tray.Menu = menu;

            return(tray);
        }
Example #8
0
        public TrayIndicatorSection()
        {
            tray       = new TrayIndicator();
            tray.Image = TestIcons.TestIcon;
            tray.Title = "Eto Test App";

            var menu = new ContextMenu();

            menu.Items.Add(new Commands.About());
            menu.Items.Add(new Commands.Quit());
            tray.Menu = menu;

            tray.Activated += (o, e) => MessageBox.Show("Hello World!!!");

            tray.Show();

            Content = TableLayout.AutoSized("Tray should now be visible");
        }
Example #9
0
        public TrayIcon(MainForm window)
        {
            this.window = window;

            Indicator = new TrayIndicator
            {
                Title = "OpenTabletDriver",
                Image = App.Logo
            };

            RefreshMenuItems();

            Indicator.Activated += (object sender, System.EventArgs e) =>
            {
                window.Show();
                window.BringToFront();
            };
        }
Example #10
0
        public void Show(TrayIndicator indicator = null)
        {
            indicator = indicator ?? GetSharedIndicator();
            var notifyIcon = TrayIndicatorHandler.GetControl(indicator);

            var currentNotification = indicator.Properties.Get <NotificationHandler>(NotificationHandler_Key);

            if (currentNotification != null)
            {
                currentNotification.Unhook(notifyIcon);
                indicator.Properties.Remove(NotificationHandler_Key);
            }

            notifyIcon.ShowBalloonTip(3000, Title, Message, swf.ToolTipIcon.Error);
            notifyIcon.BalloonTipClicked += Tray_BalloonTipClicked;
            notifyIcon.BalloonTipClosed  += Tray_BalloonTipClosed;
            indicator.Properties.Set(NotificationHandler_Key, this);
        }
Example #11
0
        public TrayIcon(MainForm window)
        {
            var showWindow = new ButtonMenuItem
            {
                Text = "Show Window"
            };

            showWindow.Click += (sender, e) =>
            {
                window.Show();
                window.BringToFront();
            };

            var close = new ButtonMenuItem
            {
                Text = "Close"
            };

            close.Click += (sender, e) => window.Close();

            indicator = new TrayIndicator
            {
                Title = "OpenTabletDriver",
                Image = App.Logo,
                Menu  = new ContextMenu
                {
                    Items =
                    {
                        showWindow,
                        close
                    }
                }
            };
            indicator.Activated += (object sender, System.EventArgs e) =>
            {
                window.Show();
                window.BringToFront();
            };
            indicator.Show();
        }
Example #12
0
        public MainForm()
        {
            // Exit if we're already running the AM2RLauncher
            // Thanks, StackOverflow! https://stackoverflow.com/questions/184084/how-to-force-c-sharp-net-app-to-run-only-one-instance-in-windows
            if (!singleInstance)
            {
                // If on Windows, set the original app to the foreground window to prevent confusion
                if (OS.IsWindows)
                {
                    Process current = Process.GetCurrentProcess();
                    Process process = Process.GetProcessesByName(current.ProcessName).First(p => p.Id == current.Id);
                    if (process != null)
                    {
                        Core.Core.SetForegroundWindow(process.MainWindowHandle);
                    }
                }
                Environment.Exit(0);
            }

            log.Info("Mutex check passed. Entering main thread.");
            log.Info("Current Launcher Version: " + VERSION);
            log.Info("Current Platform-ID is: " + Platform.ID);
            log.Info("Current OS is: " + OS.Name);

            // Set the Current Directory to the path the Launcher is located. Fixes some relative path issues.
            Environment.CurrentDirectory = CrossPlatformOperations.CURRENTPATH;
            log.Info("Set Launcher CWD to " + Environment.CurrentDirectory);

            // But log actual folder location nonetheless
            log.Info("Actual Launcher location: " + Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory));

            // Set the language to what User wanted or choose local language
            string userLanguage = CrossPlatformOperations.ReadFromConfig("Language").ToLower();

            if (!userLanguage.Equals("default"))
            {
                Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultures(CultureTypes.AllCultures).First(c => c.NativeName.ToLower().Contains(userLanguage));
            }

            log.Info("Language has been set to: " + Thread.CurrentThread.CurrentUICulture.EnglishName);

            #region VARIABLE INITIALIZATION
            log.Info("Beginning UI initialization...");

            Bitmap am2rIcon = new Bitmap(AM2RLauncher.Properties.Resources.AM2RIcon);

            // System tray indicator
            ButtonMenuItem showButton = new ButtonMenuItem {
                Text = Text.TrayButtonShow
            };
            trayIndicator = new TrayIndicator
            {
                Menu    = new ContextMenu(showButton),
                Title   = "AM2RLauncher",
                Visible = false,
                Image   = am2rIcon
            };

            // Create menubar with defaults for mac
            if (OS.IsMac)
            {
                Menu = new MenuBar();
            }

            // Create array from validCount
            profileList = new List <ProfileXML>();

            //TODO: whenever profileDropDown gets rewritten to use a datastore, scrap this
            profileNames = new List <ListItem>();
            foreach (var profile in profileList)
            {
                profileNames.Add(profile.Name);
            }

            // Custom splash texts
            string splash = Splash.GetSplash();
            log.Info("Randomly chosen splash: " + splash);

            Font smallButtonFont = new Font(SystemFont.Default, 10);

            // Create mirror list - eventually this should be platform specific!
            // We do this as a List<Uri> so we can add more dynamically on user input... if necessary.
            mirrorList = CrossPlatformOperations.GenerateMirrorList();

            // Create mirror list
            // We do this as a list<listItem> for 1) make this dynamic and 2) make ETO happy
            mirrorDescriptionList = new List <ListItem>();
            // Add each entry dynamically instead of harcoding it to two. If we have neither a github or gitlab mirror, we use the mirror itself as text
            foreach (var mirror in mirrorList)
            {
                string text = mirror;
                if (text.Contains("github.com"))
                {
                    text = Text.MirrorGithubText;
                }
                else if (text.Contains("gitlab.com"))
                {
                    text = Text.MirrorGitlabText;
                }
                mirrorDescriptionList.Add(new ListItem()
                {
                    Key = mirror, Text = text
                });
            }
            #endregion

            Icon        = new Icon(1f, am2rIcon);
            Title       = "AM2RLauncher " + VERSION + ": " + splash;
            MinimumSize = new Size(500, 400);
            // TODO: for some reason, this sometimes doesn't work on Linux. Was reported at eto, stays here until its fixed
            ClientSize = new Size(Int32.Parse(CrossPlatformOperations.ReadFromConfig("Width")), Int32.Parse(CrossPlatformOperations.ReadFromConfig("Height")));
            if (ClientSize.Width < 500)
            {
                ClientSize = new Size(500, ClientSize.Height);
            }
            if (ClientSize.Height < 400)
            {
                ClientSize = new Size(ClientSize.Width, 400);
            }
            log.Info("Start the launcher with Size: " + ClientSize.Width + ", " + ClientSize.Height);
            if (Boolean.Parse(CrossPlatformOperations.ReadFromConfig("IsMaximized")))
            {
                Maximize();
            }

            drawable = new Drawable {
                BackgroundColor = colBGNoAlpha
            };

            // Drawable paint event
            drawable.Paint += DrawablePaintEvent;
            // Some systems don't call the paintEvent by default and only do so after actual resizing
            if (OS.IsMac)
            {
                LoadComplete += (sender, e) => { Size = new Size(Size.Width + 1, Size.Height); Size = new Size(Size.Width - 1, Size.Height); }
            }
            ;

            #region MAIN WINDOW

            // Center buttons/interface panel
            var centerInterface = new DynamicLayout();

            // PLAY button
            playButton = new ColorButton
            {
                ToolTip = "",
                BackgroundColorHover = colBGHover,
                Height             = 40,
                Width              = 250,
                TextColor          = colGreen,
                TextColorDisabled  = colInactive,
                BackgroundColor    = colBG,
                FrameColor         = colGreen,
                FrameColorDisabled = colInactive
            };

            UpdateStateMachine();

            SetPlayButtonState(updateState);

            centerInterface.AddRow(playButton);

            // 2px spacer between playButton and apkButton (Windows only)
            if (OS.IsWindows)
            {
                centerInterface.AddRow(new Label {
                    BackgroundColor = colBG, Height = 2
                });
            }

            // APK button
            apkButton = new ColorButton
            {
                Text                 = Text.CreateAPK,
                Height               = 40,
                Width                = 250,
                TextColor            = colGreen,
                BackgroundColor      = colBG,
                FrameColor           = colGreen,
                BackgroundColorHover = colBGHover
            };

            centerInterface.AddRow(apkButton);

            progressBar = new ProgressBar
            {
                Visible = false,
                Height  = 15
            };

            // 4px spacer between APK button and progressBar (Windows only)
            if (OS.IsWindows)
            {
                centerInterface.AddRow(new Label {
                    BackgroundColor = colBG, Height = 4
                });
            }

            centerInterface.AddRow(progressBar);

            progressLabel = new Label
            {
                BackgroundColor = colBG,
                Height          = 15,
                Text            = "",
                TextColor       = colGreen,
                Visible         = false
            };

            centerInterface.AddRow(progressLabel);

            // 3px spacer between progressBar and profile label (Windows only)
            if (OS.IsWindows)
            {
                centerInterface.AddRow(new Label {
                    BackgroundColor = colBG, Height = 3
                });
            }

            profileLabel = new Label
            {
                BackgroundColor = colBG,
                Height          = 15,
                Text            = Text.CurrentProfile,
                TextColor       = colGreen
            };

            centerInterface.AddRow(profileLabel);

            // Profiles dropdown

            // Yes, we know this looks horrific on GTK. Sorry.
            // We're not exactly in a position to rewrite the entire DropDown object as a Drawable child, but if you want to, you're more than welcome!
            // Mac gets a default BackgroundColor because it looks waaaaaaay better.
            profileDropDown = new DropDown
            {
                TextColor       = colGreen,
                BackgroundColor = OS.IsWindows ? colBGNoAlpha : new Color()
            };
            // In order to not have conflicting theming, we just always respect the users theme for dropdown on GTK.
            if (OS.IsLinux)
            {
                profileDropDown = new DropDown();
            }

            profileDropDown.Items.AddRange(profileNames);   // It's actually more comfortable if it's outside, because of GTK shenanigans

            centerInterface.AddRow(profileDropDown);

            // Profiles label
            profileAuthorLabel = new Label
            {
                BackgroundColor = colBG,
                Height          = 16,
                Text            = Text.Author + " ",
                TextColor       = colGreen
            };

            centerInterface.AddRow(profileAuthorLabel);

            profileVersionLabel = new Label
            {
                BackgroundColor = colBG,
                Height          = 16,
                Text            = Text.VersionLabel + " ",
                TextColor       = colGreen
            };

            centerInterface.AddRow(profileVersionLabel);

            saveWarningLabel = new Label
            {
                Visible         = false,
                BackgroundColor = colBG,
                Width           = 20,
                Height          = 55,
                Text            = Text.SaveLocationWarning,
                TextColor       = colRed
            };

            centerInterface.AddRow(saveWarningLabel);


            // Social buttons
            Bitmap redditIcon   = new Bitmap(Resources.redditIcon48);
            var    redditButton = new ImageButton {
                ToolTip = Text.RedditToolTip, Image = redditIcon
            };
            redditButton.Click += (sender, e) => CrossPlatformOperations.OpenURL("https://www.reddit.com/r/AM2R");

            Bitmap githubIcon   = new Bitmap(Resources.githubIcon48);
            var    githubButton = new ImageButton {
                ToolTip = Text.GithubToolTip, Image = githubIcon
            };
            githubButton.Click += (sender, e) => CrossPlatformOperations.OpenURL("https://www.github.com/AM2R-Community-Developers");

            Bitmap youtubeIcon   = new Bitmap(Resources.youtubeIcon48);
            var    youtubeButton = new ImageButton {
                ToolTip = Text.YoutubeToolTip, Image = youtubeIcon
            };
            youtubeButton.Click += (sender, e) => CrossPlatformOperations.OpenURL("https://www.youtube.com/c/AM2RCommunityUpdates");

            Bitmap discordIcon   = new Bitmap(Resources.discordIcon48);
            var    discordButton = new ImageButton {
                ToolTip = Text.DiscordToolTip, Image = discordIcon
            };
            discordButton.Click += (sender, e) => CrossPlatformOperations.OpenURL("https://discord.gg/nk7UYPbd5u");


            // Social button panel
            var socialPanel = new DynamicLayout();
            socialPanel.BeginVertical();
            socialPanel.AddRow(redditButton);
            socialPanel.AddRow(githubButton);
            socialPanel.AddRow(youtubeButton);
            socialPanel.AddRow(discordButton);
            socialPanel.EndVertical();


            // Version number label
            Label versionLabel = new Label
            {
                Text  = "v" + VERSION + (isThisRunningFromWine ? "-WINE" : ""),
                Width = 48, TextAlignment = TextAlignment.Right, TextColor = colGreen,
                Font  = new Font(SystemFont.Default, 12)
            };

            // Tie everything together
            var mainLayout = new DynamicLayout();

            mainLayout.BeginHorizontal();
            mainLayout.AddColumn(null, socialPanel);

            mainLayout.AddSpace();
            mainLayout.AddColumn(null, centerInterface, null);
            mainLayout.AddSpace();

            // Yes, I'm hardcoding this string. Linux users can english.
            mainLayout.AddColumn(versionLabel, isThisRunningFromWine ? new Label {
                Text = "Unsupported", TextColor = colRed, TextAlignment = TextAlignment.Right
            } : null);

            drawable.Content = mainLayout;

            #endregion

            #region TABS

            #region MAIN PAGE
            // [MAIN PAGE]
            TabPage mainPage = new TabPage
            {
                BackgroundColor = colBGNoAlpha,
                Text            = Text.PlayTab,
                Content         = drawable
            };
            #endregion

            #region CHANGELOG PAGE
            // [CHANGELOG]
            Uri     changelogUri     = new Uri("https://am2r-community-developers.github.io/DistributionCenter/changelog.html");
            WebView changelogWebView = new WebView {
                Url = changelogUri
            };

            if (OS.IsUnix && !isInternetThere)
            {
                changelogWebView = new WebView();
            }

            Label changelogNoConnectionLabel = new Label
            {
                Text      = Text.NoInternetConnection,
                TextColor = colGreen
            };

            TabPage changelogPage = new TabPage
            {
                BackgroundColor = colBGNoAlpha,
                Text            = Text.ChangelogTab,

                Content = new TableLayout
                {
                    Rows =
                    {
                        changelogWebView
                    }
                }
            };

            #endregion

            #region NEWS PAGE

            // [NEWS]
            Uri     newsUri     = new Uri("https://am2r-community-developers.github.io/DistributionCenter/news.html");
            WebView newsWebView = new WebView {
                Url = newsUri
            };

            //TODO: why exactly is this check necessary?
            if (OS.IsUnix && !isInternetThere)
            {
                newsWebView = new WebView();
            }

            Label newsNoConnectionLabel = new Label
            {
                Text      = Text.NoInternetConnection,
                TextColor = colGreen
            };

            TabPage newsPage = new TabPage
            {
                Text            = Text.NewsTab,
                BackgroundColor = colBGNoAlpha,

                Content = new TableLayout
                {
                    Rows =
                    {
                        newsWebView
                    }
                }
            };

            //TODO: this is hack because on linux / mac the other way doesn't work. eto issue?
            if (OS.IsUnix && !isInternetThere)
            {
                changelogPage.Content = new TableLayout
                {
                    Rows =
                    {
                        null,
                        changelogNoConnectionLabel,
                        null
                    }
                };
                newsPage.Content = new TableLayout
                {
                    Rows =
                    {
                        null,
                        newsNoConnectionLabel,
                        null
                    }
                };
            }

            #endregion

            #region SETTINGS PAGE

            // [LAUNCHER SETTINGS]
            DynamicLayout settingsLayout = new DynamicLayout();

            // LanguageLabel
            Label languageLabel = new Label
            {
                Text      = Text.LanguageNotice,
                TextColor = colGreen
            };

            // Language DropDown menu

            List <ListItem> languageList = new List <ListItem>
            {
                Text.SystemLanguage,
                "Deutsch",
                "English",
                "Español",
                "Français",
                "Italiano",
                "Português",
                "Русский",
                "日本語",
                "中文(简体)"
            };

            languageDropDown = new DropDown
            {
                TextColor       = colGreen,
                BackgroundColor = OS.IsWindows ? colBGNoAlpha : new Color()
            };
            if (OS.IsLinux)
            {
                languageDropDown = new DropDown();
            }

            languageDropDown.Items.AddRange(languageList);

            var tmpLanguage = CrossPlatformOperations.ReadFromConfig("Language");
            languageDropDown.SelectedIndex = tmpLanguage == "Default" ? 0 : languageDropDown.Items.IndexOf(languageDropDown.Items.FirstOrDefault(x => x.Text.Equals(tmpLanguage)));

            if (languageDropDown.SelectedIndex == -1)
            {
                log.Info("User has tried to use " + tmpLanguage + " as a Language, but it was not found. Reverting to System Language");
                languageDropDown.SelectedIndex = 0;
            }

            // autoUpdateAM2R checkbox
            autoUpdateAM2RCheck = new CheckBox
            {
                Checked   = Boolean.Parse(CrossPlatformOperations.ReadFromConfig("AutoUpdateAM2R")),
                Text      = Text.AutoUpdateAM2R,
                TextColor = colGreen
            };


            // autoUpdateLauncher checkbox
            autoUpdateLauncherCheck = new CheckBox
            {
                Checked   = Boolean.Parse(CrossPlatformOperations.ReadFromConfig("AutoUpdateLauncher")),
                Text      = Text.AutoUpdateLauncher,
                TextColor = colGreen
            };

            // HQ music, PC
            hqMusicPCCheck = new CheckBox
            {
                Checked   = Boolean.Parse(CrossPlatformOperations.ReadFromConfig("MusicHQPC")),
                Text      = Text.HighQualityPC,
                TextColor = colGreen
            };

            // HQ music, Android
            hqMusicAndroidCheck = new CheckBox
            {
                Checked   = Boolean.Parse(CrossPlatformOperations.ReadFromConfig("MusicHQAndroid")),
                Text      = Text.HighQualityAndroid,
                TextColor = colGreen
            };

            // Create game debug logs
            profileDebugLogCheck = new CheckBox
            {
                Checked   = bool.Parse(CrossPlatformOperations.ReadFromConfig("ProfileDebugLog")),
                Text      = Text.ProfileDebugCheckBox,
                TextColor = colGreen
            };

            // Custom environment variables label
            Label customEnvVarLabel = new Label();
            if (OS.IsLinux)
            {
                customEnvVarLabel = new Label
                {
                    Text      = Text.CustomEnvVarLabel,
                    TextColor = colGreen
                };
            }

            // Custom environment variables textbox
            customEnvVarTextBox = null;
            if (OS.IsLinux)
            {
                customEnvVarTextBox = new TextBox
                {
                    Text            = CrossPlatformOperations.ReadFromConfig("CustomEnvVar"),
                    BackgroundColor = colBGNoAlpha,
                    TextColor       = colGreen
                };
            }

            // Mirror list
            mirrorLabel = new Label
            {
                Text      = Text.DownloadSource,
                TextColor = colGreen
            };

            mirrorDropDown = new DropDown
            {
                TextColor       = colGreen,
                BackgroundColor = OS.IsWindows ? colBGNoAlpha : new Color()
            };
            if (OS.IsLinux)
            {
                mirrorDropDown = new DropDown();
            }

            mirrorDropDown.Items.AddRange(mirrorDescriptionList);   // As above, find a way to get this inside the dropDown definition
            mirrorIndex = (Int32.Parse(CrossPlatformOperations.ReadFromConfig("MirrorIndex")) < mirrorDropDown.Items.Count) ? Int32.Parse(CrossPlatformOperations.ReadFromConfig("MirrorIndex"))
                                                                                                                            : 0;
            mirrorDropDown.SelectedIndex = mirrorIndex;

            currentMirror = mirrorList[mirrorDropDown.SelectedIndex];

            // Custom mirror
            customMirrorCheck = new CheckBox
            {
                Checked   = Boolean.Parse(CrossPlatformOperations.ReadFromConfig("CustomMirrorEnabled")),
                Text      = Text.CustomMirrorCheck,
                TextColor = colGreen
            };

            customMirrorTextBox = new TextBox
            {
                Text            = CrossPlatformOperations.ReadFromConfig("CustomMirrorText"),
                BackgroundColor = colBGNoAlpha,
                TextColor       = colGreen
            };

            EnableMirrorControlsAccordingly();

            settingsLayout.BeginHorizontal();
            settingsLayout.AddSpace();
            settingsLayout.AddColumn(null, languageLabel, languageDropDown, autoUpdateAM2RCheck, autoUpdateLauncherCheck, hqMusicPCCheck, hqMusicAndroidCheck, profileDebugLogCheck, customEnvVarLabel, (Control)customEnvVarTextBox ?? new Label(), mirrorLabel, mirrorDropDown, customMirrorCheck, customMirrorTextBox, null);
            settingsLayout.AddSpace();

            TabPage settingsPage = new TabPage
            {
                BackgroundColor = colBGNoAlpha,
                Content         = settingsLayout,
                Text            = Text.LauncherSettingsTab
            };

            #endregion

            #region MODSETTINGS PAGE

            // [MOD SETTINGS]
            DynamicLayout modSettingsLayout = new DynamicLayout();


            addModButton = new ColorButton
            {
                ToolTip              = null,
                Text                 = Text.AddNewMod,
                Font                 = smallButtonFont,
                Height               = 30,
                Width                = 275,
                TextColor            = colGreen,
                BackgroundColor      = colBG,
                FrameColor           = colGreen,
                BackgroundColorHover = colBGHover
            };

            Label modSpacer = new Label
            {
                Height = 14
            };

            settingsProfileLabel = new Label
            {
                Text      = Text.CurrentProfile,
                TextColor = colGreen,
                Width     = 275
            };

            modSettingsProfileDropDown = new DropDown
            {
                TextColor       = colGreen,
                BackgroundColor = OS.IsWindows ? colBGNoAlpha : new Color()
            };

            // In order to not have conflicting theming, we just always respect the users theme for dropdown on GTK.
            if (OS.IsLinux)
            {
                modSettingsProfileDropDown = new DropDown();
            }

            modSettingsProfileDropDown.Items.AddRange(profileNames);   // It's actually more comfortable if it's outside, because of GTK shenanigans

            profileButton = new ColorButton
            {
                ToolTip              = null,
                Text                 = Text.OpenProfileFolder,
                Font                 = smallButtonFont,
                Height               = 30,
                Width                = 275,
                TextColor            = colGreen,
                BackgroundColor      = colBG,
                FrameColor           = colGreen,
                BackgroundColorHover = colBGHover
            };

            saveButton = new ColorButton
            {
                ToolTip              = null,
                Text                 = Text.OpenSaveFolder,
                Font                 = smallButtonFont,
                Height               = 30,
                Width                = 275,
                TextColor            = colGreen,
                BackgroundColor      = colBG,
                FrameColor           = colGreen,
                BackgroundColorHover = colBGHover
            };

            updateModButton = new ColorButton
            {
                ToolTip              = null,
                Text                 = Text.UpdateModButtonText,
                Font                 = smallButtonFont,
                Height               = 30,
                Width                = 275,
                TextColor            = colGreen,
                BackgroundColor      = colBG,
                FrameColor           = colGreen,
                BackgroundColorHover = colBGHover
            };

            deleteModButton = new ColorButton
            {
                ToolTip              = null,
                Text                 = Text.DeleteModButtonText,
                Font                 = smallButtonFont,
                Height               = 30,
                Width                = 275,
                TextColor            = colGreen,
                BackgroundColor      = colBG,
                FrameColor           = colGreen,
                BackgroundColorHover = colBGHover
            };

            profileNotesTextArea = new TextArea
            {
                ReadOnly        = true,
                BackgroundColor = colBGNoAlpha,
                TextColor       = colInactive,
                SpellCheck      = false,
                Width           = 275,
                Height          = 150,
                Text            = Text.ProfileNotes
            };

            modSettingsLayout.BeginHorizontal();
            modSettingsLayout.AddSpace();
            modSettingsLayout.AddColumn(null, addModButton, modSpacer, settingsProfileLabel, modSettingsProfileDropDown, profileButton, saveButton, updateModButton, deleteModButton, profileNotesTextArea, null);
            modSettingsLayout.AddSpace();

            TabPage modSettingsPage = new TabPage
            {
                BackgroundColor = colBGNoAlpha,
                Content         = modSettingsLayout,
                Text            = Text.ModSettingsTab
            };

            #endregion

            #endregion

            Content = new TabControl
            {
                Pages =
                {
                    mainPage,

                    changelogPage,

                    newsPage,

                    settingsPage,

                    modSettingsPage
                }
            };

            #region EVENTS
            log.Info("All UI objects have been initialized, UI has been set up.");
            log.Info("Beginning event linkage...");

            Closing          += MainformClosing;
            showButton.Click += ShowButtonClick;
            profileDropDown.SelectedIndexChanged   += ProfileDropDownSelectedIndexChanged;
            languageDropDown.SelectedIndexChanged  += LanguageDropDownSelectedIndexChanged;
            autoUpdateAM2RCheck.CheckedChanged     += AutoUpdateAM2RCheckChanged;
            autoUpdateLauncherCheck.CheckedChanged += AutoUpdateLauncherCheckChanged;
            hqMusicAndroidCheck.CheckedChanged     += HqMusicAndroidCheckChanged;
            hqMusicPCCheck.CheckedChanged          += HqMusicPCCheckChanged;
            customMirrorCheck.CheckedChanged       += CustomMirrorCheckChanged;
            apkButton.Click                                 += ApkButtonClickEvent;
            apkButton.LoadComplete                          += (sender, e) => UpdateApkState();
            profileDropDown.LoadComplete                    += (sender, e) => UpdateProfileState();
            playButton.Click                                += PlayButtonClickEvent;
            playButton.LoadComplete                         += PlayButtonLoadComplete;
            customMirrorTextBox.LostFocus                   += CustomMirrorTextBoxLostFocus;
            mirrorDropDown.SelectedIndexChanged             += MirrorDropDownSelectedIndexChanged;
            modSettingsLayout.LoadComplete                  += ProfileLayoutLoadComplete;
            addModButton.Click                              += AddModButtonClicked;
            profileButton.Click                             += ProfileDataButtonClickEvent;
            saveButton.Click                                += SaveButtonClickEvent;
            modSettingsProfileDropDown.SelectedIndexChanged += ModSettingsProfileDropDownSelectedIndexChanged;
            deleteModButton.Click                           += DeleteModButtonClicked;
            updateModButton.Click                           += UpdateModButtonClicked;
            profileDebugLogCheck.CheckedChanged             += ProfileDebugLogCheckedChanged;
            if (OS.IsLinux)
            {
                customEnvVarTextBox.LostFocus += CustomEnvVarTextBoxLostFocus;
            }

            //TODO: Retest if these now work on mac
            newsWebView.DocumentLoaded      += (sender, e) => ChangeToEmptyPageOnNoInternet(newsPage, newsNoConnectionLabel);
            changelogWebView.DocumentLoaded += (sender, e) => ChangeToEmptyPageOnNoInternet(changelogPage, changelogNoConnectionLabel);

            log.Info("Events linked successfully.");

            #endregion
        }
Example #13
0
 public void Show(TrayIndicator indicator = null)
 {
     ;
     Control.UserInfo = NSDictionary.FromObjectsAndKeys(new NSObject[] { new NSString(ID), (NSString)UserData }, s_UserInfoKeys);
     NSUserNotificationCenter.DefaultUserNotificationCenter.DeliverNotification(Control);
 }