コード例 #1
0
        public async Task <bool> GetOptions(ParametersRequest parametersRequest, string message)
        {
            var dict = new IParametersRequestItem[] {
                new ParametersRequestItem()
                {
                    Title = "Filename", Value = new OpenFileValueItem(Filename, "OpenXml|*.xlsx", false)
                }
                , new ParametersRequestItem()
                {
                    Title = "First row", Value = new NumericValueItem(FirstRow, 1, 65535)
                }
                , new ParametersRequestItem()
                {
                    Title = "First column", Value = new NumericValueItem(FirstCol, 1, 65535)
                }
                , new ParametersRequestItem()
                {
                    Title = "First row is title", Value = new BoolValueItem(FirstIsHead)
                }
            };

            if (await parametersRequest(dict, "OpenXml: Настройки файла", message))
            {
                Filename    = dict[0].Value.Value;
                FirstRow    = dict[1].Value.Int;
                FirstCol    = dict[2].Value.Int;
                FirstIsHead = dict[3].Value.Value;
                return(true);
            }
            return(false);
        }
コード例 #2
0
        public async Task <bool> GetConnectInfo(ParametersRequest parametersRequest, string message)
        {
            var dict = new IParametersRequestItem[] {
                new ParametersRequestItem()
                {
                    Title = "Server", Value = new StringValueItem(Server)
                }
                , new ParametersRequestItem()
                {
                    Title = "Path", Value = new StringValueItem(Path)
                }
                , new ParametersRequestItem()
                {
                    Title = "User", Value = new StringValueItem(User)
                }
                , new ParametersRequestItem()
                {
                    Title = "Password", Value = new PasswordValueItem(Pass)
                }
            };

            if (await parametersRequest(dict, "Firebird: Настройки соединения", message))
            {
                Server = (dict[0].Value as StringValueItem).String;
                Path   = (dict[1].Value as StringValueItem).String;
                User   = (dict[2].Value as StringValueItem).String;
                Pass   = (dict[3].Value as StringValueItem).String;
                return(true);
            }
            return(false);
        }
コード例 #3
0
        public async Task <bool> Ask(string message, string caption, ParametersRequest parametersRequest)
        {
            var dict = new IParametersRequestItem[] { new HeaderRequestItem()
                                                      {
                                                          Title = message
                                                      } };

            return(await parametersRequest(dict, caption));
        }
コード例 #4
0
ファイル: MainVM.cs プロジェクト: xCMNx/QRBase
        async Task <bool> CheckSettingsPass()
        {
            var dict = new IParametersRequestItem[] {
                new ParametersRequestItem()
                {
                    Title = "Password", Value = new PasswordValueItem(string.Empty)
                }
            };

            while (await Question.ShowAsync(dict))
            {
                if (Helpers.SetEncryptionKey((dict[0].Value as StringValueItem).String))
                {
                    return(true);
                }
            }
            return(false);
        }
コード例 #5
0
        public async Task <bool> AddField(ParametersRequest parametersRequest, ShowText showText)
        {
            try
            {
                var    sheet = _Package.Workbook.Worksheets[1];
                var    c     = (sheet.Dimension == null ? 1 : sheet.Dimension.End.Column + 1).GetExcelColumnName();
                string name  = c;
                var    dict  = new IParametersRequestItem[] {
                    new ParametersRequestItem()
                    {
                        Title = "Field name", Value = new StringValueItem(name)
                    }
                };

                if (await parametersRequest(dict, "OpenXml: Добавление поля"))
                {
                    name = (dict[0].Value as StringValueItem).Value;
                    if (_Fields.Keys.Contains(name))
                    {
                        showText($"Fild \"{name}\" already exists.");
                        return(false);
                    }
                    if (FirstIsHead)
                    {
                        sheet.Cells[$"{c}{FirstRow}"].Value = name;
                    }
                    _Fields[name] = c;
                    return(true);
                }
            }
            catch (Exception e)
            {
                showText(e.Message);
                Helpers.ConsoleWrite(e.Message, ConsoleColor.Yellow);
            }
            return(false);
        }
コード例 #6
0
ファイル: MainVM.cs プロジェクト: xCMNx/QRBase
        private async void SettingsCommandExecute(object parameter)
        {
            var dict = new IParametersRequestItem[] {
                new ParametersRequestItem()
                {
                    Title = "Шаблон QR", Value = new MemoValueItem(QRFormat)
                }
                , new ParametersRequestItem()
                {
                    Title = "Шаблон подписи", Value = new MemoValueItem(TextFormat)
                }
                , new ParametersRequestItem()
                {
                    Title = "PPM", Hint = "Пикселей на модуль", Value = new NumericValueItem(QRSize, 1, 100)
                }
                , new ParametersRequestItem()
                {
                    Title = "Без отступа", Value = new BoolValueItem(QRFull)
                }
                , new ParametersRequestItem()
                {
                    Title = "Цвет фона QR", Value = new ColorValueItem(QRBackground)
                }
                , new ParametersRequestItem()
                {
                    Title = "Цвет QR", Value = new ColorValueItem(QRForeground)
                }
                , new ParametersRequestItem()
                {
                    Title = "Цвет фона подписи", Value = new ColorValueItem(TextBackground)
                }
                , new ParametersRequestItem()
                {
                    Title = "Цвет подписи", Value = new ColorValueItem(TextForeground)
                }
                , new ParametersRequestItem()
                {
                    Title = "Подпись внутри", Value = new BoolValueItem(ShowText)
                }
                , new ParametersRequestItem()
                {
                    Title = "Шарина рамки подписи", Hint = "При тексте внутри QR", Value = new NumericValueItem(TextBorderWidth, 1, 100)
                }
                , new ParametersRequestItem()
                {
                    Title = "Подпись %", Hint = "Занимаемая подписью область QR", Value = new NumericValueItem(TextPercent, 1, 100)
                }
            };

            if (await Question.ShowAsync(dict, "Настройки"))
            {
                try
                {
                    int i = 0;
                    QRFormat        = dict[i++].Value.Value;
                    TextFormat      = dict[i++].Value.Value;
                    QRSize          = dict[i++].Value.Int;
                    QRFull          = dict[i++].Value.Value;
                    QRBackground    = dict[i++].Value.ColorHex;
                    QRForeground    = dict[i++].Value.ColorHex;
                    TextBackground  = dict[i++].Value.ColorHex;
                    TextForeground  = dict[i++].Value.ColorHex;
                    ShowText        = dict[i++].Value.Value;
                    TextBorderWidth = dict[i++].Value.Int;
                    TextPercent     = dict[i++].Value.Int;
                }
                catch (Exception e)
                {
                    Toast.ShowAsync(e.Message);
                    Helpers.ConsoleWrite(e.Message, ConsoleColor.Yellow);
                }
            }
        }
