예제 #1
0
        public bool Update(INonPlayableCreatureObject creature, Point position)
        {
            if (creature.Statuses.Contains(ParalyzedObjectStatus.StatusType))
            {
                return(true);
            }

            var visibleArea            = VisibilityHelper.GetVisibleArea(creature.VisibilityRange, position);
            var relativeTargetPosition = GetNearestTargetPosition(visibleArea);

            if (relativeTargetPosition == null)
            {
                return(true);
            }

            var absoluteTargetPosition = new Point(
                position.X - creature.VisibilityRange + relativeTargetPosition.X,
                position.Y - creature.VisibilityRange + relativeTargetPosition.Y);
            var adjustedTargetDirection = Point.GetAdjustedPointRelativeDirection(position, absoluteTargetPosition);

            if (adjustedTargetDirection.HasValue)
            {
                AttackTarget(creature, position, absoluteTargetPosition, adjustedTargetDirection.Value);
                return(true);
            }

            TryMoveToTarget(creature, position, absoluteTargetPosition);
            return(true);
        }
        private static void OnPlaceHolderControlChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var comboBox = sender as ComboBox;

            if (comboBox != null)
            {
                var control = e.NewValue as FrameworkElement;

                var disposables = new CompositeDisposable();

                var selectionChanged = Observable.FromEvent <SelectionChangedEventHandler, SelectionChangedEventArgs>
                                           (h => (s, ea) => h(ea),
                                           h => comboBox.SelectionChanged += h,
                                           h => comboBox.SelectionChanged -= h);

                selectionChanged
                .Select(x => x.AddedItems.Count <= 0 || string.IsNullOrWhiteSpace(x.AddedItems[0].ToString()))
                .Subscribe(x =>
                {
                    control.Visibility = VisibilityHelper.Set(x);
                })
                .AddTo(disposables);

                comboBox.UnloadedAsObservable()
                .Subscribe(_ => disposables?.Dispose())
                .AddTo(disposables);

                control.Visibility = VisibilityHelper.Set(string.IsNullOrWhiteSpace(comboBox.SelectionBoxItem.ToString()));
            }
        }
예제 #3
0
        public static CodeItem MapMethod(MethodDeclarationSyntax member, CodeViewUserControl control, SemanticModel semanticModel)
        {
            if (member == null)
            {
                return(null);
            }

            CodeItem item;

            var statementsCodeItems = StatementMapper.MapStatement(member.Body, control, semanticModel);

            if (VisibilityHelper.ShouldBeVisible(CodeItemKindEnum.Switch) && statementsCodeItems.Any())
            {
                // Map method as item containing statements
                item = BaseMapper.MapBase <CodeClassItem>(member, member.Identifier, member.Modifiers, control, semanticModel);
                ((CodeClassItem)item).Members.AddRange(statementsCodeItems);
                ((CodeClassItem)item).BorderBrush = ColorHelper.ToBrush(Colors.DarkGray);
            }
            else
            {
                // Map method as single item
                item = BaseMapper.MapBase <CodeFunctionItem>(member, member.Identifier, member.Modifiers, control, semanticModel);
                ((CodeFunctionItem)item).Type       = TypeMapper.Map(member.ReturnType);
                ((CodeFunctionItem)item).Parameters = ParameterMapper.MapParameters(member.ParameterList);
                item.Tooltip = TooltipMapper.Map(item.Access, ((CodeFunctionItem)item).Type, item.Name, member.ParameterList);
            }

            item.Id      = IdMapper.MapId(item.FullName, member.ParameterList);
            item.Kind    = CodeItemKindEnum.Method;
            item.Moniker = IconMapper.MapMoniker(item.Kind, item.Access);

            return(item);
        }
