private void BtnSwitchView_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                AppSettings.DisplaySeriesSimple = false;
                // check if this control is part of the series container
                DependencyObject parentObject = VisualTreeHelper.GetParent(this);
                while (parentObject != null)
                {
                    parentObject = VisualTreeHelper.GetParent(parentObject);
                    AnimeSeriesContainerControl containerCtrl = parentObject as AnimeSeriesContainerControl;
                    if (containerCtrl != null)
                    {
                        // show the full view
                        AnimeSeriesVM ser = this.DataContext as AnimeSeriesVM;
                        if (ser == null)
                        {
                            return;
                        }

                        AnimeSeries seriesControl = new AnimeSeries();
                        seriesControl.DataContext = ser;

                        containerCtrl.DataContext = seriesControl;
                        return;
                    }
                }
            }
            catch (Exception ex)
            {
                Utils.ShowErrorMessage(ex);
            }
        }
Exemplo n.º 2
0
        public void ShowPinnedSeries(AnimeSeriesVM series, bool isMetroDash = false)
        {
            this.Cursor = Cursors.Wait;

            CloseableTabItem cti = new CloseableTabItem();
            //TabItem cti = new TabItem();

            // if the pinned tab already has this, don't open it again.
            int curTab = -1;
            foreach (object obj in tabPinned.Items)
            {
                curTab++;
                CloseableTabItem ctiTemp = obj as CloseableTabItem;
                if (ctiTemp == null) continue;

                AnimeSeriesVM ser = null;
                ContentControl ctrl = ctiTemp.Content as AnimeSeriesContainerControl;
                if (ctrl == null)
                {
                    ContentControl subControl = ctrl.Content as AnimeSeriesSimplifiedControl;
                    if (subControl == null)
                        subControl = ctrl.Content as AnimeSeries;

                    if (subControl != null)
                        ctrl = subControl;
                }
                else
                {
                    ContentControl subControl = ctrl.DataContext as AnimeSeriesSimplifiedControl;
                    if (subControl == null)
                        subControl = ctrl.DataContext as AnimeSeries;

                    if (subControl != null)
                        ctrl = subControl;
                }

                if (ctrl == null)
                    continue;

                ser = ctrl.DataContext as AnimeSeriesVM;
                if (ser == null) continue;

                if (ser.AnimeSeriesID == series.AnimeSeriesID)
                {
                    tabControl1.SelectedIndex = TAB_MAIN_Pinned;
                    tabPinned.SelectedIndex = curTab;
                    this.Cursor = Cursors.Arrow;
                    return;
                }
            }

            string tabHeader = series.SeriesName;
            if (tabHeader.Length > 30)
                tabHeader = tabHeader.Substring(0, 30) + "...";
            cti.Header = tabHeader;

            if (AppSettings.DisplaySeriesSimple)
            {
                AnimeSeriesSimplifiedControl ctrl = new AnimeSeriesSimplifiedControl();
                ctrl.DataContext = series;

                AnimeSeriesContainerControl cont = new AnimeSeriesContainerControl();
                cont.IsMetroDash = false;
                cont.DataContext = ctrl;

                cti.Content = cont;

                tabPinned.Items.Add(cti);
            }
            else
            {
                AnimeSeries seriesControl = new AnimeSeries();
                seriesControl.DataContext = series;

                AnimeSeriesContainerControl cont = new AnimeSeriesContainerControl();
                cont.IsMetroDash = false;
                cont.DataContext = seriesControl;

                cti.Content = cont;

                tabPinned.Items.Add(cti);
            }

            tabControl1.SelectedIndex = TAB_MAIN_Pinned;
            tabPinned.SelectedIndex = tabPinned.Items.Count - 1;

            this.Cursor = Cursors.Arrow;
        }
Exemplo n.º 3
0
        private void SetDetailBinding(object objToBind)
        {
            try
            {
                //BindingOperations.ClearBinding(ccDetail, ContentControl.ContentProperty);

                if (objToBind != null && objToBind.GetType().Equals(typeof(AnimeSeriesVM)))
                {
                    AnimeSeriesVM ser = objToBind as AnimeSeriesVM;
                    if (AppSettings.DisplaySeriesSimple)
                    {
                        AnimeSeriesSimplifiedControl ctrl = new AnimeSeriesSimplifiedControl();
                        ctrl.DataContext = ser;

                        AnimeSeriesContainerControl cont = new AnimeSeriesContainerControl();
                        cont.IsMetroDash = false;
                        cont.DataContext = ctrl;

                        objToBind = cont;
                    }
                    else
                    {
                        AnimeSeries ctrl = new AnimeSeries();
                        ctrl.DataContext = ser;

                        AnimeSeriesContainerControl cont = new AnimeSeriesContainerControl();
                        cont.IsMetroDash = false;
                        cont.DataContext = ctrl;

                        objToBind = cont;
                    }
                }

                Binding b = new Binding();
                b.Source = objToBind;
                b.UpdateSourceTrigger = UpdateSourceTrigger.Explicit;
                ccDetail.SetBinding(ContentControl.ContentProperty, b);
            }
            catch (Exception ex)
            {
                Utils.ShowErrorMessage(ex);
            }
        }