コード例 #1
0
                public void InitializeDrag(IInputModeContext inputModeContext)
                {
                    // remember the original value so the drag can be cancelled correctly
                    ClipboardBusinessObject clipboardBusinessObject = node.Tag as ClipboardBusinessObject;

                    if (clipboardBusinessObject != null)
                    {
                        originalValue = clipboardBusinessObject.Value;
                    }
                }
コード例 #2
0
        private static object CreateBusinessObjectFromTagCopyItem(object tag)
        {
            TagCopyItem copyItem = (TagCopyItem)tag;

            copyItem.incPasteCount();
            ClipboardBusinessObject origObject = (ClipboardBusinessObject)copyItem.Tag;
            string name;

            if (copyItem.PasteCount < 2)
            {
                name = "Copy of " + origObject.Name;
            }
            else
            {
                name = "Copy (" + copyItem.PasteCount + ") of " + origObject.Name;
            }
            return(new ClipboardBusinessObject {
                Name = name, Value = origObject.Value
            });
        }
コード例 #3
0
            public void Paint(IRenderContext context, Graphics graphics)
            {
                var layout = node.Layout;

                // Draw a rounded rectangle
                double roundingX = layout.Width * roundingFactor;
                double roundingY = layout.Height * roundingFactor;

                ClipboardBusinessObject businessObject = node.Tag as ClipboardBusinessObject;

                GraphicsPath upperPath = new GraphicsPath();
                GraphicsPath lowerPath = new GraphicsPath();

                upperPath.AddBezier((float)layout.X, (float)(layout.Y + roundingY), (float)layout.X,
                                    (float)(layout.Y + (roundingY / 2)),
                                    (float)(layout.X + (roundingX / 2)), (float)layout.Y, (float)(layout.X + roundingX), (float)layout.Y);
                upperPath.AddLine((float)(layout.X + roundingX), (float)layout.Y,
                                  (float)(layout.X + layout.Width - roundingX), (float)layout.Y);

                upperPath.AddBezier((float)(layout.X + layout.Width - roundingX), (float)(layout.Y),
                                    (float)(layout.X + layout.Width - (roundingX / 2)), (float)(layout.Y),
                                    (float)(layout.X + layout.Width), (float)(layout.Y + (roundingY / 2)), (float)(layout.X + layout.Width),
                                    (float)(layout.Y + roundingY));
                upperPath.AddLine((float)(layout.X + layout.Width), (float)(layout.Y + roundingY),
                                  (float)(layout.X + layout.Width), (float)(layout.Y + layout.Height / 2));

                upperPath.AddLine((float)(layout.X + layout.Width), (float)(layout.Y + layout.Height / 2), (float)(layout.X),
                                  (float)(layout.Y + layout.Height / 2));
                upperPath.AddLine((float)(layout.X), (float)(layout.Y + layout.Height / 2), (float)layout.X,
                                  (float)(layout.Y + roundingY));


                lowerPath.AddBezier((float)(layout.X + layout.Width), (float)(layout.Y + layout.Height - roundingY),
                                    (float)(layout.X + layout.Width), (float)(layout.Y + layout.Height - (roundingY / 2)),
                                    (float)(layout.X + layout.Width - (roundingX / 2)), (float)(layout.Y + layout.Height),
                                    (float)(layout.X + layout.Width - roundingX), (float)(layout.Y + layout.Height));
                lowerPath.AddLine((float)(layout.X + layout.Width - roundingX), (float)(layout.Y + layout.Height),
                                  (float)(layout.X + roundingX), (float)(layout.Y + layout.Height));

                lowerPath.AddBezier((float)(layout.X + roundingX), (float)(layout.Y + layout.Height),
                                    (float)(layout.X + (roundingX / 2)), (float)(layout.Y + layout.Height),
                                    (float)(layout.X), (float)(layout.Y + layout.Height - (roundingY / 2)), (float)(layout.X),
                                    (float)(layout.Y + layout.Height - roundingY));
                lowerPath.AddLine((float)layout.X, (float)(layout.Y + layout.Height - roundingY), (float)(layout.X),
                                  (float)(layout.Y + (layout.Height / 2)));
                lowerPath.AddLine((float)layout.X, (float)(layout.Y + (layout.Height / 2)), (float)(layout.X + layout.Width),
                                  (float)(layout.Y + (layout.Height / 2)));
                lowerPath.AddLine((float)(layout.X + layout.Width), (float)(layout.Y + (layout.Height / 2)),
                                  (float)(layout.X + layout.Width), (float)(layout.Y + layout.Height - roundingY));

                graphics.FillPath(
                    new LinearGradientBrush(
                        new RectangleF((float)layout.X, (float)layout.Y, (float)layout.Width, (float)layout.Height),
                        Mix(Color.SkyBlue, Color.White, 0.5), Mix(Color.DodgerBlue, Color.White, 0.5), 90f), upperPath);
                graphics.FillPath(
                    new LinearGradientBrush(
                        new RectangleF((float)layout.X, (float)layout.Y, (float)layout.Width, (float)layout.Height),
                        Color.SkyBlue, Color.DodgerBlue, 90f), lowerPath);


                if (businessObject != null)
                {
                    // Draw a line to visualize the business object's value
                    graphics.DrawLine(Pens.Black, (float)(layout.X + 10), (float)(layout.Y + (layout.Height * 3 / 4)),
                                      (float)(layout.X + 10 + (layout.Width - 20) * businessObject.Value),
                                      (float)(layout.Y + (layout.Height * 3 / 4)));
                    // Display the business object's name
                    graphics.DrawString(businessObject.Name, new Font("Arial", 8), Brushes.Black, (float)(layout.X + 10),
                                        (float)layout.Y + 10);
                }
            }
コード例 #4
0
 /// <summary>
 /// Creates an instance for the given business object which restores the given <paramref name="oldValue"/> upon undo.
 /// </summary>
 /// <param name="obj">The business object to handle.</param>
 /// <param name="oldValue">The original value which will be restored upon undo.</param>
 public BusinessValueUndoUnit(ClipboardBusinessObject obj, double oldValue) : base("Change Value")
 {
     this.obj      = obj;
     this.oldValue = oldValue;
 }