Пример #1
0
        private void UpdateCheckBoxes()
        {
            if (!_isLoaded || _cleaningExtraItems || TargetCollection == null)
            {
                return;
            }
            try
            {
                _cleaningExtraItems = true;

                foreach (object obj in this.sourceListBox.Items)
                {
                    ListBoxItem container = this.sourceListBox.ItemContainerGenerator.ContainerFromItem(obj) as ListBoxItem;
                    if (container != null)
                    {
                        IList <DependencyObject> list = new List <DependencyObject>();
                        VTreeHelper.GetChildrenOfType(container, typeof(CheckBox), ref list);
                        if (list.Count > 0)
                        {
                            ((CheckBox)list[0]).IsChecked = TargetCollectionEdited.Contains(obj);
                        }
                    }
                }
            }
            finally
            {
                _cleaningExtraItems = false;
            }
        }
Пример #2
0
        protected override void ClearContainerForItemOverride(DependencyObject element, object item)
        {
            IList <DependencyObject> list = new List <DependencyObject>();

            VTreeHelper.GetChildrenOfType(element, typeof(C1TileBase), ref list);
            foreach (C1TileBase tile in list)
            {
                tile.IsFrozen = true;
            }
            base.ClearContainerForItemOverride(element, item);
        }
#pragma warning disable 1591
        protected override void OnPreviewKeyDown(KeyEventArgs e)
        {
            if (e.Key == Key.Escape)
            {
                DependencyObject parentControl = VTreeHelper.GetParentOfType((DependencyObject)e.OriginalSource, GetType());
                if (parentControl != null)
                {
                    PART_DialogCancelButton_Click(this, null);
                }
            }
            base.OnPreviewKeyDown(e);
        }
        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            if (!_isLoaded)
            {
                _pattern = DataContext as RecurrencePattern;

                if (!System.Windows.Interop.BrowserInteropHelper.IsBrowserHosted)
                {
                    _parentWindow = (ContentControl)VTreeHelper.GetParentOfType(this, typeof(Window));
                }
                else
                {
                    _parentWindow = (ContentControl)VTreeHelper.GetParentOfType(this, typeof(C1Window));
                }
                if (_parentWindow != null)
                {
                    _appointment = _parentWindow.Tag as Appointment;
                    if (_appointment != null && _appointment.ParentCollection != null)
                    {
                        Scheduler = ((C1ScheduleStorage)_appointment.ParentCollection.ParentStorage.ScheduleStorage).Scheduler;
                    }
                    if (_parentWindow.Resources.Contains("IsOld"))
                    {
                        _isOld = (bool)_parentWindow.Resources["IsOld"];
                    }
                    PART_DialogCustomButton.IsEnabled = _isOld;
                    if (_parentWindow is Window)
                    {
                        ((Window)_parentWindow).Closed += new EventHandler(_parentWindow_Closed);
                    }
                    else
                    {
                        ((C1Window)_parentWindow).Closed += new EventHandler(_parentWindow_Closed);
                    }
                }
                if (_parentWindow != null)
                {
                    ((INotifyPropertyChanged)_pattern).PropertyChanged += new PropertyChangedEventHandler(EditRecurrenceControl_PropertyChanged);
                    InitializeEnums();
                }
                startTime.Focus();
                endTime.DateTime        = _pattern.EndTime;
                duration.Value          = _pattern.Duration;
                patternEndDate.DateTime = _pattern.PatternEndDate;

                UpdateRecurrenceType();
                UpdateDayOfWeekMaskControls();
                UpdateRangeControls();
                _isLoaded = true;
            }
        }
