예제 #1
0
        public void ExportToEF2File()
        {
            using (FileChooserDialog fc = new FileChooserDialog("Export to EF2", (Window)Toplevel,
                                                                FileChooserAction.Save, "Cancel", ResponseType.Cancel,
                                                                "Save", ResponseType.Accept))
            {
                fc.ShowAll();
                if (fc.Run() == (int)ResponseType.Accept)
                {
                    string        target       = fc.Filename;
                    List <string> export       = new List <string>();
                    var           downloadList = SelectedCount > 0
                        ? (IEnumerable <Downloader>)SelectedDownloaders
                        : DownloadManager.Instance.Downloads;

                    foreach (var downloader in downloadList)
                    {
                        export.Add("<\n");
                        export.Add(downloader.ResourceLocation.URL);
                        export.Add("\n>");
                    }

                    File.WriteAllText(target, string.Join("\n", export));
                }
                fc.Destroy();
            }
        }
예제 #2
0
        public void ImportFromTextFile()
        {
            using (FileChooserDialog fc = new FileChooserDialog(
                       "Import from text",
                       (Window)Toplevel,
                       FileChooserAction.Open,
                       "Cancel", ResponseType.Cancel,
                       "Open", ResponseType.Accept))
            {
                fc.ShowAll();
                if (fc.Run() == (int)ResponseType.Accept)
                {
                    string[] lines = File.ReadAllLines(fc.Filename);

                    using (var batchDlg = new AddMultipleDownloadDialog())
                    {
                        var list = lines.Where(s => ResourceLocation.IsURL(s)).ToArray();
                        foreach (var item in list)
                        {
                            batchDlg.Store.AddNode(new BatchDownloadNode {
                                Checked = true, Url = item
                            });
                        }

                        batchDlg.Run();
                        batchDlg.Destroy();
                    }
                }
                fc.Destroy();
            }
        }
예제 #3
0
        public void ImportFromEF2File()
        {
            Regex r = new Regex(@"^<\n(.*)$\n[^<]*\n^>", RegexOptions.Multiline);

            using (FileChooserDialog fc = new FileChooserDialog("Import from EF2", (Window)Toplevel, FileChooserAction.Open, "Cancel", ResponseType.Cancel,
                                                                "Open", ResponseType.Accept))
            {
                fc.ShowAll();
                if (fc.Run() == (int)ResponseType.Accept)
                {
                    string lines = File.ReadAllText(fc.Filename);
                    var    m     = r.Matches(lines);
                    var    list  = new List <Match>();
                    for (int i = 0; i < m.Count; i++)
                    {
                        list.Add(m[i]);
                    }

                    using (var batchDlg = new AddMultipleDownloadDialog())
                    {
                        foreach (var item in list)
                        {
                            batchDlg.Store.AddNode(new BatchDownloadNode {
                                Checked = true, Url = item.Groups[0].Value
                            });
                        }

                        batchDlg.Run();
                        batchDlg.Destroy();
                    }
                }
                fc.Destroy();
            }
        }
예제 #4
0
    private UploadFileChooserUI()
    {
        Glade.XML gxml = new Glade.XML(null, "organizer.glade", "filechooserdialog1", null);
        gxml.Autoconnect(this);
        _job           = new ThreadStart(ProcessThumbnail);
        _previewthread = new Thread(_job);

        label16.WidthRequest = eventbox7.WidthRequest;

        eventbox7.ModifyBg(Gtk.StateType.Normal, bgcolor);
        eventbox8.ModifyBg(Gtk.StateType.Normal, bgcolor);
        eventbox9.ModifyBg(Gtk.StateType.Normal, bgcolor);

        filechooserdialog1.Title = "Select files to upload";
        filechooserdialog1.SetIconFromFile(DeskFlickrUI.ICON_PATH);
        filechooserdialog1.SetFilename(PersistentInformation.GetInstance().UploadFilename);
        filechooserdialog1.SelectMultiple = true;

        FileFilter imagefilter = new FileFilter();

        imagefilter.AddMimeType("image/jpeg");
        imagefilter.AddMimeType("image/png");
        filechooserdialog1.Filter = imagefilter;

        filechooserdialog1.SelectionChanged += new EventHandler(OnFileSelectedChanged);
        filechooserdialog1.FileActivated    += new EventHandler(OnOpenButtonClicked);
        button10.Clicked += new EventHandler(OnOpenButtonClicked);
        button11.Clicked += new EventHandler(OnCancelButtonClicked);
        DeskFlickrUI.GetInstance().SetUploadWindow(false);
        filechooserdialog1.ShowAll();
    }
