public void SelectAllItems(ICollectionView availableItemsCollectionView)
		{
			if (availableItemsCollectionView.SourceCollection is ICollection<Store>)
			{
				availableItemsCollectionView.Cast<Store>().ToList().ForEach(x => SelectItem(x));
			}
		}
        private void UpdateStatusBar(DirectoryViewModel _directory)
        {
            Debug.Assert(_directory != null);

            int files = _directory.FileNames.Count;

            int selected = FilesDataGrid.SelectedItemsList?.Count ?? 0;

            string dir   = _directory.Name;
            int    count = m_view?.Cast <object>().Count() ?? 0;

            StatusTextBlock.Text = GetUpdateString(dir, count, files, selected);
        }
        private void LoadedHandler(object sender, RoutedEventArgs e)
        {
            // The following code doesn't work in the WPF Designer environment (Cider or Blend).
            if (!WafConfiguration.IsInDesignMode)
            {
                contactCollectionView = CollectionViewSource.GetDefaultView(ViewModel.Contacts);
                contactCollectionView.Filter = Filter;
                ViewModel.ContactCollectionView = contactCollectionView.Cast<Contact>();
                ViewModel.SelectedContact = ViewModel.ContactCollectionView.FirstOrDefault();
            }

            ViewModel.PropertyChanged += ViewModelPropertyChanged;
            contactsBox.Focus();
            if (ViewModel.SelectedContact != null) { FocusItem(); }
        }
Beispiel #4
0
        private void FirstTimeLoadedHandler(object sender, RoutedEventArgs e)
        {
            // Ensure that this handler is called only once.
            Loaded -= FirstTimeLoadedHandler;
            
            // The following code doesn't work in the WPF Designer environment (Cider or Blend).
            if (!WafConfiguration.IsInDesignMode)
            {
                bookCollectionView = CollectionViewSource.GetDefaultView(ViewModel.Books);
                bookCollectionView.Filter = Filter;
                ViewModel.BookCollectionView = bookCollectionView.Cast<BookDataModel>();

                bookTable.Focus();
                bookTable.CurrentCell = new DataGridCellInfo(ViewModel.Books.FirstOrDefault(), bookTable.Columns[0]);
            }
        }
Beispiel #5
0
        private void LoadedHandler(object sender, RoutedEventArgs e)
        {
            // The following code doesn't work in the WPF Designer environment (Cider or Blend).
            if (!WafConfiguration.IsInDesignMode)
            {
                emailCollectionView = CollectionViewSource.GetDefaultView(ViewModel.Emails);
                emailCollectionView.Filter = Filter;
                emailCollectionView.SortDescriptions.Add(new SortDescription(nameof(Email.Sent), ListSortDirection.Descending));
                ViewModel.EmailCollectionView = emailCollectionView.Cast<Email>();
                ViewModel.SelectedEmail = ViewModel.EmailCollectionView.FirstOrDefault();
            }

            ViewModel.PropertyChanged += ViewModelPropertyChanged;
            emailsBox.Focus();
            if (ViewModel.SelectedEmail != null)
            {
                FocusItem();
            }
        }
