aboutsummaryrefslogtreecommitdiff
path: root/ShiftOS.WinForms/ShiftnetSites/DesktopWidgetWebsite.cs
blob: efb0a9b75de36519e518c47a0bfa98099dad6f74 (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
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;
using ShiftOS.WinForms.Tools;
using ShiftOS.WinForms.Applications;
using Newtonsoft.Json;
using static ShiftOS.Objects.ShiftFS.Utils;

namespace ShiftOS.WinForms.ShiftnetSites
{
    [ShiftnetSite("shiftnet/superdesk", "SuperDesk", "Empower the ShiftOS Desktop like never before.")]
    [ShiftnetFundamental]
    public partial class DesktopWidgetWebsite : UserControl, Engine.IShiftnetSite
    {
        public DesktopWidgetWebsite()
        {
            InitializeComponent();
            
        }

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

        public void OnSkinLoad()
        {
            ControlManager.SetupControls(this);
            this.pictureBox1.Left = (this.Width - pictureBox1.Width) / 2;
            ControlManager.ControlSetup += (ctrl) =>
            {
                try
                {
                    this.Invoke(new Action(() =>
                    {
                        lbwhatissuperdesk.Left = (this.Width - lbwhatissuperdesk.Width) / 2;
                        lbthisissuperdesk.Top = lbwhatissuperdesk.Top + lbwhatissuperdesk.Height + 10;
                        lbthisissuperdesk.Left = (this.Width - lbthisissuperdesk.Width) / 2;

                        lbgetthepackage.Top = lbthisissuperdesk.Top + lbthisissuperdesk.Height + 10;
                        lbgetthepackage.Left = (this.Width - lbgetthepackage.Width) / 2;

                        lbpackagedesc.Top = lbgetthepackage.Top + lbgetthepackage.Height + 10;
                        lbpackagedesc.Left = (this.Width - lbpackagedesc.Width) / 2;

                        lnkdownload.Top = lbpackagedesc.Top + lbpackagedesc.Height + 10;
                        lnkdownload.Left = (this.Width - lnkdownload.Width) / 2;

                        lnkdownload.LinkColor = lbpackagedesc.ForeColor;
                    }));
                }
                catch
                {
                }
            };
        }

        public void OnUpgrade()
        {
        }

        public void Setup()
        {
            this.HorizontalScroll.Maximum = 0;
            this.AutoScroll = false;
            this.VerticalScroll.Visible = false;
            this.AutoScroll = true;

        }

        private void lnkdownload_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            var attrib = typeof(Applications.WidgetManagerFrontend).GetCustomAttributes(false).FirstOrDefault(x => x is StpContents) as StpContents;
            if(attrib != null)
            {
                FileSkimmerBackend.GetFile(new[] { ".stp" }, FileOpenerStyle.Save, (file) =>
                 {
                     WriteAllText(file, JsonConvert.SerializeObject(attrib));
                 });
            }
            else
            {
                Infobox.Show("Service not available.", "The Shiftnet service you requested is not available.");
            }
        }
    }
}