Example #1
0
        /// <summary>
        /// Overrides specific theme colors in the window header
        /// </summary>
        /// <param name="window"></param>
        public static void SetThemeWindowOverride(MetroWindow window)
        {
            if (window == null)
            {
                return;
            }

            if (Configuration.ApplicationTheme == Themes.Dark)
            {
                var darkBrush = (SolidColorBrush)(new BrushConverter().ConvertFrom("#333333"));
                window.WindowTitleBrush          = darkBrush;
                window.NonActiveWindowTitleBrush = (Brush)window.FindResource("WhiteBrush");

                //App.Current.Resources["MenuSeparatorBorderBrush"] = darkBrush;
                window.BorderBrush = (SolidColorBrush) new BrushConverter().ConvertFrom("#999");
            }
            else
            {
                // Need to fix this to show the accent color when switching
                window.WindowTitleBrush          = (SolidColorBrush)window.FindResource("AccentColorBrush");
                window.NonActiveWindowTitleBrush = window.WindowTitleBrush;

                window.BorderBrush = (SolidColorBrush) new BrushConverter().ConvertFrom("#ccc");
            }
        }
Example #2
0
        /// <summary>
        /// Overrides specific theme colors in the window header
        /// </summary>
        /// <param name="window"></param>
        public static void SetThemeWindowOverride(MetroWindow window)
        {
            if (Configuration.ApplicationTheme == Themes.Dark)
            {
                if (window != null)
                {
                    window.WindowTitleBrush          = (SolidColorBrush)(new BrushConverter().ConvertFrom("#333333"));
                    window.NonActiveWindowTitleBrush = (Brush)window.FindResource("WhiteBrush");

                    var brush = App.Current.Resources["MenuSeparatorBorderBrush"] as SolidColorBrush;
                    App.Current.Resources["MenuSeparatorBorderBrush"] =
                        (SolidColorBrush) new BrushConverter().ConvertFrom("#333333");
                    brush = App.Current.Resources["MenuSeparatorBorderBrush"] as SolidColorBrush;
                }
            }
            //else
            //{
            //    if (window != null)
            //    {
            //        // Need to fix this to show the accent color when switching
            //        //window.WindowTitleBrush = (Brush)window.FindResource("WhiteBrush");
            //        //window.NonActiveWindowTitleBrush = (Brush)window.FindResource("WhiteBrush");
            //    }
            //}
        }
Example #3
0
        /// <summary>
        /// Track processing with dialog
        /// </summary>
        /// <param name="filespaths">List of string</param>
        public static async Task TrackProcess(MetroWindow window, List <string> filespaths)
        {
            // Call ProgressDialog
            var processDialog = await window.ShowProgressAsync(
                window.FindResource("pleaseWait").ToString(), window.FindResource("trackProcessing").ToString());

            processDialog.SetIndeterminate();

            await Task.Run(() =>
            {
                // Parallel for loop, with maximun of degree is the number of processors
                Parallel.For(0, filespaths.Count, new ParallelOptions {
                    MaxDegreeOfParallelism = Environment.ProcessorCount
                }, (int i) =>
                {
                    using (var dc = new MusicDBDataContext(Properties.Settings.Default.MusicConnectionString))
                    {
                        // Thread sleep
                        //Thread.Sleep(new Random().Next(50, 500));

                        // Only handle file with extension is M4A or MP3
                        string ext = System.IO.Path.GetExtension(filespaths[i]).ToUpperInvariant();
                        if (ext == ".M4A" || ext == ".MP3")
                        {
                            Writer.ImportTrack2Database(dc, Reader.GetBasicTrack(filespaths[i]));
                        }
                    }
                });

                // One way processing

                //for (int i = 0; i < filespaths.Count; i++)
                //{
                //    using (var dc = new MusicDBDataContext(Properties.Settings.Default.MusicConnectionString))
                //    {
                //        string ext = System.IO.Path.GetExtension(filespaths[i]).ToUpperInvariant();
                //        if (ext == ".M4A" || ext == ".MP3")
                //        {
                //            //Track _track = Reader.GetBasicTrack(filespaths[i]);
                //            Writer.ImportTrack2Database(dc, Reader.GetBasicTrack(filespaths[i]));
                //        }
                //    }
                //}
            });

            await processDialog.CloseAsync();
        }
Example #4
0
        /// <summary>
        /// Delete unexist track
        /// </summary>
        /// <param name="_window"></param>
        /// <param name="_track"></param>
        public static async void DeleteUnTrack(MetroWindow _window, Track _track)
        {
            // Show comfirm message dialog
            MessageDialogResult result = await _window.ShowMessageAsync
                                             (_window.FindResource("attention").ToString(), _window.FindResource("trackDoesNotExist.Deletet?").ToString(), MessageDialogStyle.AffirmativeAndNegative, null);

            // If return affirmative then clean db
            if (result == MessageDialogResult.Affirmative)
            {
                Updater.DeleteOneTrack(_track);
            }
        }