Beispiel #6
0
        public MainWindow()
        {
            InitializeComponent();

            discord = new DiscordClient(x =>
            {
                x.AppName = "OakBot";
                x.AppUrl = "http://github.com/ocgineer/OakBot";
                x.AppVersion = FileVersionInfo.GetVersionInfo(System.Reflection.Assembly.GetExecutingAssembly().Location).FileVersion;
                x.UsePermissionsCache = false;
            });


            // Initialize instance
            instance = this;

            this.DataContext = this;

            if (!Directory.Exists(Config.AppDataPath)) Directory.CreateDirectory(Config.AppDataPath);
            if (!Directory.Exists(Config.AppDataPath + "\\Webserver")) Directory.CreateDirectory(Config.AppDataPath + "\\Webserver");

            // Initialize config
            Config.GetConfigFromDb();
            LoadConfigToUI();
            DatabaseUtils.LoadAllViewers();
            DatabaseUtils.LoadAllQuotes();

            // Enable sync between threads
            BindingOperations.EnableCollectionSynchronization(colChatMessages, _lockChat);
            BindingOperations.EnableCollectionSynchronization(colViewers, _lockViewers);
            BindingOperations.EnableCollectionSynchronization(colDatabase, _lockDatabase);
            BindingOperations.EnableCollectionSynchronization(colSongs, _lockSongs);
            BindingOperations.EnableCollectionSynchronization(colGiveaways, _lockGiveaways);

            // Create Event for collection changed
            colChatMessages.CollectionChanged += colChatMessages_Changed;

            // Link listViews with collections
            //listViewChat.ItemsSource = colChatMessages;
            listViewViewers.ItemsSource = colViewers;

            // Database listView with filter
            lvViewerDatabase.ItemsSource = colDatabase;
            databaseView = CollectionViewSource.GetDefaultView(lvViewerDatabase.ItemsSource);
            databaseView.Filter = DatabaseFilter;
            lblFilterCnt.Content = databaseView.Cast<Viewer>().Count();

            lvCommands.ItemsSource = colBotCommands;
            lvQuotes.ItemsSource = colQuotes;

            lvSongs.ItemsSource = colSongs;

            lvGiveaways.ItemsSource = colGiveaways;

            // Testing Commands
            colBotCommands.Add(new UserCommand("!test", "Test received!", 30, 0, true));
            colBotCommands.Add(new UserCommand(":yatb", "Yet Another Twitch Bot.", 30, 60, true));
            colBotCommands.Add(new UserCommand("!who", "You are @user@", 0, 0, true));
            colBotCommands.Add(new UserCommand("!block", "@block@ Hello thur!", 0, 0, true));
            colBotCommands.Add(new UserCommand("!followdate", "@user@, you are following since @followdate@.", 0, 0, true));
            colBotCommands.Add(new UserCommand("!followdatetime", "@user@, you are following since @followdatetime@", 0, 0, true));
            colBotCommands.Add(new UserCommand("!vartest", "@var1@ m8", 0, 0, true));
            colBotCommands.Add(new UserCommand("!song", "Currently playing: @song@!", 0, 0, true));
            colBotCommands.Add(new UserCommand("Giveaway", "Just stop...", 0, 0, true, true));
            colBotCommands.Add(new UserCommand("!slap", "@user@ slaps @target@ so hard, he bursts into pieces!", 0, 0, true));

            colSongs.Add(new Song("https://www.youtube.com/watch?v=VEAy700YGuU"));
            colSongs.Add(new Song("https://soundcloud.com/aivisura/steven-universe-strong-in-the-real-way-rebecca-sugar"));

            string message = "Hello and welcome to the first OakBot Alpha ever to be released! I know it took some time, but I also have a private life, you know? ;)\n\n" +
                             "Anyways, this version has not many functions yet, but the ones that are listed here, are fully working.\n\n" +
                             "WORKING:\n" +
                             "- Twitch Chat\n" +
                             "- Commands\n" +
                             "  - Song Requests (the controls are only working for YouTube at the moment)\n" +
                             "  - Quotes\n" +
                             "  - Follow Date\n" +
                             "- Discord Integration (user unspecific commands work without problems, while the user specific ones are yet to be handled)\n" +
                             "- Import from Ankhbot\n" +
                             "- Dashboard and Viewer related stuff\n\n" +
                             "IMPLEMENTED, BUT NOT FULLY WORKING:\n" +
                             "- Giveaways\n" +
                             "- Stream Currency Gain\n" +
                             "- The UI itself\n\n" +
                             "I know, there's much to do, but bear with me. I'm working as hard as I can c:";
            MessageBox.Show(message, "OakBot Alpha 1");

            // BackgroundTask Thread
            BackgroundTasks bg = new BackgroundTasks(60, 120);
            new Thread(new ThreadStart(bg.Run)) { IsBackground = true }.Start();

            // Auto connect
            if (Config.AutoConnectBot)
            {
                ConnectBot();

                // Can only connect if Bot is connected
                if (Config.AutoConnectStreamer)
                {
                    ConnectStreamer();
                }
            }
        }
 public void SelectAllItems(ICollectionView availableItemsCollectionView)
 {
     var itemsList = availableItemsCollectionView.Cast<PropertyValue>().ToList();
     itemsList.ForEach(SelectItem);
 }
Beispiel #8
0
 private void updateFilteredCollection()
 {
     FilteredItemsSource = _collectionView?.Cast <object>().ToList();
 }
