示例#1
0
 public DependencyObject GetParent(DependencyObject element)
 {
     return(LogicalTreeHelper.GetParent(element));
 }
示例#2
0
        public SetEpgView()
        {
            InitializeComponent();

            try
            {
                textBox_mouse_scroll.Text            = Settings.Instance.ScrollSize.ToString();
                textBox_service_width.Text           = Settings.Instance.ServiceWidth.ToString();
                textBox_minHeight.Text               = Settings.Instance.MinHeight.ToString();
                textBox_dragScroll.Text              = Settings.Instance.DragScroll.ToString();
                textBox_minimumHeight.Text           = Settings.Instance.MinimumHeight.ToString();
                checkBox_epg_popup.IsChecked         = Settings.Instance.EpgPopup;
                checkBox_epg_popup_resOnly.IsEnabled = Settings.Instance.EpgPopup;
                checkBox_epg_popup_resOnly.IsChecked = Settings.Instance.EpgPopupResOnly;
                checkBox_title_indent.IsChecked      = Settings.Instance.EpgTitleIndent;
                checkBox_singleOpen.IsChecked        = Settings.Instance.EpgInfoSingleClick;
                checkBox_scrollAuto.IsChecked        = Settings.Instance.MouseScrollAuto;
                checkBox_gradation.IsChecked         = Settings.Instance.EpgGradation;
                checkBox_gradationHeader.IsChecked   = Settings.Instance.EpgGradationHeader;

                checkBox_openInfo.IsChecked            = (Settings.Instance.EpgInfoOpenMode != 0);
                checkBox_displayNotifyChange.IsChecked = Settings.Instance.DisplayNotifyEpgChange;
                checkBox_reserveBackground.IsChecked   = Settings.Instance.ReserveRectBackground;

                textBox_tuner_mouse_scroll.Text            = Settings.Instance.TunerScrollSize.ToString();
                textBox_tuner_width.Text                   = Settings.Instance.TunerWidth.ToString();
                textBox_tuner_minHeight.Text               = Settings.Instance.TunerMinHeight.ToString();
                textBox_tunerDdragScroll.Text              = Settings.Instance.TunerDragScroll.ToString();
                textBox_tunerMinLineHeight.Text            = Settings.Instance.TunerMinimumLine.ToString();
                checkBox_tuner_popup.IsChecked             = Settings.Instance.TunerPopup;
                checkBox_tuner_popup_recInfo.IsEnabled     = Settings.Instance.TunerPopup;
                checkBox_tuner_popup_recInfo.IsChecked     = Settings.Instance.TunerPopupRecinfo;
                checkBox_tuner_title_indent.IsChecked      = Settings.Instance.TunerTitleIndent;
                checkBox_tunerSingleOpen.IsChecked         = Settings.Instance.TunerInfoSingleClick;
                checkBox_tuner_scrollAuto.IsChecked        = Settings.Instance.TunerMouseScrollAuto;
                checkBox_tuner_service_nowrap.IsChecked    = Settings.Instance.TunerServiceNoWrap;
                checkBox_tunerColorModeUse.IsChecked       = Settings.Instance.TunerColorModeUse;
                comboBox_tunerFontColorService.IsEnabled   = !Settings.Instance.TunerColorModeUse;
                button_tunerFontCustColorService.IsEnabled = !Settings.Instance.TunerColorModeUse;
                checkBox_tuner_display_offres.IsChecked    = Settings.Instance.TunerDisplayOffReserve;

                var bx = new BoxExchangeEditor(null, this.listBox_tab, true, true, true);
                bx.targetBoxAllowDoubleClick(bx.TargetBox, (sender, e) => button_tab_chg.RaiseEvent(new RoutedEventArgs(Button.ClickEvent)));
                button_tab_del.Click    += new RoutedEventHandler(bx.button_Delete_Click);
                button_tab_up.Click     += new RoutedEventHandler(bx.button_Up_Click);
                button_tab_down.Click   += new RoutedEventHandler(bx.button_Down_Click);
                button_tab_top.Click    += new RoutedEventHandler(bx.button_Top_Click);
                button_tab_bottom.Click += new RoutedEventHandler(bx.button_Bottom_Click);

                radioButton_1_def.IsChecked  = (Settings.Instance.UseCustomEpgView == false);
                radioButton_1_cust.IsChecked = (Settings.Instance.UseCustomEpgView != false);

                listBox_tab.Items.AddItems(Settings.Instance.CustomEpgTabList);
                if (listBox_tab.Items.Count > 0)
                {
                    listBox_tab.SelectedIndex = 0;
                }

                XmlLanguage   FLanguage = XmlLanguage.GetLanguage("ja-JP");
                List <string> fontList  = Fonts.SystemFontFamilies
                                          .Where(f => f.FamilyNames.ContainsKey(FLanguage) == true)
                                          .Select(f => f.FamilyNames[FLanguage]).ToList();

                var setCmboFont = new Action <string, ComboBox>((name, cmb) =>
                {
                    cmb.ItemsSource  = fontList;
                    cmb.SelectedItem = name;
                    if (cmb.SelectedItem == null)
                    {
                        cmb.SelectedIndex = 0;
                    }
                });
                setCmboFont(Settings.Instance.FontNameTitle, comboBox_fontTitle);
                setCmboFont(Settings.Instance.FontName, comboBox_font);
                setCmboFont(Settings.Instance.TunerFontNameService, comboBox_fontTunerService);
                setCmboFont(Settings.Instance.TunerFontName, comboBox_fontTuner);

                textBox_fontSize.Text                   = Settings.Instance.FontSize.ToString();
                textBox_fontSizeTitle.Text              = Settings.Instance.FontSizeTitle.ToString();
                checkBox_fontBoldTitle.IsChecked        = Settings.Instance.FontBoldTitle;
                textBox_fontTunerSize.Text              = Settings.Instance.TunerFontSize.ToString();
                textBox_fontTunerSizeService.Text       = Settings.Instance.TunerFontSizeService.ToString();
                checkBox_fontTunerBoldService.IsChecked = Settings.Instance.TunerFontBoldService;

                var colorReference = ColorDef.ColorTable.ToDictionary
                                         (item => item.Key, item => new ColorReferenceViewItem(item.Key, item.Value));
                colorReference["カスタム"] = new ColorReferenceViewItem("カスタム", this.Resources["HatchBrush"] as VisualBrush);

                var setComboColor1 = new Action <string, ComboBox>((name, cmb) =>
                {
                    cmb.ItemsSource  = colorReference.Values;
                    cmb.SelectedItem = colorReference.ContainsKey(name) ? colorReference[name] : colorReference["カスタム"];
                });
                var setButtonColor1 = new Action <uint, Button>((clr, btn) => btn.Background = new SolidColorBrush(ColorDef.FromUInt(clr)));
                var setColors       = new Action <UIElement, List <string>, List <uint> >((ui, stockColors, custColors) =>
                {
                    List <UIElement> uiList = new List <UIElement>();
                    uiList.Add(ui);
                    for (int n = 0; n < uiList.Count; n++)
                    {
                        foreach (var child in LogicalTreeHelper.GetChildren(uiList[n]))
                        {
                            if (child is Control)
                            {
                                int index = int.Parse((string)(child as Control).Tag ?? "-1");
                                if (index >= 0)
                                {
                                    if (child is ComboBox && index < stockColors.Count)
                                    {
                                        setComboColor1(stockColors[index], child as ComboBox);
                                    }
                                    else if (child is Button && index < custColors.Count)
                                    {
                                        setButtonColor1(custColors[index], child as Button);
                                    }
                                }
                            }
                            else if (child is UIElement)
                            {
                                uiList.Add(child as UIElement);
                            }
                        }
                    }
                });

                //番組表のフォント色と予約枠色はSettingsが個別のため個別処理。
                //これをまとめて出来るようにSettingsを変えると以前の設定が消える。
                // [番組表] - [基本]
                setComboColor1(Settings.Instance.TitleColor1, comboBox_colorTitle1);
                setButtonColor1(Settings.Instance.TitleCustColor1, button_colorTitle1);
                setComboColor1(Settings.Instance.TitleColor2, comboBox_colorTitle2);
                setButtonColor1(Settings.Instance.TitleCustColor2, button_colorTitle2);
                // [番組表] - [色1]
                setColors(groupEpgColors, Settings.Instance.ContentColorList, Settings.Instance.ContentCustColorList);
                setComboColor1(Settings.Instance.ReserveRectColorNormal, comboBox_reserveNormal);
                setComboColor1(Settings.Instance.ReserveRectColorNo, comboBox_reserveNo);
                setComboColor1(Settings.Instance.ReserveRectColorNoTuner, comboBox_reserveNoTuner);
                setComboColor1(Settings.Instance.ReserveRectColorWarning, comboBox_reserveWarning);
                setComboColor1(Settings.Instance.ReserveRectColorAutoAddMissing, comboBox_reserveAutoAddMissing);
                setColors(groupEpgColorsReserve, null, Settings.Instance.ContentCustColorList);
                // [番組表] - [色2]
                setColors(groupEpgTimeColors, Settings.Instance.EpgEtcColors, Settings.Instance.EpgEtcCustColors);
                setColors(groupEpgEtcColors, Settings.Instance.EpgEtcColors, Settings.Instance.EpgEtcCustColors);

                // [使用予定チューナー] - [基本]
                setColors(groupTunerFontColor, Settings.Instance.TunerServiceColors, Settings.Instance.TunerServiceCustColors);
                // [使用予定チューナー] - [色]
                setColors(groupTunerColors, Settings.Instance.TunerServiceColors, Settings.Instance.TunerServiceCustColors);

                // [録画済み一覧]
                checkBox_playDClick.IsChecked       = Settings.Instance.PlayDClick;
                checkBox_recNoYear.IsChecked        = Settings.Instance.RecInfoNoYear;
                checkBox_recNoSecond.IsChecked      = Settings.Instance.RecInfoNoSecond;
                checkBox_recNoDurSecond.IsChecked   = Settings.Instance.RecInfoNoDurSecond;
                checkBox_ChacheOn.IsChecked         = Settings.Instance.RecInfoExtraDataCache;
                checkBox_CacheOptimize.IsChecked    = Settings.Instance.RecInfoExtraDataCacheOptimize;
                checkBox_CacheKeepConnect.IsChecked = Settings.Instance.RecInfoExtraDataCacheKeepConnect;
                if (CommonManager.Instance.NWMode == false)
                {
                    checkBox_CacheKeepConnect.IsEnabled = false;//{Binding}を破棄しているので注意
                }
                textBox_dropErrIgnore.Text             = Settings.Instance.RecInfoDropErrIgnore.ToString();
                textBox_dropWrnIgnore.Text             = Settings.Instance.RecInfoDropWrnIgnore.ToString();
                textBox_scrambleIgnore.Text            = Settings.Instance.RecInfoScrambleIgnore.ToString();
                checkBox_recinfo_errCritical.IsChecked = Settings.Instance.RecinfoErrCriticalDrops;
                setColors(groupRecInfoBackColors, Settings.Instance.RecEndColors, Settings.Instance.RecEndCustColors);

                // [予約一覧・共通] - [基本]
                this.ctxmSetInfo = Settings.Instance.MenuSet.Clone();
                checkBox_displayAutoAddMissing.IsChecked = Settings.Instance.DisplayReserveAutoAddMissing;
                textBox_DisplayJumpTime.Text             = Settings.Instance.DisplayNotifyJumpTime.ToString();
                checkBox_resNoYear.IsChecked             = Settings.Instance.ResInfoNoYear;
                checkBox_resNoSecond.IsChecked           = Settings.Instance.ResInfoNoSecond;
                checkBox_resNoDurSecond.IsChecked        = Settings.Instance.ResInfoNoDurSecond;
                checkBox_LaterTimeUse.IsChecked          = Settings.Instance.LaterTimeUse;
                textBox_LaterTimeHour.Text = (Settings.Instance.LaterTimeHour + 24).ToString();
                checkBox_displayPresetOnSearch.IsChecked        = Settings.Instance.DisplayPresetOnSearch;
                checkBox_nekopandaToolTip.IsChecked             = Settings.Instance.RecItemToolTip;
                checkBox_displayStatus.IsChecked                = Settings.Instance.DisplayStatus;
                checkBox_displayStatusNotify.IsChecked          = Settings.Instance.DisplayStatusNotify;
                checkBox_IsVisibleReserveView.IsChecked         = Settings.Instance.IsVisibleReserveView;
                checkBox_IsVisibleRecInfoView.IsChecked         = Settings.Instance.IsVisibleRecInfoView;
                checkBox_IsVisibleAutoAddView.IsChecked         = Settings.Instance.IsVisibleAutoAddView;
                checkBox_IsVisibleAutoAddViewMoveOnly.IsChecked = Settings.Instance.IsVisibleAutoAddViewMoveOnly;

                foreach (var item in new Dictionary <object, string> {
                    { CtxmCode.ReserveView, "予約一覧" }, { CtxmCode.TunerReserveView, "使用予定チューナ" },
                    { CtxmCode.RecInfoView, "録画済み一案" }, { CtxmCode.EpgAutoAddView, "キーワード予約登録" },
                    { CtxmCode.ManualAutoAddView, "プログラム予約登録" }, { CtxmCode.EpgView, "番組表" }
                })
                {
                    wrapPanel_StartTab.Children.Add(new RadioButton {
                        Tag = item.Key, Content = item.Value
                    });
                }
                var rbtn = wrapPanel_StartTab.Children.OfType <RadioButton>()
                           .FirstOrDefault(item => item.Tag as CtxmCode? == Settings.Instance.StartTab);
                if (rbtn != null)
                {
                    rbtn.IsChecked = true;
                }

                foreach (var item in new Dictionary <object, string> {
                    { Dock.Bottom, "下" }, { Dock.Top, "上" }, { Dock.Left, "左" }, { Dock.Right, "右" }
                })
                {
                    wrapPanel_MainViewButtonsDock.Children.Add(new RadioButton {
                        Tag = item.Key, Content = item.Value
                    });
                }
                rbtn = wrapPanel_MainViewButtonsDock.Children.OfType <RadioButton>()
                       .FirstOrDefault(item => item.Tag as Dock? == Settings.Instance.MainViewButtonsDock);
                if (rbtn != null)
                {
                    rbtn.IsChecked = true;
                }

                InitializeStyleList();

                // [予約一覧・共通] - [色]
                setComboColor1(Settings.Instance.ListDefColor, cmb_ListDefFontColor);
                setButtonColor1(Settings.Instance.ListDefCustColor, btn_ListDefFontColor);
                setColors(groupReserveRecModeColors, Settings.Instance.RecModeFontColors, Settings.Instance.RecModeFontCustColors);
                setColors(groupReserveBackColors, Settings.Instance.ResBackColors, Settings.Instance.ResBackCustColors);
                setColors(groupStatColors, Settings.Instance.StatColors, Settings.Instance.StatCustColors);

                // [予約簡易表示]
                textBox_iw_refresh_interval.Text       = Settings.Instance.InfoWindowRefreshInterval.ToString();
                radioButton_iw_based_on_bcst.IsChecked = Settings.Instance.InfoWindowBasedOnBroadcast;
                radioButton_iw_based_on_rec.IsChecked  = !Settings.Instance.InfoWindowBasedOnBroadcast;
                switch (Settings.Instance.InfoWindowItemFilterLevel)
                {
                default: radioButton_All.IsChecked = true; break;

                case 1: radioButton_Level1.IsChecked = true; break;

                case 2: radioButton_Level2.IsChecked = true; break;

                case 3: radioButton_Level3.IsChecked = true; break;

                case int.MaxValue: radioButton_TopN.IsChecked = true; break;
                }
                switch (Settings.Instance.InfoWindowItemProgressBarType)
                {
                default: radioButton_ProgressBarOff.IsChecked = true; break;

                case 1: radioButton_ProgressBarType1.IsChecked = true; break;

                case 2: radioButton_ProgressBarType2.IsChecked = true; break;
                }
                setColors(groupInfoWinItemProgressBarColors, Settings.Instance.InfoWindowItemProgressBarColors, Settings.Instance.InfoWindowItemProgressBarCustColors);
                checkBox_bgTransparent.IsChecked = Settings.Instance.InfoWindowItemProgressBarTransparent;
                textBox_TopN.Text           = Settings.Instance.InfoWindowItemTopN.ToString();
                textBox_iw_item_level1.Text = (Settings.Instance.InfoWindowItemLevel1Seconds / 60.0).ToString();
                textBox_iw_item_level2.Text = (Settings.Instance.InfoWindowItemLevel2Seconds / 60.0).ToString();
                textBox_iw_item_level3.Text = (Settings.Instance.InfoWindowItemLevel3Seconds / 60.0).ToString();
                setColors(groupInfoWinItemBgColors, Settings.Instance.InfoWindowItemBgColors, Settings.Instance.InfoWindowItemBgCustColors);
            }
            catch (Exception ex) { MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace); }
        }