예제 #5
0
 private void OpenOpenDialog()
 {
     FileChooserDialog = new FileChooserDialog("Open Game", Window, FileChooserAction.Open, "Open");
     FileChooserDialog.SetCurrentFolderUri("F:/isos/psp2");
     //FileChooserDialog.AddShortcutFolder("F:/isos/psp2");
     //FileChooserDialog.
     //FileChooserDialog.SelectionChanged += FileChooserDialog_FileActivated;
     FileChooserDialog.FileActivated += FileChooserDialog_FileActivated;
     FileChooserDialog.ShowAll();
 }
예제 #6
0
 private void BtnBrowseOnActivated(object sender, EventArgs e)
 {
     using (FileChooserDialog fc = new FileChooserDialog("Save to...", null,
                                                         FileChooserAction.Save, "Cancel", ResponseType.Cancel,
                                                         "Save", ResponseType.Accept))
     {
         fc.ShowAll();
         if (fc.Run() == (int)ResponseType.Accept)
         {
             txtFilename.Text = fc.Filename;
         }
     }
 }
예제 #7
0
    protected ResponseType SelectFolder(string title, out string filename)
    {
        var dialog = new FileChooserDialog(title, null, FileChooserAction.SelectFolder,
                                           "Cancel", ResponseType.Cancel,
                                           "Select", ResponseType.Accept);

        dialog.ShowAll();

        ResponseType responseType = (ResponseType)dialog.Run();

        filename = dialog.Filename;
        dialog.Hide();

        return(responseType);
    }
예제 #8
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();
            }
        }
