Esempio n. 1
0
 public string TodayUpdate(UpdateFilter filter)
 {
     try
     {
         var    nowvideos    = VideoUtils.ConvertVodIenum(ListCache.Instance.Items[new VideoNodeKey(null, 0, null)].Ver1);
         var    updatevideos = nowvideos.Where(video => video.ModifyTime >= filter.lasttime);                  //.ToList();
         var    deletevideos = YesterdayListCache.Instance.Items.Except(nowvideos, new YesterdayVidCompare()); //.ToList();
         int    count        = updatevideos.Count();
         string lasttime     = filter.lasttime.ToString("HH:mm:ss");
         if (count > 0)
         {
             lasttime = updatevideos.Max(video => video.ModifyTime).ToString("HH:mm:ss");
         }
         //var currentvideos = updatevideos.Skip(filter.c * (filter.s - 1)).Take(filter.c);
         var xml = new XElement("vlist",
                                //new XElement("count", count),
                                //new XElement("page_count", PageUtils.PageCount(count, filter.c)),
                                new XElement("latest_time", lasttime),
                                new XElement("v-update", new XAttribute("count", count),
                                             from video in updatevideos select ResponseUtils.ResponseBack(ListCache.Instance.Dictionary[video.ChannelId])
                                             ),
                                new XElement("v-delete", new XAttribute("count", deletevideos.Count()),
                                             from dv in deletevideos select new XElement("vid", dv.ChannelId)
                                             )
                                );
         return(xml.ToString(SaveOptions.DisableFormatting));
     }
     catch (Exception ex)
     {
         return(BoxUtils.FormatErrorMsg(ex));
     }
 }
Esempio n. 2
0
        public static OnlineVersion CheckForUpdates(string feedUrl, UpdateFilter filter)
        {
            // NOTE: Requires a reference to System.ServiceModel.dll
            var formatter = new Atom10FeedFormatter();

            try
            {
                // Read the feed
                var reader = XmlReader.Create(feedUrl);
                formatter.ReadFrom(reader);
            }
            catch (Exception e)
            {
                Trace.WriteLine(String.Format("Error while trying to check updade : {0} ", e.Message));
                return(null);
            }

            var latestUpdate = formatter.Feed.Items
                               .OrderByDescending(u => u.LastUpdatedTime)
                               .FirstOrDefault();

            if (latestUpdate != null)
            {
                return(new OnlineVersion()
                {
                    downloadurl = latestUpdate.Links.Single().Uri.ToString(),
                    newversion = latestUpdate.Title.Text,
                    content = latestUpdate.Summary.Text
                });
            }
            else
            {
                return(null);
            }
        }
Esempio n. 3
0
        private void TrySortDate(UpdateFilter filter, bool sum = false)
        {
            filter.BeginDate = DateTime.Now.Date.AddDays(-4);
            var logs  = filter.Find(session);
            var count = logs.Count - 1;

            if (filter.SortDirection == "Desc")
            {
                for (int i = 0; i < count; i++)
                {
                    Assert.That(logs[i].RequestTime, Is.GreaterThanOrEqualTo(logs[i++].RequestTime));
                }
            }
            else
            {
                for (int i = 0; i < count; i++)
                {
                    Assert.That(logs[i].RequestTime, Is.LessThanOrEqualTo(logs[i++].RequestTime));
                }
            }
            if (!sum)
            {
                filter.SortDirection = filter.SortDirection == "Desc" ? "Asc" : "Desc";
                TrySortDate(filter, true);
            }
        }
Esempio n. 4
0
        public void SortColumns()
        {
            Client client = DataMother.CreateTestClientWithUser();
            IEnumerable <UpdateLogEntity> updateLog = new List <UpdateLogEntity>();

            for (int i = 0; i < 2; i++)
            {
                updateLog = updateLog.Concat(new[] { new UpdateLogEntity(client.Users.First())
                                                     {
                                                         RequestTime = DateTime.Now.AddHours(-i * 2),
                                                         UpdateType  = (UpdateType)i,
                                                         ResultSize  = (uint)i,
                                                         AppVersion  = (uint)i,
                                                         Addition    = String.Format("Test update{0}", i),
                                                         Commit      = false,
                                                     } });
            }

            session.SaveEach(updateLog);
            Flush();

            var filter = new UpdateFilter();

            filter.Client = client;
            TrySortDate(filter);
        }
Esempio n. 5
0
        /// <summary>
        /// Updates the Ctrl's GUI with the test infomation inside testInfo
        /// </summary>
        public void updateGTestInfomation(ConfiguredProject project, GTestResultCollection testInfo)
        {
            Contract.Requires(testInfo != null);

            UpdateSuitePicture updateSuitePicture = SuitePictureChange;
            Image image;

            AddProject(project);
            NumberOfTests        = testInfo.TotalNumberOfTests;
            NumberOfFailingTests = testInfo.TotalNumberOfFailures;
            NumberOfPassingTests = NumberOfTests - NumberOfFailingTests;
            if (NumberOfPassingTests == 0 && NumberOfFailingTests == 0)
            {
                image = Resources.TestNotRun;
            }
            else
            {
                image = NumberOfFailingTests == 0 ? Resources.TestPassed : Resources.TestFail;
            }

            cboFilter.SetPropertyThreadSafe(() => cboFilter.SelectedIndex, 0);
            TimeTakenForTests = testInfo.TotalTime;
            if (picPass.InvokeRequired)
            {
                picPass.Invoke(updateSuitePicture, new object[] { image });
            }
            else
            {
                updateSuitePicture(image);
            }
            BindingSource bindingSource = new BindingSource();
            UpdateFilter  addFilterItem = AddFilterItem;

            foreach (GTestSuite testSuite in testInfo.GetList())
            {
                if (cboFilter.InvokeRequired)
                {
                    cboFilter.Invoke(addFilterItem, new object[] { testSuite.Name });
                }
                else
                {
                    cboFilter.Items.Add(testSuite.Name);
                }
                foreach (GTestResult test in testSuite.GetList())
                {
                    bindingSource.Add(test);
                }
            }
            SetGridDatasouce datasouce = SetDatasource;

            if (GridTests.InvokeRequired)
            {
                GridTests.Invoke(datasouce, new object[] { bindingSource });
            }
            else
            {
                GridTests.DataSource = bindingSource;
            }
        }