示例#3
0
        private static void OnBusyStateChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            bool isBusy  = (bool)e.NewValue;
            bool wasBusy = (bool)e.OldValue;

            if (isBusy == wasBusy)
            {
                return;
            }

            var hostGridObject = (GetTargetVisual(d) ?? d);

            Debug.Assert(hostGridObject != null);

            var hostGrid = hostGridObject as Grid;

            if (hostGrid == null)
            {
                throw new InvalidCastException(
                          string.Format(
                              "The object being attached to must be of type {0}. Try embedding your visual inside a {0} control, and attaching the behavior to the {0} instead.",
                              typeof(Grid).Name));
            }

            if (isBusy)
            {
                Debug.Assert(LogicalTreeHelper.FindLogicalNode(hostGrid, "BusyIndicator") == null);

                bool dimBackground = GetDimBackground(d);
                var  grid          = new Grid
                {
                    Name    = "BusyIndicator",
                    Opacity = 0.0
                };
                if (dimBackground)
                {
                    grid.Cursor      = Cursors.Wait;
                    grid.ForceCursor = true;

                    InputManager.Current.PreProcessInput += OnPreProcessInput;
                }
                grid.SetBinding(FrameworkElement.WidthProperty, new Binding("ActualWidth")
                {
                    Source = hostGrid
                });
                grid.SetBinding(FrameworkElement.HeightProperty, new Binding("ActualHeight")
                {
                    Source = hostGrid
                });
                for (int i = 1; i <= 3; ++i)
                {
                    if (i != 2)
                    {
                        grid.ColumnDefinitions.Add(new ColumnDefinition
                        {
                            Width = new GridLength(1, GridUnitType.Star)
                        });
                        grid.RowDefinitions.Add(new RowDefinition
                        {
                            Height = new GridLength(1, GridUnitType.Star)
                        });
                    }
                    else
                    {
                        grid.ColumnDefinitions.Add(new ColumnDefinition
                        {
                            Width    = new GridLength(1, GridUnitType.Star),
                            MaxWidth = 120.0
                        });
                        grid.RowDefinitions.Add(new RowDefinition
                        {
                            Height    = new GridLength(1, GridUnitType.Star),
                            MaxHeight = 120.0
                        });
                    }
                }

                var viewbox = new Viewbox
                {
                    HorizontalAlignment = HorizontalAlignment.Center,
                    Stretch             = Stretch.Uniform,
                    StretchDirection    = StretchDirection.Both,
                    Child = new CircularProgressBar()
                };
                grid.SetValue(Panel.ZIndexProperty, 1000);
                grid.SetValue(Grid.RowSpanProperty, Math.Max(1, hostGrid.RowDefinitions.Count));
                grid.SetValue(Grid.ColumnSpanProperty, Math.Max(1, hostGrid.ColumnDefinitions.Count));
                if (GetAddMargins(d))
                {
                    viewbox.SetValue(Grid.RowProperty, 1);
                    viewbox.SetValue(Grid.ColumnProperty, 1);
                }
                else
                {
                    viewbox.SetValue(Grid.RowSpanProperty, 3);
                    viewbox.SetValue(Grid.ColumnSpanProperty, 3);
                }
                viewbox.SetValue(Panel.ZIndexProperty, 1);

                var dimmer = new Rectangle
                {
                    Name       = "Dimmer",
                    Opacity    = GetDimmerOpacity(d),
                    Fill       = GetDimmerBrush(d),
                    Visibility = (dimBackground ? Visibility.Visible : Visibility.Collapsed)
                };
                dimmer.SetValue(Grid.RowSpanProperty, 3);
                dimmer.SetValue(Grid.ColumnSpanProperty, 3);
                dimmer.SetValue(Panel.ZIndexProperty, 0);
                grid.Children.Add(dimmer);

                grid.Children.Add(viewbox);

                grid.BeginAnimation(UIElement.OpacityProperty, new DoubleAnimation(1.0, GetDimTransitionDuration(d)));

                hostGrid.Children.Add(grid);
            }
            else
            {
                var grid = (Grid)LogicalTreeHelper.FindLogicalNode(hostGrid, "BusyIndicator");

                Debug.Assert(grid != null);

                if (grid != null)
                {
                    grid.Name = string.Empty;

                    var fadeOutAnimation = new DoubleAnimation(0.0, GetDimTransitionDuration(d));
                    fadeOutAnimation.Completed += (sender, args) => OnFadeOutAnimationCompleted(d, hostGrid, grid);
                    grid.BeginAnimation(UIElement.OpacityProperty, fadeOutAnimation);
                }
            }
        }
