/// <summary> /// Método que lee un archivo con un catálogo serializado. /// </summary> /// <param name="path">Ruta del archivo</param> public void Load(string path) { catalogPath = path; Stream stream = null; try { stream = File.Open(catalogPath, FileMode.Open, FileAccess.Read); BinaryFormatter bformatter = new BinaryFormatter(); Load(stream, bformatter); } catch (FileNotFoundException e) { Console.WriteLine(Culture.Get("fileNotFound") + ": '" + catalogPath + "'"); throw e; } finally { if (stream != null) { stream.Close(); stream.Dispose(); stream = null; } } if (CatalogChanged != null) { CatalogChanged(this, EventArgs.Empty); } }
/// <summary> /// Al construir un AreaElement se necesita un prototipo de Propiedades, que define el tipo de elemento que /// se forma. De esta manera, después de construir el elemento no se le puede cambiar el tipo, además de que /// se pueden crear varios elementos con las mismas propiedades. La constructora clona al prototipo, de manera /// que un objeto externo puede crear varios elementos con el mismo objeto de propiedades. /// </summary> /// <param name="prototype">El prototipo de propiedades.</param> public AreaElement(AreaProps prototype) { props = (AreaProps)prototype.Clone(); joints = new Joint[4]; angle = 0; mass = 0; materialTemperature = 0; offsets = new float[4]; //springs = new ManagedList<AreaSprings>(); flipJoints = 0; Joint j = Model.Instance.JointList[1]; int i = 1; while (j == null && i < Model.Instance.JointList.Count) { j = Model.Instance.JointList[i++]; } if (j != null) { J1 = J2 = J3 = j; joints[3] = null; } else { throw new NullReferenceException(Culture.Get("EM0020")); } }
private void updateDesignCombosPage() { designNameLabel.Text = currentDesignOptions.ToString(); selectedCombosListBox.Items.Clear(); allCombosListBox.Items.Clear(); foreach (AbstractCase aCase in services.Model.AbstractCases) { if (aCase is LoadCombination) { if (currentDesignOptions.DesignCombinations.Contains((LoadCombination)aCase)) { selectedCombosListBox.Items.Add(aCase); } else { allCombosListBox.Items.Add(aCase); } } } editComboLinkLabel.Enabled = (allCombosListBox.SelectedItem != null || selectedCombosListBox.SelectedItem != null); AcceptButton = analyzeButton2; if (currentDesignOptions is SteelDesignOptions && services.Model.ConcreteDesignOptions is ConcreteDesignOptions) { analyzeButton2.Text = Culture.Get("next"); } else { analyzeButton2.Text = Culture.Get("analyze"); } }
public void UpdatePage2() { if (material != null) { material.Name = material.Name; // Checks that material name is valid nameTextBox.Text = material.Name; densityTextBox.Text = material.Density.ToString(); densityLabel.Text = Culture.Get("Density") + " (" + Canguro.Model.Model.Instance.UnitSystem.UnitName(Canguro.Model.UnitSystem.Units.Density) + ")"; MaterialTypeProps typeProps = material.TypeProperties; MaterialDesignProps designProps = material.DesignProperties; for (int i = 0; i < typeList.Count; i++) { if (typeList[i].ToString().Equals(typeProps.ToString())) { typeComboBox.SelectedIndex = i; } } typePropertyGrid.SelectedObject = typeProps; for (int i = 0; i < designPropList.Count; i++) { if (designPropList[i].ToString().Equals(designProps.ToString())) { designComboBox.SelectedIndex = i; } } designPropertyGrid.SelectedObject = designProps; } else { wizardControl.SelectTab(0); } }
protected override void ExecuteCrmWorkFlowActivity(CodeActivityContext context, LocalWorkflowContext localContext) { if (context == null) { throw new ArgumentNullException(nameof(context)); } if (localContext == null) { throw new ArgumentNullException(nameof(localContext)); } DateTime dateToUse = DateToUse.Get(context); bool evaluateAsUserLocal = EvaluateAsUserLocal.Get(context); string culture = Culture.Get(context); if (evaluateAsUserLocal) { int?timeZoneCode = GetLocalTime.RetrieveTimeZoneCode(localContext.OrganizationService); dateToUse = GetLocalTime.RetrieveLocalTimeFromUtcTime(dateToUse, timeZoneCode, localContext.OrganizationService); } string monthName = dateToUse.ToString("MMMM", CultureInfo.CreateSpecificCulture(culture)); MonthName.Set(context, monthName); }
/// <summary> /// Al construir un LineElement se necesita un prototipo de Propiedades, que define el tipo de elemento que /// se forma. De esta manera, después de construir el elemento no se le puede cambiar el tipo, además de que /// se pueden crear varios elementos con las mismas propiedades. La constructora clona al prototipo, de manera /// que un objeto externo puede crear varios elementos con el mismo objeto de propiedades. /// </summary> /// <param name="prototype">El prototipo de propiedades.</param> public LineElement(LineProps prototype) { props = (LineProps)prototype.Clone(); joints = new Joint[2]; angle = 0; dofI = new JointDOF(true); dofJ = new JointDOF(true); Joint j = Model.Instance.JointList[1]; int i = 1; while (j == null && i < Model.Instance.JointList.Count) { j = Model.Instance.JointList[i++]; } if (j != null) { I = j; J = j; } else { throw new NullReferenceException(Culture.Get("EM0020")); } }
public void TryGet_ObsoleteCulture_EventRaised() { Currency c; Action tryGetObsolete = () => Currency.TryGet(Culture.Get("et-EE"), out c); Assert.That(tryGetObsolete, Must.Raise.ObsoleteEvent()); }
/// <summary> /// Executes the command. /// Executes Join with all the Items and asks to renumber the JointList and LineList objects. /// </summary> /// <param name="services">CommandServices object to interact with the system</param> public override void Run(Canguro.Controller.CommandServices services) { Join(services.Model, services.Model.JointList, services.Model.LineList, services.Model.AreaList); RepairJoints(services.Model); string msg = ""; bool conn; Canguro.Utility.AnalysisUtils.CanAnalyze(services.Model, ref msg, out conn); services.Model.ChangeModel(); msg = Culture.Get("confirmCompactIDs"); if (!conn) { msg = Culture.Get("structureIsDisconnectedWrn") + "\n\n" + msg; } if (System.Windows.Forms.MessageBox.Show(msg, Culture.Get("confirm"), System.Windows.Forms.MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes) { services.Model.JointList.Compact(); services.Model.LineList.Compact(); services.Model.AreaList.Compact(); } services.Model.ChangeModel(); }
/// <summary> /// Executes the command. /// Gets the Load Case properties from the User, adds it to the Model and sets it as Active. /// </summary> /// <param name="services">CommandServices object to interact with the system</param> public override void Run(Canguro.Controller.CommandServices services) { string name = Culture.Get("defaultLoadCase"); LoadCase lCase = new LoadCase(name, LoadCase.LoadCaseType.Dead); lCase.Name = name; // services.GetProperties(lCase.Name, lCase, false); EditLoadCaseDialog dlg = new EditLoadCaseDialog(lCase); if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK) { if (!services.Model.LoadCases.ContainsKey(lCase.Name)) { services.Model.LoadCases.Add(lCase.Name, lCase); } services.Model.ActiveLoadCase = lCase; AnalysisCase aCase = new AnalysisCase(lCase.Name); StaticCaseProps props = aCase.Properties as StaticCaseProps; if (props != null) { List <StaticCaseFactor> list = props.Loads; list.Add(new StaticCaseFactor(lCase)); props.Loads = list; services.Model.AbstractCases.Add(aCase); } } else { services.Model.Undo.Rollback(); } }
protected override void ExecuteCrmWorkFlowActivity(CodeActivityContext context, LocalWorkflowContext localContext) { if (context == null) { throw new ArgumentNullException(nameof(context)); } if (localContext == null) { throw new ArgumentNullException(nameof(localContext)); } DateTime originalDate = DateToFormat.Get(context); string cultureIn = Culture.Get(context); CultureInfo culture = null; if (!string.IsNullOrEmpty(cultureIn)) { culture = new CultureInfo(cultureIn); } string formattedDateString = originalDate.ToUniversalTime().ToString(culture); FormattedDateString.Set(context, formattedDateString); }
public void ForCulture_DefinedCulture_PropertiesSet() { Money twentyBucks = Money.ForCulture(20, Culture.Get("en-US")); Assert.That(twentyBucks.Amount, Is.EqualTo(20m)); Assert.That(twentyBucks.CurrencyCode, Is.EqualTo(CurrencyIsoCode.USD)); }
/// <summary> /// Executes the command. /// Adds a new Layer with the given Name and sets it as Active. /// </summary> /// <param name="services">CommandServices object to interact with the system</param> public override void Run(Canguro.Controller.CommandServices services) { services.StoreSelection(); string name = services.GetString(Culture.Get("setLayerName")); string aux = name; bool valid = false; int i = 1; while (!valid) { valid = true; foreach (Layer l in services.Model.Layers) { if (l != null && l.Name.Equals(aux)) { valid = false; } } if (!valid) { aux = name + "(" + i++ + ")"; } } Layer layer = new Layer(aux); services.Model.Layers.Add(layer); services.Model.ActiveLayer = layer; services.RestoreSelection(); }
/// <summary> /// Agrega un elemento a la lista. Avisa a UndoManager para habilitar /// undo y para revisar que el modelo no esté bloqueado. /// Si el Item tiene Id asignado (Esto sucede en el caso de undo), se trata de /// poner en la lista en el lugar Id. Si este lugar está ocupado por otro Item, /// se lanza una InvalidIndexException. /// </summary> /// <param name="item">Item to add</param> public override void Add(Titem item) { //Model.Instance.Undo.Add(item, this); if (item != null) { int id = (int)item.Id; if (id == 0) { base.Add(item); item.Id = (uint)(Count - 1); } else if (id >= Count) { for (int i = Count; i < id; i++) { base.Add(null); } base.Add(item); } else if (base[id] == null) { base[id] = item; } else if (base[id] != item) { throw new InvalidIndexException(Culture.Get("EM0002")); } } else { base.Add(null); } }
public void LoadModel(string path) { try { string extension = System.IO.Path.GetExtension(path).ToLower(); if (System.IO.File.Exists(path)) { switch (extension) { case ".dxf": Commands.Model.ImportDXFCmd.Import(path, Model.Model.Instance); break; case ".xml": new Canguro.Model.Serializer.Deserializer(Model.Model.Instance).Deserialize(path); break; default: Model.Model.Instance.Load(path); break; } Model.Model.Instance.Undo.Commit(); } else { MessageBox.Show(Culture.Get("fileNotFound"), Culture.Get("error"), MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception) { MessageBox.Show(Culture.Get("errorLoadingFile") + " " + path, Culture.Get("error"), MessageBoxButtons.OK, MessageBoxIcon.Error); Model.Model.Instance.Undo.Rollback(); } }
protected override void Execute(NativeActivityContext context) { var twilio = context.GetExtension <ITwilioContext>(); var resourceSource = ResourceSource; var resourceName = ResourceName.Get(context); var culture = Culture.Get(context); if (resourceSource == null) { throw new ArgumentNullException("ResourceSource"); } if (resourceName == null) { throw new ArgumentNullException("ResourceName"); } // resolve resource url var url = twilio.ResolveResourceUrl(resourceSource, resourceName, culture); if (url == null) { throw new NullReferenceException("Could not resolve resource."); } // set variables referenced by child playUrl.Set(context, url.ToString()); loop.Set(context, Loop.Get(context)); // execute play context.ScheduleActivity(play); }
/// <summary> /// Executes the command. /// If the CurrentPath is not set, displays the Save File Dialog. /// Saves the Model in a file. /// </summary> /// <param name="services">CommandServices object to interact with the system</param> public override void Run(Canguro.Controller.CommandServices services) { string path = ""; string currentPath = services.Model.CurrentPath; if (currentPath.Length == 0) { System.Windows.Forms.SaveFileDialog dlg = new System.Windows.Forms.SaveFileDialog(); dlg.Filter = "Treu Structure Model (*.tsm)|*.tsm"; dlg.DefaultExt = "tsm"; dlg.AddExtension = true; dlg.Title = Culture.Get("SaveTitle"); dlg.FileName = Culture.Get("defaultModelName"); if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK) { path = dlg.FileName; } } else { path = currentPath; } if (path.Length > 0) { services.Model.Save(path); } }
private void updateModel(object sender, System.EventArgs e) { if (lastUnitSystem != Canguro.Model.Model.Instance.UnitSystem) { foreach (DataGridViewColumn column in Columns) { PropertyDescriptor pd = (PropertyDescriptor)column.Tag; UnitsAttribute gridUnits = ((UnitsAttribute)pd.Attributes[typeof(UnitsAttribute)]); string units = ""; if (gridUnits.Units != Canguro.Model.UnitSystem.Units.NoUnit) { units = " [" + Canguro.Model.Model.Instance.UnitSystem.UnitName(gridUnits.Units) + "]"; } if (!string.IsNullOrEmpty(units)) { //int i1;//, i2; //i2 = column.HeaderText.LastIndexOf(']'); //i1 = column.HeaderText.LastIndexOf('['); //column.HeaderText = column.HeaderText.Substring(0, i1) + units; column.HeaderText = Culture.Get(pd.DisplayName) + units; } } lastUnitSystem = Canguro.Model.Model.Instance.UnitSystem; } fillSelectedItems(null, false); }
private void loadButton_Click(object sender, EventArgs e) { Canguro.Model.UnitSystem.UnitSystemsManager.Instance.Enabled = false; string path = ""; System.Windows.Forms.OpenFileDialog dlg = new System.Windows.Forms.OpenFileDialog(); dlg.Filter = "Treu Structure Sections (*.xsec)|*.xsec"; dlg.DefaultExt = "xsec"; dlg.AddExtension = true; if (model.CurrentPath.Length > 0) { dlg.FileName = model.CurrentPath; } dlg.CheckPathExists = true; if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK) { path = dlg.FileName; } try { if (path.Length > 0) { SectionManager.Instance.LoadXmlSections(path, model.Sections); } } catch { MessageBox.Show(Culture.Get("errorLoadingFile") + " " + path, Culture.Get("error"), MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { Canguro.Model.UnitSystem.UnitSystemsManager.Instance.Enabled = true; } UpdatePage1(); }
static void initialize(object l) { form.loadPicture.Image = form.loadImageList.Images[l.GetType().Name]; form.loadText.Text = Culture.Get("loadType" + l.GetType().Name); form.loadDescription.Text = Culture.Get("loadDescription" + l.GetType().Name); form.properties.SelectedObject = l; }
public void TryGet_NoRegionForCulture_False() { CultureInfo neutralSpanish = Culture.Get("es"); Currency tried; Assert.That(Currency.TryGet(neutralSpanish, out tried), Is.False); Assert.That(tried, Is.Null); }
protected override object GetFormattedValue(object value, int rowIndex, ref DataGridViewCellStyle cellStyle, TypeConverter valueTypeConverter, TypeConverter formattedValueTypeConverter, DataGridViewDataErrorContexts context) { if (value != null && value is EnumType) { return(Culture.Get(value.ToString())); } return(default(EnumType)); }
public void TryGet_DefinedCurrencyForCulture_True() { CultureInfo spanish = Culture.Get("es-ES"); Currency tried; Assert.That(Currency.TryGet(spanish, out tried), Is.True); Assert.That(tried, Is.SameAs(Currency.Eur)); }
// Module defining this command // Optional custom code for this activity /// <summary> /// Returns a configured instance of System.Management.Automation.PowerShell, pre-populated with the command to run. /// </summary> /// <param name="context">The NativeActivityContext for the currently running activity.</param> /// <returns>A populated instance of Sytem.Management.Automation.PowerShell</returns> /// <remarks>The infrastructure takes responsibility for closing and disposing the PowerShell instance returned.</remarks> protected override ActivityImplementationContext GetPowerShell(NativeActivityContext context) { System.Management.Automation.PowerShell invoker = global::System.Management.Automation.PowerShell.Create(); System.Management.Automation.PowerShell targetCommand = invoker.AddCommand(PSCommandName); // Initialize the arguments if (ReferenceObject.Expression != null) { targetCommand.AddParameter("ReferenceObject", ReferenceObject.Get(context)); } if (DifferenceObject.Expression != null) { targetCommand.AddParameter("DifferenceObject", DifferenceObject.Get(context)); } if (SyncWindow.Expression != null) { targetCommand.AddParameter("SyncWindow", SyncWindow.Get(context)); } if (Property.Expression != null) { targetCommand.AddParameter("Property", Property.Get(context)); } if (ExcludeDifferent.Expression != null) { targetCommand.AddParameter("ExcludeDifferent", ExcludeDifferent.Get(context)); } if (IncludeEqual.Expression != null) { targetCommand.AddParameter("IncludeEqual", IncludeEqual.Get(context)); } if (PassThru.Expression != null) { targetCommand.AddParameter("PassThru", PassThru.Get(context)); } if (Culture.Expression != null) { targetCommand.AddParameter("Culture", Culture.Get(context)); } if (CaseSensitive.Expression != null) { targetCommand.AddParameter("CaseSensitive", CaseSensitive.Get(context)); } return(new ActivityImplementationContext() { PowerShellInstance = invoker }); }
public void Format_CulturesWithSameCurrencyAndDifferentFormat_FormatHonored() { var subject = new Money(1500, CurrencyIsoCode.EUR); string format = "{1} {0:#,#.00}"; Assert.That(subject.Format(format, Culture.Get("fr-FR")), Is.Not.EqualTo(subject.Format(format)), "Germany has different format than France"); }
public void ToString_CulturesWithSameCurrencyAndDifferentFormat_FormatHonored() { var subject = new Money(1000, CurrencyIsoCode.EUR); Assert.That(subject.ToString(), Is.EqualTo("1.000,00 €")); Assert.That(subject.ToString(Culture.Get("fr-FR")), Is.Not.EqualTo(subject.ToString()), "Germany has different format than France"); }
private void EndOffsetsControl_Load(object sender, EventArgs e) { offILabel.Text = Culture.Get("LineEndOffsetI") + " (" + Model.Model.Instance.UnitSystem.UnitName(Canguro.Model.UnitSystem.Units.Distance) + ")"; offJLabel.Text = Culture.Get("LineEndOffsetJ") + " (" + Model.Model.Instance.UnitSystem.UnitName(Canguro.Model.UnitSystem.Units.Distance) + ")"; factorLabel.Text = Culture.Get("LineEndOffsetFactor"); offILabel.Size = new Size(38, 15); offJLabel.Size = new Size(38, 15); UpdateControl(); }
private string getJointRestraints(Joint j) { if (j.DoF.IsRestrained) { return("\n" + Culture.Get("jointDoFProp") + ": " + j.DoF.ToString()); } return(string.Empty); }
private string getJointConstraints(Joint j) { if (j.Constraint != null) { return("\n" + Culture.Get("jointConstraintProp") + ": " + j.Constraint); } return(string.Empty); }
public void TruncateToSignificantDecimalDigits_CultureWithDifferentCurrency_CultureApplied() { var subject = new Money(2m / 3, CurrencyIsoCode.GBP); NumberFormatInfo spanishFormatting = Culture.Get("es-ES").NumberFormat; Assert.That(subject.Amount, Is.Not.EqualTo(0.66m), "the raw amount has more decimals"); Assert.That(subject.TruncateToSignificantDecimalDigits(spanishFormatting).Amount, Is.EqualTo(0.66m), "in Spain, 2 decimals are used for currencies"); }
public void Set_Both_CultureAndUiSetToSame() { CultureInfo ci = Culture.Get("dv-MV"); using (CultureReseter.Set(ci)) { Assert.That(CultureInfo.CurrentCulture, Is.EqualTo(ci)); Assert.That(CultureInfo.CurrentUICulture, Is.EqualTo(ci)); } }