Exemple #1
0
        protected override void OnClick()
        {
            if (!IsNotMenuButton)
            {
                var parent = FindParentWindow();
                if (parent != null)
                {
                    //Ищем лукапы
                    if (VisualTreeHelperExt.FindChildsByType <CustomComboBoxEditRcl>(parent).Any(lookup => lookup.PreviewHotKey(HotKey, HotKey2)))
                    {
                        return;
                    }

                    if (TransferHotKeyToControls)
                    {
                        //Ищем списки
                        if (VisualTreeHelperExt.FindChildsByType <CustomSelectControl>(parent)
                            .Any(c =>
                        {
                            if (c.Visibility == Visibility.Visible && c.IsEnabled)
                            {
                                c.Focus();
                            }
                            return(c.PreviewHotKey(HotKey, HotKey2));
                        }))
                        {
                            return;
                        }
                    }
                }
            }
            base.OnClick();
        }
        protected override void OnWriteElementToXML(XmlWriter xml, FrameworkElement element)
        {
            base.OnWriteElementToXML(xml, element);

            if (DoNotUseChildrenLayout)
            {
                return;
            }

            var layoutItem = element as LayoutItem;

            if (layoutItem == null || layoutItem.Content == null)
            {
                return;
            }

            foreach (var p in VisualTreeHelperExt.FindChildsByType <RclGridControl>(layoutItem.Content))
            {
                var xmlcontent = p.SaveLayoutToString();
                var key        = CreateCustomizablePropertyName(layoutItem, p);
                xml.WriteAttributeString(key, xmlcontent);
            }

            foreach (var p in VisualTreeHelperExt.FindChildsByType <CustomComboBoxEditRcl>(layoutItem.Content))
            {
                if (!string.IsNullOrEmpty(p.LayoutValue))
                {
                    var key = CreateCustomizablePropertyName(layoutItem, p);
                    xml.WriteAttributeString(key, p.LayoutValue);
                }
            }
        }
        protected override void OnReadElementFromXML(XmlReader xml, FrameworkElement element)
        {
            base.OnReadElementFromXML(xml, element);

            if (DoNotUseChildrenLayout)
            {
                return;
            }

            var layoutItem = element as LayoutItem;

            if (layoutItem == null || layoutItem.Content == null)
            {
                return;
            }

            foreach (var p in VisualTreeHelperExt.FindChildsByType <RclGridControl>(layoutItem.Content))
            {
                var key        = CreateCustomizablePropertyName(layoutItem, p);
                var xmlcontent = xml.GetAttribute(key);
                if (string.IsNullOrEmpty(xmlcontent))
                {
                    continue;
                }

                p.RestoreLayoutFromString(xmlcontent);
            }

            foreach (var p in VisualTreeHelperExt.FindChildsByType <CustomComboBoxEditRcl>(layoutItem.Content))
            {
                var key        = CreateCustomizablePropertyName(layoutItem, p);
                var xmlcontent = xml.GetAttribute(key);
                p.LayoutValue = xmlcontent;
            }
        }
Exemple #4
0
 protected override void OnPreviewKeyDown(KeyEventArgs e)
 {
     foreach (var p in VisualTreeHelperExt.FindChildsByType <CustomButton>(this).Where(p => p.IsHotKey(e.Key)))
     {
         p.PreviewHotKey(e);
     }
     base.OnPreviewKeyDown(e);
 }
        public static void ScaleTransform(DependencyObject parent, double tileLayoutControlActualWidth, double tileLayoutControlActualHeight)
        {
            var length = Math.Min(tileLayoutControlActualWidth, tileLayoutControlActualHeight) - 4;
            var minlen = (length - 24.0) / 3.0;

            foreach (var tile in VisualTreeHelperExt.FindChildsByType(parent, typeof(CustomTile)).OfType <CustomTile>())
            {
                var scalex = minlen / tile.ActualWidth;
                tile.LayoutTransform = new ScaleTransform(scalex, minlen / tile.ActualHeight);
            }
        }
Exemple #6
0
 protected override void OnPreviewKeyDown(System.Windows.Input.KeyEventArgs e)
 {
     try
     {
         foreach (var tile in VisualTreeHelperExt.FindChildsByType(this, typeof(CustomTile)).OfType <CustomTile>())
         {
             tile.PreviewHotKey(e);
         }
     }
     finally
     {
         base.OnPreviewKeyDown(e);
     }
 }
Exemple #7
0
        public static void ViewPreviewKeyDown(DependencyObject obj, KeyEventArgs e)
        {
            if (e.Handled)
            {
                return;
            }

            //Обработчик горячих клавиш меню
            foreach (var p in VisualTreeHelperExt.FindChildsByType <CustomButton>(obj).Where(p => p.IsHotKey(e.Key)))
            {
                if (p.PreviewHotKey(e))
                {
                    return;
                }
            }

            //Лукапы
            if (!e.Handled)
            {
                foreach (var p in VisualTreeHelperExt.FindChildsByType <CustomComboBoxEditRcl>(obj))
                {
                    if (p.PreviewHotKey(e))
                    {
                        return;
                    }
                }
            }

            if (!e.Handled)
            {
                var customSelectControl = VisualTreeHelperExt.FindChildsByType(obj, typeof(CustomSelectControl)).FirstOrDefault() as CustomSelectControl;
                if (customSelectControl != null)
                {
                    customSelectControl.PreviewHotKey(e);
                    if (customSelectControl.ParentKeyPreview)
                    {
                        customSelectControl.PreviewItemHotKey(e);
                    }
                }
            }
        }
Exemple #8
0
        private void OnSelectedTabChildChanged(object sender, ValueChangedEventArgs <FrameworkElement> e)
        {
            var group = e.NewValue as LayoutGroup;

            if (group == null || group.Children == null)
            {
                return;
            }

            var vm = DataContext as ILoadImageHandler;

            if (vm == null)
            {
                return;
            }

            if (VisualTreeHelperExt.FindChildsByType <SubImageView>(group).Any())
            {
                vm.LoadImage();
                UnsubscribeOnSelectedTabChildChanged();
            }
        }
Exemple #9
0
        private Window FindParentWindow()
        {
            var result = VisualTreeHelperExt.GetLogicalParent <Window>(this);

            return(result ?? Application.Current.Windows.OfType <Window>().FirstOrDefault(w => w.IsActive));
        }