Beispiel #1
0
        private void Export()
        {
            var parentW   = GtkHelper.GetParentWindow(this);
            var csvFilter = new FileFilter();

            csvFilter.AddPattern("*.csv");
            csvFilter.Name = "Comma Separated Values File (*.csv)";

            var param = new object[4];

            param[0] = "Cancel";
            param[1] = ResponseType.Cancel;
            param[2] = "Save";
            param[3] = ResponseType.Accept;

            var fc = new FileChooserDialog("Save File As", parentW, FileChooserAction.Save, param)
            {
                DoOverwriteConfirmation = true,
                CurrentName             = "Аналитика заказов.csv"
            };

            fc.AddFilter(csvFilter);

            if (fc.Run() == (int)ResponseType.Accept)
            {
                ViewModel.FileName = fc.Filename;
                ViewModel.ExportCommand.Execute();
            }

            fc.Destroy();
        }
Beispiel #2
0
        protected void OnExportBtnClicked(object sender, EventArgs e)
        {
            var parentWindow = GtkHelper.GetParentWindow(this);

            var          excelFilter = new FileFilter();
            const string extension   = ".xlsx";

            excelFilter.Name = $"Документ Microsoft Excel ({extension})";
            excelFilter.AddMimeType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
            excelFilter.AddPattern($"*{extension}");

            var fileChooserDialog = new FileChooserDialog(
                "Сохранение выгрузки",
                parentWindow,
                FileChooserAction.Save,
                Stock.Cancel, ResponseType.Cancel, Stock.Save, ResponseType.Accept)
            {
                DoOverwriteConfirmation = true,
                CurrentName             = $"{Tab.TabName} " +
                                          $"с {ViewModel.StartDeliveryDate.Value.ToShortDateString()} " +
                                          $"по {ViewModel.EndDeliveryDate.Value.ToShortDateString()}.xlsx"
            };

            fileChooserDialog.AddFilter(excelFilter);
            fileChooserDialog.ShowAll();
            if ((ResponseType)fileChooserDialog.Run() == ResponseType.Accept)
            {
                if (String.IsNullOrWhiteSpace(fileChooserDialog.Filename))
                {
                    fileChooserDialog.Destroy();
                    return;
                }
                var fileName = fileChooserDialog.Filename;
                ViewModel.FileName = fileName.EndsWith(".xlsx") ? fileName : fileName + ".xlsx";
                fileChooserDialog.Destroy();
                ViewModel.ExportCommand.Execute();
            }
            else
            {
                fileChooserDialog.Destroy();
            }
        }
Beispiel #3
0
        private void OnButtonExportClicked(object sender, EventArgs e)
        {
            var parentWindow = GtkHelper.GetParentWindow(this);

            var csvFilter = new FileFilter();

            csvFilter.AddPattern("*.csv");
            csvFilter.Name = "Comma Separated Values File (*.csv)";

            var fileChooserDialog = new FileChooserDialog(
                "Сохранение выгрузки",
                parentWindow,
                FileChooserAction.Save,
                Stock.Cancel, ResponseType.Cancel, Stock.Save, ResponseType.Accept)
            {
                DoOverwriteConfirmation = true, CurrentName = $"Выгрузка по водителям {DateTime.Today:d}.csv"
            };

            fileChooserDialog.AddFilter(csvFilter);
            fileChooserDialog.ShowAll();
            if ((ResponseType)fileChooserDialog.Run() == ResponseType.Accept)
            {
                if (String.IsNullOrWhiteSpace(fileChooserDialog.Filename))
                {
                    fileChooserDialog.Destroy();
                    return;
                }
                var fileName = fileChooserDialog.Filename;
                ViewModel.ExportPath = fileName.EndsWith(".csv") ? fileName : fileName + ".csv";
                fileChooserDialog.Destroy();
                ViewModel.ExportCommand.Execute();
            }
            else
            {
                fileChooserDialog.Destroy();
            }
        }