Example #1
0
        public T Create(string xukLN, string xukNS)
        {
            //string qname = String.Format("{0}:{1}", xukNS, xukLN);
            UglyPrettyName name  = new UglyPrettyName(!PrettyFormat ? xukLN : null, PrettyFormat ? xukLN : null);
            QualifiedName  qname = new QualifiedName(name, xukNS);

            Type t = LookupType(qname);

            if (t == null)
            {
#if DEBUG
                Debugger.Break();
#endif
                return(null);
            }

            T obj = Create(t);

            TypeAndQNames tt = LookupTypeAndQNames(qname);
            DebugFix.Assert(tt != null);
            if (tt.Type == null)
            {
                // not real type of qname => type of first available ancestor in the type inheritance chain.
                obj.MissingTypeOriginalXukedName = tt.QName;
            }

            return(obj);
        }
Example #2
0
        protected void XukOutRegisteredTypes(XmlWriter destination, Uri baseUri, progress.IProgressHandler handler)
        {
            foreach (TypeAndQNames tp in mRegisteredTypeAndQNames)
            {
                destination.WriteStartElement(Type_NAME.z(PrettyFormat), XukAble.XUK_NS);
                destination.WriteAttributeString(XukLocalName_NAME.z(PrettyFormat), tp.QName.LocalName.z(PrettyFormat));
                destination.WriteAttributeString(XukNamespaceUri_NAME.z(PrettyFormat), tp.QName.NamespaceUri);
                if (tp.BaseQName != null)
                {
                    DebugFix.Assert(!string.IsNullOrEmpty(tp.BaseQName.LocalName.Pretty) ||
                                    !string.IsNullOrEmpty(tp.BaseQName.LocalName.Ugly));

                    destination.WriteAttributeString(BaseXukLocalName_NAME.z(PrettyFormat), tp.BaseQName.LocalName.z(PrettyFormat));
                    destination.WriteAttributeString(BaseXukNamespaceUri_NAME.z(PrettyFormat), tp.BaseQName.NamespaceUri);
                }
                if (tp.Type != null)
                {
                    tp.AssemblyName = tp.Type.Assembly.GetName();
                    tp.ClassName    = tp.Type.FullName;
                }
                if (tp.AssemblyName != null)
                {
                    destination.WriteAttributeString(AssemblyName_NAME.z(PrettyFormat), tp.AssemblyName.Name);
                    destination.WriteAttributeString(AssemblyVersion_NAME.z(PrettyFormat), tp.AssemblyName.Version.ToString());
                }
                if (tp.ClassName != null)
                {
                    destination.WriteAttributeString(FullName_NAME.z(PrettyFormat), tp.ClassName);
                }
                destination.WriteEndElement();
            }
        }
Example #3
0
        public static string GetXukFilePath(string outputDirectory, string bookFilePath, string title, bool isSpine)
        {
            string extension       = Path.GetExtension(bookFilePath);
            string croppedFileName = Path.GetFileNameWithoutExtension(bookFilePath);

            if (croppedFileName.Length > 12)
            {
                croppedFileName = croppedFileName.Substring(0, 12);
            }
            croppedFileName = croppedFileName + extension;

            string xukFileName = (isSpine ? @"_" : "")
                                 + croppedFileName.Replace('.', '_')
                                 + (!string.IsNullOrEmpty(title)
                                        ? "-" //"["
                                    + CleanupTitle(title, 12)
                                              //+ "]"
                                        : "")
                                 + (isSpine ? OpenXukAction.XUK_SPINE_EXTENSION : OpenXukAction.XUK_EXTENSION);

#if DEBUG
            DebugFix.Assert(xukFileName.Length <= (1 + 12 + 6 + 1 + 12 + 9));
            DebugFix.Assert(outputDirectory.Length + xukFileName.Length <= 250);
#endif

            return(Path.Combine(outputDirectory, xukFileName));
        }
        private void handleMetaData(string rootFilePath, Project project, XmlNode mdNode, string name, string content, string id)
        {
            if (RequestCancellation)
            {
                return;
            }

            if (isUniqueIdName(name))
            {
                if (m_PackageUniqueIdAttr != null &&
                    id != null &&
                    id == m_PackageUniqueIdAttr.Value)
                {
                    DebugFix.Assert(String.IsNullOrEmpty(m_PublicationUniqueIdentifier));
                    //String.Format("The Publication's Unique Identifier is specified several times !! OLD: [{0}], NEW: [{1}]", m_PublicationUniqueIdentifier, content)

                    m_PublicationUniqueIdentifier     = content;
                    m_PublicationUniqueIdentifierNode = mdNode;

                    Presentation presentation = project.Presentations.Get(0);
                    foreach (Metadata md in presentation.Metadatas.ContentsAs_ListCopy)
                    {
                        if (RequestCancellation)
                        {
                            return;
                        }

                        if (isUniqueIdName(md.NameContentAttribute.Name) &&
                            md.NameContentAttribute.Value == m_PublicationUniqueIdentifier)
                        {
                            presentation.Metadatas.Remove(md);
                        }
                    }
                }
                else if (!metadataUidValueAlreadyExists(project, content) &&
                         (String.IsNullOrEmpty(m_PublicationUniqueIdentifier) || content != m_PublicationUniqueIdentifier))
                {
                    Metadata meta = addMetadata(rootFilePath, project, name, content, mdNode);
                }
            }
            else
            {
                MetadataDefinition md = SupportedMetadata_Z39862005.DefinitionSet.GetMetadataDefinition(name);
                if (
                    (md == null && !metadataNameContentAlreadyExists(project, name, content)) ||
                    (md != null && md.IsRepeatable && !metadataNameContentAlreadyExists(project, name, content)) ||
                    (md != null && !md.IsRepeatable && !metadataNameAlreadyExists(project, name))
                    )
                {
                    if (name != "dtb:totalTime" &&
                        name != "dtb:totalElapsedTime" &&
                        name != "media:duration" &&
                        name != "cover"
                        )
                    {
                        Metadata meta = addMetadata(rootFilePath, project, name, content, mdNode);
                    }
                }
            }
        }
