コード例 #1
0
        private void LoadActiveGangWidget(List <Character> gangMembers)
        {
            if (gangMembers != null && PopupService.IsOpen("ActiveCharacterWidgetView") == false)
            {
                Character gangLeader = gangMembers.FirstOrDefault(m => m.IsGangLeader);

                System.Windows.Style style = Helper.GetCustomWindowStyle();
                double minwidth            = 80;
                style.Setters.Add(new Setter(Window.MinWidthProperty, minwidth));
                var    desktopWorkingArea = System.Windows.SystemParameters.WorkArea;
                double left     = desktopWorkingArea.Right - 500;
                double top      = desktopWorkingArea.Bottom - 80 * gangLeader.OptionGroups.Count;
                object savedPos = PopupService.GetPosition("ActiveCharacterWidgetView", gangLeader.Name);
                if (savedPos != null)
                {
                    double[] posArray = (double[])savedPos;
                    left = posArray[0];
                    top  = posArray[1];
                }
                style.Setters.Add(new Setter(Window.LeftProperty, left));
                style.Setters.Add(new Setter(Window.TopProperty, top));
                ActiveCharacterWidgetViewModel viewModel = this.Container.Resolve <ActiveCharacterWidgetViewModel>();
                PopupService.ShowDialog("ActiveCharacterWidgetView", viewModel, "", false, null, new SolidColorBrush(Colors.Transparent), style, WindowStartupLocation.Manual);
                this.eventAggregator.GetEvent <ActivateGangEvent>().Publish(gangMembers);
                Helper.GlobalVariables_CurrentActiveWindowName = Constants.ACTIVE_CHARACTER_WIDGET;
            }
        }
コード例 #2
0
        //Add the Node to the DiagramModel
        private Node addNodes(String name, String label, Int32 level, double offsetx, double offsety, double width, double height, Shapes shape)
        {
            Node node = new Node(Guid.NewGuid(), name);

            node.Label                  = label;
            node.Level                  = level;
            node.OffsetX                = offsetx;
            node.OffsetY                = offsety;
            node.Width                  = width;
            node.Height                 = height;
            node.LabelForeground        = Brushes.White;
            node.LabelVerticalAlignment = VerticalAlignment.Center;
            node.EnableMultilineLabel   = true;
            node.LabelTextWrapping      = TextWrapping.Wrap;
            node.Shape                  = shape;
            node.IsLabelEditable        = true;
            Style s = new System.Windows.Style();

            s.TargetType = typeof(Path);
            s.BasedOn    = node.CustomPathStyle;
            s.Setters.Add(new Setter(Path.FillProperty, new SolidColorBrush(Colors.SteelBlue)));
            s.Setters.Add(new Setter(Path.StretchProperty, Stretch.Fill));
            node.CustomPathStyle = s;
            diagramModel.Nodes.Add(node);
            return(node);
        }
コード例 #3
0
        private void LoadActiveCharacterWidget(Tuple <Character, string, string> tuple)
        {
            Character character       = tuple.Item1;
            string    optionGroupName = tuple.Item2;
            string    optionName      = tuple.Item3;

            if (character != null && PopupService.IsOpen("ActiveCharacterWidgetView") == false)
            {
                System.Windows.Style style = Helper.GetCustomWindowStyle();
                double minwidth            = 80;
                style.Setters.Add(new Setter(Window.MinWidthProperty, minwidth));
                var    desktopWorkingArea = System.Windows.SystemParameters.WorkArea;
                double left     = desktopWorkingArea.Right - 500;
                double top      = desktopWorkingArea.Bottom - 80 * character.OptionGroups.Count;
                object savedPos = PopupService.GetPosition("ActiveCharacterWidgetView", character.Name);
                if (savedPos != null)
                {
                    double[] posArray = (double[])savedPos;
                    left = posArray[0];
                    top  = posArray[1];
                }
                style.Setters.Add(new Setter(Window.LeftProperty, left));
                style.Setters.Add(new Setter(Window.TopProperty, top));
                ActiveCharacterWidgetViewModel viewModel = this.Container.Resolve <ActiveCharacterWidgetViewModel>();
                PopupService.ShowDialog("ActiveCharacterWidgetView", viewModel, "", false, null, new SolidColorBrush(Colors.Transparent), style, WindowStartupLocation.Manual);
                this.eventAggregator.GetEvent <ActivateCharacterEvent>().Publish(tuple);
                Helper.GlobalVariables_CurrentActiveWindowName = Constants.ACTIVE_CHARACTER_WIDGET;
            }
            else if (character == null && PopupService.IsOpen("ActiveCharacterWidgetView"))
            {
                this.CloseActiveCharacterWidget(null);
            }
        }
コード例 #4
0
ファイル: KinectDance.cs プロジェクト: rudylee/WpfApp
        public KinectDance(double layoutHeight, double layoutWidth, List<TextBlock> menus, Style mouseOverStyle, Border menuBorder,TextBox debugBox = null)
        {
            _layoutHeight = layoutHeight;
            _layoutWidth = layoutWidth;
            _debugBox = debugBox;
            _menus = menus;
            _menuBorder = menuBorder;
            _mouseOverStyle = mouseOverStyle;

            _kinect = KinectSensor.KinectSensors.FirstOrDefault();

            if (_kinect == null) return;
            //_kinect.SkeletonStream.TrackingMode = SkeletonTrackingMode.Seated;
            _kinect.Start();

            _kinect.ColorStream.Enable();
            _kinect.SkeletonStream.Enable(new TransformSmoothParameters
                {
                    Smoothing = 0.7f,
                    Correction = 0.3f,
                    Prediction = 0.4f,
                    JitterRadius = 0.5f,
                    MaxDeviationRadius = 0.5f
                });

            _kinect.SkeletonFrameReady += kinect_SkeletonFrameReady;
        }
コード例 #5
0
        public TreeViewHandler()
        {
            Control = new EtoTreeView();
            var template = new sw.HierarchicalDataTemplate(typeof(ITreeItem));

            template.VisualTree  = WpfListItemHelper.ItemTemplate();
            template.ItemsSource = new swd.Binding {
                Converter = new WpfTreeItemHelper.ChildrenConverter()
            };
            Control.ItemTemplate = template;

            var style = new sw.Style(typeof(swc.TreeViewItem));

            //style.Setters.Add (new sw.Setter (swc.TreeViewItem.IsExpandedProperty, new swd.Binding { Converter = new WpfTreeItemHelper.IsExpandedConverter (), Mode = swd.BindingMode.OneWay }));
            style.Setters.Add(new sw.Setter(swc.TreeViewItem.IsExpandedProperty, new swd.Binding {
                Path = expandedProperty, Mode = swd.BindingMode.TwoWay
            }));
            Control.ItemContainerStyle = style;

            ITreeItem oldSelectedItem = null;

            Control.CurrentItemChanged += (sender, e) => {
                Control.Dispatcher.BeginInvoke(new Action(() => {
                    var newSelected = this.SelectedItem;
                    if (oldSelectedItem != newSelected)
                    {
                        Widget.OnSelectionChanged(EventArgs.Empty);
                        oldSelectedItem = newSelected;
                        this.RefreshData();
                    }
                }));
            };
        }
コード例 #6
0
        private void SetStyleButton(string skin, System.Windows.Style style, object key)
        {
            string          keyString;
            ImageSource     image;
            ControlTemplate controlTemplate;

            if (key is string)
            {
                keyString = key as string;

                switch (keyString)
                {
                case "UserControlDefaultLogin.Button":
                    //style.Setters.Add(new Setter(Button.BackgroundProperty, new SolidColorBrush(this.GetAttributeMediaColor($"{skin}.UserControlDefaultLogin.Button.Background"))));
                    //style.Setters.Add(new Setter(Button.ForegroundProperty, new SolidColorBrush(this.GetAttributeMediaColor($"{skin}.UserControlDefaultLogin.Button.Foreground"))));

                    //controlTemplate = new ControlTemplate(typeof(Button));

                    //style.Setters.Add(new Setter(System.Windows.Controls.Control.TemplateProperty, controlTemplate));

                    break;
                }
            }
            else
            {
            }
        }
コード例 #7
0
ファイル: Window1.xaml.cs プロジェクト: Abbas1546/WPF
        //Add the Node to DiagramModel
        private Node addNode(String name, double offsetx, double offsety, double width, double height)
        {
            Node node = new Node(Guid.NewGuid());

            node.OffsetX = offsetx;
            node.OffsetY = offsety;
            node.Width   = width;
            node.Height  = height;

            if (name != "")
            {
                node.Shape = Shapes.Rectangle;
                Style s = new System.Windows.Style();
                s.BasedOn    = node.CustomPathStyle;
                s.TargetType = typeof(Path);
                s.Setters.Add(new Setter(Path.FillProperty, new SolidColorBrush(Colors.Transparent)));
                s.Setters.Add(new Setter(Path.StrokeProperty, new SolidColorBrush(Colors.Transparent)));
                s.Setters.Add(new Setter(Path.StretchProperty, Stretch.Fill));
                node.CustomPathStyle = s;
                node.AllowSelect     = false;
                node.Loaded         += new RoutedEventHandler(node_Loaded);
                node.Label           = name;
            }
            else
            {
                node.Shape = Shapes.CustomPath;
            }
            diagramModel.Nodes.Add(node);

            return(node);
        }
