protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); //System.Threading.Thread.Sleep(1 * 1000); //System.Diagnostics.Debugger.Launch(); //System.Diagnostics.Debugger.Break(); string cscsScript = e.Args.Length == 0 ? GetConfiguration("CSCS_Init", "../../scripts/defaultWindow.cscs") : e.Args[0]; var pathName = Path.GetFullPath(cscsScript); if (!File.Exists(pathName)) { MessageBox.Show("File " + pathName + " doesn't exist.", "Invalid file path", MessageBoxButton.OK, MessageBoxImage.Error); Environment.Exit(1); } //cscsScript = "../../scripts/start.cscs"; Console.WriteLine("Running CSCS script: " + pathName); CSCS_SQL.Init(); try { CSCS_GUI.RunScript(pathName); } catch (Exception exc) { MessageBox.Show("Error running " + pathName + ": " + exc.Message, "Error running script", MessageBoxButton.OK, MessageBoxImage.Error); Environment.Exit(1); } //StartupUri = new Uri("../MainWindow.xaml", UriKind.Relative); }
private void Win_Deactivated(object sender, EventArgs e) { Window win = sender as Window; var funcName = Path.GetFileNameWithoutExtension(win.Tag.ToString()) + "_OnDeactivated"; CSCS_GUI.RunScript(funcName, win, new Variable(win.Tag)); Instance.Deactivated -= Win_Deactivated; }
private void Win_Loaded(object sender, RoutedEventArgs e) { Window win = sender as Window; CSCS_GUI.AddActions(win, true); var funcName = Path.GetFileNameWithoutExtension(win.Tag.ToString()) + "_OnStart"; CSCS_GUI.RunScript(funcName, win, new Variable(win.Tag)); Instance.Loaded -= Win_Loaded; }
private void Win_ContentRendered(object sender, EventArgs e) { Window win = sender as Window; var funcName = Path.GetFileNameWithoutExtension(win.Tag.ToString()) + "_OnDisplay"; CSCS_GUI.RunScript(funcName, win, new Variable(win.Tag)); Instance.ContentRendered -= Win_ContentRendered; if (Owner != null && Mode != MODE.NORMAL) { win.Owner = Owner; } }
void MainView_Loaded(object sender, RoutedEventArgs e) { CSCS_SQL.Init(); CSCS_GUI.MainWindow = this; CSCS_GUI.AddActions(CSCS_GUI.MainWindow, true); var win = NewWindowFunction.CreateNew("../../scripts/Sample.xaml"); CSCS_GUI.AddActions(win.Instance, true); var res = this.Resources; var cscsScript = (string)res["CSCS"]; //CSCS_GUI.MainWindow.Tag = "MainWindow"; Console.WriteLine("Running CSCS script: " + cscsScript); CSCS_GUI.RunScript(cscsScript); CSCS_GUI.MainWindow = this; /*string[] cmdArgs = Environment.GetCommandLineArgs(); * if (cmdArgs.Length <= 2) * { * CSCS_GUI.RunScript(cscsScript); * return; * } * * var cmdLineParams = cmdArgs[2].Split(new char[] { ',' }); * var scriptName = cmdLineParams[0]; * /*string msg = "StartArgs:"; * for (int i = 0; i < cmdArgs.Length; i++) * { * msg += " [" + cmdArgs[i] + "]"; * } * msg += " Script: [" + scriptName + "]"; * MessageBox.Show(msg, cmdArgs.Length + " args", MessageBoxButton.OK, MessageBoxImage.Asterisk);*/ //CSCS_GUI.RunScript("../../scripts/" + scriptName); }
private void Win_Closing(object sender, System.ComponentModel.CancelEventArgs e) { Window win = sender as Window; var funcName = Path.GetFileNameWithoutExtension(win.Tag.ToString()) + "_OnClosing"; var result = CSCS_GUI.RunScript(funcName, win, new Variable(win.Tag)); e.Cancel = result != null && result.AsBool(); if (e.Cancel) { return; } Instance.Closing -= Win_Closing; if (Mode == MODE.SPECIAL_MODAL && Instance.Owner != null) { IntPtr handle = (new System.Windows.Interop.WindowInteropHelper(Instance)).Handle; IntPtr ownerhandle = (new System.Windows.Interop.WindowInteropHelper(Instance.Owner)).Handle; EnableWindow(handle, false); EnableWindow(ownerhandle, true); ClosedCallBack(ModalDialogResult); } }
private void Win_Closed(object sender, EventArgs e) { Window win = sender as Window; var funcName = Path.GetFileNameWithoutExtension(win.Tag.ToString()) + "_OnClose"; CSCS_GUI.RunScript(funcName, win, new Variable(win.Tag)); if (IsMain) { Environment.Exit(0); } Instance.Closed -= Win_Closed; Instance.Close(); Instance = null; var parent = ChainFunction.GetParentWindow(win.Tag.ToString()); parent?.Focus(); NewWindowFunction.RemoveWindow(win); }