Esempio n. 1
0
        static void Main(string[] args)
        {
            int[] numbers = new int[] { 1, 5, 0, 4, -9, 4, -12, 7, -12, 3, -2, 5 };

            Console.WriteLine(string.Join(" ", numbers));

            OpArray oa = new OpArray(ref numbers);

            Edits[] ed = new Edits[]
            {
                oa.ConvertNegativeToNull,
                oa.SortToUp,
                oa.DoubleElementsToFront
            };

            Calcs[] ca = new Calcs[]
            {
                oa.CountNegativeNumbers,
                oa.CountSimpleNumbers,
                oa.SumAll
            };

            Menu[] m = new Menu[]
            {
                oa.Menu,
                oa.MenuCalc,
                oa.MenuEdit
            };



            m[0]();

            int cat = Convert.ToInt32(Console.ReadLine());

            m[cat]();

            int sub = Convert.ToInt32(Console.ReadLine());

            switch (cat)
            {
            case 1:
                Console.WriteLine(ca[sub - 1]());
                break;

            case 2:
                ed[sub - 1]();
                Console.WriteLine(string.Join(" ", oa.GetNumbers()));
                break;

            default:
                break;
            }
        }
        public void _method_ctor(params Instance[] types)
        {
            var parts = new List <Instance>();

            Parts.Set(parts);

            //offer components available in place of calling - they can be added to ctor
            TypeAssembly callerAssembly = GetCallerAssembly();

            Edits.AppendArgument(This, types.Length + 1, "Add component type", (v) => addComponentTypeProvider(callerAssembly, v));

            //keeping in closure
            var edits    = Edits;
            var thisInst = This;

            //collect names of types
            for (var i = 0; i < types.Length; ++i)
            {
                //because of keeping values in closure
                var index = i;
                var type  = types[index];

                AsyncCall <string>(type, "get_FullName", (fullname) =>
                {
                    var info = TypeDescriptor.Create(fullname);
                    var part = Context.Machine.CreateInstance(info);

                    edits.SetOptional(index + 1);
                    edits.AttachRemoveArgument(thisInst, part, index + 1, "Remove component type");

                    parts.Add(part);
                });
            }
        }
        public IEnumerable <T> ToPoco <T>() where T : new()
        {
            var accessors = GetAccessors <T>();

            if (Edits == null)
            {
                return(new T[0]);
            }

            return(Edits.Select(r =>
            {
                if (r == null)
                {
                    throw new ApplicationException("Received row can't be null");
                }
                if (r.Length != accessors.Length)
                {
                    throw new ApplicationException(string.Format("Received row should have {0} columns. {1} received", accessors.Length, r.Length));
                }
                var res = new T();
                for (int i = 0; i < r.Length; i++)
                {
                    var a = accessors[i];
                    object o = r[i].ToType(null, true, a.PropertyType);
                    a.SetValue(res, o);
                }
                return res;
            }));
        }
Esempio n. 4
0
 public override void WriteBinary(ESPWriter writer)
 {
     if (ResponseData != null)
     {
         ResponseData.WriteBinary(writer);
     }
     if (ResponseText != null)
     {
         ResponseText.WriteBinary(writer);
     }
     if (ScriptNotes != null)
     {
         ScriptNotes.WriteBinary(writer);
     }
     if (Edits != null)
     {
         Edits.WriteBinary(writer);
     }
     if (SpeakerAnimation != null)
     {
         SpeakerAnimation.WriteBinary(writer);
     }
     if (ListenerAnimation != null)
     {
         ListenerAnimation.WriteBinary(writer);
     }
 }
Esempio n. 5
0
        public override void WriteXML(XElement ele, ElderScrollsPlugin master)
        {
            XElement subEle;

            if (ResponseData != null)
            {
                ele.TryPathTo("ResponseData", true, out subEle);
                ResponseData.WriteXML(subEle, master);
            }
            if (ResponseText != null)
            {
                ele.TryPathTo("ResponseText", true, out subEle);
                ResponseText.WriteXML(subEle, master);
            }
            if (ScriptNotes != null)
            {
                ele.TryPathTo("ScriptNotes", true, out subEle);
                ScriptNotes.WriteXML(subEle, master);
            }
            if (Edits != null)
            {
                ele.TryPathTo("Edits", true, out subEle);
                Edits.WriteXML(subEle, master);
            }
            if (SpeakerAnimation != null)
            {
                ele.TryPathTo("SpeakerAnimation", true, out subEle);
                SpeakerAnimation.WriteXML(subEle, master);
            }
            if (ListenerAnimation != null)
            {
                ele.TryPathTo("ListenerAnimation", true, out subEle);
                ListenerAnimation.WriteXML(subEle, master);
            }
        }
