public void OnQueryDocumentActions(IDocumentActionsArgs args)
 {
     args.DocumentActions.Add(new DocumentAction(DoAction1)
     {
         Caption = "Action 1"
     });
     args.DocumentActions.Add(new DocumentAction(CanDoAction2, DoAction2)
     {
         Caption = "Action 2"
     });
 }
 public void OnQueryDocumentActions(IDocumentActionsArgs args)
 {
     args.DocumentActions.Add(new DocumentCheckAction(() => viewModel.Flag, OnToggle)
     {
         Caption = "Flag"
     });
     args.DocumentActions.Add(new DocumentCheckAction(() => viewModel.IsSpecificState, OnCheck, OnUncheck)
     {
         Caption = "Specific State"
     });
 }
 public void OnQueryDocumentActions(IDocumentActionsArgs args)
 {
     args.DocumentActions.Add(new DocumentCheckAction(() => !_isEditingMode, ToggleEditingMode) { Caption = "Новый", Image = Resources.glyphicons_432_plus });
     args.DocumentActions.Add(new DocumentAction(New)                { Caption = "Открыть файл", Image = Resources.glyphicons_144_folder_open });
     args.DocumentActions.Add(new DocumentAction(CanSave, Save)      { Caption = "Сохранить", Image = Resources.glyphicons_206_ok_2 });
     args.DocumentActions.Add(new DocumentAction(CanRemove, Remove)  { Caption = "Удалить", Image = Resources.glyphicons_207_remove_2 });
 }
 public void OnQueryDocumentActions(IDocumentActionsArgs args)
 {
     args.DocumentActions.Add(new DocumentAction(New) { Caption = "Новый", Image = Resources.glyphicons_432_plus });
     args.DocumentActions.Add(new DocumentAction(Save) { Caption = "Сохранить", Image = Resources.glyphicons_206_ok_2 });
     args.DocumentActions.Add(new DocumentAction(CanRemove, Remove) { Caption = "Удалить", Image = Resources.glyphicons_207_remove_2 });
 }
        public async void OnQueryDocumentActions(IDocumentActionsArgs args)
        {
            var btnPrint = new WindowsUIButton
            {
                Caption = "Печать",
                Image = Resources.glyph_print,
                Tag = "Print"
            };
            btnPrint.Click += (s, e) => Print();

            var btnSave = new WindowsUIButton
            {
                Caption = "Отправить",
                Image = Resources.glyphicons_359_file_export,
                Tag = "Save"
            };
            btnSave.Click += (s, e) => Save(args.Document);

            var btnCheck = new WindowsUIButton
            {
                Caption = "Проверить",
                Image = Resources.glyphicons_029_notes_2,
                Tag = "Check"
            };
            btnCheck.Click += (s, e) => Check(args.Document);

            var btnSaveToFile = new WindowsUIButton
            {
                Caption = "Сохранить в файл",
                Image = Resources.glyphicons_358_file_import,
                Tag = "SaveLocal"
            };
            btnSaveToFile.Click += (s, e) => SaveLocal();

            var btnOpen = new WindowsUIButton
            {
                Caption = "Открыть файл",
                Image = Resources.glyphicons_144_folder_open,
                Tag = "Open"
            };
            btnOpen.Click += (s, e) => OpenFile(args.Document);
            
            this.windowsUIButtonPanelActions.Buttons.Clear();
            var isArchive = args.Document.ControlName.Contains("Archive");
            this.layoutControlItem1.ContentVisible = !isArchive;
            this.layoutControlItem2.ContentVisible = !isArchive;
            if (!isArchive)
            {
                var formTypeIdMatch = new Regex(@"\w+(?<num>\d+)").Match(args.Document.ControlName);
                var formTypeId = formTypeIdMatch.Success
                    ? new int?(int.Parse(formTypeIdMatch.Groups["num"].Value))
                    : null;
                var formType = formTypeId.HasValue ? (FormType)formTypeId : FormType.None;
                var isCreateUploadButtons =
                    (Authentication.Credentials.IsMunicipality && formType.IsMunicipalityForm()) ||
                    (Authentication.Credentials.IsEdu && formType.IsEduForm()) || Authentication.Credentials.IsRegion || 
                    args.Document.ControlName == "UploadSheetFromTemplate" ||
                    args.Document.ControlName == "UploadSheetFromFile";
                
                if (isCreateUploadButtons)
                {
                    if (this.Source == FormSource.File)
                        this.windowsUIButtonPanelActions.Buttons.Add(btnOpen);
                    this.windowsUIButtonPanelActions.Buttons.Add(btnSave);
                    
                    if (Authentication.Credentials.IsMunicipality || Authentication.Credentials.IsRegion)
                    {
                        var btnPeekFormMunicipality = new WindowsUIButton
                        {
                            Caption = "Автозаполнение МО",
                            Image = Resources.three_dots_24x24,
                            ToolTip = "Автозаполнение сводной формы",
                            Tag = "AutoLoadMunicipality"
                        };
                        btnPeekFormMunicipality.Click += (s, e) =>
                        {
                            this.windowsUIButtonPanelActions.ShowPeekForm((IBaseButton)s);
                        };
                        this.windowsUIButtonPanelActions.Buttons.Add(btnPeekFormMunicipality);

                        if (Authentication.Credentials.IsRegion)
                        {
                            var btnPeekFormRegion = new WindowsUIButton
                            {
                                Caption = "Автозаполнение Регион",
                                Image = Resources.three_dots_24x24,
                                ToolTip = "Автозаполнение сводной формы",
                                Tag = "AutoLoadRegion"
                            };
                            btnPeekFormRegion.Click += (s, e) =>
                            {
                                this.windowsUIButtonPanelActions.ShowPeekForm((IBaseButton) s);
                            };
                            this.windowsUIButtonPanelActions.Buttons.Add(btnPeekFormRegion);
                            if (Mode != ControlMode.New && await Repo.HasYesteryearFormData(FormData) && ActiveForm.check_data_file_id != null)
                            {
                                var btnAlignData = new WindowsUIButton
                                {
                                    Caption = "Выверка",
                                    ToolTip = "Сверить данные с формой прошлого года",
                                    Tag = "AlignData"
                                };
                                btnAlignData.Click += (s, e) =>
                                {
                                    AlignData(args.Document);
                                };
                                this.windowsUIButtonPanelActions.Buttons.Add(btnAlignData);
                            }
                        }

                        this.windowsUIButtonPanelActions.QueryPeekFormContent += (s, e) =>
                        {
                            XtraUserControl formulaPeekControl = null;
                            if (((WindowsUIButton)e.Button).Tag as string == "AutoLoadMunicipality")
                            {
                                var peekControl = new MunicipalityFormulaPeekControl(Repo, _selectedForm, _selectedDate.Year);
                                peekControl.Completed += formulaPeekControl_Completed;
                                formulaPeekControl = peekControl;
                            }
                            else if (((WindowsUIButton)e.Button).Tag as string == "AutoLoadRegion")
                            {
                                var peekControl = new RegionFormulaPeekControl(Repo, _selectedForm, _selectedDate.Year);
                                peekControl.Completed += formulaPeekControl_Completed;
                                formulaPeekControl = peekControl;
                            }
                            e.Control = formulaPeekControl;
                        };
                    }
                }
            }
            this.windowsUIButtonPanelActions.Buttons.Add(btnPrint);
            this.windowsUIButtonPanelActions.Buttons.Add(btnCheck);
            this.windowsUIButtonPanelActions.Buttons.Add(btnSaveToFile);
            var formIsBlocked = await _selectedForm.IsBlockedAsync();
            if (!formIsBlocked && !this.formBindingSource.List.Contains(_selectedForm))
                SetEditEnabled(false, EditDisabledMessage);
            else
                SetEditEnabled(!formIsBlocked);
            (btnCheck as IBaseButton).Properties.Visible = _selectedForm.is_check_required;

            this.windowsUIButtonPanelActions.AppearanceButton.Normal.Font = new Font("Segoe UI Light", 11, FontStyle.Regular);
            this.windowsUIButtonPanelActions.AppearanceButton.Hovered.Font =
                this.windowsUIButtonPanelActions.AppearanceButton.Normal.Font;
            this.windowsUIButtonPanelActions.AppearanceButton.Pressed.Font =
                this.windowsUIButtonPanelActions.AppearanceButton.Normal.Font;
        }
 public void OnQueryDocumentActions(IDocumentActionsArgs args)
 {
     args.DocumentActions.Add(new DocumentAction(Save) { Caption = "Сохранить", Image = Resources.glyphicons_206_ok_2 });
 }