Цитата:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Timers;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
slando component;
slando cl; // переменная класса monitoring
public Form1()
{
InitializeComponent();
notifyIcon1.Text = "Parser 1.0";
cl = new slando(this);
component = new slando(this);
}
public void button2_Click(object sender, EventArgs e)
{
if (textBox1.Text != "")
{
listBox1.Items.Add(textBox1.Text);
}
}
private void button3_Click(object sender, EventArgs e)
{
if (listBox1.SelectedIndex != -1)
{
listBox1.Items.RemoveAt(listBox1.Se lectedIndex);
}
}
protected override void OnResize(EventArgs e)
{
if (this.WindowState == FormWindowState.Minimized)
{
this.ShowInTaskbar = false;
this.Visible = false;
}
}
public void notifyIcon1_MouseDoubleClick(object sender, MouseEventArgs e)
{
if (this.WindowState == FormWindowState.Minimized)
{
this.Visible = true;
this.ShowInTaskbar = true;
this.WindowState = FormWindowState.Normal;
}
}
private void button1_Click(object sender, EventArgs e)
{
System.Windows.Forms.Timer p = new System.Windows.Forms.Timer();
component.slando1();
p.Interval = 10000;
p.Start();
}
public void SetBalloonTip(string s)
{
notifyIcon1.BalloonTipTitle = s;
notifyIcon1.BalloonTipText = s;
this.Click += new EventHandler(Form1_Click);
}
public void Form1_Click(object sender, EventArgs e) {
notifyIcon1.Visible = true;
notifyIcon1.ShowBalloonTip(30);
}
}
}
|
Цитата:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.Timers;
using System.Text.RegularExpressions;
using System.IO;
namespace WindowsFormsApplication1
{
public class slando
{
public void slando1()
{
try
{
foreach (string elements in OwnerForm.listBox1.Items)
{
string url = "http://www.slando.ru/moskva/search/?q=" + elements;
string html = string.Empty;
string pattern = elements;
Form1 n = new Form1();
HttpWebRequest myRequest = (HttpWebRequest)HttpWebRequest.Crea te(url);
HttpWebResponse myResponse = (HttpWebResponse)myRequest.GetRespo nse();
StreamReader sr = new StreamReader(myResponse.GetResponse Stream(), Encoding.GetEncoding(1251));
html = sr.ReadToEnd();
Regex newReg = new Regex(pattern);//
MatchCollection matches = newReg.Matches(html);
if (matches.Count > 0)
{
//мигать в трее, выводить сообщение о находке на сландо
n.SetBalloonTip("Соответствие на Slando"+matches.Count);
}
}
}
catch (Exception)
{
Form2 forma = new Form2();
Timer p = new Timer();
p.Interval = 5000;
p.Start();
p.Elapsed += new ElapsedEventHandler(p_Tick);
}
}
void p_Tick(object sender, EventArgs e)
{
slando1();
}
private Form1 OwnerForm;
public slando(Form1 form)
{
OwnerForm = form;
}
}
}
|
При запуске создаются два значка в панели. Это из-за того, что когда передаю из другого класса текст, создаю объект класса где находится значок. Как это исправить. Еще не отображается текст. Остальные ошибки в тексте - это не дописки. Огромное спасибо за помощь!