示例#4
0
 //https://stackoverflow.com/a/4650392/3973863
 public static bool AllFieldsValid(this DependencyObject obj)
 => !Validation.GetHasError(obj) &&
 LogicalTreeHelper.GetChildren(obj)
 .OfType <DependencyObject>()
 .All(AllFieldsValid);
 public static T GetResource <T>(this DependencyObject element, object key)
 {
     for (var dependencyObject = element; dependencyObject != null; dependencyObject = (LogicalTreeHelper.GetParent(dependencyObject) ?? VisualTreeHelper.GetParent(dependencyObject)))
     {
         var frameworkElement = dependencyObject as FrameworkElement;
         if (frameworkElement != null)
         {
             if (frameworkElement.Resources.Contains(key))
             {
                 return((T)frameworkElement.Resources[key]);
             }
         }
         else
         {
             var frameworkContentElement = dependencyObject as FrameworkContentElement;
             if (frameworkContentElement != null && frameworkContentElement.Resources.Contains(key))
             {
                 return((T)frameworkContentElement.Resources[key]);
             }
         }
     }
     if (Application.Current != null && Application.Current.Resources.Contains(key))
     {
         return((T)Application.Current.Resources[key]);
     }
     return(default(T));
 }
示例#6
0
 internal virtual ResizingPanel GetContainerPanel()
 {
     return(LogicalTreeHelper.GetParent(this) as ResizingPanel);
 }
示例#7
0
        /// <summary>
        /// Retrieves the range of a child object.
        /// </summary>
        /// <param name="childElementProvider">The child element.  A provider should check that the
        /// passed element is a child of the text container, and should throw an
        /// InvalidOperationException if it is not.</param>
        /// <returns>A range that spans the child element.</returns>
        ITextRangeProvider ITextProvider.RangeFromChild(IRawElementProviderSimple childElementProvider)
        {
            if (childElementProvider == null)
            {
                throw new ArgumentNullException("childElementProvider");
            }

            // Retrieve DependencyObject from AutomationElement
            DependencyObject childElement;

            if (_textPeer is TextAutomationPeer)
            {
                childElement = ((TextAutomationPeer)_textPeer).ElementFromProvider(childElementProvider);
            }
            else
            {
                childElement = ((ContentTextAutomationPeer)_textPeer).ElementFromProvider(childElementProvider);
            }

            TextRangeAdaptor range = null;

            if (childElement != null)
            {
                ITextPointer rangeStart = null;
                ITextPointer rangeEnd   = null;

                // Retrieve start and end positions for given element.
                // If element is TextElement, retrieve its Element Start and End positions.
                // If element is UIElement hosted by UIContainer (Inlien of Block),
                // retrieve content Start and End positions of the container.
                // Otherwise scan ITextContainer to find a range for given element.
                if (childElement is TextElement)
                {
                    rangeStart = ((TextElement)childElement).ElementStart;
                    rangeEnd   = ((TextElement)childElement).ElementEnd;
                }
                else
                {
                    DependencyObject parent = LogicalTreeHelper.GetParent(childElement);
                    if (parent is InlineUIContainer || parent is BlockUIContainer)
                    {
                        rangeStart = ((TextElement)parent).ContentStart;
                        rangeEnd   = ((TextElement)parent).ContentEnd;
                    }
                    else
                    {
                        ITextPointer position = _textContainer.Start.CreatePointer();
                        while (position.CompareTo(_textContainer.End) < 0)
                        {
                            TextPointerContext context = position.GetPointerContext(LogicalDirection.Forward);
                            if (context == TextPointerContext.ElementStart)
                            {
                                if (childElement == position.GetAdjacentElement(LogicalDirection.Forward))
                                {
                                    rangeStart = position.CreatePointer(LogicalDirection.Forward);
                                    position.MoveToElementEdge(ElementEdge.AfterEnd);
                                    rangeEnd = position.CreatePointer(LogicalDirection.Backward);
                                    break;
                                }
                            }
                            else if (context == TextPointerContext.EmbeddedElement)
                            {
                                if (childElement == position.GetAdjacentElement(LogicalDirection.Forward))
                                {
                                    rangeStart = position.CreatePointer(LogicalDirection.Forward);
                                    position.MoveToNextContextPosition(LogicalDirection.Forward);
                                    rangeEnd = position.CreatePointer(LogicalDirection.Backward);
                                    break;
                                }
                            }
                            position.MoveToNextContextPosition(LogicalDirection.Forward);
                        }
                    }
                }
                // Create range
                if (rangeStart != null && rangeEnd != null)
                {
                    range = new TextRangeAdaptor(this, rangeStart, rangeEnd, _textPeer);
                }
            }
            if (range == null)
            {
                throw new InvalidOperationException(SR.Get(SRID.TextProvider_InvalidChildElement));
            }
            return(range);
        }
示例#8
0
        /// <summary>
        /// Tries to get a value that is stored somewhere in the visual tree above this <see cref="DependencyObject"/>.
        /// <para>If this is not available, it will register a <see cref="ParentChangedNotifier"/> on the last element.</para>
        /// </summary>
        /// <typeparam name="T">The return type.</typeparam>
        /// <param name="target">The <see cref="DependencyObject"/>.</param>
        /// <param name="GetFunction">The function that gets the value from a <see cref="DependencyObject"/>.</param>
        /// <param name="ParentChangedAction">The notification action on the change event of the Parent property.</param>
        /// <param name="parentNotifiers">A dictionary of already registered notifiers.</param>
        /// <returns>The value, if possible.</returns>
        public static T GetValueOrRegisterParentNotifier <T>(this DependencyObject target, Func <DependencyObject, T> GetFunction, Action <DependencyObject> ParentChangedAction, Dictionary <DependencyObject, ParentChangedNotifier> parentNotifiers)
        {
            var ret = default(T);

            if (target != null)
            {
                var depObj = target;

                while (ret == null)
                {
                    // Try to get the value using the provided GetFunction.
                    ret = GetFunction(depObj);

                    if (ret != null && parentNotifiers.ContainsKey(target))
                    {
                        var notifier = parentNotifiers[target];
                        notifier.Dispose();
                        parentNotifiers.Remove(target);
                    }

                    // Try to get the parent using the visual tree helper. This may fail on some occations.
#if !SILVERLIGHT
                    if (!(depObj is Visual) && !(depObj is Visual3D) && !(depObj is FrameworkContentElement))
                    {
                        break;
                    }

                    if (depObj is Window)
                    {
                        break;
                    }
#endif
                    DependencyObject depObjParent = null;

#if !SILVERLIGHT
                    if (depObj is FrameworkContentElement)
                    {
                        depObjParent = ((FrameworkContentElement)depObj).Parent;
                    }
                    else
                    {
                        try { depObjParent = LogicalTreeHelper.GetParent(depObj); }
                        catch { depObjParent = null; }
                    }
#endif

                    if (depObjParent == null)
                    {
                        try { depObjParent = VisualTreeHelper.GetParent(depObj); }
                        catch { break; }
                    }

                    // If this failed, try again using the Parent property (sometimes this is not covered by the VisualTreeHelper class :-P.
                    if (depObjParent == null && depObj is FrameworkElement)
                    {
                        depObjParent = ((FrameworkElement)depObj).Parent;
                    }

                    if (ret == null && depObjParent == null)
                    {
                        // Try to establish a notification on changes of the Parent property of dp.
                        if (depObj is FrameworkElement && !parentNotifiers.ContainsKey(target))
                        {
                            parentNotifiers.Add(target, new ParentChangedNotifier((FrameworkElement)depObj, () =>
                            {
                                // Call the action...
                                ParentChangedAction(target);
                                // ...and remove the notifier - it will probably not be used again.
                                if (parentNotifiers.ContainsKey(target))
                                {
                                    var notifier = parentNotifiers[target];
                                    notifier.Dispose();
                                    parentNotifiers.Remove(target);
                                }
                            }));
                        }
                        break;
                    }

                    // Assign the parent to the current DependencyObject and start the next iteration.
                    depObj = depObjParent;
                }
            }

            return(ret);
        }
        // Token: 0x060075FB RID: 30203 RVA: 0x0021A3F0 File Offset: 0x002185F0
        internal override object GetObject(DependencyObject d, ObjectRefArgs args)
        {
            if (d == null)
            {
                throw new ArgumentNullException("d");
            }
            object obj = null;

            if (args.ResolveNamesInTemplate)
            {
                FrameworkElement frameworkElement = d as FrameworkElement;
                if (frameworkElement != null && frameworkElement.TemplateInternal != null)
                {
                    obj = Helper.FindNameInTemplate(this._name, d);
                    if (args.IsTracing)
                    {
                        TraceData.Trace(TraceEventType.Warning, TraceData.ElementNameQueryTemplate(new object[]
                        {
                            this._name,
                            TraceData.Identify(d)
                        }));
                    }
                }
                if (obj == null)
                {
                    args.NameResolvedInOuterScope = true;
                }
            }
            FrameworkObject frameworkObject = new FrameworkObject(d);

            while (obj == null && frameworkObject.DO != null)
            {
                DependencyObject dependencyObject;
                obj = frameworkObject.FindName(this._name, out dependencyObject);
                if (d == dependencyObject && d is IComponentConnector && d.ReadLocalValue(NavigationService.NavigationServiceProperty) == DependencyProperty.UnsetValue)
                {
                    DependencyObject dependencyObject2 = LogicalTreeHelper.GetParent(d);
                    if (dependencyObject2 == null)
                    {
                        dependencyObject2 = Helper.FindMentor(d.InheritanceContext);
                    }
                    if (dependencyObject2 != null)
                    {
                        obj = null;
                        frameworkObject.Reset(dependencyObject2);
                        continue;
                    }
                }
                if (args.IsTracing)
                {
                    TraceData.Trace(TraceEventType.Warning, TraceData.ElementNameQuery(new object[]
                    {
                        this._name,
                        TraceData.Identify(frameworkObject.DO)
                    }));
                }
                if (obj == null)
                {
                    args.NameResolvedInOuterScope = true;
                    FrameworkObject  frameworkObject2  = new FrameworkObject(dependencyObject);
                    DependencyObject dependencyObject3 = frameworkObject2.TemplatedParent;
                    if (dependencyObject3 == null)
                    {
                        Panel panel = frameworkObject.FrameworkParent.DO as Panel;
                        if (panel != null && panel.IsItemsHost)
                        {
                            dependencyObject3 = panel;
                        }
                    }
                    if (dependencyObject3 == null && dependencyObject == null)
                    {
                        ContentControl contentControl = LogicalTreeHelper.GetParent(frameworkObject.DO) as ContentControl;
                        if (contentControl != null && contentControl.Content == frameworkObject.DO && contentControl.InheritanceBehavior == InheritanceBehavior.Default)
                        {
                            dependencyObject3 = contentControl;
                        }
                    }
                    if (dependencyObject3 == null && dependencyObject == null)
                    {
                        dependencyObject3 = frameworkObject.DO;
                        for (;;)
                        {
                            DependencyObject dependencyObject4 = LogicalTreeHelper.GetParent(dependencyObject3);
                            if (dependencyObject4 == null)
                            {
                                dependencyObject4 = Helper.FindMentor(dependencyObject3.InheritanceContext);
                            }
                            if (dependencyObject4 == null)
                            {
                                break;
                            }
                            dependencyObject3 = dependencyObject4;
                        }
                        ContentPresenter contentPresenter = VisualTreeHelper.IsVisualType(dependencyObject3) ? (VisualTreeHelper.GetParent(dependencyObject3) as ContentPresenter) : null;
                        dependencyObject3 = ((contentPresenter != null && contentPresenter.TemplateInternal.CanBuildVisualTree) ? contentPresenter : null);
                    }
                    frameworkObject.Reset(dependencyObject3);
                }
            }
            if (obj == null)
            {
                obj = DependencyProperty.UnsetValue;
                args.NameResolvedInOuterScope = false;
            }
            return(obj);
        }