コード例 #8
0
        private void LoadStyleTest()
        {
            Style txtStyle = new System.Windows.Style()
            {
                TargetType = typeof(TextBox)
            };

            txtStyle.Setters.Add(new Setter()
            {
                Property = TextBox.IsReadOnlyProperty, Value = _pageType == PageTypes.Search?true:false
            });
            txtStyle.Setters.Add(new EventSetter(TextBox.TextChangedEvent, new TextChangedEventHandler(TextBox_TextChanged)));

            LayOutGrid.Resources.Add(typeof(TextBox), txtStyle);
            Style rBtnStyle = new System.Windows.Style()
            {
                TargetType = typeof(RadioButton)
            };

            rBtnStyle.Setters.Add(new Setter()
            {
                Property = RadioButton.IsEnabledProperty, Value = _pageType == PageTypes.Search?false:true
            });
            LayOutGrid.Resources.Add(typeof(RadioButton), rBtnStyle);
        }
コード例 #9
0
        public ModernBrowser()
        {
            ViewModel.ModernBrowserViewModel defaultBrowserViewModel;

            this.SetStyle();

            defaultBrowserViewModel = new ViewModel.ModernBrowserViewModel(this);

            InitializeComponent();

            this.DataContext = defaultBrowserViewModel;

            //this.AllowsTransparency = true;

            //this.WindowStyle = WindowStyle.None;

            this.WindowStartupLocation = WindowStartupLocation.CenterScreen;

            this.Closing += DefaultBrowser_Closing;
            this.KeyDown += DefaultBrowser_KeyDown1;

            this.DefaultWindowStyle = this.Style;

            this.WindowState = WindowState.Maximized;

            //this.Style = null;
            //this.StateChanged += MainWindowStateChangeRaised;
        }
コード例 #10
0
		static TreeGridViewRowPresenter()
		{
			DefaultSeparatorStyle = new Style(typeof(Rectangle));
			DefaultSeparatorStyle.Setters.Add(new Setter(Shape.FillProperty, SystemColors.ControlLightBrush));
			DefaultSeparatorStyle.Setters.Add(new Setter(UIElement.IsHitTestVisibleProperty, false));
			SeparatorStyleProperty = DependencyProperty.Register("SeparatorStyle", typeof(Style), typeof(TreeGridViewRowPresenter), new UIPropertyMetadata(DefaultSeparatorStyle, SeparatorStyleChanged));
		}
コード例 #11
0
        protected override void OnElementChanged(ElementChangedEventArgs<Entry> e)
        {
            base.OnElementChanged(e);

            if (e.NewElement == null)
                return;

            var grid = Control;            
            var textBox = (PhoneTextBox) grid.Children[0];
            var passwordBox = (PasswordBox) grid.Children[1];

            var foregroundColor = Colors.Black;
            var hintColor = Colors.DarkGray;

            var darkBackgroundVisibility = (Visibility)Application.Current.Resources["PhoneDarkThemeVisibility"];
            if (darkBackgroundVisibility == Visibility.Visible)
            {
                foregroundColor = Colors.White;
                hintColor = Colors.DarkGray;                
            }
                
            // remove borders and backgrounds in regular mode
            textBox.BorderThickness = new Thickness(0);            
            textBox.BorderBrush = new SolidColorBrush(Colors.Transparent);
            textBox.Background = new SolidColorBrush(Colors.Transparent);
            passwordBox.BorderThickness = new Thickness(0);
            passwordBox.BorderBrush = new SolidColorBrush(Colors.Transparent);
            passwordBox.Background = new SolidColorBrush(Colors.Transparent);

            // Foregrounds
            textBox.Foreground = new SolidColorBrush(foregroundColor);                        
            textBox.SelectionForeground = new SolidColorBrush(foregroundColor);
            passwordBox.Foreground = new SolidColorBrush(foregroundColor);
            passwordBox.SelectionForeground = new SolidColorBrush(foregroundColor);

            // Focus handling
            textBox.GotFocus += (sender, evt) =>
            {
                textBox.Background = new SolidColorBrush(Colors.Transparent);
                textBox.CaretBrush = new SolidColorBrush(foregroundColor);
                passwordBox.Background = new SolidColorBrush(Colors.Transparent);
                passwordBox.CaretBrush = new SolidColorBrush(foregroundColor);

                textBox.ActualHintVisibility = string.IsNullOrWhiteSpace(textBox.Text)
                    ? Visibility.Visible
                    : Visibility.Collapsed;
            };

            textBox.TextChanged += (sender, evt) =>
            {
                textBox.ActualHintVisibility = string.IsNullOrWhiteSpace(textBox.Text)
                    ? Visibility.Visible
                    : Visibility.Collapsed;
            };
            
            // Update hint
            var style = new Style {TargetType = typeof (ContentControl)};
            style.Setters.Add(new Setter(System.Windows.Controls.Control.ForegroundProperty, new SolidColorBrush(hintColor)));
            textBox.HintStyle = style;                        
        }
コード例 #12
0
        public ucPlaylistEditor()
        {
            InitializeComponent();
            rdoArtistSearch.IsChecked = true;
            observablePlaylist = new ObservableCollection<Track>();
            lstPlaylist.ItemsSource = observablePlaylist;

            // for drag and drop reorder of playlist
            Style itemContainerStyle = new Style(typeof(ListBoxItem));
            itemContainerStyle.Setters.Add(new Setter(AllowDropProperty, true));
            itemContainerStyle.Setters.Add(new EventSetter(PreviewMouseMoveEvent, new MouseEventHandler(s_PreviewMouseMove)));
            itemContainerStyle.Setters.Add(new EventSetter(DropEvent, new DragEventHandler(lstPlaylist_Drop)));
            itemContainerStyle.Resources.Add(SystemColors.HighlightBrushKey, Brushes.Transparent);
            itemContainerStyle.Resources.Add(SystemColors.InactiveSelectionHighlightBrushKey, Brushes.Transparent);
            itemContainerStyle.Resources.Add(SystemColors.InactiveSelectionHighlightTextBrushKey, Brushes.White);
            lstPlaylist.ItemContainerStyle = itemContainerStyle;

            try
            {
                sendPlaylistChangesToPlayer = Properties.Settings.Default.SendPlaylistChangesToPlayer;
                chkSendPlaylistToPlayer.IsChecked = sendPlaylistChangesToPlayer;
            }
            catch (Exception)
            {
                sendPlaylistChangesToPlayer = false;
                chkSendPlaylistToPlayer.IsChecked = false;
            }
        }
コード例 #13
0
 static GridViewRowPresenterWithGridLines()
 {
     DefaultSeparatorStyle = new Style(typeof(Rectangle));
     DefaultSeparatorStyle.Setters.Add(new Setter(Shape.FillProperty, SystemColors.ControlLightBrush));
     SeparatorStyleProperty = DependencyProperty.Register("SeparatorStyle", typeof(Style), typeof(GridViewRowPresenterWithGridLines),
                                                             new UIPropertyMetadata(DefaultSeparatorStyle, SeparatorStyleChanged));
 }
コード例 #14
0
ファイル: PopupService.cs プロジェクト: vcsb/tfs-merge
        public MessageBoxResult AskYesNoQuestion(string message, string title    = "", string YesButtonContent = "Yes", string NoButtonContent = "No", MessageBoxResult defaultResult = MessageBoxResult.OK,
                                                 MessageBoxImage messageBoxImage = MessageBoxImage.Question)
        {
            if (string.IsNullOrEmpty(title))
            {
                title = "Merging Tool";
            }

            var mbResult = MessageBoxResult.Cancel;

            if (Application.Current.Dispatcher.CheckAccess())
            {
                var style = new System.Windows.Style();
                style.Setters.Add(new Setter(Xceed.Wpf.Toolkit.MessageBox.YesButtonContentProperty, YesButtonContent));
                style.Setters.Add(new Setter(Xceed.Wpf.Toolkit.MessageBox.NoButtonContentProperty, NoButtonContent));
                mbResult = Xceed.Wpf.Toolkit.MessageBox.Show(Application.Current.MainWindow, message, title, MessageBoxButton.YesNo, messageBoxImage, MessageBoxResult.Yes, style);
            }
            else
            {
                // Calling thread blocks.
                mbResult = Application.Current.Dispatcher.Invoke <MessageBoxResult>(() =>
                {
                    var style = new System.Windows.Style();
                    style.Setters.Add(new Setter(Xceed.Wpf.Toolkit.MessageBox.YesButtonContentProperty, YesButtonContent));
                    style.Setters.Add(new Setter(Xceed.Wpf.Toolkit.MessageBox.NoButtonContentProperty, NoButtonContent));
                    return(Xceed.Wpf.Toolkit.MessageBox.Show(Application.Current.MainWindow, message, title, MessageBoxButton.YesNo, messageBoxImage, MessageBoxResult.Yes, style));
                }, DispatcherPriority.Normal);
            }

            return(mbResult);
        }