Beispiel #9
0
        public static void Export <T>(
            this ICollectionView collectionView,
            Dictionary <string, Model.DataCellFormats> fieldsAndFormats,
            string reportTitle,
            string reportDescription,
            Func <T, string, string, object> getValueDelegate, Action <string> callBack = null)
        {
            if (getValueDelegate == null || fieldsAndFormats == null || reportTitle == null)
            {
                return;
            }

            const string commentFieldName = nameof(Model.Meter.Коментарий);
            bool         hasCommentColumn = fieldsAndFormats.ContainsKey(commentFieldName);

            IEnumerable <T> collection = null;

            Application.Current.Dispatcher.Invoke(() =>
            {
                collection = collectionView.Cast <T>();
            });
            int numberOfRows = collection.Count();

            // +1 т.к. первый столбец номер по порядку
            int numberOfColumns = fieldsAndFormats.Count + 1;

            callBack?.Invoke("чтение данных");
            object[,] output = BuildDataArray();
            object[,] outputWithTwoRowPerRecord = null;
            if (hasCommentColumn)
            {
                outputWithTwoRowPerRecord = BuildDataArrayWithTwoRowPerRecord();
            }

            callBack?.Invoke("поиск MS Excel");

            string fileName = System.IO.Path.GetTempFileName();

            fileName = System.IO.Path.ChangeExtension(fileName, "xlsx");

            System.Globalization.CultureInfo defaultCulture = System.Threading.Thread.CurrentThread.CurrentCulture;

            // HACK: Workaround for Excel bug on machines which are set up in the English language, but not an English region.
            System.Globalization.CultureInfo enusCultureInfo = System.Globalization.CultureInfo.GetCultureInfo("en-US");
            System.Threading.Thread.CurrentThread.CurrentCulture = enusCultureInfo;

            Excel.Application excelApplication = null;
            Excel.Workbook    xlWorkbook       = null;
            Excel.Worksheet   xlWorksheet      = null;
            Excel.Worksheet   xlWorksheet2     = null;

            NetOffice.OfficeApi.Tools.Contribution.CommonUtils utils = null;

            Exception exception = null;

            Process(output, outputWithTwoRowPerRecord);

            OpenCreatedWorkBook();

            // возвращает значение указанного поля записи
            object GetValueOfField(T item, string fieldName)
            {
                object value = string.Empty;

                if (string.IsNullOrWhiteSpace(fieldsAndFormats[fieldName].ExcelFormat) == false)
                {
                    value = getValueDelegate(item, string.Empty, fieldName);
                }
                else
                {
                    value = getValueDelegate(item, fieldsAndFormats[fieldName].ContentDisplayFormat, fieldName);
                }

                if (value is DateOnly dateOnlyValue)
                {
                    value = dateOnlyValue.ToDateTime(TimeOnly.MinValue);
                }

                return(value);
            }

            // создание массива данных
            object[,] BuildDataArray()
            {
                // +1 т.к. первый столбец номер по порядку
                int countOfColumns = fieldsAndFormats.Count + 1;

                // +1 т.к. первая строка шапка
                object[,] output = new object[numberOfRows + 1, countOfColumns];

                // for (int i = 0; i < numberOfRows + 1; i++)
                //    output[i] = new object[numberOfColumns];

                output[0, 0] = "№ п/п";
                int ind = 1;

                foreach (KeyValuePair <string, Model.DataCellFormats> field in fieldsAndFormats)
                {
                    output[0, ind++] = Utils.ConvertFromTitleCase(field.Key);
                }

                callBack?.Invoke("заполнение таблицы");

                int rowIndex = 1;

                foreach (T item in collection)
                {
                    output[rowIndex, 0] = rowIndex;
                    ind = 1; // т.к. первый столбец номер по порядку
                    foreach (string field in fieldsAndFormats.Keys)
                    {
                        output[rowIndex, ind++] = GetValueOfField(item, field);
                    }

                    rowIndex++;
                }

                return(output);
            }

            // создание массива данных со второй строкой в каждой записи где указан комментарий
            object[,] BuildDataArrayWithTwoRowPerRecord()
            {
                // -1 т.к. исключен столбец Комментарий
                // +1 т.к. первый столбец номер по порядку
                int countOfColumns = fieldsAndFormats.Count - 1 + 1;

                int numberOfRecords = collection.Count();

                // +1 т.к. первая строка шапка
                object[,] output = new object[(2 * numberOfRecords) + 1, countOfColumns];

                // for (int i = 0; i < numberOfRows + 1; i++)
                //    output[i] = new object[numberOfColumns];

                output[0, 0] = "№ п/п";
                int ind = 1;

                foreach (KeyValuePair <string, Model.DataCellFormats> field in fieldsAndFormats)
                {
                    if (field.Key == commentFieldName)
                    {
                        continue;
                    }
                    else
                    {
                        output[0, ind++] = Utils.ConvertFromTitleCase(field.Key);
                    }
                }

                callBack?.Invoke("заполнение таблицы");

                int rowIndex    = 1;
                int recordIndex = 1;

                foreach (T item in collection)
                {
                    output[rowIndex, 0] = recordIndex;
                    ind = 1; // т.к. первый столбец номер по порядку
                    foreach (string field in fieldsAndFormats.Keys)
                    {
                        if (field == commentFieldName)
                        {
                            continue;
                        }

                        output[rowIndex, ind++] = GetValueOfField(item, field);
                    }

                    string commentValue = GetValueOfField(item, commentFieldName).ToString().Trim().Replace('\n', '\t');
                    output[rowIndex + 1, 1] = commentValue;

                    rowIndex += 2;
                    recordIndex++;
                }

                return(output);
            }

            void ApplyDataFormatForSheet(Excel.Worksheet xlWorksheet, Excel.Range rangeToSetData, bool thisWorkSheetIsForPrint)
            {
                // -1 т.к. исключен столбец Комментарий
                // +1 т.к. первый столбец номер по порядку
                int countOfColumns = hasCommentColumn ? fieldsAndFormats.Count - 1 + 1 : fieldsAndFormats.Count + 1;

                callBack?.Invoke("установка формата данных");

                int rowIndex    = 2; // 1 - шапка таблицы
                int ind         = 1;
                int recordIndex = 1;

                foreach (T item in collection)
                {
                    rangeToSetData[rowIndex, 0 + 1].NumberFormat = "0";
                    ind = 1; // т.к. первый столбец номер по порядку
                    foreach (string field in fieldsAndFormats.Keys)
                    {
                        if (thisWorkSheetIsForPrint && field == commentFieldName)
                        {
                            continue;
                        }

                        try
                        {
                            object value = string.Empty;
                            if (string.IsNullOrWhiteSpace(fieldsAndFormats[field].ExcelFormat) == false)
                            {
                                string format = string.IsNullOrWhiteSpace(fieldsAndFormats[field].ExcelFormat) ? "General" : fieldsAndFormats[field].ExcelFormat;
                                rangeToSetData[rowIndex, 0 + 1 + ind].NumberFormat = format;
                            }
                            else if (string.IsNullOrWhiteSpace(fieldsAndFormats[field].ContentDisplayFormat) == false)
                            {
                                rangeToSetData[rowIndex, 0 + 1 + ind].NumberFormat = "General";
                            }
                        }
                        catch (Exception e)
                        {
#if DEBUG
                            App.ToDebug(e);
#endif
                        }
                        finally
                        {
                            ind++;
                        }
                    }

                    if (thisWorkSheetIsForPrint && hasCommentColumn)
                    {
                        // ячейка с номером по порядку
                        Excel.Range rng = rangeToSetData[rowIndex, 1];
                        rng = rng.Resize(2, 1);
                        rng.Merge();
                        rng.HorizontalAlignment = XlHAlign.xlHAlignLeft;
                        rng.VerticalAlignment   = XlVAlign.xlVAlignCenter;

                        // ячейка с комментарием
                        rng = rangeToSetData[rowIndex + 1, 2].Resize(1, countOfColumns - 1);
                        rng.Merge();
                        rng.WrapText     = true;
                        rng.NumberFormat = "@";

                        rng = rangeToSetData[rowIndex, 1].Resize(2, countOfColumns);
                        rng.BorderAround(XlLineStyle.xlContinuous, XlBorderWeight.xlThin, XlColorIndex.xlColorIndexAutomatic);

                        rng.Borders[XlBordersIndex.xlInsideHorizontal].LineStyle = XlLineStyle.xlDot;
                        rng.Borders[XlBordersIndex.xlInsideHorizontal].Weight    = XlBorderWeight.xlThin;
                        rng.Borders[XlBordersIndex.xlInsideHorizontal].Color     = utils.Color.ToDouble(System.Drawing.Color.Gray);

                        rng.Borders[XlBordersIndex.xlInsideVertical].LineStyle = XlLineStyle.xlDot;
                        rng.Borders[XlBordersIndex.xlInsideVertical].Weight    = XlBorderWeight.xlThin;
                        rng.Borders[XlBordersIndex.xlInsideVertical].Color     = utils.Color.ToDouble(System.Drawing.Color.Gray);

                        if (recordIndex % 2 == 0)
                        {
                            rng = rangeToSetData[rowIndex, 1].Resize(2, countOfColumns);
                            rng.Interior.Color = utils.Color.ToDouble(System.Drawing.Color.WhiteSmoke);
                        }

                        rowIndex += 2;
                    }
                    else
                    {
                        rowIndex++;
                    }

                    recordIndex++;
                }
            }

            void Process(object[,] outputData1, object[,] outputData2)
            {
                try
                {
                    callBack?.Invoke("создание книги MS Excel");

                    excelApplication = new Excel.Application
                    {
                        DisplayAlerts  = false,
                        ScreenUpdating = false,
                    };

                    utils = new NetOffice.OfficeApi.Tools.Contribution.CommonUtils(excelApplication);

                    xlWorkbook  = excelApplication.Workbooks.Add();
                    xlWorksheet = (Excel.Worksheet)xlWorkbook.Sheets[1];

                    Excel.Range all = xlWorksheet.Range("A1");

                    Excel.Range header = xlWorksheet.Range("A1");
                    header.WrapText = true;
                    header.Resize(1, numberOfColumns).Merge();
                    using (Excel.Font font = header.Font)
                    {
                        font.Size = 14;
                        font.Bold = true;
                    }

                    header.HorizontalAlignment = XlHAlign.xlHAlignCenter;
                    header.VerticalAlignment   = XlVAlign.xlVAlignCenter;

                    double oneRowHeight = (double)header.RowHeight;
                    int    rowsCount    = reportTitle.Split(new[] { Environment.NewLine }, StringSplitOptions.None).Length;
                    header.RowHeight = oneRowHeight * rowsCount * 1.1;

                    header.Value2 = reportTitle;

                    Excel.Range description = xlWorksheet.Range("A2");
                    description.Resize(1, numberOfColumns).Merge();
                    description.WrapText = true;
                    using (Excel.Font font = description.Font)
                    {
                        font.Size   = 12;
                        font.Italic = true;
                    }

                    description.HorizontalAlignment = XlHAlign.xlHAlignLeft;
                    description.VerticalAlignment   = XlVAlign.xlVAlignCenter;

                    oneRowHeight          = (double)description.RowHeight;
                    rowsCount             = reportDescription.Split(new[] { Environment.NewLine }, StringSplitOptions.None).Length;
                    description.RowHeight = oneRowHeight * rowsCount * 1.1;

                    description.Value2 = reportDescription;

                    callBack?.Invoke("настройка книги MS Excel");

                    if (hasCommentColumn)
                    {
                        // создание копии листа
                        xlWorksheet.Copy(xlWorksheet);
                        xlWorksheet       = (Excel.Worksheet)xlWorkbook.Sheets[1];
                        xlWorksheet2      = (Excel.Worksheet)xlWorkbook.Sheets[2];
                        xlWorksheet.Name  = "Данные";
                        xlWorksheet2.Name = "Для печати";

                        Excel.Range data2 = xlWorksheet2.Range("A3").Resize((2 * numberOfRows) + 1, numberOfColumns - 1);
                        data2.VerticalAlignment = VerticalAlignment.Center;
                        data2.NumberFormat      = "@";

                        data2.Value = outputData2;

                        ApplyDataFormatForSheet(xlWorksheet2, data2, true);

                        Excel.Range tableHeader = xlWorksheet2.Range("A3").Resize(1, numberOfColumns - 1);
                        tableHeader.WrapText = true;
                        using (Excel.Font font = tableHeader.Font)
                        {
                            font.Size = 12;
                            font.Bold = true;
                        }

                        header.HorizontalAlignment = XlHAlign.xlHAlignCenter;
                        header.VerticalAlignment   = XlVAlign.xlVAlignCenter;

                        tableHeader.Interior.Color = utils.Color.ToDouble(System.Drawing.Color.LightGray);
                        tableHeader.BorderAround(XlLineStyle.xlContinuous, XlBorderWeight.xlThin, XlColorIndex.xlColorIndexAutomatic);

                        tableHeader.Borders[XlBordersIndex.xlInsideHorizontal].LineStyle = XlLineStyle.xlDot;
                        tableHeader.Borders[XlBordersIndex.xlInsideHorizontal].Weight    = XlBorderWeight.xlThin;
                        tableHeader.Borders[XlBordersIndex.xlInsideHorizontal].Color     = utils.Color.ToDouble(System.Drawing.Color.Black);
                    }

                    Excel.Range data = xlWorksheet.Range("A3").Resize(numberOfRows + 1, numberOfColumns);
                    data.NumberFormat = "@";
                    data.Value        = outputData1;

                    ApplyDataFormatForSheet(xlWorksheet, data, false);

                    xlWorksheet.ListObjects.Add(XlListObjectSourceType.xlSrcRange, data,
                                                Type.Missing, XlYesNoGuess.xlYes, Type.Missing).Name = "DataTable";
                    xlWorksheet.ListObjects["DataTable"].TableStyle = "TableStyleMedium6";

                    SetupWorkSheet(xlWorksheet, numberOfColumns);

                    if (hasCommentColumn)
                    {
                        SetupWorkSheet(xlWorksheet2, numberOfColumns - 1);
                    }

                    callBack?.Invoke("сохранение книги MS Excel");
                    xlWorkbook.SaveAs(fileName);
                    xlWorkbook.Close(false);

                    callBack?.Invoke("завершение");

                    logger?.Info($"Export >> файл сформирован и сохранен: '{fileName}'");
                }
                catch (Exception e)
                {
                    exception = e;
#if DEBUG
                    App.ToDebug(e);
#endif
                    App.ShowError("Произошла ошибка:\n" + App.GetExceptionDetails(e));
                    return;
                }
                finally
                {
                    System.Threading.Thread.CurrentThread.CurrentCulture = defaultCulture;

                    excelApplication.Quit();
                    excelApplication.ScreenUpdating = true;
                    excelApplication.DisplayAlerts  = true;
                    if (exception != null)
                    {
                        if (excelApplication.Workbooks.Any())
                        {
                            foreach (Excel.Workbook workbook in excelApplication.Workbooks.Where(x => !x.IsDisposed))
                            {
                                workbook.Close(false, System.Reflection.Missing.Value, Missing.Value);
                                workbook.Dispose();
                            }
                        }

                        if (excelApplication.IsDisposed == false)
                        {
                            excelApplication.Quit();
                            excelApplication.Dispose();
                        }
                    }
                }
            }

            void SetupWorkSheet(Excel.Worksheet xlWorksheet, int numberOfColumns)
            {
                foreach (int i in Enumerable.Range(1, numberOfColumns))
                {
                    xlWorksheet.Columns[i].AutoFit();
                }

                Excel.PageSetup ps = xlWorksheet.PageSetup;
                ps.PaperSize      = XlPaperSize.xlPaperA4;
                ps.Orientation    = XlPageOrientation.xlLandscape;
                ps.Zoom           = false;
                ps.FitToPagesWide = 1;
                ps.FitToPagesTall = false;

                ps.PrintTitleRows = "$3:$3";

                ps.LeftMargin   = excelApplication.CentimetersToPoints(1.0);
                ps.RightMargin  = excelApplication.CentimetersToPoints(1.0);
                ps.TopMargin    = excelApplication.CentimetersToPoints(2.0);
                ps.BottomMargin = excelApplication.CentimetersToPoints(1.0);

                ps.HeaderMargin = excelApplication.CentimetersToPoints(0.6);
                ps.FooterMargin = excelApplication.CentimetersToPoints(0.6);

                ps.CenterHorizontally = true;
                ps.RightHeader        = DateTime.Now.ToString("D", defaultCulture);
                ps.CenterFooter       = "Страница &P / &N";
                ps.PrintArea          = xlWorksheet.Range("A1").Resize(numberOfRows + 3, numberOfColumns).Address;
            }

            void OpenCreatedWorkBook()
            {
                try
                {
                    callBack?.Invoke("открытие созданной книги MS Excel");

                    using System.Diagnostics.Process p = new System.Diagnostics.Process
                          {
                              StartInfo = new System.Diagnostics.ProcessStartInfo(fileName)
                              {
                                  UseShellExecute = true,
                              },
                          };
                    p.Start();

                    // System.Diagnostics.Process.Start(fileName);
                }
                catch (Exception e)
                {
#if DEBUG
                    App.ToDebug(e);
#endif
                    App.ShowError("Произошла ошибка при открытии файла:\n" + App.GetExceptionDetails(e));
                }
            }
        }
 public static List <T> GetFilteredData <T>(this ICollectionView collectionView)
 {
     return(collectionView.Cast <T>().ToList());
 }
		public void SelectAllItems(ICollectionView availableItemsCollectionView)
		{
			var itemVM = _returnItemVmFactory.GetViewModelInstance();
			itemVM.IsBulkReturn = true;

			var confirmation = new ConditionalConfirmation { Title = "Specify return reason".Localize(), Content = itemVM };

			ReturnItemConfirmRequest.Raise(confirmation, (x) =>
			{
				if (x.Confirmed)
				{
					var itemsList = new List<ReturnBuilder.ReturnLineItem>(availableItemsCollectionView.Cast<ReturnBuilder.ReturnLineItem>());

					foreach (var obj in itemsList)
					{
						ReturnBuilder.AddReturnItem(obj, obj.LineItem.Quantity, itemVM.SelectedReason);
					}
					OnPropertyChanged("ReturnTotal");
					OnIsValidChanged();
				}
			});

		}
