예제 #1
0
        public override void Trigger(EditableView.ClickPosition.Sources source, EditableView pnlView, Transaction transaction)
        {
            MultiUpdate update = new MultiUpdate();

            if (!frmMultiUpdateOptions.Display(CurrentPage.SelectedShapes.OfType <Item>().Any(), update))
            {
                return;
            }
            IEnumerable <Item> list;

            if (update.OnlySelected)
            {
                list = CurrentPage.SelectedShapes.OfType <Item>();
            }
            else
            {
                list = Shape.FlattenList(CurrentPage.Shapes.ToList(), Shape.FlatListPurpose.Translate).OfType <Item>();
            }
            update.Start();
            try
            {
                foreach (Item item in list)
                {
                    string result = update.DoLookup(item.LabelText, item.ConceptID);
                    if (string.IsNullOrEmpty(result))
                    {
                        continue;
                    }
                    transaction.Edit(item);
                    switch (update.PerformFunction)
                    {
                    case MultiUpdate.Functions.ChangeSymbols:
                        string      imagePath = Path.Combine(Connection.LocalPath, result);
                        SharedImage image     = (SharedImage)Globals.Root.CurrentDocument.AddSharedResourceFromFile(imagePath, transaction);
                        item.Image     = new SharedReference <SharedImage>(image);
                        item.ImageName = Path.GetFileName(imagePath);
                        break;

                    case MultiUpdate.Functions.ChangeText:
                        item.LabelText = result;
                        if ((item.Parent is Scriptable scriptable) && scriptable.OutputAsDisplay)
                        {
                            scriptable.OutputText = result;
                        }
                        break;

                    case MultiUpdate.Functions.RemoveInfo:
                        item.ConceptID = null;
                        break;

                    default: throw new ArgumentException("update.PerformFunction");
                    }
                }
            }
            finally
            {
                update.Completed();
            }
        }
예제 #2
0
파일: ObjectEdits.cs 프로젝트: stuart2w/SAW
        public override void Trigger(EditableView.ClickPosition.Sources source, EditableView pnlView, Transaction transaction)
        {
            SharedImage texture = frmTexture.PickTexture(CurrentDocument);

            if (texture == null)
            {
                return;
            }
            texture = CurrentDocument.AddSharedResource(texture);
            foreach (Shape shape in CurrentPage.SelectedShapes)
            {
                Shape.FillStyleC style = (Shape.FillStyleC)shape.StyleObjectForParameter(Parameters.FillPattern);
                if (style != null)
                {
                    transaction.Edit(shape);
                    style.Texture = texture;
                }
            }
            pnlView.InvalidateData(CurrentPage.SelectedRefreshBoundary(), StaticView.InvalidationBuffer.All);
        }