Esempio n. 6
0
 public UpdateStatus(int currentFrame)
 {
     lastUpdateFrame           = -1;
     lastUpdateSubframe        = 0;
     windowStart               = currentFrame;
     numWindowLateUpdateMoves  = 0;
     numWindowFixedUpdateMoves = 0;
     numWindows      = 0;
     preferredUpdate = UpdateFilter.Late;
     targetPos       = Matrix4x4.zero;
 }
Esempio n. 7
0
            public UpdateFilter ChoosePreferredUpdate(
                int currentFrame, Matrix4x4 pos, UpdateFilter updateFilter)
            {
                if (targetPos != pos)
                {
                    if (updateFilter == UpdateFilter.Late)
                    {
                        ++numWindowLateUpdateMoves;
                    }
                    else if (lastUpdateSubframe == 0)
                    {
                        ++numWindowFixedUpdateMoves;
                    }
                    targetPos = pos;
                }
                //Debug.Log("Fixed=" + numWindowFixedUpdateMoves + ", Late=" + numWindowLateUpdateMoves);
                if (numWindowLateUpdateMoves + numWindowFixedUpdateMoves > 0)
                {
                    UpdateFilter choice       = preferredUpdate;
                    bool         inconsistent = numWindowLateUpdateMoves > 0 && numWindowFixedUpdateMoves > 0;
                    if (inconsistent || numWindowLateUpdateMoves >= numWindowFixedUpdateMoves)
                    {
                        choice = UpdateFilter.Late;
                    }
                    else
                    {
                        choice = UpdateFilter.Fixed;
                    }
                    if (numWindows == 0)
                    {
                        preferredUpdate = choice;
                    }

                    if (windowStart + kWindowSize <= currentFrame)
                    {
                        if (numWindows > 0) // ignore junk in first few frames
                        {
                            hasInconsistentAnimation = inconsistent;
                        }
                        if (hasInconsistentAnimation)
                        {
                            hadInconsistentAnimation = true;
                        }
                        preferredUpdate = choice;
                        ++numWindows;
                        windowStart = currentFrame;
                        numWindowLateUpdateMoves = numWindowFixedUpdateMoves = 0;
                    }
                }
                return(preferredUpdate);
            }
Esempio n. 8
0
        public static string ToFriendlyString(this UpdateFilter updateFilterMode)
        {
            switch (updateFilterMode)
            {
            case UpdateFilter.All:
                return(Language.GetTextValue("tModLoader.MBShowAllMods"));

            case UpdateFilter.Available:
                return(Language.GetTextValue("tModLoader.MBShowNotInstalledUpdates"));

            case UpdateFilter.UpdateOnly:
                return(Language.GetTextValue("tModLoader.MBShowUpdates"));
            }
            return("Unknown Sort");
        }
Esempio n. 9
0
        public static UpdateFilter Next(this UpdateFilter updateFilterMode)
        {
            switch (updateFilterMode)
            {
            case UpdateFilter.All:
                return(UpdateFilter.Available);

            case UpdateFilter.Available:
                return(UpdateFilter.UpdateOnly);

            case UpdateFilter.UpdateOnly:
                return(UpdateFilter.All);
            }
            return(UpdateFilter.All);
        }
Esempio n. 10
0
        public static string ToFriendlyString(this UpdateFilter updateFilterMode)
        {
            switch (updateFilterMode)
            {
            case UpdateFilter.All:
                return("Show all mods");

            case UpdateFilter.Available:
                return("Show mods not installed and updates");

            case UpdateFilter.UpdateOnly:
                return("Show only updates");
            }
            return("Unknown Sort");
        }
Esempio n. 11
0
        public void UpdateLog(UpdateType?updateType, ulong?regionMask, uint?clientCode, uint?userId,
                              DateTime beginDate, DateTime endDate)
        {
            SetSmartBinder(AutoLoadBehavior.NullIfInvalidKey);
            //по умолчанию биндер будет пытаться проверить наши обекты, в данном контексте делать этого не следует
            Binder.Validator = null;

            var filter = new UpdateFilter();

            filter.BeginDate = beginDate;
            filter.EndDate   = endDate;

            if (updateType.HasValue)
            {
                filter.UpdateType = updateType;
                filter.RegionMask = Admin.RegionMask;

                if (regionMask.HasValue)
                {
                    filter.RegionMask &= regionMask.Value;
                }
            }
            if (clientCode.HasValue)
            {
                filter.Client = DbSession.Load <Client>(clientCode.Value);
            }
            else if (userId.HasValue)
            {
                filter.User = DbSession.Load <User>(userId.Value);
            }

            BindObjectInstance(filter, "filter");

            if (filter.Client != null)
            {
                filter.Client = DbSession.Load <Client>(filter.Client.Id);
            }

            if (filter.User != null)
            {
                filter.User = DbSession.Load <User>(filter.User.Id);
            }

            PropertyBag["beginDate"]   = filter.BeginDate;
            PropertyBag["endDate"]     = filter.EndDate;
            PropertyBag["filter"]      = filter;
            PropertyBag["logEntities"] = filter.Find(DbSession);
        }