示例#10
0
        public static DependencyObject GetLeastCommonAncestor(DependencyObject firstDescendant, DependencyObject secondDescendant, DependencyObject root)
        {
            DependencyObject current1   = firstDescendant;
            ArrayList        arrayList1 = new ArrayList();

            for (; current1 != null && LogicalTreeHelper.GetParent(current1) != null; current1 = LogicalTreeHelper.GetParent(current1))
            {
                arrayList1.Add((object)current1);
            }
            DependencyObject current2   = secondDescendant;
            ArrayList        arrayList2 = new ArrayList();

            for (; current2 != null && LogicalTreeHelper.GetParent(current2) != null; current2 = LogicalTreeHelper.GetParent(current2))
            {
                arrayList2.Add((object)current2);
            }
            DependencyObject dependencyObject = root;

            while (arrayList1.Count > 0 && arrayList2.Count > 0 && arrayList1[arrayList1.Count - 1] == arrayList2[arrayList2.Count - 1])
            {
                dependencyObject = (DependencyObject)arrayList1[arrayList1.Count - 1];
                arrayList1.RemoveAt(arrayList1.Count - 1);
                arrayList2.RemoveAt(arrayList2.Count - 1);
            }
            return(dependencyObject);
        }
示例#11
0
 public static FrameworkElement FindElement(FrameworkElement element, string id)
 {
     return(LogicalTreeHelper.FindLogicalNode((DependencyObject)element, id) as FrameworkElement);
 }
示例#12
0
 public IEnumerable <DependencyObject> GetChildren(DependencyObject element)
 {
     return(LogicalTreeHelper.GetChildren(element).OfType <DependencyObject>());
 }
示例#13
0
 public int GetChildrenCount(DependencyObject element)
 {
     return(LogicalTreeHelper.GetChildren(element).OfType <DependencyObject>().Count());
 }
示例#14
0
 public DependencyObject GetChild(DependencyObject element, int index)
 {
     return(LogicalTreeHelper.GetChildren(element).OfType <DependencyObject>().ElementAt(index));
 }
示例#15
0
        private void OnMouseDown(object sender, MouseButtonEventArgs e)
        {
            if (e.ClickCount == 2 && e.LeftButton == MouseButtonState.Pressed)
            {
                var port = sender as ExtendedPort;
                if (port == null)
                {
                    return;
                }

                // Get the ExtendedVplControl as Host UserControl
                DependencyObject ucParent = Parent;

                while (!(ucParent is PortArea))
                {
                    ucParent = LogicalTreeHelper.GetParent(ucParent);
                }
                var portArea = ucParent as PortArea;
                if (portArea == null)
                {
                    return;
                }

                try
                {
                    // Remove Connections, the port itself and recompute the port positions ...
                    foreach (var item in port.ConnectedConnectors)
                    {
                        item.RemoveFromCanvas();
                    }

                    port.UpdateLayout();
                    // portArea.PortControl.Children.Remove(port);
                    portArea.RecalculateLocationForAllPorts();
                }
                catch (Exception)
                {
                }

                e.Handled = true;
            }
            // Remove the clicked port
            else if (e.ClickCount == 2 && e.RightButton == MouseButtonState.Pressed)
            {
                var port = sender as ExtendedPort;
                if (port == null)
                {
                    return;
                }

                // Get the ExtendedVplControl as Host UserControl
                DependencyObject ucParent = Parent;

                while (!(ucParent is PortArea))
                {
                    ucParent = LogicalTreeHelper.GetParent(ucParent);
                }
                var portArea = ucParent as PortArea;
                if (portArea == null)
                {
                    return;
                }

                try
                {
                    port.UpdateLayout();
                    portArea.PortControl.Children.Remove(port);
                    portArea.RecalculateLocationForAllPorts();
                }
                catch (Exception)
                {
                }

                e.Handled = true;
            }
        }
示例#16
0
        static private void DoDumpCallback(DependencyObject current, DependencyObject initial, int indentLevel,
                                           ref IDictionary <string, List <string> > itemDictionary,
                                           ref IDictionary <string, List <string> > assistDictionary)

        {
            if (current.GetType().BaseType == typeof(Window) || current.GetType().BaseType == typeof(UserControl) || GoDownLogical(current) ||
                current.GetType().BaseType == typeof(Page))
            {
                IEnumerable children = LogicalTreeHelper.GetChildren(current);
                foreach (object child in children)
                {
                    if (child is DependencyObject)
                    {
                        DoDumpCallback((DependencyObject)child, null, 0, ref itemDictionary, ref assistDictionary);
                    }
                    else
                    {
                        var named = child;
                    }
                }
            }
            else
            {
                DependencyObject child = null;
                if (GoDown(current))
                {
                    int count = VisualTreeHelper.GetChildrenCount(current);
                    for (int i = 0; i < VisualTreeHelper.GetChildrenCount(current); i++)
                    {
                        object value = VisualTreeHelper.GetChild(current, i);
                        if (value is DependencyObject)
                        {
                            child = (DependencyObject)value;
                        }
                        DoDumpCallback(child, null, 0, ref itemDictionary, ref assistDictionary);
                    }
                }
                else
                {
                    if (current is TabControl)
                    {
                        object named = current;
                    }
                    object value = current;
                }

                /*
                 *
                 *
                 * for (int i = 0; i < VisualTreeHelper.GetChildrenCount(current); i++)
                 * {
                 *  FrameworkElement child = (FrameworkElement) VisualTreeHelper.GetChild(current, i);
                 *
                 *  if (child.GetType() == typeof(DockPanel) || child.GetType() == typeof(StackPanel) ||
                 *      child.GetType() == typeof(WrapPanel) ||
                 *      child.GetType() == typeof(Grid) || child.GetType() == typeof(Canvas) ||
                 *      child.GetType() == typeof(GroupBox) ||
                 *      child.GetType() == typeof(ScrollViewer) || child.GetType() == typeof(Border) ||
                 *      child.GetType() == typeof(UniformGrid) ||
                 *      child.GetType() == typeof(Table) || child.GetType() == typeof(TabPanel) ||
                 *      child.GetType() == typeof(ToolBarOverflowPanel) ||
                 *      child.GetType() == typeof(VirtualizingPanel) ||
                 *      child.GetType() == typeof(VirtualizingStackPanel))
                 *  {
                 *      DoDumpCallback(child, null, 0, ref itemDictionary, ref assistDictionary);
                 *  }
                 *  else
                 *  {
                 *      if (current is DataField)
                 *      {
                 *          var obj = current;
                 *      }
                 *  }
                 * }*/
            }

            /*
             * int visualChildrenCount = System.Windows.Media.VisualTreeHelper.GetChildrenCount(current);
             * IEnumerable children = LogicalTreeHelper.GetChildren(current);
             * foreach ()
             *
             * IEnumerable enumerable = LogicalTreeHelper.GetChildren(current);
             * // Collect
             * CollectItem(current, ref itemDictionary, ref assistDictionary);
             * for (int i = 0; i < visualChildrenCount; ++i)
             * {
             *  DependencyObject visualChild = System.Windows.Media.VisualTreeHelper.GetChild(current, i);
             *  DoDumpCallback(visualChild, initial, indentLevel + 1, ref itemDictionary, ref assistDictionary);
             * }*/
        }
