Не верь, не бойся, не проси - [entries|archive|friends|userinfo]
phantom

[ website | My Website ]
[ userinfo | ljr userinfo ]
[ archive | journal archive ]

[May. 24th, 2007|11:24 pm]
Previous Entry Add to Memories Tell A Friend Next Entry
LinkLeave a comment

Comments:
From:[info]masterofpuppets
Date:May 25th, 2007 - 05:27 pm
(Link)
под виндовозом что-ли программа?
From:[info]phantom
Date:May 25th, 2007 - 08:19 pm
(Link)
ага, под виндовозом.
причём под последним.
From:[info]masterofpuppets
Date:May 25th, 2007 - 09:38 pm
(Link)
покажи исходник, пожалуйста
From:[info]phantom
Date:May 25th, 2007 - 10:56 pm
(Link)
вся работа выполняется вот этим классом:

using System;
using System.IO;
using System.Diagnostics;
using System.Windows.Automation;

namespace VoiceOperativeMode
{
public class Supervisor
{
static desktop: AutomationElement = AutomationElement.RootElement;

//[PermissionSet(SecurityAction.Demand, Name="FullTrust")]
public Watch(): void
{
CreateWatcher("*.tex", FileUpdated);
CreateWatcher("*.dvi", FileUpdated);
}

CreateWatcher(filter: string, handler: FileSystemEventHandler): void
{
def watcher = FileSystemWatcher(@"D:\Mathematics", filter);
watcher.IncludeSubdirectories = true;
watcher.NotifyFilter = NotifyFilters.LastWrite;
watcher.Changed += handler;
watcher.EnableRaisingEvents = true;
}

FileUpdated(_: object, arguments: FileSystemEventArgs): void
{
def extension = Path.GetExtension(arguments.FullPath);
def handler = match (extension)
{
| ".tex" => CompileLatex;
| ".dvi" => ShowDviInYap;
| _ => throw ArgumentException($"Unknown extension: $extension");
}
_ = handler(arguments.FullPath);
}

CompileLatex(path: string): bool
{
assert(path.EndsWith(".tex"));
def info = ProcessStartInfo("latex", path);
info.WindowStyle = ProcessWindowStyle.Hidden;
info.WorkingDirectory = Path.GetDirectoryName(path);
def process = Process.Start(info);
_ = process.WaitForExit(2500);
def success = process.HasExited;
unless(success)
{
process.Kill();
Speaker.Say("Error");
}
success
}

ShowDviInYap(path: string): bool
{
assert(path.EndsWith(".dvi"));
// assume this shit is already in yap, just focus it and back
def children = desktop.FindAll(TreeScope.Children, Condition.TrueCondition).ToList();
def yaps = children.Filter(child => child.Current.Name.StartsWith("Yap"));
def editors = children.Filter(child => child.Current.Name.TrimStart().StartsWith("WinEdt"));
Console.WriteLine(editors.Length);
Console.WriteLine(editors.Map(e => e.Current.Name));
if (yaps.IsEmpty)
false
else
{
yaps.Head.SetFocus();
unless (editors.IsEmpty)
editors.Head.SetFocus();
true
}
}
}
}
From:[info]masterofpuppets
Date:May 26th, 2007 - 12:47 am
(Link)
какой это язык?
From:[info]phantom
Date:May 26th, 2007 - 01:59 am
(Link)
Немерле однако
хуяк - отсюда позырь.