Esempio n. 12
0
        public async Task<Update> CheckForUpdatesAsync(string updateUrl, UpdateFilter updateFilter)
        {
            Debug.Assert(!String.IsNullOrWhiteSpace(updateUrl));

            var reader = XmlReader.Create(updateUrl);
            var formatter = new Atom10FeedFormatter();

            await formatter.ReadFromAsync(reader);

            return (from i in formatter.Feed.Items
                    let u = UpdateHelper.FromSyndicationItem(i)
                    where u.Version > Assembly.GetExecutingAssembly().GetName().Version
                        && ((int)updateFilter & (int)u.ReleaseStatus) != 0
                    orderby u.LastUpdatedTime descending
                    select u).FirstOrDefault();
        }
Esempio n. 13
0
        public async Task <Update> CheckForUpdatesAsync(string updateUrl, UpdateFilter updateFilter)
        {
            Debug.Assert(!String.IsNullOrWhiteSpace(updateUrl));

            var reader    = XmlReader.Create(updateUrl);
            var formatter = new Atom10FeedFormatter();

            await formatter.ReadFromAsync(reader);

            return((from i in formatter.Feed.Items
                    let u = UpdateHelper.FromSyndicationItem(i)
                            where u.Version > Assembly.GetExecutingAssembly().GetName().Version &&
                            ((int)updateFilter & (int)u.ReleaseStatus) != 0
                            orderby u.LastUpdatedTime descending
                            select u).FirstOrDefault());
        }
Esempio n. 14
0
 public string AllList(UpdateFilter filter)
 {
     try
     {
         var videos = ListCache.Instance.Items[new VideoNodeKey(null, 0, null)].Ver1;
         var xml    = new XElement("vlist");
         var count  = videos.BackPageList(filter.c, filter.s, xml);
         xml.AddFirst(new XElement("count", count),
                      new XElement("page_count", PageUtils.PageCount(count, filter.c))
                      );
         return(xml.ToString(SaveOptions.DisableFormatting));
     }
     catch (Exception ex)
     {
         return(BoxUtils.FormatErrorMsg(ex));
     }
 }
Esempio n. 15
0
        /// <summary>Internal use only</summary>
        public bool GetVcamUpdateStatus(
            ICinemachineCamera vcam, out UpdateFilter updateMode,
            out bool hasInconsistentAnimation, out bool hadInconsistentAnimation)
        {
            hasInconsistentAnimation = hadInconsistentAnimation = false;
            updateMode = UpdateFilter.Late;
            UpdateStatus status;

            if (mUpdateStatus == null || !mUpdateStatus.TryGetValue(vcam, out status))
            {
                return(false);
            }

            hasInconsistentAnimation = status.hasInconsistentAnimation;
            hadInconsistentAnimation = status.hadInconsistentAnimation;
            updateMode = status.preferredUpdate;
            return(true);
        }
Esempio n. 16
0
            // Important: updateFilter may ONLY be Late or Fixed
            public UpdateFilter ChoosePreferredUpdate(
                int currentFrame, Matrix4x4 pos, UpdateFilter updateFilter)
            {
                if (targetPos != pos)
                {
                    if (updateFilter == UpdateFilter.Late)
                    {
                        ++numWindowLateUpdateMoves;
                    }
                    else if (lastUpdateSubframe == 0)
                    {
                        ++numWindowFixedUpdateMoves;
                    }
                    targetPos = pos;
                }

                //Debug.Log("Fixed=" + numWindowFixedUpdateMoves + ", Late=" + numWindowLateUpdateMoves);
                var choice       = preferredUpdate;
                var inconsistent = numWindowLateUpdateMoves > 0 && numWindowFixedUpdateMoves > 0;

                if (inconsistent || numWindowLateUpdateMoves >= numWindowFixedUpdateMoves)
                {
                    choice = UpdateFilter.Late;
                }
                else
                {
                    choice = UpdateFilter.Fixed;
                }
                if (numWindows == 0)
                {
                    preferredUpdate = choice;
                }

                if (windowStart + kWindowSize <= currentFrame)
                {
                    preferredUpdate = choice;
                    ++numWindows;
                    windowStart = currentFrame;
                    numWindowLateUpdateMoves = numWindowFixedUpdateMoves = 0;
                }

                return(preferredUpdate);
            }
Esempio n. 17
0
        public void Load_updates_by_filter()
        {
            var user1 = DataMother.CreateTestClientWithUser().Users[0];
            var user2 = DataMother.CreateTestClientWithUser(session.Load <Region>(16ul)).Users[0];

            Flush();
            var update1 = new UpdateLogEntity(user1);

            Save(update1);
            var update2 = new UpdateLogEntity(user2);

            Save(update2);

            var filter = new UpdateFilter();

            filter.RegionMask = 16;
            filter.BeginDate  = DateTime.Today.AddDays(-1);
            filter.EndDate    = DateTime.Today;
            filter.UpdateType = UpdateType.Accumulative;
            var results = filter.Find(session);

            Assert.That(results.Count, Is.GreaterThan(0));
            Assert.That(results.Any(r => r.Id == update1.Id), Is.False, "нашли запись обновления в воронеже, {0}", update1.Id);
            Assert.That(results.Any(r => r.Id == update2.Id), Is.True, "не нашли запись обновления в челябинске, {0} {1}", update2.Id, results.Implode(r => r.Id));
            filter.UpdateType = UpdateType.AccessError;
            Save(new UpdateLogEntity(user2)
            {
                UpdateType  = UpdateType.AutoOrder,
                RequestTime = DateTime.Now.AddHours(1),
                Commit      = true
            });
            Save(new UpdateLogEntity(user2)
            {
                UpdateType = UpdateType.AccessError,
            });
            results = filter.Find(session);
            Assert.IsTrue(results.Any(r => r.OkUpdate));
        }