Esempio n. 6
0
        public static void DrawImagesOnCanvas(SKCanvas canvas, SKBitmap leftBitmap, SKBitmap rightBitmap,
                                              Settings settings, Edits edits, DrawMode drawMode, bool isFov = false)
        {
            switch (drawMode)
            {
            case DrawMode.Cross:
            case DrawMode.GrayscaleRedCyanAnaglyph:
            case DrawMode.RedCyanAnaglyph:
                DrawImagesOnCanvasInternal(canvas, leftBitmap, rightBitmap,
                                           settings.BorderWidthProportion, settings.AddBorder, settings.BorderColor,
                                           edits.LeftCrop + edits.OutsideCrop, edits.InsideCrop + edits.RightCrop, edits.InsideCrop + edits.LeftCrop,
                                           edits.RightCrop + edits.OutsideCrop,
                                           edits.TopCrop, edits.BottomCrop,
                                           edits.LeftRotation, edits.RightRotation,
                                           edits.VerticalAlignment,
                                           edits.LeftZoom + (isFov ? edits.FovLeftCorrection : 0), edits.RightZoom + (isFov ? edits.FovRightCorrection : 0),
                                           edits.LeftKeystone, edits.RightKeystone,
                                           drawMode);
                break;

            case DrawMode.Parallel:
                DrawImagesOnCanvasInternal(canvas, rightBitmap, leftBitmap,
                                           settings.BorderWidthProportion, settings.AddBorder, settings.BorderColor,
                                           edits.InsideCrop + edits.LeftCrop, edits.RightCrop + edits.OutsideCrop,
                                           edits.LeftCrop + edits.OutsideCrop, edits.InsideCrop + edits.RightCrop,
                                           edits.TopCrop, edits.BottomCrop,
                                           edits.RightRotation, edits.LeftRotation,
                                           edits.VerticalAlignment,
                                           edits.RightZoom + (isFov ? edits.FovRightCorrection : 0), edits.LeftZoom + (isFov ? edits.FovLeftCorrection : 0),
                                           edits.RightKeystone, edits.LeftKeystone,
                                           drawMode);
                break;
            }
        }
Esempio n. 7
0
        public override void ReadXML(XElement ele, ElderScrollsPlugin master)
        {
            XElement subEle;

            if (ele.TryPathTo("ResponseData", false, out subEle))
            {
                if (ResponseData == null)
                {
                    ResponseData = new ResponseData();
                }

                ResponseData.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("ResponseText", false, out subEle))
            {
                if (ResponseText == null)
                {
                    ResponseText = new SimpleSubrecord <String>();
                }

                ResponseText.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("ScriptNotes", false, out subEle))
            {
                if (ScriptNotes == null)
                {
                    ScriptNotes = new SimpleSubrecord <String>();
                }

                ScriptNotes.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("Edits", false, out subEle))
            {
                if (Edits == null)
                {
                    Edits = new SimpleSubrecord <String>();
                }

                Edits.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("SpeakerAnimation", false, out subEle))
            {
                if (SpeakerAnimation == null)
                {
                    SpeakerAnimation = new RecordReference();
                }

                SpeakerAnimation.ReadXML(subEle, master);
            }
            if (ele.TryPathTo("ListenerAnimation", false, out subEle))
            {
                if (ListenerAnimation == null)
                {
                    ListenerAnimation = new RecordReference();
                }

                ListenerAnimation.ReadXML(subEle, master);
            }
        }
Esempio n. 8
0
 public void Remove(IEnumerable <Circuit.Element> Elements)
 {
     if (!Elements.Any())
     {
         return;
     }
     Edits.Do(new RemoveElements(Schematic, Elements));
 }
Esempio n. 9
0
 public static int CalculateJoinedCanvasWidthLessBorder(SKBitmap leftBitmap, SKBitmap rightBitmap,
                                                        Edits edits)
 {
     return(CalculateJoinedCanvasWidthLessBorderInternal(leftBitmap, rightBitmap,
                                                         edits.LeftCrop + edits.OutsideCrop, edits.InsideCrop + edits.RightCrop,
                                                         edits.InsideCrop + edits.LeftCrop,
                                                         edits.RightCrop + edits.OutsideCrop));
 }
Esempio n. 10
0
 public void AddWire(IList <Circuit.Coord> x)
 {
     Edits.BeginEditGroup();
     for (int i = 0; i < x.Count - 1; ++i)
     {
         AddWire(x[i], x[i + 1]);
     }
     Edits.EndEditGroup();
 }