Example #5
0
        //private const string PART_AffirmativeButton = "PART_AffirmativeButton";
        //private const string PART_NegativeButton = "PART_NegativeButton";

        //private Button AffirmativeButton = null;
        //private Button NegativeButton = null;

        //static MessageDialog()
        //{
        //    //DefaultStyleKeyProperty.OverrideMetadata(typeof(MessageDialog), new FrameworkPropertyMetadata(typeof(MessageDialog)));
        //}
        internal ProgressDialog(MetroWindow parentWindow, MetroDialogSettings settings)
            : base(parentWindow, settings)
        {
            InitializeComponent();

            if (parentWindow.MetroDialogOptions.ColorScheme == MetroDialogColorScheme.Theme)
            {
                try
                {
                    ProgressBarForeground = parentWindow.FindResource("AccentColorBrush") as Brush;
                }
                catch (Exception) { }
            }
            else
                ProgressBarForeground = Brushes.White;
        }
        //private const string PART_AffirmativeButton = "PART_AffirmativeButton";
        //private const string PART_NegativeButton = "PART_NegativeButton";

        //private Button AffirmativeButton = null;
        //private Button NegativeButton = null;

        //static MessageDialog()
        //{
        //    //DefaultStyleKeyProperty.OverrideMetadata(typeof(MessageDialog), new FrameworkPropertyMetadata(typeof(MessageDialog)));
        //}
        internal ProgressDialog(MetroWindow parentWindow, MetroDialogSettings settings)
            : base(parentWindow, settings)
        {
            InitializeComponent();

            if (parentWindow.MetroDialogOptions.ColorScheme == MetroDialogColorScheme.Theme)
            {
                try
                {
                    ProgressBarForeground = parentWindow.FindResource("AccentColorBrush") as Brush;
                }
                catch (Exception) { }
            }
            else
            {
                ProgressBarForeground = Brushes.White;
            }
        }
        public void GetData(UIResult result, MetroWindow window)
        {
            _window       = window;
            _window.Title = $"{result.Name} 结果";

            var value = WebAPI.Instance.GetMixedResult(result.TaskID);

            if (!value.Item1)
            {
                if (value.Item3.IndexOf("签名非法") != -1)
                {
                    if (SignLogic.SignCheck())
                    {
                        value = WebAPI.Instance.GetMixedResult(result.TaskID);
                    }
                }
            }

            if (value.Item1)
            {
                // 获取模型
                var model = value.Item2;

                // 结果班级
                _resultClasses = model.ResultClasses?.ToList();

                // 走班模型
                var cl = CommonDataManager.GetCLCase(base.LocalID);

                // 课时详细
                var details = (from c in model.ResultClasses
                               from rc in c.ResultDetails
                               select new
                {
                    c.ClassID,
                    rc.ClassHourId,
                    rc.DayPeriod
                });

                List <UITeacher> teachers = new List <UITeacher>();

                foreach (var rc in model.ResultClasses)
                {
                    var classModel = cl.GetClassByID(rc.ClassID);

                    if (rc.ResultDetails != null)
                    {
                        foreach (var rd in rc.ResultDetails)
                        {
                            Button rb = new Button();
                            rb.Style      = (Style)window.FindResource("ItemStyle");
                            rb.Background = this.GetRandomColor(classModel.CourseID);
                            rb.Click     += Rb_Click;
                            rb.Content    = classModel.Display;
                            rb.Opacity    = 0.9;
                            rb.FontSize   = 13;
                            rb.Margin     = new System.Windows.Thickness(2);

                            var position = this.Results.FirstOrDefault(r => r.Period.Period == rd.DayPeriod.Period);
                            if (position != null)
                            {
                                if (rd.DayPeriod.Day == DayOfWeek.Friday)
                                {
                                    position.Fridays.Add(rb);
                                }
                                else if (rd.DayPeriod.Day == DayOfWeek.Thursday)
                                {
                                    position.Thursdays.Add(rb);
                                }
                                else if (rd.DayPeriod.Day == DayOfWeek.Wednesday)
                                {
                                    position.Wednesdays.Add(rb);
                                }
                                else if (rd.DayPeriod.Day == DayOfWeek.Tuesday)
                                {
                                    position.Tuesdays.Add(rb);
                                }
                                else if (rd.DayPeriod.Day == DayOfWeek.Monday)
                                {
                                    position.Mondays.Add(rb);
                                }
                                else if (rd.DayPeriod.Day == DayOfWeek.Saturday)
                                {
                                    position.Saturdays.Add(rb);
                                }
                                else if (rd.DayPeriod.Day == DayOfWeek.Sunday)
                                {
                                    position.Sundays.Add(rb);
                                }
                            }

                            _buttons.Add(rb);
                        }
                    }

                    #region 获取教师信息

                    var classHourIDs = from c in details select c.ClassHourId;
                    var classHours   = cl.GetClassHours(classHourIDs?.ToArray());
                    classHours?.ForEach(ch =>
                    {
                        ch.Teachers.ForEach(t =>
                        {
                            var teacher = teachers.FirstOrDefault(tt => tt.ID.Equals(t.ID));
                            if (teacher == null)
                            {
                                teachers.Add(new UITeacher()
                                {
                                    ID           = t.ID,
                                    Name         = t.Name,
                                    ClassHourIDs = new List <int> {
                                        ch.ID
                                    }
                                });
                            }
                            else
                            {
                                var has = teacher.ClassHourIDs.Contains(ch.ID);
                                if (!has)
                                {
                                    teacher.ClassHourIDs.Add(ch.ID);
                                }
                            }
                        });
                    });

                    #endregion
                }

                this.Teachers      = teachers;
                this.SelectTeacher = teachers.FirstOrDefault();
            }
        }