public AssetForm(AssetElement ae, Form parentWindow, TreeNode node) { // Creates a new asset form for a given asset element Node = node; Asset = ae; MdiParent = parentWindow; Initialize(); // Create subsystem icons for asset subsystems int currX = 32; int currY = 32; foreach (SubsystemElement sub in ae.Subsystems) { // Create new icon SubsystemIcon newIcon = new SubsystemIcon(); newIcon.MouseDown += new MouseEventHandler(drawingCanvas1.SubsystemClicked); newIcon.MouseMove += new MouseEventHandler(drawingCanvas1.newIcon_MouseMove); newIcon.subsystem = sub; newIcon.Location = new Point(currX, currY); newIcon.Parent = drawingCanvas1; newIcon.BringToFront(); int seed = (int)(DateTime.UtcNow.TimeOfDay.Ticks); Random random = new Random(seed); Thread.Sleep((int)(random.NextDouble() * 100)); newIcon.Shade = MagicColors.RandomColor(40); drawingCanvas1.SubsystemIcons.Add(newIcon); // Update location of icons currX += 64; currY = currY == 32 ? 128 : 32; } }
private void eomTypeComboBox_SelectedIndexChanged(object sender, EventArgs e) { // Change element's type of EOM and register event AssetElement before = (AssetElement)Asset.Clone(); Asset.Position.Eoms.Type = (EomsType)eomTypeComboBox.SelectedValue; AssetElement after = (AssetElement)Asset.Clone(); if (before.ToXml() != after.ToXml()) { _mManager.RegisterEvent(before, after, Asset, "EOMs Type Change"); } // Enable / disable controls based on type if (Asset.Position.Eoms.Type == EomsType.None) { initFuncTextbox.Enabled = false; evalFuncTextbox.Enabled = false; } else { initFuncTextbox.Enabled = true; evalFuncTextbox.Enabled = true; } }
private void addAssetMenuItem_Click(object sender, EventArgs e) { // Get asset name from dialog TextboxDialog dialog = new TextboxDialog("Create new asset", "New asset name"); dialog.ShowDialog(); if (dialog.Cancelled) { return; } // Create new asset element with given name AssetElement ae = new AssetElement(); ae.Name = dialog.StringValue; // Add asset to selected model TreeNode modelNode = mainTreeView.SelectedNode; ModelComponent model = ((ModelForm)mainTreeView.SelectedNode.Tag).Model; model.Assets.Add(ae); // Refresh to add node UpdateModelNode(model, modelNode.Parent); TreeNode newNode = getNodeFromElement(ae); mainTreeView.SelectedNode = newNode; PicassoSubform newForm = (PicassoSubform)newNode.Tag; newForm.Show(); }
private void importAssetMenuItem_Click(object sender, EventArgs e) { // Show Import Dialog ImportDialog dialog = new ImportDialog(); dialog.Icon = Icon; dialog.ShowDialog(); if (dialog.Cancelled) { return; } // Create new asset element with given name AssetElement ae = new AssetElement(); ae.FromXml(dialog.Asset.ToXml()); // Add asset to selected model TreeNode modelNode = mainTreeView.SelectedNode; ModelComponent model = ((ModelForm)mainTreeView.SelectedNode.Tag).Model; model.Assets.Add(ae); // Refresh to add node UpdateModelNode(model, modelNode.Parent); }
private void importButton_Click(object sender, EventArgs e) { // Create a new asset from current import selection and assign to Hashtable source; string name = (string)listBox1.SelectedItem; if (name == null) { return; } if (comboBox1.Text == ImportQuerySource.CelesTrak.ToString()) { source = _importUt.ImportFromCeles(name); } else { source = _importUt.ImportFromPosc(name, textBox1.Text); } // Read source ht values and convert into asset _asset = new AssetElement(); _asset.Name = source["Name"].ToString(); _asset.Position.Ics.FromString(source["Position"].ToString()); _asset.Position.PositionType = PositionType.DynamicECI; Close(); }
public AssetForm(Form parentWindow, TreeNode node) { // Creates a new asset form for a new asset element Node = node; Asset = new AssetElement(); MdiParent = parentWindow; Initialize(); }
public void Index_Should_Return_Element() { AssetElement element = CreateElement(); _collection.Add(element); var result = _collection["foo"]; Assert.Same(element, result); }
private void evalFuncTextbox_TextChanged(object sender, EventArgs e) { // Save change to evaluation function and register event AssetElement before = (AssetElement)Asset.Clone(); Asset.Position.Eoms.EvaulationFunction = evalFuncTextbox.Text; AssetElement after = (AssetElement)Asset.Clone(); if (before.ToXml() != after.ToXml()) { _mManager.RegisterEvent(before, after, Asset, "Evaluation Function Change"); } }
private void positionTypeComboBox_SelectedIndexChanged(object sender, EventArgs e) { // Change position type of element and register event AssetElement before = (AssetElement)Asset.Clone(); Asset.Position.PositionType = (PositionType)positionTypeComboBox.SelectedValue; AssetElement after = (AssetElement)Asset.Clone(); if (before.ToXml() != after.ToXml()) { _mManager.RegisterEvent(before, after, Asset, "Position Type Change"); } // Update labels, if necessary switch (Asset.Position.PositionType) { case PositionType.DynamicECI: case PositionType.PredeterminedECI: case PositionType.StaticECI: // ECI: show all textboxes, update labels, and enlarge ICs x2Textbox.Visible = true; x2Label.Visible = true; y2Textbox.Visible = true; y2Label.Visible = true; z2Textbox.Visible = true; z2Label.Visible = true; x1Label.Text = "Px"; y1Label.Text = "Py"; z1Label.Text = "Pz"; x2Label.Text = "Vx"; y2Label.Text = "Vy"; z2Label.Text = "Vz"; Asset.Position.Ics.ChangeDimensions(6, 1); break; case PositionType.DynamicLLA: case PositionType.PredeterminedLLA: case PositionType.StaticLLA: // LLA: hide extra textboxes and update labels x2Textbox.Visible = false; x2Label.Visible = false; y2Textbox.Visible = false; y2Label.Visible = false; z2Textbox.Visible = false; z2Label.Visible = false; x1Label.Text = "Long"; y1Label.Text = "Lat"; z1Label.Text = "Alt"; Asset.Position.Ics.ChangeDimensions(3, 1); break; default: MessageBox.Show("Unknown asset position type"); break; } }
private void z2Textbox_TextChanged(object sender, EventArgs e) { // Change position[5] value and register event try { AssetElement before = (AssetElement)Asset.Clone(); Asset.Position.Ics[5] = Convert.ToDouble(z2Textbox.Text); AssetElement after = (AssetElement)Asset.Clone(); if (before.ToXml() != after.ToXml()) { _mManager.RegisterEvent(before, after, Asset, "Z2 Value Change"); } } catch (FormatException) { // Improperly formatted value; should be a decimal value MessageBox.Show("Improperly formatted value; should be a decimal value"); } }
public override void FromXml(string source) { // Deserializes model from xml string XqlParser parser = new XqlParser(); parser.LoadData(source); // Start with Lua List <Hashtable> results = parser.Query("SELECT _outerXml FROM " + Lua.ElementType); if (results.Count == 0) { // LUA tages are optional; if there are no tags present, scripting is disabled and no scripts are specified //throw new HsfComponentException("Unable to parse " + ElementType + " from xml"); Lua.IsScriptingEnabled = false; Lua.Files.Clear(); } else { Lua.FromXml(results[0]["_outerXml"].ToString()); } // Next, schedule evaluator results = parser.Query("SELECT _outerXml FROM " + ScheduleEvaluator.ElementType); if (results.Count == 0) { throw new HsfComponentException("Unable to parse " + ElementType + " from xml"); } ScheduleEvaluator.FromXml(results[0]["_outerXml"].ToString()); // Lastly, assets AssetElement blankAsset = new AssetElement(); Assets.Clear(); results = parser.Query("SELECT _outerXml FROM " + blankAsset.ElementType); foreach (Hashtable ht in results) { AssetElement newAsset = new AssetElement(); newAsset.FromXml(ht["_outerXml"].ToString()); Assets.Add(newAsset); } }
public AssetElementFixture() { _element = new AssetElement(); }
static void WriteData(Dictionary <string, string> resPathDic) { AssetManifest manifest = new AssetManifest(); manifest.AssetLst = new List <AssetElement>(); foreach (string path in resPathDic.Keys) { AssetElement element = new AssetElement(); element.Path = path; //element.Crc = Crc32.GetCrc32(path); element.ABName = resPathDic[path]; element.AssetName = path.Remove(0, path.LastIndexOf("/") + 1); element.DependAB = new List <string>(); string[] resDependce = AssetDatabase.GetDependencies(path); for (int i = 0; i < resDependce.Length; i++) { string tempPath = resDependce[i]; string abName = ""; if (mAllFileABNameDic.TryGetValue(tempPath, out abName)) { if (abName == resPathDic[path])//依赖资源就在本包内 忽略 (其实就包含了过滤自己) { continue; } if (!element.DependAB.Contains(abName)) { element.DependAB.Add(abName); } } } manifest.AssetLst.Add(element); } //写入xml string xmlPath = Application.dataPath + "/assetmanifest.xml"; if (File.Exists(xmlPath)) { File.Delete(xmlPath); } FileStream fileStream = new FileStream(xmlPath, FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite); StreamWriter sw = new StreamWriter(fileStream, System.Text.Encoding.UTF8); XmlSerializer xs = new XmlSerializer(manifest.GetType()); xs.Serialize(sw, manifest); sw.Close(); fileStream.Close(); //写入二进制 //foreach (AssetElement abBase in manifest.AssetLst) //{ // abBase.Path = ""; //} FileStream fs = new FileStream(mABBinaryPath, FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite); fs.Seek(0, SeekOrigin.Begin); fs.SetLength(0); BinaryFormatter bf = new BinaryFormatter(); bf.Serialize(fs, manifest); fs.Close(); AssetDatabase.Refresh(); setABName("assetmanifest", mABBinaryPath); }
public string GetElementKey(AssetElement element) { return(base.GetElementKey(element) as string); }