-
Notifications
You must be signed in to change notification settings - Fork 0
/
Search.cs
78 lines (74 loc) · 2.19 KB
/
Search.cs
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
using System.Windows.Forms;
using System.Drawing;
using System;
namespace Instagram
{
public partial class Search : Form
{
ProfilePreview[] searchResults;
DBHandlingUtilities dbHandler;
bool lightModeOn;
Main main;
public Search(Main main)
{
InitializeComponent();
dbHandler = new DBHandlingUtilities();
this.lightModeOn = main.lightModeOn;
this.main = main;
Configure_Theme();
}
private void Configure_Theme()
{
Color backColor, textColor;
if (lightModeOn)
{
backColor = Color.FromArgb(209, 209, 209);
textColor = Color.FromArgb(0, 0, 0);
}
else
{
backColor = Color.FromArgb(31, 31, 31);
textColor = Color.FromArgb(255, 255, 255);
}
this.BackColor = backColor;
searchBox.BackColor = backColor;
searchBox.ForeColor = textColor;
resultFeed.BackColor = backColor;
}
private void Display_Posts()
{
resultFeed.AutoScroll = true;
for(int i=0; i< searchResults.Length;i++)
{
try
{
searchResults[i].TopLevel = false;
resultFeed.Controls.Add(searchResults[i]);
searchResults[i].Show();
}
catch(Exception error)
{
Console.WriteLine(error.Message);
}
}
}
private void Search_Input(string input)
{
searchResults = dbHandler.Return_Search_Results(input, main);
Display_Posts();
}
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == (char)Keys.Enter)
{
resultFeed.Controls.Clear();
Search_Input(searchBox.Text);
}
if (e.KeyChar == (char)Keys.Escape)
{
searchBox.Text = "";
resultFeed.Controls.Clear();
}
}
}
}