コード例 #15
0
 private void FeatureInforGrid_OnAutoGeneratingColumn(object sender, DataGridAutoGeneratingColumnEventArgs e)
 {
     if (e.Column.Header.Equals("RealValue"))
     {
         e.Column.Visibility = Visibility.Collapsed;
     }
     else if (e.Column.Header.Equals("Value"))
     {
         System.Windows.Style style = new System.Windows.Style();
         style.TargetType = typeof(DataGridCell);
         DataTrigger trigger = new DataTrigger();
         Binding     binding = new Binding();
         binding.Path      = new PropertyPath(".");
         binding.Converter = new UriToBooleanConverter();
         trigger.Binding   = binding;
         trigger.Value     = true;
         Setter foregroundSetter = new Setter(ForegroundProperty, new SolidColorBrush(Colors.Blue));
         Setter cursorSetter     = new Setter(CursorProperty, System.Windows.Input.Cursors.Hand);
         Setter isHitSetter      = new Setter(IsHitTestVisibleProperty, true);
         trigger.Setters.Add(foregroundSetter);
         trigger.Setters.Add(cursorSetter);
         trigger.Setters.Add(isHitSetter);
         style.Triggers.Add(trigger);
         e.Column.CellStyle = style;
     }
 }
コード例 #16
0
 /// <summary>
 /// Activate this behavior for all ScatterViewItems
 /// </summary>
 public static void Activate()
 {
     // sets style for all ScatterViewItems
     Style sviStyle = new Style(typeof(ScatterViewItem));           
     sviStyle.Setters.Add(new Setter(CustomTopmostBehavior.IsEnabledProperty, true));
     Application.Current.Resources.Add(typeof(ScatterViewItem), sviStyle);
 }
コード例 #17
0
        /// <summary>
        /// Initializes a new instance of the <see cref="StyleItem"/> class.
        /// </summary>
        public StyleItem(Style style, FrameworkElement source, string name, string location, StyleScope scope)
        {
            Style = style;
            Name = name;
            Location = location;
            Scope = scope;

            // Setters
            foreach (Setter setter in style.Setters)
            {
                if(setter.Property.Name == "OverridesDefaultStyle" && setter.Value.ToString().ToLower() == "true")
                {
                    OverridesDefaultStyle = true;
                }
                _setterItems.Add(new SetterItem(setter, source));
            }

            // Triggers
            foreach (var trigger in style.Triggers)
            {
                _triggerItems.Add(TriggerItemFactory.GetTriggerItem(trigger, source, TriggerSource.Style ));
            }

            // Ressources
            foreach (var resource in ResourceHelper.GetResourcesRecursively<object>(style.Resources))
            {
                _resourceItems.Add(ResourceItemFactory.CreateResourceItem(resource.Key, resource.Owner, source, ResourceScope.Style));
            }

            GlobalIndex = StyleHelper.GetGlobalIndex(style);
        }
コード例 #18
0
ファイル: PageBar.xaml.cs プロジェクト: hccliubin/WPF-Project
        public void CreatePageEllipse(int pagecout)
        {
            canvas1.Children.Clear();
            ellipseList.Clear();

            System.Windows.Style rectangleStyle = this.FindResource("Rectangle_PageBar") as System.Windows.Style;

            //设置控件长度
            canvas1.Width = this.Width = ellipse_Peripheral + (ellipse_Diameter + ellipse_Peripheral) * pagecout;
            //画点
            for (int i = 1; i <= pagecout; i++)
            {
                Rectangle ellipse = new Rectangle();
                //ellipse.Width = ellipse.Height = ellipse_Diameter;
                //ellipse.StrokeThickness = 0;
                //ellipse.Fill = new SolidColorBrush(Colors.Gray);

                ellipse.Style = rectangleStyle;

                Canvas.SetLeft(ellipse, ellipse_Peripheral * i + ellipse_Diameter * (i - 1));
                Canvas.SetTop(ellipse, 1);
                canvas1.Children.Add(ellipse);
                ellipseList.Add(ellipse);
            }
        }
コード例 #19
0
    public static void ExportViewToXaml( ViewBase view, string fileName )
    {
      if( view == null )
        throw new ArgumentNullException( "view" );

      object value;
      DependencyProperty dp;
      ResourceDictionary resourceDictionary = new ResourceDictionary();
      Type viewType = view.GetType();
      Style viewStyle = new Style( viewType );

      foreach( FieldInfo fieldInfo in viewType.GetFields( BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.Static ) )
      {
        dp = fieldInfo.GetValue( view ) as DependencyProperty;

        if( dp != null )
        {
          value = view.ReadLocalValue( dp );

          if( value != DependencyProperty.UnsetValue )
            viewStyle.Setters.Add( new Setter( dp, value ) );
        }
      }

      resourceDictionary.Add( viewType, viewStyle );

      XmlWriterSettings settings = new XmlWriterSettings();
      settings.Indent = true;
      settings.OmitXmlDeclaration = true;

      using( XmlWriter xmlWriter = XmlWriter.Create( fileName, settings ) )
      {
        XamlWriter.Save( resourceDictionary, xmlWriter );
      }
    }
コード例 #20
0
        /////////////////////////////////////
        /////////TABCONTROL SETTINGS/////////
        /////////////////////////////////////

        private void ShowPropertiesAndErrors(AssemblyPointer pointer)
        {
            tabControl.Opacity = 100;

            if (pointer.HasErrors)
            {// Set Errors and Properties in TabControl
                DataGridTextColumn   c     = new DataGridTextColumn();
                System.Windows.Style style = new System.Windows.Style(typeof(TextBlock));
                style.Setters.Add(new Setter(TextBlock.TextWrappingProperty, TextWrapping.Wrap));
                c.ElementStyle = style;
                c.Header       = "Errors";
                c.Binding      = new System.Windows.Data.Binding();
                c.Width        = 336;
                errorsGrid.Columns.Add(c);

                pointer.Errors.ForEach(x => { errorsGrid.Items.Add(x); });
                errorsGrid.Visibility = Visibility.Visible;
                TabItem itemErrors = (TabItem)tabControl.Items.GetItemAt(1);
                itemErrors.Visibility = Visibility.Visible;

                SetPropetiesGrid(pointer);
            }
            else
            {
                SetPropetiesGrid(pointer);
            }
        }
コード例 #21
0
 private void OnScrollViewerStylePropertyChanged(System.Windows.Style oldStyle, System.Windows.Style newStyle)
 {
     if (_scrollViewer != null)
     {
         _scrollViewer.Style = newStyle;
     }
 }
コード例 #22
0
        private void AddOrRemoveButton(object sender, RoutedEventArgs e)
        {
            if (!(e.OriginalSource is Button))
            {
                return;
            }

            System.Windows.Style selectedStyle = (e.OriginalSource as Button).Style;
            DependencyObject     parentLVI     = VisualTreeHelper.GetParent(e.OriginalSource as DependencyObject);

            while (parentLVI != null && !(parentLVI is ListViewItem))
            {
                parentLVI = VisualTreeHelper.GetParent(parentLVI);
            }
            if (parentLVI != null)
            {
                int index = StyleListView.ItemContainerGenerator.IndexFromContainer(parentLVI);
                if (index % 2 == 0)
                {
                    // if an even index, remove the style from the dictionary
                    _observableButtonStyles.Remove(((KeyValuePair <string, System.Windows.Style>)StyleListView.Items[index]).Key as string);
                }
                else
                {
                    // if an odd index, duplicate the style in the dictionary
                    string newKey = "New Style ";
                    int    i      = 1;
                    while (_observableButtonStyles.ContainsKey(newKey + i.ToString()))
                    {
                        i++;
                    }
                    _observableButtonStyles[newKey + i.ToString()] = selectedStyle;
                }
            }
        }