예제 #4
0
        private void BackgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            try
            {
                var result = e.Result as BackgroundWorkerResult;

                if (result?.CodeItems == null)
                {
                    LogHelper.Log($"CodeNav for '{DocumentHelper.GetName(_window)}' updated, no results");
                    return;
                }

                // Filter all null items from the code document
                SyntaxMapper.FilterNullItems(result.CodeItems);

                // Do we need to update the DataContext?
                var areEqual = AreDocumentsEqual(CodeDocumentViewModel.CodeDocument, result.CodeItems);
                if (result.ForceUpdate == false && areEqual)
                {
                    LogHelper.Log($"CodeNav for '{DocumentHelper.GetName(_window)}' updated, document did not change");

                    // Should the margin be shown and are there any items to show, if not hide the margin
                    VisibilityHelper.SetMarginWidth(_column, CodeDocumentViewModel.CodeDocument);

                    return;
                }

                // Set the new list of codeitems as DataContext
                CodeDocumentViewModel.CodeDocument = result.CodeItems;
                _cache = result.CodeItems;

                // Set currently active codeitem
                HighlightHelper.SetForeground(CodeDocumentViewModel.CodeDocument);

                // Should the margin be shown and are there any items to show, if not hide the margin
                VisibilityHelper.SetMarginWidth(_column, CodeDocumentViewModel.CodeDocument);

                // Apply current visibility settings to the document
                VisibilityHelper.SetCodeItemVisibility(CodeDocumentViewModel.CodeDocument);

                // Sync all regions
                OutliningHelper.SyncAllRegions(OutliningManager, TextView, CodeDocumentViewModel.CodeDocument);

                // Sort items
                CodeDocumentViewModel.SortOrder = Settings.Default.SortOrder;
                SortHelper.Sort(CodeDocumentViewModel);

                // Apply bookmarks
                LoadBookmarksFromStorage();
                BookmarkHelper.ApplyBookmarks(CodeDocumentViewModel, Dte?.Solution?.FileName);

                LogHelper.Log($"CodeNav for '{DocumentHelper.GetName(_window)}' updated");
            }
            catch (ObjectDisposedException ex)
            {
                LogHelper.Log($"CodeNav: RunWorkerCompleted exception: {ex.Message}");
                LogHelper.Log("RunWorkerCompleted exception", ex);
            }
        }
        private void RefreshVisibility()
        {
            var isGroup = this.Source?.IsGroup ?? false;
            var isOpen  = !this.IsMainClosed;

            this.FileCommonVisibility = VisibilityHelper.Set(!isGroup);
            this.FileMainVisibility   = VisibilityHelper.Set(!isGroup && isOpen);
            this.GroupVisibility      = VisibilityHelper.Set(isGroup);
            this.CommonMainVisibility = VisibilityHelper.Set(isGroup || isOpen);
        }
예제 #6
0
        private async void mikanImportButton_Loaded(object sender, RoutedEventArgs e)
        {
            if (!conpatButtonLoaded)
            {
                conpatButtonLoaded = true;
                var convertable = await this.Core.IsOldConvertableAsync();

                this.mikanImportButton.Visibility = VisibilityHelper.Set(convertable);
            }
        }
예제 #7
0
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            var num = value as int?;

            if (num == null)
            {
                return(Visibility.Collapsed);
            }
            return(VisibilityHelper.Set(num.Value == 0));
        }
예제 #8
0
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            var isInverse = this.IsInverse(parameter);

            if (value == null)
            {
                return(isInverse ? Visibility.Visible : Visibility.Collapsed);
            }

            var b = (bool)value;

            return(VisibilityHelper.FromValue(b, isInverse));
        }
        private static void OnIsExifEnabledChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            var thisInstance = d as FileInformationPage;
            var value        = e.NewValue as bool?;

            if (thisInstance != null && value.HasValue)
            {
                thisInstance.expandButtonGrid.Visibility = VisibilityHelper.Set(value.Value);
                if (!value.Value)
                {
                    thisInstance.IsMainClosed = false;
                }
            }
        }
예제 #10
0
        public KeyBindPageViewModel()
        {
            var core = ((App)Application.Current).Core;

            this.CursorKeyBind = core
                                 .ToReactivePropertyAsSynchronized(x => x.CursorKeyBind).AddTo(this.Disposables);

            this.CursorKeyToFlipVisibility = this.CursorKeyBind
                                             .Select(x => VisibilityHelper.Set(x != 1))
                                             .ToReactiveProperty().AddTo(this.Disposables);

            this.CursorKeyToMoveVisibility = this.CursorKeyBind
                                             .Select(x => VisibilityHelper.Set(x == 1))
                                             .ToReactiveProperty().AddTo(this.Disposables);
        }
        private static void OnPlaceHolderControlChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var textBox = sender as TextBox;

            if (textBox != null)
            {
                var control = e.NewValue as FrameworkElement;

                SubscribeEvents(textBox, x =>
                {
                    control.Visibility = VisibilityHelper.Set(x);
                });

                control.Visibility = VisibilityHelper.Set(string.IsNullOrEmpty(textBox.Text));
            }
        }
예제 #12
0
        public static CodeNamespaceItem MapNamespace(NamespaceDeclarationSyntax member,
                                                     ICodeViewUserControl control, SemanticModel semanticModel, SyntaxTree tree)
        {
            if (member == null)
            {
                return(null);
            }

            var item = BaseMapper.MapBase <CodeNamespaceItem>(member, member.Name, control, semanticModel);

            item.Kind             = CodeItemKindEnum.Namespace;
            item.Moniker          = IconMapper.MapMoniker(item.Kind, item.Access);
            item.BorderColor      = Colors.DarkGray;
            item.IgnoreVisibility = VisibilityHelper.GetIgnoreVisibility(item);

            if (TriviaSummaryMapper.HasSummary(member) && SettingsHelper.UseXMLComments)
            {
                item.Tooltip = TriviaSummaryMapper.Map(member);
            }

            var regions = RegionMapper.MapRegions(tree, member.Span, control);

            foreach (var namespaceMember in member.Members)
            {
                var memberItem = SyntaxMapper.MapMember(namespaceMember);
                if (memberItem != null && !RegionMapper.AddToRegion(regions, memberItem))
                {
                    item.Members.Add(memberItem);
                }
            }

            // Add regions to namespace if they are not present in any children of the namespace
            if (regions.Any())
            {
                foreach (var region in regions)
                {
                    if (FindHelper.FindCodeItem(item.Members, region.Id) == null)
                    {
                        item.Members.Add(region);
                    }
                }
            }

            return(item);
        }