Beispiel #12
0
 private void TxtFilter_KeyUp(object sender, System.Windows.Input.KeyEventArgs e)
 {
     ICollectionView view = CollectionViewSource.GetDefaultView(dgEmployees.ItemsSource);
     view.Refresh();
     StatusMessage = $"{view.Cast<EmployeeListedDTO>().Count()} medarbejdere vist.";
 }
        private static int GetNumberOfResults(ICollectionView _view)
        {
            Debug.Assert(_view != null);

            var items = _view.Cast<object>();
            Debug.Assert(items != null);

            return items.Count();
        }
Beispiel #14
0
 public static List <TResult> AsList <TResult>(this ICollectionView source)
 {
     return(source.Cast <TResult>().ToList());
 }
        public void SelectAllItems(ICollectionView availableItemsCollectionView)
        {
            var itemsList = availableItemsCollectionView.Cast <CatalogLanguageDisplay>().ToList();

            itemsList.ForEach(SelectItem);
        }
Beispiel #16
0
        private void updateFilteredCounters(ICollectionView filteredList)
        {
            if (filteredList != null)
            {
                IEnumerable<LogItem> fltList = filteredList.Cast<LogItem>();
                if (fltList != null)
                {
                    ItemsFilterCount = fltList.Count();

                    ItemsDebugFilterCount = (from it in fltList
                                             where it.Level.Equals("DEBUG", StringComparison.OrdinalIgnoreCase)
                                             select it).Count();

                    ItemsInfoFilterCount = (from it in fltList
                                            where it.Level.Equals("INFO", StringComparison.OrdinalIgnoreCase)
                                            select it).Count();

                    ItemsWarnFilterCount = (from it in fltList
                                            where it.Level.Equals("WARN", StringComparison.OrdinalIgnoreCase)
                                            select it).Count();

                    ItemsErrorFilterCount = (from it in fltList
                                             where it.Level.Equals("ERROR", StringComparison.OrdinalIgnoreCase)
                                             select it).Count();

                    ItemsFatalFilterCount = (from it in fltList
                                             where it.Level.Equals("FATAL", StringComparison.OrdinalIgnoreCase)
                                             select it).Count();
                }
            }
            else
            {
                ItemsFilterCount = 0;
                ItemsDebugFilterCount = 0;
                ItemsInfoFilterCount = 0;
                ItemsWarnFilterCount = 0;
                ItemsErrorFilterCount = 0;
                ItemsFatalFilterCount = 0;
            }
        }
		public void SelectAllItems(ICollectionView availableItemsCollectionView)
		{
			if (availableItemsCollectionView.SourceCollection is ICollection<StoreLanguageDisplay>)
			{
				var itemsList = availableItemsCollectionView.Cast<StoreLanguageDisplay>().ToList();
				itemsList.ForEach(x => SelectItem(x));
			}
			else if (availableItemsCollectionView.SourceCollection is ICollection<StoreCurrency>)
			{
				var itemsList = availableItemsCollectionView.Cast<StoreCurrency>();
				InnerItem.Currencies.Add(itemsList);
			}
			else if (availableItemsCollectionView.SourceCollection is ICollection<Store>)
			{
				availableItemsCollectionView.Cast<Store>().ToList().ForEach(x => SelectItem(x));
			}
		}
 public static int Count(this ICollectionView collectionView)
 {
     return(collectionView.Cast <object>().Count());
 }