Esempio n. 18
0
 public bool Update(UpdateFilter filter)
 {
     try
     {
         using (var scope = new SQLServerDBContextScope(this.mDBConnect))
         {
             SQLServerDynamicRepertory db = new SQLServerDynamicRepertory();
             var dbName = filter.TableName.Split('.').First();
             var tbName = filter.TableName.Split('.').Last().Remove(0, 1);
             tbName = tbName.Remove(tbName.Length - 1, 1);
             List <IndexViewModel> indexs = ServiceFactory.GetInstance().DatabaseService.GetTableIndexs(filter.TableName);
             foreach (var data in filter.Datas)
             {
                 db.DbSet(filter.TableName).Update(data, indexs.FirstOrDefault(d => d.Type == IndexType.Primary).ColumnName);
             }
             return(true);
         }
     }
     catch (Exception e)
     {
         mLog.Error($"An error has occurred in the update data,error:{e.ToString()}");
         throw;
     }
 }
Esempio n. 19
0
 public JsonResult Update([ModelBinder(typeof(UpdateFilterModelBinder))] UpdateFilter filter)
 {
     return(Json(ServiceFactory.GetInstance().DBManageService.Update(filter), JsonRequestBehavior.AllowGet));
 }
Esempio n. 20
0
        public override void OnInitialize()
        {
            uIElement = new UIElement();
            uIElement.Width.Set(0f, 0.8f);
            uIElement.MaxWidth.Set(600f, 0f);
            uIElement.Top.Set(220f, 0f);
            uIElement.Height.Set(-220f, 1f);
            uIElement.HAlign = 0.5f;

            uIPanel = new UIPanel();
            uIPanel.Width.Set(0f, 1f);
            uIPanel.Height.Set(-110f, 1f);
            uIPanel.BackgroundColor = new Color(33, 43, 79) * 0.8f;
            uIPanel.PaddingTop      = 0f;
            uIElement.Append(uIPanel);

            uILoader = new UILoaderAnimatedImage(0.5f, 0.5f, 1f);

            modList = new UIList();
            modList.Width.Set(-25f, 1f);
            modList.Height.Set(-50f, 1f);
            modList.Top.Set(50f, 0f);
            modList.ListPadding = 5f;
            uIPanel.Append(modList);

            UIScrollbar uIScrollbar = new UIScrollbar();

            uIScrollbar.SetView(100f, 1000f);
            uIScrollbar.Height.Set(-50f, 1f);
            uIScrollbar.Top.Set(50f, 0f);
            uIScrollbar.HAlign = 1f;
            uIPanel.Append(uIScrollbar);

            modList.SetScrollbar(uIScrollbar);
            uIHeaderTextPanel        = new UITextPanel <string>("Mod Browser", 0.8f, true);
            uIHeaderTextPanel.HAlign = 0.5f;
            uIHeaderTextPanel.Top.Set(-35f, 0f);
            uIHeaderTextPanel.SetPadding(15f);
            uIHeaderTextPanel.BackgroundColor = new Color(73, 94, 171);
            uIElement.Append(uIHeaderTextPanel);

            reloadButton = new UITextPanel <string>("Getting data...", 1f, false);
            reloadButton.Width.Set(-10f, 0.5f);
            reloadButton.Height.Set(25f, 0f);
            reloadButton.VAlign = 1f;
            reloadButton.Top.Set(-65f, 0f);
            reloadButton.OnMouseOver += UICommon.FadedMouseOver;
            reloadButton.OnMouseOut  += UICommon.FadedMouseOut;
            reloadButton.OnClick     += ReloadList;
            uIElement.Append(reloadButton);

            UITextPanel <string> backButton = new UITextPanel <string>("Back", 1f, false);

            backButton.Width.Set(-10f, 0.5f);
            backButton.Height.Set(25f, 0f);
            backButton.VAlign = 1f;
            backButton.Top.Set(-20f, 0f);
            backButton.OnMouseOver += UICommon.FadedMouseOver;
            backButton.OnMouseOut  += UICommon.FadedMouseOut;
            backButton.OnClick     += BackClick;
            uIElement.Append(backButton);

            clearButton = new UITextPanel <string>("Clear Special Filter: ??", 1f, false);
            clearButton.Width.Set(-10f, 0.5f);
            clearButton.Height.Set(25f, 0f);
            clearButton.HAlign = 1f;
            clearButton.VAlign = 1f;
            clearButton.Top.Set(-65f, 0f);
            clearButton.BackgroundColor = Color.Purple * 0.7f;
            clearButton.OnMouseOver    += (s, e) => UICommon.CustomFadedMouseOver(Color.Purple, s, e);
            clearButton.OnMouseOut     += (s, e) => UICommon.CustomFadedMouseOut(Color.Purple * 0.7f, s, e);
            clearButton.OnClick        += (s, e) =>
            {
                Interface.modBrowser.SpecialModPackFilter      = null;
                Interface.modBrowser.SpecialModPackFilterTitle = null;
                Interface.modBrowser.updateNeeded = true;
                Main.PlaySound(SoundID.MenuTick);
            };

            Append(uIElement);

            UIElement upperMenuContainer = new UIElement();

            upperMenuContainer.Width.Set(0f, 1f);
            upperMenuContainer.Height.Set(32f, 0f);
            upperMenuContainer.Top.Set(10f, 0f);
            Texture2D texture = Texture2D.FromStream(Main.instance.GraphicsDevice, Assembly.GetExecutingAssembly().GetManifestResourceStream("Terraria.ModLoader.UI.UIModBrowserIcons.png"));

            for (int j = 0; j < 2; j++)
            {
                if (j == 0)
                {
                    uIToggleImage = new UICycleImage(texture, 6, 32, 32, 0, 0);
                    uIToggleImage.setCurrentState((int)sortMode);
                    uIToggleImage.OnClick += (a, b) =>
                    {
                        sortMode     = sortMode.NextEnum();
                        updateNeeded = true;
                    };
                    uIToggleImage.OnRightClick += (a, b) =>
                    {
                        sortMode     = sortMode.PreviousEnum();
                        updateNeeded = true;
                    };
                }
                else
                {
                    uIToggleImage = new UICycleImage(texture, 3, 32, 32, 34, 0);
                    uIToggleImage.setCurrentState((int)updateFilterMode);
                    uIToggleImage.OnClick += (a, b) =>
                    {
                        updateFilterMode = updateFilterMode.NextEnum();
                        updateNeeded     = true;
                    };
                    uIToggleImage.OnRightClick += (a, b) =>
                    {
                        updateFilterMode = updateFilterMode.PreviousEnum();
                        updateNeeded     = true;
                    };
                }
                uIToggleImage.Left.Set((float)(j * 36 + 8), 0f);
                _categoryButtons.Add(uIToggleImage);
                upperMenuContainer.Append(uIToggleImage);
            }
            UIPanel filterTextBoxBackground = new UIPanel();

            filterTextBoxBackground.Top.Set(0f, 0f);
            filterTextBoxBackground.Left.Set(-170, 1f);
            filterTextBoxBackground.Width.Set(135f, 0f);
            filterTextBoxBackground.Height.Set(40f, 0f);
            upperMenuContainer.Append(filterTextBoxBackground);

            filterTextBox = new UIInputTextField("Type to search");
            filterTextBox.Top.Set(5, 0f);
            filterTextBox.Left.Set(-160, 1f);
            filterTextBox.OnTextChange += (sender, e) => updateNeeded = true;
            upperMenuContainer.Append(filterTextBox);

            SearchFilterToggle = new UICycleImage(texture, 2, 32, 32, 68, 0);
            SearchFilterToggle.setCurrentState((int)searchFilterMode);
            SearchFilterToggle.OnClick += (a, b) =>
            {
                searchFilterMode = searchFilterMode.NextEnum();
                updateNeeded     = true;
            };
            SearchFilterToggle.OnRightClick += (a, b) =>
            {
                searchFilterMode = searchFilterMode.PreviousEnum();
                updateNeeded     = true;
            };
            SearchFilterToggle.Left.Set(545f, 0f);
            _categoryButtons.Add(SearchFilterToggle);
            upperMenuContainer.Append(SearchFilterToggle);
            uIPanel.Append(upperMenuContainer);
        }