예제 #13
0
        public static CodeItem MapMethod(VisualBasicSyntax.MethodBlockSyntax member, ICodeViewUserControl control, SemanticModel semanticModel)
        {
            if (member == null)
            {
                return(null);
            }

            CodeItem item;

            var statementsCodeItems = StatementMapper.MapStatement(member.Statements, control, semanticModel);

            if (VisibilityHelper.ShouldBeVisible(CodeItemKindEnum.Switch) && statementsCodeItems.Any())
            {
                // Map method as item containing statements
                item = BaseMapper.MapBase <CodeClassItem>(member, member.SubOrFunctionStatement.Identifier,
                                                          member.SubOrFunctionStatement.Modifiers, control, semanticModel);
                ((CodeClassItem)item).Members.AddRange(statementsCodeItems);
                ((CodeClassItem)item).BorderColor = Colors.DarkGray;
            }
            else
            {
                // Map method as single item
                item = BaseMapper.MapBase <CodeFunctionItem>(member, member.SubOrFunctionStatement.Identifier,
                                                             member.SubOrFunctionStatement.Modifiers, control, semanticModel);

                var symbol = SymbolHelper.GetSymbol <IMethodSymbol>(semanticModel, member);
                ((CodeFunctionItem)item).Type       = TypeMapper.Map(symbol?.ReturnType);
                ((CodeFunctionItem)item).Parameters = ParameterMapper.MapParameters(member.SubOrFunctionStatement.ParameterList, semanticModel);
                item.Tooltip = TooltipMapper.Map(item.Access, ((CodeFunctionItem)item).Type, item.Name,
                                                 member.SubOrFunctionStatement.ParameterList, semanticModel);
            }

            item.Id      = IdMapper.MapId(item.FullName, member.SubOrFunctionStatement.ParameterList, semanticModel);
            item.Kind    = CodeItemKindEnum.Method;
            item.Moniker = IconMapper.MapMoniker(item.Kind, item.Access);

            if (TriviaSummaryMapper.HasSummary(member) && SettingsHelper.UseXMLComments)
            {
                item.Tooltip = TriviaSummaryMapper.Map(member);
            }

            return(item);
        }
예제 #14
0
        private void TextBoxBase_OnTextChanged(object sender, TextChangedEventArgs e)
        {
            var dataContext = DataContext as CodeDocumentViewModel;

            if (dataContext == null)
            {
                LogHelper.Log("Datacontext error while filtering items by name");
                return;
            }

            try
            {
                VisibilityHelper.SetCodeItemVisibility(dataContext.CodeDocument, FilterTextBox.Text);
            }
            catch (Exception exception)
            {
                LogHelper.Log($"Error filtering items: {exception}");
            }
        }
예제 #15
0
        internal override bool IsMatching(MethodDefinition methodDefinition)
        {
            if (base.IsMatching(methodDefinition))
            {
                var declaringType         = methodDefinition.DeclaringType;
                var typeVisibility        = VisibilityHelper.GetTypeVisibilityLevel(declaringType);
                var methodVisibilityLevel = VisibilityHelper.GetMethodVisibilityLevel(methodDefinition);

                //check type visibility
                if ((int)typeVisibility > (int)_targetClass)
                {
                    return(false);
                }

                //then method visibility will decide
                return((int)methodVisibilityLevel <= (int)_targetMethod);
            }
            return(false);
        }
예제 #16
0
        public static bool GetIfPointIsVisible(Point position, int viewDistance, Point checkPoint)
        {
            if (!GetIfPointInVisibilityRange(position, viewDistance, checkPoint))
            {
                return(false);
            }

            var visibleArea = VisibilityHelper.GetVisibleArea(viewDistance, position);
            var relativeX   = checkPoint.X - position.X + viewDistance;
            var relativeY   = checkPoint.Y - position.Y + viewDistance;

            var checkCell = visibleArea.GetCell(relativeX, relativeY);

            if (checkCell == null)
            {
                return(false);
            }

            return(true);
        }
예제 #17
0
        public object Convert(object value, Type targetType, object parameter, string language)
        {
            bool b;

            if (value == null)
            {
                b = false;
            }
            else
            {
                b = (bool)value;
            }
            var inverse    = parameter != null && parameter.ToString().Equals("i", StringComparison.OrdinalIgnoreCase);
            var visibility = b ? Visibility.Visible : Visibility.Collapsed;

            if (!inverse)
            {
                return(visibility);
            }
            return(VisibilityHelper.InverseVisibility(visibility));
        }
예제 #18
0
        private void ButtonFilter_OnClick(object sender, RoutedEventArgs e)
        {
            new FilterWindow().ShowDialog();

            var dataContext = DataContext as CodeDocumentViewModel;

            if (dataContext == null)
            {
                LogHelper.Log("Datacontext error while filtering items by kind");
                return;
            }

            try
            {
                VisibilityHelper.SetCodeItemVisibility(dataContext.CodeDocument);
            }
            catch (Exception exception)
            {
                LogHelper.Log($"Error filtering items: {exception}");
            }
        }
