Exemple #1
0
        public UpdateService()
        {
            _gitHubClient = new GitHubClient(new ProductHeaderValue("DiverOfDark_BudgetTracker", Startup.CommmitHash));
            _timer        = new Timer(TimerCallback, null, TimeSpan.FromSeconds(1), TimeSpan.FromHours(1));

            Anchors.Add(_timer.Dispose);
        }
        protected override Task Init()
        {
            _collection = new ObjectRepositoryServerObservableCollection <SpentCategoryModel, SpentCategoriesStream>(
                ObjectRepository,
                SendUpdate,
                (x, i) => new SpentCategoriesStream {
                Added = ToSpentCategory(x)
            },
                (x, i) => new SpentCategoriesStream {
                Removed = ToSpentCategory(x)
            },
                (x, i) => new SpentCategoriesStream {
                Updated = ToSpentCategory(x)
            },
                list =>
            {
                var model = new SpentCategoriesStream {
                    Snapshot = new SpentCategoryList()
                };
                model.Snapshot.SpentCategories.AddRange(list.Select(ToSpentCategory).ToList());
                return(model);
            });

            Anchors.Add(() => _collection.Dispose());

            return(Task.CompletedTask);
        }
        public override void OnCalculateMinMax()
        {
            // It is important to set MinValue and MaxValue to the min/max Y values your drawing tool uses if you want it to support auto scale
            MinValue = double.MaxValue;
            MaxValue = double.MinValue;

            if (!IsVisible)
            {
                return;
            }

            // return min/max values only if something has been actually drawn
            if (Anchors.Any(a => !a.IsEditing))
            {
                foreach (ChartAnchor anchor in Anchors)
                {
                    if (anchor.DisplayName == RewardAnchor.DisplayName && !DrawTarget)
                    {
                        continue;
                    }

                    MinValue = Math.Min(anchor.Price, MinValue);
                    MaxValue = Math.Max(anchor.Price, MaxValue);
                }
            }
        }
Exemple #4
0
        public void RemoveAnchor(int index)
        {
            PSplineAnchor a = Anchors[index];
            List <int>    segmentIndices = FindSegments(index);

            for (int i = 0; i < segmentIndices.Count; ++i)
            {
                int sIndex = segmentIndices[i];
                Segments[sIndex].Dispose();
            }

            Segments.RemoveAll(s => s.StartIndex == index || s.EndIndex == index);
            Segments.ForEach(s =>
            {
                if (s.StartIndex > index)
                {
                    s.StartIndex -= 1;
                }
                if (s.EndIndex > index)
                {
                    s.EndIndex -= 1;
                }
            });
            Anchors.RemoveAt(index);
        }
Exemple #5
0
 protected override Task Init()
 {
     _collection = new ObjectRepositoryServerObservableCollection <DebtModel, DebtsStream>(
         ObjectRepository,
         SendUpdate,
         (x, i) => new DebtsStream {
         Added = ToDebtView(x)
     },
         (x, i) => new DebtsStream {
         Removed = ToDebtView(x)
     },
         (x, i) => new DebtsStream {
         Updated = ToDebtView(x)
     },
         list =>
     {
         var model = new DebtsStream {
             Snapshot = new DebtsList()
         };
         model.Snapshot.Debts.AddRange(list.Select(ToDebtView).ToList());
         return(model);
     });
     Anchors.Add(_collection.Dispose);
     return(Task.CompletedTask);
 }
 public override bool IsVisibleOnChart(ChartControl chartControl, ChartScale chartScale, DateTime firstTimeOnChart, DateTime lastTimeOnChart)
 {
     if (DrawingState == DrawingState.Building)
     {
         return(true);
     }
     if (Mode == RegionHighlightMode.Time)
     {
         if (Anchors.Any(a => a.Time >= firstTimeOnChart && a.Time <= lastTimeOnChart))
         {
             return(true);
         }
         // check crossovers
         if (StartAnchor.Time <= firstTimeOnChart && EndAnchor.Time >= lastTimeOnChart)
         {
             return(true);
         }
         if (EndAnchor.Time <= firstTimeOnChart && StartAnchor.Time >= lastTimeOnChart)
         {
             return(true);
         }
         return(false);
     }
     else
     {
         // check if active y range highlight is on scale or cross through
         if (Anchors.Any(a => a.Price <= chartScale.MaxValue && a.Price >= chartScale.MinValue))
         {
             return(true);
         }
         return((StartAnchor.Price <= chartScale.MinValue && EndAnchor.Price >= chartScale.MaxValue) ||
                (EndAnchor.Price <= chartScale.MinValue && StartAnchor.Price >= chartScale.MaxValue));
     }
 }
        public void Write(BinaryWriter w)
        {
            w.Write(Difficulty);
            Anchors.Write(w);
            AnchorExtensions.Write(w);
            Fingerprints1.Write(w);
            Fingerprints2.Write(w);
            Notes.Write(w);

            w.Write(PhraseCount);
            foreach (float notes in AverageNotesPerIteration)
            {
                w.Write(notes);
            }

            w.Write(PhraseIterationCount1);
            foreach (int notes in NotesInIteration1)
            {
                w.Write(notes);
            }

            w.Write(PhraseIterationCount2);
            foreach (int notes in NotesInIteration2)
            {
                w.Write(notes);
            }
        }
