Skip to content
This repository has been archived by the owner on Mar 6, 2022. It is now read-only.

Commit

Permalink
Añadida opción de cambiar cédula
Browse files Browse the repository at this point in the history
-Añadida opción para cambiar cédula por defecto (esto también permite que se use la cédula por defecto al consultar notas).
Este cambio también sirve para enlaces dirigidos a cierto usuario

-Corregido error que no mostraba botón de consulta de notas
  • Loading branch information
lxndr-rl committed Jun 7, 2021
1 parent a1e7332 commit e99b7aa
Show file tree
Hide file tree
Showing 7 changed files with 164 additions and 22 deletions.
2 changes: 1 addition & 1 deletion GradeWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public partial class GradeWindow : Form
public GradeWindow()
{
InitializeComponent();
if (Properties.Settings.Default.Cedula.Length > 2) { cedula = Properties.Settings.Default.Cedula; }
if (Properties.Settings.Default.Cedula.Length > 2 && Properties.Settings.Default.UseDefaultCed) { cedula = Properties.Settings.Default.Cedula; }

else
{
Expand Down
16 changes: 6 additions & 10 deletions MainWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ private async void FetchLatestVer()
dynamic stuff = JsonConvert.DeserializeObject(json);
dynamic stuffwin = stuff.windows;
horarioexamButton.Visible = (bool)stuff.examen;
notasButton.Visible = (bool)stuff.examen;
notasButton.Visible = (bool)stuff.notas;
if (stuffwin.latest > Properties.Settings.Default.Version)
{
string seleccion = lxMessageBox.Show(stuffwin.cambios.ToString(), stuffwin.type.ToString(), lxMessageBox.Buttons.OKCancel, lxMessageBox.Icon.Warning, lxMessageBox.AnimateStyle.FadeIn).ToString();
Expand Down Expand Up @@ -163,7 +163,7 @@ public async void FromKeyboard(object sender, HotkeyEventArgs e)
e.Handled = true;
try
{
string url = @"https://api.lxndr.dev/uae/meets/exacto.php";
string url = @"https://api.lxndr.dev/uae/meets/exacto.php?ced=" + Properties.Settings.Default.Cedula;
var json = await client.DownloadStringTaskAsync(url);
dynamic stuff = JsonConvert.DeserializeObject(json);
if (stuff.materia.ToString() == "No hay nada por ahora")
Expand All @@ -173,7 +173,7 @@ public async void FromKeyboard(object sender, HotkeyEventArgs e)
notifyIcon1.ShowBalloonTip(1000);
return;
}
OpenUrl1("https://apps.lxndr.dev/lxmeets/redirecter.php");
OpenUrl1(stuff.url.ToString());
}
catch { }
}
Expand Down Expand Up @@ -245,7 +245,7 @@ private async void FetchAPI()
cargandoAPI.Visible = true;
try
{
string url = @"https://api.lxndr.dev/uae/meets/?dia=" + comboBox1.GetItemText(comboBox1.SelectedItem);
string url = @"https://api.lxndr.dev/uae/meets/?dia=" + comboBox1.GetItemText(comboBox1.SelectedItem) + "&ced=" + Properties.Settings.Default.Cedula;
var client = new WebClient();
var json = await client.DownloadStringTaskAsync(url);
dynamic stuff = JsonConvert.DeserializeObject(json);
Expand Down Expand Up @@ -345,7 +345,7 @@ private async void FiveMinutes()
{
try
{
string url = @"https://api.lxndr.dev/uae/meets/exacto.php?hora=" + RoundUp(DateTime.Parse(DateTime.Now.ToString("HH") + ":" + DateTime.Now.ToString("mm") + ":00"), TimeSpan.FromMinutes(15)).ToShortTimeString();
string url = @"https://api.lxndr.dev/uae/meets/exacto.php?ced=" + Properties.Settings.Default.Cedula + "&hora=" + RoundUp(DateTime.Parse(DateTime.Now.ToString("HH") + ":" + DateTime.Now.ToString("mm") + ":00"), TimeSpan.FromMinutes(15)).ToShortTimeString();
var json = await client.DownloadStringTaskAsync(url);
dynamic stuff = JsonConvert.DeserializeObject(json);
if ((string)stuff.diff == "0" && (anteriorAsignatura == stuff.materia.ToString())) return;
Expand Down Expand Up @@ -375,7 +375,7 @@ private async void InstantAlert()
{
try
{
string url = @"https://api.lxndr.dev/uae/meets/exacto.php";
string url = @"https://api.lxndr.dev/uae/meets/exacto.php?ced=" + Properties.Settings.Default.Cedula;
var json = await client.DownloadStringTaskAsync(url);
dynamic stuff = JsonConvert.DeserializeObject(json);
if ((string)stuff.diff == "0" && (anteriorAsignatura == stuff.materia.ToString())) return;
Expand Down Expand Up @@ -430,10 +430,6 @@ private void Button1_Click_1(object sender, EventArgs e)
//Close();
Hide();
notifyIcon1.DoubleClick += OpenFromIcon;
notifyIcon1.BalloonTipTitle = "lxMeets sigue en funcionamiento";
notifyIcon1.BalloonTipText = "Doble click al icono para volverlo a abrir";
notifyIcon1.ShowBalloonTip(2000);
notifyIcon1.BalloonTipClicked += OpenFromIcon;
}
private void Settings_Click(object sender, EventArgs e)
{
Expand Down
14 changes: 13 additions & 1 deletion Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion Properties/Settings.settings
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,13 @@
<Value Profile="(Default)">Control | Alt | Shift</Value>
</Setting>
<Setting Name="Version" Type="System.Decimal" Scope="Application">
<Value Profile="(Default)">1.6</Value>
<Value Profile="(Default)">1.7</Value>
</Setting>
<Setting Name="Cedula" Type="System.String" Scope="User">
<Value Profile="(Default)">0</Value>
</Setting>
<Setting Name="UseDefaultCed" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value>
</Setting>
</Settings>
</SettingsFile>
73 changes: 67 additions & 6 deletions SettingsWindow.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

72 changes: 71 additions & 1 deletion SettingsWindow.cs
Original file line number Diff line number Diff line change
@@ -1,22 +1,29 @@
using Microsoft.Win32;
using lxMsgBox;
using Microsoft.Win32;
using Newtonsoft.Json;
using NHotkey.WindowsForms;
using System;
using System.Diagnostics;
using System.Linq;
using System.Net;
using System.Text.RegularExpressions;
using System.Windows.Forms;

namespace lxMeets
{
public partial class SettingsWindow : Form
{
readonly WebClient client = new WebClient();
public SettingsWindow()
{
InitializeComponent();
CenterToScreen();
keyboardShortCutText.Text = Properties.Settings.Default.KeyBoardShortCut.Replace("Keys.", "");
cedDefault.Text = Properties.Settings.Default.Cedula;
autoRunCheck.Checked = Properties.Settings.Default.AutoStart;
useKeyboardCheck.Checked = Properties.Settings.Default.UseKeyboard;
sendNotificationsCheck.Checked = Properties.Settings.Default.Notifications;
useCedulaCheck.Checked = Properties.Settings.Default.UseDefaultCed;

this.KeyPreview = true;
}
Expand Down Expand Up @@ -75,5 +82,68 @@ private void SendNotificationsCheck_CheckedChanged(object sender, EventArgs e)
Properties.Settings.Default.Save();
}
}

private void useCedulaCheck_CheckedChanged(object sender, EventArgs e)
{
if (useCedulaCheck.Checked)
{
Properties.Settings.Default.UseDefaultCed = true;
Properties.Settings.Default.Save();

}
else
{
Properties.Settings.Default.UseDefaultCed = false;
Properties.Settings.Default.Save();
}
}

private async void AuthUser(string cedula)
{
try
{
string url = @"https://api.lxndr.dev/uae/estudiantes/?cedula=" + cedula;
var json = await client.DownloadStringTaskAsync(url);
dynamic stuff = JsonConvert.DeserializeObject(json);
if ((bool)stuff.error)
{
MessageBox.Show(stuff.message.ToString());
while (true)
{
lxMessageBox.Show("La aplicación corre en segundo plano incluso cuando se presiona X\n\nPuede usar el atajo (Ctrl Alt Shift) para abrir la clase actual.\n\nLas alertas se muestran 5 minutos antes de una clase y al empezar la clase.\n\nLa aplicación se abre al iniciar windows", "lxMeets " + Properties.Settings.Default.Version, lxMessageBox.Buttons.OK, lxMessageBox.Icon.Warning, lxMessageBox.AnimateStyle.FadeIn).ToString();
cedula = lxMessageInputBox.ShowDialog("Ingresar número de cédula", "Ingresar número de cédula");

while ((cedula.Length < 9 && cedula.Length > 0) || !Regex.IsMatch(cedula, @"^\d+$"))
{
if (cedula == "Cancel") break;
MessageBox.Show("Cédula Inválida"); cedula = lxMessageInputBox.ShowDialog("Ingresar número de cédula", "Ingresar número de cédula");
}
if (cedula != "Cancel") AuthUser(cedula);
break;
}
}
else
{
Properties.Settings.Default.Cedula = cedula;
Properties.Settings.Default.Save();
cedDefault.Text = Properties.Settings.Default.Cedula;
}
}
catch { }
}

private void cambiarCedula_Click(object sender, EventArgs e)
{
string cedula = lxMessageInputBox.ShowDialog("Ingresar número de cédula", "Ingresar número de cédula");

while ((cedula.Length < 9 && cedula.Length > 0) || !Regex.IsMatch(cedula, @"^\d+$"))
{
if (cedula == "Cancel") break;
MessageBox.Show("Cédula Inválida"); cedula = lxMessageInputBox.ShowDialog("Ingresar número de cédula", "Ingresar número de cédula");
}
if (cedula != "Cancel") AuthUser(cedula);


}
}
}
4 changes: 2 additions & 2 deletions lxMeets.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
<NeutralLanguage>es-EC</NeutralLanguage>
<StartupObject></StartupObject>
<Nullable>disable</Nullable>
<Version>1.6</Version>
<Version>1.7</Version>
<NoWin32Manifest>true</NoWin32Manifest>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>lxMeetsSignature.snk</AssemblyOriginatorKeyFile>
<DelaySign>false</DelaySign>
<AssemblyVersion>1.6.0.0</AssemblyVersion>
<AssemblyVersion>1.7.0.0</AssemblyVersion>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
Expand Down

0 comments on commit e99b7aa

Please sign in to comment.