当前位置: 首页>>代码示例>>C#>>正文


C# FrameworkElement.GetHashCode方法代码示例

本文整理汇总了C#中System.Windows.FrameworkElement.GetHashCode方法的典型用法代码示例。如果您正苦于以下问题:C# FrameworkElement.GetHashCode方法的具体用法?C# FrameworkElement.GetHashCode怎么用?C# FrameworkElement.GetHashCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.FrameworkElement的用法示例。


在下文中一共展示了FrameworkElement.GetHashCode方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ShowWindow

 /// <summary>
 /// Displays content in a window
 /// </summary>
 /// <param name="windowTitle">Title text shown in window</param>
 /// <param name="windowContents">Contents of the window</param>        
 /// <param name="isModal">Determines wheter the window is modal or not</param>
 /// <param name="onClosingHandler">Event handler invoked when window is closing, and can be handled to cancel window closure</param>
 /// <param name="onClosedHandler">Event handler invoked when window is closed</param>
 public void ShowWindow(string windowTitle, FrameworkElement windowContents, bool isModal = false, EventHandler<CancelEventArgs> onClosingHandler = null, EventHandler onClosedHandler = null)            
 {                        
     if (windowContents == null)
         throw new ArgumentNullException("windowContents");
     
     int hashCode = windowContents.GetHashCode();
     ChildWindow childWindow = null;
     if (!m_ChildWindows.TryGetValue(hashCode, out childWindow))
     {
         // not existing yet
         childWindow = new ChildWindow()
         {
             Title = windowTitle ?? string.Empty,
         };                
         if (onClosedHandler != null)
             childWindow.Closed += onClosedHandler;
         if (onClosingHandler != null)
             childWindow.Closing += onClosingHandler;
         childWindow.CloseCompleted += new EventHandler(childWindow_CloseCompleted);
         childWindow.Content = windowContents;
         m_ChildWindows.Add(hashCode, childWindow);
         if (!isModal) 
         { 
             windowContents.Loaded += (o, e) => {
                 DialogResizeHelper.CenterAndSizeDialog(windowContents, childWindow);
             };
             DialogResizeHelper.CenterAndSizeDialog(windowContents, childWindow);
         }
     }
     childWindow.ShowDialog(isModal);
 }
开发者ID:Esri,项目名称:arcgis-viewer-silverlight,代码行数:39,代码来源:WindowManager.cs

示例2: Track

        /// <summary>
        /// Starts tracking the provided ChildWindow.
        /// </summary>
        /// <param name="childWindow">The ChildWindow to be tracked.</param>
        public static void Track(FrameworkElement childWindow)
        {
            if (childWindow == null)
                throw new ArgumentNullException("childWindow");

            // Verify that the object is a ChildWindow or subclass
            Type windowType = childWindow.GetType();
            while (windowType != null && !String.Equals(windowType.FullName, "System.Windows.Controls.ChildWindow"))
                windowType = windowType.BaseType;

            if (windowType == null)
                throw new ArgumentException("Tracked element is not a subclass of ChildWindow", "childWindow");

            if (!s_childWindows.ContainsKey(childWindow.GetHashCode()))
                s_childWindows.Add(childWindow.GetHashCode(), new WeakReference(childWindow));
        }
开发者ID:mparsin,项目名称:Elements,代码行数:20,代码来源:PopupTracker.cs

示例3: ShowWindow

        /// <summary>
        /// Displays content in a window
        /// </summary>
        /// <param name="windowTitle">Title text shown in window</param>
        /// <param name="windowContents">Contents of the window</param>        
        /// <param name="isModal">Determines wheter the window is modal or not</param>
        /// <param name="onClosingHandler">Event handler invoked when window is closing, and can be handled to cancel window closure</param>
        /// <param name="windowType">The type of the window</param>
        /// <param name="onClosedHandler">Event handler invoked when window is closed</param>
        /// <param name="top">The distance from the top of the application at which to position the window</param>
        /// <param name="left">The distance from the left of the application at which to position the window</param>
        /// <returns>The window</returns>
        public object ShowWindow(string windowTitle, FrameworkElement windowContents, bool isModal = false, 
            EventHandler<CancelEventArgs> onClosingHandler = null, EventHandler onClosedHandler = null, 
            WindowType windowType = WindowType.Floating, double? top = null, double? left = null)            
        {                        
            if (windowContents == null)
                throw new ArgumentNullException("windowContents");

            int hashCode = windowContents.GetHashCode();
            FloatingWindow floatingWindow = null;
            if (!m_FloatingWindows.TryGetValue(hashCode, out floatingWindow))
            {
                // not existing yet
                floatingWindow = new FloatingWindow()
                {
                    Title = windowTitle ?? string.Empty,
                };

                switch (windowType)
                {
                    case WindowType.Floating:
                if (FloatingWindowStyle != null)
                    floatingWindow.Style = FloatingWindowStyle;
                        break;
                    case WindowType.DesignTimeFloating:
                        if (DesignTimeWindowStyle != null)
                            floatingWindow.Style = DesignTimeWindowStyle;
                        else if (FloatingWindowStyle != null) // fallback to FloatingWindowStyle
                            floatingWindow.Style = FloatingWindowStyle;
                        break;
                }

                floatingWindow.Closed += (o, e) =>
                {
                    if (onClosedHandler != null)
                        onClosedHandler.Invoke(o, e);

                    m_FloatingWindows.Remove(hashCode);

                    if (floatingWindow != null)
                        floatingWindow.Content = null;
                };

                if (onClosingHandler != null)
                    floatingWindow.Closing += onClosingHandler;
                floatingWindow.Content = windowContents;
                m_FloatingWindows.Add(hashCode, floatingWindow);
            }


            if (top != null)
                floatingWindow.VerticalOffset = (double)top;

            if (left != null)
                floatingWindow.HorizontalOffset = (double)left;

            floatingWindow.Show(isModal);

            return floatingWindow;
        }
