public static void SafelyUnregisterControl(this FrameworkElement context, IFrameworkInputElement grooveContainer)
 {
     if (context.FindName(grooveContainer.Name) != null)
     {
         context.UnregisterName(grooveContainer.Name);
     }
 }
Example #2
0
        private void InitializeExpandableElementForUIAutomation(IFrameworkInputElement element)
        {
            this.Dispatcher.BeginInvoke((Action)(() =>
            {
                AutomationElement automationElement;
                lock (automationRootElementLock)
                {
                    if (this.mainAutomationWindow == null)
                    {
                        this.mainAutomationWindow = AutomationElement.RootElement.FindFirst(TreeScope.Children, new PropertyCondition(AutomationElement.AutomationIdProperty, this.Name));
                    }

                    automationElement = this.mainAutomationWindow?.FindFirst(TreeScope.Descendants, new PropertyCondition(AutomationElement.AutomationIdProperty, element.Name));
                }

                if (automationElement != null)
                {
                    AutomationPattern automationPatternFromElement = AutomationHelper.GetSpecifiedPattern(automationElement, "ExpandCollapsePatternIdentifiers.Pattern");
                    if (automationElement.GetCurrentPattern(automationPatternFromElement) is ExpandCollapsePattern expandCollapsePattern)
                    {
                        expandCollapsePattern.Expand();
                        expandCollapsePattern.Collapse();

                        this.General.Focus();
                    }
                }
            }));
        }
Example #3
0
    private static bool FindPage(IFrameworkInputElement page, Workplace workplace)
    {
        var type = (IsThisViewCanBeUsedWithViewsSubsystemAttribute)page.GetType()
                   .GetCustomAttribute(typeof(IsThisViewCanBeUsedWithViewsSubsystemAttribute));

        return(type.Workplace == workplace);
    }
Example #4
0
        private void LoadProfileById(IFrameworkInputElement listViewItem)
        {
            MainWindow mainWindow = Application.Current.Windows.OfType <MainWindow>().FirstOrDefault();

            mainWindow?.LoadProfile(listViewItem?.Name);

            Close();
        }
Example #5
0
        } // CheckMoveWhite


        /// <inheritdoc />
        /// <summary>
        /// Проверить ход для чёрных.
        /// </summary>
        /// <param name="button1">Кнопка 1.</param>
        /// <param name="button2">Кнопка 2.</param>
        public bool CheckMoveBlack(IFrameworkInputElement button1, IFrameworkInputElement button2)
        {
            var currentBoard = GetCurrentBoard();
            var jumpMoves = currentBoard.CheckJumps("Black");

            if (jumpMoves.Count > 0) {
                var invalid = true;

                foreach (var move in jumpMoves)
                    if (CurrentMove.Equals(move))
                        invalid = false;

                if (invalid) {
                    DisplayMessage("Шашка оппонента должна быть взята.");
                    CurrentMove.Piece1 = null;
                    CurrentMove.Piece2 = null;
                    Console.WriteLine(Resources.GameWithAiViewModel_CheckMoveBlack_CheckMoveBlack__False);
                    return false;
                } // if
            } // if

            if (button1.Name.Contains("Black"))
                if (button1.Name.Contains("King")) {
                    if (CurrentMove.IsAdjacent("King") && !button2.Name.Contains("Black") && !button2.Name.Contains("White"))
                        return true;
                    var middlePiece = CurrentMove.CheckJump("King");

                    if (middlePiece != null && !button2.Name.Contains("Black") && !button2.Name.Contains("White")) {
                        var middleStackPanel = (StackPanel)GetGridElement(View.CheckersGrid, middlePiece.Row, middlePiece.Column);
                        var middleButton = (Button)middleStackPanel.Children[0];

                        if (middleButton.Name.Contains("White")) {
                            View.CheckersGrid.Children.Remove(middleStackPanel);
                            AddBlackButton(middlePiece);
                            return true;
                        } // if
                    } // if
                } else {
                    if (CurrentMove.IsAdjacent("Black") && !button2.Name.Contains("Black") && !button2.Name.Contains("White"))
                        return true;

                    var middlePiece = CurrentMove.CheckJump("Black");

                    if (middlePiece != null && !button2.Name.Contains("Black") && !button2.Name.Contains("White")) {
                        var middleStackPanel = (StackPanel)GetGridElement(View.CheckersGrid, middlePiece.Row, middlePiece.Column);
                        var middleButton = (Button)middleStackPanel.Children[0];
                        if (middleButton.Name.Contains("White")) {
                            View.CheckersGrid.Children.Remove(middleStackPanel);
                            AddBlackButton(middlePiece);
                            return true;
                        } // if
                    } // if
                } // if-else
            CurrentMove = null;
            DisplayMessage("Недопустимый ход. Повторите снова.");
            return false;
        } // CheckMoveBlack
