Exemple #1
0
 internal override void Draw(Canvas gr, float scale, float coordScale, StaticView view, StaticView.InvalidationBuffer buffer, int fillAlpha = 255, int edgeAlpha = 255, bool reverseRenderOrder = false)
 {
     gr.IntersectClip(MaskShape.ConvertToPath());
     Image.Draw(gr, scale, coordScale, view, buffer, fillAlpha, 0, reverseRenderOrder);
     gr.RestoreClip();
     MaskShape.Draw(gr, scale, coordScale, view, buffer, 0, edgeAlpha, reverseRenderOrder);
 }
Exemple #2
0
        /// <summary>Edits the item(s) currently selected in the view</summary>
        public static DialogResult Display(StaticView view)
        {
            Transaction       transaction = new Transaction();
            List <Item>       items       = new List <Item>();
            List <Scriptable> scriptables = new List <Scriptable>();

            // probably selected items are scriptables, but this is written to cope with all cases (eg naked Items not inside a Scriptable)
            foreach (Shape selected in view.CurrentPage.SelectedShapes)
            {
                if (selected is Item item)
                {
                    items.Add(item);
                    if (item.Parent is Scriptable scriptable)
                    {
                        scriptables.Add(scriptable);
                    }
                }
                else if (selected is Scriptable s)
                {
                    scriptables.Add(s);
                    if (s.Element is Item item1)
                    {
                        items.Add(item1);
                    }
                }
            }
            foreach (Scriptable s in scriptables)
            {
                transaction.Edit(s);
            }
            foreach (Item i in items)
            {
                transaction.Edit(i);
                i.BeingEdited = true;
            }
            // there must always be at least one item, but not necessarily scriptables
            Globals.StoreEvent("Log " + items.Count + " items, " + scriptables.Count + " scriptable, first ID=" + (scriptables?.First()?.SAWID ?? 0));

            using (var frm = new frmSAWItem(items, scriptables, transaction))
            {
                // deselect it, so that we get a better preview of what it looks like:
                frm.m_Page.SelectOnly((Shape)null);
                Shape beside = scriptables.Any() ? (Shape)scriptables.First() : items.First();
                GUIUtilities.PositionNewFormBeside(frm, view.ShapeBounds(beside, true));
                bool ok = frm.ShowDialog() == DialogResult.OK;
                foreach (Item i in items)
                {
                    i.BeingEdited = false;
                }
                frm.SetPreviewState(ButtonShape.States.Normal);
                view.CurrentPage.SelectOnly(scriptables.Cast <Shape>().ToList());
                if (ok)
                {
                    Globals.Root.StoreNewTransaction(transaction);
                    return(DialogResult.OK);
                }
                transaction.Cancel();
                return(DialogResult.Cancel);
            }
        }
Exemple #3
0
 internal override void Draw(Canvas gr, float scale, float coordScale, StaticView view, StaticView.InvalidationBuffer buffer, int fillAlpha = 255, int edgeAlpha = 255, bool reverseRenderOrder = false)
 {
     foreach (Shape shp in Contents)
     {
         shp.Draw(gr, scale, coordScale, view, buffer, fillAlpha, edgeAlpha, reverseRenderOrder);
     }
 }
Exemple #4
0
 internal override void Draw(Canvas gr, float scale, float coordScale, StaticView view, StaticView.InvalidationBuffer buffer, int fillAlpha = 255, int edgeAlpha = 255, bool reverseRenderOrder = false)
 {
     if (Grouped)
     {
         return;                 // does not draw if grouped
     }
     // just overridden in order to avoid unnecessary resource allocation
     base.Draw(gr, scale, coordScale, view, buffer, fillAlpha, edgeAlpha, reverseRenderOrder);
 }
Exemple #5
0
        internal override void Draw(Canvas gr, float scale, float coordScale, StaticView view, StaticView.InvalidationBuffer buffer, int fillAlpha = 255, int edgeAlpha = 255, bool reverseRenderOrder = false)
        {
            if (!Shown)
            {
                return;
            }
            HighlightStyleC actualStyles = null;

            if (State == ButtonShape.States.Highlight)
            {
                actualStyles = HighlightStyleC.FromShape(Element);
                HighlightStyle.ApplyToShape(Element);
            }
            Element.Draw(gr, scale, coordScale, view, buffer, fillAlpha, edgeAlpha, reverseRenderOrder);
            if (State == ButtonShape.States.Highlight)
            {
                actualStyles.ApplyToShape(Element);
            }
        }