开发者ID:konglingjie,项目名称:arcgis-viewer-silverlight,代码行数:71,代码来源:WindowManager.cs

示例4: RegisterElement

        public string RegisterElement(FrameworkElement element)
        {
            var registeredKey = this.registeredElements.FirstOrDefault(x => x.Value.Target == element).Key;

            if (registeredKey == null)
            {
                Interlocked.Increment(ref safeInstanceCount);

                registeredKey = element.GetHashCode() + "-" + safeInstanceCount.ToString(string.Empty, CultureInfo.InvariantCulture);
                this.registeredElements.Add(registeredKey, new WeakReference(element));
            }

            return registeredKey;
        }
开发者ID:sleekweasel,项目名称:winphonedriver,代码行数:14,代码来源:AutomatorElements.cs

示例5: GetBindingExpressionBaseForPropertyName

        private static BindingExpressionBase GetBindingExpressionBaseForPropertyName(
            FrameworkElement element,
            string dependencyPropertyName,
            bool thrownOnError)
        {
            BindingExpressionBase bindingExpressionBase = null;

            // Get the property to be validated
            var descriptor =
                DependencyPropertyDescriptor.FromName(dependencyPropertyName, element.GetType(), element.GetType());
            if (descriptor == null)
            {
                if (thrownOnError)
                {
                    throw new InvalidOperationException(
                        string.Format(
                            CultureInfo.CurrentCulture,
                            Resources.ExceptionMissingDependencyProperty,
                            dependencyPropertyName,
                            element.GetType().Name,
                            element.Name,
                            element.GetHashCode()));
                }
            }
            else
            {
                var dependencyProperty = descriptor.DependencyProperty;

                // Get the BindingExpression for the property to validate
                bindingExpressionBase = BindingOperations.GetBindingExpressionBase(element, dependencyProperty);
                if (bindingExpressionBase == null)
                {
                    if (thrownOnError)
                    {
                        throw new InvalidOperationException(
                            string.Format(
                                CultureInfo.CurrentCulture,
                                Resources.ExceptionDependencyPropertyHasNoBinding,
                                dependencyPropertyName,
                                element.GetType().Name,
                                element.Name,
                                element.GetHashCode()));
                    }
                }
            }

            return bindingExpressionBase;
        }
开发者ID:HondaBey,项目名称:EnterpriseLibrary6,代码行数:48,代码来源:Validate.cs

示例6: ApplyTemplateContent

        //  ===========================================================================
        //  These methods are invoked to during a call call to
        //  FE.EnsureVisual or FCE.EnsureLogical
        //  ===========================================================================

        #region InstantiateSubTree

        //
        //  This method
        //  Creates the VisualTree
        //
        //[CodeAnalysis("AptcaMethodsShouldOnlyCallAptcaMethods")] //Tracking Bug: 29647
        internal bool ApplyTemplateContent(
            UncommonField<HybridDictionary[]> templateDataField,
            FrameworkElement container)
        {
#if STYLE_TRACE
            _timer.Begin();
#endif

            if (TraceDependencyProperty.IsEnabled)
            {
                TraceDependencyProperty.Trace(
                    TraceEventType.Start,
                    TraceDependencyProperty.ApplyTemplateContent,
                    container,
                    this);
            }


            ValidateTemplatedParent(container);

            bool visualsCreated = StyleHelper.ApplyTemplateContent(templateDataField, container,
                _templateRoot, _lastChildIndex,
                ChildIndexFromChildName, this);

            if (TraceDependencyProperty.IsEnabled)
            {
                TraceDependencyProperty.Trace(
                    TraceEventType.Stop,
                    TraceDependencyProperty.ApplyTemplateContent,
                    container,
                    this);
            }


#if STYLE_TRACE
            _timer.End();
            if (visualsCreated)
            {
                string label = container.ID;
                if (label == null || label.Length == 0)
                    label = container.GetHashCode().ToString();
                Console.WriteLine("  Style.VT created for {0} {1} in {2:f2} msec",
                    container.GetType().Name, label, _timer.TimeOfLastPeriod);
            }
#endif

            return visualsCreated;
        }
开发者ID:mind0n,项目名称:hive,代码行数:60,代码来源:FrameworkTemplate.cs

示例7: HideWindow

        /// <summary>
        /// Hides the dialog window 
        /// </summary>
        /// <param name="windowContents">Contents of the window displayed earlier using ShowWindow</param>
        public void HideWindow(FrameworkElement windowContents)
        {
            if (windowContents == null)
                throw new ArgumentNullException("windowContents");

            int hashCode = windowContents.GetHashCode();
            ChildWindow childWindow = null;
            if (m_ChildWindows.TryGetValue(hashCode, out childWindow))
            {
                childWindow.Close();
                // close will automatically remove the window from the hash table in childWindow_Closed
            }             
        }                
开发者ID:Esri,项目名称:arcgis-viewer-silverlight,代码行数:17,代码来源:WindowManager.cs


注:本文中的System.Windows.FrameworkElement.GetHashCode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。