Exemple #8
0
        protected override Task Init()
        {
            _collection = new ObjectRepositoryServerObservableCollection <MoneyColumnMetadataModel, MoneyColumnMetadataStream>(
                ObjectRepository,
                SendUpdate,
                (x, i) => new MoneyColumnMetadataStream {
                Added = ToStream(x)
            },
                (x, i) => new MoneyColumnMetadataStream {
                Removed = ToStream(x)
            },
                (x, i) => new MoneyColumnMetadataStream {
                Updated = ToStream(x)
            },
                list =>
            {
                var model = new MoneyColumnMetadataStream {
                    Snapshot = new MoneyColumnMetadataList()
                };
                model.Snapshot.MoneyColumnMetadatas.AddRange(list.Select(ToStream).ToList());
                return(model);
            });

            Anchors.Add(() => _collection.Dispose());

            return(Task.CompletedTask);
        }
Exemple #9
0
        public async Task Send(IServerStreamWriter <T> writer, ServerCallContext context)
        {
            await Init();

            ObjectRepository.ModelChanged += OnModelRepositoryChanged;
            Anchors.Add(() => ObjectRepository.ModelChanged -= OnModelRepositoryChanged);
            try
            {
                while (!context.CancellationToken.IsCancellationRequested && !IsDisposed)
                {
                    if (_sendModelEvent.IsSet)
                    {
                        _sendModelEvent.Reset();
                        while (_queue.TryDequeue(out var item))
                        {
                            await writer.WriteAsync(item);
                        }
                    }

                    await _sendModelEvent.WaitAsync(context.CancellationToken);
                }
            } catch (Exception ex) when(ex is RpcException exception && exception.StatusCode == StatusCode.Cancelled || ex is TaskCanceledException)
            {
                // cancelled, not an issue
            }
        }
Exemple #10
0
        private void RemoveAnchorPropertyXML(int AnchorId, int propertyIdx)
        {
            XmlNode propInfo = propInfoNode();

            if (propInfo == null)
            {
                return;
            }
            int Idx = -1;

            foreach (XmlNode Anchors in propInfo.SelectNodes("aAnchors"))
            {
                foreach (XmlNode Anchor in Anchors.SelectNodes("Item"))
                {
                    if (++Idx == AnchorId)
                    {
                        foreach (XmlNode props in Anchor.SelectNodes("props"))
                        {
                            string propsstr = props.InnerText;
                            if (propsstr.Length > 2)
                            {
                                propsstr = propsstr.Substring(0, propsstr.Length - 2);
                            }
                            else
                            {
                                propsstr = "";
                            }
                            props.InnerText = propsstr;
                        }
                    }
                }
            }
            foreach (XmlNode numAvail in propInfo.SelectNodes("numAvailProps"))
            {
                XmlElement elemnumAvail = (XmlElement)numAvail;
                elemnumAvail.SetAttribute("value", (Convert.ToInt32(elemnumAvail.GetAttribute("value")) - 1).ToString());
            }

            foreach (XmlNode pmd in propInfo.SelectNodes("aPropMetaData"))
            {
                foreach (XmlNode item in pmd.SelectNodes("Item"))
                {
                    foreach (XmlNode anchorId in item.SelectNodes("anchorId"))
                    {
                        XmlElement elemanchorId = (XmlElement)anchorId;
                        foreach (XmlNode propId in item.SelectNodes("propId"))
                        {
                            XmlElement elempropId = (XmlElement)propId;
                            if ((Convert.ToInt32(elemanchorId.GetAttribute("value")) == AnchorId) &&
                                (Convert.ToInt32(elempropId.GetAttribute("value")) == propertyIdx))
                            {
                                pmd.RemoveChild(item);
                                return;
                            }
                        }
                    }
                }
            }
        }
 public override IEnumerable <AlertConditionItem> GetAlertConditionItems()
 {
     return(Anchors.Select(anchor => new AlertConditionItem  {
         Name = anchor.DisplayName,
         ShouldOnlyDisplayName = true,
         Tag = anchor
     }));
 }
