Example #1
0
 public VideoOptions(ImageAspectRatio aspect, ImageRotation rotation, Demosaicing demosaicing, bool deinterlace)
 {
     ImageAspectRatio = aspect;
     ImageRotation    = rotation;
     Demosaicing      = demosaicing;
     Deinterlace      = deinterlace;
 }
Example #2
0
        private void SetAspectRatio(ImageAspectRatio _aspectRatio, Size _size)
        {
            m_AspectRatio = _aspectRatio;

            if (m_FrameGrabber.IsConnected)
            {
                int newHeight;

                switch (_aspectRatio)
                {
                case ImageAspectRatio.Auto:
                default:
                    newHeight = _size.Height;
                    break;

                case ImageAspectRatio.Force43:
                    newHeight = (_size.Width / 4) * 3;
                    break;

                case ImageAspectRatio.Force169:
                    newHeight = (_size.Width / 16) * 9;
                    break;
                }

                m_ImageSize = new Size(_size.Width, newHeight);
                transformDisplay.SetOriginalSize(m_ImageSize);
                transformRecord.SetOriginalSize(m_ImageSize);
                m_Container.DoInitDecodingSize();
                m_Metadata.ImageSize = m_ImageSize;
                m_FrameBuffer.UpdateFrameSize(m_ImageSize);
            }
        }
Example #3
0
        public FrameServerCapture()
        {
            m_FrameGrabber = new FrameGrabberAForge(this, m_FrameBuffer);
            m_AspectRatio  = PreferencesManager.PlayerPreferences.AspectRatio;

            IntPtr forceHandleCreation = m_DummyControl.Handle;             // Needed to show that the main thread "owns" this Control.

            m_EventFrameGrabbed = FrameGrabbed_Invoked;
        }
        private void ImportPreferences()
        {
            CultureInfo ci = m_prefManager.GetSupportedCulture();

            m_UICultureName    = ci.IsNeutralCulture ? ci.Name : ci.Parent.Name;
            m_iFilesToSave     = m_prefManager.HistoryCount;
            m_TimeCodeFormat   = m_prefManager.TimeCodeFormat;
            m_ImageAspectRatio = m_prefManager.AspectRatio;
            m_SpeedUnit        = m_prefManager.SpeedUnit;
        }
Example #5
0
        private CaptureAspectRatio Convert(ImageAspectRatio aspectRatio)
        {
            switch (aspectRatio)
            {
            case ImageAspectRatio.Auto: return(CaptureAspectRatio.Auto);

            case ImageAspectRatio.Force43: return(CaptureAspectRatio.Force43);

            case ImageAspectRatio.Force169: return(CaptureAspectRatio.Force169);

            default: return(CaptureAspectRatio.Auto);
            }
        }
Example #6
0
        private void ChangeAspectRatio(ImageAspectRatio aspectRatio)
        {
            CaptureAspectRatio ratio = Convert(aspectRatio);

            if (ratio == cameraSummary.AspectRatio)
            {
                return;
            }

            cameraSummary.UpdateAspectRatio(ratio);
            cameraSummary.UpdateDisplayRectangle(Rectangle.Empty);

            // update display rectangle.
            Disconnect();
            Connect();
        }
