示例#1
0
        private void Add(IWindowAction action)
        {
            UserControl newControl = null;

            if (action is WindowActionBringToFront)
            {
                newControl = new WindowBringToFront();
            }
            else if (action is WindowActionClose)
            {
                newControl = new WindowClose();
            }
            else if (action is WindowActionMaximize)
            {
                newControl = new WindowMaximize();
            }
            else if (action is WindowActionMinimize)
            {
                newControl = new WindowMinimize();
            }
            else if (action is WindowActionMove)
            {
                newControl = new WindowMove((WindowActionMove)action);
            }
            else if (action is WindowActionResize)
            {
                newControl = new WindowResize((WindowActionResize)action);
            }
            else if (action is WindowActionRestore)
            {
                newControl = new WindowRestore();
            }
            else if (action is WindowActionSendKeys)
            {
                newControl = new WindowSendKeys((WindowActionSendKeys)action);
            }
            else if (action is WindowActionWait)
            {
                newControl = new WindowWait((WindowActionWait)action);
            }

            WindowActionControl wac = new WindowActionControl(newControl);

            wac.Deleted += ContDeleted;
            stackPanelActions.Children.Add(wac);
            wac.Index = stackPanelActions.Children.Count;

            // scroll to the bottom of the viewer.
            actionScroller.ScrollToBottom();

            controlMap.Add(newControl, action);
        }
示例#2
0
        private void ContDeleted(object sender, EventArgs e)
        {
            WindowActionControl wac = sender as WindowActionControl;

            int removedIndex = wac.Index;

            stackPanelActions.Children.Remove(wac);
            controlMap.Remove(wac);

            // we removed an item, decrement all the following items by 1
            // start down by one because we are presenting at one based index
            for (int i = removedIndex - 1; i < stackPanelActions.Children.Count; i++)
            {
                ((WindowActionControl)stackPanelActions.Children[i]).Index--;
            }

            CheckCanSave();
        }