示例#1
0
 public void Execute(CommandContext context)
 {
     SendComment(context, "#PCң����#�Ѿ�������С�������Ӵ��������뷢΢�����Ӵ�����$$�������ݡ�");
     for (int i = 0; i < 10; i++)
     {
         SendMessageW(context.Handle, WM_APPCOMMAND, context.Handle, new IntPtr(APPCOMMAND_VOLUME_DOWN));
     }
 }
示例#2
0
        static void SendPhotoByEmail(CommandContext context, string[] pics)
        {
            var title = "Instagram ͼƬ����@" + DateTime.Now;
            var body = "���ʼ���<a href='http://weibo.com/k/PC%25E9%2581%25A5%25E6%258E%25A7%25E5%2599%25A8?refer=Index_mark'>#PCң����#</a>�Զ����ͣ��벻Ҫ�ظ���<br/>" +
                        "��������<a href='http://weibo.com/suchuanyi'>@����������</a>";
            var to = context.To;

            context.MailUtility.Send(to, title, body, pics);
        }
示例#3
0
        static void SendPhotoByEmail(CommandContext context, string picPath)
        {
            var title = "�ҵ�WebCamץ��@" + DateTime.Now;
            var body = "��ͼ��<a href='http://weibo.com/k/PC%25E9%2581%25A5%25E6%258E%25A7%25E5%2599%25A8?refer=Index_mark'>#PCң����#</a>�Զ����ͣ��벻Ҫ�ظ���<br/>" +
                        "��������<a href='http://weibo.com/suchuanyi'>@����������</a>";
            var to = context.MailUtility.Account.AccountName;

            context.MailUtility.Send(to, title, body, picPath);
        }
示例#4
0
        public void Execute(CommandContext context)
        {
            SendComment(context, "#PCң����#�����ϴ������Ļ��ͼ��һ�Ὣ��������������΢���С�");

            var temp = Environment.GetEnvironmentVariable("TEMP");
            var picPath = string.Format("{0}\\{1}.jpg", temp, Guid.NewGuid());
            ImageUtility.CaptureDesktop(picPath);

            context.WeiboService.SendWeiboWithPicture("������ʹ��#PCң����#�����ҵ���Ļ��ͼ " + DateTime.Now.ToLongTimeString(), picPath);
        }
示例#5
0
 protected void SendComment(CommandContext context, string message)
 {
     var weiboService = context.WeiboService;
     var weiboId = context.WeiboId;
     try
     {
         if (weiboService is SinaWeiboService)
             weiboService.SendComment(weiboId, message + "��������@���������� " + DateTime.Now.Ticks);
         else if (weiboService is QQWeiboService)
             weiboService.SendComment(weiboId, message + "��������@suchuanyi " + DateTime.Now.Ticks);
     }
     catch (Exception)
     {
         //todo: ��¼������־
     }
 }
示例#6
0
        public void Execute(CommandContext context)
        {
            if (context.MailUtility.Account.AccountName.IsNullOrEmpty())
                SendComment(context, "��������˺Ż�û���úá�");

            var template = Environment.CurrentDirectory + "\\Templates\\FileListTemplate.html";

            //��ȡ�ļ�����System.Text.Encoding.Default�����Խ��������������
            var sr = new StreamReader(template, Encoding.Default);
            var body = sr.ReadToEnd();

            //�ر��ļ���
            sr.Close();

            var rootDir = new DirectoryInfo(context.CommandParameter);
            var files = rootDir.GetFiles("*.*");
            var directories = rootDir.GetDirectories();

            var sb = new StringBuilder();
            var count = 0;
            foreach (var directory in directories)
            {
                ++count;
                if(IsEven(count))
                    sb.AppendFormat("<tr class='even'><td>{0}</td><td>{1}</td><td>�ļ���</td><td></td></tr>", directory.Name, directory.CreationTime);
                else
                    sb.AppendFormat("<tr class='odd'><td>{0}</td><td>{1}</td><td>�ļ���</td><td></td></tr>", directory.Name, directory.CreationTime);

            }

            foreach (var file in files)
            {
                ++count;
                if(IsEven(count))
                    sb.AppendFormat("<tr class='even'><td>{0}</td><td>{1}</td><td>�ļ�</td><td>{2}</td></tr>", file.Name, file.LastWriteTime, file.Length);
                else
                    sb.AppendFormat("<tr class='odd'><td>{0}</td><td>{1}</td><td>�ļ�</td><td>{2}</td></tr>", file.Name, file.LastWriteTime, file.Length);

            }

            var title = "��ȡĿ¼��{0}������ϸ��Ϣ@{1}".FormatWith(context.CommandParameter, DateTime.Now);
            body = body.Replace("{FileList}", sb.ToString());
            var to = context.To;

            SendComment(context, "#PCң����#���ڷ���Ŀ¼��{0}������ϸ��Ϣ����ָ����Email�У����һ����ա�".FormatWith(context.CommandParameter));
            context.MailUtility.Send(to, title, body);
        }