Example #7
0
        private void ImportPreferences()
        {
            // Put the values in the current pref file into local variables
            // They will then be used to fill the controls.

            m_iFilesToSave          = m_prefManager.HistoryCount;
            m_UICultureName         = m_prefManager.GetSupportedCulture().Name;
            m_TimeCodeFormat        = m_prefManager.TimeCodeFormat;
            m_SpeedUnit             = m_prefManager.SpeedUnit;
            m_ImageAspectRatio      = m_prefManager.AspectRatio;
            m_bDeinterlaceByDefault = m_prefManager.DeinterlaceByDefault;
            m_GridColor             = m_prefManager.GridColor;
            m_Plane3DColor          = m_prefManager.Plane3DColor;
            m_iWorkingZoneSeconds   = m_prefManager.WorkingZoneSeconds;
            m_iWorkingZoneMemory    = m_prefManager.WorkingZoneMemory;
            m_DefaultFading         = new InfosFading(0, 0);
            m_bDrawOnPlay           = m_prefManager.DrawOnPlay;
        }
        private void ImportPreferences()
        {
            deinterlaceByDefault    = PreferencesManager.PlayerPreferences.DeinterlaceByDefault;
            interactiveFrameTracker = PreferencesManager.PlayerPreferences.InteractiveFrameTracker;
            timecodeFormat          = PreferencesManager.PlayerPreferences.TimecodeFormat;
            imageAspectRatio        = PreferencesManager.PlayerPreferences.AspectRatio;
            speedUnit                = PreferencesManager.PlayerPreferences.SpeedUnit;
            accelerationUnit         = PreferencesManager.PlayerPreferences.AccelerationUnit;
            angleUnit                = PreferencesManager.PlayerPreferences.AngleUnit;
            angularVelocityUnit      = PreferencesManager.PlayerPreferences.AngularVelocityUnit;
            angularAccelerationUnit  = PreferencesManager.PlayerPreferences.AngularAccelerationUnit;
            customLengthUnit         = PreferencesManager.PlayerPreferences.CustomLengthUnit;
            customLengthAbbreviation = PreferencesManager.PlayerPreferences.CustomLengthAbbreviation;

            syncLockSpeeds = PreferencesManager.PlayerPreferences.SyncLockSpeed;

            workingZoneSeconds = PreferencesManager.PlayerPreferences.WorkingZoneSeconds;
            workingZoneMemory  = PreferencesManager.PlayerPreferences.WorkingZoneMemory;
        }
 private void cmbImageAspectRatio_SelectedIndexChanged(object sender, EventArgs e)
 {
     imageAspectRatio = (ImageAspectRatio)cmbImageFormats.SelectedIndex;
 }
 /// <summary>
 /// Force a specific aspect ratio.
 /// </summary>
 /// <returns>returns true if the cache has been invalidated by the operation</returns>
 public virtual bool ChangeAspectRatio(ImageAspectRatio ratio)
 {
     // Does nothing by default. Override to implement.
     return(false);
 }
 private void cmbImageAspectRatio_SelectedIndexChanged(object sender, EventArgs e)
 {
     // the combo box items have been filled in the order of the enum.
     m_ImageAspectRatio = (ImageAspectRatio)cmbImageFormats.SelectedIndex;
 }
 public ImageAspectRatioNotSupportedException(ImageAspectRatio ratio)
     : base($"Invalid image aspect ratio: {ratio.ToString()}")
 {
 }
Example #13
0
        /// <summary>
        /// Initializes a new <see cref="ShareButton"/> object.
        /// </summary>
        /// <param name="title">The shared element title. Limited to 80 characters.</param>
        /// <param name="subtitle">The shared element subtitle. Limited to 80 characters.</param>
        /// <param name="imageUrl">The URL of an optional iamge that may be included by the shared element.</param>
        /// <param name="defaultAction">An optional shared element default onclick behavior.</param>
        /// <param name="button">An optional button added to the shared element.</param>
        /// <param name="isShareable">Sets whether the native share button in Messenger is enabled for the shared element.</param>
        /// <param name="imageAspectRatio">Sets the image aspect ratio of the image in the shared element if it is set.</param>
        public ShareButton(
            string title,
            string subtitle                   = null,
            string imageUrl                   = null,
            DefaultAction defaultAction       = null,
            UrlButton button                  = null,
            bool isShareable                  = false,
            ImageAspectRatio imageAspectRatio = ImageAspectRatio.Horizontal
            )
        {
            if (title == null)
            {
                throw new ValueException("Title must be set.");
            }

            if (title.Length > 80)
            {
                throw new ValueException("Title must not exceed 80 characters.");
            }

            if (subtitle != null && subtitle.Length > 80)
            {
                throw new ValueException("Subtitle must not exceed 80 characters.");
            }

            var payload = new GenericTemplatePayloadEntity
            {
                Shareable = isShareable ? (bool?)true : null,
                Elements  = new List <ElementEntity>()
            };

            switch (imageAspectRatio)
            {
            case ImageAspectRatio.Horizontal:
                break;

            case ImageAspectRatio.Square:
                payload.ImageAspectRatio = "square";
                break;

            default:
                throw new ImageAspectRatioNotSupportedException(imageAspectRatio);
            }

            payload.Elements.Add(new ElementEntity
            {
                Title         = title,
                SubTitle      = subtitle,
                ImageUrl      = imageUrl,
                DefaultAction = defaultAction?.ToEntity(),
                Buttons       = button != null ? new List <IButtonEntity>
                {
                    button.ToEntity()
                } : new List <IButtonEntity>()
            });

            var attachment = new TemplateAttachmentEntity
            {
                Payload = payload
            };

            _content = new MessageEntity
            {
                Attachment = attachment
            };
        }
