aboutsummaryrefslogtreecommitdiff
path: root/ShiftOS.WinForms/ShiftnetSites/ShiftSoft.cs
blob: 0d84ecc096dc270cbdaa65291088f91e9cfbeedd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using ShiftOS.Engine;

namespace ShiftOS.WinForms.ShiftnetSites
{
    [ShiftnetSite("shiftnet/shiftsoft", "ShiftSoft", "What do you want to shift today?")]
    [ShiftnetFundamental]
    public partial class ShiftSoft : UserControl, IShiftnetSite
    {
        public ShiftSoft()
        {
            InitializeComponent();
        }

        public event Action GoBack;
        public event Action<string> GoToUrl;

        public void OnSkinLoad()
        {
            pnldivider.Tag = "keepbg";
            pnldivider.BackColor = SkinEngine.LoadedSkin.ControlTextColor;
            Tools.ControlManager.SetupControls(flbuttons);
            Tools.ControlManager.SetupControls(pnlhome);
            Tools.ControlManager.SetupControls(pnlservices);

            lbfreebiedesc.Top = lbfreebie.Top + lbfreebie.Height + 5;
            btnjoinfreebie.Top = lbfreebiedesc.Top + lbfreebiedesc.Height + 5;

            SetupFreebieUI();

            lbdesc.Top = lbwhere.Top + lbwhere.Height + 5;
        }

        public void OnUpgrade()
        {
        }

        public void Setup()
        {
            pnlhome.BringToFront();
        }

        private void btnping_Click(object sender, EventArgs e)
        {
            GoToUrl?.Invoke("shiftnet/shiftsoft/ping");
        }

        private void btnhome_Click(object sender, EventArgs e)
        {
            pnlhome.BringToFront();
        }

        private void btnservices_Click(object sender, EventArgs e)
        {
            pnlservices.BringToFront();
            SetupFreebieUI();
        }

        public void SetupFreebieUI()
        {
            if(SaveSystem.CurrentSave.ShiftnetSubscription == 0)
            {
                btnjoinfreebie.Enabled = false;
                btnjoinfreebie.Text = "You are already subscribed to Freebie Solutions.";
            }
            else
            {
                btnjoinfreebie.Enabled = true;
                btnjoinfreebie.Text = "Join Freebie Solutions";
            }
            btnjoinfreebie.Left = (lbfreebiedesc.Left + lbfreebiedesc.Width) - btnjoinfreebie.Width; 
        }

        private void btnjoinfreebie_Click(object sender, EventArgs e)
        {
            Infobox.PromptYesNo("Switch providers", "Would you like to switch from your current Shiftnet provider, " + Applications.DownloadManager.GetAllSubscriptions()[SaveSystem.CurrentSave.ShiftnetSubscription].Name + ", to Freebie Solutions by ShiftSoft?", (res) =>
            {
                if(res == true)
                {
                    SaveSystem.CurrentSave.ShiftnetSubscription = 0;
                    Infobox.Show("Switch providers", "The operation has completed successfully.");
                }
            });
        }
    }
}