Beispiel #1
0
        public void Compile(ActionBranch currentAction, ActionBranch nextAction, ILimnorCodeCompiler compiler, IMethodCompile methodToCompile, CodeMemberMethod method, CodeStatementCollection statements, bool debug)
        {
            CodeAssignStatement cas = new CodeAssignStatement();

            cas.Left = SetProperty.GetReferenceCode(methodToCompile);
            if (cas.Left == null)
            {
                compiler.AddError("Error: CustomSetter missing property");
            }
            else
            {
                CodeExpression rt = Value.GetReferenceCode(methodToCompile);
                CodeMethodReferenceExpression cmr = rt as CodeMethodReferenceExpression;
                if (cmr != null)
                {
                    rt = new CodeMethodInvokeExpression(cmr);
                }
                if (nextAction != null && nextAction.UseInput)
                {
                    CodeVariableDeclarationStatement output = new CodeVariableDeclarationStatement(
                        currentAction.OutputType.TypeString, currentAction.OutputCodeName, rt);
                    statements.Add(output);
                    rt = new CodeVariableReferenceExpression(currentAction.OutputCodeName);
                }
                cas.Right = rt;
                statements.Add(cas);
            }
        }
Beispiel #2
0
        public static async Task <ComposerStep> BuildComposerStepFromShape(DrawsomeShape shape)
        {
            var query        = shape.Text;
            var luisResponse = await new LuisRecognizer("", "").GetPrediction(query);

            var content = GetContent(luisResponse);

            var shapeType = luisResponse.TopScoringIntent?.Intent;

            switch (shapeType)
            {
            case nameof(IfCondition):
                var ifStep = new IfCondition(content, shape);
                return(ifStep);

            case nameof(SetProperty):
                var setStep = new SetProperty(content ?? query, shape);
                return(setStep);

            case nameof(TextInput):
                var textStep = new TextInput(content ?? query, shape);
                return(textStep);

            case nameof(HttpRequest):
                var httpStep = new HttpRequest(content ?? query, shape);
                return(httpStep);

            case nameof(SendActivity):
            default:
                var sendStep = new SendActivity(content ?? query, shape);
                return(sendStep);
            }
        }
Beispiel #3
0
        public static void Create(string assetPath, string assetType, Action <Node> onNodeCreated)
        {
            var fileName = Path.GetFileNameWithoutExtension(assetPath);
            var menu     = new Menu()
            {
                new Command("Open in New Tab", () => Project.Current.OpenDocument(assetPath)),
                new Command("Add As External Scene", () => Document.Current.History.DoTransaction(
                                () => {
                    var scene = Node.CreateFromAssetBundle(assetPath, yuzu: TangerineYuzu.Instance.Value);
                    var node  = CreateNode.Perform(scene.GetType());
                    SetProperty.Perform(node, nameof(Widget.ContentsPath), assetPath);
                    SetProperty.Perform(node, nameof(Node.Id), fileName);
                    if (scene is Widget)
                    {
                        SetProperty.Perform(node, nameof(Widget.Pivot), Vector2.Half);
                        SetProperty.Perform(node, nameof(Widget.Size), ((Widget)scene).Size);
                    }
                    onNodeCreated?.Invoke(node);
                    node.LoadExternalScenes();
                })),
                new Command("Cancel")
            };

            menu[0].Enabled = assetType != ".model";
            menu.Popup();
        }
 private static void ReadAzureManagedIdentitiesOptions(MSSqlServerConfigurationSection config, MSSqlServerSinkOptions sinkOptions)
 {
     SetProperty.IfProvided <bool>(config.UseAzureManagedIdentity, nameof(config.UseAzureManagedIdentity.Value),
                                   value => sinkOptions.UseAzureManagedIdentity = value);
     SetProperty.IfProvided <string>(config.AzureServiceTokenProviderResource, nameof(config.AzureServiceTokenProviderResource.Value),
                                     value => sinkOptions.AzureServiceTokenProviderResource = value);
 }
 private static void ReadBatchSettings(MSSqlServerConfigurationSection config, MSSqlServerSinkOptions sinkOptions)
 {
     SetProperty.IfProvided <int>(config.BatchPostingLimit, nameof(config.BatchPostingLimit.Value), value => sinkOptions.BatchPostingLimit = value);
     SetProperty.IfProvided <string>(config.BatchPeriod, nameof(config.BatchPeriod.Value), value => sinkOptions.BatchPeriod = TimeSpan.Parse(value, CultureInfo.InvariantCulture));
     SetProperty.IfProvided <bool>(config.EagerlyEmitFirstEvent, nameof(config.EagerlyEmitFirstEvent.Value),
                                   value => sinkOptions.EagerlyEmitFirstEvent = value);
 }
 private static void ReadTableOptions(IConfigurationSection config, MSSqlServerSinkOptions sinkOptions)
 {
     SetProperty.IfNotNull <string>(config["tableName"], val => sinkOptions.TableName   = val);
     SetProperty.IfNotNull <string>(config["schemaName"], val => sinkOptions.SchemaName = val);
     SetProperty.IfNotNull <bool>(config["autoCreateSqlTable"], val => sinkOptions.AutoCreateSqlTable   = val);
     SetProperty.IfNotNull <bool>(config["enlistInTransaction"], val => sinkOptions.EnlistInTransaction = val);
 }
