public PLDateSelection()
 {
     this._Types = SelectionTypes.All;
     this._ReturnType = TimeType.Date;
     this.InitializeComponent();
     this.SetLookup();
 }
Exemple #2
0
 private void select(SelectionTypes button)
 {
     if (appState.InEditSession() && currentPointerHit != null && LayerIsEditable())
     {
         editSelected    = true;
         currentSelected = currentPointerHit;
         currentSelected.SendMessage("Selected", button, SendMessageOptions.DontRequireReceiver);
     }
 }
Exemple #3
0
 public override void Selected(SelectionTypes button)
 {
     if (button == SelectionTypes.SELECTALL)
     {
         gameObject.BroadcastMessage("Selected", SelectionTypes.BROADCAST, SendMessageOptions.DontRequireReceiver);
         BlockMove = true;
         GetComponentsInChildren <Dataline>().ToList <Dataline>().ForEach(item => item.Selected(SelectionTypes.SELECTALL));
     }
 }
 public PLDateSelection(SelectionTypes SelectionTypes, SelectionTypes Default, TimeType ReturnType)
 {
     this._Types = SelectionTypes.All;
     this._ReturnType = TimeType.Date;
     this.InitializeComponent();
     this._Types = SelectionTypes;
     this._Default = Default;
     this._ReturnType = ReturnType;
     this.SetLookup();
 }
Exemple #5
0
 public void SetSelectionType(Control control, SelectionTypes selectionTypes)
 {
     if (functionDict.ContainsKey(control))
     {
         functionDict[control] = selectionTypes;
     }
     else
     {
         functionDict.Add(control, selectionTypes);
     }
 }
Exemple #6
0
        protected override void OnMouseUp(MouseEventArgs e)
        {
            base.OnMouseUp(e);

            if (SelectionType != SelectionTypes.None)
            {
                SelectionType = SelectionTypes.Selected;
                MoveHelper.UnSelectArrow();
                RotationHelper.UnSelectRing();
            }
        }
            public Selection(bool guess, Formula formula, Dictionary <string, string> dictVariables)
            {
                _guess         = guess;
                _formula       = formula;
                _selectionType = SelectionTypes.Formula;
                _dictVariables = new Dictionary <string, string>();

                foreach (KeyValuePair <string, string> valuePair in dictVariables)
                {
                    _dictVariables.Add(valuePair.Key, valuePair.Value);
                }
            }
 public GeneticMachine(int jobs, int procs, int macs, int popsize)
 {
     this.jobnum   = jobs;
     this.procnum  = procs;
     this.macnum   = macs;
     krlength      = jobs * procs;
     mutOdd        = 1;
     minTimeOdd    = 0;
     groupSize     = 5;
     population    = new Schedule[popsize];
     popSize       = popsize;
     crossOver     = COTypes.Uniform;
     mutationTypes = MutationTypes.ExchangeValues;
     selectionType = SelectionTypes.Tournament;
     best          = null;
     nothingFound  = 0;
 }
Exemple #9
0
 public GeneticMachine(int jobs, int procs, int macs, int popsize)
 {
     this.NumberOfJobs      = jobs;
     this.NumberOfProcesses = procs;
     this.NumberOfMachines  = macs;
     NumberOfJobsXProcess   = jobs * procs;
     mutOdd        = 1;
     minTimeOdd    = 0;
     groupSize     = 5;
     population    = new Schedule[popsize];
     popSize       = popsize;
     crossOver     = COTypes.Uniform;
     mutationTypes = MutationTypes.ExchangeValues;
     selectionType = SelectionTypes.Tournament;
     best          = null;
     nothingFound  = 0;
 }
Exemple #10
0
 public void SelectObject(Object3D ActiveObject3D)
 {
     if (ActiveObject3D != null)
     {
         SelectedObject          = ActiveObject3D;
         SelectionType           = SelectionTypes.Selected;
         MoveHelper.Position     = ActiveObject3D.Position;
         RotationHelper.Position = ActiveObject3D.Position;
     }
     else
     {
         SelectedObject = null;
         SelectionType  = SelectionTypes.None;
         MoveHelper.UnSelectArrow();
         RotationHelper.UnSelectRing();
     }
 }
Exemple #11
0
        void control_Click(object sender, EventArgs e)
        {
            Control        control = sender as Control;
            Control        selectionSourceControl = buttonDict[control];
            SelectionTypes selectType             = functionDict[control];

            if (selectionSourceControl is CheckedListBox)
            {
                CheckedListBox checkedListBox = selectionSourceControl as CheckedListBox;
                for (int i = 0; i < checkedListBox.Items.Count; i++)
                {
                    bool _selected = checkedListBox.GetItemChecked(i);
                    _selected = ChangSelected(_selected, selectType);
                    checkedListBox.SetItemChecked(i, _selected);
                    checkedListBox.SetSelected(i, _selected);
                }
            }
        }
Exemple #12
0
 private bool ChangSelected(bool isSelected, SelectionTypes types)
 {
     if (types == SelectionTypes.清空)
     {
         return(false);
     }
     else if (types == SelectionTypes.全选)
     {
         return(true);
     }
     else if (types == SelectionTypes.反选)
     {
         return(!isSelected);
     }
     else
     {
         throw new NotImplementedException();
     }
 }
Exemple #13
0
        private void ClickHandler(SelectionTypes button)
        {
            RaycastHit hitInfo  = new RaycastHit();
            Vector3    mousePos = Input.mousePosition;
            Ray        ray      = self.ScreenPointToRay(mousePos);
            //Debug.DrawRay(ray.origin, ray.direction * 100f, Color.yellow, 1000f);
            bool hit = Physics.Raycast(ray, out hitInfo);

            if (hit)
            {
                currentPointerHit = hitInfo.transform;
                select(button);
                selectedDistance = hitInfo.distance;
                from             = hitInfo.point;
            }
            else
            {
                editSelected = false;
            }
        }
Exemple #14
0
 /// <summary>
 /// Реализация абстрактного метода. Производит вычисления,
 /// а также принимает входные параметры от пользователя. в данном случае также выводит результат выполнения
 /// задачи в консоль.
 /// </summary>
 public override void MenuItem()
 {
     activeSelections.Clear();
     switcher = 0;
     while (true)
     {
         if (activeSelections.Count == 0)
         {
             activeSelections.Add(SelectionTypes.None);
         }
         DisplayActiveSelectionTypes();
         DisplayAllSelectionTypes();
         WriteLine("Enter exit to {0} to main menu.", ExitString);
         string enteredValue = ReadLine();
         if (enteredValue.ToLower() == ExitString)
         {
             break;
         }
         if (!uint.TryParse(enteredValue, out switcher))
         {
             WriteLine("Sorry, value is invalid. Enter unsigned integer.");
             continue;
         }
         else
         {
             SelectionTypes selected = selectionTypes.Where(st => (uint)st.Key == switcher).FirstOrDefault().Key;
             if (activeSelections.Contains(selected))
             {
                 activeSelections.Remove(selected);
             }
             else
             {
                 activeSelections.Add(selected);
             }
             if (activeSelections.Contains(SelectionTypes.None))
             {
                 activeSelections.Remove(SelectionTypes.None);
             }
         }
     }
 }