Example #5
0
        private void OnNoAudioContentFoundByFlowDocumentParserEvent(TreeNode treeNode)
        {
            DebugFix.Assert(treeNode.NeedsAudio());
            DebugFix.Assert(!treeNode.HasOrInheritsAudio());

            if (Tobi.Common.Settings.Default.ValidMissingAudioElements_Enable && isTreeNodeValidNoAudio(treeNode))
            {
                return;
            }

            foreach (var valItem in ValidationItems)
            {
                // ensure no duplicates
                if (valItem is MissingAudioValidationError && ((MissingAudioValidationError)valItem).Target == treeNode)
                {
                    return;
                }
            }

            var error = new MissingAudioValidationError(m_Session)
            {
                Target    = treeNode,
                Validator = this
            };

            addValidationItem(error);
        }
Example #6
0
        public static string GetXukFilePath_SpineItem(string outputDirectory, string relativeFilePath, string title, int index)
        {
            relativeFilePath = FileDataProvider.EliminateForbiddenFileNameCharacters(relativeFilePath);

            string extension       = Path.GetExtension(relativeFilePath);
            string croppedFileName = Path.GetFileNameWithoutExtension(relativeFilePath);

            if (croppedFileName.Length > 12)
            {
                croppedFileName = croppedFileName.Substring(0, 12);
            }
            croppedFileName = croppedFileName + extension;

            if (index >= 0)
            {
                croppedFileName = "_" + index + "_" + croppedFileName;
            }

            string xukFileName =
                croppedFileName.Replace('.', '_')
                + (!string.IsNullOrEmpty(title)
                       ? "-" //"["
                   + CleanupTitle(title, 12)
                   //+ "]"
                       : "")
                + OpenXukAction.XUK_EXTENSION;

#if DEBUG
            DebugFix.Assert(xukFileName.Length <= (1 + 12 + 6 + 1 + 12 + 4));
            DebugFix.Assert(outputDirectory.Length + xukFileName.Length <= 250);
#endif

            return(Path.Combine(outputDirectory, xukFileName));
        }
Example #7
0
        public static TimeSpan ConvertFromLocalUnitsToTimeSpan(long timeInLocalUnits)
        {
            if (timeInLocalUnits == long.MaxValue)
            {
                return(TimeSpan.MaxValue);
            }
            if (timeInLocalUnits == long.MinValue)
            {
                return(TimeSpan.MinValue);
            }
            if (timeInLocalUnits == 0)
            {
                return(TimeSpan.Zero);
            }

            double timeMillisecondsDecimal = (double)timeInLocalUnits / TIME_UNIT;

            int decimalPlaces = TIME_UNIT == 1 ? 0 : TIME_UNIT == 1000 ? 3 : TIME_UNIT == 1000000 ? 6 : 7;

            DebugFix.Assert(decimalPlaces != 7);
            timeMillisecondsDecimal = Math.Round(timeMillisecondsDecimal, decimalPlaces, MidpointRounding.AwayFromZero);

            double ticksDecimal  = timeMillisecondsDecimal * TimeSpan.TicksPerMillisecond;
            long   ticksIntegral =
                (long)
                (AudioLibPCMFormat.USE_ROUND_NOT_TRUNCATE ? Math.Round(ticksDecimal) : Math.Truncate(ticksDecimal));

            // checking whether we are loosing fractions of milliseconds
            /////DebugFix.Assert(ticksDecimal == (double)ticksIntegral);

            return(TimeSpan.FromTicks(ticksIntegral));
        }
