示例#1
0
    private void hover_MinimizeClicked(object sender, EventArgs e)
    {
        dbg.WriteLine("----- hover_MinimizeClicked -----");

        PhysicsIllustrator.SmartTag.SmartTag tag = sender as PhysicsIllustrator.SmartTag.SmartTag;

        this.WindowState = FormWindowState.Minimized;
    }
示例#2
0
    private void hover_AnimateClicked(object sender, EventArgs e)
    {
        dbg.WriteLine("----- hover_AnimateClicked -----");

        PhysicsIllustrator.SmartTag.SmartTag tag = sender as PhysicsIllustrator.SmartTag.SmartTag;

        // Running or stopping?
        if (inkoverlay.Enabled)
        {
            // Lock down all editing operations.
            DisableInkOverlay();
            if (bodytag.Visible)
            {
                bodytag.Hide();
            }

            // Change tag to red x.
            hover.Enabled = false;
            tag.Image     = Global.LoadImage("Resources.StopAnimation.ico");
            menuttip.SetToolTip(tag, "Stop!");
            tag.Show();

            // Fork the document for animation.
            MagicDocument animedoc = doc.Clone();

            // Run the animation!
            engine = new AnimationEngine();
            engine.Start(animedoc, this);
        }
        else         // stopping
        {
            engine.Stop();

            inkoverlay.Enabled = true;

            tag.Image = Global.LoadImage("Resources.Animate.ico");
            menuttip.SetToolTip(tag, "Animate!");
            hover.Enabled = true;
            hover.DisplayInitial();
            Invalidate();
        }
    }
    //
    // Interface
    #region InitializeControls()
    public void InitializeControls(ToolTip tooltip)
    {
        // Create and initialize the smart tag "menu" controls.
        fileTag     = new PhysicsIllustrator.SmartTag.SmartTag();
        editTag     = new PhysicsIllustrator.SmartTag.SmartTag();
        drawTag     = new PhysicsIllustrator.SmartTag.SmartTag();
        eraseTag    = new PhysicsIllustrator.SmartTag.SmartTag();
        lassoTag    = new PhysicsIllustrator.SmartTag.SmartTag();
        animateTag  = new PhysicsIllustrator.SmartTag.SmartTag();
        pauseTag    = new PhysicsIllustrator.SmartTag.SmartTag();
        minimizeTag = new PhysicsIllustrator.SmartTag.SmartTag();

        fileTag.Location     = new Point(1 * 42, 20);
        editTag.Location     = new Point(2 * 42, 20);
        drawTag.Location     = new Point(3 * 42, 20);
        eraseTag.Location    = new Point(4 * 42, 20);
        lassoTag.Location    = new Point(5 * 42, 20);
        animateTag.Location  = new Point(6 * 42, 20);
        pauseTag.Location    = new Point(7 * 42, 20);
        minimizeTag.Location = new Point(Parent.Width - 1 * 42, 20);

        fileTag.Image     = Global.LoadImage("Resources.FileMenu.ico");
        editTag.Image     = Global.LoadImage("Resources.EditMenu.ico");
        drawTag.Image     = Global.LoadImage("Resources.Pen.ico");
        eraseTag.Image    = Global.LoadImage("Resources.Eraser.ico");
        lassoTag.Image    = Global.LoadImage("Resources.Lasso.ico");
        animateTag.Image  = Global.LoadImage("Resources.Animate.ico");
        pauseTag.Image    = Global.LoadImage("Resources.PauseAnimate.ico");
        minimizeTag.Image = Global.LoadImage("Resources.Minimize.ico");

        tooltip.SetToolTip(fileTag, "Main Menu");
        tooltip.SetToolTip(editTag, "Edit Menu");
        tooltip.SetToolTip(drawTag, "Pen");
        tooltip.SetToolTip(eraseTag, "Eraser");
        tooltip.SetToolTip(lassoTag, "Selection Lasso");
        tooltip.SetToolTip(animateTag, "Animate!");
        tooltip.SetToolTip(pauseTag, "Pause");
        tooltip.SetToolTip(minimizeTag, "Minimize");

        fileTag.ContextMenu = new ContextMenu();
        fileTag.ContextMenu.MenuItems.Add("New", new EventHandler(fileTag_New));
        fileTag.ContextMenu.MenuItems.Add("Open...", new EventHandler(fileTag_Open));
        fileTag.ContextMenu.MenuItems.Add("Save", new EventHandler(fileTag_Save));
        fileTag.ContextMenu.MenuItems.Add("Save As...", new EventHandler(fileTag_SaveAs));

        fileTag.ContextMenu.MenuItems.Add("Collaboration...", new EventHandler(fileTag_Collab));

        fileTag.ContextMenu.MenuItems.Add("-");
        fileTag.ContextMenu.MenuItems.Add("Help", new EventHandler(fileTag_Help));
        fileTag.ContextMenu.MenuItems.Add("About...", new EventHandler(fileTag_About));
        fileTag.ContextMenu.MenuItems.Add("-");
        fileTag.ContextMenu.MenuItems.Add("Exit", new EventHandler(fileTag_Exit));

        fileTag.FindMenuItem("Open...").Shortcut = Shortcut.CtrlO;

        editTag.ContextMenu = new ContextMenu();
        editTag.ContextMenu.MenuItems.Add("Clone", new EventHandler(editTag_Clone));
        editTag.ContextMenu.MenuItems.Add("Delete", new EventHandler(editTag_Delete));
        editTag.ContextMenu.MenuItems.Add("-");
        editTag.ContextMenu.MenuItems.Add("Straighten", new EventHandler(editTag_Straighten));
        editTag.ContextMenu.MenuItems.Add("Properties...", new EventHandler(editTag_Properties));

        drawTag.ContextMenu = null;
        drawTag.Click      += new EventHandler(drawTag_Click);

        eraseTag.ContextMenu = null;
        eraseTag.Click      += new EventHandler(eraseTag_Click);

        lassoTag.ContextMenu = null;
        lassoTag.Click      += new EventHandler(lassoTag_Click);

        animateTag.ContextMenu = null;
        animateTag.Click      += new EventHandler(animateTag_Click);

        pauseTag.ContextMenu = null;
        pauseTag.Click      += new EventHandler(pauseTag_Click);

        minimizeTag.ContextMenu = null;
        minimizeTag.Click      += new EventHandler(minimizeTag_Click);

        base.AddControl(fileTag);
        base.AddControl(editTag);
        base.AddControl(drawTag);
        base.AddControl(eraseTag);
        base.AddControl(lassoTag);
        base.AddControl(animateTag);
        base.AddControl(pauseTag);
        base.AddControl(minimizeTag, true);        // right-hand side
    }