Exemple #15
0
        private void modifySelection(CheckedListBox list, SelectionTypes type)
        {
            int[] selectedArray = new int[list.SelectedIndices.Count];
            list.SelectedIndices.CopyTo(selectedArray, 0);
            list.SelectedIndices.Clear();

            for (var i = 0; i < list.Items.Count; i++)
            {
                if (type == SelectionTypes.All)
                {
                    list.SelectedIndices.Add(i);
                }
                else if (type == SelectionTypes.Inverse)
                {
                    if (!selectedArray.Contains(i))
                    {
                        list.SelectedIndices.Add(i);
                    }
                }
                list.SetItemChecked(i, list.SelectedIndices.Contains(i));
            }
        }
Exemple #16
0
    public GeneticAlgorithm(int populationSize, int dnaSize, Random random, Func <int, T> getRandomGene, Func <int, float> fitnessFunction,
                            float elitism = 1, SelectionTypes selectionType = 0, CrossoverTypes crossoverType = 0, float crossoverRate = 1f, float mutationRate = 0.01f)
    {
        Population           = new List <DNA <T> >(populationSize);
        newPopulation        = new List <DNA <T> >(populationSize);
        Generation           = 1;
        Elitism              = Math.Max(0, elitism) < 1 ? (int)elitism * populationSize : (int)elitism; //If less than 1 treat it as a percentage of the population
        MutationRate         = mutationRate;
        CrossoverRate        = crossoverRate;
        this.random          = random;
        this.dnaSize         = dnaSize;
        this.getRandomGene   = getRandomGene;
        this.selectionType   = selectionType;
        this.crossoverType   = crossoverType;
        this.fitnessFunction = fitnessFunction;

        BestGenes = new T[dnaSize];

        for (int i = 0; i < populationSize; i++)
        {
            Population.Add(new DNA <T>(dnaSize, random, getRandomGene, fitnessFunction, crossoverType, shouldInitGenes: true));
        }
    }
Exemple #17
0
        private int[] GetSelectedIndices(SelectionTypes t)
        {
            List <int> rval = new List <int>();

            if (IsCommandLine)
            {
                return(rval.ToArray());
            }

            for (int i = 0; i < treeView1.SelectedNodes.Count; i++)
            {
                SeriesCatalogRow si = treeView1.SelectedNodes[i].Tag as SeriesCatalogRow;
                if (t == SelectionTypes.Series && si.IsFolder == 0)
                {
                    rval.Add(si.id);
                }
                if (t == SelectionTypes.Folder && si.IsFolder == 1)
                {
                    rval.Add(si.id);
                }
            }
            return(rval.ToArray());
        }
Exemple #18
0
 private void HandleMouseMove(MouseEventArgs e)
 {
     if (MoveHelper.ArrowXCollideWithMouse(e.X, e.Y, GraphicsDevice.Viewport,
                                           ActiveCamera.View,
                                           ActiveCamera.Projection))
     {
         SelectionType = SelectionTypes.MoveX;
         MoveHelper.SelectArrowX();
     }
     else if (MoveHelper.ArrowYCollideWithMouse(e.X, e.Y, GraphicsDevice.Viewport,
                                                ActiveCamera.View,
                                                ActiveCamera.Projection))
     {
         SelectionType = SelectionTypes.MoveY;
         MoveHelper.SelectArrowY();
     }
     else if (MoveHelper.ArrowZCollideWithMouse(e.X, e.Y, GraphicsDevice.Viewport,
                                                ActiveCamera.View,
                                                ActiveCamera.Projection))
     {
         SelectionType = SelectionTypes.MoveZ;
         MoveHelper.SelectArrowZ();
     }
 }
Exemple #19
0
        //
        // Link this to the mouse click control
        //

        public void HandleMouseClick(InputAction.CallbackContext context)
        {
            InputAction    action = context.action;
            SelectionTypes button = SelectionTypes.SELECT;

            switch (action.name)
            {
            case "Select":
                button = SelectionTypes.SELECT;
                break;

            case "MultiSelect":
                button = SelectionTypes.SELECTALL;
                break;
            }
            if (action.phase == InputActionPhase.Canceled && appState.InEditSession())
            {
                UnClickHandler(button);
            }
            else if (action.phase == InputActionPhase.Started && !editSelected && appState.InEditSession())
            {
                ClickHandler(button);
            }
        }
Exemple #20
0
 private void HandleMouseRotation(MouseEventArgs e)
 {
     if (RotationHelper.RingXCollideWithMouse(e.X, e.Y, GraphicsDevice.Viewport,
                                              ActiveCamera.View,
                                              ActiveCamera.Projection))
     {
         SelectionType = SelectionTypes.RotateX;
         RotationHelper.SelectRingX();
     }
     else if (RotationHelper.RingYCollideWithMouse(e.X, e.Y, GraphicsDevice.Viewport,
                                                   ActiveCamera.View,
                                                   ActiveCamera.Projection))
     {
         SelectionType = SelectionTypes.RotateY;
         RotationHelper.SelectRingY();
     }
     else if (RotationHelper.RingZCollideWithMouse(e.X, e.Y, GraphicsDevice.Viewport,
                                                   ActiveCamera.View,
                                                   ActiveCamera.Projection))
     {
         SelectionType = SelectionTypes.RotateZ;
         RotationHelper.SelectRingZ();
     }
 }
		public void SetSelectedComponents(ICollection comps, SelectionTypes st)
		{
			SetSelectedComponents(comps);
		}
 public EasyGridVariousTypeCellInfo(ICollection <String> items, int selectedIndex, SelectionTypes itemtype = SelectionTypes.ComboBox)
 {
     if (itemtype == SelectionTypes.ComboBox)
     {
         this.ItemType = ItemTypes.ComboBox;
     }
     else
     {
         this.ItemType = ItemTypes.RadioButton;
     }
     this.Items         = items;
     this.SelectedIndex = selectedIndex;
     if (selectedIndex >= 0 && items.Count > selectedIndex)
     {
         this.SelectedText = items.ElementAt(selectedIndex);
     }
 }
