Пример #1
0
        private void refreshPresetsListViewsGroups()
        {
            if (src != null)
            {
                using (src.DeferRefresh())
                {
                    src.GroupDescriptions.Clear();
                }
            }
            if (src != null)
            {
                using (src.DeferRefresh())
                {
                    src.GroupDescriptions.Add(groupByType);
                }
            }

            if (factoryPresetsListBox != null)
            {
                factoryPresetsListBox.GroupStyle.Clear();
                factoryPresetsListBox.GroupStyle.Add(new GroupStyle()
                {
                    ContainerStyle = (Style)this.FindResource("PresetsGroupStyle")
                });
            }
        }
Пример #2
0
        /// <summary>
        /// Initializes data model before UI's shown.
        /// </summary>
        /// <param name="argument">Optional argument.</param>
        public override void OnInitialize(object argument)
        {
            _log.LogMessage(this.Feature, "Initializing...");

            var model        = _solutionProcessor.GetProjects(ProcessorFlags.IncludeFiles | ProcessorFlags.GroupLinkedFiles);
            var files        = model.Files;
            var solutionName = model.SolutionName;

            files = ApplyOptions(files);

            this.SolutionName = _optionsService.GetStringOption(this.Feature, "Solution", this.SolutionName);
            _search           = _optionsService.GetStringOption(this.Feature, "Search", _search);
            _allFiles         = _optionsService.GetBoolOption(this.Feature, "AllFiles", _allFiles);

            // Reset search on new solution
            if (!string.IsNullOrEmpty(this.SolutionName) && !string.IsNullOrEmpty(solutionName) && !solutionName.Equals(this.SolutionName, StringComparison.OrdinalIgnoreCase))
            {
                _search = string.Empty;
            }
            this.SolutionName = solutionName;

            _sourceFiles.Clear();
            _sourceFiles.AddRange(files);             // causes filter to be evaluated

            using (_files.DeferRefresh())             // defers filter evaluation until end of using
            {
                _files.Filter += OnFilter;

                OnSearch();
            }

            _log.LogMessage(this.Feature, "Initialized");
        }
Пример #3
0
        private void refreshSuperSessionSource()
        {
            if (_src == null)
            {
                return;
            }

            using (_src.DeferRefresh())
            {
                _src.SortDescriptions.Clear();
            }
            using (_src.DeferRefresh())
            {
                _src.SortDescriptions.Add(_sortByDate);
            }
        }
Пример #4
0
 /// <summary>
 /// 根据选择的列名排序Tests
 /// </summary>
 /// <param name="byStatus">根据Status排序</param>
 private void SortTests(bool?byStatus)
 {
     Mouse.OverrideCursor = Cursors.Wait;
     try
     {
         var icp = this.FindChild <ItemsControl>(this.uC4Log, "ICP");
         foreach (var pvm in icp.Items)
         {
             var container             = icp.ItemContainerGenerator.ContainerFromItem(pvm);
             var exp                   = this.FindChild <Expander>(container, "exp");
             CollectionViewSource cvsT =
                 (CollectionViewSource)(exp.FindResource("cvsT"));
             using (cvsT.DeferRefresh())
             {
                 cvsT.SortDescriptions.Clear();
                 if (byStatus ?? false)
                 {
                     cvsT.SortDescriptions.Add(new SortDescription("Status", ListSortDirection.Ascending));
                     cvsT.SortDescriptions.Add(new SortDescription("Date", ListSortDirection.Ascending));
                 }
                 else
                 {
                     cvsT.SortDescriptions.Add(new SortDescription("Date", ListSortDirection.Ascending));
                 }
             }
         }
     }
     finally
     {
         Mouse.OverrideCursor = null;
     }
 }
Пример #5
0
        public void GroupsAreRecreated()
        {
            Func <object, object, bool>             nameMatcher = (groupName, itemName) => (string)groupName == (string)itemName;
            Func <object, int, CultureInfo, object> nameCreator = (item, level, culture) => ((int)item <= 2 ? "Lower" : "Upper") + level.ToString();

            var desc = new ConcretePropertyGroupDescription()
            {
                GroupNameFromItemFunc = nameCreator,
                NamesMatchFunc        = nameMatcher
            };

            var source = new CollectionViewSource {
                Source = new [] { 0, 1, 2, 3, 4, 5 }
            };

            source.GroupDescriptions.Add(desc);

            var groups     = source.View.Groups;
            var lowerGroup = (CollectionViewGroup)source.View.Groups [0];
            var upperGroup = (CollectionViewGroup)source.View.Groups [1];


            using (source.DeferRefresh())
                using (source.View.DeferRefresh()) {
                    source.GroupDescriptions.Clear();
                    source.GroupDescriptions.Add(desc);
                }

            Assert.AreSame(groups, source.View.Groups, "#1");
            Assert.AreNotSame(lowerGroup, source.View.Groups [0], "#2");
            Assert.AreNotSame(upperGroup, source.View.Groups [1], "#3");
        }
