private void ShowForm() { if (this.MainForm == null) { this.MainForm = new MainForm(ConfigSystem.GetSettingPort()); (this.MainForm as MainForm).SetSize(ConfigSystem.GetWIndowSize()); } (this.MainForm as MainForm).Booting(); }
private void GetSetting(WSNode node) { var obj = new { Port = ConfigSystem.GetSettingPort(), Size = ConfigSystem.GetWIndowSize(), Start = ConfigSystem.GetWindowStart() }; String json = JsonConvert.SerializeObject(obj); node.Data = json; }
private void SetSetting(WSNode node) { var data = JsonConvert.DeserializeObject <Dictionary <String, String> >(node.Data); foreach (var n in data) { ConfigSystem.WriteConfig("Config", "Setting", n.Key, n.Value); } if (this.context.MainForm != null) { (this.context.MainForm as MainForm).SetSize(ConfigSystem.GetWIndowSize()); } }
static void Main(string[] args) { string mtxName = "PrivateTaskManager"; Mutex mtx = new Mutex(true, mtxName); TimeSpan tsWait = new TimeSpan(0, 0, 1); bool success = mtx.WaitOne(tsWait); if (!success) { String port = ConfigSystem.GetSettingPort(); HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://localhost:" + port + "/Start"); using (HttpWebResponse response = (HttpWebResponse)request.GetResponse()) { Console.WriteLine(response.StatusCode); } return; } Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new MainContext()); }
public static string GetWindowStart() { string start = ConfigSystem.ReadConfig("Config", "Setting", "Start"); return(String.IsNullOrEmpty(start) ? "on" : start); }
public static string GetWIndowSize() { String size = ConfigSystem.ReadConfig("Config", "Setting", "Size"); return(String.IsNullOrEmpty(size) ? "full" : size); }
public static string GetSettingPort() { string port = ConfigSystem.ReadConfig("Config", "Setting", "Port"); return(String.IsNullOrEmpty(port) ? "9999" : port); }
public MainContext() { ORMFactory.Initialize(); this.components = new Container(); this.notify = new NotifyIcon(this.components); this.notify.Icon = new Icon(Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "favicon.ico")); this.notify.Visible = true; this.notify.ContextMenu = new ContextMenu(); this.notify.ContextMenu.MenuItems.AddRange(SetMenuItem()); this.notify.Text = "Private Task Management"; ThreadPool.QueueUserWorkItem(c => { int port = 9999; try { port = Convert.ToInt32(ConfigSystem.GetSettingPort()); } catch { } string path = Path.GetDirectoryName(Application.ExecutablePath); var server = ServerFactory.NewInstance(port); var flow = new Flow(); var message = new Message(this); server.SetDefaultFile("index.html"); server.SetZip(path + "\\html.data"); //server.SetRootPath(webpath); /*server.Set("/", (res, req) => * { * //req.SetCookie("test", "aaa", DateTime.Now.AddMinutes(5)); * //req.SetSession("aaaaa", "asdfasfd"); * req.ReadFile(webpath + @"\index.html"); * });*/ server.Set("/js/define.js", (res, req) => { req.ContextType = "text / javascript; charset = UTF - 8"; req.Body = "var wsurl = \"ws://localhost:" + Convert.ToInt32(ConfigSystem.GetSettingPort()) + "/menu\";"; }); server.Set("/Start", (res, req) => { ShowForm(); req.StateOK(); }); server.SetWebSocket(mes => { Console.WriteLine(mes); WSNode node = WSNode.ToNode(mes.ToString()); if (node.Type == 1) { flow.Execute(node.Key, node); } else if (node.Type == 2) { message.Execute(node.Key, node); } return(new WebSocketNode() { OPCode = Opcode.BINARY, Message = node.ToString2() }); }); }); if (String.Equals(ConfigSystem.GetWindowStart(), "on")) { ShowForm(); } }