Esempio n. 11
0
 private RaidEditConversation(ConversationService conversationService, RaidService raidService, IUser user, string raidId, Edits edit, IUserMessage userMessage) : base(conversationService, user)
 {
     this._edit        = edit;
     this._userMessage = userMessage;
     _raidService      = raidService;
     if (!_raidService.TryFindRaid(raidId, out _raid))
     {
         throw new KeyNotFoundException("The raid for this message was not found!");
     }
     ;
 }
        public async Task Handle_ExtractCodeBlockWithUsing()
        {
            // Arrange
            var documentPath = "c:/Test.razor";
            var documentUri  = new Uri(documentPath);
            var contents     = $"@page \"/test\"\n@using System.Diagnostics{Environment.NewLine}@code {{ private var x = 1; }}";
            var codeDocument = CreateCodeDocument(contents);

            var resolver     = new ExtractToCodeBehindCodeActionResolver(Dispatcher, CreateDocumentResolver(documentPath, codeDocument), FilePathNormalizer);
            var actionParams = new ExtractToCodeBehindCodeActionParams
            {
                Uri          = documentUri,
                RemoveStart  = contents.IndexOf("@code", StringComparison.Ordinal),
                ExtractStart = contents.IndexOf("{", StringComparison.Ordinal),
                ExtractEnd   = contents.IndexOf("}", StringComparison.Ordinal),
                RemoveEnd    = contents.IndexOf("}", StringComparison.Ordinal),
            };
            var data = JObject.FromObject(actionParams);

            // Act
            var workspaceEdit = await resolver.ResolveAsync(data, default);

            // Assert
            Assert.NotNull(workspaceEdit);
            Assert.NotNull(workspaceEdit.DocumentChanges);
            Assert.Equal(3, workspaceEdit.DocumentChanges !.Count());

            var documentChanges  = workspaceEdit.DocumentChanges !.ToArray();
            var createFileChange = documentChanges[0];

            Assert.True(createFileChange.IsCreateFile);

            var editCodeDocumentChange = documentChanges[1];

            Assert.NotNull(editCodeDocumentChange.TextDocumentEdit);
            var editCodeDocumentEdit = editCodeDocumentChange.TextDocumentEdit !.Edits.First();

            Assert.True(editCodeDocumentEdit.Range.Start.TryGetAbsoluteIndex(codeDocument.GetSourceText(), _logger, out var removeStart));
            Assert.Equal(actionParams.RemoveStart, removeStart);
            Assert.True(editCodeDocumentEdit.Range.End.TryGetAbsoluteIndex(codeDocument.GetSourceText(), _logger, out var removeEnd));
            Assert.Equal(actionParams.RemoveEnd, removeEnd);

            var editCodeBehindChange = documentChanges[2];

            Assert.NotNull(editCodeBehindChange.TextDocumentEdit);
            var editCodeBehindEdit = editCodeBehindChange.TextDocumentEdit !.Edits.First();

            Assert.Contains("using System.Diagnostics", editCodeBehindEdit.NewText, StringComparison.Ordinal);
            Assert.Contains("public partial class Test", editCodeBehindEdit.NewText, StringComparison.Ordinal);
            Assert.Contains("private var x = 1", editCodeBehindEdit.NewText, StringComparison.Ordinal);
            Assert.Contains("namespace test.Pages", editCodeBehindEdit.NewText, StringComparison.Ordinal);
        }
        public void _method_Compose(Instance batch)
        {
            Edits.Remove(ComposeEdit.Get());

            ReportChildAdd(1, "Composition batch");
            DirectChildren.Value.Add(batch);

            AsyncCall <Instance[]>(batch, "get_PartsToRemove", (toRemove) =>
            {
                AsyncCall <Instance[]>(batch, "get_PartsToAdd", (toAdd) =>
                {
                    composeWithCatalog(toAdd, toRemove);
                });
            });
        }
Esempio n. 14
0
        /// <summary>
        /// Reports that child has been added.
        /// </summary>
        /// <param name="attachedInstance">The attached instance.</param>
        /// <param name="childArgIndex">Index of the child argument.</param>
        /// <param name="childDescription">The child description.</param>
        /// <param name="isOptional">if set to <c>true</c> can be removed from call.</param>
        protected void ReportChildAdd(Instance attachedInstance, int childArgIndex, string childDescription, bool isOptional = false)
        {
            var child = CurrentArguments[childArgIndex];

            addChild(attachedInstance, child);

            if (isOptional)
            {
                Edits.SetOptional(childArgIndex);
            }

            var editName = UserInteraction.ExcludeName;

            Edits.AttachRemoveArgument(attachedInstance, child, childArgIndex, editName);
        }