Beispiel #7
0
 private void ReadTableOptions(MSSqlServerConfigurationSection config, SinkOptions sinkOptions)
 {
     SetProperty.IfProvided <string>(config.TableName, nameof(config.TableName.Value), value => sinkOptions.TableName    = value);
     SetProperty.IfProvided <string>(config.SchemaName, nameof(config.SchemaName.Value), value => sinkOptions.SchemaName = value);
     SetProperty.IfProvided <bool>(config.AutoCreateSqlTable, nameof(config.AutoCreateSqlTable.Value),
                                   value => sinkOptions.AutoCreateSqlTable = value);
 }
Beispiel #8
0
 private static void FilesDropNodePostProcessor(Node node)
 {
     if (node is Widget)
     {
         SetProperty.Perform(node, nameof(Widget.Position), Instance.mousePositionOnFilesDrop);
     }
 }
Beispiel #9
0
        public static void Generate(CompressionFormat compressionFormat)
        {
            var   size      = Document.Current.RootNode.AsWidget.Size;
            float newWidth  = previewWidth;
            float newHeight = previewHeight;

            if (size.X > size.Y)
            {
                newHeight *= size.Y / size.X;
            }
            else
            {
                newWidth *= size.X / size.Y;
            }
            // Andrey Tyshchenko: Enable animation preview to disable presenters while rendering document preview
            var savedPreviewAnimation = Document.Current.PreviewAnimation;

            Document.Current.PreviewAnimation = true;
            var bitmap = Document.Current.RootNode.AsWidget.ToBitmap().Rescale(newWidth.Round(), newHeight.Round());

            Document.Current.PreviewAnimation = savedPreviewAnimation;
            var stream = new MemoryStream();

            bitmap.SaveTo(stream, compressionFormat);
            SetProperty.Perform(Document.Current, nameof(Document.Preview), Convert.ToBase64String(stream.ToArray()));
        }
Beispiel #10
0
 private void FilesDropOnNodeCreated(Node node)
 {
     if (node is Widget)
     {
         SetProperty.Perform(node, nameof(Widget.Position), mousePositionOnFilesDrop);
     }
 }