Пример #6
0
        /// <summary>
        /// Initializes data model before UI's shown.
        /// </summary>
        /// <param name="argument">Optional argument.</param>
        public override void OnInitialize(object argument)
        {
            _log.LogMessage(this.Feature, "Initializing...");

            if (!(argument is CodeModelFilterFlags))
            {
                throw new ArgumentException("Invalid initialization argument", nameof(argument));
            }

            this.FileName = _optionsService.GetStringOption(this.Feature, "File", this.FileName);
            _search       = _optionsService.GetStringOption(this.Feature, "Search", _search);
            this.Filter   = (CodeModelFilterFlags)argument;
            var filter = (CodeModelFilterFlags)_optionsService.GetIntOption(this.Feature, "Filter", (int)this.Filter);

            if (filter != this.Filter)
            {
                _search = string.Empty;
            }

            ApplyMembers();

            using (_members.DeferRefresh())             // defers filter evaluation until end of using
            {
                _members.Filter += OnFilter;

                OnSearch();
            }

            _log.LogMessage(this.Feature, "Initialized");
        }
        public void Sort()
        {
            DispatcherHelper.CheckBeginInvokeOnUI(() =>
            {
                using (_cvs.DeferRefresh())
                {
                    _cvs.SortDescriptions.Clear();

                    switch (this.SortOrder)
                    {
                    case SortOrder.DateAdded:
                        _cvs.SortDescriptions.Add(new SortDescription("DateAdded", ListSortDirection.Descending));
                        break;

                    case SortOrder.Album:
                        _cvs.SortDescriptions.Add(new SortDescription("Left.Title", ListSortDirection.Ascending));
                        break;

                    case SortOrder.Artist:
                        _cvs.SortDescriptions.Add(new SortDescription("Left.Artist", ListSortDirection.Ascending));
                        break;

                    case SortOrder.LinkStatus:
                        _cvs.SortDescriptions.Add(new SortDescription("LinkStatus", ListSortDirection.Ascending));
                        break;

                    case SortOrder.NotSorted:
                        break;

                    default:
                        throw new ArgumentOutOfRangeException();
                    }
                }
            });
        }
Пример #8
0
        private void btnSortGroups_Click(object sender, RoutedEventArgs e)
        {
            m_sortdir = m_sortdir == ListSortDirection.Ascending ? ListSortDirection.Descending : ListSortDirection.Ascending;
            using (groupsViewSource.DeferRefresh())
            {
                groupsViewSource.SortDescriptions.Clear();
                SortDescription sd = new SortDescription("desc", m_sortdir);
                groupsViewSource.SortDescriptions.Add(sd);
            }

            btnSortGroups.Content = "Сортировать " + (m_sortdir == ListSortDirection.Ascending ? "(asc)" : "(desc)");
        }