示例#4
0
    //
    // Initialization

    public MainForm()
    {
        // Required for Windows Form Designer support.
        InitializeComponent();

        // Load our icon.
        this.Icon = new Icon(typeof(MainForm), "PhysicsIllustrator.ico");

        // Initialize the per-item smart tag.
        bodytag         = new PhysicsIllustrator.SmartTag.SmartTag();
        bodytag.Image   = Global.LoadImage("Resources.PenMenu.ico");
        bodytag.Visible = false;

        bodytag.ContextMenu = new ContextMenu();
        bodytag.ContextMenu.MenuItems.Add("Clone", new EventHandler(hover_EditCloneClicked));
        bodytag.ContextMenu.MenuItems.Add("Delete", new EventHandler(hover_EditDeleteClicked));
        bodytag.ContextMenu.MenuItems.Add("-");
        bodytag.ContextMenu.MenuItems.Add("Straighten", new EventHandler(hover_EditStraightenClicked));
        bodytag.ContextMenu.MenuItems.Add("Properties...", new EventHandler(hover_EditPropertiesClicked));

        this.Controls.Add(bodytag);

        // Go fullscreen.  Note: this works even with the taskbar set
        // to "keep on top of other windows".
        this.WindowState = System.Windows.Forms.FormWindowState.Normal;
        this.Bounds      = Screen.PrimaryScreen.Bounds;

        // Declare repaint optimizations.
        base.SetStyle(
            ControlStyles.UserPaint |
            ControlStyles.AllPaintingInWmPaint |
            ControlStyles.DoubleBuffer,
            true);

        // Init inkoverlay.
        inkoverlay = new InkOverlay(this.Handle, true);
        inkoverlay.CollectionMode = CollectionMode.InkOnly; // no gestures

        inkoverlay.AutoRedraw = false;                      // Dynamic rendering only; we do all the painting.

        DrawingAttributes da = new DrawingAttributes();

        da.AntiAliased = false;
        inkoverlay.DefaultDrawingAttributes = da;

        inkoverlay.Stroke += new InkCollectorStrokeEventHandler(inkoverlay_Stroke);

        inkoverlay.CursorInRange   += new InkCollectorCursorInRangeEventHandler(inkoverlay_CursorInRange);
        inkoverlay.StrokesDeleting += new InkOverlayStrokesDeletingEventHandler(inkoverlay_StrokesDeleting);

        inkoverlay.SelectionChanging += new InkOverlaySelectionChangingEventHandler(inkoverlay_SelectionChanging);
        inkoverlay.SelectionChanged  += new InkOverlaySelectionChangedEventHandler(inkoverlay_SelectionChanged);
        inkoverlay.SelectionMoved    += new InkOverlaySelectionMovedEventHandler(inkoverlay_SelectionMoved);
        inkoverlay.SelectionResized  += new InkOverlaySelectionResizedEventHandler(inkoverlay_SelectionResized);

        declaredmode = inkoverlay.EditingMode;

        // Spin up SDI model (ink+doc).
        doc            = new MagicDocument();
        inkoverlay.Ink = doc.Ink;

        inkoverlay.Enabled = !DesignMode;

        inkoverlay.Ink.InkAdded += new StrokesEventHandler(inkoverlay_Ink_InkAdded);
    }