Esempio n. 21
0
 public static UpdateFilter <T> Where <T>(this UpdateFilter <T> filter, Func <T, bool> andFunc)
 {
     filter.Filters.Add(update => andFunc(filter.Mapper(update)));
     return(filter);
 }
Esempio n. 22
0
        public override void OnInitialize()
        {
            UIElement uIElement = new UIElement();

            uIElement.Width.Set(0f, 0.8f);
            uIElement.MaxWidth.Set(600f, 0f);
            uIElement.Top.Set(220f, 0f);
            uIElement.Height.Set(-220f, 1f);
            uIElement.HAlign = 0.5f;
            UIPanel uIPanel = new UIPanel();

            uIPanel.Width.Set(0f, 1f);
            uIPanel.Height.Set(-110f, 1f);
            uIPanel.BackgroundColor = new Color(33, 43, 79) * 0.8f;
            uIPanel.PaddingTop      = 0f;
            uIElement.Append(uIPanel);
            modListAll = new UIList();
            modList    = new UIList();
            modList.Width.Set(-25f, 1f);
            modList.Height.Set(-50f, 1f);
            modList.Top.Set(50f, 0f);
            modList.ListPadding = 5f;
            uIPanel.Append(modList);
            UIScrollbar uIScrollbar = new UIScrollbar();

            uIScrollbar.SetView(100f, 1000f);
            uIScrollbar.Height.Set(-50f, 1f);
            uIScrollbar.Top.Set(50f, 0f);
            uIScrollbar.HAlign = 1f;
            uIPanel.Append(uIScrollbar);
            modList.SetScrollbar(uIScrollbar);
            uITextPanel        = new UITextPanel <string>("Mod Browser", 0.8f, true);
            uITextPanel.HAlign = 0.5f;
            uITextPanel.Top.Set(-35f, 0f);
            uITextPanel.SetPadding(15f);
            uITextPanel.BackgroundColor = new Color(73, 94, 171);
            uIElement.Append(uITextPanel);
            reloadButton = new UITextPanel <string>("Loading...", 1f, false);
            reloadButton.Width.Set(-10f, 0.5f);
            reloadButton.Height.Set(25f, 0f);
            reloadButton.VAlign = 1f;
            reloadButton.Top.Set(-65f, 0f);
            reloadButton.OnMouseOver += UICommon.FadedMouseOver;
            reloadButton.OnMouseOut  += UICommon.FadedMouseOut;
            reloadButton.OnClick     += ReloadList;
            uIElement.Append(reloadButton);
            UITextPanel <string> backButton = new UITextPanel <string>("Back", 1f, false);

            backButton.Width.Set(-10f, 0.5f);
            backButton.Height.Set(25f, 0f);
            backButton.VAlign = 1f;
            backButton.Top.Set(-20f, 0f);
            backButton.OnMouseOver += UICommon.FadedMouseOver;
            backButton.OnMouseOut  += UICommon.FadedMouseOut;
            backButton.OnClick     += BackClick;
            uIElement.Append(backButton);
            base.Append(uIElement);
            UIElement uIElement2 = new UIElement();

            uIElement2.Width.Set(0f, 1f);
            uIElement2.Height.Set(32f, 0f);
            uIElement2.Top.Set(10f, 0f);
            Texture2D    texture = Texture2D.FromStream(Main.instance.GraphicsDevice, Assembly.GetExecutingAssembly().GetManifestResourceStream("Terraria.ModLoader.UI.UIModBrowserIcons.png"));
            UICycleImage uIToggleImage;

            for (int j = 0; j < 2; j++)
            {
                if (j == 0)
                {
                    uIToggleImage = new UICycleImage(texture, 5, 32, 32, 0, 0);
                    uIToggleImage.setCurrentState((int)sortMode);
                    uIToggleImage.OnClick += (a, b) =>
                    {
                        sortMode = sortMode.Next();
                        SortList();
                    };
                }
                else
                {
                    uIToggleImage = new UICycleImage(texture, 3, 32, 32, 34, 0);
                    uIToggleImage.setCurrentState((int)updateFilterMode);
                    uIToggleImage.OnClick += (a, b) =>
                    {
                        updateFilterMode = updateFilterMode.Next();
                        SortList();
                    };
                }
                uIToggleImage.Left.Set((float)(j * 36 + 8), 0f);
                _categoryButtons.Add(uIToggleImage);
                uIElement2.Append(uIToggleImage);
            }
            filterTextBox = new UIInputTextField("Type to search");
            filterTextBox.Top.Set(5, 0f);
            filterTextBox.Left.Set(-150, 1f);
            filterTextBox.OnTextChange += (sender, e) => SortList();
            uIElement2.Append(filterTextBox);
            UICycleImage SearchFilterToggle = new UICycleImage(texture, 2, 32, 32, 68, 0);

            SearchFilterToggle.setCurrentState((int)searchFilterMode);
            SearchFilterToggle.OnClick += (a, b) =>
            {
                searchFilterMode = searchFilterMode.Next();
                SortList();
            };
            SearchFilterToggle.Left.Set(545f, 0f);
            _categoryButtons.Add(SearchFilterToggle);
            uIElement2.Append(SearchFilterToggle);
            uIPanel.Append(uIElement2);

            PopulateModBrowser();
        }