Example #6
0
        public void RemoveControlLine(IFrameworkInputElement element, Grid grid)
        {
            var index = Convert.ToInt32(element.Name.Remove(0, element.Name.Length - 1));

            BindingLines.RemoveAt(index);
            ChangeIndexes();
            grid.RowDefinitions.RemoveAt(index);
            grid.Children.RemoveAt(index);
        }
        //------------------------------------------------------
        //
        //  Constructors
        //
        //------------------------------------------------------

        //------------------------------------------------------
        //
        //  Public Properties
        //
        //------------------------------------------------------

        // None

        //------------------------------------------------------
        //
        //  Public Methods
        //
        //------------------------------------------------------

        #region Public Methods

        /// <summary>
        /// Given an element in the logical tree to start searching from,
        /// searches all its descendent nodes in the logical tree a node whose Name
        /// matches the specified elementName.
        /// The given DependencyObject must be either a FrameworkElement or FrameworkContentElement.
        /// </summary>
        /// <remarks>
        /// We're searching in a depth-first manner.  Review this if this turns out
        ///  to be a performance problem.  We're doing this first because it's easy
        ///  and light on memory usage as compared to breadth-first.
        /// (RogerCh):It would be cool if the DFID (depth-first iterative-deepening)
        ///  algorithm would be useful here.
        /// </remarks>
        public static DependencyObject FindLogicalNode(DependencyObject logicalTreeNode, string elementName)
        {
            if (logicalTreeNode == null)
            {
                throw new ArgumentNullException("logicalTreeNode");
            }
            if (elementName == null)
            {
                throw new ArgumentNullException("elementName");
            }
            if (elementName == String.Empty)
            {
                throw new ArgumentException(SR.Get(SRID.StringEmpty), "elementName");
            }

            DependencyObject namedElement = null;
            DependencyObject childNode    = null;

            // Check given node against named element.
            IFrameworkInputElement selfNode = logicalTreeNode as IFrameworkInputElement;

            if (selfNode != null)
            {
                if (selfNode.Name == elementName)
                {
                    namedElement = logicalTreeNode;
                }
            }

            if (namedElement == null)
            {
                // Nope, the given node isn't it.  See if we can check children.
                IEnumerator childEnumerator = null;

                childEnumerator = LogicalTreeHelper.GetLogicalChildren(logicalTreeNode);

                // If we can enumerate, check the children.
                if (childEnumerator != null)
                {
                    childEnumerator.Reset();
                    while (namedElement == null &&
                           childEnumerator.MoveNext() == true)
                    {
                        childNode = childEnumerator.Current as DependencyObject;

                        if (childNode != null)
                        {
                            namedElement = FindLogicalNode(childNode, elementName);
                        }
                    }
                }
            }

            // Return what we can find - may be null.
            return(namedElement);
        }
Example #8
0
        void mouseDownHandler(object sender, MouseButtonEventArgs args)
        {
            KeyboardRecord kRA = null;

            kRA      = new KeyboardRecord();
            kRA.Name = "MouseDown";
            IFrameworkInputElement frameworkElement = (IFrameworkInputElement)args.Source;

            kRA.SourceID = frameworkElement.Name;
            AddRecord(kRA);
        }