Beispiel #11
0
 private void CreateSpriteAnimatedImage(List <string> files)
 {
     onBeforeDrop?.Invoke();
     using (Document.Current.History.BeginTransaction()) {
         var node = CreateNode.Perform(typeof(Image));
         SetProperty.Perform(node, nameof(Widget.Pivot), Vector2.Half);
         SetProperty.Perform(node, nameof(Widget.Id), "Temp");
         postProcessNode?.Invoke(node);
         var      i     = 0;
         ITexture first = null;
         foreach (var file in files)
         {
             if (!Utils.ExtractAssetPathOrShowAlert(file, out var assetPath, out var assetType))
             {
                 continue;
             }
             var text = new SerializableTexture(assetPath);
             first = first ?? text;
             SetKeyframe.Perform(node, nameof(Widget.Texture), Document.Current.AnimationId,
                                 new Keyframe <ITexture> {
                 Value    = text,
                 Frame    = i++,
                 Function = KeyFunction.Steep,
             });
         }
         SetProperty.Perform(node, nameof(Widget.Size), (Vector2)first.ImageSize);
         Document.Current.History.CommitTransaction();
     }
 }
 private static void ReadPropertiesColumnOptions(MSSqlServerConfigurationSection config, ColumnOptions columnOptions)
 {
     SetProperty.IfProvided <bool>(config.PropertiesColumn, nameof(columnOptions.Properties.ExcludeAdditionalProperties),
                                   value => columnOptions.Properties.ExcludeAdditionalProperties = value);
     SetProperty.IfProvided <string>(config.PropertiesColumn, nameof(columnOptions.Properties.DictionaryElementName),
                                     value => columnOptions.Properties.DictionaryElementName = value);
     SetProperty.IfProvided <string>(config.PropertiesColumn, nameof(columnOptions.Properties.ItemElementName),
                                     value => columnOptions.Properties.ItemElementName = value);
     SetProperty.IfProvided <bool>(config.PropertiesColumn, nameof(columnOptions.Properties.OmitDictionaryContainerElement),
                                   value => columnOptions.Properties.OmitDictionaryContainerElement = value);
     SetProperty.IfProvided <bool>(config.PropertiesColumn, nameof(columnOptions.Properties.OmitSequenceContainerElement),
                                   value => columnOptions.Properties.OmitSequenceContainerElement = value);
     SetProperty.IfProvided <bool>(config.PropertiesColumn, nameof(columnOptions.Properties.OmitStructureContainerElement),
                                   value => columnOptions.Properties.OmitStructureContainerElement = value);
     SetProperty.IfProvided <bool>(config.PropertiesColumn, nameof(columnOptions.Properties.OmitElementIfEmpty),
                                   value => columnOptions.Properties.OmitElementIfEmpty = value);
     SetProperty.IfProvided <string>(config.PropertiesColumn, nameof(columnOptions.Properties.PropertyElementName),
                                     value => columnOptions.Properties.PropertyElementName = value);
     SetProperty.IfProvided <string>(config.PropertiesColumn, nameof(columnOptions.Properties.RootElementName),
                                     value => columnOptions.Properties.RootElementName = value);
     SetProperty.IfProvided <string>(config.PropertiesColumn, nameof(columnOptions.Properties.SequenceElementName),
                                     value => columnOptions.Properties.SequenceElementName = value);
     SetProperty.IfProvided <string>(config.PropertiesColumn, nameof(columnOptions.Properties.StructureElementName),
                                     value => columnOptions.Properties.StructureElementName = value);
     SetProperty.IfProvided <bool>(config.PropertiesColumn, nameof(columnOptions.Properties.UsePropertyKeyAsElementName),
                                   value => columnOptions.Properties.UsePropertyKeyAsElementName = value);
 }
Beispiel #13
0
        public static void Generate(CompressionFormat compressionFormat)
        {
            var   size      = Document.Current.RootNode.AsWidget.Size;
            float newWidth  = previewWidth;
            float newHeight = previewHeight;

            if (size.X > size.Y)
            {
                newHeight *= size.Y / size.X;
            }
            else
            {
                newWidth *= size.X / size.Y;
            }
            var savedPreviewScene = Document.Current.PreviewScene;

            Document.Current.PreviewScene = true;
            var bitmap = Document.Current.RootNode.AsWidget.ToBitmap().Rescale(newWidth.Round(), newHeight.Round());

            Document.Current.PreviewScene = savedPreviewScene;
            var stream = new MemoryStream();

            bitmap.SaveTo(stream, compressionFormat);
            SetProperty.Perform(Document.Current, nameof(Document.Preview), Convert.ToBase64String(stream.ToArray()));
        }
