Esempio n. 1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GlobalFileWritingSystemStore"/> class.
 /// </summary>
 /// <param name="path">The path.</param>
 public GlobalFileWritingSystemStore(string path)
 {
     m_path = path;
     Directory.CreateDirectory(m_path);
     m_mutex = SingletonsContainer.Get(typeof(Mutex).FullName + m_path,
                                       () => new Mutex(false, m_path.Replace('\\', '_').Replace('/', '_')));
 }
Esempio n. 2
0
        internal GlobalFileWritingSystemStore(string path)
        {
            m_path = path;
            if (!Directory.Exists(m_path))
            {
                DirectoryInfo di;

                // Provides FW on Linux multi-user access. Overrides the system
                // umask and creates the directory with the permissions "775".
                // The "fieldworks" group was created outside the app during
                // configuration of the package which allows group access.
                using (new FileModeOverride())
                {
                    di = Directory.CreateDirectory(m_path);
                }

                if (!MiscUtils.IsUnix)
                {
                    // NOTE: GetAccessControl/ModifyAccessRule/SetAccessControl is not implemented in Mono
                    DirectorySecurity ds = di.GetAccessControl();
                    var        sid       = new SecurityIdentifier(WellKnownSidType.BuiltinUsersSid, null);
                    AccessRule rule      = new FileSystemAccessRule(sid, FileSystemRights.Write | FileSystemRights.ReadAndExecute
                                                                    | FileSystemRights.Modify, InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit,
                                                                    PropagationFlags.InheritOnly, AccessControlType.Allow);
                    bool modified;
                    ds.ModifyAccessRule(AccessControlModification.Add, rule, out modified);
                    di.SetAccessControl(ds);
                }
            }
            m_mutex = SingletonsContainer.Get(typeof(Mutex).FullName + m_path,
                                              () => new Mutex(false, m_path.Replace('\\', '_').Replace('/', '_')));
        }
Esempio n. 3
0
        ///<summary>
        ///</summary>
        public static void Release()
        {
            if (!SingletonsContainer.Contains <LogFileImpl>())
            {
                return;
            }

            AddLine("----- LogFile Object Released -----");
            SingletonsContainer.Get <LogFileImpl>().Shutdown();
            SingletonsContainer.Remove(SingletonsContainer.Get <LogFileImpl>());
        }
Esempio n. 4
0
 private static void RetrieveDefaultWritingSystemsFromLift(string liftPath, out CoreWritingSystemDefinition wsVern,
                                                           out CoreWritingSystemDefinition wsAnalysis)
 {
     PerformLdmlMigrationInClonedLiftRepo(liftPath);
     using (var liftReader = new StreamReader(liftPath, Encoding.UTF8))
     {
         string vernWsId, analysisWsId;
         using (var reader = XmlReader.Create(liftReader))
             RetrieveDefaultWritingSystemIdsFromLift(reader, out vernWsId, out analysisWsId);
         var wsManager = new WritingSystemManager(SingletonsContainer.Get <CoreGlobalWritingSystemRepository>());
         wsManager.GetOrSet(vernWsId, out wsVern);
         wsManager.GetOrSet(analysisWsId, out wsAnalysis);
     }
 }
Esempio n. 5
0
 ///<summary>
 ///</summary>
 private static LogFileImpl GetLogFile()
 {
     return(SingletonsContainer.Get <LogFileImpl>());
 }
Esempio n. 6
0
        /// <summary/>
        public FwNewLangProjectModel(bool useMemoryWsManager = false)
        {
            WritingSystemManager = useMemoryWsManager ? new WritingSystemManager() : new WritingSystemManager(SingletonsContainer.Get <CoreGlobalWritingSystemRepository>());
            CoreWritingSystemDefinition englishWs;

            WritingSystemManager.GetOrSet("en", out englishWs);
            _allAnalysis.Add(englishWs);
            _curAnalysis.Add(englishWs);
            WritingSystemContainer = new MemoryWritingSystemContainer(_allAnalysis, _allVern, _curAnalysis, _curVernWss, _curPron);
        }
Esempio n. 7
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        ///
        /// </summary>
        /// <param name="e"></param>
        /// ------------------------------------------------------------------------------------
        private void Init(PrintPageEventArgs e)
        {
#if false
            long x1 = System.DateTime.Now.Ticks;
#endif
            // Set these now because the Graphics object will be locked below.
            m_rcDst = m_rcSrc = new Rect(0, 0, (int)e.Graphics.DpiX, (int)e.Graphics.DpiY);

            int dpix;
            if (MiscUtils.IsUnix)
            {
                dpix = 72;
            }
            else
            {
                dpix = (int)e.Graphics.DpiX;
            }

            m_dxpAvailWidth = PixelsFrom100ths(e.MarginBounds.Width, dpix);

            // Create and initialize a print context.
            m_vwPrintContext = VwPrintContextWin32Class.Create();

            // TODO: When we provide a way for the user to specify the nFirstPageNo (i.e. the
            // first argument to SetPagePrintInfo), then change the arguments to
            // SetPagePrintInfo.
            m_vwPrintContext.SetPagePrintInfo(1, 1, 65535, 1, false);
            SetMargins(e);

            IVwGraphics vwGraphics = VwGraphicsWin32Class.Create();
            IntPtr      hdc        = IntPtr.Zero;
            try
            {
                // Get the printer's hdc and use it to initialize other stuff.
                hdc = e.Graphics.GetHdc();
                ((IVwGraphicsWin32)vwGraphics).Initialize(hdc);
                m_vwPrintContext.SetGraphics(vwGraphics);

                // Make a rootbox for printing and initialize it.
                m_rootb = VwRootBoxClass.Create();
                m_rootb.RenderEngineFactory = SingletonsContainer.Get <RenderEngineFactory>();
                m_rootb.TsStrFactory        = TsStringUtils.TsStrFactory;
                m_rootb.SetSite(this);
                m_rootb.DataAccess = m_sda;
                m_rootb.SetRootObject(m_hvo, m_vc, m_frags, m_styleSheet);
                m_rootb.InitializePrinting(m_vwPrintContext);
                m_totalNumberOfPages = m_rootb.GetTotalPrintPages(m_vwPrintContext);
                m_psettings          = e.PageSettings.PrinterSettings;
                SetPrintRange();
            }
            catch (Exception ex)
            {
                m_rootb = null;

                throw new ContinuableErrorException("An error has occurred during the setup required for printing.", ex);
            }
            finally
            {
                if (hdc != IntPtr.Zero)
                {
                    vwGraphics.ReleaseDC();
                    e.Graphics.ReleaseHdc(hdc);
                }
            }
#if false
            long x2 = System.DateTime.Now.Ticks;
            Debug.WriteLine("PrintRootSite.Init() took " + DeltaTime(x1, x2) + " seconds.");
#endif
        }