Пример #5
0
        // The default GridView virtualization reuses the ContentTemplate visual tree for different elements.
        // The GridView creates the limited number of C1Tile objects and reuses them at scrolling.
        // So, the C1Tile content is changed when end-user scrolls the GridView.
        // Unfortunately, WrapGrid doesn't honor VirtualizingStackPanel.VirtualizationMode="Standard" setting.
        // So we need some code to workaround this issue.
        // To avoid ContentChange animations while scrolling, freeze tiles in the ClearContainerForItemOverride
        // and unfreeze after reusing them for the new item.
        protected override void PrepareContainerForItemOverride(DependencyObject element, object item)
        {
            base.PrepareContainerForItemOverride(element, item);
            IList <DependencyObject> list = new List <DependencyObject>();

            VTreeHelper.GetChildrenOfType(element, typeof(C1TileBase), ref list);
            Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Low, () =>
            {
                // unfreeze tile after changing tile content.
                foreach (C1TileBase tile in list)
                {
                    tile.IsFrozen = false;
                }
            });
        }
 protected override void OnPreviewKeyDown(KeyEventArgs e)
 {
     if (e.Key == Key.Escape)
     {
         DependencyObject parentControl = VTreeHelper.GetParentOfType((DependencyObject)e.OriginalSource, GetType());
         if (parentControl != null)
         {
             if (_parentWindow is Window)
             {
                 ((Window)_parentWindow).Close();
             }
             else
             {
                 ((C1Window)_parentWindow).DialogResult = MessageBoxResult.Cancel;
             }
         }
     }
     base.OnPreviewKeyDown(e);
 }
Пример #7
0
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            FrameworkElement el = value as FrameworkElement;

            if (el != null)
            {
                SchedulerGroupItem group = el.DataContext as SchedulerGroupItem;
                int index = -1;
                if (group != null)
                {
                    ItemsControl itm = VTreeHelper.GetParentOfType(el, typeof(ItemsControl)) as ItemsControl;
                    if (itm != null)
                    {
                        object data = itm.DataContext;

                        ItemsControl itmParent = VTreeHelper.GetParentOfType(itm, typeof(ItemsControl)) as ItemsControl;
                        if (itmParent != null)
                        {
                            index = itmParent.Items.IndexOf(data);
                            VisualIntervalGroup visualIntervalGroup = group.VisualIntervalGroups[index] as VisualIntervalGroup;
                            string param = (string)parameter;
                            if (param.ToLower() == "self")
                            {
                                // create list of a single VisualIntervalGroup
                                // (we need list to use it as ItemsSource)
                                List <object> list = new List <object>();
                                list.Add(visualIntervalGroup);
                                return(list);
                            }
                            else
                            {
                                return(visualIntervalGroup.VisualIntervals);
                            }
                        }
                    }
                }
            }
            return(null);
        }
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();
            if (DropDown != null)
            {
                _elementDropDown.KeyDown += new KeyEventHandler(_elementDropDown_KeyDown);
            }

            if (TreeView != null)
            {
                _elementTreeView.ApplyTemplate();
                if (ScrollViewerStyle != null)
                {
                    IList <DependencyObject> list = new List <DependencyObject>();
                    VTreeHelper.GetChildrenOfType(_elementTreeView, typeof(ScrollViewer), ref list);
                    foreach (ScrollViewer sv in list)
                    {
                        sv.Style = ScrollViewerStyle;
                    }
                }
            }
        }
Пример #9
0
 private void root_Loaded(object sender, RoutedEventArgs e)
 {
     if (!_isLoaded)
     {
         if (!System.Windows.Interop.BrowserInteropHelper.IsBrowserHosted)
         {
             _parentWindow = (ContentControl)VTreeHelper.GetParentOfType(this, typeof(Window));
         }
         else
         {
             _parentWindow = (ContentControl)VTreeHelper.GetParentOfType(this, typeof(C1Window));
         }
         if (_parentWindow != null)
         {
             if (Scheduler == null)
             {
                 Scheduler = _parentWindow.DataContext as C1Scheduler;
             }
             if (_parentWindow is Window)
             {
                 ((Window)_parentWindow).Closed += new EventHandler(_parentWindow_Closed);
             }
             else
             {
                 ((C1Window)_parentWindow).Closed             += new EventHandler(_parentWindow_Closed);
                 ((C1Window)_parentWindow).WindowStateChanged += new EventHandler <PropertyChangedEventArgs <C1WindowState> >(_parentWindow_WindowStateChanged);
             }
         }
         UpdateTitle();
         remList.SelectionChanged += new SelectionChangedEventHandler(remList_SelectionChanged);
         UpdateTimer(1);
         remList.Focus();
         _isLoaded = true;
     }
     ShowRemindersControl_CollectionChanged(null, null);
 }