Beispiel #14
0
        public static void Perform()
        {
            var Boundaries = GetSelectionBoundaries();

            if (Boundaries == null)
            {
                AlertDialog.Show("Can't invert animation in a non-rectangular selection. The selection must be a single rectangle.");
                return;
            }
            using (Document.Current.History.BeginTransaction()) {
                for (int i = Boundaries.Value.Top; i <= Boundaries.Value.Bottom; ++i)
                {
                    if (!(Document.Current.Rows[i].Components.Get <NodeRow>()?.Node is IAnimationHost animable))
                    {
                        continue;
                    }
                    foreach (var animator in animable.Animators.ToList())
                    {
                        var saved = animator.Keys.Where(k =>
                                                        Boundaries.Value.Left <= k.Frame &&
                                                        k.Frame < Boundaries.Value.Right).ToList();
                        foreach (var key in saved)
                        {
                            RemoveKeyframe.Perform(animator, key.Frame);
                        }
                        foreach (var key in saved)
                        {
                            SetProperty.Perform(key, nameof(IKeyframe.Frame), Boundaries.Value.Left + Boundaries.Value.Right - key.Frame - 1);
                            SetKeyframe.Perform(animable, animator.TargetPropertyPath, animator.AnimationId, key);
                        }
                    }
                }
                Document.Current.History.CommitTransaction();
            }
        }
Beispiel #15
0
    public bool        explicitType; // store object type with property in file

    public Property(string name, GetProperty getter, SetProperty setter, PropertyGUI gui)
    {
        this.name    = name;
        this.getter  = getter;
        this.setter  = setter;
        this.gui     = gui;
        explicitType = false;
    }
Beispiel #16
0
 public static void SetResolution(ResolutionInfo resolution)
 {
     using (Document.Current.History.BeginTransaction()) {
         SetProperty.Perform(Document.Current.RootNode, nameof(Widget.Size), resolution.Size);
         SetMarker(Document.Current.RootNode, resolution.MarkerId);
         Document.Current.History.CommitTransaction();
     }
 }
 private static void SetCommonColumnOptions(ColumnConfig source, SqlColumn target)
 {
     SetProperty.IfProvidedNotEmpty <string>(source, nameof(target.ColumnName), value => target.ColumnName = value);
     SetProperty.IfProvided <string>(source, nameof(target.DataType), value => target.SetDataTypeFromConfigString(value));
     SetProperty.IfProvided <bool>(source, nameof(target.AllowNull), value => target.AllowNull  = value);
     SetProperty.IfProvided <int>(source, nameof(target.DataLength), value => target.DataLength = value);
     SetProperty.IfProvided <bool>(source, nameof(target.NonClusteredIndex), value => target.NonClusteredIndex = value);
 }
Beispiel #18
0
        public static void Perform(IntVector2 offset, bool removeOriginals)
        {
            var rows = Document.Current.Rows.ToList();

            if (offset.Y > 0)
            {
                rows.Reverse();
            }
            foreach (var row in rows)
            {
                var track = row.Components.Get <AnimationTrackRow>()?.Track;
                if (track?.EditorState().Locked != false)
                {
                    continue;
                }
                var clips = track.Clips.Where(i => i.IsSelected).ToList();
                var keys  = new List <IKeyframe>();
                if (track.Animators.TryFind(nameof(AnimationTrack.Weight), out var weightAnimator, Document.Current.AnimationId))
                {
                    keys = weightAnimator.ReadonlyKeys.Where(k => clips.Any(c => c.BeginFrame <= k.Frame && k.Frame <= c.EndFrame)).ToList();
                }
                if (removeOriginals)
                {
                    foreach (var key in keys)
                    {
                        RemoveKeyframe.Perform(weightAnimator, key.Frame);
                    }
                }
                foreach (var clip in clips)
                {
                    if (removeOriginals)
                    {
                        AnimationClipToolbox.RemoveClip(track, clip);
                    }
                    else
                    {
                        SetProperty.Perform(clip, nameof(AnimationClip.IsSelected), false);
                    }
                }
                int numRows   = Document.Current.Rows.Count;
                var destRow   = Document.Current.Rows[(row.Index + offset.Y).Clamp(0, numRows - 1)];
                var destTrack = destRow.Components.Get <AnimationTrackRow>()?.Track;
                foreach (var clip in clips)
                {
                    var newClip = clip.Clone();
                    newClip.BeginFrame += offset.X;
                    newClip.EndFrame   += offset.X;
                    newClip.IsSelected  = true;
                    AnimationClipToolbox.InsertClip(destTrack, newClip);
                }
                foreach (var k in keys)
                {
                    var key = k.Clone();
                    key.Frame += offset.X;
                    SetKeyframe.Perform(destTrack, nameof(AnimationTrack.Weight), Document.Current.AnimationId, key);
                }
            }
        }
 private static void SetCommonColumnOptions(IConfigurationSection section, SqlColumn target)
 {
     // Standard Columns are subclasses of the SqlColumn class
     SetProperty.IfNotNullOrEmpty <string>(section["columnName"], (val) => target.ColumnName = val);
     SetProperty.IfNotNull <string>(section["dataType"], (val) => target.SetDataTypeFromConfigString(val));
     SetProperty.IfNotNull <bool>(section["allowNull"], (val) => target.AllowNull  = val);
     SetProperty.IfNotNull <int>(section["dataLength"], (val) => target.DataLength = val);
     SetProperty.IfNotNull <bool>(section["nonClusteredIndex"], (val) => target.NonClusteredIndex = val);
 }
