Example #1
0
 void Start()
 {
     audioSetup();
     welcomePanel.SetActive(true);
     welcomePhrase = "when the stars begin to shine, pharaohs breathe from the underworld\n....... ";
     StartCoroutine(showText(welcomePhrase, welcomeText));
     GroupID           = GameManager.getGroupID();
     artifacts         = 0;
     artifactText.text = "ARTIFACTS   0";
     progressPanel.SetActive(false);
     startStringUp  = "____ __ ";
     finalStringUp  = "rise of ";
     startString    = "________";
     finalString    = "PHARAOHS";
     NameText2.text = startString;
     NameText1.text = startStringUp;
     IndexObject.SetActive(true);
     IndexObject.GetComponentInChildren <TextMeshProUGUI>().text = GameManager.getName(int.Parse(GameManager.getIndexNo())) + "\n" + GameManager.getIndexNo();
     if (GameManager.getGender(int.Parse(GameManager.getIndexNo())) == 'F')
     {
         profPic.sprite = FemaleProfPic;
     }
     else
     {
         profPic.sprite = MaleProfPic;
     }
 }
Example #2
0
        public Concerts Post([FromBody] Concerts concert)
        {
            Concerts returnConcert = null;

            using (SqlConnection conn = new SqlConnection(_dbOptions.Value.ConnectionString))
            {
                try
                {
                    conn.Open();
                    string insertSql = "INSERT INTO Concerts(ArtistId, VenueId, CalendarDate, Price)" +
                                       "VALUES(@ArtistId, @VenueId, @CalendarDate, @Price);";
                    conn.Execute(insertSql, concert);
                }
                catch (SqlException exc)
                {
                    Console.WriteLine(exc.Message);
                }

                string   selectSql    = "SELECT * FROM Concerts WHERE ArtistId = @ArtistId AND VenueId = @VenueId AND CalendarDate = @CalendarDate;";
                Concerts indexConcert = conn.Query <Concerts>(selectSql, concert).FirstOrDefault();
                returnConcert = indexConcert;

                if (indexConcert != null)
                {
                    _client.IndexDocument(indexConcert);

                    string      mainIndexSql = "SELECT * FROM ConcertIndexView WHERE ConcertId = @concertId;";
                    IndexObject mainIndex    = conn.Query <IndexObject>(mainIndexSql, new { indexConcert.ConcertId }).FirstOrDefault();

                    _client.IndexDocument(mainIndex);
                }
            }

            return(returnConcert);
        }
 void Start()
 {
     source      = this.GetComponent <AudioSource>();
     source.clip = egypt1;
     source.Play();
     fullText        = "you belong to the followers of";
     loadingfullText = " 0 0 0 0 0";
     imageTargetname = "ImageTarget";
     GroupID         = GameManager.getGroupID();
     if (GroupID > 0)
     {
         myGod = GameManager.getGodInfo(GroupID);
     }
     IndexObject.SetActive(true);
     IndexObject.GetComponentInChildren <TextMeshProUGUI>().text = GameManager.getName(int.Parse(GameManager.getIndexNo())) + "\n" + GameManager.getIndexNo();
     if (GameManager.getGender(int.Parse(GameManager.getIndexNo())) == 'F')
     {
         profPic.sprite = FemaleProfPic;
     }
     else
     {
         profPic.sprite = MaleProfPic;
     }
     allDeactive();
     activateFactions();
     button.gameObject.SetActive(false);
     StartCoroutine(showText(fullText, topText));
     trackingStatus = "TRACKED";
     StatusChanger();
 }
Example #4
0
        public string Purchase(int id, [FromBody] Customers customer)
        {
            Concerts concert = null;

            using (SqlConnection conn = new SqlConnection(_dbOptions.Value.ConnectionString))
            {
                try
                {
                    conn.Open();
                    string concertSelect = "SELECT * FROM Concerts WHERE ConcertId = @concertId;";
                    concert = conn.Query <Concerts>(concertSelect, new { concertId = id }).FirstOrDefault <Concerts>();

                    string customerSelect = "SELECT * FROM Customers WHERE CustomerId = @customerId;";
                    customer = conn.Query <Customers>(customerSelect, new { customerId = customer.CustomerId }).FirstOrDefault <Customers>();
                }
                catch (SqlException exc)
                {
                    Console.WriteLine(exc.Message);
                }
            }

            if (concert.Price > customer.Currency)
            {
                return("poor");
            }
            else
            {
                using (SqlConnection conn = new SqlConnection(_dbOptions.Value.ConnectionString))
                {
                    try
                    {
                        conn.Open();
                        conn.Execute("SP_Purchase", new { concertId = concert.ConcertId, customerId = customer.CustomerId }, commandType: CommandType.StoredProcedure);
                    }
                    catch (SqlException exc)
                    {
                        Console.WriteLine(exc.Message);
                    }

                    string   selectSql    = "SELECT * FROM Concerts WHERE ArtistId = @ArtistId AND VenueId = @VenueId AND CalendarDate = @CalendarDate;";
                    Concerts indexConcert = conn.Query <Concerts>(selectSql, concert).FirstOrDefault();

                    string      selectIndexSql = "SELECT * FROM ConcertIndexView WHERE ConcertId = @ConcertId;";
                    IndexObject indexObject    = conn.Query <IndexObject>(selectIndexSql, new { indexConcert.ConcertId }).FirstOrDefault();

                    string    selectCustomerSql = "SELECT * FROM Customers WHERE CustomerId = @CustomerId;";
                    Customers indexCustomer     = conn.Query <Customers>(selectCustomerSql, new { customer.CustomerId }).FirstOrDefault();

                    if (indexConcert != null)
                    {
                        _client.IndexDocument <Concerts>(indexConcert);
                        _client.IndexDocument <Customers>(indexCustomer);
                        _client.IndexDocument <IndexObject>(indexObject);
                    }
                }

                return("done");
            }
        }
