public static void Export(IION ion, GaugeDeviceCalibrationCertificate certificate, Stream outStream)
        {
            var pdf = new PdfFixedDocument(EmbeddedResource.Load("digital_gauge_cert.pdf"));

            // Header
            (pdf.Form.Fields[FIELD_CERT_BY] as PdfTextBoxField).Value   = certificate.certifiedBy;
            (pdf.Form.Fields[FIELD_CERT_DATE] as PdfTextBoxField).Value = certificate.lastTestCalibrationDate.ToString("d");
            // Unit Tested
            (pdf.Form.Fields[FIELD_PART_NO] as PdfTextBoxField).Text   = certificate.testPartNumber;
            (pdf.Form.Fields[FIELD_SERIAL_NO] as PdfTextBoxField).Text = certificate.testSerialNumber + "";
            // Calibration Standard
            (pdf.Form.Fields[FIELD_CAL_MODEL] as PdfTextBoxField).Text     = certificate.controlInstrument;
            (pdf.Form.Fields[FIELD_CAL_SERIAL_NO] as PdfTextBoxField).Text = certificate.controlSerial;
//      (pdf.Form.Fields[KEY_CONTROL_TRANSDUCER] as PdfTextBoxField).Text = certificate.controlTransducer;
            (pdf.Form.Fields[FIELD_CAL_ACCURACY] as PdfTextBoxField).Text = certificate.controlAccuracy + "";
            (pdf.Form.Fields[FIELD_CAL_DATE] as PdfTextBoxField).Text     = certificate.lastControlCalibrationDate.ToString("d");
            // Ambient Conditions
            (pdf.Form.Fields[FIELD_AMB_TEMP] as PdfTextBoxField).Text = certificate.environmentTemperature + "";
            (pdf.Form.Fields[FIELD_AMB_RH] as PdfTextBoxField).Text   = certificate.environmentHumidity + "";

            // Performance Data Table
            (pdf.Form.Fields[FIELD_CAL_LIMIT] as PdfTextBoxField).Text = certificate.testAccuracy + "";
            foreach (var pair in TABLE_KEYS)
            {
                var data = certificate.calibrationDataPoints[pair.second];
                for (int i = 0; i < data.Length; i++)
                {
                    (pdf.Form.Fields[pair.first + (i + 1)] as PdfTextBoxField).Text = data[i];
                }
            }

            pdf.Form.FlattenFields();
            pdf.Save(outStream);
        }
        // Implemented from IFluidManager
        public async Task <Fluid> LoadFluidAsync(string fluidName)
        {
            Fluid ret = null;

            if (__cache.ContainsKey(fluidName))
            {
                var reference = __cache[fluidName];
                if (!reference.IsAlive)
                {
                    __cache.Remove(fluidName);
                }
                else
                {
                    ret = reference.Target as Fluid;
                }
            }

            if (ret == null && HasFluid(fluidName))
            {
                ret        = new BinaryFluidParser().ParseFluid(EmbeddedResource.Load(fluidName + EXT_FLUID));
                ret.color  = GetFluidColor(ret.name);
                ret.safety = GetFluidSafety(ret.name);
                __cache.Add(fluidName, new WeakReference(ret));
                return(ret);
            }
            else
            {
                return(ret);
            }
        }
예제 #3
0
 public void Run()
 {
     Manager.Initialize();
     if (Plugin.Instance.Configuration.Enabled && Plugin.Instance.Configuration.ValidSetup)
     {
         var key = EmbeddedResource.Load("MediaBrowser.Plugins.Spotify.Embedded.spotify_appkey.key");
         Manager.Login(key, Plugin.Instance.Configuration.UserName, Plugin.Instance.Configuration.Password);
     }
 }
예제 #4
0
파일: Asset.cs 프로젝트: zxc120/GARbro
        internal static byte[] LoadResource(string name)
        {
            var res = EmbeddedResource.Load(name, typeof(TypeTree));

            if (null == res)
            {
                throw new FileNotFoundException("Resource not found.", name);
            }
            return(res);
        }
예제 #5
0
        /// <summary>
        /// Performs all of the upgrades necessary for the database.
        /// </summary>
        private async void PerformUpgrade()
        {
            var sr    = new StreamReader(EmbeddedResource.Load(UPGRADE_DATABASE));
            var query = await sr.ReadToEndAsync();

            try {
                Execute(query);
            } catch (Exception e) {
                Log.E(this, "Failed to upgrade database.", e);
            }
        }
