/// <summary>
        /// Вызывает создание файла.
        /// </summary>
        public async void NewButtonClick()
        {
            if (IsDirty && FileName != _defaultFileName ||
                FileName == _defaultFileName && Items.Count > 0)
            {
                MessageDialogResult result = await Messages.SaveTheChangesAsync(FileName);

                switch (result)
                {
                case MessageDialogResult.Yes: await SaveButtonClick(); break;

                case MessageDialogResult.No: break;

                case MessageDialogResult.Cancel: return;
                }
            }

            Items.Clear();
            IsNewEnabled    = IsAddEnabled = IsEditVisible = IsDirty = false;
            FileName        = _defaultFileName;
            CurrentFile     = null;
            CurrentQuestion = CurrentAnswer = string.Empty;
            SelectedItem    = null;

            _state = ContentStates.NoData;
            OnPropertyChanged(nameof(State));
        }
Example #2
0
 public void SetStates(IWindowsFormsEditorService edSvc, ContentStates states)
 {
     m_edSvc     = edSvc;
     m_oldStates = states;
     if ((states & ContentStates.DockLeft) != 0)
     {
         checkBoxDockLeft.Checked = true;
     }
     if ((states & ContentStates.DockRight) != 0)
     {
         checkBoxDockRight.Checked = true;
     }
     if ((states & ContentStates.DockTop) != 0)
     {
         checkBoxDockTop.Checked = true;
     }
     if ((states & ContentStates.DockTop) != 0)
     {
         checkBoxDockTop.Checked = true;
     }
     if ((states & ContentStates.DockBottom) != 0)
     {
         checkBoxDockBottom.Checked = true;
     }
     if ((states & ContentStates.Document) != 0)
     {
         checkBoxDockFill.Checked = true;
     }
     if ((states & ContentStates.Float) != 0)
     {
         checkBoxFloat.Checked = true;
     }
 }
        public Content[] Select(ContentStates stateFilter)
        {
            int count = 0;

            foreach (Content c in this)
            {
                if (DockHelper.IsDockStateValid(c.DockState, stateFilter))
                {
                    count++;
                }
            }

            Content[] contents = new Content[count];

            count = 0;
            foreach (Content c in this)
            {
                if (DockHelper.IsDockStateValid(c.DockState, stateFilter))
                {
                    contents[count++] = c;
                }
            }

            return(contents);
        }
        /// <summary>
        /// Конструктор.
        /// </summary>
        public ListEditorViewModel()
        {
            FileName = _defaultFileName;
            Items    = new ObservableCollection <ListWordViewModel>();
            Items.CollectionChanged += Items_CollectionChanged;

            _state = ContentStates.NoData;
            OnPropertyChanged(nameof(State));

            IsEditVisible = false;

            DeleteCommand = new DelegateCommand <ushort>((ushort id) =>
            {
                if (SelectedItem != null && id == ((ListWordViewModel)SelectedItem).ID)
                {
                    CurrentQuestion = CurrentAnswer = string.Empty;
                }

                Items.RemoveAt(id - 1);

                IsNewEnabled = (IsDirty && FileName != _defaultFileName || FileName == _defaultFileName && Items.Count > 0);

                if (Items.Count == 0)
                {
                    _state = ContentStates.NoData;
                    OnPropertyChanged(nameof(State));
                }
                else
                {
                    UpdateElementsID();
                }
            });
        }
        public async Task <OpenApiResult> GetWorkflowStateHistory(
            string tenantId,
            string workflowId,
            string stateName,
            string slug,
            int?limit,
            string continuationToken,
            string embed)
        {
            IContentStore contentStore = await this.contentStoreFactory.GetContentStoreForTenantAsync(tenantId).ConfigureAwait(false);

            ContentStates result = await contentStore.GetContentStatesForWorkflowAsync(slug, workflowId, stateName, limit ?? 20, continuationToken).ConfigureAwait(false);

            var mappingContext = new ContentStatesResponseMappingContext {
                TenantId = tenantId
            };

            if (embed == Constants.LinkRelations.ContentSummary)
            {
                mappingContext.ContentSummaries = await contentStore.GetContentSummariesForStatesAsync(result.States).ConfigureAwait(false);
            }

            HalDocument resultDocument = this.contentStatesMapper.Map(result, mappingContext);

            return(this.OkResult(resultDocument));
        }
