Exemplo n.º 1
0
        private void organizeChildren(bool reverseActivate)
        {
            if (currentRaindrops == 0)
            {
                return;
            }

            /*if (this.Width < 1000)
             *  this.Width = 1000;
             * int height = 340;
             * int count = 0;
             * for(int x = 0; x < this.MdiChildren.Length; x++)
             * {
             *  if (count >= 5 && count <= 20)
             *      height += 30;
             *  count++;
             * }
             * if(this.Height < height)
             *  this.Height = height;
             */
            int yoffset = 5;
            int xoffset = 505;

            foreach (Form f in this.MdiChildren)
            {
                f.WindowState = FormWindowState.Normal;
                f.Location    = new Point(xoffset, yoffset);
                if (!reverseActivate)
                {
                    f.Activate();
                }
                //offset += 86;
                yoffset += 70;
                if (yoffset > 700)
                {
                    yoffset  = 5;
                    xoffset += 471;
                }
                //offset += 30;
            }
            if (reverseActivate)
            {
                foreach (Form f in this.MdiChildren.Reverse())
                {
                    f.Activate();
                }
            }
        }
Exemplo n.º 2
0
        private void Init(CurveCanvas curveCanvas)
        {
            var lockorgValues = (int[])Enum.GetValues(typeof(OriginLockMode));
            var tanTypeValues = (int[])Enum.GetValues(typeof(CurveTangentTypes));
            var loopValues = (int[])Enum.GetValues(typeof(CurveLoopTypes));
            splitContainer1 = new SplitContainer();
            m_curvesListView = new ListView();

            m_curveControl = curveCanvas;

            m_menu = new MenuStrip();
            m_tangentsMenuItem = new ToolStripMenuItem();
            m_InTangentMenuItem = new ToolStripMenuItem();
            m_outTangentMenuItem = new ToolStripMenuItem();
            m_topStrip = new ToolStrip();
            m_PointLabel = new ToolStripLabel();
            m_xTxtBox = new ToolStripTextBox();
            m_yTxtBox = new ToolStripTextBox();
            m_bottomStrip = new ToolStrip();
            m_MousePos = new ToolStripLabel();
            m_helpForm = new HelpForm();
            m_TangentsSep1 = new ToolStripSeparator();
            m_editModeButtons = new ToolStripButton[4];
            for (int i = 0; i < m_editModeButtons.Length; i++)
            {
                m_editModeButtons[i] = new ToolStripButton();
            }

            m_tangentBtns = new ToolStripButton[5];
            for (int i = 0; i < m_tangentBtns.Length; i++)
            {
                m_tangentBtns[i] = new ToolStripButton();
            }

            m_infinityBtns = new ToolStripButton[4];
            for (int i = 0; i < m_infinityBtns.Length; i++)
            {
                m_infinityBtns[i] = new ToolStripButton();
            }

            // help menu items
            m_helpMenuItem = new ToolStripMenuItem();
            var quickHelpMenuItem = new ToolStripMenuItem();


            m_fitBtn = new ToolStripButton();
            m_breakTangent = new ToolStripButton();
            m_unifyTangent = new ToolStripButton();
            var snapToX = new ToolStripButton();
            var snapToY = new ToolStripButton();
            var snapToPoint = new ToolStripButton();
            var snapToCurve = new ToolStripButton();

            m_undoBtn = new ToolStripButton();
            m_redoBtn = new ToolStripButton();
            //m_cutBtn = new ToolStripButton();
            //m_copyBtn = new ToolStripButton();
            //m_pasteBtn = new ToolStripButton();
            m_delBtn = new ToolStripButton();

            // suspendlayouts            
            splitContainer1.Panel1.SuspendLayout();
            splitContainer1.Panel2.SuspendLayout();
            splitContainer1.SuspendLayout();
            SuspendLayout();


            m_preInfinityMenuItem = new ToolStripMenuItem();
            m_preInfinityMenuItem.Name = "PreInfinity";
            m_preInfinityMenuItem.Text = "Pre-Infinity".Localize();
            foreach (int val in loopValues)
            {
                string name = Enum.GetName(typeof(CurveLoopTypes), val);
                var item = new ToolStripMenuItem();
                item.Name = "PreInfinity" + name;
                item.Text = name;
                item.Tag = (CurveLoopTypes)val;
                item.Click += curveLoopMenu_Click;
                m_preInfinityMenuItem.DropDownItems.Add(item);
            }

            m_postInfinityMenuItem = new ToolStripMenuItem();
            m_postInfinityMenuItem.Name = "PostInfinity";
            m_postInfinityMenuItem.Text = "Post-Infinity".Localize();
            foreach (int val in loopValues)
            {
                string name = Enum.GetName(typeof(CurveLoopTypes), val);
                var item = new ToolStripMenuItem();
                item.Name = "PostInfinity" + name;
                item.Text = name;
                item.Tag = (CurveLoopTypes)val;
                item.Click += curveLoopMenu_Click;
                m_postInfinityMenuItem.DropDownItems.Add(item);
            }

            m_curveMenuItem = new ToolStripMenuItem();
            m_curveMenuItem.DropDownItems.AddRange(new ToolStripItem[] { m_preInfinityMenuItem, m_postInfinityMenuItem });
            m_curveMenuItem.Name = "Curve";
            m_curveMenuItem.Text = "Curve".Localize();

            var editMenuItem = new ToolStripMenuItem("Edit".Localize());
            editMenuItem.DropDown = m_curveControl.ContextMenuStrip;
           
            m_menu.Location = new Point(0, 0);
            m_menu.Name = "m_menu";
            m_menu.RenderMode = ToolStripRenderMode.System;
            m_menu.Size = new Size(898, 31);
            m_menu.TabIndex = 0;
            m_menu.Text = "menuStrip1";
            m_menu.Renderer = new CustomToolStripRenderer();

            foreach (int val in tanTypeValues)
            {
                var tanType = (CurveTangentTypes)val;
                if (!IsImplemented(tanType))
                    continue;
                string name = Enum.GetName(typeof(CurveTangentTypes), val);
                var item = new ToolStripMenuItem();
                item.Name = name;
                item.Text = name;
                item.Tag = tanType;
                item.Click += TanMenuItem_Click;
                m_tangentsMenuItem.DropDownItems.Add(item);
            }

            m_tangentsMenuItem.DropDownItems.AddRange(new ToolStripItem[] {                        
            m_TangentsSep1,
            m_InTangentMenuItem,
            m_outTangentMenuItem});
            m_tangentsMenuItem.Name = "m_tangentsMenuItem";
            m_tangentsMenuItem.Size = new Size(100, 27);
            m_tangentsMenuItem.Text = "Tangents".Localize();

            foreach (int val in tanTypeValues)
            {
                var tanType = (CurveTangentTypes)val;
                if (!IsImplemented(tanType) || tanType == CurveTangentTypes.Stepped
                    || tanType == CurveTangentTypes.SteppedNext)
                    continue;

                string name = Enum.GetName(typeof(CurveTangentTypes), val);
                var item = new ToolStripMenuItem();
                item.Name = "InTan" + name;
                item.Text = name;
                item.Tag = tanType;
                item.Click += TanMenuItem_Click;
                m_InTangentMenuItem.DropDownItems.Add(item);
            }
            m_InTangentMenuItem.Name = "m_InTangentMenuItem";
            m_InTangentMenuItem.Size = new Size(205, 28);
            m_InTangentMenuItem.Text = "In Tangent".Localize();

            foreach (int val in tanTypeValues)
            {
                var tanType = (CurveTangentTypes)val;
                if (!IsImplemented(tanType) || tanType == CurveTangentTypes.Stepped
                    || tanType == CurveTangentTypes.SteppedNext)
                    continue;

                string name = Enum.GetName(typeof(CurveTangentTypes), val);
                var item = new ToolStripMenuItem();
                item.Name = "OutTan" + name;
                item.Text = name;
                item.Tag = tanType;
                item.Click += TanMenuItem_Click;
                m_outTangentMenuItem.DropDownItems.Add(item);
            }
            m_outTangentMenuItem.Name = "m_outTangentMenuItem";
            m_outTangentMenuItem.Size = new Size(205, 28);
            m_outTangentMenuItem.Text = "Out Tangent".Localize();

            m_helpMenuItem.Name = "helpMenuItem";
            m_helpMenuItem.Text = "Help".Localize();
            m_helpMenuItem.DropDownItems.Add(quickHelpMenuItem);

            quickHelpMenuItem.Name = "quickHelpMenuItem";
            quickHelpMenuItem.Text = "Quick Help...".Localize();
            quickHelpMenuItem.Click += delegate
            {
                if (m_helpForm.Visible)
                {
                    m_helpForm.Activate();
                    return;
                }
                m_helpForm.Show(this);
            };

            m_optionsMenu = new ToolStripMenuItem("Options".Localize());
            var inputmodeMenu = new ToolStripMenuItem("Input Mode".Localize());
            m_basicMenuItem = new ToolStripMenuItem("Basic".Localize());
            m_basicMenuItem.Name = "basic";
            m_basicMenuItem.Click += delegate
            {
                InputMode = InputModes.Basic;

            };
            m_advancedInputMenuItem = new ToolStripMenuItem("Advanced".Localize());
            m_advancedInputMenuItem.Click += delegate
            {
                InputMode = InputModes.Advanced;
            };
            InputMode = m_curveControl.InputMode;

            m_flipYMenuItem = new ToolStripMenuItem("Flip Y-Axis".Localize());
            m_flipYMenuItem.Click += delegate
            {
                FlipY = !FlipY;
            };

            m_optionsMenu.DropDownOpening += delegate { m_flipYMenuItem.Checked = FlipY; };
                       
            inputmodeMenu.DropDownItems.Add(m_basicMenuItem);
            inputmodeMenu.DropDownItems.Add(m_advancedInputMenuItem);

            var lockmenu = new ToolStripMenuItem("Lock Origin".Localize(
                "This is the name of a command. Lock is a verb. Origin is like the origin of a graph."));
            foreach (int val in lockorgValues)
            {
                string name = Enum.GetName(typeof(OriginLockMode), val);
                var item = new ToolStripMenuItem();
                item.Name = name;
                item.Text = name;
                item.Tag = (OriginLockMode)val;
                item.Click += delegate(object sender, EventArgs e)
                {
                    var menuItem = (ToolStripMenuItem)sender;
                    m_curveControl.LockOrigin = (OriginLockMode)menuItem.Tag;
                };
                lockmenu.DropDownItems.Add(item);
            }
            lockmenu.DropDownOpening += delegate
            {
                foreach (ToolStripMenuItem mitem in lockmenu.DropDownItems)
                {
                    mitem.Checked = m_curveControl.LockOrigin == (OriginLockMode)mitem.Tag;
                }
            };

            m_optionsMenu.DropDownItems.Add(inputmodeMenu);
            m_optionsMenu.DropDownItems.Add(lockmenu);
            m_optionsMenu.DropDownItems.Add(m_flipYMenuItem);
                        
            // Initialize CurveTypeSelector (with items and labels)
            m_curveTypeLabel = new ToolStripLabel();
            m_curveTypeLabel.Name = "CurveTypeLabel";
            m_curveTypeLabel.AutoSize = true;
            m_curveTypeLabel.Text = "Type".Localize("curve types");
            m_curveTypeSelector = new ToolStripDropDownButton();
            m_curveTypeSelector.Name = "CurveTypeSelector";
            m_curveTypeSelector.AutoSize = false;
            m_curveTypeSelector.Width = 70;
            m_curveTypeSelector.ToolTipText = "Type of Selected Curve(s)".Localize();
            m_curveTypeSelector.DisplayStyle = ToolStripItemDisplayStyle.Text;
            var linearItem = new ToolStripMenuItem("Linear".Localize());
            linearItem.Tag = InterpolationTypes.Linear;
            linearItem.Name = linearItem.Text;
            var smoothItem = new ToolStripMenuItem("Smooth".Localize());
            smoothItem.Tag = InterpolationTypes.Hermite;
            smoothItem.Name = smoothItem.Text;
            smoothItem.Checked = true;
            m_curveTypeSelector.DropDownItems.Add(linearItem);
            m_curveTypeSelector.DropDownItems.Add(smoothItem);
            m_curveTypeSelector.Text = smoothItem.Text;
            m_curveTypeSelector.DropDownItemClicked += curveTypeSelector_DropDownItemClicked;

            m_menu.Items.AddRange(new ToolStripItem[] {
                editMenuItem,
                m_curveMenuItem,
            m_tangentsMenuItem,m_optionsMenu,m_helpMenuItem});

            m_topStrip.Items.AddRange(m_editModeButtons);
            m_topStrip.Items.Add(new ToolStripSeparator());
            m_topStrip.Items.AddRange(new ToolStripItem[] {                
            m_PointLabel,
            m_xTxtBox,
            m_yTxtBox,
            m_fitBtn,            
            });
            m_tanSeparator1 = new ToolStripSeparator();
            m_tanSeparator2 = new ToolStripSeparator();
            m_topStrip.Items.Add(m_tanSeparator1);
            m_topStrip.Items.Add(m_curveTypeLabel);
            m_topStrip.Items.Add(m_curveTypeSelector);
            m_topStrip.Items.AddRange(m_tangentBtns);
            m_topStrip.Items.Add(m_tanSeparator2);
            m_topStrip.Items.Add(m_breakTangent);
            m_topStrip.Items.Add(m_unifyTangent);
            m_topStrip.Items.Add(new ToolStripSeparator());
            m_topStrip.Items.Add(snapToX);
            m_topStrip.Items.Add(snapToY);
            m_topStrip.Items.Add(snapToPoint);
            m_topStrip.Items.Add(snapToCurve);
            m_topStrip.Items.Add(new ToolStripSeparator());
            m_topStrip.Items.AddRange(m_infinityBtns);
            m_topStrip.Items.Add(new ToolStripSeparator());
            m_topStrip.Items.Add(m_undoBtn);
            m_topStrip.Items.Add(m_redoBtn);
            //m_topStrip.Items.Add(m_cutBtn);
            //m_topStrip.Items.Add(m_copyBtn);
            //m_topStrip.Items.Add(m_pasteBtn);
            m_topStrip.Items.Add(m_delBtn);
            m_topStrip.Items.Add(new ToolStripSeparator());
            m_topStrip.Location = new Point(0, 31);
            m_topStrip.Name = "m_topStrip";
            m_topStrip.RenderMode = ToolStripRenderMode.System;
            m_topStrip.Size = new Size(898, 32);
            m_topStrip.TabIndex = 1;
            m_topStrip.Stretch = true;
            m_topStrip.Text = "topstrip";
            m_topStrip.GripStyle = ToolStripGripStyle.Hidden;
            m_topStrip.MinimumSize = new Size(32, 32);
            m_topStrip.CausesValidation = true;


            for (int i = 0; i < m_editModeButtons.Length; i++)
            {
                m_editModeButtons[i].DisplayStyle = ToolStripItemDisplayStyle.Image;
                m_editModeButtons[i].Click += EditModeClick;
                m_editModeButtons[i].Alignment = ToolStripItemAlignment.Left;
                m_editModeButtons[i].ImageScaling = ToolStripItemImageScaling.None;
            }

            m_editModeButtons[0].Name = "ScalePoint";
            m_editModeButtons[0].Tag = EditModes.Scale;
            m_editModeButtons[0].Image = new Bitmap(typeof(CurveUtils), "Resources.ScaleKeysTool.png");
            m_editModeButtons[0].ToolTipText = "Scale selected control points   " + KeysUtil.KeysToString(CurveCanvas.ShortcutKeys.Scale, true);

            m_editModeButtons[1].Checked = true;
            m_editModeButtons[1].Name = "MovePoint";
            m_editModeButtons[1].Tag = EditModes.Move;
            m_editModeButtons[1].Image = new Bitmap(typeof(CurveUtils), "Resources.MoveKeysTool.png");
            m_editModeButtons[1].ToolTipText = "Move selected control points   " + KeysUtil.KeysToString(CurveCanvas.ShortcutKeys.Move, true);

            m_editModeButtons[2].Name = "InsertPoint";
            m_editModeButtons[2].Tag = EditModes.InsertPoint;
            m_editModeButtons[2].Image = new Bitmap(typeof(CurveUtils), "Resources.InsertKeysTool.png");
            m_editModeButtons[2].ToolTipText = "Insert control point";

            m_editModeButtons[3].Name = "AddPoint";
            m_editModeButtons[3].Tag = EditModes.AddPoint;
            m_editModeButtons[3].Image = new Bitmap(typeof(CurveUtils), "Resources.AddKeysTool.png");
            m_editModeButtons[3].ToolTipText = "Add control point";


            m_PointLabel.Name = "m_PointLabel";
            m_PointLabel.AutoSize = true;
            m_PointLabel.Text = "Stats".Localize();

            m_xTxtBox.Name = "m_XtxtBox";
            m_xTxtBox.Size = new Size(100, 30);
            m_xTxtBox.Validating += InputBoxValidating;
            m_xTxtBox.KeyUp += m_TxtBox_KeyUp;
            m_xTxtBox.ReadOnly = true;


            m_yTxtBox.Name = "m_yTxtBox";
            m_yTxtBox.Size = new Size(100, 30);
            m_yTxtBox.Validating += InputBoxValidating;
            m_yTxtBox.KeyUp += m_TxtBox_KeyUp;
            m_yTxtBox.ReadOnly = true;


            // fit all
            m_fitBtn.Name = "m_fitBtn";
            m_fitBtn.DisplayStyle = ToolStripItemDisplayStyle.Image;
            m_fitBtn.Alignment = ToolStripItemAlignment.Left;
            m_fitBtn.Tag = null;
            m_fitBtn.Image = new Bitmap(typeof(CurveUtils), "Resources.FrameAll.png");
            m_fitBtn.ToolTipText = "Fit " + KeysUtil.KeysToString(CurveCanvas.ShortcutKeys.Fit, true);
            m_fitBtn.Click += delegate { m_curveControl.Fit(); };
            m_fitBtn.ImageScaling = ToolStripItemImageScaling.None;
            



            // tangent buttons
            for (int i = 0; i < m_tangentBtns.Length; i++)
            {
                m_tangentBtns[i].DisplayStyle = ToolStripItemDisplayStyle.Image;
                m_tangentBtns[i].Alignment = ToolStripItemAlignment.Left;
                m_tangentBtns[i].Name = "m_tangentBtns" + i;
                m_tangentBtns[i].ImageScaling = ToolStripItemImageScaling.None;
                m_tangentBtns[i].Click += delegate(object sender, EventArgs e)
                {
                    var btn = sender as ToolStripButton;
                    m_curveControl.SetTangent(TangentSelection.TangentInOut, (CurveTangentTypes)btn.Tag);
                };
            }
            m_tangentBtns[0].Tag = CurveTangentTypes.Spline;
            m_tangentBtns[0].Image = new Bitmap(typeof(CurveUtils), "Resources.SplineTangents.png");
            m_tangentBtns[0].ToolTipText = "Spline";

            m_tangentBtns[1].Tag = CurveTangentTypes.Clamped;
            m_tangentBtns[1].Image = new Bitmap(typeof(CurveUtils), "Resources.ClampedTangents.png");
            m_tangentBtns[1].ToolTipText = "Clamped";

            m_tangentBtns[2].Tag = CurveTangentTypes.Linear;
            m_tangentBtns[2].Image = new Bitmap(typeof(CurveUtils), "Resources.LinearTangents.png");
            m_tangentBtns[2].ToolTipText = "Linear";

            m_tangentBtns[3].Tag = CurveTangentTypes.Flat;
            m_tangentBtns[3].Image = new Bitmap(typeof(CurveUtils), "Resources.FlatTangents.png");
            m_tangentBtns[3].ToolTipText = "Flat";

            m_tangentBtns[4].Tag = CurveTangentTypes.Stepped;
            m_tangentBtns[4].Image = new Bitmap(typeof(CurveUtils), "Resources.StepTangents.png");
            m_tangentBtns[4].ToolTipText = "Step";


            // break tangents
            m_breakTangent.Name = "m_breakTangent";
            m_breakTangent.DisplayStyle = ToolStripItemDisplayStyle.Image;
            m_breakTangent.Alignment = ToolStripItemAlignment.Left;
            m_breakTangent.Image = new Bitmap(typeof(CurveUtils), "Resources.BreakTangents.png");
            m_breakTangent.ImageScaling = ToolStripItemImageScaling.None;
            m_breakTangent.ToolTipText = "Break Tangents";
            m_breakTangent.Click += delegate { m_curveControl.BreakTangents(true); };

            m_unifyTangent.Name = "m_unifyTangent";
            m_unifyTangent.DisplayStyle = ToolStripItemDisplayStyle.Image;
            m_unifyTangent.Alignment = ToolStripItemAlignment.Left;
            m_unifyTangent.Image = new Bitmap(typeof(CurveUtils), "Resources.UnifyTangents.png");
            m_unifyTangent.ImageScaling = ToolStripItemImageScaling.None;
            m_unifyTangent.ToolTipText = "Unify Tangents";
            m_unifyTangent.Click += delegate { m_curveControl.BreakTangents(false); };


            snapToX.Checked = m_curveControl.AutoSnapToX;
            snapToX.Name = "snapToX";
            snapToX.DisplayStyle = ToolStripItemDisplayStyle.Image;
            snapToX.Alignment = ToolStripItemAlignment.Left;
            snapToX.Image = new Bitmap(typeof(CurveUtils), "Resources.TimeSnap.png");
            snapToX.ImageScaling = ToolStripItemImageScaling.None;
            snapToX.ToolTipText = "Auto snap to major X tick";
            snapToX.Click += delegate
            {
                snapToX.Checked = !snapToX.Checked;
                m_curveControl.AutoSnapToX = snapToX.Checked;
            };


            snapToY.Checked = m_curveControl.AutoSnapToY;
            snapToY.Name = "snapToY";
            snapToY.DisplayStyle = ToolStripItemDisplayStyle.Image;
            snapToY.Alignment = ToolStripItemAlignment.Left;
            snapToY.Image = new Bitmap(typeof(CurveUtils), "Resources.ValueSnap.png");
            snapToY.ImageScaling = ToolStripItemImageScaling.None;
            snapToY.ToolTipText = "Auto snap to major Y tick";
            snapToY.Click += delegate
            {
                snapToY.Checked = !snapToY.Checked;
                m_curveControl.AutoSnapToY = snapToY.Checked;
            };

            snapToPoint.Checked = m_curveControl.AutoPointSnap;
            snapToPoint.Name = "snapToPoint";
            snapToPoint.DisplayStyle = ToolStripItemDisplayStyle.Image;
            snapToPoint.Alignment = ToolStripItemAlignment.Left;
            snapToPoint.Image = new Bitmap(typeof(CurveUtils), "Resources.PointSnap.png");
            snapToPoint.ImageScaling = ToolStripItemImageScaling.None;
            snapToPoint.ToolTipText = "Auto snap to point";
            snapToPoint.Click += delegate
            {
                snapToPoint.Checked = !snapToPoint.Checked;
                m_curveControl.AutoPointSnap = snapToPoint.Checked;
            };

            snapToCurve.Checked = m_curveControl.AutoCurveSnap;
            snapToCurve.Name = "snapToCurve";
            snapToCurve.DisplayStyle = ToolStripItemDisplayStyle.Image;
            snapToCurve.Alignment = ToolStripItemAlignment.Left;
            snapToCurve.Image = new Bitmap(typeof(CurveUtils), "Resources.CurveSnap.png");
            snapToCurve.ImageScaling = ToolStripItemImageScaling.None;
            snapToCurve.ToolTipText = "Auto snap to curve";
            snapToCurve.Click += delegate
            {
                snapToCurve.Checked = !snapToCurve.Checked;
                m_curveControl.AutoCurveSnap = snapToCurve.Checked;
            };

            for (int i = 0; i <= 1; i++)
            {
                m_infinityBtns[i].DisplayStyle = ToolStripItemDisplayStyle.Image;
                m_infinityBtns[i].Alignment = ToolStripItemAlignment.Left;
                m_infinityBtns[i].Name = "m_infinityBtns" + i;
                m_infinityBtns[i].ImageScaling = ToolStripItemImageScaling.None;
                m_infinityBtns[i].Click += delegate(object sender, EventArgs e)
                {
                    var btn = sender as ToolStripButton;
                    m_curveControl.SetPreInfinity((CurveLoopTypes)btn.Tag);
                };
            }

            for (int i = 2; i <= 3; i++)
            {
                m_infinityBtns[i].DisplayStyle = ToolStripItemDisplayStyle.Image;
                m_infinityBtns[i].Alignment = ToolStripItemAlignment.Left;
                m_infinityBtns[i].Name = "m_infinityBtns" + i;
                m_infinityBtns[i].ImageScaling = ToolStripItemImageScaling.None;
                m_infinityBtns[i].Click += delegate(object sender, EventArgs e)
                {
                    var btn = sender as ToolStripButton;
                    m_curveControl.SetPostInfinity((CurveLoopTypes)btn.Tag);
                };
            }


            m_infinityBtns[0].Tag = CurveLoopTypes.Cycle;
            m_infinityBtns[0].Image = new Bitmap(typeof(CurveUtils), "Resources.CycleBefore.png");
            m_infinityBtns[0].ToolTipText = "Cycle Before";

            m_infinityBtns[1].Tag = CurveLoopTypes.CycleWithOffset;
            m_infinityBtns[1].Image = new Bitmap(typeof(CurveUtils), "Resources.CycleBeforewithOffset.png");
            m_infinityBtns[1].ToolTipText = "Cycle Before with Offset";

            m_infinityBtns[2].Tag = CurveLoopTypes.Cycle;
            m_infinityBtns[2].Image = new Bitmap(typeof(CurveUtils), "Resources.CycleAfter.png");
            m_infinityBtns[2].ToolTipText = "Cycle After";

            m_infinityBtns[3].Tag = CurveLoopTypes.CycleWithOffset;
            m_infinityBtns[3].Image = new Bitmap(typeof(CurveUtils), "Resources.CycleAfterwithOffset.png");
            m_infinityBtns[3].ToolTipText = "Cycle After with Offset";

            // udo/redo/cut/copy/paste/delete  buttons            
            m_undoBtn.Name = "m_undoBtn";
            m_undoBtn.DisplayStyle = ToolStripItemDisplayStyle.Image;
            m_undoBtn.Alignment = ToolStripItemAlignment.Left;
            m_undoBtn.Image = ResourceUtil.GetImage24(Resources.UndoImage);
            m_undoBtn.ImageScaling = ToolStripItemImageScaling.None;
            m_undoBtn.ToolTipText = "Undo";
            m_undoBtn.Click += delegate { m_curveControl.Undo(); };

            m_redoBtn.Name = "m_redoBtn";
            m_redoBtn.DisplayStyle = ToolStripItemDisplayStyle.Image;
            m_redoBtn.Alignment = ToolStripItemAlignment.Left;
            m_redoBtn.Image = ResourceUtil.GetImage24(Resources.RedoImage);
            m_redoBtn.ImageScaling = ToolStripItemImageScaling.None;
            m_redoBtn.ToolTipText = "Redo";
            m_redoBtn.Click += delegate { m_curveControl.Redo(); };

            //m_cutBtn.Name = "cutBtn";
            //m_cutBtn.DisplayStyle = ToolStripItemDisplayStyle.Image;
            //m_cutBtn.Alignment = ToolStripItemAlignment.Left;
            //m_cutBtn.Image = ResourceUtil.GetImage24(Resources.CutImage);
            //m_cutBtn.ImageScaling = ToolStripItemImageScaling.None;
            //m_cutBtn.ToolTipText = "Cut selected points";
            //m_cutBtn.Click += delegate { m_curveControl.Cut(); };

            //m_copyBtn.Name = "copyBtn";
            //m_copyBtn.DisplayStyle = ToolStripItemDisplayStyle.Image;
            //m_copyBtn.Alignment = ToolStripItemAlignment.Left;
            //m_copyBtn.Image = ResourceUtil.GetImage24(Resources.CopyImage);
            //m_copyBtn.ImageScaling = ToolStripItemImageScaling.None;
            //m_copyBtn.ToolTipText = "Copy selected points";
            //m_copyBtn.Click += delegate { m_curveControl.Copy(); };

            //m_pasteBtn.Name = "pasteBtn";
            //m_pasteBtn.DisplayStyle = ToolStripItemDisplayStyle.Image;
            //m_pasteBtn.Alignment = ToolStripItemAlignment.Left;
            //m_pasteBtn.Image = ResourceUtil.GetImage24(Resources.PasteImage);
            //m_pasteBtn.ImageScaling = ToolStripItemImageScaling.None;
            //m_pasteBtn.ToolTipText = "Paste selected points";
            //m_pasteBtn.Click += delegate { m_curveControl.Paste(); };

            m_delBtn.Name = "delBtn";
            m_delBtn.DisplayStyle = ToolStripItemDisplayStyle.Image;
            m_delBtn.Alignment = ToolStripItemAlignment.Left;
            m_delBtn.Image = ResourceUtil.GetImage24(Resources.DeleteImage);
            m_delBtn.ImageScaling = ToolStripItemImageScaling.None;
            m_delBtn.ToolTipText = "Delete selected points";
            m_delBtn.Click += delegate { m_curveControl.Delete(); };

            m_bottomStrip.Dock = DockStyle.Bottom;
            m_bottomStrip.Items.AddRange(new ToolStripItem[] { m_MousePos });
            m_bottomStrip.Location = new Point(0, 549);
            m_bottomStrip.Name = "m_bottomStrip";
            m_bottomStrip.RenderMode = ToolStripRenderMode.System;
            m_bottomStrip.Size = new Size(898, 26);
            m_bottomStrip.TabIndex = 2;
            m_bottomStrip.Text = "toolStrip2";
            m_bottomStrip.GripStyle = ToolStripGripStyle.Hidden;

            m_MousePos.Alignment = ToolStripItemAlignment.Left;
            m_MousePos.AutoSize = true;
            m_MousePos.Name = "m_MousePos";
            m_MousePos.Size = new Size(250, 27);
            m_MousePos.Text = "Mouse Position".Localize();

            m_curveControl.Dock = DockStyle.Fill;
            m_curveControl.Location = new Point(24, 61);
            m_curveControl.Name = "m_curveControl";
            m_curveControl.Size = new Size(900, 600);
            m_curveControl.TabIndex = 0;
            m_curveControl.TabStop = false;
            m_curveControl.MouseMove += delegate(object sender, MouseEventArgs e)
            {
                PointD gp = m_curveControl.ClientToGraph_d(e.X, e.Y);
                m_MousePos.Text = string.Format("{0}, {1}", Math.Round(gp.X, 4), Math.Round(gp.Y, 4));
            };
            m_curveControl.MouseLeave += delegate { m_MousePos.Text = ""; };
            m_curveControl.MouseUp += delegate { UpdateInputBoxes(); };
            m_curveControl.EditMode = EditModes.Move;
            m_curveControl.EditModeChanged += delegate
            {
                foreach (ToolStripButton btn in m_editModeButtons)
                {
                    btn.Checked = (EditModes)btn.Tag == m_curveControl.EditMode;
                }
            };
            m_curveControl.SelectionChanged += SelectionChanged;

            m_TangentsSep1.Name = "m_TangentsSep1";
            m_TangentsSep1.Size = new Size(202, 6);

            splitContainer1.Dock = DockStyle.Fill;
            splitContainer1.ForeColor = SystemColors.Control;
            splitContainer1.Location = new Point(0, 48);
            splitContainer1.Name = "splitContainer1";
            splitContainer1.Panel1MinSize = 30;
            splitContainer1.Panel2MinSize = 30;
            splitContainer1.Panel1.Controls.Add(m_curvesListView);
            splitContainer1.Panel2.Controls.Add(m_curveControl);
            splitContainer1.Size = new Size(898, 520);
            splitContainer1.SplitterDistance = 180;
            splitContainer1.SplitterIncrement = 5;
            splitContainer1.TabIndex = 0;
            splitContainer1.TabStop = false;
            splitContainer1.Text = "splitContainer1";
            splitContainer1.BorderStyle = BorderStyle.None;
            splitContainer1.SplitterWidth = 4;
            splitContainer1.FixedPanel = FixedPanel.Panel1;
            splitContainer1.SplitterMoved += splitContainer1_SplitterMoved;
            splitContainer1.SplitterMoving += splitContainer1_SplitterMoving;

            // list view                  
            m_curvesListView.CheckBoxes = true;
            m_curvesListView.Dock = DockStyle.Fill;
            m_curvesListView.HideSelection = false;
            m_curvesListView.LabelEdit = false;
            m_curvesListView.Location = new Point(0, 0);
            m_curvesListView.Name = "m_curvesListView";
            m_curvesListView.Size = new Size(300, 300);
            m_curvesListView.TabIndex = 0;
            m_curvesListView.TabStop = false;
            m_curvesListView.TileSize = new Size(250, 24);
            m_curvesListView.UseCompatibleStateImageBehavior = false;
            m_curvesListView.View = View.Details;
            m_curvesListView.Sorting = SortOrder.Ascending;
            m_curvesListView.ItemChecked += m_curvesListView_ItemChecked;            
            m_curvesListView.Scrollable = true;
            m_curvesListView.Columns.Add("Curves", 250);
            m_curvesListView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
            m_curvesListView.AllowColumnReorder = false;
            m_curvesListView.BackColor = m_curveControl.BackColor;

            var addMenuItem = new ToolStripMenuItem("Add Point".Localize());
            var listMenuStrip = new ContextMenuStrip();
            m_curvesListView.ContextMenuStrip = listMenuStrip;
            listMenuStrip.Opening += delegate
            {
                addMenuItem.Enabled = m_curvesListView.SelectedItems.Count > 0;
            };
            listMenuStrip.Items.Add(addMenuItem);
            addMenuItem.Click += delegate
            {
                if (m_curvesListView.SelectedItems.Count == 0)
                    return;
                var dlg = new AddPointDialog();
                dlg.Location = new Point(MousePosition.X, MousePosition.Y);
                dlg.ShowDialog(this);
                if (dlg.DialogResult != DialogResult.OK)
                    return;

                PointF pt = dlg.PointPosition;
                m_curveControl.TransactionContext.DoTransaction(delegate
                {
                    foreach (ListViewItem item in m_curvesListView.SelectedItems)
                    {
                        var curve = (ICurve)item.Tag;
                        IControlPoint cpt = curve.CreateControlPoint();
                        float x = pt.X;

                        int index = CurveUtils.GetValidInsertionIndex(curve, x);
                        while (index == -1)
                        {
                            x += CurveUtils.Epsilone;
                            index = CurveUtils.GetValidInsertionIndex(curve, x);
                        }

                        cpt.X = x;
                        cpt.Y = pt.Y;
                        curve.InsertControlPoint(index, cpt);
                        CurveUtils.ComputeTangent(curve);
                    }
                }, "Add Point".Localize());

                m_curveControl.Invalidate();
            };

            ClientSize = new Size(898, 575);
            Dock = DockStyle.Fill;
            Controls.Add(splitContainer1);
            Controls.Add(m_bottomStrip);
            Controls.Add(m_topStrip);
            Controls.Add(m_menu);

            // resume layouts.                        
            splitContainer1.Panel1.ResumeLayout(false);
            splitContainer1.Panel2.ResumeLayout(false);
            splitContainer1.ResumeLayout(false);
            ResumeLayout(false);
            PerformLayout();
            Invalidated += CurveEditorControl_Invalidated;
            SetUI(false);
            Application.Idle += Application_Idle;
        }