/// <remarks>
        /// Method <c>ToString</c> generates view of pizza table.
        /// Method takes parameter <c>yournick</c> type of string which is current Name of player
        /// </remarks>
        /// <param Name="yourNick"></param>
        /// <returns>
        ///     The returned value is string representation of Pizza view.
        /// </returns>
        public string ToString(string yourNick)
        {
            StringBuilder builder = new StringBuilder();

            int entireLength = 30;

            builder.Append(new string('-', entireLength)).Append("\n");

            int spaceLength = entireLength - "|".Length - "|".Length - yourNick.Length;

            int leftSpaceLength;
            int rightSpaceLength;

            if (spaceLength % 2 == 0)
            {
                int result = spaceLength / 2;
                leftSpaceLength  = result;
                rightSpaceLength = result;
            }
            else
            {
                int result = (spaceLength - 1) / 2;
                leftSpaceLength  = result;
                rightSpaceLength = result + 1;
            }

            builder.Append("|")
            .Append(new string(' ', leftSpaceLength))
            .Append(yourNick)
            .Append(new string(' ', rightSpaceLength))
            .Append("|").Append("\n");

            builder.Append(new string('-', entireLength)).Append("\n");

            builder.Append("|").Append(new string(' ', entireLength - 2)).Append("|").Append("\n");

            ProcessFieldsToTable(entireLength, "Pizza", Name.ToString(), builder);

            builder.Append("|").Append(new string(' ', entireLength - 2)).Append("|").Append("\n");

            ProcessFieldsToTable(entireLength, "Hunger", Hunger.ToString(), builder);
            ProcessFieldsToTable(entireLength, "Sharpness", Sharpness.ToString(), builder);
            ProcessFieldsToTable(entireLength, "Flavor", Flavor.ToString(), builder);
            ProcessFieldsToTable(entireLength, "Smell", Smell.ToString(), builder);

            builder.Append("|").Append(new string(' ', entireLength - 2)).Append("|").Append("\n");

            ProcessFieldsToTable(entireLength, "Shape", Shape.ToString(), builder);

            builder.Append("|").Append(new string(' ', entireLength - 2)).Append("|").Append("\n");

            ProcessFieldsToTable(entireLength, "Score", Score.ToString(), builder);

            builder.Append("|").Append(new string(' ', entireLength - 2)).Append("|").Append("\n");
            builder.Append(new string('-', entireLength)).Append("\n");

            return(builder.ToString());
        }
Beispiel #2
0
 private void Sharpness_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         if (filteredImage.Source == null)
         {
             FillStaticProperties(originalImage, filteredImage);
             Matrix = KernelMatrix(BmpImage.Width, BmpImage.Height);
         }
         Sharpness.Filter();
     }
     catch (OriginalImageDontExistException exception)
     {
         MessageBox.Show(exception.Message);
     }
 }
        private void Btn_max_sharpness_cheat_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(targetFile))
            {
                return;
            }

            if (!targetFileType.Is(typeof(Melee),
                                   typeof(Sharpness)))
            {
                return;
            }

            foreach (var item in items)
            {
                switch (item)
                {
                case Sharpness _: {
                    Sharpness sharpness = item;
                    sharpness.Red    = 1;
                    sharpness.Orange = 1;
                    sharpness.Yellow = 1;
                    sharpness.Green  = 1;
                    sharpness.Blue   = 1;
                    sharpness.White  = 1;
                    sharpness.Purple = 400;
                    break;
                }

                case Melee _: {
                    Melee weapon = item;
                    if (weapon.Sharpness_Amount > 0)
                    {
                        weapon.Sharpness_Amount = 5;
                    }
                    break;
                }
                }
            }
        }
Beispiel #4
0
        public void WriteConfigFile(XmlTextWriter xmlWriter)
        {
            if (DeviceName.Length < 1)
            {
                DeviceName = "Settings " + DateTime.Now;
            }

            xmlWriter.WriteStartElement("CameraSettings");

            Settings.WriteElement(xmlWriter, "DeviceName", DeviceName);
            Settings.WriteElement(xmlWriter, "DeviceNumber", DeviceNumber.ToString());
            Settings.WriteElement(xmlWriter, "DeviceMode", DeviceMode.ToString());

            Settings.WriteElement(xmlWriter, "Brightness", Brightness.ToString());
            Settings.WriteElement(xmlWriter, "BrightnessAuto", BrightnessAuto.ToString());

            Settings.WriteElement(xmlWriter, "Contrast", Contrast.ToString());
            Settings.WriteElement(xmlWriter, "ContrastAuto", ContrastAuto.ToString());

            Settings.WriteElement(xmlWriter, "Saturation", Saturation.ToString());
            Settings.WriteElement(xmlWriter, "SaturationAuto", SaturationAuto.ToString());

            Settings.WriteElement(xmlWriter, "Sharpness", Sharpness.ToString());
            Settings.WriteElement(xmlWriter, "SharpnessAuto", SharpnessAuto.ToString());

            Settings.WriteElement(xmlWriter, "Zoom", Zoom.ToString());
            Settings.WriteElement(xmlWriter, "ZoomAuto", ZoomAuto.ToString());

            Settings.WriteElement(xmlWriter, "Focus", Focus.ToString());
            Settings.WriteElement(xmlWriter, "FocusAuto", FocusAuto.ToString());

            Settings.WriteElement(xmlWriter, "Exposure", Exposure.ToString());
            Settings.WriteElement(xmlWriter, "ExposureAuto", ExposureAuto.ToString());

            Settings.WriteElement(xmlWriter, "FlipImage", FlipImage.ToString());

            xmlWriter.WriteEndElement();
        }