示例#5
0
    public MainForm()
    {
        // Required for Windows Form Designer support.
        InitializeComponent();

        // Load our icon.
        this.Icon = new Icon(typeof(MainForm),"PhysicsIllustrator.ico");

        // Initialize the per-item smart tag.
        bodytag = new PhysicsIllustrator.SmartTag.SmartTag();
        bodytag.Image = Global.LoadImage("Resources.PenMenu.ico");
        bodytag.Visible = false;

        bodytag.ContextMenu = new ContextMenu();
        bodytag.ContextMenu.MenuItems.Add("Clone", new EventHandler(hover_EditCloneClicked));
        bodytag.ContextMenu.MenuItems.Add("Delete", new EventHandler(hover_EditDeleteClicked));
        bodytag.ContextMenu.MenuItems.Add("-");
        bodytag.ContextMenu.MenuItems.Add("Straighten", new EventHandler(hover_EditStraightenClicked));
        bodytag.ContextMenu.MenuItems.Add("Properties...", new EventHandler(hover_EditPropertiesClicked));

        this.Controls.Add(bodytag);

        // Go fullscreen.  Note: this works even with the taskbar set
        // to "keep on top of other windows".
        this.WindowState = System.Windows.Forms.FormWindowState.Normal;
        // this.Bounds = Screen.PrimaryScreen.Bounds;

        // Declare repaint optimizations.
        base.SetStyle(
            ControlStyles.UserPaint|
            ControlStyles.AllPaintingInWmPaint|
            ControlStyles.DoubleBuffer,
            true);

        // Init inkoverlay.
        inkoverlay = new InkOverlay(this.Handle,true);
        inkoverlay.CollectionMode = CollectionMode.InkOnly; // no gestures

        inkoverlay.AutoRedraw = false; // Dynamic rendering only; we do all the painting.

        DrawingAttributes da = new DrawingAttributes();
        da.AntiAliased = false;
        inkoverlay.DefaultDrawingAttributes = da;

        inkoverlay.Stroke += new InkCollectorStrokeEventHandler(inkoverlay_Stroke);

        inkoverlay.CursorInRange += new InkCollectorCursorInRangeEventHandler(inkoverlay_CursorInRange);
        inkoverlay.StrokesDeleting += new InkOverlayStrokesDeletingEventHandler(inkoverlay_StrokesDeleting);

        inkoverlay.SelectionChanging += new InkOverlaySelectionChangingEventHandler(inkoverlay_SelectionChanging);
        inkoverlay.SelectionChanged += new InkOverlaySelectionChangedEventHandler(inkoverlay_SelectionChanged);
        inkoverlay.SelectionMoved += new InkOverlaySelectionMovedEventHandler(inkoverlay_SelectionMoved);
        inkoverlay.SelectionResized += new InkOverlaySelectionResizedEventHandler(inkoverlay_SelectionResized);

        // inkoverlay.
        declaredmode = inkoverlay.EditingMode;

        // Spin up SDI model (ink+doc).
        doc = new MagicDocument();
        inkoverlay.Ink = doc.Ink;

        inkoverlay.Enabled = !DesignMode;

        inkoverlay.Ink.InkAdded += new StrokesEventHandler(inkoverlay_Ink_InkAdded);
    }
    public void InitializeControls(ToolTip tooltip)
    {
        // Create and initialize the smart tag "menu" controls.
        fileTag = new PhysicsIllustrator.SmartTag.SmartTag();
        editTag = new PhysicsIllustrator.SmartTag.SmartTag();
        drawTag = new PhysicsIllustrator.SmartTag.SmartTag();
        eraseTag = new PhysicsIllustrator.SmartTag.SmartTag();
        lassoTag = new PhysicsIllustrator.SmartTag.SmartTag();
        animateTag = new PhysicsIllustrator.SmartTag.SmartTag();
        pauseTag = new PhysicsIllustrator.SmartTag.SmartTag();
        minimizeTag = new PhysicsIllustrator.SmartTag.SmartTag();

        fileTag.Location = new Point(1*42, 20);
        editTag.Location = new Point(2*42, 20);
        drawTag.Location = new Point(3*42, 20);
        eraseTag.Location = new Point(4*42, 20);
        lassoTag.Location = new Point(5*42, 20);
        animateTag.Location = new Point(6*42, 20);
        pauseTag.Location = new Point(7*42, 20);
        minimizeTag.Location = new Point(Parent.Width-1*42, 20);

        fileTag.Image = Global.LoadImage("Resources.FileMenu.ico");
        editTag.Image = Global.LoadImage("Resources.EditMenu.ico");
        drawTag.Image = Global.LoadImage("Resources.Pen.ico");
        eraseTag.Image = Global.LoadImage("Resources.Eraser.ico");
        lassoTag.Image = Global.LoadImage("Resources.Lasso.ico");
        animateTag.Image = Global.LoadImage("Resources.Animate.ico");
        pauseTag.Image = Global.LoadImage("Resources.PauseAnimate.ico");
        minimizeTag.Image = Global.LoadImage("Resources.Minimize.ico");

        tooltip.SetToolTip(fileTag,"Main Menu");
        tooltip.SetToolTip(editTag,"Edit Menu");
        tooltip.SetToolTip(drawTag,"Pen");
        tooltip.SetToolTip(eraseTag,"Eraser");
        tooltip.SetToolTip(lassoTag,"Selection Lasso");
        tooltip.SetToolTip(animateTag,"Animate!");
        tooltip.SetToolTip(pauseTag,"Pause");
        tooltip.SetToolTip(minimizeTag,"Minimize");

        fileTag.ContextMenu = new ContextMenu();
        fileTag.ContextMenu.MenuItems.Add("New", new EventHandler(fileTag_New));
        fileTag.ContextMenu.MenuItems.Add("Open...", new EventHandler(fileTag_Open));
        fileTag.ContextMenu.MenuItems.Add("Save", new EventHandler(fileTag_Save));
        fileTag.ContextMenu.MenuItems.Add("Save As...", new EventHandler(fileTag_SaveAs));

        fileTag.ContextMenu.MenuItems.Add("Collaboration...", new EventHandler(fileTag_Collab));

        fileTag.ContextMenu.MenuItems.Add("-");
        fileTag.ContextMenu.MenuItems.Add("Help", new EventHandler(fileTag_Help));
        fileTag.ContextMenu.MenuItems.Add("About...", new EventHandler(fileTag_About));
        fileTag.ContextMenu.MenuItems.Add("-");
        fileTag.ContextMenu.MenuItems.Add("Exit", new EventHandler(fileTag_Exit));

        fileTag.FindMenuItem("Open...").Shortcut = Shortcut.CtrlO;

        editTag.ContextMenu = new ContextMenu();
        editTag.ContextMenu.MenuItems.Add("Clone", new EventHandler(editTag_Clone));
        editTag.ContextMenu.MenuItems.Add("Delete", new EventHandler(editTag_Delete));
        editTag.ContextMenu.MenuItems.Add("-");
        editTag.ContextMenu.MenuItems.Add("Straighten", new EventHandler(editTag_Straighten));
        editTag.ContextMenu.MenuItems.Add("Properties...", new EventHandler(editTag_Properties));

        drawTag.ContextMenu = null;
        drawTag.Click += new EventHandler(drawTag_Click);

        eraseTag.ContextMenu = null;
        eraseTag.Click += new EventHandler(eraseTag_Click);

        lassoTag.ContextMenu = null;
        lassoTag.Click += new EventHandler(lassoTag_Click);

        animateTag.ContextMenu = null;
        animateTag.Click += new EventHandler(animateTag_Click);

        pauseTag.ContextMenu = null;
        pauseTag.Click += new EventHandler(pauseTag_Click);

        minimizeTag.ContextMenu = null;
        minimizeTag.Click += new EventHandler(minimizeTag_Click);

        base.AddControl(fileTag);
        base.AddControl(editTag);
        base.AddControl(drawTag);
        base.AddControl(eraseTag);
        base.AddControl(lassoTag);
        base.AddControl(animateTag);
        base.AddControl(pauseTag);
        base.AddControl(minimizeTag,true); // right-hand side
    }