Example #14
0
 public VideoOptions(ImageAspectRatio _ratio, bool _deint)
 {
     ImageAspectRatio = _ratio;
     Deinterlace      = _deint;
 }
Example #15
0
        public void ReadXML(XmlReader reader)
        {
            reader.ReadStartElement();

            while (reader.NodeType == XmlNodeType.Element)
            {
                switch (reader.Name)
                {
                case "TimecodeFormat":
                    timecodeFormat = (TimecodeFormat)Enum.Parse(typeof(TimecodeFormat), reader.ReadElementContentAsString());
                    break;

                case "SpeedUnit":
                    speedUnit = (SpeedUnit)Enum.Parse(typeof(SpeedUnit), reader.ReadElementContentAsString());
                    break;

                case "AccelerationUnit":
                    accelerationUnit = (AccelerationUnit)Enum.Parse(typeof(AccelerationUnit), reader.ReadElementContentAsString());
                    break;

                case "AngleUnit":
                    angleUnit = (AngleUnit)Enum.Parse(typeof(AngleUnit), reader.ReadElementContentAsString());
                    break;

                case "AngularVelocityUnit":
                    angularVelocityUnit = (AngularVelocityUnit)Enum.Parse(typeof(AngularVelocityUnit), reader.ReadElementContentAsString());
                    break;

                case "AngularAccelerationUnit":
                    angularAccelerationUnit = (AngularAccelerationUnit)Enum.Parse(typeof(AngularAccelerationUnit), reader.ReadElementContentAsString());
                    break;

                case "CustomLengthUnit":
                    customLengthUnit = reader.ReadElementContentAsString();
                    break;

                case "CustomLengthAbbreviation":
                    customLengthAbbreviation = reader.ReadElementContentAsString();
                    break;

                case "AspectRatio":
                    aspectRatio = (ImageAspectRatio)Enum.Parse(typeof(ImageAspectRatio), reader.ReadElementContentAsString());
                    break;

                case "DeinterlaceByDefault":
                    deinterlaceByDefault = XmlHelper.ParseBoolean(reader.ReadElementContentAsString());
                    break;

                case "InteractiveFrameTracker":
                    interactiveFrameTracker = XmlHelper.ParseBoolean(reader.ReadElementContentAsString());
                    break;

                case "WorkingZoneSeconds":
                    workingZoneSeconds = reader.ReadElementContentAsInt();
                    break;

                case "WorkingZoneMemory":
                    workingZoneMemory = reader.ReadElementContentAsInt();
                    break;

                case "SyncLockSpeed":
                    syncLockSpeed = XmlHelper.ParseBoolean(reader.ReadElementContentAsString());
                    break;

                case "ImageFormat":
                    imageFormat = (KinoveaImageFormat)Enum.Parse(typeof(KinoveaImageFormat), reader.ReadElementContentAsString());
                    break;

                case "VideoFormat":
                    videoFormat = (KinoveaVideoFormat)Enum.Parse(typeof(KinoveaVideoFormat), reader.ReadElementContentAsString());
                    break;

                case "InfoFading":
                    defaultFading.ReadXml(reader);
                    break;

                case "MaxFading":
                    maxFading = reader.ReadElementContentAsInt();
                    break;

                case "DrawOnPlay":
                    drawOnPlay = XmlHelper.ParseBoolean(reader.ReadElementContentAsString());
                    break;

                case "RecentColors":
                    ParseRecentColors(reader);
                    break;

                case "MaxRecentColors":
                    maxRecentColors = reader.ReadElementContentAsInt();
                    break;

                case "TrackingProfile":
                    trackingProfile.ReadXml(reader);
                    break;

                case "EnableFiltering":
                    enableFiltering = XmlHelper.ParseBoolean(reader.ReadElementContentAsString());
                    break;

                case "EnableCustomToolsDebugMode":
                    enableCustomToolsDebugMode = XmlHelper.ParseBoolean(reader.ReadElementContentAsString());
                    break;

                default:
                    reader.ReadOuterXml();
                    break;
                }
            }

            reader.ReadEndElement();
        }