Пример #9
0
        public void SendSmsWorker()
        {
            try
            {
                if (currentItem >= grdClients.Items.Count)
                {
                    btnStopQueue.IsEnabled = false;
                    continueSending        = false;
                    btnStopQueue.Content   = res.ResourceManager.GetString("Complete");

                    string message = "Total SMS " + grdClients.Items.Count + Environment.NewLine + "Complete: " +
                                     (grdClients.Items.Count - smsErros) + Environment.NewLine + "Erori: " + smsErros;
                    ShowVRAlertBox(message);
                    return;
                }
                //send sms
                PropertyBag["history"] = grdClients.Items[currentItem];
                IDictionary prop = NavigatorFactory.Navigator.Get("Main", "TrySendSMS", PropertyBag);
                if (prop.Contains("flash"))
                {
                    Flash flash = (Flash)prop["flash"];
                    ShowVRAlertBox(flash.Error);
                }
                ((SmsHistory)grdClients.Items[currentItem]).Status = ((SmsHistory)prop["history"]).Status;

                if (((SmsHistory)prop["history"]).HasError)
                {
                    smsErros++;
                }

                grdClients.Items.Refresh();
                source.DeferRefresh();
                //increment current
                currentItem++;

                Thread.Sleep(100);
            }
            catch (Exception e)
            {
                RoLog.Instance.WriteToLog(e.ToString(), TracedAttribute.ERROR);
            }
            if (continueSending)
            {
                btnStopQueue.Dispatcher.BeginInvoke(DispatcherPriority.ApplicationIdle, new SendSmsDelegate(SendSmsWorker));
            }

//            for (int i = 0; i <= 5000; i++)
//            {
//                Console.WriteLine("Begin filter");
//                Thread.Sleep(5);
//            }
        }
        private void refreshRoisViewGroups()
        {
            if (_src != null)
            {
                using (_src.DeferRefresh())
                {
                    _src.GroupDescriptions.Clear();
                    _src.SortDescriptions.Clear();
                }
                using (_src.DeferRefresh())
                {
                    _src.GroupDescriptions.Add(_groupByRoiLayerName);
                    _src.SortDescriptions.Add(_sortByRoiLayerName);
                }
            }

            if (roiLayersItemsControl != null)
            {
                roiLayersItemsControl.GroupStyle.Clear();
                roiLayersItemsControl.GroupStyle.Add(_roiLayerNameGroupStyle);
            }
        }
        /// <summary>
        /// Applies the groupings.
        /// </summary>
        /// <param name="viewSource">The view source.</param>
        /// <param name="groupings">The groupings.</param>
        public static void ApplyGroupings(CollectionViewSource viewSource, IEnumerable <GroupDescription> groupings)
        {
            if (!FrameworkDispatcherUtility.HasCurrentWindowsApplication())
            {
                return;
            }
            viewSource.CheckViewSource();

            using (viewSource.DeferRefresh())
            {
                if (viewSource.GroupDescriptions.Any())
                {
                    viewSource.GroupDescriptions.Clear();
                }
                groupings.ForEachInEnumerable(i => viewSource.GroupDescriptions.Add(i));
            }
        }
 /// <summary>
 /// Re-fills data source based on AppointmentCollection content.
 /// </summary>
 private void RefreshData()
 {
     if (_table == null)
     {
         return;
     }
     using (_source.DeferRefresh())
     {
         _refreshing = true;
         _table.Rows.Clear();
         foreach (var app in Scheduler.DataStorage.AppointmentStorage.Appointments)
         {
             AddDataRow(app);
         }
         _refreshing = false;
     }
     _source.View.Refresh();
 }