Esempio n. 23
0
        /// <summary>
        /// Update a single Cinemachine Virtual Camera if and only if it
        /// hasn't already been updated this frame.  Always update vcams via this method.
        /// Calling this more than once per frame for the same camera will have no effect.
        /// </summary>
        internal bool UpdateVirtualCamera(ICinemachineCamera vcam, Vector3 worldUp, float deltaTime)
        {
            //UnityEngine.Profiling.Profiler.BeginSample("CinemachineCore.UpdateVirtualCamera");
            int          now           = Time.frameCount;
            UpdateFilter filter        = CurrentUpdateFilter;
            bool         isSmartUpdate = filter != UpdateFilter.ForcedFixed &&
                                         filter != UpdateFilter.ForcedLate;
            bool isSmartLateUpdate = filter == UpdateFilter.Late;

            if (!isSmartUpdate)
            {
                if (filter == UpdateFilter.ForcedFixed)
                {
                    filter = UpdateFilter.Fixed;
                }
                if (filter == UpdateFilter.ForcedLate)
                {
                    filter = UpdateFilter.Late;
                }
            }

            if (mUpdateStatus == null)
            {
                mUpdateStatus = new Dictionary <ICinemachineCamera, UpdateStatus>();
            }
            if (vcam.VirtualCameraGameObject == null)
            {
                if (mUpdateStatus.ContainsKey(vcam))
                {
                    mUpdateStatus.Remove(vcam);
                }
                //UnityEngine.Profiling.Profiler.EndSample();
                return(false); // camera was deleted
            }
            UpdateStatus status;

            if (!mUpdateStatus.TryGetValue(vcam, out status))
            {
                status = new UpdateStatus(now);
                mUpdateStatus.Add(vcam, status);
            }

            int subframes = isSmartLateUpdate ? 1 : CinemachineBrain.GetSubframeCount();

            if (status.lastUpdateFrame != now)
            {
                status.lastUpdateSubframe = 0;
            }

            // If we're in smart update mode and the target moved, then we must examine
            // how the target has been moving recently in order to figure out whether to
            // update now
            bool updateNow = !isSmartUpdate;

            if (isSmartUpdate)
            {
                Matrix4x4 targetPos;
                if (!GetTargetPosition(vcam, out targetPos))
                {
                    updateNow = isSmartLateUpdate; // no target
                }
                else
                {
                    updateNow = status.ChoosePreferredUpdate(now, targetPos, filter)
                                == filter;
                }
            }

            if (updateNow)
            {
                status.preferredUpdate = filter;
                while (status.lastUpdateSubframe < subframes)
                {
//Debug.Log(vcam.Name + ": frame " + Time.frameCount + "." + status.lastUpdateSubframe + ", " + CurrentUpdateFilter + ", deltaTime = " + deltaTime);
                    vcam.UpdateCameraState(worldUp, deltaTime);
                    ++status.lastUpdateSubframe;
                }
                status.lastUpdateFrame = now;
            }

            mUpdateStatus[vcam] = status;
            //UnityEngine.Profiling.Profiler.EndSample();
            return(true);
        }