コード例 #7
0
ファイル: MainVM.cs プロジェクト: xCMNx/QRBase
        private async void ExportCommandExecute(object parameter)
        {
            if (!(SelectedQRList != null && SelectedQRList.Count > 0))
            {
                return;
            }
            var dict = new IParametersRequestItem[] {
                new ParametersRequestItem()
                {
                    Title = "Путь", Value = new PathValueItem(ExportPath)
                }
                , new ParametersRequestItem()
                {
                    Title = "Листы", Value = new BoolValueItem(PagesExport)
                }
                , new ParametersRequestItem()
                {
                    Title = "Столбцов на лист", Value = new NumericValueItem(PageColumns, 1, 1000)
                }
                , new ParametersRequestItem()
                {
                    Title = "Строк на лист", Value = new NumericValueItem(PageRows, 1, 1000)
                }
                , new ParametersRequestItem()
                {
                    Title = "Размер QR", Value = new NumericValueItem(PageQRSize, 21, 740)
                }
                , new ParametersRequestItem()
                {
                    Title = "Интервал", Value = new NumericValueItem(PageInterval, 0, 100)
                }
                , new ParametersRequestItem()
                {
                    Title = "Ширина рамки", Value = new NumericValueItem(PageBorderWidth, 0, 10)
                }
            };

            if (await Question.ShowAsync(dict, "Экспорт"))
            {
                try
                {
                    var qrFore   = _QRForeground.ToSDColor();
                    var qrBack   = _QRBackground.ToSDColor();
                    var textFore = _TextForeground.ToSDColor();
                    var textBack = _TextBackground.ToSDColor();
                    Func <QRData, System.Drawing.Bitmap> makeBmp = d => d.MakeBmp(QRSize, QRFormat, qrFore, qrBack, QRFull, ShowText, TextFormat, textFore, textBack, TextBorderWidth, TextPercent);
                    var exportPath = ExportPath = Path.GetFullPath(dict[0].Value.Value);
                    Directory.CreateDirectory(exportPath);
                    if (!(PagesExport = dict[1].Value.Value))
                    {
                        foreach (var d in SelectedQRList)
                        {
                            makeBmp(d)?.Save($"{Path.Combine(exportPath, d.GenInfo(TextFormat).GetValidFileName())}.png", ImageFormat.Png);
                        }
                    }
                    else
                    {
                        var cellSize     = PageQRSize = dict[4].Value.Int;
                        var cols         = PageColumns = dict[2].Value.Int;
                        var rows         = PageRows = dict[3].Value.Int;
                        var border       = PageBorderWidth = dict[6].Value.Int;
                        var interval     = PageInterval = dict[5].Value.Int;
                        var fullinterval = interval + border;
                        var step         = cellSize + fullinterval;
                        var i            = 0;
                        var page         = 1;
                        while (i < SelectedQRList.Count)
                        {
                            using (var bmp = new System.Drawing.Bitmap(step * cols, step * rows))
                            {
                                var p = border > 0 ? new System.Drawing.Pen(System.Drawing.Color.Black, border) : null;
                                using (var graph = System.Drawing.Graphics.FromImage(bmp))
                                {
                                    var y = fullinterval / 2;
                                    for (var r = 0; r < rows && i < SelectedQRList.Count; r++, i++)
                                    {
                                        var x = fullinterval / 2;
                                        for (var c = 0; c < cols && i < SelectedQRList.Count; c++, i++)
                                        {
                                            if (p != null)
                                            {
                                                graph.DrawRectangle(p, x - fullinterval / 2, y - fullinterval / 2, cellSize + fullinterval, cellSize + fullinterval);
                                            }
                                            var qBmp = makeBmp(SelectedQRList.ElementAt(i));
                                            graph.DrawImage(qBmp, new System.Drawing.Rectangle(x, y, cellSize, cellSize));
                                            x += step;
                                        }
                                        y += step;
                                    }
                                }
                                bmp.Save($"{exportPath}\\{page++}.png", ImageFormat.Png);
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    Toast.ShowAsync(e.Message);
                    Helpers.ConsoleWrite(e.Message, ConsoleColor.Yellow);
                }
            }
        }