Beispiel #20
0
 public Property(string name, GetProperty getter, SetProperty setter, PropertyGUI gui,
                 bool explicitType)
 {
     this.name         = name;
     this.getter       = getter;
     this.setter       = setter;
     this.gui          = gui;
     this.explicitType = explicitType;
 }
 public SimplePropertyHandler(GetProperty <T> Get, SetProperty <T> Set, Primitive delta)
 {
     this.Get           = Get;
     this.Set           = Set;
     SetDirection       = (b, d, v) => Set(b, v);
     Increment          = (b, v) => Set(b, Get(b).Plus(v));
     IncrementDirection = (b, d, v) => Increment(b, Multiply(v, d));
     Move    = (b, d) => Set(b, Get(b).Plus(Multiply(delta, d)));
     Reverse = (b) => Set(b, Get(b).Not());
 }
Beispiel #22
0
        public object VisitSetPropertyExpr(SetProperty expr)
        {
            object obj = Evaluate(expr.Object);

            if (!(obj is HlangClass))
            {
                throw new RuntimeError(expr.Name, "Only class objects have fields");
            }
            object value = Evaluate(expr.Value);

            ((HlangClass)obj).Set(expr.Name, value);
            return(value);
        }
Beispiel #23
0
        void DragMarker(Marker marker, int destColumn)
        {
            var markerToRemove = Document.Current.Animation.Markers.FirstOrDefault(m => m.Frame == destColumn);

            if (marker.Frame != destColumn && markerToRemove != null)
            {
                DeleteMarker.Perform(markerToRemove, false);
            }
            // Delete and add marker again, because we want to maintain the markers order.
            DeleteMarker.Perform(marker, false);
            SetProperty.Perform(marker, "Frame", destColumn);
            SetMarker.Perform(marker, true);
        }
Beispiel #24
0
 private static void Expand()
 {
     foreach (var row in Document.Current.SelectedRows().ToList())
     {
         if (row.Components.Get <NodeRow>() is NodeRow nodeRow)
         {
             SetProperty.Perform(nodeRow, nameof(NodeRow.Expanded), !nodeRow.Expanded, isChangingDocument: false);
             if (nodeRow.Expanded && row.Rows.Count > 0)
             {
                 Timeline.Instance.EnsureRowChildsVisible(row);
             }
         }
     }
 }
Beispiel #25
0
        private void SelectAnimation(int index)
        {
            var a = GetAnimations();

            index = index.Clamp(0, a.Count - 1);
            EnsureRowVisible(index);
            Window.Current.Invalidate();
            var document = Document.Current;

            document.History.DoTransaction(() => {
                SetProperty.Perform(document, nameof(Document.SelectedAnimation), a[index], isChangingDocument: false);
            });
            // Invalidate dependent documents for which this is an external scene.
            Project.Current.SceneCache.InvalidateEntryFromOpenedDocumentChanged(document.Path, () => document.RootNodeUnwrapped);
        }
 private static void RestoreChildrenPositions(Widget widget, Matrix32 transform)
 {
     foreach (var child in widget.Nodes.OfType <Widget>())
     {
         var newPosition = transform.TransformVector(child.Position);
         SetProperty.Perform(child, nameof(Widget.Position), newPosition);
         if (child.Animators.TryFind(nameof(Widget.Position), out var animator))
         {
             foreach (var key in animator.ReadonlyKeys.ToList())
             {
                 var newKey = key.Clone();
                 newKey.Value = transform.TransformVector((Vector2)key.Value);
                 SetKeyframe.Perform(animator, newKey);
             }
         }
     }
 }