Exemple #23
0
        // If the array is a null reference or does not contain any components,
        // SetSelectedComponents selects the top-level component in the designer.
        //
        public void SetSelectedComponents(ICollection components, SelectionTypes selectionType)
        {
            bool primary, add, remove, replace, toggle, auto;

            primary = add = remove = replace = toggle = auto = false;

            OnSelectionChanging();

            if (_selection == null)
            {
                throw new InvalidOperationException("_selection == null");
            }

            if (components == null || components.Count == 0)
            {
                components = new ArrayList();
                ((ArrayList)components).Add(this.RootComponent);
                selectionType = SelectionTypes.Replace;
            }

            if (!Enum.IsDefined(typeof(SelectionTypes), selectionType))
            {
                selectionType = SelectionTypes.Auto;
            }

            auto = ((selectionType & SelectionTypes.Auto) == SelectionTypes.Auto);


            if (auto)
            {
                if ((((Control.ModifierKeys & Keys.Control) == Keys.Control) || ((Control.ModifierKeys & Keys.Shift) == Keys.Shift)))
                {
                    toggle = true;
                }
                else if (components.Count == 1)
                {
                    object component = null;
                    foreach (object c in components)
                    {
                        component = c;
                        break;
                    }

                    if (this.GetComponentSelected(component))
                    {
                        primary = true;
                    }
                    else
                    {
                        replace = true;
                    }
                }
                else
                {
                    replace = true;
                }
            }
            else
            {
                primary = ((selectionType & SelectionTypes.Primary) == SelectionTypes.Primary);
                add     = ((selectionType & SelectionTypes.Add) == SelectionTypes.Add);
                remove  = ((selectionType & SelectionTypes.Remove) == SelectionTypes.Remove);
                toggle  = ((selectionType & SelectionTypes.Toggle) == SelectionTypes.Toggle);
                replace = ((selectionType & SelectionTypes.Replace) == SelectionTypes.Replace);
            }


            if (replace)
            {
                _selection.Clear();
                add = true;
            }

            if (add)
            {
                foreach (object component in components)
                {
                    if (component is IComponent && !_selection.Contains(component))
                    {
                        _selection.Add(component);
                        _primarySelection = (IComponent)component;
                    }
                }
            }

            if (remove)
            {
                bool rootRemoved = false;
                foreach (object component in components)
                {
                    if (component is IComponent && _selection.Contains(component))
                    {
                        _selection.Remove(component);
                    }
                    if (component == this.RootComponent)
                    {
                        rootRemoved = true;
                    }
                }
                if (_selection.Count == 0)
                {
                    if (rootRemoved)
                    {
                        _primarySelection = null;
                    }
                    else
                    {
                        _primarySelection = this.RootComponent;
                        _selection.Add(this.RootComponent);
                    }
                }
            }

            if (toggle)
            {
                foreach (object component in components)
                {
                    if (component is IComponent)
                    {
                        if (_selection.Contains(component))
                        {
                            _selection.Remove(component);
                            if (component == _primarySelection)
                            {
                                _primarySelection = this.RootComponent;
                            }
                        }
                        else
                        {
                            _selection.Add(component);
                            _primarySelection = (IComponent)component;
                        }
                    }
                }
            }

            if (primary)
            {
                object primarySelection = null;

                foreach (object component in components)
                {
                    primarySelection = component;
                    break;
                }

                if (!this.GetComponentSelected(primarySelection))
                {
                    _selection.Add(primarySelection);
                }

                _primarySelection = (IComponent)primarySelection;
            }

            OnSelectionChanged();
        }
        public void SetSelectedComponents(ICollection components, SelectionTypes selectionType)
        {
            bool control = false;
            bool shift = false;

            // Raise selectionchanging event
            if (SelectionChanging != null)
                SelectionChanging(this, EventArgs.Empty);

            // If we're being passed an empty collection
            if (components == null || components.Count == 0)
                components = new object[1] { host.RootComponent };

            // If the selection type is Click, we want to know if shift or control is being held
            if ((selectionType & SelectionTypes.Click) == SelectionTypes.Click)
            {
                control = ((Control.ModifierKeys & Keys.Control) == Keys.Control);
                shift = ((Control.ModifierKeys & Keys.Shift)   == Keys.Shift);
            }

            if (selectionType == SelectionTypes.Replace)
            {
                // Simply replace our existing collection with the new one
                selectedComponents.Clear();
                foreach (object component in components)
                {
                    if (component != null && !selectedComponents.Contains(component))
                        selectedComponents.Add(component);
                }
            }
            else
            {
                // Clear selection if ctrl or shift isn't pressed
                if (!control && !shift && components.Count == 1)
                {
                    foreach(object component in components)
                    {
                        if (!selectedComponents.Contains(component))
                            selectedComponents.Clear();
                    }
                }

                // Add or remove each component to or from the selection
                foreach (object component in components)
                {
                    if (component != null)
                    {
                        if (control || shift)
                        {
                            if (selectedComponents.Contains(component))
                                selectedComponents.Remove(component);
                            else
                                selectedComponents.Insert(0, component);
                        }
                        else
                        {
                            if (!selectedComponents.Contains(component))
                                selectedComponents.Add(component);
                            else
                            {
                                selectedComponents.Remove(component);
                                selectedComponents.Insert(0, component);
                            }
                        }
                    }
                }
            }

            // Raise the selectionchanged event
            if (SelectionChanged != null)
                SelectionChanged(this, EventArgs.Empty);
        }