Example #9
0
        internal static String InferJobName(object o)
        {
            String jobName = null;

            if (o != null)
            {
                IFrameworkInputElement inputElement = o as IFrameworkInputElement;
                if (inputElement != null)
                {
                    jobName = inputElement.Name;
                }
                if (jobName == null || jobName.Length == 0)
                {
                    jobName = o.ToString();
                }
            }

            return(jobName);
        }
        private static string CreateCustomizablePropertyName(IFrameworkInputElement child, IFrameworkInputElement childElementContent)
        {
            if (child == null)
            {
                throw new ArgumentNullException("child");
            }
            if (childElementContent == null)
            {
                throw new ArgumentNullException("childElementContent");
            }

            var name = childElementContent.Name;

            if (string.IsNullOrEmpty(name))
            {
                throw new Exception("Property Name of FrameworkElement childElementContent should be defined when used method CreateCustomizablePropertyName.");
            }

            return(string.Format("{0}_{1}_{2}", child.Name, childElementContent.GetType().Name, name));
        }
        }         // Save

        // ----------------------------------------------------------------------
        private static void OnDependencyPropertyChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e)
        {
            IFrameworkInputElement frameworkInputElement = dependencyObject as IFrameworkInputElement;

            if (frameworkInputElement == null)
            {
                Debug.WriteLine("DependencyPropertySetting: invalid framework element");
                return;
            }

            string elementName = frameworkInputElement.Name;

            if (string.IsNullOrEmpty(elementName))
            {
                Debug.WriteLine("DependencyPropertySetting: missing name for framework element " + frameworkInputElement);
                return;                 // name is required
            }

            DependencyProperty dependencyProperty = e.NewValue as DependencyProperty;

            if (dependencyProperty == null)
            {
                Debug.WriteLine("DependencyPropertySetting: missing dependency property");
                return;
            }

            // search on the parent-tree for application settings
            ApplicationSettings applicationSettings = FindParentSettings(dependencyObject);

            if (applicationSettings == null)
            {
                Debug.WriteLine("DependencyPropertySetting: missing application settings in parent hierarchy");
                return;
            }

            string settingName = string.Concat(elementName, ".", dependencyProperty.Name);

            applicationSettings.Settings.Add(
                new DependencyPropertySetting(settingName, dependencyObject, dependencyProperty));
        }         // OnDependencyPropertyChanged
        /// <summary>Attempts to find and return an object that has the specified name. The search starts from the specified object and continues into subnodes of the logical tree. </summary>
        /// <param name="logicalTreeNode">The object to start searching from. This object must be either a <see cref="T:System.Windows.FrameworkElement" /> or a <see cref="T:System.Windows.FrameworkContentElement" />.</param>
        /// <param name="elementName">The name of the object to find.</param>
        /// <returns>The object with the matching name, if one is found; returns <see langword="null" /> if no matching name was found in the logical tree.</returns>
        // Token: 0x06000763 RID: 1891 RVA: 0x00017104 File Offset: 0x00015304
        public static DependencyObject FindLogicalNode(DependencyObject logicalTreeNode, string elementName)
        {
            if (logicalTreeNode == null)
            {
                throw new ArgumentNullException("logicalTreeNode");
            }
            if (elementName == null)
            {
                throw new ArgumentNullException("elementName");
            }
            if (elementName == string.Empty)
            {
                throw new ArgumentException(SR.Get("StringEmpty"), "elementName");
            }
            DependencyObject       dependencyObject      = null;
            IFrameworkInputElement frameworkInputElement = logicalTreeNode as IFrameworkInputElement;

            if (frameworkInputElement != null && frameworkInputElement.Name == elementName)
            {
                dependencyObject = logicalTreeNode;
            }
            if (dependencyObject == null)
            {
                IEnumerator logicalChildren = LogicalTreeHelper.GetLogicalChildren(logicalTreeNode);
                if (logicalChildren != null)
                {
                    logicalChildren.Reset();
                    while (dependencyObject == null && logicalChildren.MoveNext())
                    {
                        DependencyObject dependencyObject2 = logicalChildren.Current as DependencyObject;
                        if (dependencyObject2 != null)
                        {
                            dependencyObject = LogicalTreeHelper.FindLogicalNode(dependencyObject2, elementName);
                        }
                    }
                }
            }
            return(dependencyObject);
        }