Пример #10
0
        private void EditAppointmentControl_Loaded(object sender, RoutedEventArgs e)
        {
            if (!_isLoaded)
            {
                _appointment = DataContext as Appointment;

                _defaultStart    = _appointment.AllDayEvent ? TimeSpan.FromHours(8) : _appointment.Start.TimeOfDay;
                _defaultDuration = _appointment.AllDayEvent ? TimeSpan.FromMinutes(30) : _appointment.Duration;
                if (!System.Windows.Interop.BrowserInteropHelper.IsBrowserHosted)
                {
                    _parentWindow = (ContentControl)VTreeHelper.GetParentOfType(this, typeof(Window));
                }
                else
                {
                    _parentWindow = (ContentControl)VTreeHelper.GetParentOfType(this, typeof(C1Window));
                }
                if (_parentWindow != null)
                {
                    Binding bnd = new Binding("Header");
                    bnd.Source = this;
                    if (_parentWindow is Window)
                    {
                        _parentWindow.SetBinding(Window.TitleProperty, bnd);
                    }
                    else
                    {
                        _parentWindow.SetBinding(C1Window.HeaderProperty, bnd);
                    }

                    if (_parentWindow is Window)
                    {
                        ((Window)_parentWindow).Closed += new EventHandler(_parentWindow_Closed);
                    }
                    else
                    {
                        ((C1Window)_parentWindow).Closed += new EventHandler(_parentWindow_Closed);
                    }
                }
                if (_appointment != null)
                {
                    ((System.ComponentModel.INotifyPropertyChanged)_appointment).PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(appointment_PropertyChanged);
                    if (_appointment.ParentCollection != null)
                    {
                        _scheduler = ((C1ScheduleStorage)_appointment.ParentCollection.ParentStorage.ScheduleStorage).Scheduler;

                        AppointmentBOList _os = (AppointmentBOList)_scheduler.DataStorage.AppointmentStorage.List;
                        var _list             = _os.Where(w => w.Id.Equals(_appointment.Key[0])).ToList();

                        foreach (AppointmentBusinessObject _item in _list)
                        {
                            _hidid.Text = _item.BOProperty1.ToString();
                        }

                        if (_appointment.AllDayEvent)
                        {
                            _defaultStart    = _scheduler.CalendarHelper.StartDayTime;
                            _defaultDuration = _scheduler.CalendarHelper.Info.TimeScale;
                        }
                    }
                    UpdateWindowHeader();
                    UpdateRecurrenceState();
                    UpdateCollections();
                    UpdateEndCalendar();
                    if (_appointment.AllDayEvent)
                    {
                        startCalendar.EditMode = endCalendar.EditMode = C1DateTimePickerEditMode.Date;
                    }
                    else
                    {
                        startCalendar.EditMode = endCalendar.EditMode = C1DateTimePickerEditMode.DateTime;
                    }
                    UpdateEditingControls();
                }
                if (_parentWindow != null && _appointment != null)
                {
                    _isLoaded = true;
                }
            }
            subject.Focus();
        }
Пример #11
0
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            Page parent = VTreeHelper.GetParentOfType(this, typeof(Page)) as Page;
        }