Example #8
0
        public Time(string stringRepresentation)
        {
            double timeMillisecondsDecimal = ParseToMilliseconds(stringRepresentation);

            int decimalPlaces = TIME_UNIT == 1 ? 0 : TIME_UNIT == 1000 ? 3 : TIME_UNIT == 1000000 ? 6 : 7;

            DebugFix.Assert(decimalPlaces != 7);
            timeMillisecondsDecimal = Math.Round(timeMillisecondsDecimal, decimalPlaces, MidpointRounding.AwayFromZero);

#if DEBUG
            try
            {
                TimeSpan timeSpan = TimeSpan.Parse(stringRepresentation);
                DebugFix.Assert(Math.Abs(timeSpan.TotalMilliseconds - timeMillisecondsDecimal) <= AudioLibPCMFormat.MILLISECONDS_TOLERANCE);
            }
            catch (FormatException ex)
            {
                ; // we can safely ignore
            }
#endif //DEBUG


            double timeAsLocalUnitsDecimal  = timeMillisecondsDecimal * TIME_UNIT;
            long   timeAsLocalUnitsIntegral = (long)(AudioLibPCMFormat.USE_ROUND_NOT_TRUNCATE ? Math.Round(timeAsLocalUnitsDecimal) : Math.Truncate(timeAsLocalUnitsDecimal));

#if DEBUG
            // checking whether we are loosing fractions (of localunits) greater than 0.1
            DebugFix.Assert(((int)Math.Truncate((timeAsLocalUnitsDecimal - timeAsLocalUnitsIntegral) * 10)) <= 1);
#endif //DEBUG

            AsLocalUnits = timeAsLocalUnitsIntegral;
        }
Example #9
0
        private bool _validate() //IEnumerable<urakawa.metadata.Metadata> metadatas)
        {
            bool isValid = true;

            string name   = m_Session.DocumentProject.Presentations.Get(0).RootNode.GetXmlElementLocalName();
            bool   isHTML = @"body".EndsWith(name, StringComparison.OrdinalIgnoreCase);

#if DEBUG
            bool isXukSpine = @"spine".EndsWith(name, StringComparison.OrdinalIgnoreCase);
            DebugFix.Assert(isXukSpine == m_Session.IsXukSpine);

            if (isHTML)
            {
                //DebugFix.Assert(m_Session.HasXukSpine); too early
            }
#endif

            if (!isHTML && !m_Session.IsXukSpine)
            {
                //validate each item by itself
                foreach (
                    urakawa.metadata.Metadata metadata in
                    m_Session.DocumentProject.Presentations.Get(0).Metadatas.ContentsAs_Enumerable)
                {
                    if (!_validateItem(metadata))
                    {
                        isValid = false;
                    }
                }
                bool val = _validateAsSet();
                isValid = isValid && val; //metadatas);
            }

            return(isValid);
        }
Example #10
0
        private void HandleConfigurationErrorsException(ConfigurationErrorsException ex)
        {
#if DEBUG
            Debugger.Break();
#endif
            string filename = ex.Filename;
            if (string.IsNullOrEmpty(filename) &&
                ex.InnerException != null &&
                ex.InnerException is ConfigurationErrorsException)
            {
                filename = ((ConfigurationErrorsException)ex.InnerException).Filename;
            }

            if (filename != null && File.Exists(filename))
            {
                File.Delete(filename);
            }

            string directory = Path.GetDirectoryName(filename);

            Configuration config       = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal);
            string        settingsPath = Path.GetDirectoryName(config.FilePath);
            Shell.ExecuteShellProcess_(settingsPath);

            DebugFix.Assert(directory == settingsPath);

            Settings.Default.Reset();
            //Settings.Default.Reload();
            //Settings.Default.Upgrade();
        }
Example #11
0
        private long computeByteOffset(TreeNode targetNode1, TreeNode targetNode2)
        {
            long byteOffset = 0;

            if (State.Audio.PlayStreamMarkers != null && targetNode2 != null)
            {
                ManagedAudioMedia mediaInPlayMarkers = targetNode2.GetManagedAudioMedia();

                if (mediaInPlayMarkers == null)
                {
                    TreeNode prev = targetNode2.GetPreviousSiblingWithManagedAudio();
                    if (prev != null && prev.IsDescendantOf(targetNode1))
                    {
                        ManagedAudioMedia prevAudio = prev.GetManagedAudioMedia();
                        DebugFix.Assert(prevAudio != null);

                        byteOffset = getByteOffset(prev, prevAudio);

                        if (prevAudio != null)
                        {
                            byteOffset += prevAudio.AudioMediaData.PCMFormat.Data.ConvertTimeToBytes(prevAudio.AudioMediaData.AudioDuration.AsLocalUnits);
                        }
                    }
                }
                else
                {
                    byteOffset = getByteOffset(targetNode2, mediaInPlayMarkers);
                }
            }

            return(byteOffset);
        }