Example #5
0
        public Search.Models.IndexObject GetIndexObject(object o)
        {
            IndexObject indexObject = null;

            Page page = (Page)o;
            NameValueCollection storeFields = new NameValueCollection();
            NameValueCollection sysFields   = new NameValueCollection();

            sysFields.Add("SiteName", page.Site.FullName);
            sysFields.Add("PageName", page.FullName);

            string        title = "";
            StringBuilder body  = new StringBuilder();

            if (page.HtmlMeta != null && !string.IsNullOrEmpty(page.HtmlMeta.HtmlTitle))
            {
                title = page.HtmlMeta.HtmlTitle;
            }
            if (!string.IsNullOrEmpty(page.ContentTitle))
            {
                body.AppendFormat(title);

                title = page.ContentTitle;
            }

            if (page.PagePositions != null)
            {
                foreach (var item in page.PagePositions.Where(it => (it is HtmlBlockPosition) || (it is HtmlPosition)))
                {
                    if (item is HtmlBlockPosition)
                    {
                        HtmlBlockPosition htmlBlockPosition = (HtmlBlockPosition)item;
                        var htmlBlock = new HtmlBlock(page.Site, htmlBlockPosition.BlockName).LastVersion().AsActual();
                        if (htmlBlock != null)
                        {
                            body.Append(" " + Kooboo.Extensions.StringExtensions.StripAllTags(htmlBlock.Body));
                        }
                    }
                    else
                    {
                        HtmlPosition htmlPosition = (HtmlPosition)item;
                        body.Append(" " + Kooboo.Extensions.StringExtensions.StripAllTags(htmlPosition.Html));
                    }
                }
            }


            indexObject = new IndexObject()
            {
                Title        = title,
                Body         = body.ToString(),
                StoreFields  = storeFields,
                SystemFields = sysFields,
                NativeType   = typeof(Page).AssemblyQualifiedNameWithoutVersion()
            };

            return(indexObject);
        }
Example #6
0
        private int DeleteJunctions(string directoryName, out string[] pathTooLong)
        {
            var ptl       = new List <string>();
            var directory = new DirectoryInfo(directoryName);

            if (directory.Attributes.HasFlag(FileAttributes.ReparsePoint))
            {
                if (Verbose)
                {
                    Console.WriteLine(string.Format("Deleting Junction {0}", directory));
                }
                directory.Delete();
                pathTooLong = ptl.ToArray();
                return(1);
            }
            var dirCount = new IndexObject();

            string[] subDirs;

            try
            {
                subDirs = directory.GetDirectories().Select(d =>
                {
                    try
                    {
                        return(d.FullName);
                    }
                    catch (PathTooLongException)
                    {
                        ptl.Add(directoryName);
                        return(null);
                    }
                }
                                                            ).Where(d => !string.IsNullOrWhiteSpace(d)).ToArray();
            }
            catch (PathTooLongException)
            {
                ptl.Add(directoryName);
                subDirs = new string[0];
            }

            foreach (var dir in subDirs)
            {
                string[] subptl;
                var      count = DeleteJunctions(dir, out subptl);
                lock (dirCount)
                    dirCount.Count += count;
                ptl.AddRange(subptl);
            }
            pathTooLong = ptl.ToArray();
            return(dirCount.Count);
        }
Example #7
0
        //protected KeyValuePair<string, string> this[int index] { get { return _lstIndexes.ElementAt(index); } } Never used, if needed should be changed to
        //return Value and not the <key,index>-pair.

        #region IDisposable Members

        public void Dispose()
        {
            _file.Close();
            _file.Dispose();

            _lstIndexes.Clear();
            _lstIndexes = null;

            emptyFileSpots.Clear();
            emptyFileSpots = null;

            lastFilledIndex = null;
        }
Example #8
0
        public Concerts Cancel(int id)
        {
            Concerts    returnConcert = null;
            IndexObject indexObject   = null;

            using (SqlConnection conn = new SqlConnection(_dbOptions.Value.ConnectionString))
            {
                try
                {
                    conn.Open();

                    conn.Execute("SP_CancelConcert", new { concertId = id }, commandType: CommandType.StoredProcedure);

                    string selectSql = "SELECT * FROM Concerts WHERE ConcertId = @ConcertId;";
                    returnConcert = conn.Query <Concerts>(selectSql, new { ConcertId = id }).FirstOrDefault();

                    string selectIndexSql = "SELECT * FROM ConcertIndexView WHERE ConcertId = @ConcertId;";
                    indexObject = conn.Query <IndexObject>(selectIndexSql, new { concertId = id }).FirstOrDefault();
                }
                catch (SqlException exc)
                {
                    Console.WriteLine(exc.Message);
                }
            }
            if (returnConcert != null)
            {
                _client.IndexDocument <Concerts>(returnConcert);
                _client.IndexDocument <IndexObject>(indexObject);

                _client.Indices.Delete("customers");

                using (SqlConnection conn = new SqlConnection(_dbOptions.Value.ConnectionString))
                {
                    try
                    {
                        conn.Open();
                        var customers = conn.Query <Customers>("SELECT * FROM Customers WHERE IsActive = 1;");
                        _client.Bulk(request => request
                                     .Index("customers")
                                     .IndexMany <Customers>(customers));
                    }
                    catch (SqlException exc)
                    {
                        Console.WriteLine(exc.Message);
                    }
                }
            }

            return(returnConcert);
        }