Exemple #12
0
 /// <summary>
 /// 从指定Layer中删除
 /// </summary>
 /// <param name="layer"></param>
 public virtual void RemoveOperationShapeFromLayer(ILayer <IPrimitive> layer)
 {
     Anchors.ForEach(a => a.RemoveFromLayer(layer));
     ResizeHandles.ForEach(a => a.RemoveFromLayer(layer));
     if (__bound != null)
     {
         layer.Remove(__bound);
     }
 }
Exemple #13
0
 public virtual void AddOperationShapeToLayer(ILayer <IPrimitive> layer)
 {
     if (__bound != null)
     {
         layer.Add(__bound);
     }
     Anchors.ForEach(a => a.AddToLayer(layer));
     ResizeHandles.ForEach(a => a.AddToLayer(layer));
 }
Exemple #14
0
            internal static unsafe void Invoke(IntPtr obj, Anchors InAnchors)
            {
                long *p = stackalloc long[] { 0L, 0L, 0L };
                byte *b = (byte *)p;

                *((Anchors *)(b + 0)) = InAnchors;
                Main.GetProcessEvent(obj, SetAnchors_ptr, new IntPtr(p));;
            }
        }
Exemple #15
0
 private AnchorTemplate updateStart(ref Anchors anchors, double percentage, double margin, double?size)
 {
     anchors = new Anchors(
         new Anchor(percentage, margin),
         size.HasValue
             ? new Anchor(percentage, margin + size.Value)
             : anchors.End
         );
     return(this);
 }
Exemple #16
0
 private AnchorTemplate updateEnd(ref Anchors anchors, double percentage, double margin, double?size)
 {
     anchors = new Anchors(
         size.HasValue
             ? new Anchor(percentage, -(margin + size.Value))
             : anchors.Start,
         new Anchor(percentage, -margin)
         );
     return(this);
 }
        private void AnalyseBoardTileAtCoordinatesAndAddIfItIsAnAnchor(int X, int Y)
        {
            BoardTile tile = Board.GetBoardTileAtCoordinates(X, Y);

            if (tile == null || tile.CharTile != null || AddedAnchors.Contains(tile))
            {
                return;
            }
            Anchors.Add(tile);
            AddedAnchors.Add(tile);
        }
Exemple #18
0
        public GrpcViewModelBase(ObjectRepository objectRepository, ILogger logger)
        {
            ObjectRepository = objectRepository;
            logger.LogInformation($"Creating {GetType().Name}.");

            Anchors.Add(() =>
            {
                logger.LogInformation($"Disposing {GetType().Name}.");
                _sendModelEvent.Set();
            });
        }
        protected override Task Init()
        {
            var timer = new Timer(1000);

            timer.Elapsed += SendScrenshot;
            timer.Start();
            SendScrenshot(null, null);
            Anchors.Add(timer.Dispose);
            Anchors.Add(() => timer.Elapsed -= SendScrenshot);
            return(Task.CompletedTask);
        }
Exemple #20
0
        protected void InitializeDefaultAnchor(RectangleF rect, IPrimitiveProvider provider)
        {
            var a = new AnchorHandle(rect.GetCornerPoint(CornerType.Top), this, TOP_ANCHOR, provider);

            Anchors.Add(a);
            a = new AnchorHandle(rect.GetCornerPoint(CornerType.LeftMiddle), this, LEFT_ANCHOR, provider);
            Anchors.Add(a);
            a = new AnchorHandle(rect.GetCornerPoint(CornerType.RightMiddle), this, RIGHT_ANCHOR, provider);
            Anchors.Add(a);
            a = new AnchorHandle(rect.GetCornerPoint(CornerType.Bottom), this, BOTTOM_ANCHOR, provider);
            Anchors.Add(a);
        }