Example #12
0
            private Stream SetPlayStream_FromTreeNode_OPEN(Stream stream)
            {
                if (stream != null)
                {
                    stream.Position = 0;
                    stream.Seek(0, SeekOrigin.Begin);

                    Tuple <TreeNode, TreeNode> treeNodeSelection = m_viewModel.m_UrakawaSession.GetTreeNodeSelection();

                    if (treeNodeSelection.Item1 != null)
                    {
                        DebugFix.Assert(treeNodeSelection.Item1.Presentation.MediaDataManager.EnforceSinglePCMFormat);
                        PcmFormat = treeNodeSelection.Item1.Presentation.MediaDataManager.DefaultPCMFormat;
                    }
                    else if (m_viewModel.m_UrakawaSession != null && m_viewModel.m_UrakawaSession.DocumentProject != null)
                    {
                        DebugFix.Assert(m_viewModel.m_UrakawaSession.DocumentProject.Presentations.Get(0).MediaDataManager.EnforceSinglePCMFormat);
                        PcmFormat = m_viewModel.m_UrakawaSession.DocumentProject.Presentations.Get(0).MediaDataManager.DefaultPCMFormat;
                    }
                    else
                    {
                        PcmFormat = null;
                        Debug.Fail("This should never happen !!");
                    }

                    DataLength            = stream.Length;
                    EndOffsetOfPlayStream = DataLength;
                }

                return(stream);
            }
Example #13
0
            private Stream SetPlayStream_FromFile_OPEN(
                FileStream fileStream,
                string filePathOptionalInfo)
            {
                Stream stream = fileStream;

                if (stream != null)
                {
                    stream.Position = 0;
                    stream.Seek(0, SeekOrigin.Begin);

                    uint dataLength;
                    AudioLibPCMFormat format = AudioLibPCMFormat.RiffHeaderParse(stream, out dataLength);

                    PcmFormat = new PCMFormatInfo(format);

                    dataLength = (uint)(stream.Length - stream.Position);

                    stream = new SubStream(stream, stream.Position, dataLength, filePathOptionalInfo);

                    DebugFix.Assert(dataLength == stream.Length);

                    DataLength            = stream.Length;
                    EndOffsetOfPlayStream = DataLength;
                }

                return(stream);
            }
Example #14
0
        static FileDataProvider()
        {
            string str1 = @"C:/dir/file.txt";
            string str2 = @"C:/dir/../dir/file.txt";
            string str3 = @"C:/dir/./file.txt";
            string str4 = @"C:/dir/../dir/./file.txt";
            string str5 = @"C:/dir/subdir/../file.txt";
            string str6 = @"C:/dir/subdir/./../file.txt";
            string str7 = @"C:/dir/subdir/.././file.txt";

            string p1 = NormaliseFullFilePath(str1);
            string p2 = NormaliseFullFilePath(str2);
            string p3 = NormaliseFullFilePath(str3);
            string p4 = NormaliseFullFilePath(str4);
            string p5 = NormaliseFullFilePath(str5);
            string p6 = NormaliseFullFilePath(str6);
            string p7 = NormaliseFullFilePath(str7);

            DebugFix.Assert(p1 == p2);
            DebugFix.Assert(p2 == p3);
            DebugFix.Assert(p3 == p4);
            DebugFix.Assert(p4 == p5);
            DebugFix.Assert(p5 == p6);
            DebugFix.Assert(p6 == p7);

            str1 = str1.Replace('/', '\\');
            str2 = str2.Replace('/', '\\');
            str3 = str3.Replace('/', '\\');
            str4 = str4.Replace('/', '\\');
            str5 = str5.Replace('/', '\\');
            str6 = str6.Replace('/', '\\');
            str7 = str7.Replace('/', '\\');

            p1 = NormaliseFullFilePath(str1);
            p2 = NormaliseFullFilePath(str2);
            p3 = NormaliseFullFilePath(str3);
            p4 = NormaliseFullFilePath(str4);
            p5 = NormaliseFullFilePath(str5);
            p6 = NormaliseFullFilePath(str6);
            p7 = NormaliseFullFilePath(str7);

            DebugFix.Assert(p1 == p2);
            DebugFix.Assert(p2 == p3);
            DebugFix.Assert(p3 == p4);
            DebugFix.Assert(p4 == p5);
            DebugFix.Assert(p5 == p6);
            DebugFix.Assert(p6 == p7);

            string pp1 = NormaliseFullFilePath(@"C:/dir/subdir/");
            string pp2 = NormaliseFullFilePath(@"C:/dir/subdir");

            DebugFix.Assert(pp1 == pp2);

            string pp3 = NormaliseFullFilePath(@"\\\\network-share/dir\\subdir/");
            string pp4 = NormaliseFullFilePath(@"//network-share\\dir/subdir");

            DebugFix.Assert(pp3 == pp4);
        }
        private static bool IsRunning64()
        {
            bool is64 = IntPtr.Size == 8;

#if NET40
            DebugFix.Assert(is64 == Environment.Is64BitProcess);
#endif
            return(is64); //4 in x86 / 32 bits arch
        }