Пример #13
0
        /// <summary>
        /// Initializes data model before UI's shown.
        /// </summary>
        /// <param name="argument">Optional argument.</param>
        public override void OnInitialize(object argument)
        {
            _log.LogMessage(this.Feature, "Initializing...");

            var files = _solutionProcessor.GetProjects(ProcessorFlags.IncludeFiles | ProcessorFlags.GroupLinkedFiles).Files;

            files = ApplyOptions(files);

            _search   = _optionsService.GetStringOption(this.Feature, "Search", _search);
            _allFiles = _optionsService.GetBoolOption(this.Feature, "AllFiles", _allFiles);

            _sourceFiles.Clear();
            _sourceFiles.AddRange(files);             // causes filter to be evaluated

            using (_files.DeferRefresh())             // defers filter evaluation until end of using
            {
                _files.Filter += OnFilter;

                OnSearch();
            }

            _log.LogMessage(this.Feature, "Initialized");
        }
        private CollectionViewSource LuaCreateSource(object collection)
        {
            var collectionArgs = collection as LuaTable;

            if (collectionArgs != null)
            {
                collection = collectionArgs.GetMemberValue("Source");
            }

            if (collection == null)
            {
                throw new ArgumentNullException(nameof(collection));
            }

            // get containted list
            if (collection is IListSource listSource)
            {
                collection = listSource.GetList();
            }

            // function views
            if (!(collection is IEnumerable) && Lua.RtInvokeable(collection))
            {
                collection = new LuaFunctionEnumerator(collection);
            }

            var collectionViewSource = new CollectionViewSource();

            using (collectionViewSource.DeferRefresh())
            {
                collectionViewSource.Source = collection;

                if (collectionArgs != null)
                {
                    if (collectionArgs.GetMemberValue(nameof(CollectionView.SortDescriptions)) is LuaTable t)
                    {
                        foreach (var col in t.ArrayList.OfType <string>())
                        {
                            if (String.IsNullOrEmpty(col))
                            {
                                continue;
                            }

                            string            propertyName;
                            ListSortDirection direction;

                            if (col[0] == '+')
                            {
                                propertyName = col.Substring(1);
                                direction    = ListSortDirection.Ascending;
                            }
                            else if (col[0] == '-')
                            {
                                propertyName = col.Substring(1);
                                direction    = ListSortDirection.Descending;
                            }
                            else
                            {
                                propertyName = col;
                                direction    = ListSortDirection.Ascending;
                            }

                            collectionViewSource.SortDescriptions.Add(new SortDescription(propertyName, direction));
                        }
                    }

                    // todo: beist sich mit CanFilter
                    var viewFilter = collectionArgs.GetMemberValue("ViewFilter");
                    if (Lua.RtInvokeable(viewFilter))
                    {
                        collectionViewSource.Filter += (sender, e) => e.Accepted = Procs.ChangeType <bool>(new LuaResult(Lua.RtInvoke(viewFilter, e.Item)));
                    }
                }
            }


            if (collectionViewSource.View == null)
            {
                throw new ArgumentNullException("Could not create a collection view.");
            }

            return(collectionViewSource);
        }         // func LuaCreateSource
        }         // proc LoadInternAsync

        private void InitializeData()
        {
            // create the views on the undo manager
            undoView = new CollectionViewSource();
            using (undoView.DeferRefresh())
            {
                undoView.Source = data.UndoManager;
                undoView.SortDescriptions.Add(new SortDescription(nameof(IPpsUndoStep.Index), ListSortDirection.Descending));
                undoView.Filter += (sender, e) => e.Accepted = ((IPpsUndoStep)e.Item).Type == PpsUndoStepType.Undo;
            }

            redoView = new CollectionViewSource();
            using (redoView.DeferRefresh())
            {
                redoView.Source = data.UndoManager;
                redoView.SortDescriptions.Add(new SortDescription(nameof(IPpsUndoStep.Index), ListSortDirection.Ascending));
                redoView.Filter += (sender, e) => e.Accepted = ((IPpsUndoStep)e.Item).Type == PpsUndoStepType.Redo;
            }

            //// Extent command bar
            //if (PaneControl?.Commands != null)
            //{
            //	UndoManagerListBox listBox;

            //	var undoCommand = new PpsUISplitCommandButton()
            //	{
            //		Order = new PpsCommandOrder(200, 130),
            //		DisplayText = "Rückgängig",
            //		Description = "Rückgängig",
            //		Image = "undo",
            //		Command = new PpsCommand(
            //			(args) =>
            //			{
            //				UpdateSources();
            //				UndoManager.Undo();
            //			},
            //			(args) => UndoManager?.CanUndo ?? false
            //		),
            //		Popup = new System.Windows.Controls.Primitives.Popup()
            //		{
            //			Child = listBox = new UndoManagerListBox()
            //			{
            //				Style = (Style)App.Current.FindResource("UndoManagerListBoxStyle")
            //			}
            //		}
            //	};

            //	listBox.SetBinding(FrameworkElement.DataContextProperty, new Binding("DataContext.UndoView"));

            //	var redoCommand = new PpsUISplitCommandButton()
            //	{
            //		Order = new PpsCommandOrder(200, 140),
            //		DisplayText = "Wiederholen",
            //		Description = "Wiederholen",
            //		Image = "redo",
            //		Command = new PpsCommand(
            //			(args) =>
            //			{
            //				UpdateSources();
            //				UndoManager.Redo();
            //			},
            //			(args) => UndoManager?.CanRedo ?? false
            //		),
            //		Popup = new System.Windows.Controls.Primitives.Popup()
            //		{
            //			Child = listBox = new UndoManagerListBox()
            //			{
            //				IsRedoList = true,
            //				Style = (Style)App.Current.FindResource("UndoManagerListBoxStyle")
            //			}
            //		}
            //	};

            //	listBox.SetBinding(FrameworkElement.DataContextProperty, new Binding("DataContext.RedoView"));

            //	PaneControl.Commands.Add(undoCommand);
            //	PaneControl.Commands.Add(redoCommand);
            //}

            HelpKey = obj.Typ + ".Edit";

            OnPropertyChanged(nameof(UndoManager));
            OnPropertyChanged(nameof(UndoView));
            OnPropertyChanged(nameof(RedoView));
            OnPropertyChanged(nameof(Data));
            OnPropertyChanged(nameof(CurrentData));
            OnPropertyChanged(nameof(HelpKey));
            OnDataChanged();
        }         // proc InitializeData