Пример #12
0
        public void OnNavigatedTo(string fragment)
        {
            fragment = "/" + Uri.UnescapeDataString(fragment);
            var args = fragment.Split('/');
            FeatureDescription feature = null;

            if (args.Length > 1)
            {
                var control = MainViewModel.Instance.Controls.FirstOrDefault(c => c.Name.Equals(args[1]));
                if (control != null)
                {
                    feature = control.GetAllFeatures().FirstOrDefault(f => f.Link.OriginalString == fragment);
                }
            }
            else
            {
                feature = MainViewModel.Instance.Features.FirstOrDefault(f => f.Link.OriginalString == fragment);
            }
            if (feature.SubFeatures.Count != 0)
            {
                FeatureDescription toSelect = feature.SubFeatures[0];
                foreach (var f in feature.SubFeatures)
                {
                    if (f.IsNew)
                    {
                        toSelect = f;
                    }
                }
                feature.IsExpanded = true;
                feature            = toSelect;
            }
            if (feature != null)
            {
                try
                {
                    Title = feature.Control.Name + " - " + feature.Name;
                    var assembly = Assembly.LoadFrom(feature.AssemblyName);
                    feature.Sample = assembly.CreateInstance(feature.FullDemoControlTypeName) as FrameworkElement;
                    properties.AvailableEditors.Insert(0, new TimeSpanEditor());
                    properties.AvailableEditors.Insert(0, new NumericEditor());
                    properties.AvailableEditors.Insert(0, new ReadOnlyImageSourceEditor());
                    properties.AvailableEditors.Insert(0, new CornerRadiusEditor());
                    properties.PropertyAttributes.Clear();
                    LoadCollection <PropertyAttribute>(properties.PropertyAttributes, feature.Properties);
                    DataContext = feature;
                    if (feature.Sample == null)
                    {
                        code.ContainsSample = false;
                    }
                    else
                    {
                        code.ContainsSample = true;
                        code.Source         = feature.Source;
                    }

                    Dispatcher.BeginInvoke(new Action(() =>
                    {
                        this.UpdateLayout();
                        var mask = properties.SelectedObject as BasicControls.DemoMaskedTextBox;
                        if (mask != null)
                        {
                            foreach (PropertyBox box in properties.PropertyBoxes)
                            {
                                if (box.CurrentEditor != null && box.CurrentEditor is StringEditor && box.PropertyAttribute.DisplayName == "Text")
                                {
                                    TextBox txt           = box.CurrentEditor as TextBox;
                                    txt.PreviewTextInput += txt_PreviewTextInput;
                                    txt.TextChanged      += txt_TextChanged;
                                    break;
                                }
                            }
                        }
                        var item = FindItem(tree, feature);

                        if (item != null)
                        {
                            item.IsSelected = true;
                            IList <DependencyObject> list = new List <DependencyObject>();
                            VTreeHelper.GetChildrenOfType(tree, typeof(ScrollViewer), ref list);
                            if (list.Count > 0)
                            {
                                ScrollViewer scv = list[0] as ScrollViewer;
                                Point point      = item.TransformToVisual(scv).Transform(new Point(scv.HorizontalOffset, scv.VerticalOffset));
                                Rect rect        = new Rect(point, new Point(point.X + item.ActualWidth, point.Y + item.ActualHeight));
                                if (scv.VerticalOffset > rect.Top)
                                {
                                    scv.ScrollToVerticalOffset(rect.Top);
                                }
                                else if (scv.VerticalOffset < rect.Bottom - scv.ViewportHeight)
                                {
                                    scv.ScrollToVerticalOffset(rect.Bottom - scv.ViewportHeight);
                                }
                            }
                        }
                    }), System.Windows.Threading.DispatcherPriority.Loaded);
                }
                catch (Exception exc)
                {
                    if (exc.InnerException != null &&
                        exc.InnerException.Message != null &&
                        exc.InnerException.Message.Contains(ControlExplorer.Properties.Resources.SamplePage_ExceptionText))
                    {
                        Dispatcher.BeginInvoke(new Action(() =>
                        {
                            MessageBox.Show(ControlExplorer.Properties.Resources.SamplePage_MsgBoxText);
                        }), null);
                    }
                    if (NavigationService.CanGoBack)
                    {
                        NavigationService.GoBack();
                    }
                }
            }
        }