ToDecimal() public static méthode

public static ToDecimal ( this s ) : decimal
s this
Résultat decimal
Exemple #1
0
        /// <summary>
        /// Fills the combo box entry.
        /// </summary>
        /// <param name='combo'>
        /// Combo.
        /// </param>
        /// <param name='items'>
        /// Items.
        /// </param>
        /// <param name='currentValue'>
        /// Current value.
        /// </param>
        /// <param name='editable'>
        /// Editable.
        /// </param>
        public static void FillComboBoxEntry(Gtk.ComboBoxEntry combo, List <string> items, string currentValue, bool isDecimal, bool editable)
        {
            combo.Model = new ListStore(typeof(string));

            var resultItems = new List <string>();

            if (editable)
            {
                // searching for value
                var present = false;
                foreach (var value in items)
                {
                    if (
                        (isDecimal && (SupportMethods.ToDecimal(value) == SupportMethods.ToDecimal(currentValue)))
                        ||
                        (!isDecimal && (value == currentValue))
                        )
                    {
                        present = true;
                        break;
                    }
                }

                // adding missing to first pos
                if (!present)
                {
                    resultItems.Add(currentValue);
                }

                foreach (var value in items)
                {
                    resultItems.Add(value);
                }
            }
            else
            {
                resultItems.Add(currentValue);
            }

            var index = 0;

            foreach (var value in resultItems)
            {
                combo.AppendText(value);

                if (
                    (isDecimal && (SupportMethods.ToDecimal(value) == SupportMethods.ToDecimal(currentValue)))
                    ||
                    (!isDecimal && (value == currentValue))
                    )
                {
                    combo.Active = index;
                }
                index++;
            }
        }
Exemple #2
0
        public static decimal ParseDecimalValueFromValue(string value, Dictionary <decimal, string> dict)
        {
            var res = 0m;

            if (SupportMethods.IsNumeric(value))
            {
                res = SupportMethods.ToDecimal(value);
            }
            else
            {
                foreach (var kvp in dict)
                {
                    if (kvp.Value == value)
                    {
                        res = kvp.Key;
                    }
                }
            }

            return(res);
        }
Exemple #3
0
        protected void OnEntryWidthChanged(object sender, EventArgs e)
        {
            if (checkKeep.Active &&
                MovieInfo.FirstVideoTrack != null &&
                SupportMethods.IsNumeric(entryWidth.Text))
            {
                if (_eventLock.Lock())
                {
                    var width = SupportMethods.ToDecimal(entryWidth.Text);

                    var aspectRatio = MovieInfo.FirstVideoTrack.AspectAsNumber;
                    if (aspectRatio != -1)
                    {
                        entryHeight.Text = Convert.ToInt32(width / aspectRatio).ToString();
                    }
                    _eventLock.Unlock();
                }
            }

            OnAnyValueChanged();
        }
        public void ParseFromXmlNode(XmlNode node)
        {
            foreach (XmlNode subNode in node.ChildNodes)
            {
                if (subNode.Name == "Overall_bit_rate" && (SupportMethods.IsNumeric(subNode.InnerText)))
                {
                    Bitrate = SupportMethods.ToDecimal(subNode.InnerText);
                }

                if (subNode.Name == "Frame_rate" && (SupportMethods.IsNumeric(subNode.InnerText)))
                {
                    FrameRate = SupportMethods.ToDecimal(subNode.InnerText);
                }

                if (subNode.Name == "Sampling_rate" && (SupportMethods.IsNumeric(subNode.InnerText)))
                {
                    SamplingRateHz = SupportMethods.ToDecimal(subNode.InnerText);
                }

                if (subNode.Name == "Bit_rate" && (SupportMethods.IsNumeric(subNode.InnerText)))
                {
                    Bitrate = decimal.Parse(subNode.InnerText);
                }

                if (subNode.Name == "Stream_size" && (SupportMethods.IsNumeric(subNode.InnerText)))
                {
                    StreamSize = long.Parse(subNode.InnerText);
                }

                if (subNode.Name == "Channel_s_" && (SupportMethods.IsNumeric(subNode.InnerText)))
                {
                    Channels = Int32.Parse(subNode.InnerText);
                }

                if (subNode.Name == "Channel_count" && (SupportMethods.IsNumeric(subNode.InnerText)))
                {
                    Channels = Int32.Parse(subNode.InnerText);
                }

                if (subNode.Name == "Pixel_aspect_ratio" && (SupportMethods.IsNumeric(subNode.InnerText)))
                {
                    PixelAspect = SupportMethods.ToDecimal(subNode.InnerText);
                }

                if (subNode.Name == "Width" && (SupportMethods.IsInt(subNode.InnerText)))
                {
                    Width = Int32.Parse(subNode.InnerText);
                }
                if (subNode.Name == "Height" && (SupportMethods.IsInt(subNode.InnerText)))
                {
                    Height = Int32.Parse(subNode.InnerText);
                }

                if (subNode.Name == "Display_aspect_ratio" && (subNode.InnerText.Contains(":")))
                {
                    Aspect = subNode.InnerText;
                }

                if (subNode.Name == "Codec")
                {
                    Codec = subNode.InnerText;
                }

                if (subNode.Name == "Rotation" && (SupportMethods.IsNumeric(subNode.InnerText)))
                {
                    decimal angle            = 0;
                    var     separator        = System.Globalization.CultureInfo.CurrentUICulture.NumberFormat.NumberDecimalSeparator;
                    var     rotationAsString = subNode.InnerText.Replace(".", separator).Replace(",", separator);
                    if (Decimal.TryParse(rotationAsString, out angle))
                    {
                        RotatationAngle = angle;
                    }
                }

                if (subNode.Name == "Duration" && (subNode.InnerText.Contains(":")))
                {
                    Duration = subNode.InnerText;
                }

                if (subNode.Name == "Duration" && (SupportMethods.IsNumeric(subNode.InnerText)))
                {
                    DurationMS = SupportMethods.ToDecimal(subNode.InnerText);
                }
            }

            TrackType = node.Attributes.GetNamedItem("type").Value;
        }