示例#7
0
        public void Execute(CommandContext context)
        {
            Bitmap bitmap = null;
            EncoderParameters encoderParams = null;
            EncoderParameter parameter = null;
            try
            {
                var temp = Environment.GetEnvironmentVariable("TEMP");
                var picPath = temp + "\\" + Guid.NewGuid() + ".bmp";

                var webcam = new WebCamUtility(context.Handle, 600, 480);
                webcam.StartWebCam();
                webcam.GrabImage(context.Handle, picPath);
                webcam.CloseWebcam();

                bitmap = new Bitmap(picPath);
                var codecInfo = GetCodecInfo("image/jpeg");
                var quality = Encoder.Quality;
                encoderParams = new EncoderParameters(1);
                const long num = 0x5fL;
                parameter = new EncoderParameter(quality, num);
                encoderParams.Param[0] = parameter;

                var newPicPath = picPath.Replace("bmp", "jpg");
                bitmap.Save(newPicPath, codecInfo, encoderParams);

                if (context.SendPhotoByEmail)
                {
                    SendComment(context, "#PCң����#���ڷ������WebCamץ�ĵ����ָ��Email�У����һ��ȥ���ա�");
                    SendPhotoByEmail(context, newPicPath);
                }
                else
                {
                    SendComment(context, "#PCң����#�����ϴ����WebCamץ�ģ�һ�Ὣ��������������΢���С�");
                    context.WeiboService.SendWeiboWithPicture("������ʹ��#PCң����#�����ҵ�WebCamץ�� " + DateTime.Now.ToLongTimeString(), newPicPath);
                }

            }
            finally
            {
                if (parameter != null) parameter.Dispose();
                if (encoderParams != null) encoderParams.Dispose();
                if (bitmap != null) bitmap.Dispose();
            }
        }
示例#8
0
        public void Execute(CommandContext context)
        {
            var parameters = context.CommandParameter.Split('|');

            if (parameters.Length == 0)
                throw new ArgumentNullException();

            var song = string.Empty;
            var singer = string.Empty;

            switch (parameters.Length)
            {
                case 1:
                    song = parameters[0].Trim();
                    break;
                case 2:
                    song = parameters[0].Trim();
                    singer = parameters[1].Trim();
                    break;
            }

            var graber = new BaiduMp3Graber();
            var result = graber.Grab(song, singer);

            if (result.Count == 0)
            {
                SendComment(context, "�ܱ�Ǹ��û���ҵ�����Ҫ�ĸ�����");
                return;
            }

            string downUrl;
            if (result.DLinks.Count != 0 && !string.IsNullOrEmpty(result.DLinks[0].Encode))
                downUrl = result.DLinks[0].TrueDownloadUrl;
            else
                downUrl = result.Links[0].TrueDownloadUrl;

            SendComment(context, string.Format("#PCң����# ��ʼ�������ظ�����{0}, ���ص�ַΪ��{1}", song, downUrl));
            DonwloadMp3(context.DownloadPath, downUrl, song, singer);
            SendComment(context, "�����������...");
        }
示例#9
0
 public void Execute(CommandContext context)
 {
     SendComment(context, "#PCң����#���ڰ���ע�����ļ������");
     Process.Start("shutdown", "-l -f");
 }