示例#17
0
        void SetStatus(string new_status)
        {
            Label ui_name = (Label)LogicalTreeHelper.FindLogicalNode(m_RootElement, "status");

            ui_name.Content = new_status;
        }
        private void UserControl_Loaded(object sender, RoutedEventArgs ea)
        {
            DependencyObject ucParent = (sender as DayScheduler).Parent;

            while (!(ucParent is Scheduler))
            {
                ucParent = LogicalTreeHelper.GetParent(ucParent);
            }

            _scheduler = ucParent as Scheduler;

            _scheduler.OnEventAdded += ((object s, Event e) =>
            {
                if (e.Start.Date == e.End.Date)
                {
                    PaintAllEvents();
                }
                else
                {
                    PaintAllDayEvents();
                }
            });

            _scheduler.OnEventDeleted += ((object s, Event e) =>
            {
                if (e.Start.Date == e.End.Date)
                {
                    PaintAllEvents();
                }
                else
                {
                    PaintAllDayEvents();
                }
            });

            _scheduler.OnEventsModified += ((object s, EventArgs e) =>
            {
                PaintAllEvents();
                PaintAllDayEvents();
            });

            _scheduler.OnStartJourneyChanged += ((object s, TimeSpan t) =>
            {
                if (_scheduler.StartJourney.Hours == 0)
                {
                    startJourney.Visibility = System.Windows.Visibility.Hidden;
                }
                else
                {
                    Grid.SetRowSpan(startJourney, (int)t.TotalHours * 2);
                }
            });

            _scheduler.OnEndJourneyChanged += ((object s, TimeSpan t) =>
            {
                if (_scheduler.EndJourney.Hours == 0)
                {
                    endJourney.Visibility = System.Windows.Visibility.Hidden;
                }
                else
                {
                    Grid.SetRow(endJourney, (int)t.Hours);
                    Grid.SetRowSpan(endJourney, 48 - (int)t.Hours * 2);
                }
            });

            (sender as DayScheduler).SizeChanged += DayScheduler_SizeChanged;

            ResizeGrids(new Size(this.ActualWidth, this.ActualHeight));
            PaintAllEvents();
            PaintAllDayEvents();
            if (_scheduler.StartJourney.Hours != 0)
            {
                double hourHeight = EventsGrid.ActualHeight / 22;
                ScrollEventsViewer.ScrollToVerticalOffset(hourHeight * (_scheduler.StartJourney.Hours - 1));
            }

            if (_scheduler.StartJourney.Hours == 0)
            {
                startJourney.Visibility = System.Windows.Visibility.Hidden;
            }
            else
            {
                Grid.SetRowSpan(startJourney, _scheduler.StartJourney.Hours * 2);
            }

            if (_scheduler.EndJourney.Hours == 0)
            {
                endJourney.Visibility = System.Windows.Visibility.Hidden;
            }
            else
            {
                Grid.SetRow(endJourney, _scheduler.EndJourney.Hours * 2);
                Grid.SetRowSpan(endJourney, 48 - _scheduler.EndJourney.Hours * 2);
            }
        }
示例#19
0
        public override object ProvideValue(IServiceProvider serviceProvider)
        {
            IProvideValueTarget provideValue = serviceProvider.GetService(typeof(IProvideValueTarget)) as IProvideValueTarget;

            if (provideValue == null || provideValue.TargetObject == null)
            {
                return(null);
                //                throw new NotSupportedException("The IProvideValueTarget is not supported");
            }
            if (provideValue.TargetObject.GetType().FullName == "System.Windows.SharedDp")
            {
                return(this);
            }

            DependencyObject targetObject = provideValue.TargetObject as DependencyObject;

            if (targetObject == null)
            {
                Debug.Fail(string.Format("can't persist type {0}, not a dependency object", provideValue.TargetObject));
                throw new NotSupportedException();
            }

            DependencyProperty targetProperty = provideValue.TargetProperty as DependencyProperty;

            if (targetProperty == null)
            {
                Debug.Fail(string.Format("can't persist type {0}, not a dependency property", provideValue.TargetProperty));
                throw new NotSupportedException();
            }
            Func <DependencyObject, Window> getParent = null;

            getParent = new Func <DependencyObject, Window>(ui => {
                var uie = ui;
                while (!(uie is Window) && uie != null)
                {
                    uie = LogicalTreeHelper.GetParent(uie);
                }
                if (uie == null)
                {
                    if (ui is UserControl)
                    {
                        var uc = ui as UserControl;
                        if (uc.Parent != null)
                        {
                            return(getParent(uc.Parent));
                        }
                        else
                        {
                            return(Application.Current.MainWindow);
                        }
                    }
                    return(ui is FrameworkElement ? getParent((ui as FrameworkElement).Parent) : null);
                }
                return(uie as Window);
            });
            #region key
            if (key == null)
            {
                IUriContext uriContext = (IUriContext)serviceProvider.GetService(typeof(IUriContext));
                if (uriContext == null)
                {
                    // fallback to default value if no key available
                    DependencyPropertyDescriptor descriptor = DependencyPropertyDescriptor.FromProperty(targetProperty, targetObject.GetType());
                    return(descriptor.GetValue(targetObject));
                }

                // UIElements have a 'PersistId' property that we can use to generate a unique key
                if (targetObject is UIElement)
                {
                    Func <DependencyObject, string, object> foo = (dp, name) => {
                        var en = dp.GetLocalValueEnumerator();
                        while (en.MoveNext())
                        {
                            if (en.Current.Property.Name.ToLower() == name.ToLower())
                            {
                                return(en.Current.Value);
                            }
                        }
                        return(null);
                    };
                    string persistID = (foo(targetObject, "Name") ?? ((UIElement)targetObject).PersistId) + "";
                    var    window    = getParent(targetObject as UIElement);
                    //System.Diagnostics.Debug.Assert(window!=null,"Main window is <Null>");
                    var windowName = window == null ? "" : window.Name;
                    key = string.Format("{0}.{1}[{2}.{3}]{4}",
                                        uriContext.BaseUri.PathAndQuery,
                                        targetObject.GetType().Name,
                                        windowName,
                                        persistID,
                                        targetProperty.Name);
                }
                // use parent-child relation to generate unique key
                else if (LogicalTreeHelper.GetParent(targetObject) is UIElement)
                {
                    UIElement parent = (UIElement)LogicalTreeHelper.GetParent(targetObject);
                    int       i      = 0;
                    foreach (object c in LogicalTreeHelper.GetChildren(parent))
                    {
                        if (c == targetObject)
                        {
                            key = string.Format("{0}.{1}[{2}].{3}[{4}].{5}",
                                                uriContext.BaseUri.PathAndQuery,
                                                parent.GetType().Name, parent.PersistId,
                                                targetObject.GetType().Name, i,
                                                targetProperty.Name);
                            break;
                        }
                        i++;
                    }
                }
                //TODO:should do something clever here to get a good key for tags like GridViewColumn

                if (key == null)
                {
                    Debug.Fail(string.Format("don't know how to automatically get a key for objects of type {0}\n use Key='...' option", targetObject.GetType()));

                    // fallback to default value if no key available
                    DependencyPropertyDescriptor descriptor = DependencyPropertyDescriptor.FromProperty(targetProperty, targetObject.GetType());
                    return(descriptor.GetValue(targetObject));
                }
                else
                {
                    //Debug.WriteLine(string.Format("key={0}", key));
                }
            }
            #endregion

            if (!UserSettingsStorage.Dictionary.ContainsKey(key))
            {
                UserSettingsStorage.Dictionary[key] = defaultValue;
            }

            object value = ConvertFromString(targetObject, targetProperty, UserSettingsStorage.Dictionary[key]);

            SetBinding(targetObject, targetProperty, key);

            return(value);
        }
示例#20
0
 public MenuItem GetContextMenuItem(string contextName, string itemName)
 {
     System.Windows.Controls.ContextMenu cm = Explorer.Resources[contextName] as System.Windows.Controls.ContextMenu;
     return(LogicalTreeHelper.FindLogicalNode(cm, itemName) as MenuItem);
 }
        private void UserControl_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
        {
            if (this.Visibility == Visibility.Visible)
            {
                DependencyObject ucParent = this.Parent;

                while (!(ucParent is UserControl))
                {
                    ucParent = LogicalTreeHelper.GetParent(ucParent);
                }

                parent              = (receiptMng)ucParent;
                lstGuest            = UserController.loadDataGuest();
                cmbKH.ItemsSource   = lstGuest;
                cmbKH.SelectedIndex = 0;

                lstLB = receiptMngController.loadLichBayData();
                cmbMaCB.ItemsSource   = lstLB;
                cmbMaCB.SelectedIndex = 0;

                switch (parent.method)
                {
                case 1:    // Thêm
                {
                    addComboBtn.Visibility    = Visibility.Visible;
                    detailComboBtn.Visibility = Visibility.Hidden;
                    ManChe.Visibility         = Visibility.Hidden;
                    ManChe_2.Visibility       = Visibility.Hidden;

                    searchPanel.Visibility = Visibility.Visible;
                    btnAddGuest.Visibility = Visibility.Visible;


                    dpNgayMua.SelectedDate = DateTime.Today;
                    dpNgayMua.IsEnabled    = false;

                    txtNormalSeats.Text = "";
                    txtVIPSeats.Text    = "";

                    break;
                }

                case 2:    // Xem
                {
                    addComboBtn.Visibility    = Visibility.Hidden;
                    detailComboBtn.Visibility = Visibility.Visible;
                    btnCancel.Visibility      = Visibility.Hidden;

                    ManChe.Visibility   = Visibility.Visible;
                    ManChe_2.Visibility = Visibility.Visible;

                    searchPanel.Visibility = Visibility.Hidden;
                    btnAddGuest.Visibility = Visibility.Hidden;

                    cmbKH.ItemsSource = lstGuest;

                    KHACH guest = lstGuest.Where(x => x.ID == GlobalItem.selectedReceipt.MaKH).ToList().SingleOrDefault();

                    cmbKH.SelectedItem  = guest;
                    txtTenKH.Text       = guest.HoTen;
                    txtDialNumber2.Text = guest.SDT;

                    cmbMaCB.SelectedItem = lstLB.Where(x => x.MaCB == GlobalItem.selectedReceipt.MaCB && x.NgayDi == GlobalItem.selectedReceipt.NgayDi)
                                           .SingleOrDefault();

                    txtNormalSeats.Text = GlobalItem.selectedReceipt.SoVeThuong.ToString();
                    txtVIPSeats.Text    = GlobalItem.selectedReceipt.SoVeVip.ToString();
                    txtTongTien.Text    = GlobalItem.selectedReceipt.TongTien.ToString();

                    dpNgayMua.SelectedDate = GlobalItem.selectedReceipt.NgayMua;

                    break;
                }

                case 3:    // Sửa
                {
                    addComboBtn.Visibility    = Visibility.Hidden;
                    detailComboBtn.Visibility = Visibility.Visible;
                    btnCancel.Visibility      = Visibility.Visible;
                    ManChe.Visibility         = Visibility.Hidden;
                    ManChe_2.Visibility       = Visibility.Hidden;

                    searchPanel.Visibility = Visibility.Hidden;
                    btnAddGuest.Visibility = Visibility.Hidden;
                    cmbKH.ItemsSource      = lstGuest;

                    cmbKH.IsEnabled   = false;
                    cmbMaCB.IsEnabled = false;

                    KHACH guest = lstGuest.Where(x => x.ID == GlobalItem.selectedReceipt.MaKH).ToList().SingleOrDefault();
                    cmbKH.SelectedItem  = guest;
                    txtTenKH.Text       = guest.HoTen;
                    txtDialNumber2.Text = guest.SDT;

                    cmbMaCB.SelectedItem = lstLB.Where(x => x.MaCB == GlobalItem.selectedReceipt.MaCB && x.NgayDi == GlobalItem.selectedReceipt.NgayDi)
                                           .SingleOrDefault();

                    txtNormalSeats.Text = GlobalItem.selectedReceipt.SoVeThuong.ToString();
                    txtVIPSeats.Text    = GlobalItem.selectedReceipt.SoVeVip.ToString();

                    oriNormal = GlobalItem.selectedReceipt.SoVeThuong.Value;
                    oriVip    = GlobalItem.selectedReceipt.SoVeVip.Value;

                    txtTongTien.Text = GlobalItem.selectedReceipt.TongTien.ToString();

                    dpNgayMua.SelectedDate = GlobalItem.selectedReceipt.NgayMua;
                    break;
                }

                default: break;
                }
            }
            else
            {
                GlobalItem.selectedReceipt = null;
                dpNgayMua.IsEnabled        = true;
                cmbKH.IsEnabled            = true;
                cmbMaCB.IsEnabled          = true;
                txtTongTien.Text           = "";
                parent.loadDataHoaDon();
            }
        }
 // Redo last step
 private void RedoMenuItem_Click(object sender, RoutedEventArgs e)
 {
     (LogicalTreeHelper.FindLogicalNode(this, "TabsControlUserControl") as TabsControl).RedoLastStep();
 }