Exemple #5
0
        private void OnAnyValueChanged()
        {
            if (Editable && MovieInfo != null && MovieInfo.FirstVideoTrack != null)
            {
                if (_eventLock.Lock())
                {
                    var m = MovieInfo.FirstVideoTrack;

                    // reactivating disabled?
                    if (chBoxResolution.Active && !MovieInfo.EditResolution)
                    {
                        entryWidth.Text  = m.Width.ToString();
                        entryHeight.Text = m.Height.ToString();
                    }
                    if (chBoxBitRate.Active && !MovieInfo.EditBitRate)
                    {
                        comboBitRate.Entry.Text = (m.BitrateKbps).ToString();
                    }

                    if (chBoxAspect.Active && !MovieInfo.EditAspect)
                    {
                        comboAspect.Entry.Text = m.Aspect;
                    }

                    if (chBoxFrameRate.Active && !MovieInfo.EditFrameRate)
                    {
                        comboFrameRate.Entry.Text = m.FrameRate.ToString();
                    }


                    MovieInfo.EditResolution = chBoxResolution.Active;
                    MovieInfo.EditAspect     = chBoxAspect.Active;
                    MovieInfo.EditBitRate    = chBoxBitRate.Active;
                    MovieInfo.EditFrameRate  = chBoxFrameRate.Active;

                    if (chBoxBitRate.Active)
                    {
                        var bitRateTypedValue = SupportMethods.ParseDecimalValueFromValue(comboBitRate.ActiveText, MediaConvertGUIConfiguration.DefaultVideoBitRates);
                        m.Bitrate = bitRateTypedValue * 1000;
                    }

                    if (chBoxResolution.Active)
                    {
                        if (SupportMethods.IsNumeric(entryWidth.Text))
                        {
                            m.Width = Convert.ToInt32(entryWidth.Text);
                        }

                        if (SupportMethods.IsNumeric(entryHeight.Text))
                        {
                            m.Height = Convert.ToInt32(entryHeight.Text);
                        }
                    }

                    if (chBoxFrameRate.Active)
                    {
                        if (SupportMethods.IsNumeric(comboFrameRate.ActiveText))
                        {
                            m.FrameRate = SupportMethods.ToDecimal(comboFrameRate.ActiveText);
                        }
                    }

                    if (chBoxAspect.Active)
                    {
                        m.Aspect = comboAspect.ActiveText;
                    }

                    if (chBoxRotation.Active)
                    {
                        if (SupportMethods.IsNumeric(comboRotation.ActiveText))
                        {
                            m.RotatationAngle = SupportMethods.ToDecimal(comboRotation.ActiveText);
                        }
                    }
                    MovieInfo.EditRotation = chBoxRotation.Active;

                    MovieInfo.AutoRotate = checkAutorotate.Active;
                    if (checkAutorotate.Active)
                    {
                        // reseting Rotation angle to 0
                        m.RotatationAngle = 0;
                    }

                    MovieInfo.TargetVideoCodec = MediaConvertGUIConfiguration.GetVideoCodecByName(comboCodec.ActiveText);
                    comboCodec.TooltipText     = MovieInfo.TargetVideoCodec.Title;

                    _eventLock.Unlock();
                    Fill();
                }
            }
        }