Example #9
0
        /// <summary>
        /// Any adjacent empty slots are turned into one big slot.
        /// Empty slots after lastFilledIndex are removed.
        ///
        /// Add method will have to split large empty slots.
        /// This method should be called after removing or moving an
        /// element.
        /// </summary>
        private void ConcatenateEmptySlots()
        {
            //Find adjacent spots and concatenate them:
            SortedList <long, IndexObject> newList = new SortedList <long, IndexObject>();
            IndexObject newIndexObject;

            //Edge case all should be removed:
            var keyValPair = emptyFileSpots.FirstOrDefault();

            if (keyValPair.Key >= lastFilledIndex.FilePosition)
            {
                emptyFileSpots = newList;
            }
            else //Normal case all should be removed:
            {
                int j = 1;
                for (int i = 0; i < emptyFileSpots.Count; i++)
                {
                    //Remove spot if after lastFilled and reset file length:
                    if (i + 1 >= emptyFileSpots.Count || emptyFileSpots.ElementAt(i + 1).Key >= lastFilledIndex.FilePosition)
                    {
                        newList.Add(emptyFileSpots.ElementAt(i).Key, emptyFileSpots.ElementAt(i).Value);
                        //File length is reset in method "UpdateLastFilledIndex()".
                        break; //All else will be after file end and hence removed.
                    }

                    //Concatenation:
                    newIndexObject = emptyFileSpots.ElementAt(i).Value;
                    while (i + j < emptyFileSpots.Count
                           &&
                           newIndexObject.FilePosition + newIndexObject.FileSpotLength ==
                           emptyFileSpots.ElementAt(i + j).Key)
                    {
                        newIndexObject = new IndexObject
                        {
                            ElementLength  = 0,
                            FilePosition   = newIndexObject.FilePosition,
                            FileSpotLength =
                                newIndexObject.FileSpotLength + emptyFileSpots.ElementAt(i + j).Value.FileSpotLength,
                        };
                        j++;
                    }
                    i += j; //Skip the indices added to this one empty file spot.
                    j  = 1; //Reset j.
                    newList.Add(newIndexObject.FilePosition, newIndexObject);
                }

                emptyFileSpots = newList;
            }
        }
Example #10
0
        public void SortWithProperty()
        {
            IndexObject[] objetSet = new IndexObject[] {
                new IndexObject {
                    Id = "eins", Index = 2
                },
                new IndexObject {
                    Id = "zwei", Index = 0
                },
                new IndexObject {
                    Id = "drei", Index = 1
                }
            };

            LinearList <IndexObject> list = new LinearList <IndexObject>(objetSet);

            list.Sort(item => item.Index);

            IndexObject[] sortedSet = list.ToArray();
            CollectionAssert.AreEqual(new IndexObject[] { objetSet[1], objetSet[2], objetSet[0] }, sortedSet);
        }
Example #11
0
 /// <summary>
 /// Sets the lastFilledIndex to be equal to the item in lstIndexes with the maximum file position.
 /// This method is heavy, cycling through all lstIndexes elements.
 /// </summary>
 private void UpdateLastFilledIndex()
 {
     if (_lstIndexes == null || _lstIndexes.Count == 0)
     {
         lastFilledIndex = null;
     }
     else
     {
         long        newLastPosition = Int64.MinValue;
         IndexObject newLast         = null;
         foreach (var keyIndexPair in _lstIndexes)
         {
             if (keyIndexPair.Value.FilePosition > newLastPosition)
             {
                 newLast         = keyIndexPair.Value;
                 newLastPosition = keyIndexPair.Value.FilePosition;
             }
         }
         lastFilledIndex = newLast;
         _file.SetLength(lastFilledIndex != null ? lastFilledIndex.FilePosition + lastFilledIndex.FileSpotLength : 0);
     }
 }
Example #12
0
        public override Index Decode(XElement data)
        {
            List <XElement> nodes = data.Descendants().ToList();

            nodes.Sort(CompareElements);
            Dictionary <string, IndexElement> elements = new Dictionary <string, IndexElement>();

            while (nodes.Count > 0)
            {
                XElement el = nodes[0];
                nodes.RemoveAt(0);
                switch (el.Name.LocalName.ToLower())
                {
                case "import":
                    XDocument doc = XDocument.Load("Resources/" + el.Attribute("file").Value);
                    nodes.AddRange(doc.Root.Descendants());
                    nodes.Sort(CompareElements);
                    break;

                case "class":
                    IndexClass c = classEncoder.Decode(el);
                    elements.Add(c.id, c);
                    break;

                case "verb":
                    IndexVerb v = verbEncoder.Decode(el);
                    elements.Add(v.id, v);
                    break;

                case "obj":
                    IndexObject o = objEncoder.Decode(el);
                    elements.Add(o.id, o);
                    break;

                default: throw new NotImplementedException();
                }
            }
        }