Esempio n. 15
0
        /// <summary>
        /// Reports that child has been added in variable arguments parameter.
        /// </summary>
        /// <param name="childParamArgIndex">Index of the child parameter argument.</param>
        /// <param name="child">The child.</param>
        /// <param name="childDescription">The child description.</param>
        /// <param name="isOptional">if set to <c>true</c> can be removed from call.</param>
        protected void ReportParamChildAdd(int childParamArgIndex, Instance child, string childDescription, bool isOptional = false)
        {
            ++childParamArgIndex;
            var attachedInstance = This;

            addChild(attachedInstance, child);

            if (isOptional)
            {
                Edits.SetOptional(childParamArgIndex);
            }

            var editName = UserInteraction.ExcludeName;

            Edits.AttachRemoveArgument(attachedInstance, child, childParamArgIndex, editName);
        }
        /// <summary>
        /// Runtime member definition.
        /// </summary>
        /// <param name="constructedParts">The constructed parts.</param>
        public void _method_ComposeParts(params Instance[] constructedParts)
        {
            //there is already compose part call
            Edits.Remove(ComposeEdit.Get());
            //so we will accept components to this call
            var e = Edits;

            AppendArg(constructedParts.Length + 1, UserInteraction.AcceptEditName, (v) => acceptAppendComponent(e, v));

            DirectChildren.Value.AddRange(constructedParts);
            for (int i = 0; i < constructedParts.Length; ++i)
            {
                ReportParamChildAdd(i, constructedParts[i], "Composed part", true);
            }

            composeWithCatalog(constructedParts);
        }
Esempio n. 17
0
        public async Task Load(CanvasDevice device, StorageFile file)
        {
            using (var stream = await file.OpenReadAsync())
            {
                SourceBitmap = await CanvasBitmap.LoadAsync(device, stream);
            }

            bitmapFormat = sourceBitmap.Format;
            bitmapData   = sourceBitmap.GetPixelBytes();

            Size = sourceBitmap.Size.ToVector2();

            Edits.Clear();
            Edits.Add(new EditGroup(this));

            SelectedEffect = null;
        }
Esempio n. 18
0
        private object componentAccepter(ExecutionView view)
        {
            //instanci, kterou uživatel přesunul myší, získáme následovně
            var toAccept = UserInteraction.DraggedInstance;

            //zjistíme, zda se jedná o komponentu
            var componentInfo = Services.GetComponentInfo(toAccept.Info);

            //akceptovat chceme pouze komponenty
            if (componentInfo == null)
            {
                //pokud se o komponentu nejedná, sdělíme uživateli
                //proč nelze instanci akceptovat a editaci zrušíme
                view.Abort("Can only accept components");
                return(null);
            }

            //pokud akceptujeme komponentu,
            //získáme proměnnou, ve které je dostupná
            //a vrátíme ji jako hodnotu k akceptování
            return(Edits.GetVariableFor(toAccept, view));;
        }
Esempio n. 19
0
 public static Edit New(params Edit[] Edits)
 {
     return(New(Edits.AsEnumerable()));
 }
Esempio n. 20
0
        public static async Task <RaidEditConversation> Create(ConversationService conversationService, RaidService raidService, IUser user, string raidId, Edits edit, IUserMessage userMessage)
        {
            //Create Conversation
            RaidEditConversation conversation = new RaidEditConversation(conversationService, raidService, user, raidId, edit, userMessage);

            //send edit Message
            string message = $"You are editing the {edit} of Raid {conversation._raid.RaidId}.\n" +
                             $"you can write \"cancel\" to cancel the editing\n" +
                             $"the current {edit} is: \n";

            switch (edit)
            {
            case Edits.Description:
                message += conversation._raid.Description;
                break;

            case Edits.Duation:
                message += conversation._raid.RaidDuration;
                break;

            case Edits.Time:
                message += conversation._raid.StartTime.ToString() +
                           $"\nrequired Format: {Constants.DateFormat}";
                break;

            case Edits.Title:
                message += conversation._raid.Title;
                break;

            case Edits.Organisator:
                message += conversation._raid.Organisator;
                break;

            case Edits.Guild:
                message += conversation._raid.Guild;
                break;

            case Edits.VoiceChat:
                message += conversation._raid.VoiceChat;
                break;
            }
            await UserExtensions.SendMessageAsync(conversation._user, message);

            return(conversation);
        }
Esempio n. 21
0
 /// <summary>
 /// Create edit for call creation.
 /// </summary>
 /// <param name="name">The name of edit.</param>
 /// <param name="callProvider">The provider of created call.</param>
 /// <returns>Created edit.</returns>
 protected Edit AddCallEdit(string name, CallProvider callProvider)
 {
     return(Edits.AddCall(This, name, callProvider));
 }
Esempio n. 22
0
 /// <summary>
 /// Create edit that rewrite the argument.
 /// </summary>
 /// <param name="argIndex">Index of the argument.</param>
 /// <param name="editName">Name of the edit.</param>
 /// <param name="valueProvider">The value provider.</param>
 protected void RewriteArg(int argIndex, string editName, ValueProvider valueProvider)
 {
     Edits.ChangeArgument(This, argIndex, editName, valueProvider);
 }