예제 #6
0
파일: ArcVAFS.cs 프로젝트: zxc120/GARbro
        static short[] LoadWaveTable(string name)
        {
            var src = EmbeddedResource.Load(name, typeof(VafsOpener));

            if (null == src)
            {
                return(null);
            }
            var array = new short[src.Length / 2];

            Buffer.BlockCopy(src, 0, array, 0, src.Length);
            return(array);
        }
        // Overridden from IDeviceManager
        public Task <InitializationResult> InitAsync()
        {
            deviceFactory = DeviceFactory.CreateFromStream(EmbeddedResource.Load(DEVICES_XML));

            if (deviceFactory == null)
            {
                return(Task.FromResult(new InitializationResult()
                {
                    success = false,
                    errorMessage = "Failed to init device manager: could not load device's database."
                }));
            }

            return(Task.FromResult(new InitializationResult()
            {
                success = __isInitialized = true
            }));
        }
        // Overridden from IFluidManager
        public async Task <InitializationResult> InitAsync()
        {
            try {
                var dir        = ion.fileManager.GetApplicationInternalDirectory();
                var propStream = EmbeddedResource.Load(FLUID_COLORS_FILE);
                fluidColors = await Properties.FromStreamAsync(propStream);

                var fsStream = EmbeddedResource.Load(FLUID_SAFETY_FILE);
                fluidSafety = await Properties.FromStreamAsync(fsStream);

                var favoriteFluids = ion.preferences.fluid.favorites;
                if (favoriteFluids == null)
                {
                    ion.preferences.fluid.favorites = favoriteFluids = DEFAULT_FLUIDS;
                }

                __preferredFluids = new HashSet <string>(favoriteFluids);

                var fluidName = ion.preferences.fluid.preferredFluid;
                if (fluidName == null)
                {
                    fluidName = DEFAULT_FLUID;
                }

                await GetFluidAsync(fluidName);

                return(new InitializationResult()
                {
                    success = __isInitialized = true
                });
            } catch (Exception e) {
                Log.E(this, "Failed to init " + this, e);
                return(new InitializationResult()
                {
                    success = __isInitialized = false,
                    errorMessage = "Failed to initialize fluid manager: " + e.Message
                });
            }
        }
예제 #9
0
        // Implemented from IDeviceManager
        public Task <InitializationResult> InitAsync()
        {
            Log.D(this, "loading the base device manager");
            try {
                deviceFactory = DeviceFactory.CreateFromStream(EmbeddedResource.Load(DEVICES_XML));
            } catch (Exception e) {
                Log.E(this, "Failed from device factor", e);
            }
            Log.D(this, "device factory set");
            if (deviceFactory == null)
            {
                return(Task.FromResult(new InitializationResult()
                {
                    success = false,
                    errorMessage = "Failed to init device manager: could not load device database.",
                }));
            }

            return(Task.FromResult(new InitializationResult()
            {
                success = true
            }));
        }
        // Overridden from IDeviceManager
        public async Task <InitializationResult> InitAsync()
        {
            try {
                deviceFactory = DeviceFactory.CreateFromStream(EmbeddedResource.Load(DEVICES_XML));
            } catch (Exception e) {
                Log.E(this, "Failed from device factor", e);
            }
            if (deviceFactory == null)
            {
                return(new InitializationResult()
                {
                    success = false,
                    errorMessage = "Failed to init device manager: could not load device database."
                });
            }

            try {
                var devices = await ion.database.QueryForAllDevicesAsync();

                foreach (IDevice device in devices)
                {
                    try {
                        Register(device);
                    } catch (Exception ee) {
                        Log.E(this, "Failed to register device", ee);
                    }
                }
            } catch (Exception e) {
                Log.E(this, "Failed to load previous devices", e);
            }

            return(new InitializationResult()
            {
                success = __isInitialized = true
            });
        }
        private bool BuildTest(List <ISerialNumber> serialNumbers)
        {
            var address = Intent.GetStringExtra(EXTRA_RIG_ADDRESS);
            var type    = (EDeviceModel)Intent.GetIntExtra(EXTRA_TEST_TYPE, -1);

            service = AppService.INSTANCE;
            var rig = service.GetRigByAddress(address);

            if (rig == null)
            {
                var adb = new AlertDialog.Builder(this);
                adb.SetTitle("Initialization Error");
                adb.SetMessage("Failed to find Rig.");
                adb.SetCancelable(false);
                adb.SetNegativeButton("Then how did I get here? Ok, take me back...", (sender, e) => {
                    Finish();
                });
                adb.Show();
                return(false);
            }
            else if (rig.rigType != type.AsRigType())
            {
                var adb = new AlertDialog.Builder(this);
                adb.SetTitle("Initialization Error");
                adb.SetMessage("Received a Rig of type: " + rig.rigType + ". A rig of this type is incompatible with a test designed for " + type);
                adb.SetCancelable(false);
                adb.SetNegativeButton("This app just refuses to work. Ok, take me back...", (sender, e) => {
                    Finish();
                });
                adb.Show();
                return(false);
            }
            else
            {
                var connections = new List <IConnection>();

                foreach (var serialNumber in serialNumbers)
                {
                    // TODO [email protected]: This is bad
                    var connection = service.GetConnection(serialNumber);
                    if (connection != null)
                    {
                        connections.Add(connection);
                    }
                }

                var tp = new XmlTestParser().Parse(EmbeddedResource.Load(typeof(TestActivity).GetTypeInfo().Assembly, "test_av760.xml"));
                switch (rig.rigType)
                {
                case ERigType.Vacuum:
                    test = new AV760Test(tp, rig as VacuumRig, connections);
                    break;

                default:
                    var adb = new AlertDialog.Builder(this);
                    adb.SetTitle("Initialization Error");
                    adb.SetMessage("Failed to build test");
                    adb.SetCancelable(false);
                    adb.SetNegativeButton("Wai?! Ok, take me back...", (sender, e) => {
                        Finish();
                    });
                    adb.Show();
                    return(false);
                }

                service.currentTest = test;
                test.onTestEvent   += OnTestEvent;
                return(true);
            }
        }
예제 #12
0
파일: ImageI.cs 프로젝트: zxc120/GARbro
 static byte[] LoadResource(string name)
 {
     return(EmbeddedResource.Load(name, typeof(Img2Reader)));
 }