示例#23
0
 public static DependencyObject FindLogicalNode(this DependencyObject ob, string name)
 {
     return(LogicalTreeHelper.FindLogicalNode(ob, name));
 }
示例#24
0
 public void ScrollIntoView(DesignItem designItem)
 {
     enableBringIntoView = true;
     LogicalTreeHelper.BringIntoView(designItem.View);
     enableBringIntoView = false;
 }
示例#25
0
        public void SaveSetting()
        {
            try
            {
                Settings.Instance.ScrollSize         = MenuUtil.MyToNumerical(textBox_mouse_scroll, Convert.ToDouble, 240);
                Settings.Instance.ServiceWidth       = MenuUtil.MyToNumerical(textBox_service_width, Convert.ToDouble, double.MaxValue, 16, 16);//小さいと描画で落ちる
                Settings.Instance.MinHeight          = MenuUtil.MyToNumerical(textBox_minHeight, Convert.ToDouble, double.MaxValue, 0.1, 2);
                Settings.Instance.MinimumHeight      = MenuUtil.MyToNumerical(textBox_minimumHeight, Convert.ToDouble, double.MaxValue, 0, 0);
                Settings.Instance.DragScroll         = MenuUtil.MyToNumerical(textBox_dragScroll, Convert.ToDouble, 1.5);
                Settings.Instance.EpgTitleIndent     = (checkBox_title_indent.IsChecked == true);
                Settings.Instance.EpgPopup           = (checkBox_epg_popup.IsChecked == true);
                Settings.Instance.EpgPopupResOnly    = (checkBox_epg_popup_resOnly.IsChecked == true);
                Settings.Instance.EpgGradation       = (checkBox_gradation.IsChecked == true);
                Settings.Instance.EpgGradationHeader = (checkBox_gradationHeader.IsChecked == true);

                Settings.Instance.EpgInfoSingleClick     = (checkBox_singleOpen.IsChecked == true);
                Settings.Instance.EpgInfoOpenMode        = (byte)(checkBox_openInfo.IsChecked == true ? 1 : 0);
                Settings.Instance.MouseScrollAuto        = (checkBox_scrollAuto.IsChecked == true);
                Settings.Instance.DisplayNotifyEpgChange = (checkBox_displayNotifyChange.IsChecked == true);
                Settings.Instance.ReserveRectBackground  = (checkBox_reserveBackground.IsChecked == true);
                Settings.Instance.TunerScrollSize        = MenuUtil.MyToNumerical(textBox_tuner_mouse_scroll, Convert.ToDouble, 240);
                Settings.Instance.TunerWidth             = MenuUtil.MyToNumerical(textBox_tuner_width, Convert.ToDouble, double.MaxValue, 16, 150);//小さいと描画で落ちる
                Settings.Instance.TunerMinHeight         = MenuUtil.MyToNumerical(textBox_tuner_minHeight, Convert.ToDouble, double.MaxValue, 0.1, 2);
                Settings.Instance.TunerMinimumLine       = MenuUtil.MyToNumerical(textBox_tunerMinLineHeight, Convert.ToDouble, double.MaxValue, 0, 0);
                Settings.Instance.TunerDragScroll        = MenuUtil.MyToNumerical(textBox_tunerDdragScroll, Convert.ToDouble, 1.5);
                Settings.Instance.TunerMouseScrollAuto   = (checkBox_tuner_scrollAuto.IsChecked == true);
                Settings.Instance.TunerServiceNoWrap     = (checkBox_tuner_service_nowrap.IsChecked == true);
                Settings.Instance.TunerTitleIndent       = (checkBox_tuner_title_indent.IsChecked == true);
                Settings.Instance.TunerPopup             = (checkBox_tuner_popup.IsChecked == true);
                Settings.Instance.TunerPopupRecinfo      = (checkBox_tuner_popup_recInfo.IsChecked == true);
                Settings.Instance.TunerInfoSingleClick   = (checkBox_tunerSingleOpen.IsChecked == true);
                Settings.Instance.TunerColorModeUse      = (checkBox_tunerColorModeUse.IsChecked == true);
                Settings.Instance.TunerDisplayOffReserve = (checkBox_tuner_display_offres.IsChecked == true);

                if (comboBox_font.SelectedItem != null)
                {
                    Settings.Instance.FontName = comboBox_font.SelectedItem as string;
                }
                Settings.Instance.FontSize = MenuUtil.MyToNumerical(textBox_fontSize, Convert.ToDouble, 72, 1, 12);
                if (comboBox_fontTitle.SelectedItem != null)
                {
                    Settings.Instance.FontNameTitle = comboBox_fontTitle.SelectedItem as string;
                }
                Settings.Instance.FontSizeTitle = MenuUtil.MyToNumerical(textBox_fontSizeTitle, Convert.ToDouble, 72, 1, 12);
                Settings.Instance.FontBoldTitle = (checkBox_fontBoldTitle.IsChecked == true);

#if false
                Settings.Instance.UseCustomEpgView = (radioButton_1_cust.IsChecked == true);
                Settings.Instance.CustomEpgTabList.Clear();
                foreach (CustomEpgTabInfo info in listBox_tab.Items)
                {
                    Settings.Instance.CustomEpgTabList.Add(info);
                }

                if (CommonManager.Instance.NWMode == false)
                {
                    string iniValue = "";
                    iniValue = (radioButton_1_cust.IsChecked == true ? "1" : "0");
                    IniFileHandler.WritePrivateProfileString("HTTP", "HttpCustEpg", iniValue, SettingPath.TimerSrvIniPath);

                    int custCount = listBox_tab.Items.Count;
                    IniFileHandler.WritePrivateProfileString("HTTP", "HttpCustCount", custCount.ToString(), SettingPath.TimerSrvIniPath);
                    custCount = 0;
                    foreach (CustomEpgTabInfo info in listBox_tab.Items)
                    {
                        IniFileHandler.WritePrivateProfileString("HTTP_CUST" + custCount.ToString(), "Name", info.TabName, SettingPath.TimerSrvIniPath);
                        IniFileHandler.WritePrivateProfileString("HTTP_CUST" + custCount.ToString(), "ViewServiceCount", info.ViewServiceList.Count.ToString(), SettingPath.TimerSrvIniPath);
                        int serviceCount = 0;
                        foreach (Int64 id in info.ViewServiceList)
                        {
                            IniFileHandler.WritePrivateProfileString("HTTP_CUST" + custCount.ToString(), "ViewService" + serviceCount.ToString(), id.ToString(), SettingPath.TimerSrvIniPath);
                            serviceCount++;
                        }

                        IniFileHandler.WritePrivateProfileString("HTTP_CUST" + custCount.ToString(), "ContentCount", info.ViewContentKindList.Count.ToString(), SettingPath.TimerSrvIniPath);
                        int contentCount = 0;
                        foreach (UInt16 id in info.ViewContentKindList)
                        {
                            IniFileHandler.WritePrivateProfileString("HTTP_CUST" + custCount.ToString(), "Content" + contentCount.ToString(), id.ToString(), SettingPath.TimerSrvIniPath);
                            contentCount++;
                        }
                        IniFileHandler.WritePrivateProfileString("HTTP_CUST" + custCount.ToString(), "ViewMode", info.ViewMode.ToString(), SettingPath.TimerSrvIniPath);

                        iniValue = (info.NeedTimeOnlyBasic == true ? "1" : "0");
                        IniFileHandler.WritePrivateProfileString("HTTP_CUST" + custCount.ToString(), "NeedTimeOnlyBasic", iniValue, SettingPath.TimerSrvIniPath);

                        iniValue = (info.NeedTimeOnlyWeek == true ? "1" : "0");
                        IniFileHandler.WritePrivateProfileString("HTTP_CUST" + custCount.ToString(), "NeedTimeOnlyWeek", iniValue, SettingPath.TimerSrvIniPath);

                        iniValue = (info.SearchMode == true ? "1" : "0");
                        IniFileHandler.WritePrivateProfileString("HTTP_CUST" + custCount.ToString(), "SearchMode", iniValue, SettingPath.TimerSrvIniPath);

                        custCount++;
                    }
                }

                Settings.Instance.ContentCustColorList = custColorList.Select(c => ColorDef.ToUInt(c)).ToList();
                Settings.Instance.TitleCustColor1      = ColorDef.ToUInt(custTitleColorList[0]);
                Settings.Instance.TitleCustColor2      = ColorDef.ToUInt(custTitleColorList[1]);
#endif
                if (comboBox_fontTuner.SelectedItem != null)
                {
                    Settings.Instance.TunerFontName = comboBox_fontTuner.SelectedItem as string;
                }
                Settings.Instance.TunerFontSize = MenuUtil.MyToNumerical(textBox_fontTunerSize, Convert.ToDouble, 72, 1, 12);
                if (comboBox_fontTunerService.SelectedItem != null)
                {
                    Settings.Instance.TunerFontNameService = comboBox_fontTunerService.SelectedItem as string;
                }
                Settings.Instance.TunerFontSizeService = MenuUtil.MyToNumerical(textBox_fontTunerSizeService, Convert.ToDouble, 72, 1, 12);
                Settings.Instance.TunerFontBoldService = (checkBox_fontTunerBoldService.IsChecked == true);

                Settings.Instance.UseCustomEpgView = (radioButton_1_cust.IsChecked == true);
                Settings.Instance.CustomEpgTabList = listBox_tab.Items.OfType <CustomEpgTabInfo>().ToList();
                Settings.SetCustomEpgTabInfoID();

                var getComboColor1  = new Func <ComboBox, string>((cmb) => ((ColorReferenceViewItem)(cmb.SelectedItem)).ColorName);
                var getButtonColor1 = new Func <Button, uint>((btn) => ColorDef.ToUInt((btn.Background as SolidColorBrush).Color));
                var getColors       = new Action <UIElement, List <string>, List <uint> >((ui, stockColors, custColors) =>
                {
                    List <UIElement> uiList = new List <UIElement>();
                    uiList.Add(ui);
                    for (int n = 0; n < uiList.Count; n++)
                    {
                        foreach (var child in LogicalTreeHelper.GetChildren(uiList[n]))
                        {
                            if (child is Control)
                            {
                                int index = int.Parse((string)(child as Control).Tag ?? "-1");
                                if (index >= 0)
                                {
                                    if (child is ComboBox && index < stockColors.Count)
                                    {
                                        stockColors[index] = getComboColor1(child as ComboBox);
                                    }
                                    else if (child is Button && index < custColors.Count)
                                    {
                                        custColors[index] = getButtonColor1(child as Button);
                                    }
                                }
                            }
                            else if (child is UIElement)
                            {
                                uiList.Add(child as UIElement);
                            }
                        }
                    }
                });

                // [番組表] - [基本]
                Settings.Instance.TitleColor1     = getComboColor1(comboBox_colorTitle1);
                Settings.Instance.TitleCustColor1 = getButtonColor1(button_colorTitle1);
                Settings.Instance.TitleColor2     = getComboColor1(comboBox_colorTitle2);
                Settings.Instance.TitleCustColor2 = getButtonColor1(button_colorTitle2);
                // [番組表] - [色1]
                getColors(groupEpgColors, Settings.Instance.ContentColorList, Settings.Instance.ContentCustColorList);
                Settings.Instance.ReserveRectColorNormal         = getComboColor1(comboBox_reserveNormal);
                Settings.Instance.ReserveRectColorNo             = getComboColor1(comboBox_reserveNo);
                Settings.Instance.ReserveRectColorNoTuner        = getComboColor1(comboBox_reserveNoTuner);
                Settings.Instance.ReserveRectColorWarning        = getComboColor1(comboBox_reserveWarning);
                Settings.Instance.ReserveRectColorAutoAddMissing = getComboColor1(comboBox_reserveAutoAddMissing);
                getColors(groupEpgColorsReserve, null, Settings.Instance.ContentCustColorList);
                // [番組表] - [色2]
                getColors(groupEpgTimeColors, Settings.Instance.EpgEtcColors, Settings.Instance.EpgEtcCustColors);
                getColors(groupEpgEtcColors, Settings.Instance.EpgEtcColors, Settings.Instance.EpgEtcCustColors);

                // [使用予定チューナー] - [基本]
                getColors(groupTunerFontColor, Settings.Instance.TunerServiceColors, Settings.Instance.TunerServiceCustColors);
                // [使用予定チューナー] - [色]
                getColors(groupTunerColors, Settings.Instance.TunerServiceColors, Settings.Instance.TunerServiceCustColors);

                // [録画済み一覧]
                Settings.Instance.PlayDClick                    = (checkBox_playDClick.IsChecked == true);
                Settings.Instance.RecInfoNoYear                 = (checkBox_recNoYear.IsChecked == true);
                Settings.Instance.RecInfoNoSecond               = (checkBox_recNoSecond.IsChecked == true);
                Settings.Instance.RecInfoNoDurSecond            = (checkBox_recNoDurSecond.IsChecked == true);
                Settings.Instance.RecInfoExtraDataCache         = (checkBox_ChacheOn.IsChecked == true);
                Settings.Instance.RecInfoExtraDataCacheOptimize = (checkBox_CacheOptimize.IsChecked == true);
                if (checkBox_CacheKeepConnect.IsEnabled)
                {
                    Settings.Instance.RecInfoExtraDataCacheKeepConnect = (checkBox_CacheKeepConnect.IsChecked == true);
                }
                Settings.Instance.RecInfoDropErrIgnore    = MenuUtil.MyToNumerical(textBox_dropErrIgnore, Convert.ToInt64, Settings.Instance.RecInfoDropErrIgnore);
                Settings.Instance.RecInfoDropWrnIgnore    = MenuUtil.MyToNumerical(textBox_dropWrnIgnore, Convert.ToInt64, Settings.Instance.RecInfoDropWrnIgnore);
                Settings.Instance.RecInfoScrambleIgnore   = MenuUtil.MyToNumerical(textBox_scrambleIgnore, Convert.ToInt64, Settings.Instance.RecInfoScrambleIgnore);
                Settings.Instance.RecinfoErrCriticalDrops = (checkBox_recinfo_errCritical.IsChecked == true);
                getColors(groupRecInfoBackColors, Settings.Instance.RecEndColors, Settings.Instance.RecEndCustColors);

                // [予約一覧・共通] - [基本]
                Settings.Instance.MenuSet = this.ctxmSetInfo.Clone();
                Settings.Instance.DisplayReserveAutoAddMissing = (checkBox_displayAutoAddMissing.IsChecked != false);
                Settings.Instance.DisplayNotifyJumpTime        = MenuUtil.MyToNumerical(textBox_DisplayJumpTime, Convert.ToDouble, Double.MaxValue, 0, 3);
                Settings.Instance.ResInfoNoYear      = (checkBox_resNoYear.IsChecked == true);
                Settings.Instance.ResInfoNoSecond    = (checkBox_resNoSecond.IsChecked == true);
                Settings.Instance.ResInfoNoDurSecond = (checkBox_resNoDurSecond.IsChecked == true);

                Settings.Instance.LaterTimeUse          = (checkBox_LaterTimeUse.IsChecked == true);
                Settings.Instance.LaterTimeHour         = MenuUtil.MyToNumerical(textBox_LaterTimeHour, Convert.ToInt32, 36, 24, 28) - 24;
                Settings.Instance.DisplayPresetOnSearch = (checkBox_displayPresetOnSearch.IsChecked == true);
                Settings.Instance.RecItemToolTip        = (checkBox_nekopandaToolTip.IsChecked == true);
                Settings.Instance.NoStyle = (checkBox_NotNoStyle.IsChecked == true ? 0 : 1);
                if (Settings.Instance.NoStyle == 0)
                {
                    Settings.Instance.StyleXamlPath = (comboBox_Style.SelectedItem as ComboBoxItem).Tag as string;
                }
                Settings.Instance.DisplayStatus                = (checkBox_displayStatus.IsChecked == true);
                Settings.Instance.DisplayStatusNotify          = (checkBox_displayStatusNotify.IsChecked == true);
                Settings.Instance.IsVisibleReserveView         = (checkBox_IsVisibleReserveView.IsChecked == true);
                Settings.Instance.IsVisibleRecInfoView         = (checkBox_IsVisibleRecInfoView.IsChecked == true);
                Settings.Instance.IsVisibleAutoAddView         = (checkBox_IsVisibleAutoAddView.IsChecked == true);
                Settings.Instance.IsVisibleAutoAddViewMoveOnly = (checkBox_IsVisibleAutoAddViewMoveOnly.IsChecked == true);

                CtxmCode?code = wrapPanel_StartTab.Children.OfType <RadioButton>()
                                .Where(btn => btn.IsChecked == true).Select(btn => btn.Tag as CtxmCode?).FirstOrDefault();
                if (code != null)
                {
                    Settings.Instance.StartTab = (CtxmCode)code;
                }

                Dock?dock = wrapPanel_MainViewButtonsDock.Children.OfType <RadioButton>()
                            .Where(btn => btn.IsChecked == true).Select(btn => btn.Tag as Dock?).FirstOrDefault();
                if (dock != null)
                {
                    Settings.Instance.MainViewButtonsDock = (Dock)dock;
                }

                // [予約一覧・共通] - [色]
                Settings.Instance.ListDefColor     = getComboColor1(cmb_ListDefFontColor);
                Settings.Instance.ListDefCustColor = getButtonColor1(btn_ListDefFontColor);
                getColors(groupReserveRecModeColors, Settings.Instance.RecModeFontColors, Settings.Instance.RecModeFontCustColors);
                getColors(groupReserveBackColors, Settings.Instance.ResBackColors, Settings.Instance.ResBackCustColors);
                getColors(groupStatColors, Settings.Instance.StatColors, Settings.Instance.StatCustColors);

                // [予約簡易表示]
                Settings.Instance.InfoWindowRefreshInterval  = MenuUtil.MyToNumerical(textBox_iw_refresh_interval, Convert.ToInt32, 60, 1, 10);
                Settings.Instance.InfoWindowBasedOnBroadcast = (radioButton_iw_based_on_bcst.IsChecked == true);
                string level = (string)new RadioButton[] {
                    radioButton_Level1, radioButton_Level2, radioButton_Level3, radioButton_All, radioButton_TopN
                }.Where(x => x.IsChecked == true).Select(x => x.Tag).FirstOrDefault();
                Settings.Instance.InfoWindowItemFilterLevel = level != null?int.Parse(level) : int.MaxValue;

                string progbar = (string)new RadioButton[] {
                    radioButton_ProgressBarOff, radioButton_ProgressBarType1, radioButton_ProgressBarType2,
                }.Where(x => x.IsChecked == true).Select(x => x.Tag).FirstOrDefault();
                Settings.Instance.InfoWindowItemProgressBarType = progbar != null?int.Parse(progbar) : 0;

                getColors(groupInfoWinItemProgressBarColors, Settings.Instance.InfoWindowItemProgressBarColors, Settings.Instance.InfoWindowItemProgressBarCustColors);
                Settings.Instance.InfoWindowItemProgressBarTransparent = checkBox_bgTransparent.IsChecked == true;
                Settings.Instance.InfoWindowItemTopN          = MenuUtil.MyToNumerical(textBox_TopN, Convert.ToInt32, 10);
                Settings.Instance.InfoWindowItemLevel1Seconds = MenuUtil.MyToNumerical(textBox_iw_item_level1, Convert.ToInt32, 0) * 60;
                Settings.Instance.InfoWindowItemLevel2Seconds = MenuUtil.MyToNumerical(textBox_iw_item_level2, Convert.ToInt32, 15) * 60;
                Settings.Instance.InfoWindowItemLevel3Seconds = MenuUtil.MyToNumerical(textBox_iw_item_level3, Convert.ToInt32, 480) * 60;
                getColors(groupInfoWinItemBgColors, Settings.Instance.InfoWindowItemBgColors, Settings.Instance.InfoWindowItemBgCustColors);
            }
            catch (Exception ex) { MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace); }
        }