コード例 #23
0
 public void ApplayStyleAndData(System.Windows.Style uiStyle, PrintTemplateItem item)
 {
     //创建UI
     this.UI = new Thumb {
         DataContext = this
     };
     this.UI.Style = uiStyle;
     this.UI.ApplyTemplate();
     Data = item;
     if (double.IsNaN(this.Data.X) || this.Data.X < 0)
     {
         this.Data.X = 0;
     }
     this.X = this.Data.X;
     if (double.IsNaN(this.Data.Y) || this.Data.Y < 0)
     {
         this.Data.Y = 0;
     }
     this.Y             = this.Data.Y;
     this.Width         = this.Data.Width;
     this.Height        = this.Data.Height;
     this.FontName      = this.Data.FontName;
     this.FontSize      = this.Data.FontSize;
     this.Format        = this.Data.Format;
     this.Type          = this.Data.Type;
     this.Value         = item.Value;
     this.Value1        = item.Value1;
     this.TextAlignment = item.TextAlignment;
     this.Opacity       = item.Opacity;
     this.ScaleFormat   = item.ScaleFormat;
     item.RunTimeTag    = this;
     AttachThumbEvents(this.UI);
 }
コード例 #24
0
ファイル: Extensions.cs プロジェクト: MagicWang/WYJ
 public static void SetStyleWithType(this FrameworkElement element, Style style)
 {
     if (element.Style != style && (style == null || style.TargetType != null))
     {
         element.Style = style;
     }
 }
コード例 #25
0
 private static Style CreateElementStyle(DataGrid dataGrid, string bindingPath)
 {
   var baseStyle = dataGrid.FindResource("TextBlockBaseStyle") as Style;
   var style = new Style(typeof(TextBlock), baseStyle);
   AddSetters(style, bindingPath);
   return style;
 }
コード例 #26
0
 public WhereTabNullNotNullConditionControl()
 {
     InitializeComponent();
     ComboboxOriginalStyle = this.cmbWhereTabNullNotNullColumns.Style;
     List<string> ListOfLogicalOpreator = new List<string> { "And", "Or" };
     this.cmbWhereTabQueryAndOr.ItemsSource = ListOfLogicalOpreator;
 }
コード例 #27
0
 public void InitializeComponent()
 {
     if (_contentLoaded)
     {
         return;
     }
     _contentLoaded = true;
     System.Windows.Application.LoadComponent(this, new System.Uri("/ESRI.SilverlightViewer;component/Widgets/EditWidget.xaml", System.UriKind.Relative));
     this.ActiveButtonStyle            = ((System.Windows.Style)(this.FindName("ActiveButtonStyle")));
     this.EditorToolButtons            = ((System.Windows.Controls.StackPanel)(this.FindName("EditorToolButtons")));
     this.StackEditActionButtons       = ((System.Windows.Controls.StackPanel)(this.FindName("StackEditActionButtons")));
     this.ButtonNewSelection           = ((System.Windows.Controls.Button)(this.FindName("ButtonNewSelection")));
     this.ButtonAddSelection           = ((System.Windows.Controls.Button)(this.FindName("ButtonAddSelection")));
     this.ButtonRemoveSelection        = ((System.Windows.Controls.Button)(this.FindName("ButtonRemoveSelection")));
     this.ButtonClearSelection         = ((System.Windows.Controls.Button)(this.FindName("ButtonClearSelection")));
     this.ButtonDeleteSelected         = ((System.Windows.Controls.Button)(this.FindName("ButtonDeleteSelected")));
     this.ButtonEditVertices           = ((System.Windows.Controls.Button)(this.FindName("ButtonEditVertices")));
     this.ButtonCutSelected            = ((System.Windows.Controls.Button)(this.FindName("ButtonCutSelected")));
     this.ButtonReshapeSelected        = ((System.Windows.Controls.Button)(this.FindName("ButtonReshapeSelected")));
     this.ButtonUnionSelected          = ((System.Windows.Controls.Button)(this.FindName("ButtonUnionSelected")));
     this.StackAddFeatureButtons       = ((System.Windows.Controls.StackPanel)(this.FindName("StackAddFeatureButtons")));
     this.ButtonAddPoint               = ((System.Windows.Controls.Button)(this.FindName("ButtonAddPoint")));
     this.ButtonAddPolyline            = ((System.Windows.Controls.Button)(this.FindName("ButtonAddPolyline")));
     this.ButtonAddFreehandPolyline    = ((System.Windows.Controls.Button)(this.FindName("ButtonAddFreehandPolyline")));
     this.ButtonAddPolygon             = ((System.Windows.Controls.Button)(this.FindName("ButtonAddPolygon")));
     this.ButtonAddFreehandPolygon     = ((System.Windows.Controls.Button)(this.FindName("ButtonAddFreehandPolygon")));
     this.ButtonAddAutoCompletePolygon = ((System.Windows.Controls.Button)(this.FindName("ButtonAddAutoCompletePolygon")));
     this.ButtonEditAttributes         = ((System.Windows.Controls.Button)(this.FindName("ButtonEditAttributes")));
     this.ButtonSaveEdits              = ((System.Windows.Controls.Button)(this.FindName("ButtonSaveEdits")));
     this.FeatureTemplateList          = ((System.Windows.Controls.ListBox)(this.FindName("FeatureTemplateList")));
 }
コード例 #28
0
        internal static System.Windows.DataTemplate CreateCellTemplate(EntityFieldInfo entityFieldInfo,DataGrid dataGrid)
        {
            DataTemplate dataTemplate = new DataTemplate();
            FrameworkElementFactory contentControl = new FrameworkElementFactory(typeof(ContentControl));
            contentControl.SetBinding(ContentControl.ContentProperty, new Binding());
            Style contentControlStyle = new Style();
            contentControl.SetValue(ContentControl.StyleProperty, contentControlStyle);

            DataTemplate tpl = new DataTemplate();
            if (entityFieldInfo.ControlType == Infrastructure.Attributes.ControlType.Color)
            {
                FrameworkElementFactory grid = new FrameworkElementFactory(typeof(Grid));
                Binding binding = CreateBindingOneWay(entityFieldInfo.Path);
                binding.Converter = new StringToBrushConverter();
                grid.SetBinding(Grid.BackgroundProperty, binding);
                tpl.VisualTree = grid;
                contentControlStyle.Setters.Add(new Setter(ContentControl.ContentTemplateProperty, tpl));
                dataTemplate.VisualTree = contentControl;
            }
            else
            {
                FrameworkElementFactory textBox = new FrameworkElementFactory(typeof(TextBlock));
                if (entityFieldInfo.ControlType == Infrastructure.Attributes.ControlType.Pr)
                { textBox.SetValue(TextBlock.TextAlignmentProperty, TextAlignment.Right); }
                textBox.SetBinding(TextBlock.TextProperty, CreateBindingOneWay(entityFieldInfo.Path));
                tpl.VisualTree = textBox;
                contentControlStyle.Setters.Add(new Setter(ContentControl.ContentTemplateProperty, tpl));
                dataTemplate.VisualTree = contentControl;
            }

            return dataTemplate;
        }
コード例 #29
0
        public MainWindow()
        {
            InitializeComponent();

            string culture = CfgFile.Get("Lang");
            LocalizeDictionary.Instance.Culture = CultureInfo.GetCultureInfo(culture);
            Thread.CurrentThread.CurrentUICulture = LocalizeDictionary.Instance.Culture;

            using (var fs = new FileStream("Theme.xaml", FileMode.Open))
            {
                var dic = (ResourceDictionary)XamlReader.Load(fs);
                Application.Current.MainWindow.Resources.MergedDictionaries.Clear();
                Application.Current.MainWindow.Resources.MergedDictionaries.Add(dic);
            }

            // Wiring up View and ViewModel
            var model = new MainWindowViewModel();
            DataContext = model;

            navigationButtonStyle = (Style)FindResource("NavigationButton");
            navigationButtonSelectedStyle = (Style)FindResource("NavigationButton");
            navigationButtonFirstStyle = (Style)FindResource("NavigationButton");
            navigationButtonFirstSelectedStyle = (Style)FindResource("NavigationButton");

            ProcessFirstRun();
        }
コード例 #30
0
        public override Style SelectStyle(object item, DependencyObject container)
        {
            Style style = new Style {
                TargetType = typeof(ListBoxItem)
            };
            Setter setter = new Setter {
                Property = Control.BackgroundProperty
            };
            ListBox box = ItemsControl.ItemsControlFromItemContainer(container) as ListBox;
            switch (box.ItemContainerGenerator.IndexFromContainer(container))
            {
                case 0:
                    setter.Value = Brushes.LightBlue;
                    break;

                case 1:
                    setter.Value = Brushes.Green;
                    break;

                default:
                    setter.Value = Brushes.SaddleBrown;
                    break;
            }
            style.Setters.Add(setter);
            return style;
        }