예제 #19
0
        private void TextBoxBase_OnTextChanged(object sender, TextChangedEventArgs e)
        {
            var dataContext = DataContext as CodeDocumentViewModel;

            if (dataContext == null)
            {
                // Datacontext error while filtering items by name
                return;
            }

            dataContext.FilterText = FilterTextBox.Text;

            try
            {
                VisibilityHelper.SetCodeItemVisibility(dataContext);
            }
            catch (Exception)
            {
                // Error filtering items
            }
        }
예제 #20
0
        private void BackgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            var result = e.Result as BackgroundWorkerResult;

            if (result?.CodeItems == null)
            {
                LogHelper.Log($"CodeNav for '{_window.Document.Name}' updated, no results");
                return;
            }

            // Filter all null items from the code document
            SyntaxMapper.FilterNullItems(result.CodeItems);

            // Do we need to update the DataContext?
            var areEqual = AreDocumentsEqual(CodeDocumentViewModel.CodeDocument, result.CodeItems);

            if (result.ForceUpdate == false && areEqual)
            {
                LogHelper.Log($"CodeNav for '{_window.Document.Name}' updated, document did not change");
                return;
            }

            // Set the new list of codeitems as DataContext
            CodeDocumentViewModel.CodeDocument = result.CodeItems;
            _cache = result.CodeItems;

            // Set currently active codeitem
            HighlightHelper.SetForeground(CodeDocumentViewModel.CodeDocument);

            // Are there any items to show, if not hide the margin
            VisibilityHelper.SetMarginWidth(_column, CodeDocumentViewModel.CodeDocument);

            // Apply current visibility settings to the document
            VisibilityHelper.SetCodeItemVisibility(CodeDocumentViewModel.CodeDocument);

            // Sync all regions
            OutliningHelper.SyncAllRegions(_outliningManager, _textView, CodeDocumentViewModel.CodeDocument);

            LogHelper.Log($"CodeNav for '{_window.Document.Name}' updated");
        }
예제 #21
0
        private static CodeItem MapMethod(MethodDeclarationSyntax member)
        {
            if (member == null)
            {
                return(null);
            }

            CodeItem item;

            var statements = new List <CodeItem>();

            if (member.Body?.Statements != null)
            {
                foreach (var statement in member.Body?.Statements)
                {
                    statements.Add(StatementMapper.MapStatement(statement, _control, _semanticModel));
                }
                FilterNullItems(statements);
            }

            if (VisibilityHelper.ShouldBeVisible(CodeItemKindEnum.Switch) && statements != null && statements.Any())
            {
                item = BaseMapper.MapBase <CodeClassItem>(member, member.Identifier, member.Modifiers, _control, _semanticModel);
                ((CodeClassItem)item).Members.AddRange(statements);
                ((CodeClassItem)item).BorderBrush = ColorHelper.CreateSolidColorBrush(Colors.DarkGray);
            }
            else
            {
                item = BaseMapper.MapBase <CodeFunctionItem>(member, member.Identifier, member.Modifiers, _control, _semanticModel);
                ((CodeFunctionItem)item).Type       = TypeMapper.Map(member.ReturnType);
                ((CodeFunctionItem)item).Parameters = MapParameters(member.ParameterList);
                item.Tooltip = TooltipMapper.Map(item.Access, ((CodeFunctionItem)item).Type, item.Name, member.ParameterList);
            }

            item.Id      = MapId(item.FullName, member.ParameterList);
            item.Kind    = CodeItemKindEnum.Method;
            item.Moniker = IconMapper.MapMoniker(item.Kind, item.Access);

            return(item);
        }
예제 #22
0
        private static void OnIsOpenChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            var thisInstance = d as PopupDialog;
            var value        = e.NewValue as bool?;

            if (thisInstance != null && value.HasValue)
            {
                thisInstance.rootGrid.Visibility = VisibilityHelper.Set(value.Value);
                if (!value.Value)
                {
                    var content = thisInstance.mainContent.Content as FrameworkElement;

                    thisInstance.DialogContent = null;
                    //thisInstance.mainContent.Content = null;

                    if (content != null)
                    {
                        content.IsEnabled = false;
                    }

                    thisInstance.ClosedCommand?.Execute(thisInstance);
                }
            }
        }
예제 #23
0
        public void EmptyItemsShouldRespectSetting(bool hideItemsWithoutChildren, Visibility expectedVisibility)
        {
            var document = new CodeDocumentViewModel
            {
                CodeDocument = SyntaxMapper.MapDocument(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "..\\..\\Files\\TestVisibility.cs"))
            };

            SettingsHelper.FilterRules = new List <FilterRule>
            {
                new FilterRule
                {
                    Access      = CodeItemAccessEnum.All,
                    Kind        = CodeItemKindEnum.Class,
                    Visible     = true,
                    HideIfEmpty = hideItemsWithoutChildren
                }
            };

            VisibilityHelper.SetCodeItemVisibility(document.CodeDocument);

            var firstClass = (document.CodeDocument.First() as IMembers).Members.First() as CodeClassItem;

            Assert.AreEqual(expectedVisibility, firstClass.IsVisible);
        }