Beispiel #5
0
        /// <summary>
        /// config the snapshot
        /// </summary>
        /// <param name="wb">WhiteBalance</param>
        /// <param name="ev">explosure value</param>
        /// <param name="contrast">Contrast</param>
        /// <param name="ce">ColorEffect</param>
        /// <param name="sharp">Sharpness</param>
        /// <returns>True if succeed</returns>
        public bool ConfigSnapshot(WhiteBalance wb, EV ev, Contrast contrast, ColorEffect ce, Sharpness sharp)
        {
            byte[] writeBuffer = new byte[5];

            writeBuffer[0] = (byte)wb;
            writeBuffer[1] = (byte)ev;
            writeBuffer[2] = (byte)contrast;
            writeBuffer[3] = (byte)ce;
            writeBuffer[4] = (byte)sharp;

            CreatCommand(5, CMD_SNAPSHOT_CONFIG);
            CreatCommand(writeBuffer);

            SendCommand(id_cmd);
            SendCommand(para_cmd);

            if (!ReceiveACK(CMD_SNAPSHOT_CONFIG, 100))
            {
                return(false);
            }

            return(true);
        }
Beispiel #6
0
        Tag CreateSpecificTag(TagInfo info, string numberValue)
        {
            try
            {
                if (info.IsGps)
                {
                    switch (info.Name.ToLower())
                    {
                    case "gpslatituderef":
                        return(new Tag <GpsLatitudeRef> {
                            TypedValue = GpsLatitudeRef.FromKey(numberValue)
                        });

                    case "gpslongituderef":
                        return(new Tag <GpsLongitudeRef> {
                            TypedValue = GpsLongitudeRef.FromKey(numberValue)
                        });

                    case "gpsaltituderef":
                        return(new Tag <GpsAltitudeRef> {
                            TypedValue = GpsAltitudeRef.FromKey(byte.Parse(numberValue))
                        });

                    case "gpsstatus":
                        return(new Tag <GpsStatus> {
                            TypedValue = GpsStatus.FromKey(numberValue)
                        });

                    case "gpsmeasuremode":
                        return(new Tag <GpsMeasureMode> {
                            TypedValue = GpsMeasureMode.FromKey(numberValue)
                        });

                    case "gpsspeedref":
                        return(new Tag <GpsSpeedRef> {
                            TypedValue = GpsSpeedRef.FromKey(numberValue)
                        });

                    case "gpstrackref":
                        return(new Tag <GpsTrackRef> {
                            TypedValue = GpsTrackRef.FromKey(numberValue)
                        });

                    case "gpsimgdirectionref":
                        return(new Tag <GpsImgDirectionRef> {
                            TypedValue = GpsImgDirectionRef.FromKey(numberValue)
                        });

                    case "gpsdestlatituderef":
                        return(new Tag <GpsDestLatitudeRef> {
                            TypedValue = GpsDestLatitudeRef.FromKey(numberValue)
                        });

                    case "gpsdestlongituderef":
                        return(new Tag <GpsDestLongitudeRef> {
                            TypedValue = GpsDestLongitudeRef.FromKey(numberValue)
                        });

                    case "gpsdestbearingref":
                        return(new Tag <GpsDestBearingRef> {
                            TypedValue = GpsDestBearingRef.FromKey(numberValue)
                        });

                    case "gpsdestdistanceref":
                        return(new Tag <GpsDestDistanceRef> {
                            TypedValue = GpsDestDistanceRef.FromKey(numberValue)
                        });

                    case "gpsdifferential":
                        return(new Tag <GpsDifferential> {
                            TypedValue = GpsDifferential.FromKey(ushort.Parse(numberValue))
                        });
                    }
                }

                if (info.IsNikon)
                {
                    switch (info.Name.ToLower())
                    {
                    case "colorspace":
                        return(new Tag <NikonColorSpace> {
                            TypedValue = NikonColorSpace.FromKey(ushort.Parse(numberValue))
                        });

                    case "vibrationreduction":
                        return(new Tag <NikonVibrationReduction> {
                            TypedValue = NikonVibrationReduction.FromKey(byte.Parse(numberValue))
                        });

                    case "vrmode":
                        return(new Tag <NikonVRMode> {
                            TypedValue = NikonVRMode.FromKey(byte.Parse(numberValue))
                        });

                    case "imageauthentication":
                        return(new Tag <NikonImageAuthentication> {
                            TypedValue = NikonImageAuthentication.FromKey(byte.Parse(numberValue))
                        });

                    case "actived-lighting":
                        return(new Tag <NikonActiveDLighting> {
                            TypedValue = NikonActiveDLighting.FromKey(ushort.Parse(numberValue))
                        });

                    case "picturecontroladjust":
                        return(new Tag <NikonPictureControlAdjust> {
                            TypedValue = NikonPictureControlAdjust.FromKey(byte.Parse(numberValue))
                        });

                    case "filtereffect":
                        return(new Tag <NikonFilterEffect> {
                            TypedValue = NikonFilterEffect.FromKey(byte.Parse(numberValue))
                        });

                    case "toningeffect":
                        return(new Tag <NikonToningEffect> {
                            TypedValue = NikonToningEffect.FromKey(byte.Parse(numberValue))
                        });

                    case "daylightsavings":
                        return(new Tag <NikonDaylightSavings> {
                            TypedValue = NikonDaylightSavings.FromKey(byte.Parse(numberValue))
                        });

                    case "datedisplayformat":
                        return(new Tag <NikonDateDisplayFormat> {
                            TypedValue = NikonDateDisplayFormat.FromKey(byte.Parse(numberValue))
                        });

                    case "isoexpansion":
                        return(new Tag <NikonIsoExpansion> {
                            TypedValue = NikonIsoExpansion.FromKey(ushort.Parse(numberValue))
                        });

                    case "isoexpansion2":
                        return(new Tag <NikonIsoExpansion2> {
                            TypedValue = NikonIsoExpansion2.FromKey(ushort.Parse(numberValue))
                        });

                    case "vignettecontrol":
                        return(new Tag <NikonVignetteControl> {
                            TypedValue = NikonVignetteControl.FromKey(ushort.Parse(numberValue))
                        });

                    case "autodistortioncontrol":
                        return(new Tag <NikonAutoDistortionControl> {
                            TypedValue = NikonAutoDistortionControl.FromKey(byte.Parse(numberValue))
                        });

                    case "hdr":
                        return(new Tag <NikonHdr> {
                            TypedValue = NikonHdr.FromKey(byte.Parse(numberValue))
                        });

                    case "hdrlevel":
                        return(new Tag <NikonHdrLevel> {
                            TypedValue = NikonHdrLevel.FromKey(byte.Parse(numberValue))
                        });

                    case "hdrsmoothing":
                        return(new Tag <NikonHdrSmoothing> {
                            TypedValue = NikonHdrSmoothing.FromKey(byte.Parse(numberValue))
                        });

                    case "hdrlevel2":
                        return(new Tag <NikonHdrLevel2> {
                            TypedValue = NikonHdrLevel2.FromKey(byte.Parse(numberValue))
                        });

                    case "textencoding":
                        return(new Tag <NikonTextEncoding> {
                            TypedValue = NikonTextEncoding.FromKey(byte.Parse(numberValue))
                        });

                    case "flashmode":
                        return(new Tag <NikonFlashMode> {
                            TypedValue = NikonFlashMode.FromKey(byte.Parse(numberValue))
                        });

                    case "afareamode":
                        return(new Tag <NikonAfAreaMode> {
                            TypedValue = NikonAfAreaMode.FromKey(byte.Parse(numberValue))
                        });

                    case "afpoint":
                        return(new Tag <NikonAfPoint> {
                            TypedValue = NikonAfPoint.FromKey(byte.Parse(numberValue))
                        });

                    case "afpointsinfocus":
                        return(new Tag <NikonAfPointsInFocus> {
                            TypedValue = NikonAfPointsInFocus.FromKey(ushort.Parse(numberValue))
                        });

                    case "nefcompression":
                        return(new Tag <NikonNefCompression> {
                            TypedValue = NikonNefCompression.FromKey(ushort.Parse(numberValue))
                        });

                    case "retouchhistory":
                        return(new Tag <NikonRetouchHistory> {
                            TypedValue = NikonRetouchHistory.FromKey(ushort.Parse(numberValue))
                        });

                    case "flashsource":
                        return(new Tag <NikonFlashSource> {
                            TypedValue = NikonFlashSource.FromKey(byte.Parse(numberValue))
                        });

                    case "flashcolorfilter":
                        return(new Tag <NikonFlashColorFilter> {
                            TypedValue = NikonFlashColorFilter.FromKey(byte.Parse(numberValue))
                        });

                    case "highisonoisereduction":
                        return(new Tag <NikonHighIsoNoiseReduction> {
                            TypedValue = NikonHighIsoNoiseReduction.FromKey(ushort.Parse(numberValue))
                        });
                    }
                }

                if (info.IsExif)
                {
                    switch (info.Name.ToLower())
                    {
                    case "interopindex":
                        return(new Tag <InteropIndex> {
                            TypedValue = InteropIndex.FromKey(numberValue)
                        });

                    case "subfiletype":
                        return(new Tag <SubfileType> {
                            TypedValue = SubfileType.FromKey(uint.Parse(numberValue))
                        });

                    case "oldsubfiletype":
                        return(new Tag <OldSubfileType> {
                            TypedValue = OldSubfileType.FromKey(ushort.Parse(numberValue))
                        });

                    case "compression":
                        return(new Tag <Compression> {
                            TypedValue = Compression.FromKey(ushort.Parse(numberValue))
                        });

                    case "photometricinterpretation":
                        return(new Tag <PhotometricInterpretation> {
                            TypedValue = PhotometricInterpretation.FromKey(ushort.Parse(numberValue))
                        });

                    case "thresholding":
                        return(new Tag <Thresholding> {
                            TypedValue = Thresholding.FromKey(ushort.Parse(numberValue))
                        });

                    case "fillorder":
                        return(new Tag <FillOrder> {
                            TypedValue = FillOrder.FromKey(ushort.Parse(numberValue))
                        });

                    case "orientation":
                        return(new Tag <Orientation> {
                            TypedValue = Orientation.FromKey(ushort.Parse(numberValue))
                        });

                    case "planarconfiguration":
                        return(new Tag <PlanarConfiguration> {
                            TypedValue = PlanarConfiguration.FromKey(ushort.Parse(numberValue))
                        });

                    case "grayresponseunit":
                        return(new Tag <GrayResponseUnit> {
                            TypedValue = GrayResponseUnit.FromKey(ushort.Parse(numberValue))
                        });

                    case "resolutionunit":
                        return(new Tag <ResolutionUnit> {
                            TypedValue = ResolutionUnit.FromKey(ushort.Parse(numberValue))
                        });

                    case "predictor":
                        return(new Tag <Predictor> {
                            TypedValue = Predictor.FromKey(ushort.Parse(numberValue))
                        });

                    case "cleanfaxdata":
                        return(new Tag <CleanFaxData> {
                            TypedValue = CleanFaxData.FromKey(ushort.Parse(numberValue))
                        });

                    case "inkset":
                        return(new Tag <InkSet> {
                            TypedValue = InkSet.FromKey(ushort.Parse(numberValue))
                        });

                    case "extrasamples":
                        return(new Tag <ExtraSamples> {
                            TypedValue = ExtraSamples.FromKey(ushort.Parse(numberValue))
                        });

                    case "sampleformat":
                        return(new Tag <SampleFormat> {
                            TypedValue = SampleFormat.FromKey(ushort.Parse(numberValue))
                        });

                    case "indexed":
                        return(new Tag <Indexed> {
                            TypedValue = Indexed.FromKey(ushort.Parse(numberValue))
                        });

                    case "opiproxy":
                        return(new Tag <OpiProxy> {
                            TypedValue = OpiProxy.FromKey(ushort.Parse(numberValue))
                        });

                    case "profiletype":
                        return(new Tag <ProfileType> {
                            TypedValue = ProfileType.FromKey(ushort.Parse(numberValue))
                        });

                    case "faxprofile":
                        return(new Tag <FaxProfile> {
                            TypedValue = FaxProfile.FromKey(ushort.Parse(numberValue))
                        });

                    case "jpegproc":
                        return(new Tag <JpegProc> {
                            TypedValue = JpegProc.FromKey(ushort.Parse(numberValue))
                        });

                    case "ycbcrsubsampling":
                        return(new Tag <YCbCrSubSampling> {
                            TypedValue = YCbCrSubSampling.FromKey(numberValue)
                        });

                    case "ycbcrpositioning":
                        return(new Tag <YCbCrPositioning> {
                            TypedValue = YCbCrPositioning.FromKey(ushort.Parse(numberValue))
                        });

                    case "sonyrawfiletype":
                        return(new Tag <SonyRawFileType> {
                            TypedValue = SonyRawFileType.FromKey(ushort.Parse(numberValue))
                        });

                    case "rasterpadding":
                        return(new Tag <RasterPadding> {
                            TypedValue = RasterPadding.FromKey(ushort.Parse(numberValue))
                        });

                    case "imagecolorindicator":
                        return(new Tag <ImageColorIndicator> {
                            TypedValue = ImageColorIndicator.FromKey(ushort.Parse(numberValue))
                        });

                    case "backgroundcolorindicator":
                        return(new Tag <BackgroundColorIndicator> {
                            TypedValue = BackgroundColorIndicator.FromKey(ushort.Parse(numberValue))
                        });

                    case "hcusage":
                        return(new Tag <HCUsage> {
                            TypedValue = HCUsage.FromKey(ushort.Parse(numberValue))
                        });

                    case "exposureprogram":
                        return(new Tag <ExposureProgram> {
                            TypedValue = ExposureProgram.FromKey(ushort.Parse(numberValue))
                        });

                    case "sensitivitytype":
                        return(new Tag <SensitivityType> {
                            TypedValue = SensitivityType.FromKey(ushort.Parse(numberValue))
                        });

                    case "componentsconfiguration":
                        return(new Tag <ComponentsConfiguration> {
                            TypedValue = ComponentsConfiguration.FromKey(ushort.Parse(numberValue))
                        });

                    case "meteringmode":
                        return(new Tag <MeteringMode> {
                            TypedValue = MeteringMode.FromKey(ushort.Parse(numberValue))
                        });

                    case "lightsource":
                    case "calibrationilluminant1":
                    case "calibrationilluminant2":
                        return(new Tag <LightSource> {
                            TypedValue = LightSource.FromKey(ushort.Parse(numberValue))
                        });

                    case "flash":
                        return(new Tag <FlashValue> {
                            TypedValue = FlashValue.FromKey(ushort.Parse(numberValue))
                        });

                    case "focalplaneresolutionunit":
                        return(new Tag <FocalPlaneResolutionUnit> {
                            TypedValue = FocalPlaneResolutionUnit.FromKey(ushort.Parse(numberValue))
                        });

                    case "securityclassification":
                        return(new Tag <SecurityClassification> {
                            TypedValue = SecurityClassification.FromKey(numberValue)
                        });

                    case "sensingmethod":
                        return(new Tag <SensingMethod> {
                            TypedValue = SensingMethod.FromKey(ushort.Parse(numberValue))
                        });

                    case "colorspace":
                        return(new Tag <ColorSpace> {
                            TypedValue = ColorSpace.FromKey(ushort.Parse(numberValue))
                        });

                    case "filesource":
                        return(new Tag <FileSource> {
                            TypedValue = FileSource.FromKey(ushort.Parse(numberValue))
                        });

                    case "scenetype":
                        return(new Tag <SceneType> {
                            TypedValue = SceneType.FromKey(ushort.Parse(numberValue))
                        });

                    case "customrendered":
                        return(new Tag <CustomRendered> {
                            TypedValue = CustomRendered.FromKey(ushort.Parse(numberValue))
                        });

                    case "exposuremode":
                        return(new Tag <ExposureMode> {
                            TypedValue = ExposureMode.FromKey(ushort.Parse(numberValue))
                        });

                    case "whitebalance":
                        return(new Tag <WhiteBalance> {
                            TypedValue = WhiteBalance.FromKey(ushort.Parse(numberValue))
                        });

                    case "scenecapturetype":
                        return(new Tag <SceneCaptureType> {
                            TypedValue = SceneCaptureType.FromKey(ushort.Parse(numberValue))
                        });

                    case "gaincontrol":
                        return(new Tag <GainControl> {
                            TypedValue = GainControl.FromKey(ushort.Parse(numberValue))
                        });

                    case "contrast":
                        return(new Tag <Contrast> {
                            TypedValue = Contrast.FromKey(ushort.Parse(numberValue))
                        });

                    case "saturation":
                        return(new Tag <Saturation> {
                            TypedValue = Saturation.FromKey(ushort.Parse(numberValue))
                        });

                    case "sharpness":
                        return(new Tag <Sharpness> {
                            TypedValue = Sharpness.FromKey(ushort.Parse(numberValue))
                        });

                    case "subjectdistancerange":
                        return(new Tag <SubjectDistanceRange> {
                            TypedValue = SubjectDistanceRange.FromKey(ushort.Parse(numberValue))
                        });

                    case "pixelformat":
                        return(new Tag <PixelFormat> {
                            TypedValue = PixelFormat.FromKey(ushort.Parse(numberValue))
                        });

                    case "transformation":
                        return(new Tag <Transformation> {
                            TypedValue = Transformation.FromKey(ushort.Parse(numberValue))
                        });

                    case "uncompressed":
                        return(new Tag <Uncompressed> {
                            TypedValue = Uncompressed.FromKey(ushort.Parse(numberValue))
                        });

                    case "imagedatadiscard":
                        return(new Tag <ImageDataDiscard> {
                            TypedValue = ImageDataDiscard.FromKey(ushort.Parse(numberValue))
                        });

                    case "alphadatadiscard":
                        return(new Tag <AlphaDataDiscard> {
                            TypedValue = AlphaDataDiscard.FromKey(ushort.Parse(numberValue))
                        });

                    case "usptooriginalcontenttype":
                        return(new Tag <USPTOOriginalContentType> {
                            TypedValue = USPTOOriginalContentType.FromKey(ushort.Parse(numberValue))
                        });

                    case "cfalayout":
                        return(new Tag <CFALayout> {
                            TypedValue = CFALayout.FromKey(ushort.Parse(numberValue))
                        });

                    case "makernotesafety":
                        return(new Tag <MakerNoteSafety> {
                            TypedValue = MakerNoteSafety.FromKey(ushort.Parse(numberValue))
                        });

                    case "profileembedpolicy":
                        return(new Tag <ProfileEmbedPolicy> {
                            TypedValue = ProfileEmbedPolicy.FromKey(ushort.Parse(numberValue))
                        });

                    case "previewcolorspace":
                        return(new Tag <PreviewColorSpace> {
                            TypedValue = PreviewColorSpace.FromKey(ushort.Parse(numberValue))
                        });

                    case "profilehuesatmapencoding":
                        return(new Tag <ProfileHueSatMapEncoding> {
                            TypedValue = ProfileHueSatMapEncoding.FromKey(ushort.Parse(numberValue))
                        });

                    case "profilelooktableencoding":
                        return(new Tag <ProfileLookTableEncoding> {
                            TypedValue = ProfileLookTableEncoding.FromKey(ushort.Parse(numberValue))
                        });

                    case "defaultblackrender":
                        return(new Tag <DefaultBlackRender> {
                            TypedValue = DefaultBlackRender.FromKey(ushort.Parse(numberValue))
                        });
                    }
                }

                // ---- VALUE TAG ----
                if (string.IsNullOrEmpty(info.ValueType))
                {
                    return(new Tag());
                }

                switch (info.ValueType.ToLower())
                {
                case "int8u":
                    return(new Tag <byte> {
                        TypedValue = byte.Parse(numberValue)
                    });

                case "int8s":
                    return(new Tag <sbyte> {
                        TypedValue = sbyte.Parse(numberValue)
                    });

                case "int16u":
                    return(new Tag <ushort> {
                        TypedValue = ushort.Parse(numberValue)
                    });

                case "int16s":
                    return(new Tag <short> {
                        TypedValue = short.Parse(numberValue)
                    });

                case "int32u":
                    return(new Tag <uint> {
                        TypedValue = uint.Parse(numberValue)
                    });

                case "integer":
                case "int32s":
                    return(new Tag <int> {
                        TypedValue = int.Parse(numberValue)
                    });

                case "int64u":
                    return(new Tag <ulong> {
                        TypedValue = ulong.Parse(numberValue)
                    });

                case "int64s":
                    return(new Tag <long> {
                        TypedValue = long.Parse(numberValue)
                    });

                case "float":
                case "rational32s":
                case "rational32u":
                    return(new Tag <float> {
                        TypedValue = float.Parse(numberValue)
                    });

                case "double":
                case "rational":
                case "rational64s":
                case "rational64u":
                case "real":
                    return(new Tag <double> {
                        TypedValue = double.Parse(numberValue)
                    });

                case "boolean":
                    return(new Tag <bool> {
                        TypedValue = bool.Parse(numberValue)
                    });
                }
            }
            catch
            {
                if (!Quiet)
                {
                    Console.WriteLine($"error converting {info.TableName}::{info.Id} with name {info.Name}.  Expected type: {info.ValueType} but got value: {numberValue}");
                }
            }

            return(new Tag());
        }