Example #16
0
        private void ParseConfigFile(string filePath)
        {
            // Fill the local variables with infos found in the XML file.
            XmlReader PreferencesReader = new XmlTextReader(filePath);

            if (PreferencesReader != null)
            {
                try
                {
                    while (PreferencesReader.Read())
                    {
                        if ((PreferencesReader.IsStartElement()) && (PreferencesReader.Name == "KinoveaPreferences"))
                        {
                            while (PreferencesReader.Read())
                            {
                                if (PreferencesReader.IsStartElement())
                                {
                                    switch (PreferencesReader.Name)
                                    {
                                    case "HistoryCount":
                                        m_iFilesToSave = int.Parse(PreferencesReader.ReadString());
                                        break;

                                    case "Language":
                                        m_UICultureName = PreferencesReader.ReadString();
                                        break;

                                    case "TimeCodeFormat":
                                        m_TimeCodeFormat = ParseTimeCodeFormat(PreferencesReader.ReadString());
                                        break;

                                    case "SpeedUnit":
                                        m_SpeedUnit = ParseSpeedUnit(PreferencesReader.ReadString());
                                        break;

                                    case "ImageAspectRatio":
                                        m_AspectRatio = ParseImageAspectRatio(PreferencesReader.ReadString());
                                        break;

                                    case "DeinterlaceByDefault":
                                        m_bDeinterlaceByDefault = bool.Parse(PreferencesReader.ReadString());
                                        break;

                                    case "WorkingZoneSeconds":
                                        m_iWorkingZoneSeconds = int.Parse(PreferencesReader.ReadString());
                                        break;

                                    case "WorkingZoneMemory":
                                        m_iWorkingZoneMemory = int.Parse(PreferencesReader.ReadString());
                                        break;

                                    case "InfosFading":
                                        //m_DefaultFading.ReadXml(PreferencesReader);
                                        break;

                                    case "MaxFading":
                                        m_iMaxFading = int.Parse(PreferencesReader.ReadString());
                                        break;

                                    case "DrawOnPlay":
                                        m_bDrawOnPlay = bool.Parse(PreferencesReader.ReadString());
                                        break;

                                    case "ExplorerThumbnailsSize":
                                        m_iExplorerThumbsSize = (ExplorerThumbSizes)ExplorerThumbSizes.Parse(m_iExplorerThumbsSize.GetType(), PreferencesReader.ReadString());
                                        break;

                                    case "ExplorerVisible":
                                        m_bIsExplorerVisible = bool.Parse(PreferencesReader.ReadString());
                                        break;

                                    case "ExplorerSplitterDistance":
                                        m_iExplorerSplitterDistance = int.Parse(PreferencesReader.ReadString());
                                        break;

                                    case "ActiveFileBrowserTab":
                                        m_ActiveFileBrowserTab = (ActiveFileBrowserTab)ActiveFileBrowserTab.Parse(m_ActiveFileBrowserTab.GetType(), PreferencesReader.ReadString());
                                        break;

                                    case "ExplorerFilesSplitterDistance":
                                        m_iExplorerFilesSplitterDistance = int.Parse(PreferencesReader.ReadString());
                                        break;

                                    case "ShortcutsFilesSplitterDistance":
                                        m_iShortcutsFilesSplitterDistance = int.Parse(PreferencesReader.ReadString());
                                        break;

                                    case "Shortcuts":
                                        ParseShortcuts(PreferencesReader);
                                        break;

                                    case "RecentColors":
                                        ParseRecentColors(PreferencesReader);
                                        break;

                                    case "CaptureImageDirectory":
                                        m_CaptureImageDirectory = PreferencesReader.ReadString();
                                        break;

                                    case "CaptureImageFile":
                                        m_CaptureImageFile = PreferencesReader.ReadString();
                                        break;

                                    case "CaptureVideoDirectory":
                                        m_CaptureVideoDirectory = PreferencesReader.ReadString();
                                        break;

                                    case "CaptureVideoFile":
                                        m_CaptureVideoFile = PreferencesReader.ReadString();
                                        break;

                                    case "CaptureImageFormat":
                                        m_CaptureImageFormat = ParseImageFormat(PreferencesReader.ReadString());
                                        break;

                                    case "CaptureVideoFormat":
                                        m_CaptureVideoFormat = ParseVideoFormat(PreferencesReader.ReadString());
                                        break;

                                    case "CaptureUsePattern":
                                        m_bCaptureUsePattern = bool.Parse(PreferencesReader.ReadString());
                                        break;

                                    case "CapturePattern":
                                        m_CapturePattern = PreferencesReader.ReadString();
                                        break;

                                    case "CaptureImageCounter":
                                        m_iCaptureImageCounter = long.Parse(PreferencesReader.ReadString());
                                        break;

                                    case "CaptureVideoCounter":
                                        m_iCaptureVideoCounter = long.Parse(PreferencesReader.ReadString());
                                        break;

                                    case "CaptureMemoryBuffer":
                                        m_iCaptureMemoryBuffer = int.Parse(PreferencesReader.ReadString());
                                        break;

                                    case "DeviceConfigurations":
                                        ParseDeviceConfigurations(PreferencesReader);
                                        break;

                                    case "NetworkCameraUrl":
                                        m_NetworkCameraUrl = PreferencesReader.ReadString();
                                        break;

                                    case "NetworkCameraFormat":
                                        m_NetworkCameraFormat = ParseCameraFormat(PreferencesReader.ReadString());
                                        break;

                                    case "RecentNetworkCameras":
                                        ParseRecentCameras(PreferencesReader);
                                        break;

                                    default:
                                        // Preference from a newer file format...
                                        // We don't have a holder variable for it.
                                        break;
                                    }
                                }
                                else if (PreferencesReader.Name == "KinoveaPreferences")
                                {
                                    break;
                                }
                                else
                                {
                                    // Fermeture d'un tag interne.
                                }
                            }
                        }
                    }
                }
                catch (Exception)
                {
                    log.Error("Error happenned while parsing preferences. We'll keep the default values.");
                }
                finally
                {
                    PreferencesReader.Close();
                }
            }
        }
        /// <summary>
        /// Sets the image aspect ratio for element images.
        /// </summary>
        /// <param name="imageAspectRatio">The image aspect ratio.</param>
        /// <returns></returns>
        public GenericTemplateBuilder SetImageAspectRation(ImageAspectRatio imageAspectRatio)
        {
            _imageAspectRatio = imageAspectRatio;

            return(this);
        }