예제 #24
0
 public void FilterBookmarks()
 => VisibilityHelper.SetCodeItemVisibility(CodeDocumentViewModel.CodeDocument,
                                           filterOnBookmarks: CodeDocumentViewModel.FilterOnBookmarks, bookmarks: CodeDocumentViewModel.Bookmarks);
예제 #25
0
    IEnumerator AICoroutine()
    {
        yield return(new WaitForSeconds(1));

        while (true)
        {
            if (VisibilityHelper.CheckVisibility(transform, _playerGameObject.transform, MaxVisibleDistance, _layerMask))
            {
                // player visible
                if (_toTargetObjectRotation != null && !_toTargetObjectRotation.enabled)
                {
                    // point to player
                    _toTargetObjectRotation.Target  = _playerGameObject.transform;
                    _toTargetObjectRotation.enabled = true;
                }
                if (_toMoveDirectionRotation != null && _toMoveDirectionRotation.enabled)
                {
                    _toMoveDirectionRotation.enabled = false;
                }

                // shoot if able
                if (!_isStaggered && Stats.HasEnough(StatsEnum.Bullets, 1) && !_gunCooldown)
                {
                    var q = Quaternion.LookRotation(Vector3.forward,
                                                    _playerGameObject.transform.position - transform.position);
                    FireBullet(q.eulerAngles.z);
                    Stats.AddAmount(StatsEnum.Bullets, -1);
                    StartCoroutine(WeaponCooldown(2));

                    yield return(null);
                }
                else
                {
                    // go to proper distance
                    var distance = (transform.position - _playerGameObject.transform.position).magnitude;
                    if (distance < TooCloseDistance && !_isAttacking)
                    {
                        // move back when close
                        var vector = -_playerGameObject.transform.position + transform.position;
                        MoveBackWards(vector);
                    }
                    else if (distance <= AttackDistance && !_isAttacking)
                    {
                        // attack when in attack range
                        Attack();
                    }
                    else
                    {
                        // move to target
                        var vector = _playerGameObject.transform.position - transform.position;
                        Move(vector);
                    }
                    yield return(null);
                }
            }
            else
            {
                if (_toTargetObjectRotation != null && _toTargetObjectRotation.enabled)
                {
                    _toTargetObjectRotation.enabled = false;
                }
                if (_toMoveDirectionRotation != null && !_toMoveDirectionRotation.enabled)
                {
                    _toMoveDirectionRotation.enabled = true;
                }

                // wander randomly
                float angle  = Random.Range(0, 16) * (float)Math.PI * 2f / 16;
                var   vector = Math2.AngleRadToVector(angle);
                Move(vector);

                yield return(new WaitForSeconds(Random.Range(1, 3)));
            }
        }
    }
        public async Task UpdateDocumentAsync(bool forceUpdate = false)
        {
            await Microsoft.VisualStudio.Shell.ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

            var activeDocument = DocumentHelper.GetActiveDocument(Dte);

            if (activeDocument == null)
            {
                return;
            }

            CodeDocumentViewModel.FilePath = activeDocument.FullName;

            // Do we need to change the side where the margin is displayed
            if (_margin?.MarginSide != null &&
                _margin?.MarginSide != Settings.Default.MarginSide &&
                Dte != null)
            {
                var filename = activeDocument.FullName;
                Dte.ExecuteCommand("File.Close");
                Dte.ExecuteCommand("File.OpenFile", filename);
            }

            try
            {
                if (forceUpdate)
                {
                    _cache = null;
                    CodeDocumentViewModel.CodeDocument.Clear();
                }

                // Do we have a cached version of this document
                if (_cache != null)
                {
                    CodeDocumentViewModel.CodeDocument = _cache;
                }

                // If not show a loading item
                if (!CodeDocumentViewModel.CodeDocument.Any())
                {
                    CodeDocumentViewModel.CodeDocument = CreateLoadingItem();
                }

                var codeItems = await SyntaxMapper.MapDocumentAsync(activeDocument, this, _workspace);

                if (codeItems == null)
                {
                    // CodeNav for document updated, no results
                    return;
                }

                // Filter all null items from the code document
                SyntaxMapper.FilterNullItems(codeItems);

                // Sort items
                CodeDocumentViewModel.SortOrder = Settings.Default.SortOrder;
                SortHelper.Sort(codeItems, Settings.Default.SortOrder);

                // Set currently active codeitem
                HighlightHelper.SetForeground(codeItems);

                // Set the new list of codeitems as DataContext
                CodeDocumentViewModel.CodeDocument = codeItems;
                _cache = codeItems;

                // Apply current visibility settings to the document
                VisibilityHelper.SetCodeItemVisibility(CodeDocumentViewModel);

                // Apply bookmarks
                LoadBookmarksFromStorage();
                BookmarkHelper.ApplyBookmarks(CodeDocumentViewModel, Dte?.Solution?.FileName);

                // Apply history items
                LoadHistoryItemsFromStorage();
                HistoryHelper.ApplyHistoryIndicator(CodeDocumentViewModel);
            }
            catch (Exception e)
            {
                LogHelper.Log("Error running UpdateDocument", e);
            }

            try
            {
                // Sync all regions
                OutliningHelper.SyncAllRegions(OutliningManagerService, TextView, CodeDocumentViewModel.CodeDocument);

                // Should the margin be shown and are there any items to show, if not hide the margin
                VisibilityHelper.SetMarginHeight(_row, CodeDocumentViewModel.CodeDocument);
            }
            catch (Exception e)
            {
                LogHelper.Log("Error finishing UpdateDocument", e);
            }
        }
 public void FilterBookmarks()
 => VisibilityHelper.SetCodeItemVisibility(CodeDocumentViewModel);