예제 #9
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();
            }
        }
        private void ConfigureDlg()
        {
            ybuttonExport.Clicked += (sender, e) => {
                var parentWindow  = GetParentWindow(this);
                var folderChooser = new FileChooserDialog("Выберите папку выгрузки", parentWindow, FileChooserAction.SelectFolder,
                                                          Stock.Cancel, ResponseType.Cancel, Stock.Open, ResponseType.Accept)
                {
                    DoOverwriteConfirmation = true,
                };
                folderChooser.ShowAll();
                if ((ResponseType)folderChooser.Run() == ResponseType.Accept)
                {
                    if (folderChooser.CurrentFolder == null)
                    {
                        folderChooser.Destroy();
                        return;
                    }
                    ViewModel.FolderPath = folderChooser.CurrentFolder;
                    var shortpath = folderChooser.CurrentFolder;
                    if (folderChooser.CurrentFolder.Length > 25)
                    {
                        shortpath = "..." + shortpath.Substring(shortpath.Length - 25);
                    }
                    ybuttonExport.Label = shortpath;
                    folderChooser.Destroy();
                }
                else
                {
                    folderChooser.Destroy();
                }
            };

            enummenubuttonExport.ItemsEnum        = typeof(ExportType);
            enummenubuttonExport.EnumItemClicked += (sender, e) => {
                ViewModel.ExportCommand.Execute(e.ItemEnum);
            };

            enummenubuttonLoadActions.ItemsEnum        = typeof(LoadAction);
            enummenubuttonLoadActions.EnumItemClicked += (sender, e) => {
                ViewModel.LoadActionCommand.Execute(e.ItemEnum);
            };

            enummenubuttonConfirmUpdate.ItemsEnum        = typeof(ConfirmUpdateAction);
            enummenubuttonConfirmUpdate.EnumItemClicked += (sender, e) => {
                ViewModel.ConfirmUpdateDataCommand.Execute(e.ItemEnum);
            };

            ycheckDontChangeSellPrice.Binding.AddBinding(ViewModel, vm => vm.DontChangeSellPrice, w => w.Active);
            ycheckDontChangeSellPrice.Active      = true;
            ycheckDontChangeSellPrice.TooltipText = "При включении у всех заменяемых номенклатур будут удалены все старые цены и будет создана одна новая цена, указанная в файле";

            ybuttonConfirmLoadNew.Clicked += (sender, e) => { ViewModel.ConfirmLoadNewCommand.Execute(); };

            yfilechooserbuttonImport.Binding.AddBinding(ViewModel, vm => vm.FilePath, w => w.Filename);
            var fileFilter = new FileFilter();

            fileFilter.AddPattern("*.csv");
            yfilechooserbuttonImport.Filter = fileFilter;
            yfilechooserbuttonImport.Title  = "Выберите csv файл";

            ytreeviewNomenclatures.ColumnsConfig = FluentColumnsConfig <NomenclatureCatalogNode> .Create()
                                                   .AddColumn("Действие")
                                                   .MinWidth(120)
                                                   .AddComboRenderer(x => x.ConflictSolveAction)
                                                   .SetDisplayFunc(x => x.GetEnumTitle())
                                                   .FillItems(((ConflictSolveAction[])Enum.GetValues(typeof(ConflictSolveAction))).ToList())
                                                   .AddSetter((c, n) => {
                c.Editable = n.Source == Source.File && n.Status == NodeStatus.Conflict && n.DuplicateOf != null && ViewModel.CurrentState == LoadAction.LoadNew;
                switch (ViewModel.CurrentState)
                {
                case LoadAction.LoadNew:
                    if (n.DuplicateOf == null || n.Source == Source.Base || !c.Editable)
                    {
                        c.Text = "";
                    }
                    break;

                case LoadAction.UpdateData:
                    if (n.ConflictSolveAction != ConflictSolveAction.Ignore)
                    {
                        c.Text = "";
                    }
                    break;
                }
            })
                                                   .AddColumn("Источник")
                                                   .AddEnumRenderer((x) => x.Source)
                                                   .XAlign(0.5f)
                                                   .AddColumn("Статус")
                                                   .AddTextRenderer((x) => x.Status.GetEnumTitle())
                                                   .XAlign(0.5f)
                                                   .AddColumn("ID номенклатуры")
                                                   .AddTextRenderer(x => x.Id.ToString())
                                                   .AddSetter((c, n) => { if (n.Id == null)
                                                                          {
                                                                              c.Text = "Новый";
                                                                          }
                                                              })
                                                   .XAlign(0.5f)
                                                   .AddColumn("Наименование")
                                                   .AddTextRenderer(x => x.Name)
                                                   .WrapMode(Pango.WrapMode.WordChar)
                                                   .WrapWidth(400)
                                                   .AddColumn("ID группы товаров")
                                                   .AddNumericRenderer(x => x.GroupId)
                                                   .XAlign(0.5f)
                                                   .AddColumn("ID поставщика")
                                                   .AddNumericRenderer(x => x.ShipperCounterpartyId)
                                                   .XAlign(0.5f)
                                                   .AddColumn("Цена продажи")
                                                   .AddNumericRenderer(x => x.SellPrice).Digits(2).WidthChars(10)
                                                   .XAlign(1)
                                                   .AddColumn("Единицы измерения")
                                                   .AddNumericRenderer(x => x.MeasurementUnit)
                                                   .XAlign(0.5f)
                                                   .AddColumn("Папка 1С")
                                                   .HeaderAlignment(0.5f)
                                                   .AddNumericRenderer(x => x.Folder1cName)
                                                   .XAlign(0.5f)
                                                   .AddColumn("Категория")
                                                   .HeaderAlignment(0.5f)
                                                   .AddTextRenderer(x => x.NomenclatureCategory)
                                                   .XAlign(0.5f)
                                                   .AddColumn("Объем тары")
                                                   .HeaderAlignment(0.5f)
                                                   .AddTextRenderer(x => x.TareVolume)
                                                   .XAlign(0.5f)
                                                   .AddColumn("Вид оборудования")
                                                   .AddTextRenderer(x => x.EquipmentKindName)
                                                   .XAlign(0.5f)
                                                   .AddColumn("Доступность для продажи")
                                                   .AddTextRenderer(x => x.SaleCategory)
                                                   .XAlign(0.5f)
                                                   .AddColumn("Тип залога")
                                                   .AddTextRenderer(x => x.TypeOfDepositCategory)
                                                   .XAlign(0.5f)
                                                   .AddColumn("Тип топлива")
                                                   .AddTextRenderer(x => x.FuelTypeName)
                                                   .XAlign(0.5f)
                                                   .RowCells()
                                                   .AddSetter((CellRendererText c, NomenclatureCatalogNode n) => {
                c.CellBackgroundGdk = GetGdkColor(n.BackgroundColor);
                c.ForegroundGdk     = GetGdkColor(n.ForegroundColor);
            })
                                                   .Finish();

            ViewModel.PropertyChanged += (sender, e) => {
                Application.Invoke((s, args) => {
                    if (e.PropertyName == nameof(ViewModel.ProgressBarValue))
                    {
                        progressbar.Adjustment.Value = ViewModel.ProgressBarValue;
                    }
                    if (e.PropertyName == nameof(ViewModel.ProgressBarUpper))
                    {
                        progressbar.Adjustment.Upper = ViewModel.ProgressBarUpper;
                    }
                    if (e.PropertyName == nameof(ViewModel.Items))
                    {
                        ytreeviewNomenclatures.ItemsDataSource = ViewModel.Items;
                    }
                    if (e.PropertyName == nameof(ViewModel.IsConfirmUpdateDataButtonVisible))
                    {
                        enummenubuttonConfirmUpdate.Visible = ViewModel.IsConfirmUpdateDataButtonVisible;
                    }
                    if (e.PropertyName == nameof(ViewModel.IsConfirmLoadNewButtonVisible))
                    {
                        ycheckDontChangeSellPrice.Visible = ViewModel.IsConfirmUpdateDataButtonVisible;
                    }
                    if (e.PropertyName == nameof(ViewModel.IsConfirmLoadNewButtonVisible))
                    {
                        ybuttonConfirmLoadNew.Visible = ViewModel.IsConfirmLoadNewButtonVisible;
                    }
                });
            };

            TextTagTable textTags   = new TextTagTable();
            var          darkredtag = new TextTag("DarkRed");

            darkredtag.ForegroundGdk = GetGdkColor(ConsoleColor.DarkRed);
            textTags.Add(darkredtag);
            var redtag = new TextTag("red");

            redtag.ForegroundGdk = GetGdkColor(ConsoleColor.Red);
            textTags.Add(redtag);
            var greentag = new TextTag("Green");

            greentag.ForegroundGdk = GetGdkColor(ConsoleColor.Green);
            textTags.Add(greentag);
            var darkgreentag = new TextTag("DrakGreen");

            darkgreentag.ForegroundGdk = GetGdkColor(ConsoleColor.DarkGreen);
            textTags.Add(darkgreentag);
            var blackTag = new TextTag("Black");

            blackTag.ForegroundGdk = GetGdkColor(ConsoleColor.Black);
            textTags.Add(blackTag);
            var yellowTag = new TextTag("Yellow");

            yellowTag.ForegroundGdk = GetGdkColor(ConsoleColor.DarkYellow);
            textTags.Add(yellowTag);

            ViewModel.ProgressBarMessagesUpdated += (aList, aIdx) => {
                Application.Invoke((s, args) => {
                    TextBuffer tempBuffer = new TextBuffer(textTags);
                    foreach (ColoredMessage message in ViewModel.ProgressBarMessages)
                    {
                        TextIter iter = tempBuffer.EndIter;
                        switch (message.Color)
                        {
                        case ConsoleColor.Black: tempBuffer.InsertWithTags(ref iter, "\n" + message.Text, blackTag); break;

                        case ConsoleColor.DarkRed: tempBuffer.InsertWithTags(ref iter, "\n" + message.Text, darkredtag); break;

                        case ConsoleColor.Green: tempBuffer.InsertWithTags(ref iter, "\n" + message.Text, greentag); break;

                        case ConsoleColor.Yellow: tempBuffer.InsertWithTags(ref iter, "\n" + message.Text, yellowTag); break;

                        case ConsoleColor.DarkGreen: tempBuffer.InsertWithTags(ref iter, "\n" + message.Text, darkgreentag); break;

                        case ConsoleColor.Red: tempBuffer.InsertWithTags(ref iter, "\n" + message.Text, redtag); break;

                        default: throw new NotImplementedException("Цвет не настроен");
                        }
                    }
                    ytextviewProgressStatus.Buffer = tempBuffer;
                    ScrollToEnd();
                });
            };

            ytreeviewNomenclatures.Selection.Changed += (sender, e) => {
                Application.Invoke((s, args) => {
                    ytextviewNodeMessages.Buffer.Clear();
                    TextBuffer tempBuffer = new TextBuffer(textTags);
                    var node = ytreeviewNomenclatures.GetSelectedObject <NomenclatureCatalogNode>();
                    if (node == null)
                    {
                        ytextviewNodeMessages.Buffer.Text = "Выберите запись для просмотра ошибок";
                        return;
                    }
                    foreach (ColoredMessage message in node.ErrorMessages)
                    {
                        TextIter iter = tempBuffer.EndIter;
                        switch (message.Color)
                        {
                        case ConsoleColor.Black: tempBuffer.InsertWithTags(ref iter, message.Text + "\n", blackTag); break;

                        case ConsoleColor.DarkRed: tempBuffer.InsertWithTags(ref iter, message.Text + "\n", darkredtag); break;

                        case ConsoleColor.Green: tempBuffer.InsertWithTags(ref iter, message.Text + "\n", greentag); break;

                        case ConsoleColor.Yellow: tempBuffer.InsertWithTags(ref iter, message.Text + "\n", yellowTag); break;

                        case ConsoleColor.DarkGreen: tempBuffer.InsertWithTags(ref iter, message.Text + "\n", darkgreentag); break;

                        case ConsoleColor.Red: tempBuffer.InsertWithTags(ref iter, message.Text + "\n", redtag); break;

                        default: throw new NotImplementedException("Цвет не настроен");
                        }
                    }
                    if (!node.ErrorMessages.Any() && node.Source == Source.File)
                    {
                        TextIter iter = tempBuffer.EndIter;
                        tempBuffer.InsertWithTags(ref iter, "Ошибок нет\n", darkgreentag);
                    }
                    if (node.Source == Source.Base)
                    {
                        TextIter iter = tempBuffer.EndIter;
                        tempBuffer.InsertWithTags(ref iter, "Данные из базы\n", blackTag);
                    }
                    ytextviewNodeMessages.Buffer = tempBuffer;
                    ScrollToEnd();
                });
            };
        }