Exemple #21
0
 protected void DisposeAnchorsAndResizeHandles()
 {
     foreach (var a in Anchors)
     {
         a.Dispose();
     }
     Anchors.Clear();
     foreach (var a in ResizeHandles)
     {
         a.Dispose();
     }
     ResizeHandles.Clear();
 }
Exemple #22
0
        public void EntityAnchorArgument_ParseShouldFail_BecauseInvalidEntityAnchor()
        {
            // Arrange
            Anchors.Set("[\"foo\",\"bar\"]");
            EntityAnchorArgument argument = new EntityAnchorArgument();
            IStringReader        reader   = new StringReader("baz");

            // Act
            ReadResults readResults = argument.Parse(reader, out _);

            // Assert
            Assert.IsFalse(readResults.Successful);
        }
Exemple #23
0
        public void EntityAnchorArgument_ParseShouldSucceed()
        {
            // Arrange
            Anchors.Set("[\"foo\",\"bar\"]");
            EntityAnchorArgument argument = new EntityAnchorArgument();
            IStringReader        reader   = new StringReader("foo");

            // Act
            ReadResults readResults = argument.Parse(reader, out _);

            // Assert
            Assert.IsTrue(readResults.Successful);
        }
Exemple #24
0
        public override void OnCalculateMinMax()
        {
            MinValue = double.MaxValue;
            MaxValue = double.MinValue;

            if (!IsVisible)
            {
                return;
            }

            MinValue = Anchors.Select(a => a.Price).Min();
            MaxValue = Anchors.Select(a => a.Price).Max();
        }
Exemple #25
0
 public void Unwrap(IBundle bundle)
 {
     if (bundle != null)
     {
         #region Unwrap the bundle
         Anchors.Clear();
         this.Controller.Model.Unwrap(bundle.Entities);
         Rectangle rec = Utils.BoundingRectangle(bundle.Entities);
         rec.Inflate(30, 30);
         this.Controller.View.Invalidate(rec);
         #endregion
     }
 }
        public UnitTest1()
        {
            CommandAssemblysLoader.EntryAssembly = Assembly.GetAssembly(typeof(UnitTestMef));
            Anchors.Add(ProgramsCommand.Anchor.FullName);
            var root       = Assembly.GetAssembly(typeof(UnitTestMef)).Location;
            var dir        = Path.GetDirectoryName(root);
            var components = dir;
            var dd         = Programs.ProgramsRepository;

            //  var components = Path.Combine(dir, "components");
            CommandCompositionHelper = new CommandCompositionHelper(components);
            CommandCompositionHelper.AssembleCommandComponents();
            CommandCompositionHelper.Initialize();
        }
 /// <summary>
 /// Creates a clone of this instance
 /// </summary>
 /// <returns>A clone of this instance</returns>
 public object Clone()
 {
     return(new Geometry
     {
         Type = (Type != null) ? string.Copy(Type) : null,
         Anchors = (float[])Anchors.Clone(),
         PrintRadius = PrintRadius,
         Radius = Radius,
         HomedHeight = HomedHeight,
         AngleCorrections = (float[])AngleCorrections.Clone(),
         EndstopAdjustments = (float[])EndstopAdjustments.Clone(),
         Tilt = (float[])Tilt.Clone()
     });
 }