コード例 #31
0
 public DragAndDrop(User _user, Grid _grid, double depthOfShadow = 4, double directionOfDropShadow = 315)
 {
     user = _user;
     try
     {
         DirectionOfDropShadow = directionOfDropShadow;
         DepthOfShadow         = depthOfShadow;
         Grid = _grid;
         System.Windows.Style gridStyle = new System.Windows.Style(typeof(Grid));
         WrapPanel = Grid.Parent as WrapPanel;
         System.Windows.Style wrapPanelStyle  = new System.Windows.Style(typeof(WrapPanel));
         System.Windows.Style mainWindowStyle = new System.Windows.Style(typeof(MainWindow));
         //wrapPanelStyle.Setters.Add(new EventSetter(WrapPanel.DropEvent, new DragEventHandler(Grid_Dropping)));
         mainWindowStyle.Setters.Add(new EventSetter(MainWindow.DropEvent, new DragEventHandler(Grid_Dropping)));
         gridStyle.Setters.Add(new Setter(Grid.AllowDropProperty, true));
         gridStyle.Setters.Add(new EventSetter(Grid.PreviewDragLeaveEvent, new DragEventHandler(Grid_PreviewDragLeave)));
         gridStyle.Setters.Add(new EventSetter(Grid.PreviewMouseMoveEvent, new MouseEventHandler(Grid_PreviewMouseMove)));
         //gridStyle.Setters.Add(new EventSetter(Grid.DropEvent, new DragEventHandler(Grid_Dropping)));
         gridStyle.Setters.Add(new EventSetter(Grid.GiveFeedbackEvent, new GiveFeedbackEventHandler(Grid_DraggingFeedback)));
         Grid.Style      = gridStyle;
         WrapPanel.Style = wrapPanelStyle;
         Application.Current.MainWindow.Style = mainWindowStyle;
     }
     catch (Exception ex)
     {
         IMethods.WriteToErrorLog("DragAndDrop.cs", ex.Message, user);
     }
 }
コード例 #32
0
ファイル: GridSplitterTests.cs プロジェクト: senfo/snaglV2
 public void HorizontalHandleStyleSetViaCode()
 {
     GridSplitter splitter = new GridSplitter();
     Style s = new Style(typeof(System.Windows.Controls.Primitives.ToggleButton));
     splitter.HorizontalHandleStyle = s;
     Assert.AreEqual(s, splitter.GetValue(GridSplitter.HorizontalHandleStyleProperty), "Assigning a new style to the HandleStyleProperty should set the style.");
 }
コード例 #33
0
        public GridSinkView()
        {
            InitializeComponent();

            rightAlignStyle = new Style();
            rightAlignStyle.Setters.Add(new Setter(FrameworkElement.HorizontalAlignmentProperty, HorizontalAlignment.Right));
        }
コード例 #34
0
        public ZoomableInlineAdornment(UIElement content, ITextView parent) {
            _parent = parent;
            Debug.Assert(parent is IInputElement);
            Content = new Border { BorderThickness = new Thickness(1), Child = content, Focusable = true };

            _zoom = 1.0;             // config.GetConfig().Repl.InlineMedia.MaximizedZoom
            _zoomStep = 0.25;        // config.GetConfig().Repl.InlineMedia.ZoomStep
            _minimizedZoom = 0.25;   // config.GetConfig().Repl.InlineMedia.MinimizedZoom
            _widthRatio = 0.67;      // config.GetConfig().Repl.InlineMedia.WidthRatio
            _heightRatio = 0.5;      // config.GetConfig().Repl.InlineMedia.HeightRatio

            _isResizing = false;
            UpdateSize();

            GotFocus += OnGotFocus;
            LostFocus += OnLostFocus;

            ContextMenu = MakeContextMenu();

            var trigger = new Trigger { Property = Border.IsFocusedProperty, Value = true };
            var setter = new Setter { Property = Border.BorderBrushProperty, Value = SystemColors.ActiveBorderBrush };
            trigger.Setters.Add(setter);

            var style = new Style();
            style.Triggers.Add(trigger);
            MyContent.Style = style;
        }
コード例 #35
0
ファイル: StyleTest.cs プロジェクト: kangaroo/moon
		public void AddIncompleteSetter ()
		{
			Style s = new Style (typeof (Rectangle));
			Assert.Throws<Exception> (() => s.Setters.Add (new Setter ()), "#1");
			Assert.Throws<Exception> (() => s.Setters.Add (new Setter { Value = 5 }), "#2");
			Assert.Throws<Exception> (() => s.Setters.Add (new Setter { Property = Rectangle.WidthProperty }), "#3");
		}
コード例 #36
0
ファイル: Style.cs プロジェクト: sjyanxin/WPFSource
        /// <summary>
        ///     Style construction 
        /// </summary>
        /// <param name="targetType">Type in which Style will be applied</param> 
        /// <param name="basedOn">Style to base this Style on</param> 
        public Style(Type targetType, Style basedOn)
        { 
            TargetType = targetType;
            BasedOn = basedOn;

            GetUniqueGlobalIndex(); 
        }
コード例 #37
0
ファイル: LinkButtonHandler.cs プロジェクト: philstopford/Eto
        void SetStyle(bool force = false)
        {
            if (Widget.Loaded || force)
            {
                var style = new sw.Style();
                if (textColor != null)
                {
                    style.Setters.Add(new sw.Setter(swd.Hyperlink.ForegroundProperty, textColor.Value.ToWpfBrush()));
                }
                /**/
                style.Triggers.Add(new sw.Trigger
                {
                    Property = swd.Hyperlink.IsMouseOverProperty,
                    Value    = true,
                    Setters  = { new sw.Setter(swd.Hyperlink.ForegroundProperty, (textColor ?? TextColor).ToWpfBrush()) }
                });
                style.Triggers.Add(new sw.Trigger
                {
                    Property = swd.Hyperlink.IsEnabledProperty,
                    Value    = false,
                    Setters  = { new sw.Setter(swd.Hyperlink.ForegroundProperty, DisabledTextColor.ToWpfBrush()) }
                });

                /**
                 * style.Triggers.Add(new sw.Trigger
                 * {
                 *      Property = swd.Hyperlink.IsMouseCaptureWithinProperty,
                 *      Value = true,
                 *      Setters = { new sw.Setter(swd.Hyperlink.ForegroundProperty, Colors.Red.ToWpfBrush()) }
                 * });/**/
                Hyperlink.Style = style;
            }
        }
コード例 #38
0
ファイル: StyleTest_Implicit.cs プロジェクト: dfr0/moon
		public void TestImplicitStyleRectangle_multipleImplicitStylesInVisualTree ()
		{
			Style rectStyle1 = new Style { TargetType = typeof (Rectangle) };
			Setter setter = new Setter (FrameworkElement.WidthProperty, 100.0);
			rectStyle1.Setters.Add (setter);

			Style rectStyle2 = new Style { TargetType = typeof (Rectangle) };
			setter = new Setter (FrameworkElement.HeightProperty, 100.0);
			rectStyle2.Setters.Add (setter);

			Rectangle r = new Rectangle ();
			r.Resources.Add (typeof (Rectangle), rectStyle1);

			Canvas c = new Canvas ();
			c.Resources.Add (typeof (Rectangle), rectStyle2);

			c.Children.Add (r);

			Assert.IsTrue (Double.IsNaN (r.Height), "1");

			CreateAsyncTest (c,  () => {
					Assert.AreEqual (100.0, r.Width, "2");
					Assert.IsTrue (Double.IsNaN (r.Height), "3");

					r.Resources.Remove (typeof (Rectangle));

					Assert.AreEqual (100.0, r.Height, "4");
					Assert.IsTrue (Double.IsNaN (r.Width), "5");
				});
		}
コード例 #39
0
ファイル: ListBoxHelper.cs プロジェクト: Danmer/uberdemotools
        public AlternatingListBoxBackground(Color color1, Color color2)
        {
            var setter = new Setter();
            setter.Property = ListBoxItem.BackgroundProperty;
            setter.Value = new SolidColorBrush(color1);

            var trigger = new Trigger();
            trigger.Property = ItemsControl.AlternationIndexProperty;
            trigger.Value = 0;
            trigger.Setters.Add(setter);

            var setter2 = new Setter();
            setter2.Property = ListBoxItem.BackgroundProperty;
            setter2.Value = new SolidColorBrush(color2);

            var trigger2 = new Trigger();
            trigger2.Property = ItemsControl.AlternationIndexProperty;
            trigger2.Value = 1;
            trigger2.Setters.Add(setter2);

            var listBoxStyle = new Style(typeof(ListBoxItem));
            listBoxStyle.Triggers.Add(trigger);
            listBoxStyle.Triggers.Add(trigger2);

            _listBoxStyle = listBoxStyle;
        }