Esempio n. 24
0
        public async void InnerExecuteUpdate()
        {
            Owner.Executing = true;
            try
            {
                var result = await Owner.Service.UpdateAsync(Owner.Database, Owner.Collection, UpdateFilter.Deserialize <BsonDocument>(Constants.UpdateFilterProperty), UpdateDocument.Deserialize <BsonDocument>(Constants.UpdateDocumentProperty), UpdateMulti, Owner.Cts.Token);

                Owner.RawResult  = result.ToJson(Options.JsonWriterSettings);
                Owner.RawResult += Environment.NewLine;
                Owner.RawResult += Environment.NewLine;
                Owner.RawResult += "Modified Count: " + result.ModifiedCount;

                Owner.SelectedViewIndex = 1;
                Owner.Root = null;
            }
            catch (BsonExtensions.BsonParseException ex)
            {
                LoggerHelper.Logger.Error("Exception while executing Update command", ex);
                Owner.SelectedViewIndex = 1;
                Owner.RawResult         = ex.Message;
                Owner.Root = null;
                Messenger.Default.Send(new NotificationMessage <BsonExtensions.BsonParseException>(this, ex, Constants.UpdateParseException));
            }
            catch (Exception ex)
            {
                LoggerHelper.Logger.Error("Exception while executing Update command", ex);
                Owner.RawResult         = ex.Message;
                Owner.SelectedViewIndex = 1;
                Owner.Root = null;
            }
            finally
            {
                Owner.Executing = false;
                Owner.ShowPager = false;
            }
        }
