Skip to content

Commit

Permalink
Qe
Browse files Browse the repository at this point in the history
  • Loading branch information
Mrgaton committed Mar 4, 2024
1 parent cf34bdf commit d86d504
Show file tree
Hide file tree
Showing 10 changed files with 147 additions and 106 deletions.
36 changes: 9 additions & 27 deletions Telefono de rosalia/Program.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
using System;
using System.IO;
using System.Linq;
using System.Media;
using System.Runtime.InteropServices;
using System.Threading;
using System.Windows.Forms;

namespace Telefono_de_rosalia
Expand All @@ -22,10 +18,8 @@ private enum SL_GENUINE_STATE
SL_GEN_STATE_LAST = 3
}

[DllImport("Slwga.dll", EntryPoint = "SLIsGenuineLocal", CharSet = CharSet.None, ExactSpelling = false, SetLastError = false, PreserveSig = true, CallingConvention = CallingConvention.Winapi, BestFitMapping = false, ThrowOnUnmappableChar = false)]
[DllImport("Slwga.dll", EntryPoint = "SLIsGenuineLocal", CharSet = CharSet.None, ExactSpelling = false, SetLastError = false, PreserveSig = true, CallingConvention = CallingConvention.Winapi, BestFitMapping = false, ThrowOnUnmappableChar = false)][PreserveSig()] private static extern uint SLIsGenuineLocal(ref SLID slid, [In, Out] ref SL_GENUINE_STATE genuineState, IntPtr val3);

[PreserveSig()]
static extern uint SLIsGenuineLocal(ref SLID slid, [In, Out] ref SL_GENUINE_STATE genuineState, IntPtr val3);
public static void CheckWindows()
{
if (!IsGenuineWindows())
Expand Down Expand Up @@ -61,18 +55,12 @@ private static bool IsGenuineWindows()
}
}

[DllImport("winmm.dll", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
public static extern uint waveOutGetNumDevs();

[DllImport("user32.dll", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
private static extern bool SetProcessDPIAware();

[DllImport("winmm.dll", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)] public static extern uint waveOutGetNumDevs();

[DllImport("user32.dll", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)] private static extern bool SetProcessDPIAware();

[STAThread]
static void Main()
private static void Main()
{
GenuineWindowsDetector.CheckWindows();

Expand All @@ -82,22 +70,16 @@ static void Main()
Environment.Exit(0);
}

double[] freqs = { 697, 770, 852, 941 };
double[] freqs2 = { 1209, 1336, 1477 };

for (int i = 0; i < freqs.Length; i++)
/*for (int i = 0; i < horizontalFreq.Length; i++)
{
for (int e = 0; e < freqs2.Length; e++)
for (int e = 0; e < verticalFreq.Length; e++)
{
using (var tone = GenerateTone(0.25, freqs[i], freqs2[e]))
using (var tone = GenerateTone(0.8, horizontalFreq[i], verticalFreq[e]))
{
using (var player = new SoundPlayer(tone))
{
player.PlaySync();
}
}
}
}
}*/

if (waveOutGetNumDevs() == 0)
{
Expand All @@ -112,7 +94,7 @@ static void Main()
Application.Run(new RosaliaTelefonoForm());
}

private static Stream GenerateTone(double duration, params double[] frequencies)
/*private static Stream GenerateTone(double duration, params double[] frequencies)
{
const int sampleRate = 44100;
const short bitsPerSample = 16;
Expand All @@ -137,13 +119,13 @@ private static Stream GenerateTone(double duration, params double[] frequencies)
{
double t = (double)i / sampleRate;
var freqSamples = frequencies.Select(f => (Math.Sin(2 * Math.PI * f * t)));
short sample = (short)(short.MaxValue * freqSamples.Sum() / 2); ;
short sample = (short)(short.MaxValue * freqSamples.Sum() / 2);
writer.Write(sample);
}
writer.Flush();
stream.Position = 0;
return stream;
}
}*/
}
}
Binary file removed Telefono de rosalia/Resources/Nokiarosalico
Binary file not shown.
Binary file modified Telefono de rosalia/Resources/Nokiarosalico.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed Telefono de rosalia/Resources/NokiarosalicoOcup
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Telefono de rosalia/Resources/NokiarosalicoOcupado.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Telefono de rosalia/Resources/TararaTaratata.wav
Binary file not shown.
102 changes: 66 additions & 36 deletions Telefono de rosalia/RosaliaTelefonoForm.Designer.cs

Large diffs are not rendered by default.

113 changes: 71 additions & 42 deletions Telefono de rosalia/RosaliaTelefonoForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ public RosaliaTelefonoForm()

this.ShowInTaskbar = false;

Console.WriteLine(SystemColors.Control);

InvisibleButton.FlatStyle = FlatStyle.Flat;
InvisibleButton.BackColor = Color.Transparent;
InvisibleButton.FlatAppearance.MouseDownBackColor = Color.Transparent;
Expand Down Expand Up @@ -52,11 +54,7 @@ private async void NumbersButton_Click(object sender, EventArgs e)
{
Console.WriteLine("Button clicked " + ((Button)sender).Name.ToString());

if (callAnswered)
{
Task.Run(() => Beep(1209, 200));
Task.Run(() => Beep(697, 200));
}
Shake(5, 1, 2);
}

private bool callAnswered = false;
Expand All @@ -66,35 +64,42 @@ private void RosaliaTelefonoForm_Shown(object sender, EventArgs e)
this.Refresh();

ConfigForm(new List<Button>() {
this.InvisibleButton,
this.Number_Asterisk_Button,
this.Number_9_Button,
this.Number_7_Button,
this.Number_5_Button,
this.Number_2_Button,
this.Number_1_Button,
this.NullButton,
this.Number_Hashtag_Button,
this.Number_8_Button,
this.Number_2_Button,
this.Number_3_Button,
this.Number_4_Button,
this.Number_0_Button,
this.Number_5_Button,
this.Number_6_Button,
this.Number_3_Button
this.Number_7_Button,
this.Number_8_Button,
this.Number_9_Button,
this.Number_0_Button,
this.Number_Asterisk_Button,
this.NullButton,
this.Number_Hashtag_Button,
this.InvisibleButton,
});

this.Opacity = 1;

player.LoadCompleted += (object snd, AsyncCompletedEventArgs a) => Invoke(new MethodInvoker(async () =>
{
Task.Factory.StartNew(() =>
{
player.PlaySync();

Environment.Exit(0);
});

await Task.Delay(800);

await Shake(800, 10, 15);

await Task.Delay(400);
await Task.Delay(500);

await Shake(800, 11, 14);
await Shake(1250, 12, 14);

await Task.Delay(800);
await Task.Delay(850);

TelefonoPictureBox.Image = Properties.Resources.NokiarosalicoOcupado;

Expand All @@ -106,17 +111,13 @@ private void RosaliaTelefonoForm_Shown(object sender, EventArgs e)
callAnswered = true;
}));

Task tsk = Task.Factory.StartNew(() =>
{
player.Load();

player.PlaySync();
player.Load();

Environment.Exit(0);
});
this.Focus();
}

private static Random rnd = new Random();

private static Point originalPoint = new Point();

private async Task Shake(int Time, int ShakeMult, int TimeBetwemShake)
Expand All @@ -139,10 +140,7 @@ private void ConfigForm(List<Button> Buttons)
{
Console.WriteLine(FormButton.Name);

if (FormButton.Name.StartsWith("Number_"))
{
FormButton.Click += NumbersButton_Click;
}
if (FormButton.Name.StartsWith("Number_")) FormButton.Click += NumbersButton_Click;

FormButton.MouseDown += TelefonoPictureBox_MouseDown;
FormButton.MouseUp += TelefonoPictureBox_MouseUp;
Expand Down Expand Up @@ -185,24 +183,55 @@ private void TelefonoPictureBox_MouseMove(object sender, MouseEventArgs e)
}
}