Exemple #25
0
        public void SetSelectedComponents(ICollection components, SelectionTypes selectionType)
        {
            // fire changing event
            if (SelectionChanging != null)
            {
                try
                {
                    SelectionChanging(this, EventArgs.Empty);
                }
                catch {}
            }
            // dont allow an empty collection
            if (components == null || components.Count == 0)
            {
                components = new ArrayList();
            }
            bool ctrlDown = false, shiftDown = false;

            // we need to know if shift or ctrl is down on clicks
            if ((selectionType & SelectionTypes.Click) == SelectionTypes.Click)
            {
                ctrlDown  = ((Control.ModifierKeys & Keys.Control) == Keys.Control);
                shiftDown = ((Control.ModifierKeys & Keys.Shift) == Keys.Shift);
            }
            if (selectionType == SelectionTypes.Replace)
            {
                // discard the hold list and go with this one
                selectedComponents = new ArrayList(components);
            }
            else
            {
                if (!shiftDown && !ctrlDown && components.Count == 1 && !selectedComponents.Contains(components))
                {
                    selectedComponents.Clear();
                }
                // something was either added to the selection
                // or removed
                IEnumerator ie = components.GetEnumerator();
                while (ie.MoveNext())
                {
                    IComponent comp = ie.Current as IComponent;
                    if (comp != null)
                    {
                        if (ctrlDown || shiftDown)
                        {
                            if (selectedComponents.Contains(comp))
                            {
                                selectedComponents.Remove(comp);
                            }
                            else
                            {
                                // put it back into the front because it was
                                // the last one selected
                                selectedComponents.Insert(0, comp);
                            }
                        }
                        else
                        {
                            if (!selectedComponents.Contains(comp))
                            {
                                selectedComponents.Add(comp);
                            }
                            else
                            {
                                selectedComponents.Remove(comp);
                                selectedComponents.Insert(0, comp);
                            }
                        }
                    }
                }
            }
            // fire changed event
            if (SelectionChanged != null)
            {
                try
                {
                    SelectionChanged(this, EventArgs.Empty);
                }
                catch {}
            }
        }
		/// Select the given components with the given SelectionType.
        void ISelectionService.SetSelectedComponents(ICollection components, SelectionTypes selectionType) {
            bool fToggle = false;
            bool fControl = false;
            bool fClick  = false;
            bool fChanged = false;  // did we actually change something?

            // Catch a null input list
            if (components == null){
                components = new Component[0];
            }

            if ((selectionType & SelectionTypes.Normal) == SelectionTypes.Normal
                || (selectionType & SelectionTypes.Click) == SelectionTypes.Click) {

                fControl = ((Control.ModifierKeys & Keys.Control) == Keys.Control);

                // Only toggle when we are affecting a single control, and
                // when we are handling the "mouse" state events (i.e. up/down
                // used to show/hide the selection).
                //
                fToggle = ((Control.ModifierKeys & Keys.Control) != 0 || (Control.ModifierKeys & Keys.Shift) != 0)
                          && components.Count == 1
                          && (selectionType & SelectionTypes.MouseUp) != SelectionTypes.MouseUp;
            }

            if ((selectionType & SelectionTypes.Click) == SelectionTypes.Click) {
                fClick = true;
            }


            // If we are replacing the selection, only remove the ones that are not in our new list.
            // We also handle the special case here of having a singular component selected that's
            // already selected.  In this case we just move it to the primary selection.
            //
            if (!fToggle && !fControl) {
                object firstSelection = null;
                foreach(object o in components) {
                    firstSelection = o;
                    break;
                }
                
                if (fClick && 1 == components.Count && ((ISelectionService)this).GetComponentSelected(firstSelection)) {
                    SampleSelectionItem oldPrimary = primarySelection;
                    SetPrimarySelection((SampleSelectionItem)selectionsByComponent[firstSelection]);
                    if (oldPrimary != primarySelection) {
                        fChanged = true;
                    }
                }
                else {
                    SampleSelectionItem[] selections = new SampleSelectionItem[selectionsByComponent.Values.Count];
                    selectionsByComponent.Values.CopyTo(selections, 0);                    

                    // Even with several hundred components this should be fairly fast
                    foreach(SampleSelectionItem item in selections) {
                        bool remove = true;
                    
                        foreach(object comp in components) {
                            if (comp == item.Component) {
                                remove = false;
                                break;
                            }
                        }
                        
                        if (remove) {
                            RemoveSelection(item);
                            fChanged = true;
                        }
                    }
                }
            }

            SampleSelectionItem primarySel = null;
            int selectedCount = selectionsByComponent.Count;

            // Now do the selection.
            foreach(Component comp in components) {
                if (comp != null) {
                    SampleSelectionItem  s = (SampleSelectionItem)selectionsByComponent[comp];
    
                    if (null == s) {
                        s = new SampleSelectionItem(this, comp);
                        AddSelection(s);

                        if (fControl || fToggle) {
                            primarySel = s;
                        }

                        fChanged = true;
                    }
                    else {
                        if (fToggle) {
                            // Remove the selection from our list.
                            RemoveSelection(s);
                            fChanged = true;
                        }
                    }
                }
            }

            if (primarySel != null) {
                SetPrimarySelection(primarySel);
            }

            // Now notify that our selection has changed
            if (fChanged) {
                OnSelectionChanged();
            }
        }
        public virtual bool Add(Entity newEntity, SelectionTypes type)
        {
            if (newEntity == null) //invalid entity
            {
                return(false);
            }

            if (manager.MultipleSelectionKeyDown == true)          //if the player is holding down the multiple selection key
            {
                type = SelectionTypes.multiple;                    //multiple selection incoming
            }
            if (currExclusive && newEntity.Type != lastEntityType) //if the last selection type was exclusive and this doesn't match the last selected entity type
            {
                type = SelectionTypes.single;                      //single selection now (and all previous elements will be deselected)
            }
            bool exclusiveOnSuccess = false;                       //will the selection be marked as exclusive in case the entity is successfully selected? by default no

            foreach (SelectionOptions options in selectionOptions) //go through all the selection options
            {
                if (newEntity.Type == options.entityType)          //if the entity type matches
                {
                    if (options.exclusive == true)                 //if this entity type can be selected only exclusively
                    {
                        exclusiveOnSuccess = true;                 //mark selection as exclusive on success

                        if (newEntity.Type != lastEntityType)      //the last selected entity does not match with the current type
                        {
                            type = SelectionTypes.single;          //all previous selected elements will be deselected
                        }
                    }

                    if (type == SelectionTypes.multiple && options.allowMultiple == false) //if the selection type is multiple but that's not allowed for this entity type
                    {
                        type = SelectionTypes.single;                                      //set type back to single to deselect previous elements
                    }
                    break;                                                                 //entity type match found, no need to see the rest of the options
                }
            }

            switch (type)
            {
            case SelectionTypes.single: //single selection

                RemoveAll();            //remove all selected entities
                break;

            case SelectionTypes.multiple:                                      //multiple selection:

                if (manager.MultipleSelectionKeyDown && IsSelected(newEntity)) //if the multiple selection key is down & entity is already selected, selecting a new entity -> removing it from the already selected group
                {
                    Remove(newEntity);
                    return(false);
                }
                break;
            }

            if (newEntity.GetSelection().CanSelect() == true && IsSelected(newEntity) == false) //can be selected and not already selected?
            {
                if (selectedDic.TryGetValue(newEntity.GetCode(), out List <Entity> targetList)) //if there's at least another entity of the same type that is already selected
                {
                    targetList.Add(newEntity);
                }
                else //if not add it to new list and new entry to dictionary
                {
                    selectedDic.Add(newEntity.GetCode(), new List <Entity> {
                        newEntity
                    });
                }

                Count++;                                                  //increment the selection count

                if (Count == 1)                                           //first entity to get selected?
                {
                    singleSelected = newEntity;                           //assign as the single selected entity
                    singleSelected.GetSelection().IsSelectedOnly = true;  //mark as selected only
                }
                else if (Count == 2)                                      //only one entity was selected before
                {
                    singleSelected.GetSelection().IsSelectedOnly = false; //not the only selected entity any more.
                }
                newEntity.GetSelection().OnSelected();

                lastEntityType = newEntity.Type;     //set the last selected entity type
                currExclusive  = exclusiveOnSuccess; //is the selection exclusive now?

                return(true);
            }

            return(false);
        }
        public void SetSelectedComponents(ICollection <DesignItem> components, SelectionTypes selectionType)
        {
            if (components == null)
            {
                components = SharedInstances.EmptyDesignItemArray;
            }

            if (components.Contains(null))
            {
                throw new ArgumentException("Cannot select 'null'.");
            }

            var prevSelectedItems = _selectedComponents.ToArray();

            if (SelectionChanging != null)
            {
                SelectionChanging(this, EventArgs.Empty);
            }

            DesignItem newPrimarySelection = _primarySelection;

            if (selectionType == SelectionTypes.Auto)
            {
                if (Keyboard.Modifiers == ModifierKeys.Control)
                {
                    selectionType = SelectionTypes.Toggle;                     // Ctrl pressed: toggle selection
                }
                else if ((Keyboard.Modifiers & ~ModifierKeys.Control) == ModifierKeys.Shift)
                {
                    selectionType = SelectionTypes.Add;                     // Shift or Ctrl+Shift pressed: add to selection
                }
                else
                {
                    selectionType = SelectionTypes.Primary;                     // otherwise: change primary selection
                }
            }

            if ((selectionType & SelectionTypes.Primary) == SelectionTypes.Primary)
            {
                // change primary selection to first new component
                newPrimarySelection = null;
                foreach (DesignItem obj in components)
                {
                    newPrimarySelection = obj;
                    break;
                }

                selectionType &= ~SelectionTypes.Primary;
                if (selectionType == 0)
                {
                    // if selectionType was only Primary, and components has only one item that
                    // changes the primary selection was changed to an already-selected item,
                    // then we keep the current selection.
                    // otherwise, we replace it
                    if (components.Count == 1 && IsComponentSelected(newPrimarySelection) && prevSelectedItems.Length == 1)
                    {
                        // keep selectionType = 0 -> don't change the selection
                    }
                    else
                    {
                        selectionType = SelectionTypes.Replace;
                    }
                }
            }

            HashSet <DesignItem> componentsToNotifyOfSelectionChange = new HashSet <DesignItem>();

            switch (selectionType)
            {
            case SelectionTypes.Add:
                // add to selection and notify if required
                foreach (DesignItem obj in components)
                {
                    if (_selectedComponents.Add(obj))
                    {
                        componentsToNotifyOfSelectionChange.Add(obj);
                    }
                }
                break;

            case SelectionTypes.Remove:
                // remove from selection and notify if required
                foreach (DesignItem obj in components)
                {
                    if (_selectedComponents.Remove(obj))
                    {
                        componentsToNotifyOfSelectionChange.Add(obj);
                    }
                }
                break;

            case SelectionTypes.Replace:
                // notify all old components:
                componentsToNotifyOfSelectionChange.AddRange(_selectedComponents);
                // set _selectedCompontents to new components
                _selectedComponents.Clear();
                foreach (DesignItem obj in components)
                {
                    _selectedComponents.Add(obj);
                    // notify the new components
                    componentsToNotifyOfSelectionChange.Add(obj);
                }
                break;

            case SelectionTypes.Toggle:
                // toggle selection and notify
                foreach (DesignItem obj in components)
                {
                    if (_selectedComponents.Contains(obj))
                    {
                        _selectedComponents.Remove(obj);
                    }
                    else
                    {
                        _selectedComponents.Add(obj);
                    }
                    componentsToNotifyOfSelectionChange.Add(obj);
                }
                break;

            case 0:
                // do nothing
                break;

            default:
                throw new NotSupportedException("The selection type " + selectionType + " is not supported");
            }

            if (!IsComponentSelected(newPrimarySelection))
            {
                // primary selection is not selected anymore - change primary selection to any other selected component
                newPrimarySelection = null;
                foreach (DesignItem obj in _selectedComponents)
                {
                    newPrimarySelection = obj;
                    break;
                }
            }

            // Primary selection has changed:
            if (newPrimarySelection != _primarySelection)
            {
                componentsToNotifyOfSelectionChange.Add(_primarySelection);
                componentsToNotifyOfSelectionChange.Add(newPrimarySelection);
                if (PrimarySelectionChanging != null)
                {
                    PrimarySelectionChanging(this, EventArgs.Empty);
                }
                _primarySelection = newPrimarySelection;
                if (PrimarySelectionChanged != null)
                {
                    PrimarySelectionChanged(this, EventArgs.Empty);
                }
                RaisePropertyChanged("PrimarySelection");
            }

            if (!_selectedComponents.SequenceEqual(prevSelectedItems))
            {
                if (SelectionChanged != null)
                {
                    SelectionChanged(this, new DesignItemCollectionEventArgs(componentsToNotifyOfSelectionChange));
                }
                RaisePropertyChanged("SelectedItems");
            }
        }
        protected override void OnClick(EventArgs e)
        {
            Invalidate();
            if (TheSelectionType == SelectionTypes.SelectionOne) {
                Caption1Visible = false;
                Caption2Visible = true;

                RaiseToggleButtonSelectionTwoClickedEvent();
                TheSelectionType = SelectionTypes.SelectionTwo;
            } else {
                Caption2Visible = false;
                Caption1Visible = true;

                RaiseToggleButtonSelectionOneClickedEvent();
                TheSelectionType = SelectionTypes.SelectionOne;
            }
            while (TheExcutionDuration.ElapsedMilliseconds() <= 300)
                System.Threading.Thread.Sleep(100);

            TheToggleButton.Pressed = false;
            Invalidate();
        }
 public Selection(bool guess, Formula formula, Dictionary <string, string> dictVariables, WorldObject obj, string variable) : this(guess, formula, dictVariables)
 {
     _worldObject   = new WorldObject(obj);
     _variable      = variable;
     _selectionType = SelectionTypes.WorldObject;
 }
