Пример #1
0
        /// <summary>
        /// Updates both text boxes.  Applies lock icons to locked runs in the after box
        /// </summary>
        /// <param name="percent"></param>
        private void updateParagraphs(double percent)
        {
            currentPercent = percent;
            int newLength = (int)Math.Round(data.longestLength * percent);

            List <PatchSelection> selections = data.getPatchSelections(newLength);

            runMap = new Dictionary <Run, PatchSelection>();

            List <Run> beforeRuns = getOriginalRuns(selections);

            before.Inlines.Clear();
            before.Inlines.AddRange(beforeRuns);

            List <Run> afterRuns = getShortenedRuns(selections);

            after.Inlines.Clear();
            after.Inlines.AddRange(afterRuns);

            //The list of locked runs.  Must be dealt with later to avoid altering the collection we're iterating through
            List <Run> lockedRuns = new List <Run>();

            foreach (Inline inline in after.Inlines)
            {
                if (!(inline is Run))
                {
                    continue;
                }
                Run tempRun = inline as Run;

                if ((runMap[tempRun].patch as ShortnPatch).isLocked)
                {
                    lockedRuns.Add(tempRun);
                }
            }
            // Add the lock icon to the locked runs
            foreach (Run run in lockedRuns)
            {
                Image       img = new Image();
                BitmapImage bmi = new BitmapImage(new Uri(Soylent.GetAppDirectory() + @"lock.png"));
                img.Source = bmi;
                img.Height = 9;
                img.Width  = 9;

                InlineUIContainer iuc = new InlineUIContainer(img, run.ContentEnd); // Can kill Word if that run.TextPointer is not currently displayed

                iuc.ContextMenu = run.ContextMenu;
                iuc.Cursor      = Cursors.Hand;
                iuc.MouseUp    += new MouseButtonEventHandler(lockClickHandler);
            }
        }
Пример #2
0
        public JobManager()
        {
            // Search the active-hits directory to find the most recent job number
            DirectoryInfo activeHits = new DirectoryInfo(Soylent.GetDataDirectory() + @"active-hits\");

            FileInfo[] hits = activeHits.GetFiles(@"*.data.js");

            foreach (FileInfo file in hits)
            {
                Regex jobnumber   = new Regex(@"(shortn|crowdproof|macro).(?<jobNumber>\d{1,}).data.js");
                Match regexResult = jobnumber.Match(file.Name);
                int   thisJob     = int.Parse(regexResult.Groups["jobNumber"].Value);

                lastJob = Math.Max(thisJob, lastJob);
            }
        }
Пример #3
0
        public static AmazonKeys LoadAmazonKeys()
        {
            string rootDirectory = Soylent.GetDataDirectory();
            string keyFile       = rootDirectory + @"\amazon.xml";


            if (!File.Exists(keyFile))
            {
                return(null);
            }
            else
            {
                AmazonKeys keys = getKeysFromFile(keyFile);
                return(keys);
            }
        }
Пример #4
0
        public static void SetAmazonKeys(string key, string secret)
        {
            string rootDirectory = Soylent.GetDataDirectory();

            StreamReader reader  = new StreamReader(rootDirectory + "amazon.template.xml");
            string       content = reader.ReadToEnd();

            reader.Close();

            content = Regex.Replace(content, "AmazonKeyHere", key);
            content = Regex.Replace(content, "AmazonSecretHere", secret);

            StreamWriter writer = new StreamWriter(rootDirectory + "amazon.xml", false);

            writer.Write(content);
            writer.Close();
        }