Esempio n. 23
0
 /// <summary>
 /// Create edit that appends the argument.
 /// </summary>
 /// <param name="argIndex">Index of the argument.</param>
 /// <param name="editName">Name of the edit.</param>
 /// <param name="valueProvider">The value provider.</param>
 protected void AppendArg(int argIndex, string editName, ValueProvider valueProvider)
 {
     Edits.AppendArgument(CurrentArguments[0], argIndex, editName, valueProvider);
 }
Esempio n. 24
0
        public bool Equals([AllowNull] Config other)
        {
            if (other == null)
            {
                return(false);
            }

            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return((StaticPlot == other.StaticPlot && StaticPlot != null && other.StaticPlot != null && StaticPlot.Equals(other.StaticPlot)) &&
                   (PlotlyServerUrl == other.PlotlyServerUrl && PlotlyServerUrl != null && other.PlotlyServerUrl != null && PlotlyServerUrl.Equals(other.PlotlyServerUrl)) &&
                   (Editable == other.Editable && Editable != null && other.Editable != null && Editable.Equals(other.Editable)) &&
                   (Edits == other.Edits && Edits != null && other.Edits != null && Edits.Equals(other.Edits)) &&
                   (AutoSizable == other.AutoSizable && AutoSizable != null && other.AutoSizable != null && AutoSizable.Equals(other.AutoSizable)) &&
                   (Responsive == other.Responsive && Responsive != null && other.Responsive != null && Responsive.Equals(other.Responsive)) &&
                   (FillFrame == other.FillFrame && FillFrame != null && other.FillFrame != null && FillFrame.Equals(other.FillFrame)) &&
                   (FrameMargins == other.FrameMargins && FrameMargins != null && other.FrameMargins != null && FrameMargins.Equals(other.FrameMargins)) &&
                   (ScrollZoom == other.ScrollZoom && ScrollZoom != null && other.ScrollZoom != null && ScrollZoom.Equals(other.ScrollZoom)) &&
                   (DoubleClick == other.DoubleClick && DoubleClick != null && other.DoubleClick != null && DoubleClick.Equals(other.DoubleClick)) &&
                   (DoubleClickDelay == other.DoubleClickDelay && DoubleClickDelay != null && other.DoubleClickDelay != null && DoubleClickDelay.Equals(other.DoubleClickDelay)) &&
                   (ShowAxisDragHandles == other.ShowAxisDragHandles && ShowAxisDragHandles != null && other.ShowAxisDragHandles != null && ShowAxisDragHandles.Equals(other.ShowAxisDragHandles)) &&
                   (ShowAxisRangeEntryBoxes == other.ShowAxisRangeEntryBoxes &&
                    ShowAxisRangeEntryBoxes != null &&
                    other.ShowAxisRangeEntryBoxes != null &&
                    ShowAxisRangeEntryBoxes.Equals(other.ShowAxisRangeEntryBoxes)) &&
                   (ShowTips == other.ShowTips && ShowTips != null && other.ShowTips != null && ShowTips.Equals(other.ShowTips)) &&
                   (ShowLink == other.ShowLink && ShowLink != null && other.ShowLink != null && ShowLink.Equals(other.ShowLink)) &&
                   (LinkText == other.LinkText && LinkText != null && other.LinkText != null && LinkText.Equals(other.LinkText)) &&
                   (SendData == other.SendData && SendData != null && other.SendData != null && SendData.Equals(other.SendData)) &&
                   (ShowSources == other.ShowSources && ShowSources != null && other.ShowSources != null && ShowSources.Equals(other.ShowSources)) &&
                   (DisplayModeBar == other.DisplayModeBar && DisplayModeBar != null && other.DisplayModeBar != null && DisplayModeBar.Equals(other.DisplayModeBar)) &&
                   (ShowSendToCloud == other.ShowSendToCloud && ShowSendToCloud != null && other.ShowSendToCloud != null && ShowSendToCloud.Equals(other.ShowSendToCloud)) &&
                   (ShowEditInChartStudio == other.ShowEditInChartStudio &&
                    ShowEditInChartStudio != null &&
                    other.ShowEditInChartStudio != null &&
                    ShowEditInChartStudio.Equals(other.ShowEditInChartStudio)) &&
                   (ModeBarButtonsToRemove == other.ModeBarButtonsToRemove &&
                    ModeBarButtonsToRemove != null &&
                    other.ModeBarButtonsToRemove != null &&
                    ModeBarButtonsToRemove.Equals(other.ModeBarButtonsToRemove)) &&
                   (ModeBarButtonsToAdd == other.ModeBarButtonsToAdd && ModeBarButtonsToAdd != null && other.ModeBarButtonsToAdd != null && ModeBarButtonsToAdd.Equals(other.ModeBarButtonsToAdd)) &&
                   (ModeBarButtons == other.ModeBarButtons && ModeBarButtons != null && other.ModeBarButtons != null && ModeBarButtons.Equals(other.ModeBarButtons)) &&
                   (ToImageButtonOptions == other.ToImageButtonOptions &&
                    ToImageButtonOptions != null &&
                    other.ToImageButtonOptions != null &&
                    ToImageButtonOptions.Equals(other.ToImageButtonOptions)) &&
                   (DisplayLogo == other.DisplayLogo && DisplayLogo != null && other.DisplayLogo != null && DisplayLogo.Equals(other.DisplayLogo)) &&
                   (Watermark == other.Watermark && Watermark != null && other.Watermark != null && Watermark.Equals(other.Watermark)) &&
                   (PlotGlPixelRatio == other.PlotGlPixelRatio && PlotGlPixelRatio != null && other.PlotGlPixelRatio != null && PlotGlPixelRatio.Equals(other.PlotGlPixelRatio)) &&
                   (SetBackground == other.SetBackground && SetBackground != null && other.SetBackground != null && SetBackground.Equals(other.SetBackground)) &&
                   (TopoJsonUrl == other.TopoJsonUrl && TopoJsonUrl != null && other.TopoJsonUrl != null && TopoJsonUrl.Equals(other.TopoJsonUrl)) &&
                   (MapboxAccessToken == other.MapboxAccessToken && MapboxAccessToken != null && other.MapboxAccessToken != null && MapboxAccessToken.Equals(other.MapboxAccessToken)) &&
                   (Logging == other.Logging && Logging != null && other.Logging != null && Logging.Equals(other.Logging)) &&
                   (NotifyOnLogging == other.NotifyOnLogging && NotifyOnLogging != null && other.NotifyOnLogging != null && NotifyOnLogging.Equals(other.NotifyOnLogging)) &&
                   (QueueLength == other.QueueLength && QueueLength != null && other.QueueLength != null && QueueLength.Equals(other.QueueLength)) &&
                   (GlobalTransforms == other.GlobalTransforms && GlobalTransforms != null && other.GlobalTransforms != null && GlobalTransforms.Equals(other.GlobalTransforms)) &&
                   (Locale == other.Locale && Locale != null && other.Locale != null && Locale.Equals(other.Locale)) &&
                   (Locales == other.Locales && Locales != null && other.Locales != null && Locales.Equals(other.Locales)));
        }