Пример #16
0
        public void ImportClient()
        {
            string[] strings = lines[currentLine].Split(new[] { ',' }, StringSplitOptions.None);
            Client   c       = new Client();

            if (strings.Length > 0)
            {
                c.Name = strings[0];
            }
            if (strings.Length > 1)
            {
                c.Phone = strings[1];
            }
            if (strings.Length > 2)
            {
                string network = "Unknow";
                if (strings[2].ToLower() == "o")
                {
                    network = "Orange";
                }
                if (strings[2].ToLower() == "v")
                {
                    network = "Vodafone";
                }
                if (strings[2].ToLower() == "c")
                {
                    network = "Cosmote";
                }
                c.Network = network;
            }
            if (strings.Length > 3)
            {
                c.Email = strings[3];
            }
            try
            {
                c.Save();
                imported++;
            }
            catch (ActiveRecordValidationException exception)
            {
                string message = "";
                foreach (string s in exception.ValidationErrorMessages)
                {
                    message += s + Environment.NewLine;
                }
                c.Message = message;
                RoLog.Instance.WriteToLog(exception.ToString(), TracedAttribute.ERROR);
            }
            finally
            {
                list.Add(c);
                grdClients.Items.Refresh();
                source.DeferRefresh();
                currentLine++;
                txtStatus.Text = "Line " + currentLine + "/" + lines.Count;
            }
            if (currentLine >= lines.Count)
            {
                ShowVRAlertBox("Import ready" + Environment.NewLine + "Imported " + imported + " from " + lines.Count);
                return;
            }

            btnFileBrowse.Dispatcher.BeginInvoke(DispatcherPriority.ApplicationIdle,
                                                 new ImportClientsDelegate(ImportClient));
        }
Пример #17
0
        public DocumentsPageModel()
        {
            ModelUrl = "/documents";

            ApplicationModel.Current.Server.Value.RawUrl = null;
            SelectedCollectionSortingMode = new Observable <string> {
                Value = Settings.Instance.CollectionSortingMode
            };

            collectionSource         = new CollectionDocumentsCollectionSource();
            collectionDocumentsModel = new DocumentsModel(collectionSource)
            {
                DocumentNavigatorFactory = (id, index) =>
                                           DocumentNavigator.Create(id, index, CollectionsIndex,
                                                                    new IndexQuery
                {
                    Query = "Tag:" + GetSelectedCollectionName()
                })
            };
            collectionDocumentsModel.SetChangesObservable(d => d.IndexChanges
                                                          .Where(n => n.Name.Equals(CollectionsIndex, StringComparison.InvariantCulture))
                                                          .Select(m => Unit.Default));

            allDocumentsDocumentsModel = new DocumentsModel(new DocumentsCollectionSource())
            {
                DocumentNavigatorFactory = (id, index) => DocumentNavigator.Create(id, index),
                Context = "AllDocuments",
            };

            allDocumentsDocumentsModel.SetChangesObservable(d => d.DocumentChanges.Select(s => Unit.Default));

            ravenDocumentsDocumentsModel = new DocumentsModel(new CollectionDocumentsCollectionSource());

            ravenDocumentsDocumentsModel.SetChangesObservable(d => d.DocumentChanges.Select(s => Unit.Default));

            Collections = new BindableCollection <CollectionModel>(model => model.Name)
            {
                new AllDocumentsCollectionModel(),
                new RavenDocumentsCollectionModel()
            };

            SelectedCollection = new Observable <CollectionModel>();
            SelectedCollection.PropertyChanged += (sender, args) =>
            {
                PutCollectionNameInTheUrl();

                var selectedCollectionName = GetSelectedCollectionName();
                if (selectedCollectionName == "")
                {
                    DocumentsModel = allDocumentsDocumentsModel;
                }
                else if (selectedCollectionName == "Raven Documents")
                {
                    DocumentsModel = ravenDocumentsDocumentsModel;
                }
                else
                {
                    collectionSource.CollectionName  = selectedCollectionName;
                    collectionDocumentsModel.Context = "Collection/" + GetSelectedCollectionName();
                    DocumentsModel = collectionDocumentsModel;
                }
            };

            SortedCollectionsList = new CollectionViewSource
            {
                Source           = Collections,
                SortDescriptions =
                {
                    GetSortDescription()
                }
            };

            SelectedCollectionSortingMode.PropertyChanged += (sender, args) =>
            {
                using (SortedCollectionsList.DeferRefresh())
                {
                    SortedCollectionsList.SortDescriptions.Clear();
                    SortedCollectionsList.SortDescriptions.Add(GetSortDescription());
                }

                Settings.Instance.CollectionSortingMode = SelectedCollectionSortingMode.Value;
            };

            CollectionsListWidth = DefaultCollectionsListWidth;
        }