Example #16
0
        private static void NotifyScreenReaderAutomation(AutomationPeer automationPeer, string str)
        {
            if (automationPeer == null)
            {
                return;
            }

            if (!AutomationInteropProvider.ClientsAreListening)
            {
                return;
            }

            //            if (AutomationPeer.ListenerExists(AutomationEvents.AutomationFocusChanged))
            //            {
            //                automationPeer.RaiseAutomationEvent(AutomationEvents.AutomationFocusChanged);

            //#if DEBUG
            //                Console.WriteLine("AUTOMATION EVENT ==> AutomationFocusChanged");
            //#endif //DEBUG
            //            }

            //            if (AutomationPeer.ListenerExists(AutomationEvents.TextPatternOnTextSelectionChanged))
            //            {
            //                automationPeer.RaiseAutomationEvent(AutomationEvents.TextPatternOnTextSelectionChanged);

            //#if DEBUG
            //                Console.WriteLine("AUTOMATION EVENT ==> TextPatternOnTextSelectionChanged");
            //#endif //DEBUG
            //            }



            //automationPeer.InvalidatePeer();

            //AutomationEventArgs args = new AutomationEventArgs(InvokePatternIdentifiers.InvokedEvent);
            //AutomationInteropProvider.RaiseAutomationEvent(InvokePatternIdentifiers.InvokedEvent, this, args);

            //AutomationProperties.NameProperty

            try
            {
#if DEBUG
                var autoProp = AutomationProperty.LookupById(AutomationElementIdentifiers.NameProperty.Id);
                DebugFix.Assert(AutomationElementIdentifiers.NameProperty == autoProp);
#endif //DEBUG
                automationPeer.RaisePropertyChangedEvent(AutomationElementIdentifiers.NameProperty, "", str);
            }
            catch (Exception e)
            {
#if DEBUG
                Console.WriteLine("Exception automationPeer.RaisePropertyChangedEvent");
                Debugger.Break();
#endif //DEBUG
            }
        }
        private void OnClick_ButtonClearText_Specific(string diagramElementName)
        {
            AlternateContent altContent = m_ViewModel.GetAltContent(diagramElementName);

            DebugFix.Assert(altContent != null);

            DescriptionsListView.SelectedItem = altContent;
            DebugFix.Assert(DescriptionsListView.SelectedItem == altContent);

            OnClick_ButtonClearText(null, null);
        }
Example #18
0
        private void verifyTreeNodeSelection()
        {
            if (m_TreeNode == null)
            {
                DebugFix.Assert(m_SubTreeNode == null);
                return;
            }

            TreeNode nodeAncestorAudio = m_TreeNode.GetFirstAncestorWithManagedAudio();


#if ENABLE_SEQ_MEDIA
            bool nodeHasDirectAudio = m_TreeNode.GetManagedAudioMediaOrSequenceMedia() != null;
#else
            bool nodeHasDirectAudio = m_TreeNode.GetManagedAudioMedia() != null;
#endif

            TreeNode nodeDescendantAudio = m_TreeNode.GetFirstDescendantWithManagedAudio();

            DebugFix.Assert(nodeAncestorAudio == null);

            if (nodeHasDirectAudio)
            {
                DebugFix.Assert(nodeDescendantAudio == null);
                DebugFix.Assert(m_SubTreeNode == null);
            }

            if (nodeDescendantAudio != null)
            {
                DebugFix.Assert(!nodeHasDirectAudio);
            }

            if (m_SubTreeNode == null)
            {
                DebugFix.Assert(nodeDescendantAudio == null);
            }
            else
            {
                DebugFix.Assert(m_TreeNode.IsAncestorOf(m_SubTreeNode)); // nodes cannot be equal

                TreeNode subnodeAncestorAudio = m_SubTreeNode.GetFirstAncestorWithManagedAudio();

#if ENABLE_SEQ_MEDIA
                bool subnodeHasDirectAudio = m_SubTreeNode.GetManagedAudioMediaOrSequenceMedia() != null;
#else
                bool subnodeHasDirectAudio = m_SubTreeNode.GetManagedAudioMedia() != null;
#endif

                TreeNode subnodeDescendantAudio = m_SubTreeNode.GetFirstDescendantWithManagedAudio();

                DebugFix.Assert(subnodeAncestorAudio == null);
                DebugFix.Assert(subnodeDescendantAudio == null);
            }
        }