Esempio n. 25
0
 /// <summary>
 /// Create edit that executes given action.
 /// </summary>
 /// <param name="editName">Name of the edit.</param>
 /// <param name="action">The action.</param>
 protected void AddActionEdit(string editName, Action action)
 {
     Edits.AddEdit(This, editName, new ActionTransformation(action));
 }
Esempio n. 26
0
        public void AddWire(Circuit.Coord A, Circuit.Coord B)
        {
            if (A == B)
            {
                return;
            }

            Debug.Assert(A.x == B.x || A.y == B.y);

            Edits.BeginEditGroup();

            // Find all of the wires that are parallel and overlapping this wire.
            List <Circuit.Wire> overlapping = CoincidentWires(A, B).ToList();
            bool selected = overlapping.Any(i => ((WireControl)i.Tag).Selected);

            Circuit.Coord a = new Circuit.Coord(
                overlapping.Min(i => Math.Min(i.A.x, i.B.x), Math.Min(A.x, B.x)),
                overlapping.Min(i => Math.Min(i.A.y, i.B.y), Math.Min(A.y, B.y)));
            Circuit.Coord b = new Circuit.Coord(
                overlapping.Max(i => Math.Max(i.A.x, i.B.x), Math.Max(A.x, B.x)),
                overlapping.Max(i => Math.Max(i.A.y, i.B.y), Math.Max(A.y, B.y)));

            List <Circuit.Coord> terminals = new List <Circuit.Coord>()
            {
                a, b
            };

            foreach (Circuit.Element i in InRect(a - 1, b + 1))
            {
                // Find all of the terminals between a and b.
                foreach (Circuit.Terminal j in i.Terminals)
                {
                    if (Circuit.Wire.PointOnSegment(i.MapTerminal(j), a, b))
                    {
                        // If i is not a wire, or it is a wire that is not coincident with a, b, add the terminal to the list.
                        if (!(i is Circuit.Wire) ||
                            i.Terminals.Any(k => !Circuit.Wire.PointOnLine(i.MapTerminal(k), a, b)))
                        {
                            terminals.Add(i.MapTerminal(j));
                        }
                    }
                }

                // If i is a Wire that crosses a, b, add a terminal at the intersection.
                if (i is Circuit.Wire)
                {
                    Circuit.Wire w = (Circuit.Wire)i;

                    Circuit.Coord ia = w.MapTerminal(w.Anode);
                    Circuit.Coord ib = w.MapTerminal(w.Cathode);

                    // If one of A, B is intersecting this wire, we shouldn't merge wires across this point.
                    if (Circuit.Wire.PointOnLine(A, ia, ib) && !Circuit.Wire.PointOnLine(B, ia, ib))
                    {
                        terminals.Add(A);
                    }
                    else if (Circuit.Wire.PointOnLine(B, ia, ib) && !Circuit.Wire.PointOnLine(A, ia, ib))
                    {
                        terminals.Add(B);
                    }
                }
            }
            terminals.Sort((t1, t2) => t1.x == t2.x ? t1.y.CompareTo(t2.y) : t1.x.CompareTo(t2.x));

            // Remove the original wires, and add new ones between each terminal between a and b.
            Remove(overlapping);
            for (int i = 0; i < terminals.Count - 1; ++i)
            {
                if (terminals[i] != terminals[i + 1])
                {
                    Add(new Circuit.Wire(terminals[i], terminals[i + 1]));
                }
            }

            Edits.EndEditGroup();
        }