Example #13
0
        private int DeleteEmptyDirectories(DirectoryInfo directory)
        {
            var emptyDirCount = new IndexObject();

            foreach (var dir in directory.GetDirectories())
            {
                var count = DeleteEmptyDirectories(dir);
                lock (emptyDirCount)
                    emptyDirCount.Count += count;
            }
            var emptyDirectoriesDeleted = emptyDirCount.Count;

            if (!directory.GetFileSystemInfos().Any())
            {
                if (Verbose)
                {
                    Console.WriteLine(string.Format("Deleting empty directory {0}", directory));
                }
                directory.Delete(false);
                emptyDirectoriesDeleted++;
            }
            return(emptyDirectoriesDeleted);
        }
Example #14
0
        /// <summary>
        /// Overwrites the old file location with spaces.
        /// Moves the old Index to the empty indices list.
        /// Checks if lastFilledIndex should be updated/does it.
        ///
        /// Saves all indexing information to disk via the update
        /// indexes method.
        /// </summary>
        public virtual void Remove(string key)
        {
            //Requires logic
            IndexObject indexObject;

            if (String.IsNullOrEmpty(key) || !_lstIndexes.TryGetValue(key, out indexObject))
            {
                return; //Maintain silence.
            }
            _lstIndexes.Remove(key);

            //Update the position of the index/length in the list:
            emptyFileSpots.Add(indexObject.FilePosition,
                               new IndexObject
            {
                ElementLength  = 0,
                FilePosition   = indexObject.FilePosition,
                FileSpotLength = indexObject.FileSpotLength
            });

            ConcatenateEmptySlots();

            if (lastFilledIndex != null && lastFilledIndex.FilePosition == indexObject.FilePosition)
            {
                lastFilledIndex = null;
            }

            if (lastFilledIndex == null)
            {
                UpdateLastFilledIndex();
            }

            UpdateIndexFiles();

            //Clear old spot.
            WriteToFile(indexObject.FilePosition, null, indexObject.FileSpotLength);
        }
Example #15
0
        /// <summary>
        /// Method for finding the nearest to start empty slot. Otherwise returns null.
        /// Method will split slot if it is large.
        /// If the empty slots list is changed call concatenate empty slots method.
        /// </summary>
        private IndexObject FindAndSplitExistingEmptySpot(int minLength, int expectedUsageLength = -1)
        {
            if ((minLength <= 0 && expectedUsageLength <= 0) || emptyFileSpots == null)
            {
                return(null);
            }

            int len = Math.Max(Math.Max(minLength, expectedUsageLength), averageElementLength);

            for (int i = 0; i < emptyFileSpots.Count; i++)
            {
                var tempValue = emptyFileSpots.ElementAt(i).Value;
                if (tempValue.FileSpotLength >= len)
                {
                    if (tempValue.FileSpotLength - len <= averageElementLength * 2)
                    {
                        return(tempValue);
                    }
                    else //Split large spot:
                    {
                        IndexObject newSpot = new IndexObject
                        {
                            FilePosition   = tempValue.FilePosition + len,
                            ElementLength  = 0,
                            FileSpotLength = tempValue.FileSpotLength - len
                        };
                        emptyFileSpots.Add(newSpot.FilePosition, newSpot);
                        tempValue.FileSpotLength = len;
                        emptyFileSpots[i]        = tempValue;
                        return(tempValue);
                    }
                }
            }

            return(null);
        }
Example #16
0
        public override bool Execute()
        {
            try
            {
                var repoRoot = FindRepoRoot(new DirectoryInfo(BaseDirectory));
                if (repoRoot == null)
                {
                    Console.Error.WriteLine("Must be in a mercurial repository.");
                    return(false);
                }
                string[] pathTooLong;
                var      junctionsDeleted = DeleteJunctions(repoRoot.FullName, out pathTooLong);
                Console.WriteLine("Deleted {0} junctions.", junctionsDeleted);
                var directoriesDeleted = DeleteTooLong(repoRoot.FullName, pathTooLong);

                var hgIgnoreFile  = repoRoot.GetFiles(".hgignore").Where(f => f.Exists && f.Name.Equals(".hgignore", StringComparison.InvariantCultureIgnoreCase)).Select(f => f.FullName).SingleOrDefault();
                var tmpIgnoreFile = Path.Combine(repoRoot.FullName, string.Format("{0}.hgignore", Guid.NewGuid()));

                if (hgIgnoreFile != null)
                {
                    File.Move(hgIgnoreFile, tmpIgnoreFile);
                }

                const string hgExe = "hg";
                var          files = GetHgStatFiles(hgExe, repoRoot, tmpIgnoreFile).ToArray();

                if (hgIgnoreFile != null)
                {
                    File.Move(tmpIgnoreFile, hgIgnoreFile);
                }

                var fileCount       = new IndexObject();
                var filePathTooLong = files.Where(f => f.Length >= 248).ToArray();
                directoriesDeleted += DeleteTooLong(repoRoot.FullName, filePathTooLong);
                Console.WriteLine("Deleted {0} total directories with path names too long", directoriesDeleted);

                files.AsParallel().ForAll(file =>
                {
                    if (!File.Exists(file))
                    {
                        return;
                    }
                    if (Verbose)
                    {
                        Console.WriteLine(string.Format("Deleting {0}", file));
                    }
                    File.Delete(file);
                    lock (fileCount)
                        fileCount.Count++;
                });

                Console.WriteLine(string.Format("Deleted {0} files.", fileCount.Count));
                ExecuteRevertAll(hgExe, repoRoot);

                var emptyDirectories = DeleteEmptyDirectories(repoRoot);
                Console.WriteLine(string.Format("Deleted {0} empty directories.", emptyDirectories));
            }
            catch (Exception ex)
            {
                Console.Error.WriteLine(ex);
                return(false);
            }
            return(true);
        }