Example #19
0
        private void SetCulture(string str)
        {
            DebugFix.Assert(CultureInfo.CurrentCulture.Equals(Thread.CurrentThread.CurrentCulture));
            DebugFix.Assert(CultureInfo.CurrentUICulture.Equals(Thread.CurrentThread.CurrentUICulture));

            //var c1 = CultureInfo.CurrentCulture;
            //var c2 = CultureInfo.CurrentUICulture;
            //DebugFix.Assert(c1.Equals(c2));

            if (str == "en")
            {
                str = "en-GB";
            }
            if (str == "fr")
            {
                str = "fr-FR";
            }

            var c3 = CultureInfo.GetCultureInfoByIetfLanguageTag(str);

            var c4 = CultureInfo.GetCultureInfo(str);

            DebugFix.Assert(c3.Equals(c4));

            var c5 = new CultureInfo(str);

            DebugFix.Assert(c3.Equals(c5));

            //if (!c4.IsNeutralCulture)
            //{
            //    Thread.CurrentThread.CurrentCulture = c4;
            //}
            Thread.CurrentThread.CurrentUICulture = c4;

            //DebugFix.Assert(Thread.CurrentThread.CurrentUICulture.Equals(Thread.CurrentThread.CurrentCulture));

            str = CultureInfo.CurrentCulture.TwoLetterISOLanguageName;
            str = CultureInfo.CurrentCulture.ThreeLetterWindowsLanguageName;
            str = CultureInfo.CurrentCulture.ThreeLetterISOLanguageName;
            str = CultureInfo.CurrentCulture.NativeName;
            str = CultureInfo.CurrentCulture.Name;
            str = CultureInfo.CurrentCulture.IetfLanguageTag;
            str = CultureInfo.CurrentCulture.EnglishName;
            str = CultureInfo.CurrentCulture.DisplayName;

            str = CultureInfo.CurrentUICulture.TwoLetterISOLanguageName;
            str = CultureInfo.CurrentUICulture.ThreeLetterWindowsLanguageName;
            str = CultureInfo.CurrentUICulture.ThreeLetterISOLanguageName;
            str = CultureInfo.CurrentUICulture.NativeName;
            str = CultureInfo.CurrentUICulture.Name;
            str = CultureInfo.CurrentUICulture.IetfLanguageTag;
            str = CultureInfo.CurrentUICulture.EnglishName;
            str = CultureInfo.CurrentUICulture.DisplayName;
        }
Example #20
0
        /// <summary>
        /// Gets Operating System Architecture.  This does not tell you if the program in running in
        /// 32- or 64-bit mode or if the CPU is 64-bit capable.  It tells you whether the actual Operating
        /// System is 32- or 64-bit.
        /// </summary>
        /// <returns>Int containing 32 or 64 representing the number of bits in the OS Architecture</returns>
        private static int getOSArchitectureLegacy()
        {
            string pa = Environment.GetEnvironmentVariable("PROCESSOR_ARCHITECTURE");

            int bits = ((String.IsNullOrEmpty(pa) || String.Compare(pa, 0, "x86", 0, 3, true) == 0) ? 32 : 64);

#if NET40
            DebugFix.Assert((bits == 64) == Environment.Is64BitOperatingSystem);
#endif
            return(bits);
        }
Example #21
0
        public static string GetXukNamespace(Type type)
        {
            Attribute attribute = Attribute.GetCustomAttribute(
                type,
                typeof(XukNamespaceAttribute));

            DebugFix.Assert(attribute != null);

            return(attribute == null ? string.Empty
                : ((XukNamespaceAttribute)attribute).Namespace);
        }