Exemple #31
0
 private void unSelect(SelectionTypes button)
 {
     editSelected = false;
     currentSelected?.SendMessage("UnSelected", button, SendMessageOptions.DontRequireReceiver);
     currentSelected = null;
 }
 void ISelectionService.SetSelectedComponents(ICollection components, SelectionTypes selectionType)
 {
     bool fToggle = false;
     bool fControl = false;
     bool fClick = false;
     bool fChanged = false;
     if (components == null)
     {
         components = new Component[0];
     }
     if (((selectionType & SelectionTypes.Auto) == SelectionTypes.Auto) || ((selectionType & SelectionTypes.Click) == SelectionTypes.Click))
     {
         fControl = (Control.ModifierKeys & Keys.Control) == Keys.Control;
         fToggle = ((((Control.ModifierKeys & Keys.Control) != Keys.None) || ((Control.ModifierKeys & Keys.Shift) != Keys.None)) && (components.Count == 1)) && ((selectionType & SelectionTypes.MouseUp) != SelectionTypes.MouseUp);
     }
     if ((selectionType & SelectionTypes.Click) == SelectionTypes.Click)
     {
         fClick = true;
     }
     if (!fToggle && !fControl)
     {
         object firstSelection = null;
         foreach (object o in components)
         {
             firstSelection = o;
             break;
         }
         if ((fClick && (1 == components.Count)) && ((ISelectionService) this).GetComponentSelected(firstSelection))
         {
             SampleSelectionItem oldPrimary = this.primarySelection;
             this.SetPrimarySelection((SampleSelectionItem) this.selectionsByComponent[firstSelection]);
             if (oldPrimary != this.primarySelection)
             {
                 fChanged = true;
             }
         }
         else
         {
             SampleSelectionItem[] selections = new SampleSelectionItem[this.selectionsByComponent.Values.Count];
             this.selectionsByComponent.Values.CopyTo(selections, 0);
             foreach (SampleSelectionItem item in selections)
             {
                 bool remove = true;
                 foreach (object comp in components)
                 {
                     if (comp == item.Component)
                     {
                         remove = false;
                         break;
                     }
                 }
                 if (remove)
                 {
                     this.RemoveSelection(item);
                     fChanged = true;
                 }
             }
         }
     }
     SampleSelectionItem primarySel = null;
     int selectedCount = this.selectionsByComponent.Count;
     foreach (Component comp in components)
     {
         if (comp != null)
         {
             SampleSelectionItem s = (SampleSelectionItem) this.selectionsByComponent[comp];
             if (null == s)
             {
                 s = new SampleSelectionItem(this, comp);
                 this.AddSelection(s);
                 if (fControl || fToggle)
                 {
                     primarySel = s;
                 }
                 fChanged = true;
             }
             else if (fToggle)
             {
                 this.RemoveSelection(s);
                 fChanged = true;
             }
         }
     }
     if (primarySel != null)
     {
         this.SetPrimarySelection(primarySel);
     }
     if (fChanged)
     {
         this.OnSelectionChanged();
     }
 }
        private void ChangeSelection(SelectionTypes Selection)
        {
            BasicControl control;
            DateTime dateTo = DateTime.Now;
            //DateTime dateFrom = this.DateTimeControl.DateFrom;
            if (this.bkWith != null)
            {
                this.LookUpEditFrom.Width = (Int32)bkWith;
            }
            switch (Selection)
            {
                case SelectionTypes.None:
                    if (bkWith == null)
                        bkWith = this.LookUpEditFrom.Width;
                    this.LookUpEditFrom.Width = this.orginWith;
                    control = new BasicControl();
                    control.Visible = false;
                    break;
                case SelectionTypes.OneDate:
                    control = new DayControl(dateTo);
                    break;

                case SelectionTypes.OneMonth:
                    control = new PLMonthControl(dateTo);
                    break;

                case SelectionTypes.OneQuarter:
                    control = new PLQuarterControl(dateTo);
                    break;

                case SelectionTypes.OneYear:
                    control = new PLYearControl(dateTo);
                    break;

                case SelectionTypes.SixMonths:
                    control = new PLSixMonths(dateTo);
                    break;

                case SelectionTypes.FromQuarterToQuarter:
                    control = new PLFromToQuarter(dateTo.AddMonths(-9), dateTo);
                    break;

                case SelectionTypes.FromYearToYear:
                    control = new PLFromToYearDateTime(new DateTime(dateTo.Year - 1, 1, 1), new DateTime(dateTo.Year, 1, 1));
                    break;

                case SelectionTypes.FromDateToDate:
                    control = new PLFromToDay(dateTo.AddDays(-7), dateTo);
                    break;

                case SelectionTypes.FromMonthToMonth:
                    control = new PLFromToMonth(dateTo.AddMonths(-2), dateTo);
                    break;

                default:
                    control = new DayControl(dateTo);
                    break;
            }
            this.ShowControl(control);
        }