Example #6
0
        /// <summary>
        /// 设置内容状态
        /// </summary>
        /// <param name="content"></param>
        /// <param name="state"></param>
        public void SetContentState(ContentItem content, ContentStates state)
        {
            if (content == null)
            {
                return;
            }

            content.State = state;
            lock (this.LockSeed)
                this.TargetDBContext.SaveChangesAsync();
        }
        public async Task WhenIGetThePublishedStateHistoryAndCorrespondingContentSummariesForSlugAndCallIt(string slug, int limit, string continuationToken, string name)
        {
            IContentStore store  = ContentManagementCosmosContainerBindings.GetContentStore(this.featureContext);
            ContentStates states = await store.GetPublishedHistory(
                SpecHelpers.ParseSpecValue <string>(this.scenarioContext, slug),
                limit,
                SpecHelpers.ParseSpecValue <string>(this.scenarioContext, continuationToken)).ConfigureAwait(false);

            List <ContentSummary> summaries = await store.GetContentSummariesForStatesAsync(states.States).ConfigureAwait(false);

            this.scenarioContext.Set((states, summaries), name);
        }
        private void Edit()
        {
            Items.Insert(((ListWordViewModel)SelectedItem).ID, new ListWordViewModel(new ListWordModel
            {
                ID       = ((ListWordViewModel)SelectedItem).ID,
                Question = CurrentQuestion,
                Answer   = CurrentAnswer
            }));
            Items.RemoveAt(((ListWordViewModel)SelectedItem).ID - 1);

            _state = ContentStates.Normal;

            CurrentQuestion = CurrentAnswer = string.Empty;
            IsAddEnabled    = IsEditVisible = false;
            IsNewEnabled    = true;
            SelectedItem    = null;
        }
        public async Task WhenIGetThePublicationHistoryForSlugWithLimitAndContinuationTokenAndCallItAsync(string slug, int limit, string continuationTokenSource, string contentSummariesName)
        {
            IContentStore store = ContentManagementCosmosContainerBindings.GetContentStore(this.featureContext);

            string continuationToken = continuationTokenSource == null
                ? null
                : this.scenarioContext.Get <(ContentStates States, List <ContentSummary> Summaries)>(continuationTokenSource).States.ContinuationToken;

            ContentStates states = await store.GetPublicationHistory(
                SpecHelpers.ParseSpecValue <string>(this.scenarioContext, slug),
                limit,
                continuationToken).ConfigureAwait(false);

            List <ContentSummary> summaries = await store.GetContentSummariesForStatesAsync(states.States).ConfigureAwait(false);

            this.scenarioContext.Set((states, summaries), contentSummariesName);
        }
        /// <summary>
        /// Общий метод для всех способов открытия файла.
        /// </summary>
        /// <param name="file">Файл, который требуется открыть.</param>
        public async void OpenListFile(StorageFile file)
        {
            List <ListWordModel> data = new List <ListWordModel>();

            try
            {
                data = new XmlService().ReadList(await FileIO.ReadTextAsync(file));
                if (data == null)
                {
                    return;
                }
            }
            catch (Exception ex)
            {
                Messages.OpenFileError(ex.Message);
                return;
            }

            CurrentQuestion = CurrentAnswer = string.Empty;
            IsAddEnabled    = IsEditVisible = false;
            IsNewEnabled    = true;
            SelectedItem    = null;

            FileName = file.DisplayName;

            _state = data?.Count > 0 ? ContentStates.Normal : ContentStates.NoData;
            OnPropertyChanged(nameof(State));

            CurrentFile = file;
            new AppHelper().AddFileToMRU(CurrentFile);

            ObservableCollection <ListWordViewModel> readed
                = new ObservableCollection <ListWordViewModel>(data?.Select(e => new ListWordViewModel(e)));

            Items.Clear();
            foreach (ListWordViewModel item in readed)
            {
                Items.Add(item);
            }

            IsDirty = false;
        }
Example #11
0
 public static bool IsDockStateValid(DockState dockState, ContentStates allowedStates)
 {
     if (((allowedStates & ContentStates.Float) == 0) &&
         (dockState == DockState.Float))
     {
         return(false);
     }
     else if (((allowedStates & ContentStates.Document) == 0) &&
              (dockState == DockState.Document))
     {
         return(false);
     }
     else if (((allowedStates & ContentStates.DockLeft) == 0) &&
              (dockState == DockState.DockLeft || dockState == DockState.DockLeftAutoHide))
     {
         return(false);
     }
     else if (((allowedStates & ContentStates.DockRight) == 0) &&
              (dockState == DockState.DockRight || dockState == DockState.DockRightAutoHide))
     {
         return(false);
     }
     else if (((allowedStates & ContentStates.DockTop) == 0) &&
              (dockState == DockState.DockTop || dockState == DockState.DockTopAutoHide))
     {
         return(false);
     }
     else if (((allowedStates & ContentStates.DockBottom) == 0) &&
              (dockState == DockState.DockBottom || dockState == DockState.DockBottomAutoHide))
     {
         return(false);
     }
     else
     {
         return(true);
     }
 }
        /// <summary>
        /// Вызывает добавление.
        /// </summary>
        public void AddButtonClick()
        {
            Items.Add(new ListWordViewModel(new ListWordModel
            {
                ID       = (ushort)(Items.Count + 1),
                Question = CurrentQuestion,
                Answer   = CurrentAnswer
            }));

            _state = ContentStates.Normal;

            CurrentQuestion = CurrentAnswer = string.Empty;
            IsAddEnabled    = false;
            IsNewEnabled    = true;

            if (Locator.NavigationHelper.CurrentFrame.CurrentSourcePageType == typeof(AddListWordView))
            {
                Locator.NavigationHelper.CurrentFrame.GoBack();
            }
            else
            {
                OnPropertyChanged(nameof(State));
            }
        }