コード例 #40
0
        /*
         * 3.4插入视频  Video
         */
        public void insertVideoToPage(DControl ctl)
        {
            //获取视频所在的集合
            StorageVideo storageVideo = storageVideoBll.get(ctl.storageId);

            if (storageVideo == null)
            {
                storageVideo              = new StorageVideo();
                storageVideo.url          = "/myfile/sysimg/notExists/video.mp4";
                storageVideo.origFilename = "演示视频.mp4";
            }
            StorageVideoDto dto          = StorageVideoUtil.convert(storageVideo);
            StorageImage    storageImage = storageImageBll.get(dto.storageImageId);

            dto.storageImageUrl = storageImage?.url;


            Cfg    pageCfg = PageWidthUtil.getPageCfg(pageTemplate.dPage, App.localStorage.cfg);
            CVideo cVideo  = NewControlUtil.newCVideo(ctl, dto, pageCfg, pageTemplate.mqServer, true);

            System.Windows.Style myStyle = (System.Windows.Style)pageTemplate.container.FindResource("DefaultCVideoStyle");
            cVideo.Style = myStyle;
            cVideo.PreviewMouseLeftButtonDown += control_MouseDown;
            cVideo.PreviewMouseMove           += control_MouseMove;
            cVideo.PreviewMouseLeftButtonUp   += control_MouseUp;
            //控件上右击显示菜单
            cVideo.MouseRightButtonUp += control_MouseRightButtonUp;
            pageTemplate.container.Children.Add(cVideo);
        }
コード例 #41
0
        public SelectTabControl()
        {

            InitializeComponent();
            DataContext = m_items;
            ComboboxOriginalStyle = this.ComputedColComboBox1.Style;
            ComboboxOriginalStyle = this.ComputedColFunctionComboBox.Style;
            this.ComputedColFunctionComboBox.ItemsSource = Functions.getFunctionNames();
            isValidated = false;
            ColsToSelectAcc.SelectionMode = AccordionSelectionMode.ZeroOrOne;
            RowOriginalBorderBrush = Brushes.White;
            //seting up list ToselectColumFrom
            lstToSelecteColFrom.ItemsSource = _FromSelectedColToCollection;
            //seting up selected list box itemsource
            lstSelectedCol.ItemsSource = _SelectedColCollection;
            //setting computed col listbox
            Column computedCol = new Column();
            computedCol.Name = "";
            computedCol.AliasName = "";
            computedColList.Add(computedCol);
            lstSelectedCol.MouseMove += new MouseEventHandler(lstSelectedCol_MouseMove);
            List<string> ComputedColFormatComboBoxItemSrc = Common.GetColumsFormatList();
            ComputedColFormatComboBoxItemSrc.Insert(0, "Select One");
            ComputedColFormatComboBox.ItemsSource = ComputedColFormatComboBoxItemSrc;
            ComputedColFormatComboBox.SelectedIndex = 0;

        }
コード例 #42
0
        private ImageAnnotation(
            Point textLocation,
            Image image,
            Style annontationStyle,
            Style annotationEditorStyle)
        {
            if (image == null)
                throw new ArgumentNullException("image");

            _image = image;
            this.HookImageEvents(true);

            //Size imageSize = _image.RenderSize;
            Size imageSize = new Size(_image.Width, _image.Height);
            if (imageSize.Height == 0 || imageSize.Width == 0)
                throw new ArgumentException("image has invalid dimensions");

            // Determine the relative location of the TextBlock.
            _horizPercent = textLocation.X / imageSize.Width;
            _vertPercent = textLocation.Y / imageSize.Height;

            // Create the adorner which displays the annotation.
            _adorner = new ImageAnnotationAdorner(
                this,
                _image,
                annontationStyle,
                annotationEditorStyle,
                textLocation);

            this.InstallAdorner();
        }
コード例 #43
0
        /// <summary>
        /// Initialize the <see cref="ListBox"/> style and event handlers.
        /// </summary>
        public void Initialize()
        {
            var style = ItemContainerStyle;

            if (style != null)
            {
                if (style.IsSealed)
                {
                    return;
                }
            }
            else
            {
                style = new System.Windows.Style(typeof(ListBoxItem));
            }

            PreviewMouseMove += ListBox_PreviewMouseMove;

            style.Setters.Add(new Setter(ListBoxItem.AllowDropProperty, true));

            style.Setters.Add(
                new EventSetter(
                    ListBoxItem.PreviewMouseLeftButtonDownEvent,
                    new MouseButtonEventHandler(ListBoxItem_PreviewMouseLeftButtonDown)));

            style.Setters.Add(
                new EventSetter(
                    ListBoxItem.DropEvent,
                    new DragEventHandler(ListBoxItem_Drop)));

            if (ItemContainerStyle == null)
            {
                ItemContainerStyle = style;
            }
        }
コード例 #44
0
		public EditableTextBlock()
		{
			var textBox = new FrameworkElementFactory(typeof(TextBox));
			textBox.SetValue(Control.PaddingProperty, new Thickness(1)); // 1px for border
			textBox.AddHandler(FrameworkElement.LoadedEvent, new RoutedEventHandler(TextBox_Loaded));
			textBox.AddHandler(UIElement.KeyDownEvent, new KeyEventHandler(TextBox_KeyDown));
			textBox.AddHandler(UIElement.LostFocusEvent, new RoutedEventHandler(TextBox_LostFocus));
			textBox.SetBinding(TextBox.TextProperty, new System.Windows.Data.Binding("Text") { Source = this, Mode = BindingMode.TwoWay, UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged });
			var editTemplate = new DataTemplate { VisualTree = textBox };

			var textBlock = new FrameworkElementFactory(typeof(TextBlock));
			textBlock.SetValue(FrameworkElement.MarginProperty, new Thickness(2));
			textBlock.AddHandler(UIElement.MouseDownEvent, new MouseButtonEventHandler(TextBlock_MouseDown));
			textBlock.SetBinding(TextBlock.TextProperty, new System.Windows.Data.Binding("Text") { Source = this });
			var viewTemplate = new DataTemplate { VisualTree = textBlock };

			var style = new System.Windows.Style(typeof(EditableTextBlock));
			var trigger = new Trigger { Property = IsInEditModeProperty, Value = true };
			trigger.Setters.Add(new Setter { Property = ContentTemplateProperty, Value = editTemplate });
			style.Triggers.Add(trigger);

			trigger = new Trigger { Property = IsInEditModeProperty, Value = false };
			trigger.Setters.Add(new Setter { Property = ContentTemplateProperty, Value = viewTemplate });
			style.Triggers.Add(trigger);
			Style = style;
		}
コード例 #45
0
 public void setHeader(cKomorka komorka, Style styl)
 {
     header = komorka;
     komorka.kolumna = this;
     header.lbl.Content = cpdb.IdPDB.ToString();
     header.lbl.Style = styl;
 }
コード例 #46
0
 public void InitializeComponent()
 {
     if (_contentLoaded)
     {
         return;
     }
     _contentLoaded = true;
     System.Windows.Application.LoadComponent(this, new System.Uri("/SilverlightDemo;component/MainPage.xaml", System.UriKind.Relative));
     this.accordionStyle        = ((System.Windows.Style)(this.FindName("accordionStyle")));
     this.tabContentBorderBrush = ((System.Windows.Media.LinearGradientBrush)(this.FindName("tabContentBorderBrush")));
     this.LayoutRoot            = ((System.Windows.Controls.Grid)(this.FindName("LayoutRoot")));
     this.sideBar            = ((System.Windows.Controls.Border)(this.FindName("sideBar")));
     this.ListScroller       = ((System.Windows.Controls.ScrollViewer)(this.FindName("ListScroller")));
     this.ListOfSamples      = ((System.Windows.Controls.StackPanel)(this.FindName("ListOfSamples")));
     this.expand             = ((System.Windows.Controls.Accordion)(this.FindName("expand")));
     this.gridSplitter       = ((System.Windows.Controls.GridSplitter)(this.FindName("gridSplitter")));
     this.tabPanel           = ((System.Windows.Controls.TabControl)(this.FindName("tabPanel")));
     this.tabSample          = ((System.Windows.Controls.TabItem)(this.FindName("tabSample")));
     this.mapFrameBorder     = ((System.Windows.Controls.Border)(this.FindName("mapFrameBorder")));
     this.ContentFrame       = ((System.Windows.Controls.Frame)(this.FindName("ContentFrame")));
     this.tabXaml            = ((System.Windows.Controls.TabItem)(this.FindName("tabXaml")));
     this.tabXamlScrollView  = ((System.Windows.Controls.ScrollViewer)(this.FindName("tabXamlScrollView")));
     this.txtXaml            = ((JeffWilcox.SyntaxHighlighting.SyntaxHighlightingTextBlock)(this.FindName("txtXaml")));
     this.tabSrc             = ((System.Windows.Controls.TabItem)(this.FindName("tabSrc")));
     this.tabSrcScrollView   = ((System.Windows.Controls.ScrollViewer)(this.FindName("tabSrcScrollView")));
     this.txtSrc             = ((JeffWilcox.SyntaxHighlighting.SyntaxHighlightingTextBlock)(this.FindName("txtSrc")));
     this.tabSrcVB           = ((System.Windows.Controls.TabItem)(this.FindName("tabSrcVB")));
     this.tabSrcScrollViewVB = ((System.Windows.Controls.ScrollViewer)(this.FindName("tabSrcScrollViewVB")));
     this.txtSrcExplain      = ((System.Windows.Controls.TextBox)(this.FindName("txtSrcExplain")));
     this.SampleCaption      = ((System.Windows.Controls.TextBlock)(this.FindName("SampleCaption")));
 }