Beispiel #7
0
 public static void SetSharpness(Device devnum, Sharpness value)
 {
     throw new NotImplementedException("なにこれ");
 }
Beispiel #8
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (CameraDev.Length != 0)
            {
                hash ^= CameraDev.GetHashCode();
            }
            if (FrameId.Length != 0)
            {
                hash ^= FrameId.GetHashCode();
            }
            if (PixelFormat.Length != 0)
            {
                hash ^= PixelFormat.GetHashCode();
            }
            if (IoMethod != 0)
            {
                hash ^= IoMethod.GetHashCode();
            }
            if (Width != 0)
            {
                hash ^= Width.GetHashCode();
            }
            if (Height != 0)
            {
                hash ^= Height.GetHashCode();
            }
            if (FrameRate != 0)
            {
                hash ^= FrameRate.GetHashCode();
            }
            if (Monochrome != false)
            {
                hash ^= Monochrome.GetHashCode();
            }
            if (Brightness != 0)
            {
                hash ^= Brightness.GetHashCode();
            }
            if (Contrast != 0)
            {
                hash ^= Contrast.GetHashCode();
            }
            if (Saturation != 0)
            {
                hash ^= Saturation.GetHashCode();
            }
            if (Sharpness != 0)
            {
                hash ^= Sharpness.GetHashCode();
            }
            if (Gain != 0)
            {
                hash ^= Gain.GetHashCode();
            }
            if (AutoFocus != false)
            {
                hash ^= AutoFocus.GetHashCode();
            }
            if (Focus != 0)
            {
                hash ^= Focus.GetHashCode();
            }
            if (AutoExposure != false)
            {
                hash ^= AutoExposure.GetHashCode();
            }
            if (Exposure != 0)
            {
                hash ^= Exposure.GetHashCode();
            }
            if (AutoWhiteBalance != false)
            {
                hash ^= AutoWhiteBalance.GetHashCode();
            }
            if (WhiteBalance != 0)
            {
                hash ^= WhiteBalance.GetHashCode();
            }
            if (BytesPerPixel != 0)
            {
                hash ^= BytesPerPixel.GetHashCode();
            }
            if (TriggerInternal != 0)
            {
                hash ^= TriggerInternal.GetHashCode();
            }
            if (TriggerFps != 0)
            {
                hash ^= TriggerFps.GetHashCode();
            }
            if (ChannelName.Length != 0)
            {
                hash ^= ChannelName.GetHashCode();
            }
            if (DeviceWaitMs != 0)
            {
                hash ^= DeviceWaitMs.GetHashCode();
            }
            if (SpinRate != 0)
            {
                hash ^= SpinRate.GetHashCode();
            }
            if (OutputType != 0)
            {
                hash ^= OutputType.GetHashCode();
            }
            if (compressConf_ != null)
            {
                hash ^= CompressConf.GetHashCode();
            }
            return(hash);
        }
        private string ParseImpl(string text)
        {
            text = ReplaceDefineStatements(text);

            var guids = new Dictionary<string, string>();

            text = Regex.Replace(text, @"\[[a-zA-Z_]*?\s*[a-zA-Z_]*?\s*]", match =>
            {
                string g = "_" + Guid.NewGuid().ToString().Replace("-", "") + "_";
                guids.Add(g, match.Value);
                return g;
            });

            text = text.Replace("[NSNull null]", "null");

            MethodSignatures(ref text);
            MethodInvocations(ref text);
            UIColorManipulations(ref text);

            foreach (string key in guids.Keys)
                text = text.Replace(key, guids[key]);

            MethodInvocations(ref text);

            text = text.Replace("NSString", "string");
            
            // CGRectInset(allRect, 2.0f, 2.0f); -> allRect.Inset(2.0f, 2.0f);
            SmartReplace(ref text, @"CGRectInset\(<varNum1>,", "$1.Inset(");

            // [keyPath isEqualToString:@"labelText"] -> keyPath == "labelText"
            SmartReplace(ref text, @"\[<var1> isEqualToString:@\""<var2>\""\]", @"$1 == ""$2""");

            // [label.Text sizeWithFont:label.Font] -> new NSString(label.Text).StringSize(label.Font)
            text = Regex.Replace(text, @"\[([_a-zA-Z\.]*?)\s*sizeWithFont:([_a-zA-Z\.]*?)\]", "new NSString($1).StringSize($2)");

            SmartReplace(ref text, @"\[\[UILabel  alloc\] init\]", "new UILabel()");
            text = Regex.Replace(text, @"\[\[UILabel alloc\] initWithFrame:([\._a-zA-Z]*?)\]", "new UILabel($1)");

            // UIFont
            SmartReplace(ref text, @"\[ UIFont  boldSystemFontOfSize : <varNum1> \]", "UIFont.BoldSystemFontOfSize($1)");
            SmartReplace(ref text, @"\[ UIFont  systemFontOfSize : <varNum1> \]", "UIFont.SystemFontOfSize($1)");

            //UIImageView *iv = [[UIImageView alloc] initWithFrame:CGRectMake(0,0, NOB_SIZE, NOB_SIZE)];
            //SmartReplace(ref text, @"UIImageView  \*<var1> = \[\[ UIImageView  alloc \]  initWithFrame : ([^\]]*?) \];", "UIImageView $1 = new UIImageView($2);");

            // UILabel *label; -- remove stars
            SmartReplace(ref text, @"^( <var> )\*(<var>; )$", "$1$2", RegexOptions.Multiline);
            SmartReplace(ref text, @"^( <var> )\*(<var> = .*? ;)$", "$1$2", RegexOptions.Multiline);

            var wordReplacements = new Dictionary<string, string> {
                { "nil", "null" },
                { "self", "this" },
                { "super", "base" },
                { "YES", "true" },
                { "NO", "false" },
                { "BOOL", "bool" },
                { "NSInteger", "int" },
                { "NSNumber", "float" },
                { "NSURL", "NSUrl" },
                { "colorWithWhite", "FromWhiteAlpha" },
                { "NSMakeRange", "new NSRange" },
                { "rintf", "Math.Round" },
                { "UIInterfaceOrientationPortraitUpsideDown", "UIInterfaceOrientation.PortraitUpsideDown" }, 
                { "UIInterfaceOrientationPortrait", "UIInterfaceOrientation.Portrait" }, 
                { "UIInterfaceOrientationLandscapeLeft", "UIInterfaceOrientation.LandscapeLeft" }, 
                { "UIInterfaceOrientationLandscapeRight", "UIInterfaceOrientation.LandscapeRight" }, 
                { "UIInterfaceOrientationIsLandscape", "UIInterfaceOrientation.IsLandscape" }, 
                { "UIInterfaceOrientationIsPortrait", "UIInterfaceOrientation.IsPortrait" }, 
            };

            foreach (string key in wordReplacements.Keys)
                text = Regex.Replace(text, @"\b" + key + @"\b", wordReplacements[key]);

            var capitalizeKeywords = new[] { 
                "setNeedsDisplay",
                "viewDidLoad",
                "canSendMail",
                "dequeueReusableHeaderFooterViewWithIdentifier",
                "deselectRowAtIndexPath",
                "viewWillAppear",
                "numberOfSectionsInTableView",
                "addSubview",
                "removeFromSuperview",
                "setNeedsLayout",
                "addGestureRecognizer",
                "anyObject",
                "layoutSubviews",
                "setStroke",
                "setFill",
                "stroke",
                "sizeToFit",
                "lineWidth",
                "lineCapStyle",
                "frame",
                "bounds",
                "layer",
                "shadowOpacity",
                "shadowOffset",
                "shadowColor",
                "shadowRadius",
                "shadowPath"
            };

            foreach (string prop in capitalizeKeywords)
                text = text.Replace("." + prop, "." + prop[0].ToString().ToUpperInvariant() + prop.Substring(1));

            SmartReplace(ref text, @"^@property (\([^)]*?\)) <var1> \*?([^\*]*?);$", "public $2 $3;", RegexOptions.Multiline);

            text = Regex.Replace(text, @"/\*[\w\W]*?\*/", "");

            text = Regex.Replace(text, "^@implementation(.*?)$", "public class$1", RegexOptions.Multiline);
            text = text.Replace("@end", "}");
            text = Regex.Replace(text, @"\(CGPoint\)\d*?{([\w\W]*?)}", "new PointF($1)");
            text = Regex.Replace(text, @"\(CGRect\)\d*?{([\w\W]*?)}", "new RectangleF($1)");

            text = Regex.Replace(text, @"CGRectGetMinX\((.*?)\)", "$1.GetMinX()");
            text = Regex.Replace(text, @"CGRectGetMaxX\((.*?)\)", "$1.GetMaxX()");
            text = Regex.Replace(text, @"CGRectGetMinY\((.*?)\)", "$1.GetMinY()");
            text = Regex.Replace(text, @"CGRectGetMaxY\((.*?)\)", "$1.GetMaxY()");
            text = Regex.Replace(text, @"CGRectGetMidX\((.*?)\)", "$1.GetMidX()");
            text = Regex.Replace(text, @"CGRectGetMidY\((.*?)\)", "$1.GetMidY()");
            text = Regex.Replace(text, @"CGRectGetHeight\((.*?)\)", "$1.Height");

            text = Regex.Replace(text, @"isKindOfClass:\[(.*?) class\]", "is $1");

            text = Regex.Replace(text, @"^(\s*?)CGPathMoveToPoint\(([^,]*?),(.*?);$", "$1$2.MoveToPoint($3;", RegexOptions.Multiline);
            text = Regex.Replace(text, @"^(\s*?)CGPathAddArcToPoint\(([^,]*?),(.*?);$", "$1$2.AddArcToPoint($3;", RegexOptions.Multiline);
            text = Regex.Replace(text, @"^(\s*?)CGPathAddLineToPoint\(([^,]*?),(.*?);$", "$1$2.AddLineToPoint($3;", RegexOptions.Multiline);
            text = Regex.Replace(text, @"CGPathCloseSubpath\(([^\)]*?)\);", "$1.CloseSubpath();");
            text = Regex.Replace(text, @"CGContextAddPath\(([^,]*?),", "$1.AddPath(");
            text = Regex.Replace(text, @"CGContextAddRect\(([^,]*?),", "$1.AddRect(");
            text = Regex.Replace(text, @"CGContextSetRGBFillColor\(([^,]*?),", "$1.SetRGBFillColor(");
            text = Regex.Replace(text, @"CGContextDrawLinearGradient\s?\(([^,]*?),", "$1.DrawLinearGradient(");
            text = Regex.Replace(text, @"CGContextDrawRadialGradient\s?\(([^,]*?),", "$1.DrawRadialGradient(");
            text = Regex.Replace(text, @"CGContextSetLineWidth\s?\(([^,]*?),", "$1.SetLineWidth(");
            text = Regex.Replace(text, @"CGContextFillEllipseInRect\s?\(([^,]*?),", "$1.FillEllipseInRect(");
            text = Regex.Replace(text, @"CGContextStrokeEllipseInRect\s?\(([^,]*?),", "$1.StrokeEllipseInRect(");
            text = Regex.Replace(text, @"CGContextMoveToPoint\s?\(([^,]*?),", "$1.MoveToPoint(");
            text = Regex.Replace(text, @"CGContextAddArcToPoint\s?\(([^,]*?),", "$1.AddArcToPoint(");
            text = Regex.Replace(text, @"CGContextDrawPath\s?\(([^,]*?),", "$1.DrawPath(");
            text = Regex.Replace(text, @"CGContextAddArc\s?\(([^,]*?),", "$1.AddArc(");
            text = Regex.Replace(text, @"CGContextSetFillColorWithColor\s?\(([^,]*?),", "$1.SetFillColorWithColor(");
            text = Regex.Replace(text, @"CGContextSetGrayFillColor\s?\(([^,]*?),", "$1.SetGrayFillColor(");


            text = Regex.Replace(text, @"CGContextFillPath\(([^\)]*?)\);", "$1.FillPath();");
            text = Regex.Replace(text, @"CGContextClosePath\(([^\)]*?)\);", "$1.ClosePath();");
            text = Regex.Replace(text, @"CGContextSaveGState\(([^\)]*?)\);", "$1.SaveState();");
            text = Regex.Replace(text, @"CGContextRestoreGState\(([^\)]*?)\);", "$1.RestoreState();");
            text = Regex.Replace(text, @"CGContextClip\(([^\)]*?)\);", "$1.Clip();");
            text = Regex.Replace(text, @"(CGPathRelease|CGGradientRelease|CGColorSpaceRelease)\(([^\)]*?)\);", "$2.Dispose();");
            text = Regex.Replace(text, @"UIGraphicsPushContext\(([^\)]*?)\);", "$1.Push();");

            text = Regex.Replace(text, "^//.*?$", "", RegexOptions.Multiline);
            text = Regex.Replace(text, "^(@interface|#import).*?$", "", RegexOptions.Multiline);
            text = text.Trim();
            text = Regex.Replace(text, "\n{3,}", "\n\n");
            text = text
                .Replace("roundf", "Math.Round")
                .Replace("PointFZero", "PointF.Empty")
                .Replace("CGSizeZero", "SizeF.Empty")
                .Replace("CGPointMake", "new PointF")
                .Replace("CGRectMake", "new RectangleF")
                .Replace("UIEdgeInsetsMake", "new UIEdgeInsets")
                .Replace(" isNavigationBarHidden", "NavigationBarHidden")
                .Replace(" navigationBar", ".NavigationBar")
                .Replace("[UIApplication sharedApplication]", "UIApplication.SharedApplication")
                .Replace(" statusBarOrientation", ".StatusBarOrientation")
                .Replace(".statusBarOrientation", ".StatusBarOrientation")
                .Replace("this.superview", "this.Superview")
                .Replace(" setText:", ".Text = ")
                .Replace(".boldSystemFontOfSize", ".BoldSystemFontOfSize")
                .Replace(".systemFontOfSize", ".SystemFontOfSize")
                .Replace("UIControlStateNormal", "UIControlState.Normal")
                .Replace(" setBackgroundImage:", ".SetBackgroundImage(")
                .Replace(" setTitle:", ".SetTitle(")
                .Replace(" setTitleColor:", ".SetTitleColor(")
                .Replace(" setTextColor:", ".TextColor = ")
                //.Replace(" setBackgroundColor:", ".BackgroundColor = ")
                .Replace(".contentEdgeInsets", ".ContentEdgeInsets")
                .Replace("[[UIView alloc] initWithFrame:", "new UIView(")
                .Replace("[UIScreen mainScreen]", "UIScreen.MainScreen")
                .Replace("UISwipeGestureRecognizerDirectionUp", "UISwipeGestureRecognizerDirection.Up")
                .Replace("UISwipeGestureRecognizerDirectionDown", "UISwipeGestureRecognizerDirection.Down")
                .Replace("UISwipeGestureRecognizerDirectionLeft", "UISwipeGestureRecognizerDirection.Left")
                .Replace("UISwipeGestureRecognizerDirectionRight", "UISwipeGestureRecognizerDirection.Right")
                .Replace("NSTextAlignmentCenter", "NSTextAlignment.Center")
                .Replace(" setFont:", ".Font = ")
                .Replace(" setShadowColor:", ".ShadowColor = ")
                .Replace(" setShadowOffset:", ".ShadowOffset = ")
                .Replace(".numberOfLines", ".Lines")
                .Replace(".lineBreakMode", ".LineBreakMode")
                .Replace("NSLineBreakByWordWrapping", "UILineBreakMode.WordWrap")
                .Replace("UIGraphicsBeginImageContextWithOptions", "UIGraphics.BeginImageContextWithOptions")
                .Replace("UIGraphicsEndImageContext", "UIGraphics.EndImageContext")
                .Replace("UIGraphicsGetImageFromCurrentImageContext", "UIGraphics.GetImageFromCurrentImageContext")
                .Replace("UIGraphicsGetCurrentContext", "UIGraphics.GetCurrentContext")
                .Replace("CGContextRef", "CGContext")
                .Replace("CGPathCreateMutable()", "new CGPath()")
                .Replace("CGMutablePathRef", "CGPath")
                .Replace("kCGGradientDrawsAfterEndLocation", "CGGradientDrawingOptions.DrawsAfterEndLocation")
                .Replace("kCGGradientDrawsBeforeStartLocation", "CGGradientDrawingOptions.DrawsBeforeStartLocation")
                .Replace("NULL", "null")
                .Replace(".statusBarFrame", ".StatusBarFrame")
                .Replace("UIViewAutoresizingFlexibleWidth", "UIViewAutoresizing.FlexibleWidth")
                .Replace("UIViewAutoresizingFlexibleHeight", "UIViewAutoresizing.FlexibleHeight")
                .Replace("UIViewAutoresizingFlexibleTopMargin", "UIViewAutoresizing.FlexibleTopMargin")
                .Replace("UIViewAutoresizingFlexibleBottomMargin", "UIViewAutoresizing.FlexibleBottomMargin")
                .Replace("UIViewAutoresizingFlexibleLeftMargin", "UIViewAutoresizing.FlexibleLeftMargin")
                .Replace("UIViewAutoresizingFlexibleRightMargin", "UIViewAutoresizing.FlexibleRightMargin")
                .Replace("CGAffineTransformIdentity", "CGAffineTransform.MakeIdentity")
                .Replace("CGAffineTransformIdentity", "CGAffineTransform.MakeIdentity")
                .Replace("CGAffineTransformScale", "CGAffineTransform.Scale")
                .Replace("CGAffineTransformMakeRotation", "CGAffineTransform.MakeRotation")
                .Replace("[UIImage imageNamed:", "UIImage.FromName(")
                .Replace("[[UIImageView alloc] initWithImage:", "new UIImageView(")
                .Replace(" objectAtIndex:", "[")
                .Replace("[[NSBundle mainBundle] resourcePath]", "NSBundle.MainBundle.ResourcePath")
                .Replace(".viewController", ".ViewController")
                .Replace("completion:^", ", delegate")
                .Replace("[UIView animateWithDuration:", "UIView.Animate(")
                .Replace("animations:^", ", delegate {")
                .Replace(".center", ".Center")
                .Replace("[UIButton buttonWithType:UIButtonTypeCustom]", "UIButton.FromType(UIButtonType.Custom)")
                .Replace(".tag", ".Tag")
                .Replace(".clipsToBounds", ".ClipsToBounds")
                .Replace(".contentMode", ".ContentMode")
                .Replace(".text", ".Text")
                .Replace(".font", ".Font")
                .Replace(".enabled", ".Enabled")
                .Replace("CGRectZero", "RectangleF.Empty")
                .Replace("UIViewAutoresizingNone", "UIViewAutoresizing.None")
                .Replace("NSUInteger", "int")
                .Replace(" removeFromSuperview", ".RemoveFromSuperview")
                .Replace("MAX(", "Math.Max(")
                .Replace("MIN(", "Math.Min(")
                .Replace("M_PI", "Math.PI")
                .Replace("CGColorSpaceRef", "CGColorSpace")
                .Replace("CGColorSpaceCreateDeviceRGB", "CGColorSpace.CreateDeviceRGB")
                .Replace("CGGradientRef", "CGGradient")
                .Replace("CGGradientCreateWithColorComponents", "new CGGradient")
                .Replace(".autoresizingMask", ".AutoresizingMask")
                .Replace(".backgroundColor", ".BackgroundColor")
                .Replace(".opaque", ".Opaque")
                .Replace(".image.size", ".Image.Size")
                .Replace("CGFloat", "float")
                .Replace(".size.width", ".Width")
                .Replace(".size.height", ".Height")
                .Replace(".width", ".Width")
                .Replace(".height", ".Height")
                .Replace(".origin.x", ".X")
                .Replace(".origin.y", ".Y")
                .Replace(".x", ".X")
                .Replace(".y", ".Y")
                .Replace("CGSizeMake", "new SizeF")
                .Replace("CGSize", "SizeF")
                .Replace("CGRect", "RectangleF")
                .Replace("CGPoint", "PointF")
                .Replace(".alpha", ".Alpha")
                ;

            return text;
        }