Exemple #34
0
 /// <summary>
 /// make ComboBox or RadioButton Column
 /// </summary>
 /// <param name="wid"></param>
 /// <param name="colName"></param>
 /// <param name="titleText"></param>
 /// <param name="items"></param>
 /// <param name="selectedIndex"></param>
 /// <param name="itemtype"></param>
 public EasyGridColumnInfo(int wid, String colName, String titleText, ICollection <String> items, int selectedIndex, SelectionTypes itemtype = SelectionTypes.ComboBox)
 {
     ColumnName     = colName;
     Width          = wid;
     this.TitleText = titleText;
     if (itemtype == SelectionTypes.ComboBox)
     {
         this.ItemType = ItemTypes.ComboBox;
     }
     else
     {
         this.ItemType = ItemTypes.RadioButton;
     }
     this.Items = items;
     if (selectedIndex < 0)
     {
         if (items != null && items.Count > 0)
         {
             this.SelectedText  = items.ElementAt(0);
             this.SelectedIndex = 0;
         }
     }
     else
     {
         this.SelectedIndex = selectedIndex;
         if (selectedIndex >= 0 && items.Count > selectedIndex)
         {
             this.SelectedText = items.ElementAt(selectedIndex);
         }
     }
 }
Exemple #35
0
 public void SetComboOrRadioInfo(int wid, String colName, ICollection <String> items, int selectedIndex, SelectionTypes itemtype = SelectionTypes.ComboBox)
 {
     ColumnName = colName;
     Width      = wid;
     if (itemtype == SelectionTypes.ComboBox)
     {
         this.ItemType = ItemTypes.ComboBox;
     }
     else
     {
         this.ItemType = ItemTypes.RadioButton;
     }
     this.Items         = items;
     this.SelectedIndex = selectedIndex;
     if (selectedIndex >= 0 && items.Count > selectedIndex)
     {
         this.SelectedText = items.ElementAt(selectedIndex);
     }
 }
		protected virtual void SelectComponent(IComponent comp, SelectionTypes selectionType)
		{
			ISelectionService selection = (ISelectionService) this.GetService(typeof(ISelectionService));
			if(selection!=null && comp!=null)
			{
				ArrayList arr=new ArrayList(1);
				arr.Add(comp);
				selection.SetSelectedComponents(arr,selectionType);
			}
		}