示例#26
0
        public void ChangeSelection(object item, MyRibbonGalleryItem container, bool isSelected)
        {
            if (this.IsSelectionChangeActive)
            {
                return;
            }
            object selectedItem = this.SelectedItem;
            object itemValue    = item;
            bool   flag         = !MyRibbonGallery.VerifyEqual(selectedItem, itemValue);

            try
            {
                Debug.WriteLine("here");
                this.IsSelectionChangeActive = true;
                if (isSelected == flag)
                {
                    Debug.WriteLine("here1");
                    if (!isSelected && container != null)
                    {
                        Debug.WriteLine("here2");
                        container.IsSelected = false;
                        int index = this._selectedContainers.IndexOf(container);
                        if (index > -1)
                        {
                            Debug.WriteLine("here3");
                            this._selectedContainers.RemoveAt(index);
                            container.OnUnselected_(new RoutedEventArgs(RibbonGalleryItem.UnselectedEvent, (object)container));
                        }
                    }
                    else
                    {
                        Debug.WriteLine("here4");
                        for (int index = 0; index < this._selectedContainers.Count; ++index)
                        {
                            MyRibbonGalleryItem selectedContainer = (MyRibbonGalleryItem)this._selectedContainers[index];
                            selectedContainer.IsSelected = false;
                            selectedContainer.OnUnselected_(new RoutedEventArgs(RibbonGalleryItem.UnselectedEvent, (object)selectedContainer));
                            if (!isSelected)
                            {
                                Debug.WriteLine("here5");
                                this.MoveCurrentToPosition_(selectedContainer.RibbonGalleryCategory.CollectionView, -1);
                            }
                        }
                        this._selectedContainers.Clear();
                        if (!isSelected)
                        {
                            Debug.WriteLine("here6");
                            this.InvalidateProperty(RibbonGallery.SelectedItemProperty);
                            this.InvalidateProperty(RibbonGallery.SelectedValueProperty);
                            this.MoveCurrentToPosition_(this.CollectionView, -1);
                            this.MoveCurrentToPosition_(this.SourceCollectionView, -1);
                            if (LogicalTreeHelper.GetParent((DependencyObject)this) is MyRibbonComboBox parent && this == parent.FirstGallery && !parent.IsSelectedItemCached)
                            {
                                parent.UpdateSelectionProperties_();
                            }
                        }
                    }
                    if (isSelected)
                    {
                        Debug.WriteLine("here7");
                        this.SetCurrentValue(RibbonGallery.SelectedItemProperty, item);
                        this.SetCurrentValue(RibbonGallery.SelectedValueProperty, this.GetSelectableValueFromItem(item));
                        if (container != null)
                        {
                            this.SynchronizeWithCurrentItem(container.RibbonGalleryCategory, item);
                        }
                        else
                        {
                            this.SynchronizeWithCurrentItem();
                        }
                    }
                }
                if (isSelected)
                {
                    Debug.WriteLine("here8");
                    if (container != null)
                    {
                        Debug.WriteLine("here9");
                        if (!this._selectedContainers.Contains(container))
                        {
                            Debug.WriteLine("her10e");
                            this._selectedContainers.Add(container);
                            container.IsSelected = true;
                            container.OnSelected_(new RoutedEventArgs(RibbonGalleryItem.SelectedEvent, (object)container));
                        }
                    }
                }
            }
            finally
            {
                this.IsSelectionChangeActive = false;
            }

            if (!flag)
            {
                Debug.WriteLine("here11");
                return;
            }

            Debug.WriteLine("here12");
            this.OnSelectionChanged(new RoutedPropertyChangedEventArgs <object>(selectedItem, isSelected ? itemValue : (object)null, RibbonGallery.SelectionChangedEvent));
        }
