//public override void save_file() //{ // SaveAsTemplate(); //} //public override void save_file_as() //{ //} private void LoadButton_Click(object sender, EventArgs e) { try { OpenFileDialog d = new OpenFileDialog(); d.Filter = "Templates (*.xml)|*.xml"; d.InitialDirectory = CoreGlobals.getWorkPaths().mTemplateRoot; if (d.ShowDialog() == DialogResult.OK) { XmlSerializer s = new XmlSerializer(typeof(TriggerTemplateDefinition), new Type[] { }); Stream st = File.OpenRead(d.FileName); TemplateDefinition = (TriggerTemplateDefinition)s.Deserialize(st); st.Close(); this.Parent.Text = Path.GetFileName(d.FileName); saveAsName = d.FileName; } } catch (System.Exception ex) { CoreGlobals.getErrorManager().OnException(ex); } }
private static void InternalScan(object input)//bool bfilter, List<string> filterList) { ScanSettings settings = input as ScanSettings; bool bfilter = settings.bFilter; List <string> filterList = settings.filterList; //TreeNode templateNode = new TreeNode("Scanning Templates"); List <ScanResults> scanResults = mScanResults; // new List<ScanResults>(); List <string> templates = settings.templates; // TriggerSystemMain.mTriggerDefinitions.GetTemplateFileNames(); foreach (string filename in templates) { if (bfilter == true && filterList.Contains(filename.ToLower()) == false) { continue; } try { if (filename.Contains("customswatches.xml") == true) { continue; } XmlSerializer s = new XmlSerializer(typeof(TriggerTemplateDefinition), new Type[] { }); Stream st = File.OpenRead(filename); TriggerTemplateDefinition def = (TriggerTemplateDefinition)s.Deserialize(st); st.Close(); TriggerNamespace ns = new TriggerNamespace(); //ns.TriggerData = def.TriggerSystemRoot; //TriggerRoot output = ns.TriggerData; ns.mDebugInfo.Clear(); ns.PreProcessObjectGraph(def.TriggerSystemRoot, false, def.TriggerTemplateMapping.GetActivatedTriggers(), def.TriggerTemplateMapping.GetInitializedVars()); if (ns.mDebugInfo.Count > 0) { lock (scanResults) { //TreeNode thisFile = new TreeNode(); foreach (TriggerSystemDebugInfo d in ns.mDebugInfo) { //TreeNode info = new TreeNode(d.ToString()); //info.Tag = d; //SetNodeProps(info, d); //thisFile.Nodes.Add(info); scanResults.Add(new ScanResults(filename, "Template", d)); } } //thisFile.Text = filename; //templateNode.Nodes.Add(thisFile); } } catch (System.Exception ex) { //templateNode.Nodes.Add("Fatal error loading " + filename + " " + ex.ToString()); } } //this.ScanResultsTreeView.Nodes.Add(templateNode); //this.ScanResultsTreeView.Refresh(); //TreeNode powerNode = new TreeNode("Scanning Powers/Abilites/Triggerscripts"); List <string> scripts = settings.scripts;// new List<string>(); //scripts.AddRange(TriggerSystemMain.mTriggerDefinitions.GetPowerFileNames()); //scripts.AddRange(TriggerSystemMain.mTriggerDefinitions.GetAbilityFileNames()); //scripts.AddRange(TriggerSystemMain.mTriggerDefinitions.GetGeneralScriptFileNames()); foreach (string filename in scripts) { if (bfilter == true && filterList.Contains(filename.ToLower()) == false) { continue; } try { if (filename.Contains("customswatches.xml") == true) { continue; } XmlSerializer s = new XmlSerializer(typeof(TriggerRoot), new Type[] { }); Stream st = File.OpenRead(filename); TriggerRoot root = (TriggerRoot)s.Deserialize(st); st.Close(); //TriggerNamespace ns = new TriggerNamespace(); //ns.TriggerData = root; ////TriggerRoot output = ns.TriggerData; TriggerNamespace ns = new TriggerNamespace(); ns.mDebugInfo.Clear(); ns.PreProcessObjectGraph(root, false); if (ns.mDebugInfo.Count > 0) { //TreeNode thisFile = new TreeNode(); lock (scanResults) { foreach (TriggerSystemDebugInfo d in ns.mDebugInfo) { //TreeNode info = new TreeNode(d.ToString()); //info.Tag = d; //SetNodeProps(info, d); //thisFile.Nodes.Add(info); scanResults.Add(new ScanResults(filename, "AbilityPowerTScript", d)); } } //thisFile.Text = filename; //powerNode.Nodes.Add(thisFile); } } catch (System.Exception ex) { //powerNode.Nodes.Add("Fatal error loading " + filename + " " + ex.ToString()); } } //this.ScanResultsTreeView.Nodes.Add(powerNode); //this.ScanResultsTreeView.Refresh(); //TreeNode scenarioNode = new TreeNode("Scanning Scenarios"); //string[] scenarioFiles = CoreGlobals.getWorkPaths().GetScenarioFiles(); List <string> scenarioFiles = settings.scenarios; foreach (string filename in scenarioFiles) { if (bfilter == true && filterList.Contains(filename.ToLower()) == false) { continue; } try { if (filename.Contains("customswatches.xml") == true) { continue; } XmlSerializer s = new XmlSerializer(typeof(ScenarioXML), new Type[] { }); Stream st = File.OpenRead(filename); ScenarioXML scenXml = (ScenarioXML)s.Deserialize(st); st.Close(); foreach (TriggerRoot ts in scenXml.mTriggers) { //TriggerNamespace ns = new TriggerNamespace(); //ns.TriggerData = ts; ////TriggerRoot output = ns.TriggerData; TriggerNamespace ns = new TriggerNamespace(); ns.mDebugInfo.Clear(); ns.PreProcessObjectGraph(ts, false); if (ns.mDebugInfo.Count > 0) { lock (scanResults) { //TreeNode thisFile = new TreeNode(); foreach (TriggerSystemDebugInfo d in ns.mDebugInfo) { //TreeNode info = new TreeNode(d.ToString()); //SetNodeProps(info, d); //info.Tag = d; //thisFile.Nodes.Add(info); scanResults.Add(new ScanResults(filename, "Scenario", d)); } } //thisFile.Text = filename; //scenarioNode.Nodes.Add(thisFile); } } } catch (System.Exception ex) { //scenarioNode.Nodes.Add("Fatal error loading " + filename + " " + ex.ToString()); } } System.Threading.Interlocked.Decrement(ref mRemainingTasks); //this.ScanResultsTreeView.Nodes.Add(scenarioNode); //ScanResultsTreeView.ImageList = l; //this.ScanResultsTreeView.Refresh(); //return scanResults; }
public TriggerTemplatePage() { InitializeComponent(); TriggerSystemMain.Init(); triggerHostArea1.ViewChanged += new EventHandler(triggerHostArea1_ViewChanged); previewNavWindow1.BorderStyle = BorderStyle.FixedSingle; TemplateAttributesPropertyGrid.IgnoreProperties("TriggerTemplateMapping", new string[] { "InputMappings", "OutputMappings", "TriggerInputs", "TriggerOutputs", "GroupID", "ID", "X", "Y", "Name", "CommentOut" }); TemplateAttributesPropertyGrid.AddMetaDataForProp("TriggerTemplateMapping", "SizeX", "Min", 30); TemplateAttributesPropertyGrid.AddMetaDataForProp("TriggerTemplateMapping", "SizeX", "Max", 800); TemplateAttributesPropertyGrid.AddMetaDataForProp("TriggerTemplateMapping", "SizeY", "Min", 30); TemplateAttributesPropertyGrid.AddMetaDataForProp("TriggerTemplateMapping", "SizeY", "Max", 500); TemplateAttributesPropertyGrid.AddMetaDataForProp("TriggerTemplateMapping", "Image", "FileFilter", "Images (*.bmp)|*.bmp"); TemplateAttributesPropertyGrid.AddMetaDataForProp("TriggerTemplateMapping", "Image", "RootDirectory", CoreGlobals.getWorkPaths().mBaseDirectory); TemplateAttributesPropertyGrid.AddMetaDataForProp("TriggerTemplateMapping", "Image", "StartingDirectory", Path.Combine(CoreGlobals.getWorkPaths().mAppIconDir, "TriggerEditor")); TemplateAttributesPropertyGrid.SetTypeEditor("TriggerTemplateMapping", "Image", typeof(FileNameProperty)); TemplateAttributesPropertyGrid.AnyPropertyChanged += new ObjectEditorControl.PropertyChanged(onAnyPropertyChanged); InputVarsBasicTypedSuperList.UseLabels = false; OutputVarsBasicTypedSuperList.UseLabels = false; InputTriggersBasicTypedSuperList.UseLabels = false; OutputTriggersBasicTypedSuperList.UseLabels = false; InputVarsBasicTypedSuperList.AddMetaDataForProp("TriggersTemplateInputVariable", "Type", "ReadOnly", true); InputVarsBasicTypedSuperList.AddMetaDataForProp("TriggersTemplateInputVariable", "ID", "Ignore", true); //InputVarsBasicTypedSuperList.AddMetaDataForProp("TriggersTemplateInputVariable", "Optional", "Ignore", true); InputVarsBasicTypedSuperList.AddMetaDataForProp("TriggersTemplateInputVariable", "SigID", "Ignore", true); InputVarsBasicTypedSuperList.AddMetaDataForProp("TriggersTemplateInputVariable", "BindID", "TriggerNamespace", mMainTriggerSystem.MainNamespace); InputVarsBasicTypedSuperList.AddMetaDataForProp("TriggersTemplateInputVariable", "BindID", "UpdateEvent", true); InputVarsBasicTypedSuperList.SetTypeEditor("TriggersTemplateInputVariable", "BindID", typeof(VariableIDProperty)); InputVarsBasicTypedSuperList.mListDataObjectType = typeof(TriggersTemplateInputVariable); InputVarsBasicTypedSuperList.SelectedObjectPropertyChanged += new BasicTypedSuperList.PropertyChanged(basicTypedSuperList1_SelectedObjectPropertyChanged); InputVarsBasicTypedSuperList.AnyObjectPropertyChanged += new BasicTypedSuperList.PropertyChanged(onAnyPropertyChanged); InputVarsBasicTypedSuperList.NeedsResize += new EventHandler(BasicTypedSuperList_Changed); OutputVarsBasicTypedSuperList.AddMetaDataForProp("TriggersTemplateOutputVariable", "Type", "ReadOnly", true); OutputVarsBasicTypedSuperList.AddMetaDataForProp("TriggersTemplateOutputVariable", "ID", "Ignore", true); //OutputVarsBasicTypedSuperList.AddMetaDataForProp("TriggersTemplateOutputVariable", "Optional", "Ignore", true); OutputVarsBasicTypedSuperList.AddMetaDataForProp("TriggersTemplateOutputVariable", "SigID", "Ignore", true); OutputVarsBasicTypedSuperList.AddMetaDataForProp("TriggersTemplateOutputVariable", "BindID", "TriggerNamespace", mMainTriggerSystem.MainNamespace); OutputVarsBasicTypedSuperList.AddMetaDataForProp("TriggersTemplateOutputVariable", "BindID", "UpdateEvent", true); OutputVarsBasicTypedSuperList.SetTypeEditor("TriggersTemplateOutputVariable", "BindID", typeof(VariableIDProperty)); OutputVarsBasicTypedSuperList.mListDataObjectType = typeof(TriggersTemplateOutputVariable); OutputVarsBasicTypedSuperList.SelectedObjectPropertyChanged += new BasicTypedSuperList.PropertyChanged(basicTypedSuperList1_SelectedObjectPropertyChanged); OutputVarsBasicTypedSuperList.AnyObjectPropertyChanged += new BasicTypedSuperList.PropertyChanged(onAnyPropertyChanged); OutputVarsBasicTypedSuperList.NeedsResize += new EventHandler(BasicTypedSuperList_Changed); InputTriggersBasicTypedSuperList.IgnoreProperties("TriggersTemplateInputActionBinder", new string[] { "Color", "TargetIDs", "_TargetID", "BindID" }); InputTriggersBasicTypedSuperList.AddMetaDataForProp("TriggersTemplateInputActionBinder", "_BindID", "ReadOnly", true); InputTriggersBasicTypedSuperList.SetTypeEditor("TriggersTemplateInputActionBinder", "_BindID", typeof(TriggerBindIDProperty)); InputTriggersBasicTypedSuperList.SelectedObjectPropertyChanged += new BasicTypedSuperList.PropertyChanged(InputTriggersBasicTypedSuperList_SelectedObjectPropertyChanged); InputTriggersBasicTypedSuperList.mListDataObjectType = typeof(TriggersTemplateInputActionBinder); InputTriggersBasicTypedSuperList.AnyObjectPropertyChanged += new BasicTypedSuperList.PropertyChanged(onAnyPropertyChanged); InputTriggersBasicTypedSuperList.NeedsResize += new EventHandler(BasicTypedSuperList_Changed); OutputTriggersBasicTypedSuperList.IgnoreProperties("TriggersTemplateOutputActionBinder", new string[] { "Color", "TargetIDs", "_TargetID", "BindID" }); OutputTriggersBasicTypedSuperList.AddMetaDataForProp("TriggersTemplateOutputActionBinder", "_BindID", "ReadOnly", true); OutputTriggersBasicTypedSuperList.SetTypeEditor("TriggersTemplateOutputActionBinder", "_BindID", typeof(TriggerBindIDProperty)); OutputTriggersBasicTypedSuperList.SelectedObjectPropertyChanged += new BasicTypedSuperList.PropertyChanged(OutputTriggersBasicTypedSuperList_SelectedObjectPropertyChanged); OutputTriggersBasicTypedSuperList.mListDataObjectType = typeof(TriggersTemplateOutputActionBinder); OutputTriggersBasicTypedSuperList.AnyObjectPropertyChanged += new BasicTypedSuperList.PropertyChanged(onAnyPropertyChanged); OutputTriggersBasicTypedSuperList.NeedsResize += new EventHandler(BasicTypedSuperList_Changed); TriggerRoot trigroot = new TriggerRoot(); mFakeTriggerSystem.TriggerData = trigroot; triggerHostArea2.CurrentTriggerNamespace = mFakeTriggerSystem.MainNamespace; TemplateDefinition = new TriggerTemplateDefinition(); }