示例#10
0
        public void Execute(CommandContext context)
        {
            var parameters = context.CommandParameter.Split('|');
            if (parameters.Length == 0)
                throw new ArgumentNullException();

            var user = string.Empty;
            var count = 0;
            var sendToEmail = false;

            switch (parameters.Length)
            {
                case 1:
                    user = parameters[0].Trim();
                    break;
                case 2:
                    user = parameters[0].Trim();
                    count = Convert.ToInt32(parameters[1].Trim());
                    break;
                case 3:
                    user = parameters[0].Trim();
                    count = Convert.ToInt32(parameters[1].Trim());
                    if (parameters[2].Trim() == "1")
                        sendToEmail = true;
                    break;
            }

            SendComment(context, string.Format("#PCң����# ��ʼΪ������Instagram���û� {0} ����Ƭ��ͼƬ�п��ܺܶ࣬�����ĵȺ򡣡���", user));

            var graber = new InstagramGraber();
            var images = graber.Grab(user, count);

            var downDirectory = string.Format("{0}\\Instagram\\{1}", context.DownloadPath, user);
            if (!Directory.Exists(downDirectory))
                Directory.CreateDirectory(downDirectory);

            var downPara = new DownloadParameter();
            var files = new List<string>();
            foreach (var image in images)
            {
                var index = image.LastIndexOf("/");
                var fileName = image.Substring(index);
                downPara.FilePath = string.Format("{0}\\{1}", downDirectory, fileName);
                downPara.Url = image;

                if(File.Exists(downPara.FilePath))
                    continue;

                NetworkUtility.DownloadFile(downPara);
                files.Add(downPara.FilePath);
            }

            var page = files.Count/100 + 1;
            if(sendToEmail)
            {
                for (var i = 0; i < page; i++)
                {
                    var filesToSend = files.Take(100).Skip(i*100).ToArray();
                    SendPhotoByEmail(context, filesToSend);
                }
            }

            SendComment(context, string.Format("��Ƭ������ɡ�����һ��������{0}����Ƭ��", images.Count));
        }
示例#11
0
 public void Execute(CommandContext context)
 {
     SendComment(context, "#PCң����#�Ѿ������ر�������ʾ����");
     SendMessage(0xFFFF, 0x112, 0xF170, 2);
 }
示例#12
0
 public void Execute(CommandContext context)
 {
     SendComment(context, "#PC遥控器#将会在5分钟之后帮您关闭您的计算机。如果需要终止重启,请发微博:终止关机$$任意内容。");
     Process.Start("shutdown", "-s -f -t 300");
 }
示例#13
0
 public void Execute(CommandContext context)
 {
     SendComment(context, "#PCң����#����Ϊ��������һ����ý���ļ���");
     InputUtility.Send(InputUtility.Keyboard.MediaNextTrack);
 }
示例#14
0
文件: Main.cs 项目: terryso/PCRemote
 private CommandContext CreateCommandContext(string weiboId, IntPtr handle, EmailAccount account)
 {
     var context = new CommandContext
                       {
                           WeiboId = weiboId,
                           WeiboService = _service,
                           Handle = handle,
                           SendPhotoByEmail = Settings.Default.SendPhotoByEmail,
                           MailUtility = new MailUtility(account),
                           To = Settings.Default.MyEmailAddress,
                           DownloadPath = Settings.Default.DownloadPath
                       };
     return context;
 }
示例#15
0
 public void Execute(CommandContext context)
 {
     SendComment(context, "#PCң����#����Ϊ�����ŵ�ǰ�Ķ�ý���ļ���");
     InputUtility.Send(InputUtility.Keyboard.MediaPlayPause);
 }
示例#16
0
 public void Execute(CommandContext context)
 {
     SendComment(context, "#PCң����#�Ѿ�������ס���ļ��������Ļ��");
     Process.Start("rundll32.exe", "user32.dll,LockWorkStation");
 }
示例#17
0
文件: Main.cs 项目: rench/PCRemote
        private void ProcessCommand(string command, string weiboId)
        {
            NotifyIcon.Text = @"正在处理命令...";
            DebugPrintHelper("当前状态:处理命令中...");

            ICommand commandHandler;

            if(_commands.ContainsKey(command))
            {
                commandHandler = _commands[command];
                var context = new CommandContext
                {
                    WeiboId = weiboId,
                    WeiboService = _service,
                    Handle = Handle
                };

                commandHandler.Execute(context);
            }
            else
            {
                RunCustomCommands(weiboId, command);
            }
        }
示例#18
0
 public void Execute(CommandContext context)
 {
     SendComment(context, "#PCң����#�Ѿ�����ֹͣ���ŵ�ǰ�Ķ�ý���ļ���");
     InputUtility.Send(InputUtility.Keyboard.MediaStop);
 }
示例#19
0
 public void Execute(CommandContext context)
 {
     SendComment(context, "#PC遥控器#已经停止关闭您的计算机。");
     Process.Start("shutdown", "-a");
 }
示例#20
0
 public void Execute(CommandContext context)
 {
     SendComment(context, "#PCң����#�Ѿ������ļ������Ϊ�����ȡ��������뷢΢����ȡ������$$�������ݡ�");
     SendMessageW(context.Handle, WM_APPCOMMAND, context.Handle, new IntPtr(APPCOMMAND_VOLUME_MUTE));
 }