示例#27
0
        public static string GetContextByName(this DependencyObject dependencyObject)
        {
            string result = "";

            if (dependencyObject != null)
            {
                if (dependencyObject is UserControl || dependencyObject is Window)
                {
                    result = dependencyObject.FormatForTextId(true);
                }
                else
                {
                    DependencyObject parent = dependencyObject is Visual || dependencyObject is Visual3D?VisualTreeHelper.GetParent(dependencyObject) : LogicalTreeHelper.GetParent(dependencyObject);

                    result = GetContextByName(parent);
                }
            }

            return(string.IsNullOrEmpty(result) ? dependencyObject?.FormatForTextId(true) ?? string.Empty : result);
        }
示例#28
0
 private DependencyObject GetElementByName(string name)
 {
     return(LogicalTreeHelper.FindLogicalNode(MainPanel, name) as DependencyObject);
 }
示例#29
0
        /// <summary>
        ///     Shows a custom control as a tooltip in the tray location.
        /// </summary>
        /// <param name="balloon"></param>
        /// <param name="animation">An optional animation for the popup.</param>
        /// <param name="timeout">
        ///     The time after which the popup is being closed.
        ///     Submit null in order to keep the balloon open inde
        /// </param>
        /// <exception cref="ArgumentNullException">
        ///     If <paramref name="balloon" />
        ///     is a null reference.
        /// </exception>
        public void ShowCustomBalloon(UIElement balloon, PopupAnimation animation, int?timeout)
        {
            Dispatcher dispatcher = this.GetDispatcher();

            if (!dispatcher.CheckAccess())
            {
                var action = new Action(() => this.ShowCustomBalloon(balloon, animation, timeout));
                dispatcher.Invoke(DispatcherPriority.Normal, action);
                return;
            }

            if (balloon == null)
            {
                throw new ArgumentNullException("balloon");
            }
            if (timeout.HasValue && timeout < 500)
            {
                string msg = "Invalid timeout of {0} milliseconds. Timeout must be at least 500 ms";
                msg = String.Format(msg, timeout);
                throw new ArgumentOutOfRangeException("timeout", msg);
            }

            this.EnsureNotDisposed();

            //make sure we don't have an open balloon
            lock (this)
            {
                this.CloseBalloon();
            }

            //create an invisible popup that hosts the UIElement
            var popup = new Popup {
                AllowsTransparency = true
            };

            //provide the popup with the taskbar icon's data context
            this.UpdateDataContext(popup, null, this.DataContext);

            //don't animate by default - devs can use attached
            //events or override
            popup.PopupAnimation = animation;

            //in case the balloon is cleaned up through routed events, the
            //control didn't remove the balloon from its parent popup when
            //if was closed the last time - just make sure it doesn't have
            //a parent that is a popup
            var parent = LogicalTreeHelper.GetParent(balloon) as Popup;

            if (parent != null)
            {
                parent.Child = null;
            }

            if (parent != null)
            {
                string msg = "Cannot display control [{0}] in a new balloon popup - that control already has a parent. You may consider creating new balloons every time you want to show one.";
                msg = String.Format(msg, balloon);
                throw new InvalidOperationException(msg);
            }

            popup.Child = balloon;

            //don't set the PlacementTarget as it causes the popup to become hidden if the
            //TaskbarIcon's parent is hidden, too...
            //popup.PlacementTarget = this;

            popup.Placement = PlacementMode.AbsolutePoint;
            popup.StaysOpen = true;

            Point position = TrayInfo.GetTrayLocation();

            position = this.GetDeviceCoordinates(position);
            popup.HorizontalOffset = position.X - 1;
            popup.VerticalOffset   = position.Y - 1;

            //store reference
            lock (this)
            {
                this.SetCustomBalloon(popup);
            }

            //assign this instance as an attached property
            SetParentTaskbarIcon(balloon, this);

            //fire attached event
            RaiseBalloonShowingEvent(balloon, this);

            //display item
            popup.IsOpen = true;

            if (timeout.HasValue)
            {
                //register timer to close the popup
                this._balloonCloseTimer.Change(timeout.Value, Timeout.Infinite);
            }
        }
 // Token: 0x06007232 RID: 29234 RVA: 0x0020A030 File Offset: 0x00208230
 internal override void PrivateConnectChild(int index, TElementType item)
 {
     if (item.Parent is ContentElementCollection <TParent, TElementType> .DummyProxy && LogicalTreeHelper.GetParent(item.Parent) != base.Owner)
     {
         throw new ArgumentException(SR.Get("TableCollectionWrongProxyParent"));
     }
     base.Items[index] = item;
     item.Index        = index;
     item.OnEnterParentTree();
 }