Example #22
0
        protected void XukInRegisteredType(XmlReader source)
        {
            if (Type_NAME.Match(source.LocalName) &&
                source.NamespaceURI == XukAble.XUK_NS)
            {
                TypeAndQNames tq = new TypeAndQNames();

                readTypeAndQNamesFromXmlReader(tq, source, PrettyFormat);

                if (tq.Type == null)
                {
#if DEBUG
                    Debugger.Break();
#endif
                    RegisterType(tq);
                }
                else
                {
                    TypeAndQNames tq_ = RegisterType(tq.Type);

                    DebugFix.Assert(tq_.AssemblyName.Name == tq.AssemblyName.Name);
                    //DebugFix.Assert(tq_.AssemblyName.Version == tq.AssemblyName.Version);

                    DebugFix.Assert(tq_.ClassName == tq.ClassName);
                    DebugFix.Assert(tq_.Type == tq.Type);

                    DebugFix.Assert(tq_.QName.NamespaceUri == tq.QName.NamespaceUri);

                    DebugFix.Assert(tq_.QName.LocalName.Ugly == tq.QName.LocalName.Ugly);
                    DebugFix.Assert(tq_.QName.LocalName.Pretty == tq.QName.LocalName.Pretty);

                    if (tq_.BaseQName != null && tq.BaseQName != null)
                    {
                        DebugFix.Assert(tq_.BaseQName.NamespaceUri == tq.BaseQName.NamespaceUri);

                        if (!String.IsNullOrEmpty(tq.BaseQName.LocalName.Ugly))
                        {
                            DebugFix.Assert(tq_.BaseQName.LocalName.Ugly == tq.BaseQName.LocalName.Ugly);
                        }

                        if (!String.IsNullOrEmpty(tq.BaseQName.LocalName.Pretty))
                        {
                            DebugFix.Assert(tq_.BaseQName.LocalName.Pretty == tq.BaseQName.LocalName.Pretty);
                        }
                    }
                }
            }
            if (!source.IsEmptyElement)
            {
                source.ReadSubtree().Close();
            }
        }
Example #23
0
        public bool NeedsAudio()
        {
            if (HasXmlProperty)
            {
                string localName = GetXmlElementLocalName();

                bool isMath = localName.Equals("math", //DiagramContentModelHelper.Math
                                               StringComparison.OrdinalIgnoreCase);

                bool isSVG = localName.Equals("svg", //DiagramContentModelHelper.Svg
                                              StringComparison.OrdinalIgnoreCase);

                if (!isMath &&
                    GetXmlNamespaceUri() == "http://www.w3.org/1998/Math/MathML"
                    //DiagramContentModelHelper.NS_URL_MATHML
                    )
                {
                    return(false);
                }

                if (!isSVG &&
                    GetXmlNamespaceUri() == "http://www.w3.org/2000/svg"
                    //DiagramContentModelHelper.NS_URL_SVG
                    )
                {
                    return(false);
                }

                if (localName.Equals("img", StringComparison.OrdinalIgnoreCase) ||
                    localName.Equals("video", StringComparison.OrdinalIgnoreCase) ||
                    isMath ||
                    isSVG
                    )
                {
                    //if (!isMath && !isSVG)
                    //{
                    //    DebugFix.Assert(Children.Count == 0);
                    //}
                    return(true);
                }
            }

            if (GetTextMedia() != null &&
                !TextOnlyContainsPunctuation(GetTextFlattened_()))
            {
                DebugFix.Assert(Children.Count == 0);
                return(true);
            }

            return(false);
        }
Example #24
0
        public void Init(TreeNodeAndStreamSelection selection, TreeNode currentTreeNode)
        {
            if (selection == null)
            {
                throw new ArgumentNullException("selection");
            }
            if (selection.m_TreeNode == null)
            {
                throw new ArgumentNullException("selection.m_TreeNode");
            }
            if (currentTreeNode == null)
            {
                throw new ArgumentNullException("currentTreeNode");
            }

            //TreeNode = selection.m_TreeNode;

            CurrentTreeNode = currentTreeNode;
            SelectionData   = selection;

            //DebugFix.Assert(m_SelectionData.m_TreeNode == TreeNode);

            ShortDescription = "Delete audio portion";
            LongDescription  = "Delete a portion of audio for a given treenode";

            ManagedAudioMedia manMedia = m_SelectionData.m_TreeNode.GetManagedAudioMedia();

            if (manMedia == null)
            {
                throw new NullReferenceException("m_SelectionData.m_TreeNode.GetManagedAudioMedia()");
            }
            OriginalManagedAudioMedia = manMedia.Copy();
            m_UsedMediaData.Add(OriginalManagedAudioMedia.AudioMediaData);

#if DEBUG
            DebugFix.Assert(manMedia.Duration.IsEqualTo(OriginalManagedAudioMedia.Duration));
#endif //DEBUG

            ChannelsProperty chProp = m_SelectionData.m_TreeNode.GetChannelsProperty();
            foreach (Channel ch in chProp.UsedChannels)
            {
                if (manMedia == chProp.GetMedia(ch))
                {
                    ChannelOfOriginalMedia = ch;
                    break;
                }
            }
            DebugFix.Assert(ChannelOfOriginalMedia != null);
            DebugFix.Assert(ChannelOfOriginalMedia is AudioChannel);
        }