コード例 #47
0
ファイル: PanoramaPage.xaml.cs プロジェクト: juank334/TrackMe
        private void AddSessionsHubTiles(string name , string session)
        {
            /*
            HubTile hubTile = new HubTile();
            hubTile.Title="Track";
            hubTile.Margin =new Thickness(14);
            hubTile.Notification="JUAN";
            hubTile.DisplayNotification=true;
            hubTile.Background = new SolidColorBrush(Colors.Cyan);
            hubTile.Foreground = new SolidColorBrush(Colors.Black);
            hubTile.GroupTag="Food";
            hubTile.Size=TileSize.Medium;*/

            SessionButton b = new SessionButton();
            if (name == "")
            {
                b.Content = "No\nname\nSession:\n" + session;
            }
            else
            {
                b.Content = "Name:\n"+name+"\nSession:\n" + session;
            }
            b.Height = 175;
            b.Width = 175;
            Style s = new Style();
            b.Style = (Style)this.Resources["ButtonStyleViewerHistory"];
            b.Session = session;
            b.Click += b_Click;

            LastSessionsStack.Children.Add(b);
        }
コード例 #48
0
        /*
         * 3.3插入层叠相册
         */
        public void insertMarqueLayerToPage(DControl ctl)
        {
            List <TurnPictureImagesDto> list = turnPictureImagesBll.getByDControlId(ctl.id);

            //如果storageImageId=0,则显示替代的Params.TurnPictureNotExists[i]
            for (int i = 0; i < list.Count; i++)
            {
                TurnPictureImagesDto dto = list[i];
                if (dto == null)
                {
                    list.Remove(dto);
                }
                string imgNotExists = Params.ImageNotExists;
                if (i < 6 && dto.storageImageId == 0)
                {
                    imgNotExists = Params.TurnPictureNotExists[i];
                }
                string imgFullPath = FileUtil.notExistsShowDefault(dto.url, imgNotExists);
                dto.url = imgFullPath;
            }
            MarqueLayer marqueLayer = NewControlUtil.newMarqueLayer(ctl, list, true);

            System.Windows.Style myStyle = (System.Windows.Style)pageTemplate.container.FindResource("DefaultMarqueLayerStyle");
            marqueLayer.Style = myStyle;

            marqueLayer.PreviewMouseLeftButtonDown += control_MouseDown;
            marqueLayer.PreviewMouseMove           += control_MouseMove;
            marqueLayer.PreviewMouseLeftButtonUp   += control_MouseUp;
            //控件上右击显示菜单
            marqueLayer.MouseRightButtonUp += control_MouseRightButtonUp;
            pageTemplate.container.Children.Add(marqueLayer);
        }
コード例 #49
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            GridView myGridView = new GridView();
            myGridView.AllowsColumnReorder = true;

            //Collapse the header
            Style collapsedHeaderStyle = new Style();
            Setter collapsedHeaderSetter = new Setter();

            collapsedHeaderSetter.Property = VisibilityProperty;
            collapsedHeaderSetter.Value = Visibility.Collapsed;
            collapsedHeaderStyle.Setters.Add(collapsedHeaderSetter);

            myGridView.ColumnHeaderContainerStyle = collapsedHeaderStyle;

            for (int i = 0; i < control.XSize; i++)
            {
                GridViewColumn col = new GridViewColumn();
                col.DisplayMemberBinding = new Binding("Column[" + i.ToString() + "]");
                col.Width = 30;
                myGridView.Columns.Add(col);
            }

            listView.View = myGridView;
            listView.DataContext = control.AgentCollection;
        }
コード例 #50
0
        /*
         * 插入小窗口到页面
         */
        internal void insertCFrameToPage(DControl ctl)
        {
            CFrame cFrame = new CFrame(ctl, App.localStorage.cfg, pageTemplate.mqServer);

            cFrame.BorderThickness     = new Thickness(0);
            cFrame.Margin              = new Thickness(ctl.left, ctl.top, 0, 0);
            cFrame.Width               = ctl.width;
            cFrame.Height              = ctl.height;
            cFrame.HorizontalAlignment = HorizontalAlignment.Left;
            cFrame.VerticalAlignment   = VerticalAlignment.Top;
            cFrame.Opacity             = ctl.opacity / 100.0;
            Panel.SetZIndex(cFrame, ctl.idx);
            cFrame.Tag = ctl;
            TransformGroup group = new TransformGroup();

            cFrame.RenderTransform       = group;
            cFrame.RenderTransformOrigin = new Point(0.5, 0.5);


            System.Windows.Style myStyle = (System.Windows.Style)pageTemplate.container.FindResource("DefaultCFrameStyle");
            cFrame.Style      = myStyle;
            cFrame.Focusable  = false;
            cFrame.Visibility = Visibility.Visible;
            //控件拖动
            cFrame.PreviewMouseLeftButtonDown += control_MouseDown;
            cFrame.PreviewMouseMove           += control_MouseMove;
            cFrame.PreviewMouseLeftButtonUp   += control_MouseUp;
            //控件上右击显示菜单
            cFrame.MouseRightButtonUp += control_MouseRightButtonUp;


            pageTemplate.container.Children.Add(cFrame);
        }
コード例 #51
0
ファイル: ComboBoxBackend.cs プロジェクト: steffenWi/xwt
        //private static readonly DataTemplate DefaultTemplate;
        static ComboBoxBackend()
        {
            if (System.Windows.Application.Current.Resources.MergedDictionaries.Count == 0 ||
                !System.Windows.Application.Current.Resources.MergedDictionaries.Any(x => x.Contains(typeof(ExComboBox))))
            {
                var factory = new FrameworkElementFactory(typeof(WindowsSeparator));
                factory.SetValue(FrameworkElement.HorizontalAlignmentProperty, HorizontalAlignment.Stretch);

                var sepTemplate = new ControlTemplate(typeof(ComboBoxItem));
                sepTemplate.VisualTree = factory;

                DataTrigger trigger = new DataTrigger();
                trigger.Binding = new Binding(".[1]") { Converter = new TypeToStringConverter() };
                trigger.Value = typeof(ItemSeparator).Name;
                trigger.Setters.Add(new Setter(Control.TemplateProperty, sepTemplate));
                trigger.Setters.Add(new Setter(UIElement.IsEnabledProperty, false));

                ContainerStyle = new Style(typeof(ComboBoxItem));
                ContainerStyle.Triggers.Add(trigger);
            }
            else
            {
                ContainerStyle = null;
            }
        }
コード例 #52
0
ファイル: StyleTest_Implicit.cs プロジェクト: dfr0/moon
		public void TestImplicitStyleRectangle_styleInRectangleDictionary ()
		{
			Style rectStyle = new Style { TargetType = typeof (Rectangle) };
			Setter setter = new Setter (FrameworkElement.WidthProperty, 100.0);
			rectStyle.Setters.Add (setter);

			Rectangle r = new Rectangle ();

			Assert.IsTrue (Double.IsNaN (r.Width), "1");

			r.Resources.Add (typeof (Rectangle), rectStyle);

			Assert.AreEqual (100.0, r.Width, "2");

			CreateAsyncTest (r,  () => {
					Assert.AreEqual (100.0, r.Width, "3");

					//setter.Value = 200.0;
					//Assert.AreEqual (200.0, r.Width, "4");

					rectStyle.Setters.Remove (setter);

					Assert.AreEqual (100.0, r.Width, "5");
				});
		}
コード例 #53
0
ファイル: StyleKeyCache.cs プロジェクト: JamesTryand/snoopwpf
 public static void CacheStyle(Style style, string key)
 {
     if (!Keys.ContainsKey(style))
     {
         Keys.Add(style, key);
     }
 }