Exemple #28
0
    /// <summary>
    /// Will check if this bridge has anchors that were saved. basically
    /// see if has a saved file. otherwise just call GetBridgeAnchors()
    ///
    /// Also if has a saved file will reassign Anchors. Anchors = saved;
    /// </summary>
    /// <returns></returns>
    internal Vector3[] GetBridgeAnchorsCheckIfSave()
    {
        List <Vector3> saved = BuildingPot.Control.Registro.ReturnMySavedAnchors(MyId);

        //means has a saved value. then bz bridge gets scaled up anchors will reassign here
        if (saved.Count > 0)
        {
            Anchors = saved;
            return(Anchors.ToArray());
        }

        //UVisHelp.CreateHelpers(copy.ToList(), Root.yellowCube);
        return(GetBridgeAnchors().ToArray());
    }
    // A realtime database transaction receives MutableData which can be modified
    // and returns a TransactionResult which is either TransactionResult.Success(data) with
    // modified data or TransactionResult.Abort() which stops the transaction with no changes.
    TransactionResult AddAnchorTransaction(MutableData mutableData)
    {
        List <object> Anchors = mutableData.Value as List <object>;

        if (Anchors == null)
        {
            Anchors = new List <object>();
        }
        //else if (mutableData.ChildrenCount >= MaxScores)
        //{
        //    // If the current list of scores is greater or equal to our maximum allowed number,
        //    // we see if the new score should be added and remove the lowest existing score.
        //    long minScore = long.MaxValue;
        //    object minVal = null;
        //    foreach (var child in users)
        //    {
        //        if (!(child is Dictionary<string, object>))
        //            continue;
        //        long childScore = (long)((Dictionary<string, object>)child)["hitCounter"];
        //        if (childScore < minScore)
        //        {
        //            minScore = childScore;
        //            minVal = child;
        //        }
        //    }
        //    // If the new score is lower than the current minimum, we abort.
        //    if (minScore > hitCounter)
        //    {
        //        return TransactionResult.Abort();
        //    }
        //    // Otherwise, we remove the current lowest to be replaced with the new score.
        //    users.Remove(minVal);
        //}

        // Now we add the new score as a new entry that contains the email address and score.

        //newNameMap["hitCounter"] =hitCounter;

        //newNameMap["scale"] = treeScale;
        newNameMap["Room"]       = roomNumber;
        newNameMap["IP"]         = IPAddress;
        newNameMap["playerName"] = playerName;

        Anchors.Add(newNameMap);

        // You must set the Value to indicate data at that location has changed.
        mutableData.Value = Anchors;
        return(TransactionResult.Success(mutableData));
    }
 protected override void _Execute(atom.Trace context, string url, int level)
 {
     url = "https://www.ixbt.com/";
     {
         var a_Context = Configuration.Default.WithDefaultLoader(new LoaderOptions()
         {
             IsNavigationDisabled = false, IsResourceLoadingEnabled = false
         });
         {
             var a_Context1 = BrowsingContext.New(a_Context).OpenAsync(url).Result;
             {
                 context.
                 SetState(NAME.STATE.HEADER).
                 Send(NAME.SOURCE.PREVIEW, NAME.TYPE.FOLDER, level, "[[Info]]");
                 {
                     context.Send(NAME.SOURCE.PREVIEW, NAME.TYPE.VARIABLE, level + 1, "[[File Name]]", url);
                     context.Send(NAME.SOURCE.PREVIEW, NAME.TYPE.VARIABLE, level + 1, "[[File Size]]", a_Context1.Source?.Length.ToString());
                     context.Send(NAME.SOURCE.PREVIEW, NAME.TYPE.VARIABLE, level + 1, "[[Raw Format]]", "HTML");
                 }
             }
             {
                 var a_Size = GetProperty(NAME.PROPERTY.PREVIEW_MEDIA_SIZE);
                 for (var i = 0; i < a_Size; i++)
                 {
                     context.Send(NAME.SOURCE.PREVIEW, NAME.TYPE.PREVIEW, level);
                 }
             }
             {
                 context.
                 SetState(NAME.STATE.FOOTER).
                 Send(NAME.SOURCE.PREVIEW, NAME.TYPE.FOLDER, level, "[[Document]]");
                 {
                     Anchors.Execute(context, level + 1, a_Context1.Anchors);
                     Forms.Execute(context, level + 1, a_Context1.Forms);
                     Images.Execute(context, level + 1, a_Context1.Images);
                     Links.Execute(context, level + 1, a_Context1.Links);
                 }
             }
         }
     }
     {
         var a_Context = new Thread(__BrowserThread);
         {
             a_Context.SetApartmentState(ApartmentState.STA);
             a_Context.Start(url);
         }
     }
 }
Exemple #31
0
 /// <summary>
 /// Set the panel's anchor style with specific <code>Anchors</code>
 /// This is incompatible with docking
 /// </summary>
 /// <param name="anchors">The <code>Anchors</code> enum that defines which sides the panel should be anchored to the parent panel</param>
 public void SetAnchorStyle(Anchors anchors)
 {
     this.AnchorStyle = anchors;
     this.ShouldAnchor = true;
 }