Example #13
0
        void SaveQuestion(IFrameworkInputElement category, IFrameworkInputElement question) {
            loadedQuestion = exam.Categories[ GetIdNum(category?.Name) ].Questions[ GetIdNum(question?.Name) ];

            loadedQuestion.Text = CategoryGrid.QuestionTextTextBox.Text;
            loadedQuestion.A.Text = CategoryGrid.AnswerOneTextBox.Text;
            loadedQuestion.B.Text = CategoryGrid.AnswerTwoTextBox.Text;
            loadedQuestion.C.Text = CategoryGrid.AnswerThreeTextBox.Text;
            loadedQuestion.D.Text = CategoryGrid.AnswerFourTextBox.Text;
            loadedQuestion.E.Text = CategoryGrid.AnswerFiveTextBox.Text;
            SaveCorrectAnswers();
        }
Example #14
0
 private void applyPanelLanguage(IFrameworkInputElement pnl, bool checkName = true)
 {
     try
     {
         var spnl = PNStatic.Panels.FirstOrDefault(p => p.Name == pnl.Name);
         if (spnl == null) return;
         if (spnl.Language == PNStatic.Settings.GeneralSettings.Language && checkName) return;
         PNLang.Instance.ApplyControlLanguage(pnl);
         if (spnl.Name == pnlGeneral.Name)
         {
             //special cases
             if (cboDeleteBin.Items.Count > 0)
             {
                 var index = cboDeleteBin.SelectedIndex;
                 cboDeleteBin.Items.RemoveAt(0);
                 cboDeleteBin.Items.Insert(0, PNLang.Instance.GetMiscText("never", "(Never"));
                 cboDeleteBin.SelectedIndex = index;
             }
             _ButtonSizes[0].Name = PNLang.Instance.GetCaptionText("b_size_normal", "Normal");
             _ButtonSizes[1].Name = PNLang.Instance.GetCaptionText("b_size_large", "Large");
             if (cboButtonsSize.Items.Count > 0)
             {
                 var index = cboButtonsSize.SelectedIndex;
                 cboButtonsSize.Items.Clear();
                 foreach (var bs in _ButtonSizes)
                 {
                     cboButtonsSize.Items.Add(bs);
                 }
                 cboButtonsSize.SelectedIndex = index;
             }
         }
         else if (pnl.Name == pnlProtection.Name)
         {
             var daysChecks = stkFullBackup.Children.OfType<CheckBox>();
             var ci = new CultureInfo(PNLang.Instance.GetLanguageCulture());
             foreach (var c in daysChecks)
             {
                 c.Content = ci.DateTimeFormat.GetAbbreviatedDayName((DayOfWeek)Convert.ToInt32(c.Tag));
             }
         }
         spnl.Language = PNStatic.Settings.GeneralSettings.Language;
     }
     catch (Exception ex)
     {
         PNStatic.LogException(ex);
     }
 }
Example #15
0
 public TextFieldInputDataAdapter(IFrameworkInputElement inputElement)
 {
     InputElement = inputElement;
 }
Example #16
0
        public int GetIndex(IFrameworkInputElement element)
        {
            int index = Convert.ToInt32(element.Name.Remove(0, element.Name.Length - 1));

            return(index);
        }
 private static bool ContainsItem(ItemsControl menu, IFrameworkInputElement menuItem)
 {
     foreach (MenuItem item in menu.Items)
     {
         if (item.Name == menuItem.Name)
             return true;
     }
     return false;
 }