Exemple #37
0
 void ISelectionService.SetSelectedComponents(ICollection components, SelectionTypes selectionType)
 {
     if (selectionType != SelectionTypes.Auto)
     {
         throw new ArgumentOutOfRangeException("selectionType");
     }
     this.OnSelectionChanging(EventArgs.Empty);
     this._selectedObjects = components;
     this.OnSelectionChanged(EventArgs.Empty);
 }
		// If the array is a null reference or does not contain any components,
		// SetSelectedComponents selects the top-level component in the designer.
		//
		public void SetSelectedComponents (ICollection components, SelectionTypes selectionType)
		{
			bool primary, add, remove, replace, toggle, auto;
			primary = add = remove = replace = toggle = auto = false;
			
			OnSelectionChanging ();

			if (_selection == null)
				throw new InvalidOperationException("_selection == null");
			
			if (components == null || components.Count == 0) {
				components = new ArrayList ();
				((ArrayList) components).Add (this.RootComponent);
				selectionType = SelectionTypes.Replace;
			}
			
			if (!Enum.IsDefined (typeof (SelectionTypes), selectionType)) {
#if NET_2_0	
				selectionType = SelectionTypes.Auto;
#else
				selectionType = SelectionTypes.Normal;	   				
#endif
			}

#if NET_2_0		
			auto = ((selectionType & SelectionTypes.Auto) == SelectionTypes.Auto);
#else
			if ((selectionType & SelectionTypes.Normal) == SelectionTypes.Normal ||
				(selectionType & SelectionTypes.MouseDown) == SelectionTypes.MouseDown ||
				(selectionType & SelectionTypes.MouseUp) == SelectionTypes.MouseUp) {

					auto = true;
			}	   	
#endif			
			
			
			if (auto) {
				if ((((Control.ModifierKeys & Keys.Control) == Keys.Control) || ((Control.ModifierKeys & Keys.Shift) == Keys.Shift))) {
					toggle = true;
				}
				else if (components.Count == 1) {
					object component = null;
					foreach (object c in components) {
						component = c;
						break;
					}

					if (this.GetComponentSelected (component))
						primary = true;
					else
						replace = true;
				}
				else {
					replace = true;
				}
			}
			else {
#if NET_2_0			   
				primary = ((selectionType & SelectionTypes.Primary) == SelectionTypes.Primary);
				add = ((selectionType & SelectionTypes.Add) == SelectionTypes.Add);
				remove = ((selectionType & SelectionTypes.Remove) == SelectionTypes.Remove);
				toggle = ((selectionType & SelectionTypes.Toggle) == SelectionTypes.Toggle);
#else
				primary = ((selectionType & SelectionTypes.Click) == SelectionTypes.Click);
#endif				
				replace = ((selectionType & SelectionTypes.Replace) == SelectionTypes.Replace);
				
			}

			
			if (replace) {
				_selection.Clear ();
				add = true;
			}
						
			if (add) {
				foreach (object component in components) {
					if (component is IComponent && !_selection.Contains (component)) {
						_selection.Add (component);
						_primarySelection = (IComponent) component;
					}
				}
			}

			if (remove) {
				foreach (object component in components) {
					if (component is IComponent && _selection.Contains (component)) {
						_selection.Remove (component);
						if (component == _primarySelection)
							_primarySelection = this.RootComponent;
					}
				}
			}

			if (toggle) {
				foreach (object component in components) {
					if (component is IComponent) {
						if (_selection.Contains (component)) {
							_selection.Remove (component);
							if (component == _primarySelection)
								_primarySelection = this.RootComponent;
						}
						else {
							_selection.Add (component);
							_primarySelection = (IComponent) component;
						}
					}
				}
			}
				
			if (primary) {
				object primarySelection = null;

				foreach (object component in components) {
					primarySelection = component;
					break;
				}

				if (!this.GetComponentSelected (primarySelection))
					_selection.Add (_primarySelection);

				_primarySelection = (IComponent) primarySelection;
			}				
						
			OnSelectionChanged ();
		}
Exemple #39
0
 public void SetSelectedComponents(ICollection components, SelectionTypes selectionType)
 {
     throw new NotSupportedException();
 }