コード例 #54
0
        private void SetStyle1()
        {
            LinearGradientBrush linearGradientBrush;

            System.Windows.Style    style;
            ControlTemplate         controlTemplate;
            FrameworkElementFactory border;
            FrameworkElementFactory contentPresenter;
            Trigger trigger;

            linearGradientBrush = new LinearGradientBrush("#FF5BB75B".ToMediaColor(), "#FF398239".ToMediaColor(), new Point(0.5, 1), new Point(0.5, 0));


            style = new System.Windows.Style(typeof(Button));
            style.Setters.Add(new Setter(Button.FontSizeProperty, 11D));
            style.Setters.Add(new Setter(Button.ForegroundProperty, Brushes.DarkGreen));


            controlTemplate = new ControlTemplate(typeof(Button));


            border      = new FrameworkElementFactory(typeof(Border));
            border.Name = "ButtonBorder";
            border.SetValue(Border.CornerRadiusProperty, new CornerRadius(10));
            border.SetValue(Border.BorderBrushProperty, new SolidColorBrush("#387f38".ToMediaColor()));
            border.SetValue(Border.PaddingProperty, new Thickness(0));
            border.SetValue(Border.BackgroundProperty, new LinearGradientBrush("#FF5BB75B".ToMediaColor(), "#FF449B44".ToMediaColor(), new Point(0.5, 1), new Point(0.5, 0)));


            contentPresenter      = new FrameworkElementFactory(typeof(ContentPresenter));
            contentPresenter.Name = "ButtonContentPresenter";
            contentPresenter.SetValue(ContentPresenter.VerticalAlignmentProperty, VerticalAlignment.Center);
            contentPresenter.SetValue(ContentPresenter.HorizontalAlignmentProperty, HorizontalAlignment.Center);

            border.AppendChild(contentPresenter);


            trigger          = new Trigger();
            trigger.Property = Button.IsMouseOverProperty;
            trigger.Value    = true;
            trigger.Setters.Add(new Setter()
            {
                TargetName = "ButtonBorder",
                Property   = Border.BackgroundProperty,
                Value      = linearGradientBrush
            });

            trigger.Setters.Add(new Setter()
            {
                Property = Border.CursorProperty,
                Value    = Cursors.Hand
            }
                                );

            controlTemplate.VisualTree = border;
            controlTemplate.Triggers.Add(trigger);

            this.ResourceDictionaryRoot.Add(typeof(Button), style);
        }
コード例 #55
0
 /* CUSTOM FORM */
 public static MessageBoxResult CustomMessageBox(String Text, String Caption, String YesButtonText, String NoButtonText, String CancelButtonText, MessageBoxButton Button, MessageBoxImage Image)
 {
     System.Windows.Style style = new System.Windows.Style();
     style.Setters.Add(new Setter(Xceed.Wpf.Toolkit.MessageBox.YesButtonContentProperty, YesButtonText));
     style.Setters.Add(new Setter(Xceed.Wpf.Toolkit.MessageBox.NoButtonContentProperty, NoButtonText));
     style.Setters.Add(new Setter(Xceed.Wpf.Toolkit.MessageBox.CancelButtonContentProperty, CancelButtonText));
     return(Xceed.Wpf.Toolkit.MessageBox.Show(Text, Caption, Button, Image, MessageBoxResult.Yes, style));
 }
コード例 #56
0
        private void removeAddItemTip()
        {
            Style st = new System.Windows.Style();

            _addItemTextBox.Text       = String.Empty;
            _addItemTextBox.Foreground = (Brush)FindResource("textbox_textColor");
            _addItemTextBox.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Left;
        }
コード例 #57
0
        private static Style CreateCellStyle()
        {
            var cellStyle = new Style(typeof(DataGridCell));

            cellStyle.Setters.Add(new Setter(HorizontalAlignmentProperty, HorizontalAlignment.Center));
            cellStyle.Setters.Add(new Setter(VerticalAlignmentProperty, VerticalAlignment.Center));
            return(cellStyle);
        }
コード例 #58
0
        private void grdMain_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                //design columns
                grdDependencies.grdMain.ColumnHeaderHeight = 50;
                try
                {
                    int      colorIndx  = 0;
                    int      columnIndx = 2;
                    string[] variableColumnBackgroundColor = new string[] { "#FFFFCC", "#E5FFCC", "#CCE5FF", "#CCCCFF", "#FFCCFF", "#FFCC99", "#CCFFFF", "#FF99CC" };
                    foreach (VariableBase var in mParentListVars)
                    {
                        for (int indx = 0; indx < ((VariableSelectionList)var).OptionalValuesList.Count; indx++)
                        {
                            Style           colStyle        = new System.Windows.Style(typeof(DataGridColumnHeader));
                            SolidColorBrush backgroundColor = (SolidColorBrush) new BrushConverter().ConvertFromString(variableColumnBackgroundColor[colorIndx % 8]);
                            colStyle.Setters.Add(new Setter(DataGridColumnHeader.BackgroundProperty, backgroundColor));
                            SolidColorBrush foregroundColor = (SolidColorBrush) new BrushConverter().ConvertFromString((TryFindResource("$Color_DarkBlue")).ToString());
                            colStyle.Setters.Add(new Setter(DataGridColumnHeader.ForegroundProperty, foregroundColor));
                            colStyle.Setters.Add(new Setter(DataGridColumnHeader.FontWeightProperty, FontWeights.Bold));
                            colStyle.Setters.Add(new Setter(DataGridColumnHeader.BorderThicknessProperty, new Thickness(0.5, 0.5, 0.5, 0.5)));
                            colStyle.Setters.Add(new Setter(DataGridColumnHeader.BorderBrushProperty, foregroundColor));
                            colStyle.Setters.Add(new Setter(DataGridColumnHeader.HorizontalContentAlignmentProperty, HorizontalAlignment.Center));
                            colStyle.Setters.Add(new EventSetter(Button.ClickEvent, new RoutedEventHandler(ColumnWasClicked)));

                            grdDependencies.grdMain.Columns[columnIndx].HeaderStyle = colStyle;
                            columnIndx++;
                        }
                        colorIndx++;
                    }
                }
                catch (Exception ex)
                {
                    Reporter.ToLog(eLogLevel.ERROR, "Failed to design the " + mDepededItemType.ToString() + "-Variables dependencies grid columns", ex);
                }
                grdDependencies.SetGridColumnsWidth();//fix columns width

                //design rows
                grdDependencies.grdMain.SelectionUnit = DataGridSelectionUnit.CellOrRowHeader;

                //design checkbox cells
                if (grdDependencies.grdMain.Columns.Count >= 2)
                {
                    for (int i = 0; i < grdDependencies.grdMain.Columns.Count; i++)
                    {
                        if (grdDependencies.grdMain.Columns[i].Visibility == System.Windows.Visibility.Visible && i > 1)
                        {
                            ((DataGridCheckBoxColumn)grdDependencies.grdMain.Columns[i]).ElementStyle = (Style)FindResource("@CheckBoxGridCellElemntStyle");
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Reporter.ToLog(eLogLevel.ERROR, "Failed to design the " + mDepededItemType.ToString() + "-Variables dependencies grid data", ex);
            }
        }
コード例 #59
0
        public void SetWindowsResource()
        {
            System.Windows.Style windowStyle = null;

            switch (MargedResourceDictionary.gThemeType)
            {
            case MargedResourceDictionary.geThemeType.ShinyBlue:
                //Dlg_ThemeShinyBlue dlgThemeShinyBlue = (Dlg_ThemeShinyBlue)ExVisualTreeHelper.FindChildWindowForTheme(this, "dlgThemeShinyBlue");
                //if (dlgThemeShinyBlue != null)
                //{
                //    windowStyle = dlgThemeShinyBlue.Resources["ThemeStyle"] as Style;
                //}
                Dlg_ThemeShinyBlue dlgThemeShinyBlue = (Dlg_ThemeShinyBlue)this.FindName("dlgThemeShinyBlue");
                if (dlgThemeShinyBlue != null)
                {
                    windowStyle = dlgThemeShinyBlue.Resources["ThemeStyle"] as Style;
                }
                break;

            case MargedResourceDictionary.geThemeType.ShinyRed:
                break;

            case MargedResourceDictionary.geThemeType.TwilightBlue:
                Dlg_ThemeTwilightBlue dlgThemeTwilightBlue = (Dlg_ThemeTwilightBlue)this.FindName("dlgThemeTwilightBlue");
                if (dlgThemeTwilightBlue != null)
                {
                    windowStyle = dlgThemeTwilightBlue.Resources["ThemeStyle"] as Style;
                }
                break;

            case MargedResourceDictionary.geThemeType.BubbleCreme:
                break;

            case MargedResourceDictionary.geThemeType.BureauBlack:
                break;

            case MargedResourceDictionary.geThemeType.BureauBlue:
                break;

            case MargedResourceDictionary.geThemeType.ExpressionDark:
                break;

            case MargedResourceDictionary.geThemeType.ExpressionLight:
                break;

            case MargedResourceDictionary.geThemeType.RainerOrange:
                break;

            default:
                break;
            }

            if (windowStyle != null)
            {
                this.Style = windowStyle;
            }
        }
 private void ShowAttackConfigurationWidgetPopup()
 {
     if (!popupService.IsOpen("AttackConfigurationWidgetView"))
     {
         System.Windows.Style style = ControlUtilities.GetCustomWindowStyle();
         popupService.ShowDialog("AttackConfigurationWidgetView", AttackConfigurationWidgetViewModel, "", false, null, new SolidColorBrush(Colors.Transparent), style);
         ActivateWindow(ActiveWindow.ATTACK);
     }
 }