private void RosaliaDancePictureBox_MouseDown(object sender, MouseEventArgs e)
{
TelefonoPictureBox_MouseDown(sender, e);
}
private void RosaliaDancePictureBox_MouseDown(object sender, MouseEventArgs e) => TelefonoPictureBox_MouseDown(sender, e);

private void RosaliaDancePictureBox_MouseUp(object sender, MouseEventArgs e)
{
TelefonoPictureBox_MouseUp(sender, e);
}
private void RosaliaDancePictureBox_MouseUp(object sender, MouseEventArgs e) => TelefonoPictureBox_MouseUp(sender, e);

private void RosaliaDancePictureBox_MouseMove(object sender, MouseEventArgs e) => TelefonoPictureBox_MouseMove(sender, e);

private void RosaliaTelefonoForm_FormClosing(object sender, FormClosingEventArgs e) => e.Cancel = true;

private void RosaliaDancePictureBox_MouseMove(object sender, MouseEventArgs e)
private static double[] horizontalFreq = { 697, 770, 852, 941 };

private static double[] verticalFreq = { 1209, 1336, 1477, 1632 };

private void PlayFrequency(int num)
{
TelefonoPictureBox_MouseMove(sender, e);
if (!callAnswered) return;

int x = (num - 1) % 3;
int y = (num - 1) / 3;

PlayFrequency(x, y);
}

private void RosaliaTelefonoForm_FormClosing(object sender, FormClosingEventArgs e)
private static void PlayFrequency(int x, int y)
{
e.Cancel = true;
Task.Factory.StartNew(() => Beep(Math.Abs((int)((horizontalFreq[x] + verticalFreq[y]) / 1.5)), 250));
}

private void Number_1_Button_Click(object sender, EventArgs e) => PlayFrequency(1);

private void Number_2_Button_Click(object sender, EventArgs e) => PlayFrequency(2);

private void Number_3_Button_Click(object sender, EventArgs e) => PlayFrequency(3);

private void Number_4_Button_Click(object sender, EventArgs e) => PlayFrequency(4);

private void Number_5_Button_Click(object sender, EventArgs e) => PlayFrequency(5);

private void Number_6_Button_Click(object sender, EventArgs e) => PlayFrequency(6);

private void Number_7_Button_Click(object sender, EventArgs e) => PlayFrequency(7);

private void Number_8_Button_Click(object sender, EventArgs e) => PlayFrequency(8);

private void Number_9_Button_Click(object sender, EventArgs e) => PlayFrequency(9);

private void Number_Asterisk_Button_Click(object sender, EventArgs e) => PlayFrequency(10);

private void Number_0_Button_Click(object sender, EventArgs e) => PlayFrequency(11);

private void Number_Hashtag_Button_Click(object sender, EventArgs e) => PlayFrequency(12);
}
}
2 changes: 1 addition & 1 deletion Telefono de rosalia/Telefono de rosalia.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{6BFB1C95-25D9-4741-9B73-F34A1DCD99C7}</ProjectGuid>
<OutputType>Exe</OutputType>
<OutputType>WinExe</OutputType>
<RootNamespace>Telefono_de_rosalia</RootNamespace>
<AssemblyName>Telefono de rosalia</AssemblyName>
<TargetFrameworkVersion>v4.8.1</TargetFrameworkVersion>
Expand Down

0 comments on commit d86d504

Please sign in to comment.