Exemple #40
0
        /// Select the given components with the given SelectionType.
        void ISelectionService.SetSelectedComponents(ICollection components, SelectionTypes selectionType)
        {
            bool fToggle  = false;
            bool fControl = false;
            bool fClick   = false;
            bool fChanged = false;  // did we actually change something?

            // Catch a null input list
            if (components == null)
            {
                components = new Component[0];
            }

            if ((selectionType & SelectionTypes.Normal) == SelectionTypes.Normal ||
                (selectionType & SelectionTypes.Click) == SelectionTypes.Click)
            {
                fControl = ((Control.ModifierKeys & Keys.Control) == Keys.Control);

                // Only toggle when we are affecting a single control, and
                // when we are handling the "mouse" state events (i.e. up/down
                // used to show/hide the selection).
                //
                fToggle = ((Control.ModifierKeys & Keys.Control) != 0 || (Control.ModifierKeys & Keys.Shift) != 0) &&
                          components.Count == 1 &&
                          (selectionType & SelectionTypes.MouseUp) != SelectionTypes.MouseUp;
            }

            if ((selectionType & SelectionTypes.Click) == SelectionTypes.Click)
            {
                fClick = true;
            }


            // If we are replacing the selection, only remove the ones that are not in our new list.
            // We also handle the special case here of having a singular component selected that's
            // already selected.  In this case we just move it to the primary selection.
            //
            if (!fToggle && !fControl)
            {
                object firstSelection = null;
                foreach (object o in components)
                {
                    firstSelection = o;
                    break;
                }

                if (fClick && 1 == components.Count && ((ISelectionService)this).GetComponentSelected(firstSelection))
                {
                    SampleSelectionItem oldPrimary = primarySelection;
                    SetPrimarySelection((SampleSelectionItem)selectionsByComponent[firstSelection]);
                    if (oldPrimary != primarySelection)
                    {
                        fChanged = true;
                    }
                }
                else
                {
                    SampleSelectionItem[] selections = new SampleSelectionItem[selectionsByComponent.Values.Count];
                    selectionsByComponent.Values.CopyTo(selections, 0);

                    // Even with several hundred components this should be fairly fast
                    foreach (SampleSelectionItem item in selections)
                    {
                        bool remove = true;

                        foreach (object comp in components)
                        {
                            if (comp == item.Component)
                            {
                                remove = false;
                                break;
                            }
                        }

                        if (remove)
                        {
                            RemoveSelection(item);
                            fChanged = true;
                        }
                    }
                }
            }

            SampleSelectionItem primarySel = null;
            int selectedCount = selectionsByComponent.Count;

            // Now do the selection.
            foreach (Component comp in components)
            {
                if (comp != null)
                {
                    SampleSelectionItem s = (SampleSelectionItem)selectionsByComponent[comp];

                    if (null == s)
                    {
                        s = new SampleSelectionItem(this, comp);
                        AddSelection(s);

                        if (fControl || fToggle)
                        {
                            primarySel = s;
                        }

                        fChanged = true;
                    }
                    else
                    {
                        if (fToggle)
                        {
                            // Remove the selection from our list.
                            RemoveSelection(s);
                            fChanged = true;
                        }
                    }
                }
            }

            if (primarySel != null)
            {
                SetPrimarySelection(primarySel);
            }

            // Now notify that our selection has changed
            if (fChanged)
            {
                OnSelectionChanged();
            }
        }
		public void SetSelectedComponents(ICollection<DesignItem> components, SelectionTypes selectionType)
		{
			if (components == null)
				components = SharedInstances.EmptyDesignItemArray;
			
			if (components.Contains(null))
				throw new ArgumentException("Cannot select 'null'.");

			var prevSelectedItems = _selectedComponents.ToArray();
			
			if (SelectionChanging != null)
				SelectionChanging(this, EventArgs.Empty);
			
			DesignItem newPrimarySelection = _primarySelection;
			
			if (selectionType == SelectionTypes.Auto) {
				if (Keyboard.Modifiers == ModifierKeys.Control)
					selectionType = SelectionTypes.Toggle; // Ctrl pressed: toggle selection
				else if ((Keyboard.Modifiers & ~ModifierKeys.Control) == ModifierKeys.Shift)
					selectionType = SelectionTypes.Add; // Shift or Ctrl+Shift pressed: add to selection
				else
					selectionType = SelectionTypes.Primary; // otherwise: change primary selection
			}
			
			if ((selectionType & SelectionTypes.Primary) == SelectionTypes.Primary) {
				// change primary selection to first new component
				newPrimarySelection = null;
				foreach (DesignItem obj in components) {
					newPrimarySelection = obj;
					break;
				}
				
				selectionType &= ~SelectionTypes.Primary;
				if (selectionType == 0) {
					// if selectionType was only Primary, and components has only one item that
					// changes the primary selection was changed to an already-selected item,
					// then we keep the current selection.
					// otherwise, we replace it
                    if (components.Count == 1 && IsComponentSelected(newPrimarySelection) && prevSelectedItems.Length == 1){
						// keep selectionType = 0 -> don't change the selection
					} else {
						selectionType = SelectionTypes.Replace;
					}
				}
			}
			
			HashSet<DesignItem> componentsToNotifyOfSelectionChange = new HashSet<DesignItem>();
			switch (selectionType) {
				case SelectionTypes.Add:
					// add to selection and notify if required
					foreach (DesignItem obj in components) {
						if (_selectedComponents.Add(obj))
							componentsToNotifyOfSelectionChange.Add(obj);
					}
					break;
				case SelectionTypes.Remove:
					// remove from selection and notify if required
					foreach (DesignItem obj in components) {
						if (_selectedComponents.Remove(obj))
							componentsToNotifyOfSelectionChange.Add(obj);
					}
					break;
				case SelectionTypes.Replace:
					// notify all old components:
					componentsToNotifyOfSelectionChange.AddRange(_selectedComponents);
					// set _selectedCompontents to new components
					_selectedComponents.Clear();
					foreach (DesignItem obj in components) {
						_selectedComponents.Add(obj);
						// notify the new components
						componentsToNotifyOfSelectionChange.Add(obj);
					}
					break;
				case SelectionTypes.Toggle:
					// toggle selection and notify
					foreach (DesignItem obj in components) {
						if (_selectedComponents.Contains(obj)) {
							_selectedComponents.Remove(obj);
						} else {
							_selectedComponents.Add(obj);
						}
						componentsToNotifyOfSelectionChange.Add(obj);
					}
					break;
				case 0:
					// do nothing
					break;
				default:
					throw new NotSupportedException("The selection type " + selectionType + " is not supported");
			}
			
			if (!IsComponentSelected(newPrimarySelection)) {
				// primary selection is not selected anymore - change primary selection to any other selected component
				newPrimarySelection = null;
				foreach (DesignItem obj in _selectedComponents) {
					newPrimarySelection = obj;
					break;
				}
			}
			
			// Primary selection has changed:
			if (newPrimarySelection != _primarySelection) {
				componentsToNotifyOfSelectionChange.Add(_primarySelection);
				componentsToNotifyOfSelectionChange.Add(newPrimarySelection);
				if (PrimarySelectionChanging != null) {
					PrimarySelectionChanging(this, EventArgs.Empty);
				}
				_primarySelection = newPrimarySelection;
				if (PrimarySelectionChanged != null) {
					PrimarySelectionChanged(this, EventArgs.Empty);
				}
				RaisePropertyChanged("PrimarySelection");
			}

			if (!_selectedComponents.SequenceEqual(prevSelectedItems)) {
				if (SelectionChanged != null) {
					SelectionChanged(this, new DesignItemCollectionEventArgs(componentsToNotifyOfSelectionChange));
				}
				RaisePropertyChanged("SelectedItems");
			}
		}
 public void SetSelectedComponents(ICollection components, SelectionTypes selectionType)
 {
     // fire changing event
     if (SelectionChanging != null)
     {
         try
         {
             SelectionChanging(this, EventArgs.Empty);
         }
         catch{}
     }
     // dont allow an empty collection
     if (components == null || components.Count == 0)
     {
         components = new ArrayList();
     }
     bool ctrlDown=false,shiftDown=false;
     // we need to know if shift or ctrl is down on clicks
     if ((selectionType & SelectionTypes.Click) == SelectionTypes.Click)
     {
         ctrlDown = ((Control.ModifierKeys & Keys.Control) == Keys.Control);
         shiftDown = ((Control.ModifierKeys & Keys.Shift)   == Keys.Shift);
     }
     if (selectionType == SelectionTypes.Replace)
     {
         // discard the hold list and go with this one
         selectedComponents = new ArrayList(components);
     }
     else
     {
         if (!shiftDown && !ctrlDown && components.Count == 1 && !selectedComponents.Contains(components))
         {
             selectedComponents.Clear();
         }
         // something was either added to the selection
         // or removed
         IEnumerator ie = components.GetEnumerator();
         while(ie.MoveNext())
         {
             IComponent comp = ie.Current as IComponent;
             if(comp!=null)
             {
                 if (ctrlDown || shiftDown)
                 {
                     if (selectedComponents.Contains(comp))
                     {
                         selectedComponents.Remove(comp);
                     }
                     else
                     {
                         // put it back into the front because it was
                         // the last one selected
                         selectedComponents.Insert(0,comp);
                     }
                 }
                 else
                 {
                     if (!selectedComponents.Contains(comp))
                     {
                         selectedComponents.Add(comp);
                     }
                     else
                     {
                         selectedComponents.Remove(comp);
                         selectedComponents.Insert(0,comp);
                     }
                 }
             }
         }
     }
     // fire changed event
     if (SelectionChanged != null)
     {
         try
         {
             SelectionChanged(this, EventArgs.Empty);
         }
         catch{}
     }
 }
Exemple #43
0
 private void UnClickHandler(SelectionTypes button)
 {
     unSelect(button);
 }
		public void SetSelectedComponents(System.Collections.ICollection components, SelectionTypes selectionType)
		{
			//TODO: Use .NET 2.0 SelectionTypes Primary, Add, Replace, Remove, Toggle
			if ((selectionType & SelectionTypes.Valid) == SelectionTypes.Valid)
				SetSelectedComponents(components);
		}