Esempio n. 27
0
        public override int GetHashCode()
        {
            unchecked // Overflow is fine, just wrap
            {
                int hashCode = 41;

                if (StaticPlot != null)
                {
                    hashCode = hashCode * 59 + StaticPlot.GetHashCode();
                }

                if (PlotlyServerUrl != null)
                {
                    hashCode = hashCode * 59 + PlotlyServerUrl.GetHashCode();
                }

                if (Editable != null)
                {
                    hashCode = hashCode * 59 + Editable.GetHashCode();
                }

                if (Edits != null)
                {
                    hashCode = hashCode * 59 + Edits.GetHashCode();
                }

                if (AutoSizable != null)
                {
                    hashCode = hashCode * 59 + AutoSizable.GetHashCode();
                }

                if (Responsive != null)
                {
                    hashCode = hashCode * 59 + Responsive.GetHashCode();
                }

                if (FillFrame != null)
                {
                    hashCode = hashCode * 59 + FillFrame.GetHashCode();
                }

                if (FrameMargins != null)
                {
                    hashCode = hashCode * 59 + FrameMargins.GetHashCode();
                }

                if (ScrollZoom != null)
                {
                    hashCode = hashCode * 59 + ScrollZoom.GetHashCode();
                }

                if (DoubleClick != null)
                {
                    hashCode = hashCode * 59 + DoubleClick.GetHashCode();
                }

                if (DoubleClickDelay != null)
                {
                    hashCode = hashCode * 59 + DoubleClickDelay.GetHashCode();
                }

                if (ShowAxisDragHandles != null)
                {
                    hashCode = hashCode * 59 + ShowAxisDragHandles.GetHashCode();
                }

                if (ShowAxisRangeEntryBoxes != null)
                {
                    hashCode = hashCode * 59 + ShowAxisRangeEntryBoxes.GetHashCode();
                }

                if (ShowTips != null)
                {
                    hashCode = hashCode * 59 + ShowTips.GetHashCode();
                }

                if (ShowLink != null)
                {
                    hashCode = hashCode * 59 + ShowLink.GetHashCode();
                }

                if (LinkText != null)
                {
                    hashCode = hashCode * 59 + LinkText.GetHashCode();
                }

                if (SendData != null)
                {
                    hashCode = hashCode * 59 + SendData.GetHashCode();
                }

                if (ShowSources != null)
                {
                    hashCode = hashCode * 59 + ShowSources.GetHashCode();
                }

                if (DisplayModeBar != null)
                {
                    hashCode = hashCode * 59 + DisplayModeBar.GetHashCode();
                }

                if (ShowSendToCloud != null)
                {
                    hashCode = hashCode * 59 + ShowSendToCloud.GetHashCode();
                }

                if (ShowEditInChartStudio != null)
                {
                    hashCode = hashCode * 59 + ShowEditInChartStudio.GetHashCode();
                }

                if (ModeBarButtonsToRemove != null)
                {
                    hashCode = hashCode * 59 + ModeBarButtonsToRemove.GetHashCode();
                }

                if (ModeBarButtonsToAdd != null)
                {
                    hashCode = hashCode * 59 + ModeBarButtonsToAdd.GetHashCode();
                }

                if (ModeBarButtons != null)
                {
                    hashCode = hashCode * 59 + ModeBarButtons.GetHashCode();
                }

                if (ToImageButtonOptions != null)
                {
                    hashCode = hashCode * 59 + ToImageButtonOptions.GetHashCode();
                }

                if (DisplayLogo != null)
                {
                    hashCode = hashCode * 59 + DisplayLogo.GetHashCode();
                }

                if (Watermark != null)
                {
                    hashCode = hashCode * 59 + Watermark.GetHashCode();
                }

                if (PlotGlPixelRatio != null)
                {
                    hashCode = hashCode * 59 + PlotGlPixelRatio.GetHashCode();
                }

                if (SetBackground != null)
                {
                    hashCode = hashCode * 59 + SetBackground.GetHashCode();
                }

                if (TopoJsonUrl != null)
                {
                    hashCode = hashCode * 59 + TopoJsonUrl.GetHashCode();
                }

                if (MapboxAccessToken != null)
                {
                    hashCode = hashCode * 59 + MapboxAccessToken.GetHashCode();
                }

                if (Logging != null)
                {
                    hashCode = hashCode * 59 + Logging.GetHashCode();
                }

                if (NotifyOnLogging != null)
                {
                    hashCode = hashCode * 59 + NotifyOnLogging.GetHashCode();
                }

                if (QueueLength != null)
                {
                    hashCode = hashCode * 59 + QueueLength.GetHashCode();
                }

                if (GlobalTransforms != null)
                {
                    hashCode = hashCode * 59 + GlobalTransforms.GetHashCode();
                }

                if (Locale != null)
                {
                    hashCode = hashCode * 59 + Locale.GetHashCode();
                }

                if (Locales != null)
                {
                    hashCode = hashCode * 59 + Locales.GetHashCode();
                }

                return(hashCode);
            }
        }
