public static FormMain CreateForm(IDatabaseCoordinator coordinator, ByteHolder holder, OrdinaryDifferentialEquations.IDifferentialEquationSolver ordSolver, DataPerformer.Portable.DifferentialEquationProcessors.DifferentialEquationProcessor diffProcessor, DataPerformer.Portable.Interfaces.IDataRuntimeFactory strategy, IApplicationInitializer[] initializers, IUIFactory[] factories, bool throwsRepeatException, LightDictionary <string, ButtonWrapper[]> buttons, Icon icon, string filename, Dictionary <string, object>[] resources, string text, string ext, string fileFilter, TextWriter logWriter, TestCategory.Interfaces.ITestInterface testInterface) { EngineeringUIFactory factory = new EngineeringUIFactory(factories, true, ext); StaticExtensionDiagramUIFactory.UIFactory = factory; IDatabaseCoordinator c = coordinator; if (c == null) { c = AssemblyService.StaticExtensionAssemblyService.GetFirstInterfaceObjectFromBaseDirectory <IDatabaseCoordinator>(); } EngineeringInitializer initializer = new EngineeringInitializer(c, ordSolver, diffProcessor, strategy, initializers, throwsRepeatException, resources, logWriter); DefaultApplicationCreator creator = new DefaultApplicationCreator(c, buttons, icon, factory, holder, filename, factory.Start, resources, text, ext, fileFilter, initializer, logWriter, testInterface); return(CreateForm(creator)); }
/// <summary> /// Creates application form without 3D shapes /// </summary> /// <param name="coordinator">Database coordinator</param> /// <param name="holder">byte holder for editor of proprerties</param> /// <param name="ordSolver">Ordinary differential equations solver</param> /// <param name="diffProcessor">Ordinary differential equations processor</param> /// <param name="initializers">Array of initializers</param> /// <param name="factories">UI Factotries</param> /// <param name="throwsRepeatException">The "throw exception for repeat" sign</param> /// <param name="buttons">Palette buttons</param> /// <param name="icon">Form icon</param> /// <param name="filename">File name</param> /// <param name="resources">Localization resourses</param> /// <param name="text">Caption text</param> /// <param name="ext">File extesion</param> /// <returns>The Application form</returns> /// <returns></returns> public static FormMain CreateForm(IDatabaseCoordinator coordinator, ByteHolder holder, OrdinaryDifferentialEquations.IDifferentialEquationSolver ordSolver, DataPerformer.Portable.DifferentialEquationProcessors.DifferentialEquationProcessor diffProcessor, IApplicationInitializer[] initializers, IUIFactory[] factories, bool throwsRepeatException, LightDictionary <string, ButtonWrapper[]> buttons, Icon icon, string filename, Dictionary <string, object>[] resources, string text, string ext, string fileFilter, TextWriter logWriter, TestCategory.Interfaces.ITestInterface testInterface) { return(CreateForm(coordinator, holder, ordSolver, diffProcessor, initializers, factories, throwsRepeatException, buttons, icon, null, filename, resources, text, ext, fileFilter, logWriter, testInterface)); }
public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, IServiceProvider provider, object value) { ByteHolder holder = value as ByteHolder; BasicEngineering.UI.Factory.Advanced.Forms.FormMain m = StaticExtension.CreateAviationForm(null, holder, null, null, null, null, false, null, null, null, null); m.ShowDialog(); return(m.Creator.Holder); }
/// <summary> /// Extracts InkObjects from a Microsoft JNT.XML file, which store information about Ink.Stroke data. /// Converts each InkObject from a Base64 string into a byte array. /// </summary> /// <param name="xmlDoc">A Microsoft JNT.XML file that contains Ink data to be extracted.</param> /// <param name="pageNumber">Page number to extract</param> /// <returns>The Ink data of the document stored in an array of byte arrays</returns> private ByteHolder[] ExtractXmlInkObject(XmlDocument xmlDoc, int pageNumber) { //Please refer to http://support.microsoft.com/default.aspx?scid=kb;en-us;318545 for help XmlNamespaceManager manager = new XmlNamespaceManager(xmlDoc.NameTable); manager.AddNamespace("sketch", "urn:schemas-microsoft-com:tabletpc:journalreader"); //This is an xpath query to extract all the InkObjects from the specific JournalPage XmlNodeList inkNodes = xmlDoc.SelectNodes("//sketch:JournalPage[@Number='" + pageNumber.ToString() + "']//sketch:InkObject", manager); ByteHolder[] toReturn = new ByteHolder[inkNodes.Count]; // Create an array of byte arrays //byte [][] textFromInkObjs = new byte[inkNodes.Count][]; // Cycle through the inkNodes and pull out each InkObject int i; int j; int length = inkNodes.Count; for (i = 0; i < length; ++i) { // Get the matrix scalartransform data XmlNode transform = inkNodes[i].ParentNode.FirstChild; toReturn[i].isShifted = false; if (transform.Name == "ScalarTransform") { toReturn[i].isShifted = true; float[] m = new float[9]; for (j = 1; j <= 9; ++j) { m[j - 1] = Convert.ToSingle(transform.Attributes["Mat" + j.ToString()].Value); } // We have to scale the last two arguments by 2.54 so that the shifting transformation works correctly // There are other examples of code that does this (InkExplorer), but it is undocumented. // All we really know is that in order to get shifting/scaling to work, you need to divide the // shift by 2.54 toReturn[i].shift = new Matrix(m[0], m[1], m[3], m[4], (int)(m[2] / 2.54), (int)(m[5] / 2.54)); } // Grab the Base64 string from the InkObject and convert it to a byte array // textFromInkObjs[count] = Convert.FromBase64String(inkNode.InnerText); toReturn[i].inkBytes = Convert.FromBase64String(inkNodes[i].InnerText); } return(toReturn); //return textFromInkObjs; }
public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, IServiceProvider provider, object value) { string[] tabs = new string[] { "General", "6D Motion", "Arrows" }; ButtonWrapper[][] but = new ButtonWrapper[tabs.Length][]; int i = 0; List <ButtonWrapper> gen = new List <ButtonWrapper>(); gen.AddRange(DataPerformer.UI.Factory.StaticFactory.GeneralObjectsButtons); // gen.AddRange(ControlSystems.Data.UI.Factory.ControlSystemsFactory.ObjectButtons); but[i] = gen.ToArray(); ++i; List <ButtonWrapper> geom = new List <ButtonWrapper>(); //geom.AddRange(Motion6D.UI.Factory.MotionFactory.ObjectButtons); // geom.AddRange(Motion6D.UI.Factory.VisibleFactory.GetVisualObjectButtons(factory)); but[i] = geom.ToArray(); ++i; List <ButtonWrapper> arr = new List <ButtonWrapper>(); arr.AddRange(EngineeringUIFactory.ArrowButtons); arr.AddRange(Motion6D.UI.Factory.MotionFactory.ArrowButtons); arr.AddRange(Motion6D.UI.Factory.VisibleFactory.VisualArrowButtons); but[i] = arr.ToArray(); LightDictionary <string, ButtonWrapper[]> buttons = new LightDictionary <string, ButtonWrapper[]>(); buttons.Add(tabs, but); IUIFactory[] factories = new IUIFactory[] { // ControlSystems.Data.UI.Factory.ControlSystemsFactory.Object, }; IApplicationInitializer[] init = new IApplicationInitializer[] { }; Dictionary <string, object>[] d = Motion6D.UI.Utils.ControlUtilites.Resources; ByteHolder holder = value as ByteHolder; FormMain m = MotionApplicationCreator.CreateForm(null, holder, OrdinaryDifferentialEquations.Runge4Solver.Singleton, DataPerformer.Portable.DifferentialEquationProcessors.RungeProcessor.Processor, init, factories, true, buttons, Properties.Resources.Aviation, null, null, Motion6D.UI.Utils.ControlUtilites.Resources, "Astronomy + OpenGL", ".cfa", "Astronomy configuration files |*.cfa", null, null); m.ShowDialog(); return(m.Creator.Holder); }
/// <summary> /// Creates application form /// </summary> /// <param name="coordinator">Database coordinator</param> /// <param name="holder">byte holder for editor of proprerties</param> /// <param name="ordSolver">Ordinary differential equations solver</param> /// <param name="diffProcessor">Ordinary differential equations processor</param> /// <param name="initializers">Array of initializers</param> /// <param name="factories">UI Factotries</param> /// <param name="throwsRepeatException">The "throw exception for repeat" sign</param> /// <param name="buttons">Palette buttons</param> /// <param name="icon">Form icon</param> /// <param name="positionFactory">Position factory</param> /// <param name="filename">File name</param> /// <param name="resources">Localization resourses</param> /// <param name="text">Caption text</param> /// <param name="ext">File extesion</param> /// <param name="fileFilter">Filter for file dialog</param> /// <param name="logWriter">Log writer</param> /// <param name="testInterface">Test Interface</param> /// <returns>The Application form</returns> public static FormMain CreateForm(IDatabaseCoordinator coordinator, ByteHolder holder, OrdinaryDifferentialEquations.IDifferentialEquationSolver ordSolver, DataPerformer.Portable.DifferentialEquationProcessors.DifferentialEquationProcessor diffProcessor, IApplicationInitializer[] initializers, IUIFactory[] factories, bool throwsRepeatException, LightDictionary <string, ButtonWrapper[]> buttons, Icon icon, IPositionObjectFactory positionFactory, string filename, Dictionary <string, object>[] resources, string text, string ext, string fileFilter, TextWriter logWriter, TestCategory.Interfaces.ITestInterface testInterface) { Motion6D.PositionFactory.Factory = Motion6D.Drawing.Factory.ColoredPositionFactory.Object; Motion6D.UI.UserControls.SimpleChooser.Chooser = Motion6D.UI.UserControls.ColoredChooser.Object; List <IUIFactory> fact = null; if (factories == null) { fact = new List <IUIFactory>(); } else { fact = new List <IUIFactory>(factories); } fact.Add(MotionFactory.Object); if (positionFactory != null) { VisibleFactory vf = new VisibleFactory(positionFactory); fact.Add(vf); } List <IApplicationInitializer> apps = new List <IApplicationInitializer>(initializers); apps.Add(Motion6D.ApplicationInitializer.Object); FormMain form = DefaultApplicationCreator.CreateForm(coordinator, holder, ordSolver, diffProcessor, Motion6D.Runtime.DataRuntimeFactory.Object, apps.ToArray(), fact.ToArray(), throwsRepeatException, buttons, icon, filename, resources, text, ext, fileFilter, logWriter, testInterface); StaticExtensionMotion6D.Animation = form; return(form); }
public static FormMain CreateForm(IDatabaseCoordinator coordinator, ByteHolder holder, OrdinaryDifferentialEquations.IDifferentialEquationSolver ordSolver, DataPerformer.Portable.DifferentialEquationProcessors.DifferentialEquationProcessor diffProcessor, IApplicationInitializer[] initializers, IUIFactory[] factories, bool throwsRepeatException, LightDictionary <string, ButtonWrapper[]> buttons, Icon icon, string filename, Dictionary <string, object>[] resources, string text, string ext, string fileFilter, TextWriter logWriter, TestCategory.Interfaces.ITestInterface testInterface) { EngineeringUIFactory factory = new EngineeringUIFactory(factories, true, ext); EngineeringInitializer initializer = new EngineeringInitializer(coordinator, ordSolver, diffProcessor, DataPerformer.Runtime.DataRuntimeFactory.Object, initializers, throwsRepeatException, resources, logWriter); DefaultApplicationCreator creator = new DefaultApplicationCreator(coordinator, buttons, icon, factory, holder, filename, factory.Start, resources, text, ext, fileFilter, initializer, logWriter, testInterface); return(CreateForm(creator)); }
public DefaultApplicationCreator(IDatabaseCoordinator coordinator, LightDictionary <string, ButtonWrapper[]> buttons, Icon icon, EngineeringUIFactory factory, ByteHolder holder, string filename, Action <double, double, int, int, int, IDesktop> start, Dictionary <string, object>[] resources, string text, string ext, string fileFilter, IApplicationInitializer initializer, TextWriter log, TestCategory.Interfaces.ITestInterface testInterface) { this.coordinator = coordinator; this.buttons = buttons; this.icon = icon; this.factory = factory; this.holder = holder; this.filename = filename; this.start = start; this.resources = resources; this.text = text; this.ext = ext; this.fileFilter = fileFilter; this.initializer = initializer; this.log = log; this.testInterface = testInterface; }
internal override bool Transform(string propName, string propData, ResolutionContext ctx, ConvertionManager cm, ExtensionResolution ex) { // convert to custom type (with an ObjectConverter registered in ConvertionManager). var objectConverter = cm.TryGet(typeof(string), ExtensionDataType); if (objectConverter == null) { return(false); } // if an property value is provided for the property name, try to convert it. object propValue; if (!objectConverter.TryConvert(propData, out propValue)) { return(false); } var holder = new ByteHolder(propValue); ex.Data.AddDataHolder(propName, holder); return(true); }
// Notes that this method will load the related assembly which defined the IExtensionBuilder implementation into memory. /// <summary> /// The required properties of extension builder (marked by ExtensionDataAttribute) must be provided by the extension data. /// </summary> /// <returns></returns> internal static bool ExtensionDataMatchesExtensionBuilder(this ExtensionResolution ex, IMessageDialog dialog, ResolutionContext ctx, ConvertionManager convertionManager) { var ebProperties = ex.ExtensionBuilder.Type.GetSettableRuntimeProperties(); if (ebProperties == null) { return(true); } var data = ex.Data; foreach (var ebProp in ebProperties) { var propName = ebProp.Name; string propInput; if (!data.TryGetString(propName, out propInput)) { var exPropAttrib = ebProp.GetCustomAttribute <ExtensionPropertyAttribute>(false, false); if (exPropAttrib != null && exPropAttrib.Required) { dialog.AddError("a required property is missing!"); return(false); } continue; } #region specific types if (ebProp.PropertyType == typeof(string)) { var holder = new StringHolder(propInput); data.AddSerializableHolder(propName, holder); continue; } // convert to TypeId if (ebProp.PropertyType == typeof(TypeId)) { TypeResolution type; // a type dependency is introduced here. // should it be added to the current addin's reference set? if (!ctx.TryGetAddinType(ex.DeclaringAddin, propInput, out type)) { dialog.AddError(""); return(false); } var holder = new LazyTypeIdHolder(type); data.AddSerializableHolder(propName, holder); continue; } #endregion // convert to custom type (with an ObjectConverter registered in ConvertionManager). var objectConverter = convertionManager.TryGet(typeof(string), ebProp.PropertyType); if (objectConverter == null) { dialog.AddError("No converter is registered for !"); return(false); } // if an property value is provided for the property name, try to convert it. object propValue; if (!objectConverter.TryConvert(propInput, out propValue)) { dialog.AddError("The string [] can not be converted to !"); return(false); } #region common types if (ebProp.PropertyType == typeof(Int32)) { var holder = new Int32Holder(propInput); data.AddSerializableHolder(propName, holder); continue; } if (ebProp.PropertyType == typeof(Boolean)) { var holder = new BooleanHolder(propInput); data.AddSerializableHolder(propName, holder); continue; } if (ebProp.PropertyType == typeof(Version)) { var holder = new VersionHolder(propInput); data.AddSerializableHolder(propName, holder); continue; } if (ebProp.PropertyType == typeof(DateTime)) { var holder = new DateTimeHolder(propInput); data.AddSerializableHolder(propName, holder); continue; } if (ebProp.PropertyType == typeof(Guid)) { var holder = new GuidHolder(propInput); data.AddSerializableHolder(propName, holder); continue; } if (ebProp.PropertyType == typeof(TimeSpan)) { var holder = new TimeSpanHolder(propInput); data.AddSerializableHolder(propName, holder); continue; } if (ebProp.PropertyType == typeof(Int64)) { var holder = new Int64Holder(propInput); data.AddSerializableHolder(propName, holder); continue; } if (ebProp.PropertyType == typeof(UInt64)) { var holder = new UInt64Holder(propInput); data.AddSerializableHolder(propName, holder); continue; } if (ebProp.PropertyType == typeof(UInt32)) { var holder = new UInt32Holder(propInput); data.AddSerializableHolder(propName, holder); continue; } if (ebProp.PropertyType == typeof(Int16)) { var holder = new Int16Holder(propInput); data.AddSerializableHolder(propName, holder); continue; } if (ebProp.PropertyType == typeof(UInt16)) { var holder = new UInt16Holder(propInput); data.AddSerializableHolder(propName, holder); continue; } if (ebProp.PropertyType == typeof(Byte)) { var holder = new ByteHolder(propInput); data.AddSerializableHolder(propName, holder); continue; } if (ebProp.PropertyType == typeof(SByte)) { var holder = new SByteHolder(propInput); data.AddSerializableHolder(propName, holder); continue; } if (ebProp.PropertyType == typeof(Char)) { var holder = new CharHolder(propInput); data.AddSerializableHolder(propName, holder); continue; } if (ebProp.PropertyType == typeof(Decimal)) { var holder = new DecimalHolder(propInput); data.AddSerializableHolder(propName, holder); continue; } if (ebProp.PropertyType == typeof(Double)) { var holder = new DoubleHolder(propInput); data.AddSerializableHolder(propName, holder); continue; } if (ebProp.PropertyType == typeof(Single)) { var holder = new SingleHolder(propInput); data.AddSerializableHolder(propName, holder); continue; } #endregion } return(true); }