예제 #28
0
        public IEnumerable <Publication> GetLatestPublicationsForce(int count, int offset, IEnumerable <string> groups)
        {
            var visibility = (short)VisibilityHelper.VisibilityFromStrings(groups);

            return(DALPublication.GetLatestPublications(count, offset, visibility));
        }
        public ClientWindowViewModel()
        {
            var core    = ((App)Application.Current).Core;
            var library = core.Library;

            var client = new Client(new LibraryFront(library), core).AddTo(this.Disposables);

            this.Client = client;
            this.Core   = core;

            this.KeyReceiver = new KeyReceiver <object>().AddTo(this.Disposables);

            this.WindowTitle = client.SelectedPage
                               .CombineLatest(client.ViewerDisplaying, (Page, Item) => new { Page, Item })
                               .Select(x =>
            {
                var file = (x.Page == PageType.Viewer) ? x.Item?.FileName : null;
                return((file == null) ? core.AppName : (file + " - " + core.AppName));
            })
                               .ToReadOnlyReactiveProperty()
                               .AddTo(this.Disposables);

            this.SelectedInformationPage = new ReactiveProperty <OptionPaneType>
                                               (core.IsViewerPageLeftBarFixed ? OptionPaneType.ItemInfo : OptionPaneType.None)
                                           .AddTo(this.Disposables);

            this.IsPaneOpen = new ReactiveProperty <bool>(core.IsViewerPageLeftBarFixed)
                              .AddTo(this.Disposables);


            this.IsPaneFixed = core
                               .ToReactivePropertyAsSynchronized(x => x.IsViewerPageLeftBarFixed)
                               .AddTo(this.Disposables);

            this.SelectedTab = client.SelectedPage
                               .Select(x =>
            {
                switch (x)
                {
                case PageType.Search:
                    return(0);

                case PageType.Catalog:
                    return(1);

                case PageType.Viewer:
                    return(2);

                default:
                    return(0);
                }
            })
                               .ToReactiveProperty(0)
                               .AddTo(this.Disposables);


            this.SelectedTab.Subscribe(x =>
            {
                if (this.IsPaneOpen.Value)
                {
                    if (this.IsPaneFixed.Value)
                    {
                        this.ShowInformationPane();
                    }
                    else
                    {
                        this.IsPaneOpen.Value = false;
                    }
                }
            })
            .AddTo(this.Disposables);

            this.Client.FeaturedGroupChanged.Subscribe(x =>
            {
                if (client.SelectedPage.Value == PageType.Catalog && this.IsPaneOpen.Value)
                {
                    this.ShowInformationPane();
                }
            })
            .AddTo(this.Disposables);


            this.PaneSelectedPath = new ReactiveProperty <string>((string)null)
                                    .AddTo(this.Disposables);
            this.PaneSelectedPath.Where(x => !string.IsNullOrWhiteSpace(x))
            .Subscribe(x => this.StartPathOrTagSearch(FileProperty.DirectoryPathStartsWith, x))
            .AddTo(this.Disposables);

            this.PaneSelectedTag = new ReactiveProperty <TagInformation>((TagInformation)null)
                                   .AddTo(this.Disposables);
            this.PaneSelectedTag.Where(x => x != null)
            .Subscribe(x => this.StartPathOrTagSearch(FileProperty.ContainsTag, x.Id))
            .AddTo(this.Disposables);

            this.DefaultPaneMode = client.SelectedPage
                                   .Select(x => (x == PageType.Viewer) ? PaneMode.HideInClosing
                    : PaneMode.AlwaysVisible)
                                   .ToReactiveProperty(PaneMode.AlwaysVisible)
                                   .AddTo(this.Disposables);



            this.IsOptionPageOpen = this.SelectedInformationPage
                                    .Select(x => x > 0)
                                    .ToReactiveProperty()
                                    .AddTo(this.Disposables);


            //情報
            this.IsInformationPaneOpen = this.SelectedInformationPage
                                         .Select(x => this.IsInformationPane(x))
                                         .ToReactiveProperty(false)
                                         .AddTo(this.Disposables);

            this.OpenInformationPaneCommand = new ReactiveCommand()
                                              .WithSubscribe(_ =>
            {
                if (this.IsInformationPaneOpen.Value)
                {
                    if (this.prevPaneSelected == OptionPaneType.None)
                    {
                        this.prevPaneSelected = OptionPaneType.NoInformation;
                    }
                    this.ShowInformationPane(true);
                }
                else
                {
                    if (this.SelectedInformationPage.Value != OptionPaneType.Setting)
                    {
                        this.SelectedInformationPage.Value = OptionPaneType.None;
                    }
                }
            }, this.Disposables);



            //設定
            this.IsSettingPaneOpen = this.SelectedInformationPage
                                     .Select(x => x == OptionPaneType.Setting)
                                     .ToReactiveProperty(false)
                                     .AddTo(this.Disposables);

            this.OpenSettingPaneCommand = new ReactiveCommand()
                                          .WithSubscribe(_ =>
            {
                if (this.IsSettingPaneOpen.Value)
                {
                    this.SelectedInformationPage.Value = OptionPaneType.Setting;
                    this.IsPaneOpen.Value = true;
                }
                else
                {
                    if (this.SelectedInformationPage.Value == OptionPaneType.Setting)
                    {
                        this.SelectedInformationPage.Value = OptionPaneType.None;
                    }
                }
            }, this.Disposables);



            //ヘルプ
            this.IsHelpPaneOpen = this.SelectedInformationPage
                                  .Select(x => x == OptionPaneType.Help)
                                  .ToReactiveProperty(false)
                                  .AddTo(this.Disposables);

            this.OpenHelpPaneCommand = new ReactiveCommand()
                                       .WithSubscribe(_ =>
            {
                if (this.IsHelpPaneOpen.Value)
                {
                    this.SelectedInformationPage.Value = OptionPaneType.Help;
                    this.IsPaneOpen.Value = true;
                }
                else
                {
                    if (this.SelectedInformationPage.Value == OptionPaneType.Help)
                    {
                        this.SelectedInformationPage.Value = OptionPaneType.None;
                    }
                }
            }, this.Disposables);



            this.OptionPaneVisibility = this.SelectedInformationPage
                                        .Select(x => VisibilityHelper.Set(x > 0))
                                        .ToReactiveProperty()
                                        .AddTo(this.Disposables);

            this.FrameWidth = new ReactiveProperty <double>(300).AddTo(this.Disposables);

            this.IsFullScreen = client.SelectedPage.Select(_ => false).ToReactiveProperty().AddTo(this.Disposables);

            this.PageChangedSubject = new Subject <SplitViewDisplayMode>().AddTo(this.Disposables);

            this.PaneDisplayMode = this.IsPaneFixed
                                   .CombineLatest(this.DefaultPaneMode,
                                                  (paneFixed, defaultMode) =>
                                                  (defaultMode == PaneMode.Disabled) ? SplitViewDisplayMode.Overlay
                    : (paneFixed) ? SplitViewDisplayMode.CompactInline
                    : (defaultMode == PaneMode.HideInClosing) ? SplitViewDisplayMode.Overlay
                    : SplitViewDisplayMode.CompactOverlay)
                                   .ToReactiveProperty()
                                   .AddTo(this.Disposables);

            this.IsPaneOpen
            .Subscribe(x =>
            {
                if (!x)
                {
                    this.IsPaneFixed.Value             = false;
                    this.SelectedInformationPage.Value = OptionPaneType.None;
                    if (this.PaneDisplayMode.Value == SplitViewDisplayMode.CompactInline)
                    {
                        this.PaneDisplayMode.Value = SplitViewDisplayMode.CompactOverlay;
                    }
                }
            })
            .AddTo(this.Disposables);


            this.PaneOpenButtonVisibility = new ReactiveProperty <Visibility>(Visibility.Collapsed)
                                            .ToReactiveProperty()
                                            .AddTo(this.Disposables);

            var isWide = this.FrameWidth.Select(y => y > middleWindowWidth).Publish().RefCount();

            this.PaneFixButtonVisibility = isWide.Select(y => VisibilityHelper.Set(y))
                                           .ToReactiveProperty().AddTo(this.Disposables);
            isWide.Where(y => !y).Skip(2).Subscribe(y => this.IsPaneFixed.Value = false).AddTo(this.Disposables);

            this.JumpListWidth = this.IsOptionPageOpen.Select(x => x ? compactPaneWidth : openPaneWidth)
                                 .ToReactiveProperty().AddTo(this.Disposables);

            this.IsOptionPageOpen.Subscribe(x =>
            {
                if (x && this.SelectedInformationPage.Value != OptionPaneType.NoInformation &&
                    !core.IsAutoInformationPaneDisabled)
                {
                    this.IsPaneOpen.Value = true;
                }
            }).AddTo(this.Disposables);



            this.OpenSettingWindowCommand = new ReactiveCommand()
                                            .WithSubscribe(_ => ((App)Application.Current).ShowSettingWindow(-1), this.Disposables);

            this.OptionPageCommand = new ReactiveCommand <string>().AddTo(this.Disposables);



            this.IsPopupOpen = new ReactiveProperty <bool>(false).AddTo(this.Disposables);

            this.IsPopupOpen
            .Subscribe(x => this.KeyReceiver.Mode
                           = (int)(x ? KeyReceiverMode.PopupIsOpened : KeyReceiverMode.Normal))
            .AddTo(this.Disposables);



            this.prevPaneMode     = this.PaneDisplayMode.Value;
            this.prevPaneOpen     = this.IsPaneOpen.Value;
            this.prevPaneSelected = (OptionPaneType)this.SelectedInformationPage.Value;

            this.SelectedItems.ObserveProperty(x => x.Count).Pairwise().Subscribe(x =>
            {
                var autoOpen = !core.IsAutoInformationPaneDisabled;

                if (x.OldItem <= 0 && x.NewItem > 0)
                {
                    this.prevPaneMode     = this.PaneDisplayMode.Value;
                    this.prevPaneOpen     = this.IsPaneOpen.Value;
                    this.prevPaneSelected = (OptionPaneType)this.SelectedInformationPage.Value;

                    if (autoOpen && this.FrameWidth.Value > wideWindowWidth)
                    {
                        this.PaneDisplayMode.Value = SplitViewDisplayMode.CompactInline;
                        this.IsPaneOpen.Value      = true;
                    }

                    this.ShowInformationPane();
                }
                else if (x.OldItem > 0 && x.NewItem > 0 &&
                         (this.FrameWidth.Value > wideWindowWidth || this.IsPaneOpen.Value))
                {
                    this.ShowInformationPane();
                }
                else if (x.OldItem > 0 && x.NewItem <= 0)
                {
                    if (autoOpen)
                    {
                        this.PaneDisplayMode.Value = this.prevPaneMode;
                    }

                    this.ShowInformationPane();

                    if (autoOpen)
                    {
                        this.IsPaneOpen.Value = this.prevPaneOpen;
                    }
                }
            })
            .AddTo(this.Disposables);


            this.IsPaneFixed
            .Subscribe(x =>
            {
                if (x)
                {
                    this.prevPaneMode = SplitViewDisplayMode.CompactInline;
                    this.prevPaneOpen = true;
                }
                else
                {
                    this.prevPaneMode = SplitViewDisplayMode.CompactOverlay;
                    this.prevPaneOpen = false;
                }
            })
            .AddTo(this.Disposables);

            this.TagSelectorSortMode = core
                                       .ToReactivePropertyAsSynchronized(x => x.TagSelectorSortMode)
                                       .AddTo(this.Disposables);

            this.ExifVisibilityCheck = new ReactiveProperty <bool>(false).AddTo(this.Disposables);
            this.ExifVisibilityCheck
            .Skip(1)
            .Subscribe(x => core.Library.ExifManager.EnableAll(x)).AddTo(this.Disposables);

            this.IsExifEnabled = core.Library.ExifManager.HasVisibleItem
                                 .ToReadOnlyReactiveProperty().AddTo(this.Disposables);


            this.BackCommand = client.BackHistoryCount
                               .Select(x => x > 0)
                               .ToReactiveCommand()
                               .WithSubscribe(_ => client.Back(), this.Disposables);

            this.MoveToSearchPageCommand = new ReactiveCommand()
                                           .WithSubscribe(x => client.MoveToSearch(), this.Disposables);

            this.OpenPaneCommand = new ReactiveCommand()
                                   .WithSubscribe(_ => this.TogglePane(OptionPaneType.None), this.Disposables);

            // ウインドウへのファイルのドラッグ&ドロップ
            this.FileDropCommand = new ReactiveCommand()
                                   .WithSubscribe(obj =>
            {
                var files = obj as string[];
                if (files != null)
                {
                    this.Client.ActivateFiles(files);
                }
            }, this.Disposables);

            this.MouseExButtonSubject = new Subject <bool>().AddTo(this.Disposables);

            this.MouseExButtonLeftCommand = new ReactiveCommand()
                                            .WithSubscribe(_ =>
            {
                if (core.UseExtendedMouseButtonsToSwitchImage &&
                    client.SelectedPage.Value == PageType.Viewer)
                {
                    this.MouseExButtonSubject.OnNext(false);
                }
                else
                {
                    client.Back();
                }
            }, this.Disposables);

            this.MouseExButtonRightCommand = new ReactiveCommand()
                                             .WithSubscribe(_ =>
            {
                if (core.UseExtendedMouseButtonsToSwitchImage &&
                    client.SelectedPage.Value == PageType.Viewer)
                {
                    this.MouseExButtonSubject.OnNext(true);
                }
                else
                {
                    client.Forward();
                }
            }, this.Disposables);


            //Keyboard
            this.RegisterKeyReceiver(client);

            this.Catalog = new CatalogPageViewModel(this).AddTo(this.Disposables);
            this.Viewer  = new ViewerPageViewModel(this).AddTo(this.Disposables);
            this.Search  = new SearchPageViewModel(this).AddTo(this.Disposables);
        }
예제 #30
0
 private void Splitter_MouseDoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e)
 {
     VisibilityHelper.SetMarginWidth(_codeNavColumn, _codeNavColumn.Width != new GridLength(0));
     Settings.Default.ShowMargin = !Settings.Default.ShowMargin;
     Settings.Default.Save();
 }