Esempio n. 1
0
        public static NestedDialogResults <TViewModel> Show <TViewModel>(INestedViewModel <TViewModel> viewModel)
            where TViewModel : ViewModelBase
        {
            var dialog = (INestedViewDialog <TViewModel>)_dialogLookup[typeof(TViewModel)];

            return(dialog.Show(viewModel));
        }
Esempio n. 2
0
        public NestedDialogResults <PresetViewModel> Show(INestedViewModel <PresetViewModel> data)
        {
            DataContext = data.InnerItem;
            ShowDialog();

            var viewModel = (PresetViewModel)DataContext;

            return(new NestedDialogResults <PresetViewModel>(viewModel, DialogResult));
        }
Esempio n. 3
0
        public NestedDialogResults <RegionViewModel> Show(INestedViewModel <RegionViewModel> data)
        {
            DataContext = new RegionDialogViewModel((NestedViewModel <RegionViewModel>)data);

            ShowDialog();
            var viewModel = (RegionDialogViewModel)DataContext;

            return(new NestedDialogResults <RegionViewModel>(viewModel.InnerItem, DialogResult));
        }
Esempio n. 4
0
 public RegionDialogViewModel(INestedViewModel <RegionViewModel> viewModel) : base(viewModel.Title, viewModel.Message, viewModel.InnerItem, viewModel.MessageBoxButtons)
 {
     AvailableTypes = Enum.GetNames(typeof(RegionTypes));
 }
Esempio n. 5
0
        protected virtual bool HandleDragReceived(List <IViewModel> draggedViewModels, int x, int y, bool internalDrop)
        {
            IViewModel           destParentVM, destChildVM;
            TreePath             path;
            TreeViewDropPosition pos;
            TreeIter             iter;
            var elementsToRemove = new Dictionary <INestedViewModel, List <IViewModel> > ();
            var elementsToAdd    = new KeyValuePair <INestedViewModel, List <IViewModel> > ();

            if (GetDestRowAtPos(x, y, out path, out pos))
            {
                int destIndex;
                store.GetIter(out iter, path);
                FillParentAndChild(iter, out destParentVM, out destChildVM);
                store.GetIter(out iter, path);
                int [] Indices = store.GetPath(iter).Indices;
                if (pos == TreeViewDropPosition.Before ||
                    pos == TreeViewDropPosition.IntoOrBefore)
                {
                    destIndex = Indices [Indices.Length - 1];
                }
                else
                {
                    destIndex = Indices [Indices.Length - 1] + 1;
                }
                if (destChildVM == null)
                {
                    if (internalDrop)
                    {
                        elementsToRemove.Add(ViewModel as INestedViewModel, draggedViewModels.ToList());
                    }
                    elementsToAdd = new KeyValuePair <INestedViewModel, List <IViewModel> > (ViewModel as INestedViewModel, draggedViewModels);
                }
                else
                {
                    if (internalDrop)
                    {
                        TreeIter parent;
                        //Get the parentVM for every drag ViewModel
                        foreach (IViewModel vm in draggedViewModels)
                        {
                            foreach (TreeIter element in dictionaryStore[vm])
                            {
                                if (Model.IterParent(out parent, element))
                                {
                                    INestedViewModel sourceParentVM = Model.GetValue(parent, COL_DATA) as INestedViewModel;
                                    if (!elementsToRemove.ContainsKey(sourceParentVM))
                                    {
                                        elementsToRemove.Add(sourceParentVM, new List <IViewModel> ());
                                    }
                                    elementsToRemove [sourceParentVM].Add(vm);
                                }
                            }
                        }
                    }
                    elementsToAdd = new KeyValuePair <INestedViewModel, List <IViewModel> > (destParentVM as INestedViewModel, draggedViewModels);
                }
                return(MoveElements(elementsToRemove, elementsToAdd, destIndex));
            }
            return(false);
        }