Beispiel #27
0
        public static void TransformPropertyAndKeyframes <T>(Node node, string propertyId, Func <T, T> transformer)
        {
            var value = new Property <T>(node, propertyId).Value;

            SetProperty.Perform(node, propertyId, transformer(value));
            foreach (var animation in node.Animators)
            {
                if (animation.TargetPropertyPath == propertyId)
                {
                    foreach (var keyframe in animation.Keys.ToList())
                    {
                        var newKeyframe = keyframe.Clone();
                        newKeyframe.Value = transformer((T)newKeyframe.Value);
                        SetKeyframe.Perform(node, animation.TargetPropertyPath, animation.AnimationId, newKeyframe);
                    }
                }
            }
        }
Beispiel #28
0
        // TODO: Get rid of parent parameter
        public static bool TryTransformSetPropertyChainToSequence(this SetProperty s, Namescope scope, Statement parent, ref Expression result)
        {
            if (parent == null ||
                parent is SequenceOp && (parent as SequenceOp).Left == s)
            {
                return(false);
            }

            var ind = TryCreateIndirection(scope, ref s.Value);

            result = new SequenceOp(s, s.Value);

            if (ind != null)
            {
                result = new SequenceOp(ind, result);
            }

            return(true);
        }
Beispiel #29
0
        public static void SwitchOnStringInForLoop()
        {
            List <SetProperty> list  = new List <SetProperty>();
            List <SetProperty> list2 = new List <SetProperty>();

            SetProperty[] properties = Switch.GetProperties();
            for (int i = 0; i < properties.Length; i++)
            {
                Console.WriteLine("In for-loop");
                SetProperty setProperty = properties[i];
                switch (setProperty.Property.Name)
                {
                case "Name1":
                    setProperty.Set = 1;
                    list.Add(setProperty);
                    break;

                case "Name2":
                    setProperty.Set = 2;
                    list.Add(setProperty);
                    break;

                case "Name3":
                    setProperty.Set = 3;
                    list.Add(setProperty);
                    break;

                case "Name4":
                    setProperty.Set = 4;
                    list.Add(setProperty);
                    break;

                case "Name5":
                case "Name6":
                    list.Add(setProperty);
                    break;

                default:
                    list2.Add(setProperty);
                    break;
                }
            }
        }
        private void ReadMiscColumnOptions(MSSqlServerConfigurationSection config, ColumnOptions columnOptions)
        {
            SetProperty.IfProvided <bool>(config, nameof(columnOptions.DisableTriggers), value => columnOptions.DisableTriggers = value);
            SetProperty.IfProvided <bool>(config, nameof(columnOptions.ClusteredColumnstoreIndex), value => columnOptions.ClusteredColumnstoreIndex = value);

            string pkName = null;

            SetProperty.IfProvidedNotEmpty <string>(config, "PrimaryKeyColumnName", value => pkName = value);
            if (pkName != null)
            {
                if (columnOptions.ClusteredColumnstoreIndex)
                {
                    throw new ArgumentException("SQL Clustered Columnstore Indexes and primary key constraints are mutually exclusive.");
                }

                foreach (var standardCol in columnOptions.Store)
                {
                    var stdColOpts = columnOptions.GetStandardColumnOptions(standardCol);
                    if (pkName.Equals(stdColOpts.ColumnName, StringComparison.InvariantCultureIgnoreCase))
                    {
                        columnOptions.PrimaryKey = stdColOpts;
                        break;
                    }
                }

                if (columnOptions.PrimaryKey == null && columnOptions.AdditionalColumns != null)
                {
                    foreach (var col in columnOptions.AdditionalColumns)
                    {
                        if (pkName.Equals(col.ColumnName, StringComparison.InvariantCultureIgnoreCase))
                        {
                            columnOptions.PrimaryKey = col;
                            break;
                        }
                    }
                }

                if (columnOptions.PrimaryKey == null)
                {
                    throw new ArgumentException($"Could not match the configured primary key column name \"{pkName}\" with a data column in the table.");
                }
            }
        }