Esempio n. 25
0
        public override void OnInitialize()
        {
            uIElement = new UIElement();
            uIElement.Width.Set(0f, 0.8f);
            uIElement.MaxWidth.Set(600f, 0f);
            uIElement.Top.Set(220f, 0f);
            uIElement.Height.Set(-220f, 1f);
            uIElement.HAlign = 0.5f;

            uIPanel = new UIPanel();
            uIPanel.Width.Set(0f, 1f);
            uIPanel.Height.Set(-110f, 1f);
            uIPanel.BackgroundColor = new Color(33, 43, 79) * 0.8f;
            uIPanel.PaddingTop      = 0f;
            uIElement.Append(uIPanel);

            uILoader = new UILoaderAnimatedImage(0.5f, 0.5f, 1f);

            modList = new UIList();
            modList.Width.Set(-25f, 1f);
            modList.Height.Set(-50f, 1f);
            modList.Top.Set(50f, 0f);
            modList.ListPadding = 5f;
            uIPanel.Append(modList);

            UIScrollbar uIScrollbar = new UIScrollbar();

            uIScrollbar.SetView(100f, 1000f);
            uIScrollbar.Height.Set(-50f, 1f);
            uIScrollbar.Top.Set(50f, 0f);
            uIScrollbar.HAlign = 1f;
            uIPanel.Append(uIScrollbar);

            modList.SetScrollbar(uIScrollbar);
            uIHeaderTextPanel        = new UITextPanel <string>(Language.GetTextValue("tModLoader.MenuModBrowser"), 0.8f, true);
            uIHeaderTextPanel.HAlign = 0.5f;
            uIHeaderTextPanel.Top.Set(-35f, 0f);
            uIHeaderTextPanel.SetPadding(15f);
            uIHeaderTextPanel.BackgroundColor = new Color(73, 94, 171);
            uIElement.Append(uIHeaderTextPanel);

            reloadButton = new UITextPanel <string>(Language.GetTextValue("tModLoader.MBGettingData"), 1f, false);
            reloadButton.Width.Set(-10f, 0.5f);
            reloadButton.Height.Set(25f, 0f);
            reloadButton.VAlign = 1f;
            reloadButton.Top.Set(-65f, 0f);
            reloadButton.OnMouseOver += UICommon.FadedMouseOver;
            reloadButton.OnMouseOut  += UICommon.FadedMouseOut;
            reloadButton.OnClick     += ReloadList;
            uIElement.Append(reloadButton);

            UITextPanel <string> backButton = new UITextPanel <string>(Language.GetTextValue("UI.Back"), 1f, false);

            backButton.Width.Set(-10f, 0.5f);
            backButton.Height.Set(25f, 0f);
            backButton.VAlign = 1f;
            backButton.Top.Set(-20f, 0f);
            backButton.OnMouseOver += UICommon.FadedMouseOver;
            backButton.OnMouseOut  += UICommon.FadedMouseOut;
            backButton.OnClick     += BackClick;
            uIElement.Append(backButton);

            clearButton = new UITextPanel <string>(Language.GetTextValue("tModLoader.MBClearSpecialFilter", "??"), 1f, false);
            clearButton.Width.Set(-10f, 0.5f);
            clearButton.Height.Set(25f, 0f);
            clearButton.HAlign = 1f;
            clearButton.VAlign = 1f;
            clearButton.Top.Set(-65f, 0f);
            clearButton.BackgroundColor = Color.Purple * 0.7f;
            clearButton.OnMouseOver    += (s, e) => UICommon.CustomFadedMouseOver(Color.Purple, s, e);
            clearButton.OnMouseOut     += (s, e) => UICommon.CustomFadedMouseOut(Color.Purple * 0.7f, s, e);
            clearButton.OnClick        += (s, e) =>
            {
                Interface.modBrowser.SpecialModPackFilter      = null;
                Interface.modBrowser.SpecialModPackFilterTitle = null;
                Interface.modBrowser.updateNeeded = true;
                Main.PlaySound(SoundID.MenuTick);
            };

            downloadAllButton = new UITextPanel <string>(Language.GetTextValue("tModLoader.MBDownloadAll"), 1f, false);
            downloadAllButton.Width.Set(-10f, 0.5f);
            downloadAllButton.Height.Set(25f, 0f);
            downloadAllButton.HAlign = 1f;
            downloadAllButton.VAlign = 1f;
            downloadAllButton.Top.Set(-20f, 0f);
            downloadAllButton.BackgroundColor = Color.Azure * 0.7f;
            downloadAllButton.OnMouseOver    += (s, e) => UICommon.CustomFadedMouseOver(Color.Azure, s, e);
            downloadAllButton.OnMouseOut     += (s, e) => UICommon.CustomFadedMouseOut(Color.Azure * 0.7f, s, e);
            downloadAllButton.OnClick        += (s, e) => DownloadMods(SpecialModPackFilter, SpecialModPackFilterTitle);

            updateAllButton = new UITextPanel <string>(Language.GetTextValue("tModLoader.MBUpdateAll"), 1f, false);
            updateAllButton.Width.Set(-10f, 0.5f);
            updateAllButton.Height.Set(25f, 0f);
            updateAllButton.HAlign = 1f;
            updateAllButton.VAlign = 1f;
            updateAllButton.Top.Set(-20f, 0f);
            updateAllButton.BackgroundColor = Color.Orange * 0.7f;
            updateAllButton.OnMouseOver    += UICommon.FadedMouseOver;
            updateAllButton.OnMouseOut     += UICommon.FadedMouseOut;
            updateAllButton.OnClick        += (s, e) =>
            {
                if (!loading)
                {
                    var updatableMods = items.Where(x => x.update && !x.updateIsDowngrade).Select(x => x.mod).ToList();
                    DownloadMods(updatableMods, Language.GetTextValue("tModLoader.MBUpdateAll"));
                }
            };

            Append(uIElement);

            UIElement upperMenuContainer = new UIElement();

            upperMenuContainer.Width.Set(0f, 1f);
            upperMenuContainer.Height.Set(32f, 0f);
            upperMenuContainer.Top.Set(10f, 0f);
            Texture2D texture = Texture2D.FromStream(Main.instance.GraphicsDevice, Assembly.GetExecutingAssembly().GetManifestResourceStream("Terraria.ModLoader.UI.UIModBrowserIcons.png"));

            SortModeFilterToggle = new UICycleImage(texture, 6, 32, 32, 0, 0);
            SortModeFilterToggle.setCurrentState((int)sortMode);
            SortModeFilterToggle.OnClick += (a, b) =>
            {
                sortMode     = sortMode.NextEnum();
                updateNeeded = true;
            };
            SortModeFilterToggle.OnRightClick += (a, b) =>
            {
                sortMode     = sortMode.PreviousEnum();
                updateNeeded = true;
            };
            SortModeFilterToggle.Left.Set((float)(0 * 36 + 8), 0f);
            _categoryButtons.Add(SortModeFilterToggle);
            upperMenuContainer.Append(SortModeFilterToggle);

            UpdateFilterToggle = new UICycleImage(texture, 3, 32, 32, 34, 0);
            UpdateFilterToggle.setCurrentState((int)updateFilterMode);
            UpdateFilterToggle.OnClick += (a, b) =>
            {
                updateFilterMode = updateFilterMode.NextEnum();
                updateNeeded     = true;
            };
            UpdateFilterToggle.OnRightClick += (a, b) =>
            {
                updateFilterMode = updateFilterMode.PreviousEnum();
                updateNeeded     = true;
            };
            UpdateFilterToggle.Left.Set((float)(1 * 36 + 8), 0f);
            _categoryButtons.Add(UpdateFilterToggle);
            upperMenuContainer.Append(UpdateFilterToggle);

            ModSideFilterToggle = new UICycleImage(texture, 5, 32, 32, 34 * 5, 0);
            ModSideFilterToggle.setCurrentState((int)modSideFilterMode);
            ModSideFilterToggle.OnClick += (a, b) =>
            {
                modSideFilterMode = modSideFilterMode.NextEnum();
                updateNeeded      = true;
            };
            ModSideFilterToggle.OnRightClick += (a, b) =>
            {
                modSideFilterMode = modSideFilterMode.PreviousEnum();
                updateNeeded      = true;
            };
            ModSideFilterToggle.Left.Set((float)(2 * 36 + 8), 0f);
            _categoryButtons.Add(ModSideFilterToggle);
            upperMenuContainer.Append(ModSideFilterToggle);

            UIPanel filterTextBoxBackground = new UIPanel();

            filterTextBoxBackground.Top.Set(0f, 0f);
            filterTextBoxBackground.Left.Set(-170, 1f);
            filterTextBoxBackground.Width.Set(135f, 0f);
            filterTextBoxBackground.Height.Set(40f, 0f);
            filterTextBoxBackground.OnRightClick += (a, b) => filterTextBox.SetText("");
            upperMenuContainer.Append(filterTextBoxBackground);

            filterTextBox = new UIInputTextField(Language.GetTextValue("tModLoader.ModsTypeToSearch"));
            filterTextBox.Top.Set(5, 0f);
            filterTextBox.Left.Set(-160, 1f);
            filterTextBox.Width.Set(100f, 0f);
            filterTextBox.Height.Set(10f, 0f);
            filterTextBox.OnTextChange += (sender, e) => updateNeeded = true;
            upperMenuContainer.Append(filterTextBox);

            SearchFilterToggle = new UICycleImage(texture, 2, 32, 32, 34 * 2, 0);
            SearchFilterToggle.setCurrentState((int)searchFilterMode);
            SearchFilterToggle.OnClick += (a, b) =>
            {
                searchFilterMode = searchFilterMode.NextEnum();
                updateNeeded     = true;
            };
            SearchFilterToggle.OnRightClick += (a, b) =>
            {
                searchFilterMode = searchFilterMode.PreviousEnum();
                updateNeeded     = true;
            };
            SearchFilterToggle.Left.Set(545f, 0f);
            _categoryButtons.Add(SearchFilterToggle);
            upperMenuContainer.Append(SearchFilterToggle);
            uIPanel.Append(upperMenuContainer);
        }
Esempio n. 26
0
 public static UpdateFilter <TResult> Select <TResult, TSource>(this UpdateFilter <TSource> filter,
                                                                Func <TSource, TResult> mapper)
 {
     return(new(filter.client, update => mapper(filter.Mapper(update)), filter.Filters));
 }