Example #17
0
        /// <summary>
        /// 初始化PPT呈现线程
        /// </summary>
        /// <returns></returns>
        private static Thread InitPPTRenderThread()
        {
            var pptRenderThread = new Thread(() =>
            {
                // 第一次
                Thread thread = InitCaptureThread(_objPres);

                try
                {
                    if (_slide_index == -1)
                    {
                        _slide_index = 1;
                        _objPres.SlideShowWindow.View.First();
                        _objPres.SlideShowWindow.View.GotoSlide(1);
                        _objPres.SlideShowWindow.View.ResetSlideTime();

                        // 前一个全局索引等于_index
                        _prev_index = _index;

                        _indexs.Add(_index, new IndexObject()
                        {
                            SlideIndex = _slide_index,
                            ViewIndex  = _view_index
                        });

                        thread.Start();
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }

                while (true)
                {
                    try
                    {
                        // 等待3秒
                        Thread.Sleep(deplyTime);

                        if (thread.ThreadState == ThreadState.Running ||
                            thread.ThreadState != ThreadState.Unstarted)
                        {
                            _view_index++;

                            thread.Abort();
                            thread = InitCaptureThread(_objPres);

                            // 前一个全局索引等于_index
                            _prev_index = _index;

                            // 启动之前,保存索引信息
                            _indexs.Add(_index, new IndexObject()
                            {
                                SlideIndex = _slide_index,
                                ViewIndex  = _view_index
                            });

                            thread.Start();
                        }

                        // 下一个动画页面
                        _objPres.SlideShowWindow.View.Next();

                        if (_slide_index != -1)
                        {
                            // 获取当前PPT索引,第几张PPT
                            _slide_index = _objPres.SlideShowWindow.View.Slide.SlideIndex;

                            if (_prev_slide_index != _slide_index)
                            {
                                _view_index       = 1;
                                _prev_slide_index = _slide_index;

                                // 修改前一个全局索引对应的值
                                _indexs[_prev_index] = new IndexObject()
                                {
                                    SlideIndex = _slide_index,
                                    ViewIndex  = _view_index
                                };
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                    }
                }
            });

            pptRenderThread.Priority = ThreadPriority.Highest;

            return(pptRenderThread);
        }
 public abstract IdxAccesser Create(IndexObject dsObj);
 public override IdxAccesser Create(IndexObject dsObj)
 {
     return new IdxMongoAccesser(dsObj);
 }
        private ScatterViewItem getItemView(IndexObject indexedItem, String deviceName)
        {
            if (indexedItem == null)
            {
                return null;
            }

            DEVICE_ID = DEVICE_ID.Equals("") ? indexedItem.deviceId : DEVICE_ID;

            ScatterViewItem item = new ScatterViewItem();
            //Set properties
            //item.Center = startingPosition;
            item.MinWidth = 250;
            //item.MaxWidth = 600;
            item.MinHeight = 120;
            item.Background = SurfaceColors.ScatterViewItemBackgroundBrush;

            /*
            if (indexedItem.name.Substring(0,1).Equals("."))
            {
                item.Visibility = Visibility.Collapsed;
            }
            */

            //Add grid view for sub-directory list
            Grid subDirectoryList = new Grid();
            subDirectoryList.ColumnDefinitions.Add(new ColumnDefinition());
            subDirectoryList.RowDefinitions.Add(new RowDefinition());
            subDirectoryList.Name = "subDirectoryList";

            Label device_name = new Label();
            device_name.Name = "deviceName";
            device_name.Content = deviceName;
            device_name.HorizontalContentAlignment = HorizontalAlignment.Center;
            device_name.VerticalContentAlignment = VerticalAlignment.Center;
            device_name.Height = 40;

            Label path = new Label();
            path.Name = "path";
            path.Content = indexedItem.fullPath;
            path.MaxHeight = 0;
            path.Visibility = Visibility.Collapsed;

            Label deviceId = new Label();
            deviceId.Name = "deviceId";
            deviceId.Content = DEVICE_ID;
            deviceId.HorizontalContentAlignment = HorizontalAlignment.Center;
            deviceId.VerticalContentAlignment = VerticalAlignment.Center;
            deviceId.MaxHeight = 0;
            deviceId.Visibility = Visibility.Collapsed;

            SurfaceButton sb = new SurfaceButton();
            //Style the buttons
            sb.Name = "button";
            sb.MinHeight = 30;
            sb.HorizontalContentAlignment = HorizontalAlignment.Stretch;
            sb.VerticalContentAlignment = VerticalAlignment.Center;
            sb.Background = Brushes.DodgerBlue;
            sb.FontWeight = FontWeights.UltraBold;
            sb.Foreground = Brushes.WhiteSmoke;

            Console.WriteLine(indexedItem.type);

            if (indexedItem.type.Equals("DIR"))
            {
                sb.Content = indexedItem.parent + "/" + indexedItem.name + "      >>";
            }
            else
            {
                sb.Content = "File : " + indexedItem.parent + "/" + indexedItem.name;
            }

            sb.Click += new RoutedEventHandler(this.open);

            //Grid view to hold all the UI elements inside scatterViewitem
            Grid grid = new Grid();

            grid.ColumnDefinitions.Add(new ColumnDefinition());
            RowDefinition deviceNameRow = new RowDefinition();
            deviceNameRow.MaxHeight = 0;
            grid.RowDefinitions.Add(deviceNameRow);

            //Row def for button
            RowDefinition button_def = new RowDefinition();
            button_def.MaxHeight = 35;
            grid.RowDefinitions.Add(button_def);

            //Row def for subdirectory list
            grid.RowDefinitions.Add(new RowDefinition());
            RowDefinition hiddenRow = new RowDefinition();
            hiddenRow.MaxHeight = 0;
            RowDefinition hiddenRow1 = new RowDefinition();
            hiddenRow1.MaxHeight = 0;

            grid.RowDefinitions.Add(hiddenRow);
            grid.RowDefinitions.Add(hiddenRow1);

            Grid.SetColumn(device_name, 0);
            Grid.SetRow(device_name, 0);
            Grid.SetColumn(sb, 0);
            Grid.SetRow(sb, 1);
            Grid.SetColumn(subDirectoryList, 0);
            Grid.SetRow(subDirectoryList, 2);
            Grid.SetColumn(path, 0);
            Grid.SetRow(path, 3);
            Grid.SetColumn(deviceId, 0);
            Grid.SetRow(deviceId, 4);

            grid.Children.Add(device_name);
            grid.Children.Add(subDirectoryList);
            grid.Children.Add(sb);
            grid.Children.Add(path);
            grid.Children.Add(deviceId);

            item.Content = grid;

            return item;
        }
Example #21
0
        /// <summary>
        /// 初始化PPT呈现线程
        /// </summary>
        /// <returns></returns>
        private static Thread InitPPTRenderThread()
        {
            var pptRenderThread = new Thread(() =>
                {
                    // 第一次
                    Thread thread = InitCaptureThread(_objPres);

                    try
                    {
                        if (_slide_index == -1)
                        {
                            _slide_index = 1;
                            _objPres.SlideShowWindow.View.First();
                            _objPres.SlideShowWindow.View.GotoSlide(1);
                            _objPres.SlideShowWindow.View.ResetSlideTime();

                            // 前一个全局索引等于_index
                            _prev_index = _index;

                            _indexs.Add(_index, new IndexObject()
                                {
                                    SlideIndex = _slide_index,
                                    ViewIndex = _view_index
                                });

                            thread.Start();
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                    }

                    while (true)
                    {
                        try
                        {
                            // 等待3秒
                            Thread.Sleep(deplyTime);

                            if (thread.ThreadState == ThreadState.Running
                                || thread.ThreadState != ThreadState.Unstarted)
                            {
                                _view_index++;

                                thread.Abort();
                                thread = InitCaptureThread(_objPres);

                                // 前一个全局索引等于_index
                                _prev_index = _index;

                                // 启动之前,保存索引信息
                                _indexs.Add(_index, new IndexObject()
                                {
                                    SlideIndex = _slide_index,
                                    ViewIndex = _view_index
                                });

                                thread.Start();
                            }

                            // 下一个动画页面
                            _objPres.SlideShowWindow.View.Next();

                            if (_slide_index != -1)
                            {
                                // 获取当前PPT索引,第几张PPT
                                _slide_index = _objPres.SlideShowWindow.View.Slide.SlideIndex;

                                if (_prev_slide_index != _slide_index)
                                {
                                    _view_index = 1;
                                    _prev_slide_index = _slide_index;

                                    // 修改前一个全局索引对应的值
                                    _indexs[_prev_index] = new IndexObject()
                                        {
                                            SlideIndex = _slide_index,
                                            ViewIndex = _view_index
                                        };
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.Message);
                        }
                    }
                });

            pptRenderThread.Priority = ThreadPriority.Highest;

            return pptRenderThread;
        }
Example #22
0
        private void Init()
        {
            bool needsSave = false;

            using (FileStream fs = new FileStream(_indexFile, FileMode.OpenOrCreate, FileAccess.ReadWrite))
            {
                if (fs.Length < 1)
                {
                    _lstIndexes = new Dictionary <string, IndexObject>();
                    needsSave   = true;
                }
                else
                {
                    BinaryFormatter bin = new BinaryFormatter();
                    _lstIndexes = JsonConvert.DeserializeObject <Dictionary <string, IndexObject> >(bin.Deserialize(fs) as string);
                }
            }

            using (FileStream fs = new FileStream(_emptyFileSpots, FileMode.OpenOrCreate, FileAccess.ReadWrite))
            {
                if (fs.Length < 1)
                {
                    emptyFileSpots = new SortedList <long, IndexObject>();
                    needsSave      = true;
                }
                else
                {
                    BinaryFormatter bin = new BinaryFormatter();
                    emptyFileSpots = JsonConvert.DeserializeObject <SortedList <long, IndexObject> >(bin.Deserialize(fs) as string);
                }
            }

            using (FileStream fs = new FileStream(_lastIndexFile, FileMode.OpenOrCreate, FileAccess.ReadWrite))
            {
                if (fs.Length < 1)
                {
                    UpdateLastFilledIndex();
                    needsSave = true;
                }
                else
                {
                    BinaryFormatter bin = new BinaryFormatter();
                    lastFilledIndex = JsonConvert.DeserializeObject <IndexObject>(bin.Deserialize(fs) as string);
                }
            }

            using (FileStream fs = new FileStream(_averageLengthFile, FileMode.OpenOrCreate, FileAccess.ReadWrite))
            {
                if (fs.Length < 1)
                {
                    averageElementLength = defaultAverageElementLength;
                    needsSave            = true;
                }
                else
                {
                    BinaryFormatter bin = new BinaryFormatter();
                    averageElementLength = JsonConvert.DeserializeObject <int?>(bin.Deserialize(fs) as string) ?? defaultAverageElementLength;
                }
            }

            using (FileStream fs = new FileStream(_typeFile, FileMode.OpenOrCreate, FileAccess.ReadWrite))
            {
                if (fs.Length < 1)
                {
                    typeInfo = null;
                }
                else
                {
                    BinaryFormatter bin = new BinaryFormatter();
                    typeInfo = bin.Deserialize(fs) as string;
                }
            }

            if (needsSave)
            {
                UpdateIndexFiles();
            }
        }
Example #23
0
        public virtual IndexObject GetIndexObject(object o)
        {
            IndexObject indexObject = null;

            TextContent         textContent = (TextContent)o;
            NameValueCollection storeFields = new NameValueCollection();
            NameValueCollection sysFields   = new NameValueCollection();

            var repository = textContent.GetRepository();
            var schema     = textContent.GetSchema().AsActual();
            var folder     = textContent.FolderName;

            var folderSearchSetting = SearchSettingProvider.Get(new SearchSetting(repository, folder));

            if (folderSearchSetting != null)
            {
                string        title       = textContent.GetSummary();
                StringBuilder bodyBuilder = new StringBuilder();
                foreach (var key in textContent.Keys)
                {
                    var column = schema[key];
                    // If column == null, then it could be a system field.
                    var isSystemField = column == null || column.IsSystemField;
                    var index         = !isSystemField;

                    var value = textContent[key];

                    string strValue   = "";
                    string indexValue = "";
                    if (value != null)
                    {
                        if (value is DateTime)
                        {
                            var rawValue = (DateTime)value;
                            strValue   = rawValue.Ticks.ToString();
                            indexValue = rawValue.ToString();
                        }
                        else
                        {
                            indexValue = strValue = value.ToString();
                        }
                    }
                    if (index && !column.Summarize)
                    {
                        bodyBuilder.AppendFormat(" {0} ", Kooboo.StringExtensions.StripAllTags(indexValue.ToString()));
                    }

                    if (isSystemField)
                    {
                        sysFields[key] = strValue;
                    }
                    else
                    {
                        storeFields[key] = strValue;
                    }
                }

                indexObject = new IndexObject()
                {
                    Title        = title,
                    Body         = bodyBuilder.ToString(),
                    StoreFields  = storeFields,
                    SystemFields = sysFields,
                    NativeType   = typeof(TextContent).AssemblyQualifiedNameWithoutVersion()
                };
            }

            return(indexObject);
        }
Example #24
0
    private void Start()
    {
        welcomePhrase = "when the sun sets over the nile, mummies start to roam the land of the pyramids \n.......";
        Egypt         = this.GetComponent <AudioSource>();
        if (!GameManager.getIsCompleted())
        {
            GameManager.ReceiveSavedData();
            welcomePanel.SetActive(true);
            typing = welcomePanel.GetComponent <AudioSource>();
            StartCoroutine(showText(welcomePhrase, welcomeText, typing));
        }
        else
        {
            Egypt.Play();
        }
        GroupID = GameManager.getGroupID();
        GameManager.createGods();
        if (GroupID > 0)
        {
            myGod = GameManager.getGodInfo(GroupID);
        }
        revealPanel.SetActive(false);
        factionPanel.SetActive(false);
        nextPanel.SetActive(false);

        if (GameManager.getInitial() == 0)
        {
            factionButton.SetActive(false);
            infoButton.SetActive(false);
            IndexObject.SetActive(false);
        }
        else
        {
            factionButton.SetActive(true);
            infoButton.SetActive(true);
            IndexObject.SetActive(true);
            IndexObject.GetComponentInChildren <TextMeshProUGUI>().text = GameManager.getName(int.Parse(GameManager.getIndexNo())) + "\n" + GameManager.getIndexNo();
            if (GameManager.getGender(int.Parse(GameManager.getIndexNo())) == 'F')
            {
                profPic.sprite = FemaleProfPic;
            }
            else
            {
                profPic.sprite = MaleProfPic;
            }
            switch (GroupID)
            {
            case 1:
                godSprite = Horus;
                break;

            case 2:
                godSprite = Bastet;
                break;

            case 3:
                godSprite = Osiris;
                break;

            case 4:
                godSprite = Anubis;
                break;
            }
        }
    }
Example #25
0
        protected void Add(string key, string value)
        {
            int valueUTF8Length = value.UTF8Length();

            //Update average:
            averageElementLength = ((value != null ? valueUTF8Length : 0) + averageElementLength * _lstIndexes.Count) /
                                   (1 + _lstIndexes.Count);

            //See if we already have a key,
            //If yes, this means, user wants to overwrite the
            //existing value

            IndexObject indexObject;
            bool        removedFromTooSmallSpot = false;

            if (_lstIndexes.TryGetValue(key, out indexObject))
            {
                if (value == null || indexObject.FileSpotLength >= valueUTF8Length) //Update existing filespot with new element value
                {
                    WriteToFile(indexObject.FilePosition, value, indexObject.FileSpotLength);

                    indexObject.ElementLength = value != null ? valueUTF8Length : 0;
                    _lstIndexes[key]          = indexObject;
                }
                else //Element already exists, but its filespot is too small for the new value.
                {
                    //1. Check emptySpots for extension options.
                    IndexObject emptySpot;
                    emptyFileSpots.TryGetValue(indexObject.FilePosition + indexObject.FileSpotLength, out emptySpot);

                    if (emptySpot != null && emptySpot.FileSpotLength + indexObject.FileSpotLength >= valueUTF8Length)
                    {
                        int newLen = -1;
                        //2A. Extend spot and update.
                        if (emptySpot.FileSpotLength + indexObject.FileSpotLength - valueUTF8Length * 2 < averageElementLength * 2) //Use whole spot.
                        {
                            newLen = indexObject.FileSpotLength + emptySpot.FileSpotLength;
                            emptyFileSpots.Remove(emptySpot.FilePosition);
                        }
                        else //Split empty spot.
                        {
                            newLen = Math.Max(valueUTF8Length * 2, averageElementLength * 2);
                            emptyFileSpots.Remove(emptySpot.FilePosition);

                            emptyFileSpots.Add(indexObject.FilePosition + newLen, new IndexObject
                            {
                                FilePosition   = indexObject.FilePosition + newLen,
                                ElementLength  = 0,
                                FileSpotLength = emptySpot.FileSpotLength + indexObject.FileSpotLength - newLen
                            });
                        }

                        indexObject.FileSpotLength = newLen;
                        indexObject.ElementLength  = valueUTF8Length;
                        _lstIndexes[key]           = indexObject; //Position and key unchanged.

                        WriteToFile(indexObject.FilePosition, value, indexObject.FileSpotLength);
                    }
                    else //No (suitable) empty spot for extension, move current spot.
                    {
                        //2B. Create empty spot from current spot.
                        emptyFileSpots.Add(indexObject.FilePosition, new IndexObject
                        {
                            ElementLength  = 0,
                            FilePosition   = indexObject.FilePosition,
                            FileSpotLength = indexObject.FileSpotLength
                        });

                        if (lastFilledIndex.FilePosition == indexObject.FilePosition)
                        {
                            lastFilledIndex = null;
                        }

                        ConcatenateEmptySlots();

                        //Clear old spot.
                        WriteToFile(indexObject.FilePosition, null, indexObject.FileSpotLength);

                        //3B. Move current spot in file. -> Happens in add new logic.
                        removedFromTooSmallSpot = true;
                    }
                }
            }

            if (!_lstIndexes.ContainsKey(key) || removedFromTooSmallSpot)
            {
                IndexObject availableEmpty = FindAndSplitExistingEmptySpot(value != null ? valueUTF8Length * 2 : 0, averageElementLength * 2);
                if (availableEmpty != null) //Move to bigger empty spot:
                {
                    //If first or moved update file index last filled value:
                    if (lastFilledIndex == null)
                    {
                        UpdateLastFilledIndex();
                    }

                    WriteToFile(availableEmpty.FilePosition, value, availableEmpty.FileSpotLength); //Write value to file.
                    availableEmpty.ElementLength = value != null ? valueUTF8Length : 0;             //Update length from 0 to value length.
                    _lstIndexes[key]             = availableEmpty;                                  //Update file index with new index object.
                    emptyFileSpots.Remove(availableEmpty.FilePosition);                             //Remove now no longer empty spot from empty list.
                }
                else //Add new OR no available empty spot:
                {
                    //Make new index object:
                    IndexObject newIndex = new IndexObject
                    {
                        ElementLength  = value != null ? valueUTF8Length : 0,
                        FilePosition   = lastFilledIndex != null ? lastFilledIndex.FilePosition + lastFilledIndex.FileSpotLength : 0, //0 only in case of FIRST element.
                        FileSpotLength = Math.Max((value != null ? valueUTF8Length : 0) * 2, averageElementLength * 2)
                    };

                    //When adding to end of file we are always the lastFilled:
                    lastFilledIndex = newIndex;
                    _file.SetLength(lastFilledIndex != null ? lastFilledIndex.FilePosition + lastFilledIndex.FileSpotLength : 0);

                    WriteToFile(newIndex.FilePosition, value, newIndex.FileSpotLength); //Write value to file.
                    if (_lstIndexes.ContainsKey(key))                                   //Existing moved from old spot to entirely new:
                    {
                        _lstIndexes[key] = newIndex;
                    }
                    else //Entirely new value added:
                    {
                        _lstIndexes.Add(key, newIndex);
                    }
                }
            }

            UpdateIndexFiles();
        }