Esempio n. 28
0
 private void Redo_Executed(object sender, ExecutedRoutedEventArgs e)
 {
     Edits.Redo();
 }
Esempio n. 29
0
 private void Redo_CanExecute(object sender, CanExecuteRoutedEventArgs e)
 {
     e.CanExecute = Edits.CanRedo();
 }
Esempio n. 30
0
        public async override Task <CodeAction?> ResolveAsync(
            CSharpCodeActionParams csharpParams,
            CodeAction codeAction,
            CancellationToken cancellationToken)
        {
            if (csharpParams is null)
            {
                throw new ArgumentNullException(nameof(csharpParams));
            }

            if (codeAction is null)
            {
                throw new ArgumentNullException(nameof(codeAction));
            }

            cancellationToken.ThrowIfCancellationRequested();

            var resolvedCodeAction = await ResolveCodeActionWithServerAsync(csharpParams.RazorFileUri, codeAction, cancellationToken).ConfigureAwait(false);

            if (resolvedCodeAction?.Edit?.DocumentChanges is null)
            {
                // Unable to resolve code action with server, return original code action
                return(codeAction);
            }

            if (resolvedCodeAction.Edit.DocumentChanges.Count() != 1)
            {
                // We don't yet support multi-document code actions, return original code action
                Debug.Fail($"Encountered an unsupported multi-document code action edit with ${codeAction.Title}.");
                return(codeAction);
            }

            var documentChanged = resolvedCodeAction.Edit.DocumentChanges.First();

            if (!documentChanged.IsTextDocumentEdit)
            {
                // Only Text Document Edit changes are supported currently, return original code action
                return(codeAction);
            }

            var textEdit = documentChanged.TextDocumentEdit !.Edits.FirstOrDefault();

            if (textEdit is null)
            {
                // No text edit available
                return(codeAction);
            }

            var documentInfo = await _projectSnapshotManagerDispatcher.RunOnDispatcherThreadAsync <(DocumentSnapshot, int)?>(() =>
            {
                if (_documentResolver.TryResolveDocument(csharpParams.RazorFileUri.ToUri().GetAbsoluteOrUNCPath(), out var documentSnapshot))
                {
                    if (_documentVersionCache.TryGetDocumentVersion(documentSnapshot, out var version))
                    {
                        return(documentSnapshot, version.Value);
                    }
                }

                return(null);
            }, cancellationToken).ConfigureAwait(false);

            if (documentInfo is null)
            {
                return(codeAction);
            }

            var(documentSnapshot, documentVersion) = documentInfo.Value;

            var codeDocument = await documentSnapshot.GetGeneratedOutputAsync().ConfigureAwait(false);

            if (codeDocument.IsUnsupported())
            {
                return(codeAction);
            }

            if (!_documentMappingService.TryMapFromProjectedDocumentRange(codeDocument, textEdit.Range, MappingBehavior.Inclusive, out var originalRange))
            {
                // Text edit failed to map
                return(codeAction);
            }

            textEdit = textEdit with {
                Range = originalRange
            };

            var codeDocumentIdentifier = new OptionalVersionedTextDocumentIdentifier()
            {
                Uri     = csharpParams.RazorFileUri,
                Version = documentVersion
            };

            resolvedCodeAction = resolvedCodeAction with
            {
                Edit = new WorkspaceEdit()
                {
                    DocumentChanges = new[] {
                        new WorkspaceEditDocumentChange(
                            new TextDocumentEdit()
                        {
                            TextDocument = codeDocumentIdentifier,
                            Edits        = new[] { textEdit },
                        })
                    }
                },
            };

            return(resolvedCodeAction);
        }
    }