Example #25
0
        public ManagedAudioMedia GetManagedAudioMedia()
        {
            AbstractAudioMedia media = GetAudioMedia();

            if (media != null &&
                media is ManagedAudioMedia &&
                ((ManagedAudioMedia)media).IsWavAudioMediaData)
            {
                DebugFix.Assert(((ManagedAudioMedia)media).HasActualAudioMediaData);

                return(media as ManagedAudioMedia);
            }
            return(null);
        }
Example #26
0
        public void VerifyTree(TreeNode rootNode)
        {
            if (!rootNode.Presentation.ChannelsManager.HasAudioChannel ||
                SourceChannel != rootNode.Presentation.ChannelsManager.GetOrCreateAudioChannel())
            {
                throw new Exception("The verification routine for the 'publish visitor' only works when the SourceChannel is the default audio channel of the Presentation !");
            }

            DebugFix.Assert(m_RootNode == null);
            DebugFix.Assert(m_TransientWavFileStream == null);
            DebugFix.Assert(m_TransientWavFileStreamRiffOffset == 0);

            verifyTree(rootNode, false, null);
        }
        public static string GetNodeXml_Flat(TreeNode node)
        {
            if (node == null)
            {
                return("");
            }

            string nodeName = GetTreeNodeName(node);
            string text     = GetTreeNodeTextExcerpt(node);
            string str1     = @"<";
            string str2     = @">";
            string str3     = @"/>";
            string str4     = @"</";

            int capacity = string.IsNullOrEmpty(nodeName) ? text.Length
                : (nodeName.Length +
                   (text.Length == 0 ?
                    str1.Length + str3.Length
                : str1.Length + str2.Length + text.Length + nodeName.Length + str4.Length + str2.Length
                   )
                   );
            StringBuilder strBuilder = new StringBuilder(capacity);

            if (string.IsNullOrEmpty(nodeName))
            {
                strBuilder.Append(text);
            }
            else
            {
                strBuilder.Append(str1);
                if (text.Length == 0)
                {
                    strBuilder.Append(nodeName);
                    strBuilder.Append(str3);
                }
                else
                {
                    strBuilder.Append(nodeName);
                    strBuilder.Append(str2);
                    strBuilder.Append(text);
                    strBuilder.Append(str4);
                    strBuilder.Append(nodeName);
                    strBuilder.Append(str2);
                }
            }

            DebugFix.Assert(strBuilder.Length == capacity);
            return(strBuilder.ToString());
        }
Example #28
0
        public static UglyPrettyName GetXukName(Type type)
        {
            Attribute attribute = Attribute.GetCustomAttribute(
                type,
                typeof(XukNameUglyPrettyAttribute));

            DebugFix.Assert(attribute != null);

            if (attribute == null)
            {
                return(null);
            }

            return(((XukNameUglyPrettyAttribute)attribute).Name);
        }
        private void OnUndoRedoManagerChanged_TextNodeStructureEditCommand(UndoRedoManagerEventArgs eventt, bool done, TextNodeStructureEditCommand command, bool isTransactionEndEvent, bool isNoTransactionOrTrailingEdge)
        {
            DebugFix.Assert(command is TreeNodeInsertCommand || command is TreeNodeRemoveCommand);

            //TreeNode node = (command is TreeNodeInsertCommand) ? ((TreeNodeInsertCommand)command).TreeNode : ((TreeNodeRemoveCommand)command).TreeNode;
            TreeNode node = command.TreeNode;

            bool forceInvalidate = (command is TreeNodeInsertCommand && !done) || (command is TreeNodeRemoveCommand && done);

            InvalidatePages(forceInvalidate, node);

            bool done_ = (command is TreeNodeInsertCommand) ? !done : done;

            checkTreeNodeFragmentRemoval(done_, node);
        }
        public InputSource ResolveEntity(string name, string publicId, string baseUri, string systemId)
        {
            string dtdUniqueResourceId;
            Stream dtdStream = LocalXmlUrlResolver.mapUri(new Uri(systemId, UriKind.Absolute), out dtdUniqueResourceId);

            if (!string.IsNullOrEmpty(dtdUniqueResourceId))
            {
                DebugFix.Assert(dtdStream != null);

                TextReader txtReader = new StreamReader(dtdStream, Encoding.UTF8);
                return(new InputSource <TextReader>(txtReader, systemId));

                //return new InputSource<Stream>(dtdStream, systemId);
            }

            return(null);
        }