示例#1
0
        public Label CreateColumnNameBox()
        {
            var columnNameBox = new Label();

            columnNameBox.SetBinding(Label.ContentProperty, new Binding("ColumnName"){Source=_data});

            return columnNameBox;
        }
示例#2
0
文件: Score.cs 项目: zpw987/Teteris
        /// <summary>
        /// 计分板,必须传入作为UI的Label
        /// </summary>
        /// <param name="Scoring_Board"></param>
        public ScoringBoard(Label scoring_Board,int l1=100,int l2=250,int l3=400,int l4=600)
        {
            Binding binding = new Binding("Score");
            binding.Source = this;
            binding.Mode = BindingMode.OneWay;
            binding.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
            scoring_Board.SetBinding(Label.ContentProperty, binding);

            L1 = l1; L2 = l2; L3 = l3; L4 = l4;
        }
示例#3
0
        public Label GetLabel(UIElement visual)
        {
            var label = new Label();
            var binding = new Binding();
            binding.Source = visual;
            binding.Path = new PropertyPath(LabelProperty);

            label.SetBinding(ContentControl.ContentProperty, binding);

            return label;
        }
示例#4
0
        public ViewModel(int w, int h, MainViewModel mainModel)
        {
            this.mainModel = mainModel;
            items = new ObservableCollection<GameObjectShape>();
            Game = new Game(w, h);
            Game.NewObject += (s, e) => AddToScene(e);
            Game.RemoveObject += (s, e) => RemoveFromScene(e);
            Game.GameEndEvent += (s, e) => GameEnded(e);

            //informacios panel a jobb oldalon
            //100*ch meret
            HUDmodel sidepanelmodel = new HUDmodel(w - 100, 0, 100, h);
            Rectangle sidepanel = new Rectangle();
            sidepanel.Width = sidepanelmodel.Area.Width;
            sidepanel.Height = sidepanelmodel.Area.Height;
            sidepanel.Fill = sidepanelmodel.B;
            items.Add(new GameObjectShape(sidepanelmodel, sidepanel));

            //Palya label
            Label palya = new Label();
            HUDmodel palyaszammodel = new HUDmodel(w-100, 5, 0, 0);
            palya.DataContext = game;
            palya.ContentStringFormat = "Pálya: {0}";
            palya.SetBinding(ContentControl.ContentProperty, new Binding("Palyaszam"));
            items.Add(new GameObjectShape(palyaszammodel, palya));

            //Eletek label
            Label eletek = new Label();
            HUDmodel eletmodel = new HUDmodel(w-100, 20, 0, 0);
            eletek.DataContext = game;
            eletek.ContentStringFormat = "Életek: {0}";
            eletek.SetBinding(ContentControl.ContentProperty, new Binding("Player.Lives"));
            items.Add(new GameObjectShape(eletmodel, eletek));

            //Pontok label
            Label pontszam = new Label();
            HUDmodel pontmodel = new HUDmodel(w-100, 35, 0, 0);
            pontszam.DataContext = game;
            pontszam.ContentStringFormat = "Pontok: {0}";
            pontszam.SetBinding(ContentControl.ContentProperty, new Binding("Player.Points"));
            items.Add(new GameObjectShape(pontmodel, pontszam));

            //jatekos fegyverenek sebzese
            Label sebzes = new Label();
            HUDmodel sebzesmodel = new HUDmodel(w - 100, 50, 0, 0);
            sebzes.DataContext = game;
            sebzes.ContentStringFormat = "Sebzés: {0}";
            sebzes.SetBinding(ContentControl.ContentProperty, new Binding("Player.Damage"));
            items.Add(new GameObjectShape(sebzesmodel, sebzes));
        }
示例#5
0
        public void SetContent(string label, bool useMnemonic, ImageDescription image, ContentPosition position)
        {
            var accessText = new SWC.AccessText();

            accessText.Text = label;
            if (image.IsNull)
            {
                if (useMnemonic)
                {
                    Button.Content = accessText;
                }
                else
                {
                    Button.Content = accessText.Text.Replace("_", "__");
                }
            }
            else
            {
                SWC.DockPanel grid = new SWC.DockPanel();

                var imageCtrl = new ImageBox(Context);
                imageCtrl.ImageSource = image;

                SWC.DockPanel.SetDock(imageCtrl, DataConverter.ToWpfDock(position));
                grid.Children.Add(imageCtrl);

                if (!string.IsNullOrEmpty(label))
                {
                    SWC.Label labelCtrl = new SWC.Label();
                    if (useMnemonic)
                    {
                        labelCtrl.Content = accessText;
                    }
                    else
                    {
                        labelCtrl.Content = label;
                    }
                    labelCtrl.SetBinding(SWC.Label.ForegroundProperty, new Binding("Foreground")
                    {
                        Source = Button
                    });
                    grid.Children.Add(labelCtrl);
                }
                Button.Content = grid;
            }
            Button.InvalidateMeasure();
        }
        private void CreateCurrentPotValueLabel(RadDiagram diagram, ReplayerViewModel viewModel)
        {
            System.Windows.Controls.Label lbl = new System.Windows.Controls.Label();
            Binding myBinding = new Binding(nameof(ReplayerViewModel.CurrentPotValue))
            {
                Source = viewModel, Mode = BindingMode.TwoWay, Converter = new DecimalToPotConverter(), ConverterParameter = "Pot {0:C2}"
            };

            lbl.SetBinding(ContentControl.ContentProperty, myBinding);
            lbl.Background      = Brushes.LightGray;
            lbl.Foreground      = Brushes.Black;
            lbl.BorderBrush     = Brushes.Black;
            lbl.BorderThickness = new Thickness(1);
            lbl.Padding         = new Thickness(3, 3, 3, 3);
            lbl.Margin          = new Thickness(480, 315, 100, 100);
            diagram.AddShape(lbl);
        }
        private void CreateTotalPotValueLabel(RadDiagram diagram, ReplayerViewModel viewModel)
        {
            System.Windows.Controls.Label lbl = new System.Windows.Controls.Label();
            Binding myBinding = new Binding(nameof(ReplayerViewModel.TotalPotValue))
            {
                Source = viewModel, Mode = BindingMode.TwoWay, Converter = new DecimalToPotConverter(), ConverterParameter = "{0:C2}"
            };

            lbl.SetBinding(ContentControl.ContentProperty, myBinding);
            lbl.Foreground = Brushes.White;
            lbl.Margin     = new Thickness(480, 100, 100, 100);
            diagram.AddShape(lbl);

            viewModel.TotalPotChipsContainer.ChipsShape.X = TotalPotChipsPosition.X;
            viewModel.TotalPotChipsContainer.ChipsShape.Y = TotalPotChipsPosition.Y;

            diagram.AddShape(viewModel.TotalPotChipsContainer.ChipsShape);
        }
        private void AddPotPlayerLabel(RadDiagram diagram, ReplayerPlayerViewModel player, double x, double y)
        {
            try
            {
                System.Windows.Controls.Label lbl = new System.Windows.Controls.Label();
                Binding myBinding = new Binding(ReflectionHelper.GetPath <ReplayerPlayerViewModel>(o => o.ActiveAmount))
                {
                    Source = player, Mode = BindingMode.TwoWay, Converter = new DecimalToPotConverter(), ConverterParameter = "{0:C2}"
                };
                lbl.SetBinding(ContentControl.ContentProperty, myBinding);
                lbl.Foreground = Brushes.White;

                lbl.Margin = new Thickness(x - 15, y + 20, 100, 100);

                diagram.AddShape(lbl);
            }
            catch (Exception e)
            {
                LogProvider.Log.Error(this, e);
            }
        }
示例#9
0
        public WhereAmI(IWpfTextView textView)
        {
            _textView = textView;
            _monitor = new FileNameMonitor(GetDocument());

            Height = 20;
            ClipToBounds = true;
            Background = new SolidColorBrush(Colors.DarkSlateGray);

            var label = new Label
            {
                Background = new SolidColorBrush(Colors.DarkSlateGray),
                Foreground = new SolidColorBrush(Colors.White),
            };

            label.SetBinding(ContentControl.ContentProperty, new Binding("FileName") { Source = _monitor });

            Children.Add(label);

            ToolTip = "Click to open in explorer";
        }
        public UIWithHierarchicalPath()
        {
            var grid = new Grid();
            Content = grid;

            var label = new Label();
            label.SetBinding(Label.ContentProperty, new Binding("Items/Description"));
            grid.Children.Add(label);

            var stack = new StackPanel();
            stack.SetBinding(StackPanel.DataContextProperty, new Binding("Items"));
            grid.Children.Add(stack);

            label = new Label();
            label.SetBinding(Label.ContentProperty, new Binding("/Description"));
            stack.Children.Add(label);

            var button = new Button();
            button.SetBinding(Button.ContentProperty, new Binding("/"));
            button.Template = CreateTemplate();
            stack.Children.Add(button);
        }
示例#11
0
        public Field()
        {
            IsTabStop   = false;
            this.Margin = new Thickness(3);
            Grid root = new Grid();

            Content = root;
            root.RowDefinitions.Add(new RowDefinition()
            {
                Height = new GridLength(1.0, GridUnitType.Auto)
            });
            root.RowDefinitions.Add(new RowDefinition()
            {
                Height = new GridLength(1.0, GridUnitType.Auto)
            });

            Label label = new System.Windows.Controls.Label();

            label.Padding = new Thickness(0);
            label.Margin  = new Thickness(0, 0, 0, 3);
            label.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Left;
            label.SetBinding(System.Windows.Controls.Label.ContentProperty, new Binding("Label")
            {
                Source = this
            });
            label.VerticalAlignment = System.Windows.VerticalAlignment.Center;
            root.Children.Add(label);
            ContentControl control = new ContentControl();

            control.IsTabStop         = false;
            control.VerticalAlignment = System.Windows.VerticalAlignment.Center;
            control.SetBinding(ContentControl.ContentProperty, new Binding("Entry")
            {
                Source = this
            });
            control.SetValue(Grid.RowProperty, 1);
            root.Children.Add(control);
        }
示例#12
0
        private void InitializeGame()
        {
            this.ClearControls();
            // set game title
            title.DataContext = game;
            title.SetBinding(TextBlock.TextProperty, "VarietyName");
            // fill in the players
            matrix.RowDefinitions.RemoveRange(2, matrix.RowDefinitions.Count - 2);
            foreach (Player player in game.Players) {
                matrix.RowDefinitions.Add(new RowDefinition());
                Label playerLabel = new Label() {
                    Style = (Style)Resources["PlayerName"],
                };
                playerLabel.DataContext = player;
                playerLabel.SetBinding(Label.ContentProperty, new Binding("Name"));
                playerLabel.SetValue(Grid.ColumnProperty, 0);
                playerLabel.SetValue(Grid.RowProperty, matrix.RowDefinitions.Count - 1);
                matrix.Children.Add(playerLabel);
            }
            // fill in the cards
            matrix.ColumnDefinitions.RemoveRange(1, matrix.ColumnDefinitions.Count - 1);
            var columnWidth = new GridLength(0.75 / game.Cards.Count(), GridUnitType.Star);

            this.AddCardColumn(columnWidth, game.Suspects.OfType<Card>());
            this.AddCardColumn(columnWidth, game.Weapons.OfType<Card>());
            this.AddCardColumn(columnWidth, game.Places.OfType<Card>());

            suspectsLabel.SetValue(Grid.ColumnSpanProperty, game.Suspects.Count());
            weaponsLabel.SetValue(Grid.ColumnProperty, game.Suspects.Count());
            weaponsLabel.SetValue(Grid.ColumnSpanProperty, game.Weapons.Count());
            placesLabel.SetValue(Grid.ColumnProperty, game.Suspects.Count() + game.Weapons.Count());
            placesLabel.SetValue(Grid.ColumnSpanProperty, game.Places.Count());

            // fill in the envelope row
            matrix.RowDefinitions.Add(new RowDefinition());
            caseFile.SetValue(Grid.RowProperty, game.Players.Count + 2);
            matrix.Children.Add(caseFile);
            int cardIndex = 0;
            foreach (Card c in game.Cards) {
                Node node = game.Nodes.Where(n => n.CardHolder == game.CaseFile && n.Card == c).First();
                Label nodeLabel = new Label();
                nodeLabel.SetValue(Grid.ColumnProperty, 1 + cardIndex);
                nodeLabel.SetValue(Grid.RowProperty, game.Players.Count + 2);
                nodeLabel.DataContext = node;
                nodeLabel.SetBinding(Label.ContentProperty, new Binding("IsSelected"));
                matrix.Children.Add(nodeLabel);
                cardIndex++;
            }
        }
        private void PopulatePropertyValues(ControlSystem controlSystem)
        {
            var rowCount = 1;
            const int rowHeight = 25;

            var typeTestingProperties = controlSystem.ControlSystemType.ControlSystemTypeTestingProperties;

            var getAllPropertyListsTask = DatabaseLoader.GetAllPropertyLists();
            var getPidDocumentsTask = DatabaseLoader.GetQuickDocuments(CommonUtils.DoctypePidCode);
            var getSpecDocumentsTask = DatabaseLoader.GetQuickDocuments(CommonUtils.DoctypeFuncspecCode);
            var tasks = new List<Task> { getAllPropertyListsTask, getPidDocumentsTask, getSpecDocumentsTask };

            Task.Factory.ContinueWhenAll(tasks.ToArray(), xx =>
            {
                CMS.UiFactory.StartNew(() =>
                {
                    var addedGroups = new List<ComponentTypeGroup>();
                    var propertyLists = getAllPropertyListsTask.Result;

                    mPidDocuments = getPidDocumentsTask.Result.Select(d => d.Name).ToList();
                    mSpecDocuments = getSpecDocumentsTask.Result.Select(d => d.Name).ToList();

                    List<ControlSystemTypeTestingProperty> list = typeTestingProperties.OrderBy(x => x.Ordinal).ThenBy(x => x.GroupOrdinal).ToList();

                    foreach (var typeTestingProperty in list)
                    {
                        //Skip Properties that are not visible
                        if (typeTestingProperty.TestPropertyId.HasValue && !typeTestingProperty.ControlSystemTestingProperty.IsVisible) continue;

                        #region Group

                        if (typeTestingProperty.ComponentTypeGroupId.HasValue && !addedGroups.Contains(typeTestingProperty.ComponentTypeGroup))
                        {
                            var groupLabel = new Label
                            {
                                Content = typeTestingProperty.ComponentTypeGroup.Name,
                                VerticalAlignment = VerticalAlignment.Center,
                                Margin = new Thickness(1),
                                FontWeight = FontWeights.Bold
                            };

                            PropertiesGrid.Children.Add(groupLabel);
                            Grid.SetRow(groupLabel, rowCount);
                            Grid.SetColumn(groupLabel, (int)GridColumn.Description);
                            PropertiesGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(26) });
                            rowCount++;
                            addedGroups.Add(typeTestingProperty.ComponentTypeGroup);

                            //This is a empty Group so don't need to render a Property
                            if (!typeTestingProperty.TestPropertyId.HasValue) continue;
                        }
                        #endregion

                        #region Property Value

                        var propertyValue = GetPropertyValue(controlSystem, typeTestingProperty);

                        var wrapViewModel = new ControlTestingPropertyWrapViewModel(typeTestingProperty.ControlSystemTestingProperty, propertyValue);
                        PropertyWrapViewModels.Add(wrapViewModel);

                        var element = BindElementValue(wrapViewModel, propertyLists, mPidDocuments, mSpecDocuments);
                        PropertiesGrid.Children.Add(element);
                        Grid.SetRow(element, rowCount);
                        Grid.SetColumn(element, (int)GridColumn.Value);

                        #endregion

                        #region Description

                        var descLabel = new Label();
                        var descLabelBinding = new Binding("ShortDescription")
                        {
                            Mode = BindingMode.OneTime,
                            Source = typeTestingProperty.ControlSystemTestingProperty
                        };

                        descLabel.SetBinding(ContentControl.ContentProperty, descLabelBinding);

                        descLabel.Margin = new Thickness(1);

                        PropertiesGrid.Children.Add(descLabel);
                        Grid.SetRow(descLabel, rowCount);
                        Grid.SetColumn(descLabel, (int)GridColumn.Description);

                        var toolTip = new ToolTip { Content = typeTestingProperty.ControlSystemTestingProperty.Description };
                        ToolTipService.SetToolTip(descLabel, toolTip);

                        #endregion

                        #region Notes

                        //NOTES
                        var binding = new Binding("Notes")
                        {
                            Mode = BindingMode.TwoWay,
                            Source = wrapViewModel,
                            UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
                        };

                        var notesTextBox = new CmsTextBox();
                        notesTextBox.SetBinding(TextBox.TextProperty, binding);

                        notesTextBox.Margin = new Thickness(1);

                        var toolTipNotes = new ToolTip { Content = wrapViewModel.Notes };
                        ToolTipService.SetToolTip(notesTextBox, toolTipNotes);

                        notesTextBox.ResetOriginalValue();
                        notesTextBox.ControlChanged += ControlChanged;
                        PropertiesGrid.Children.Add(notesTextBox);
                        Grid.SetRow(notesTextBox, rowCount);
                        Grid.SetColumn(notesTextBox, (int)GridColumn.Notes);

                        #endregion

                        if (wrapViewModel.PropertyType == CommonUtils.PropertyType.LargeText)
                        {
                            descLabel.VerticalAlignment = VerticalAlignment.Top;
                            notesTextBox.VerticalAlignment = VerticalAlignment.Stretch;
                        }
                        else
                        {
                            descLabel.VerticalAlignment = VerticalAlignment.Center;
                            notesTextBox.VerticalAlignment = VerticalAlignment.Center;
                        }

                        PropertiesGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(element.Height + 2) });

                        rowCount++;
                    }
                });
            });
        }
        private void PopulatePropertyValues(ControlSystemComponent controlSystemComponent)
        {
            int rowCount = 1;
            const int rowHeight = 25;

            //var controlSystemComponentProperies = controlSystemComponent.ControlSystemComponentType.ControlSystemComponentTypeProperties.OrderBy(x => x.Ordinal).ToList();
            var controlSystemComponentTypeTuningProperties =
                controlSystemComponent.ControlSystemComponentType.ControlSystemComponentTypeTuningProperties.OrderBy(x => x.Ordinal).ToList();

            CmsWebServiceClient cmsWebServiceClient = new CmsWebServiceClient(Utils.WcfBinding, Utils.WcfEndPoint);
            cmsWebServiceClient.GetAllPropertyListsCompleted += (s, e) =>
            {
                List<ComponentTypeGroup> addedGroups = new List<ComponentTypeGroup>();
                //controlSystemComponentProperies.Where(x => x.ComponentTypeGroupId.HasValue).ToList().ForEach(x => x.Ordinal = x.ComponentTypeGroup.Ordinal);
                controlSystemComponentTypeTuningProperties = controlSystemComponentTypeTuningProperties.
                    OrderBy(x => x.Ordinal).ThenBy(x => x.GroupOrdinal).ToList();

                foreach (var controlSystemComponentTypeTuningProperty in controlSystemComponentTypeTuningProperties.Where(x => x.ControlSystemTuningProperty.IsVisible))
                {
                    if (controlSystemComponentTypeTuningProperty.ComponentTypeGroupId.HasValue && !addedGroups.Contains(controlSystemComponentTypeTuningProperty.ComponentTypeGroup))
                    {
                        Label groupLabel = new Label
                        {
                            Content = controlSystemComponentTypeTuningProperty.ComponentTypeGroup.Name,
                            VerticalAlignment = VerticalAlignment.Center,
                            Margin = new Thickness(1),
                            FontWeight = FontWeights.Bold
                        };

                        PropertiesGrid.Children.Add(groupLabel);
                        Grid.SetRow(groupLabel, rowCount);
                        Grid.SetColumn(groupLabel, 0);
                        PropertiesGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(26) });
                        rowCount++;
                        addedGroups.Add(controlSystemComponentTypeTuningProperty.ComponentTypeGroup);
                    }

                    //Property Label
                    Label label = new Label();

                    Binding labelBinding = new Binding("Name")
                    {
                        Mode = BindingMode.OneTime,
                        Source = controlSystemComponentTypeTuningProperty.ControlSystemTuningProperty
                    };

                    label.SetBinding(ContentControl.ContentProperty, labelBinding);
                    label.VerticalAlignment = VerticalAlignment.Center;
                    label.Margin = new Thickness(1);

                    Silverlight.Controls.ToolTips.ToolTip nameTip = new Silverlight.Controls.ToolTips.ToolTip
                    {
                        Content = controlSystemComponentTypeTuningProperty.ControlSystemTuningProperty.Description
                    };
                    ToolTipService.SetToolTip(label, nameTip);

                    PropertiesGrid.Children.Add(label);
                    Grid.SetRow(label, rowCount);
                    Grid.SetColumn(label, 0);

                    var propertyValue = GetPropertyValue(controlSystemComponent, controlSystemComponentTypeTuningProperty);

                    var tuningPropertyWrapViewModel = new TuningPropertyWrapViewModel(controlSystemComponentTypeTuningProperty.ControlSystemTuningProperty, propertyValue);
                    TuningPropertyWrapViewModels.Add(tuningPropertyWrapViewModel);

                    //Property VALUE
                    var element = BindElementValue(tuningPropertyWrapViewModel, e.Result);
                    PropertiesGrid.Children.Add(element);
                    Grid.SetRow((FrameworkElement) element, rowCount);
                    Grid.SetColumn((FrameworkElement) element, 1);

                    //PCS Value
                    var pcsValueElement = BindElementPcsvalue(tuningPropertyWrapViewModel, "PcsValue");
                    pcsValueElement.IsHitTestVisible = false;
                    //((CmsTextBox)pcsValueElement).Background = new SolidColorBrush(Color.FromArgb(255, 239, 239, 239));

                    PropertiesGrid.Children.Add(pcsValueElement);
                    Grid.SetRow((FrameworkElement) pcsValueElement, rowCount);
                    Grid.SetColumn((FrameworkElement) pcsValueElement, 2);

                    //Trended
                    var trendedElement = BindCheckBoxElement(tuningPropertyWrapViewModel, "Trended");
                    ((FrameworkElement) trendedElement).HorizontalAlignment = HorizontalAlignment.Center;

                    PropertiesGrid.Children.Add(trendedElement);
                    Grid.SetRow((FrameworkElement) trendedElement, rowCount);
                    Grid.SetColumn((FrameworkElement) trendedElement, 3);

                    //Notes
                    var notesElement = BindElementTextBox(tuningPropertyWrapViewModel, "Notes");

                    PropertiesGrid.Children.Add(notesElement);
                    Grid.SetRow((FrameworkElement) notesElement, rowCount);
                    Grid.SetColumn((FrameworkElement) notesElement, 4);

                    //Accept
                    Button acceptButton = new Button {Content = "Accept"};
                    acceptButton.Height = 23;
                    acceptButton.DataContext = tuningPropertyWrapViewModel;
                    acceptButton.Command = tuningPropertyWrapViewModel.AcceptCommand;
                    acceptButton.IsEnabled = controlSystemComponentTypeTuningProperty.ControlSystemTuningProperty.IsEditable;

                    Binding visibilityBinding = new Binding("AcceptButtonVisibility")
                    {
                        Mode = BindingMode.OneWay,
                        Source = tuningPropertyWrapViewModel
                    };
                    acceptButton.SetBinding(VisibilityProperty, visibilityBinding);

                    acceptButton.Width = 60;
                    PropertiesGrid.Children.Add(acceptButton);
                    Grid.SetRow((FrameworkElement) acceptButton, rowCount);
                    Grid.SetColumn((FrameworkElement) acceptButton, 5);

                    //ModfiedUserDate
                    var modfiedUserDate = BindElementLabel(tuningPropertyWrapViewModel, "ModfiedUserDate");
                    PropertiesGrid.Children.Add(modfiedUserDate);
                    Grid.SetRow((FrameworkElement) modfiedUserDate, rowCount);
                    Grid.SetColumn((FrameworkElement) modfiedUserDate, 6);

                    PropertiesGrid.RowDefinitions.Add(new RowDefinition {Height = new GridLength(rowHeight)});

                    rowCount++;
                }
            };
            cmsWebServiceClient.GetAllPropertyListsAsync();
        }
示例#15
0
        /// <summary>
        /// Creates a Label control for input type field
        /// </summary>
        /// <param name="parameterViewModel">DataContext object</param>
        /// <param name="rowNumber">Row number</param>
        /// <returns>Return a Label control</returns>
        private Label CreateLabel(ParameterViewModel parameterViewModel, int rowNumber)
        {
            Label label = new Label();

            label.SetBinding(Label.ContentProperty, new Binding("NameTextLabel"));
            label.DataContext = parameterViewModel;
            label.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
            label.SetValue(Grid.ColumnProperty, 0);
            label.SetValue(Grid.RowProperty, rowNumber);
            label.Margin = new Thickness(2);
            label.SetBinding(Label.ToolTipProperty, new Binding("ToolTip"));

            //// Add AutomationProperties.AutomationId for Ui Automation test.
            label.SetValue(
                System.Windows.Automation.AutomationProperties.AutomationIdProperty,
                string.Format(CultureInfo.CurrentCulture, "lbl{0}", parameterViewModel.Name));

            return label;
        }
示例#16
0
        public MapInfo(int X, int Y, int Rad, string Text)
        {
            _PosX = X;
            _PosY = Y;
            _Radius = Rad;
            _Text = Text;
            _InfoText = "";

            //Create the circle
            _NewCircle = new Ellipse();
            _NewCircle.Height = Rad * 2;
            _NewCircle.Width = Rad * 2;
            _NewCircle.Stroke = new SolidColorBrush(Colors.Red);
            _NewCircle.Fill = new SolidColorBrush(Colors.Red);
            _NewCircle.Opacity = 0.6;
            _NewCircle.HorizontalAlignment = HorizontalAlignment.Left;
            _NewCircle.VerticalAlignment = VerticalAlignment.Top;

            _NewCircle.MouseDown += new MouseButtonEventHandler(Obj_MouseDown);
            _NewCircle.MouseUp += new MouseButtonEventHandler(Obj_MouseUp);
            _NewCircle.MouseLeave += new MouseEventHandler(Obj_MouseLeave);

            //Create the Label Info
            _InfoLabel = new Label();
            _InfoLabel.DataContext = this;
            _InfoLabel.SetBinding(Label.ContentProperty, new Binding("Text"));
            _InfoLabel.Background = new SolidColorBrush(Colors.LightGray);
            _InfoLabel.HorizontalAlignment = HorizontalAlignment.Left;
            _InfoLabel.VerticalAlignment = VerticalAlignment.Top;
            _InfoLabel.Opacity = 0.9;

            //Set Pos
            _NewCircle.Margin = new Thickness(X - Rad, Y - Rad, 0, 0);
            _InfoLabel.Margin = new Thickness(X - Rad, Y - Rad - 30, 0, 0);
        }
        private UIElement BindElementLabel(TuningPropertyWrapViewModel tuningPropertyWrapViewModel, string bindingPath)
        {
            Binding binding = new Binding(bindingPath)
            {
                Mode = BindingMode.TwoWay,
                Source = tuningPropertyWrapViewModel
            };

            Label lastModifiedLabel = new Label();
            lastModifiedLabel.SetBinding(Label.ContentProperty, binding);
            lastModifiedLabel.VerticalAlignment = VerticalAlignment.Center;
            lastModifiedLabel.Margin = new Thickness(1);

            UIElement returnElement = lastModifiedLabel;

            return returnElement;
        }
        //--------------methods--------------
        public MORSObjectsMerge()
        {
            InitializeComponent();

            /*
             mGrid.ColumnDefinitions.Add(new ColumnDefinition());
             Label lbl1 = new Label();
             lbl1.Content = "testestestest";
              lbl1.Style = stylBezGorLew;
             Grid.SetColumn(lbl1, 5);
             Grid.SetRow(lbl1, 0);
             mGrid.Children.Add(lbl1);
             */
            //ustawia kulturę

            CultureInfo culture;
            culture = CultureInfo.CreateSpecificCulture("pl");
            Thread.CurrentThread.CurrentCulture = culture;
            Thread.CurrentThread.CurrentUICulture = culture;
            this.Language = XmlLanguage.GetLanguage(Thread.CurrentThread.CurrentCulture.Name);

            //generuje liste wierszy
            listaWierszy = new List<cPDBVar>();
            listaWierszy.Add(new cPDBVar(1, "Catering, diety, bilety, transport własny", "Catering_diety_bilety_transport_własny", "inne"));
            listaWierszy.Add(new cPDBVar(4, "CAPI koszt wywiadowcy", "CAPI_IntervrCost", "CAPI"));
            listaWierszy.Add(new cPDBVar(982, "CAWI inny koszt", "CAWI_anotherCost", "CAWI"));
            listaWierszy.Add(new cPDBVar(23, "RT koszt analizy", "RT_AnalysisCost", "RT"));
            listaWierszy.Add(new cPDBVar(2, "CAWI koszt operacji", "cawi_opserviceCost", "CAWI"));
            listaWierszy.Add(new cPDBVar(3, "CAPI inny koszt", "CAPI_AnotherCost", "CAPI"));
            listaWierszy.Add(new cPDBVar(5, "CAPI koszt koordynatora", "CAPI_CoordCost", "CAPI"));
            //  listaWierszy.Add(new cPDBVar(65, "raaaa", "ARAAAA", "ARARA"));
            listaWierszy = listaWierszy.OrderBy(p => p.VarGroup).ToList(); //zeby byly po kolei

            Random random = new Random();

            listacPDB = new List<cPDB>();
            listacPDB.Add(new cPDB(999, 11, 11, 11, 11, 11, 11));
            listacPDB.Add(new cPDB(982, random.Next(0, 100), random.Next(0, 100), random.Next(0, 100), random.Next(0, 100), random.Next(0, 100), random.Next(0, 100)));
            listacPDB.Add(new cPDB(888, 22, 22, 22, 22, 22, 22));
            listacPDB.Add(new cPDB(477, 33, 33, 33, 33, 33, 33));
            listacPDB.Add(new cPDB(666, 44, 44, 44, 44, 44, 44));
            listacPDB.Add(new cPDB(159, 55, 55, 55, 55, 55, 55));

            listaKolumn = new List<cKolumna>();

            foreach(cPDB kol in listacPDB)
            {
                listaKolumn.Add(new cKolumna(kol));
            }

            /*
               listaSum = new List<decimal>();
               for (int i =0; i < listaWierszy.Count(); ++i)
               {
                listaSum.Add(0);
               }
            */
            //--------------------------------------------------------------------------------------------------
            /*
             * ogolnie, działa to tak:
             * najpierw pisze nazwy poszczególnych wierszy i sumy z nich, potem pomiędzy nie wkleja wiersze z grupami i ich sumy
             * zeby uniknąć wyszukiwania ktory wiersz jest grupy, a ktory juz pojedynczej zmiennej
             */
            //style z xamla sciaga
            stylBezGorLew = this.FindResource("bezGorLew") as Style;
            stylNazwaPoz = this.FindResource("nazwaPoz") as Style;
            stylCala = this.FindResource("cala") as Style;
            stylNazwaPrel = this.FindResource("nazwaPrel") as Style;
            stylNazwaPrelZaznaczona = this.FindResource("nazwaPrelZaznaczona") as Style;
            stylNazwaGrupy = this.FindResource("nazwaGrupy") as Style;
            stylZaznaczona = this.FindResource("zaznaczona") as Style;
            stylNazwaGrupyZaznaczona = this.FindResource("nazwaGrupyZaznaczona") as Style;
            stylNazwaPozZaznaczona = this.FindResource("nazwaPozZaznaczona") as Style;

            Label lbl;

            //wypełnia liste grup nie duplikujac jej:
            listaGrup = new HashSet<string>();
            try
            {
                foreach (cPDBVar wiersz in listaWierszy)
                {
                    listaGrup.Add(wiersz.VarGroup);
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message + "dupa1");
            }

            //generuje lewy gorny rog
            ColumnDefinition col = new ColumnDefinition();
            col.MinWidth = 300;
            mGrid.ColumnDefinitions.Add(col);
            lbl = new Label();
            lbl.Content = "pozycja";
            lbl.Style = stylCala;
            Grid.SetColumn(lbl, 0);
            Grid.SetRow(lbl, 0);
            mGrid.Children.Add(lbl);

            //generuje nazwy pozycji i nazwy grup
            mGrid.RowDefinitions.Add(new RowDefinition());
            int index = 1;
            foreach (string str in listaGrup)
            {
                mGrid.RowDefinitions.Add(new RowDefinition());
                lbl = new Label();
                lbl.Content = str;
                lbl.Style = stylNazwaGrupy;
                lbl.MouseDown += new MouseButtonEventHandler(OnGroupNameClick);
                Grid.SetColumn(lbl, 0);
                Grid.SetRow(lbl, index);

                listaWierszy.Insert(index++ - 1, new cPDBVar(0, "none", "none", str));

                mGrid.Children.Add(lbl);

                foreach (cPDBVar wiersz in listaWierszy)
                {
                    if (wiersz.VarGroup == str && wiersz.Name != "none")
                    {
                        mGrid.RowDefinitions.Add(new RowDefinition());
                        lbl = new Label { DataContext = wiersz };
                        lbl.SetBinding(Label.ContentProperty, new Binding("Name"));

                        lbl.Style = stylNazwaPoz;
                        lbl.MouseDown += new MouseButtonEventHandler(OnRowNameClick);
                        Grid.SetColumn(lbl, 0);
                        Grid.SetRow(lbl, index++);
                        mGrid.Children.Add(lbl);

                    }
                }
            }

            //generuje nazwy kolumn
            for (int i = 0; i < listacPDB.Count(); ++i)
            {
                mGrid.ColumnDefinitions.Add(new ColumnDefinition());
                lbl = new Label { DataContext = listacPDB[i] };
                lbl.SetBinding(Label.ContentProperty, new Binding("IdPDB"));

                lbl.Style = stylNazwaPrel;
                lbl.MouseDown += new MouseButtonEventHandler(OnColumnNameClick);
                Grid.SetColumn(lbl, i + 1);
                Grid.SetRow(lbl, 0);
                mGrid.Children.Add(lbl);
            }

            //generuje ostatnia kolumne
            mGrid.ColumnDefinitions.Add(new ColumnDefinition());
            lbl = new Label();
            lbl.ContentStringFormat = "C";
            lbl.Content = "suma";
            lbl.Style = stylNazwaPrel;
            Grid.SetColumn(lbl, mGrid.ColumnDefinitions.Count());
            Grid.SetRow(lbl, 0);
            mGrid.Children.Add(lbl);

            //generuje komorke sumy calkowitej
            lblSumaCalkowita = new Label();

            mGrid.RowDefinitions.Add(new RowDefinition());
            sumaCalkowita = 0;
            lblSumaCalkowita.Content = sumaCalkowita.ToString();
            lblSumaCalkowita.ContentStringFormat = "C";
               // lbl.ContentStringFormat = "C";
            lblSumaCalkowita.Style = stylCala ;
            Grid.SetColumn(lblSumaCalkowita, mGrid.ColumnDefinitions.Count());
            Grid.SetRow(lblSumaCalkowita, mGrid.RowDefinitions.Count());
            mGrid.Children.Add(lblSumaCalkowita);

            //zawartość tabeli:
            //v2
            //konstruuje tabele komorek
            tabela = new List<List<cKomorka>>();
            foreach (cPDBVar wiersz in listaWierszy)
            {
                List<cKomorka> wierszKomorek = new List<cKomorka>();

                foreach (cPDB kol in listacPDB)
                {
                    wierszKomorek.Add(new cKomorka(kol, wiersz));
                }
                tabela.Add(wierszKomorek);
            }

            int x = 1;
            int y = 1;
            //suma poszczegolnych wierszy
            foreach (List<cKomorka> wiersz in tabela)
            {
                x = 1;
                foreach (cKomorka komorka in wiersz)
                {
                    if (komorka.jestSuma)
                    {
                        decimal sumOfGroupInColumn = calculateSumOfGroupInColumn(komorka.kolumna.cpdb , komorka.wiersz.VarGroup, tabela);
                        komorka.val = sumOfGroupInColumn;
                        sumaCalkowita += sumOfGroupInColumn;
                    }

                }
                y++;
            }
            //suma z wiersza
            List<decimal> listaSum = new List<decimal>();
            foreach (List<cKomorka> wiersz in tabela)
            {
                cKomorka newKomorka = new cKomorka(calculateSumOfRow(wiersz));
                wiersz.Add(newKomorka);

            }

            //wyswietlam tabele komorek
            x = 1;
            y = 1;
            foreach (List<cKomorka> wiersz in tabela)
            {
                x = 1;
                for (int i = 0; i< wiersz.Count(); ++i) //each (cKomorka komorka in wiersz)
                {
                    lbl = new Label();
                    lbl.Content = wiersz[i].val;
                    wiersz[i].lbl = lbl;
                    if (i < wiersz.Count() - 1)
                    {
                        lbl.MouseDown += new MouseButtonEventHandler(OnCellClick);
                    }
                    lbl.Style = stylBezGorLew;
                    Grid.SetColumn(lbl, x++);
                    Grid.SetRow(lbl, y);
                    mGrid.Children.Add(lbl);

                }
                y++;
            }
        }
        private void OnLoadShapeModelButtonClick(object sender, RoutedEventArgs e)
        {
            OpenFileDialog openDialog = new OpenFileDialog();
            openDialog.InitialDirectory = @"C:\Users\boya\Source\BayesianShapePrior\ShapeModelLearner\bin\Release";
            if (openDialog.ShowDialog().Value)
            {
                try
                {
                    this.shapeModel = ShapeModel.Load(openDialog.FileName);
                }
                catch (Exception)
                {
                    MessageBox.Show("Something went wrong while loading a model from " + openDialog.FileName);
                    return;
                }

                this.loadMaskToCompleteButton.IsEnabled = true;

                this.traitSetupPanel.Children.Clear();
                this.traitSliders.Clear();
                for (int i = 0; i < this.shapeModel.TraitCount; ++i)
                {
                    Slider slider = new Slider();
                    slider.Value = i == this.shapeModel.TraitCount - 1 ? 1 : 0;
                    slider.Minimum = -3;
                    slider.Maximum = 3;
                    slider.TickPlacement = System.Windows.Controls.Primitives.TickPlacement.BottomRight;
                    slider.TickFrequency = 0.25;
                    slider.ValueChanged += OnSliderValueChanged;

                    traitSliders.Add(slider);
                    this.traitSetupPanel.Children.Add(slider);

                    Label sliderValueLabel = new Label();
                    sliderValueLabel.DataContext = slider;
                    sliderValueLabel.SetBinding(Label.ContentProperty, new Binding("Value"));
                    sliderValueLabel.Margin = new Thickness(5, 5, 5, 15);
                    this.traitSetupPanel.Children.Add(sliderValueLabel);
                }

                this.Sample();
            }
        }
示例#20
0
        private void CreateOnOffStopIndependentOperationInfo(Grid grid, FALibrary.Part.FAPart part, string name, Action<object> OnAction, Action<object> OffAction, Action<object> StopAction, Func<bool> IsOn, Func<bool> IsOff, string onName, string offName)
        {
            GeneralOperationInfo obj = new GeneralOperationInfo();
            RowDefinition rd = new RowDefinition();
            rd.Height = new GridLength(100, GridUnitType.Auto);
            rd.MinHeight = 100;
            grid.RowDefinitions.Add(rd);
            SetOperationGridColor(grid, grid.RowDefinitions.Count - 1);

            obj.Name = name;
            obj.On = OnAction;
            obj.Off = OffAction;
            obj.StatusOnName = onName;
            obj.StatusOffName = offName;
            obj.IsOn = IsOn;
            obj.IsOff = IsOff;

            Label labelName = new Label();
            labelName.Height = Double.NaN;
            labelName.Width = Double.NaN;
            labelName.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Stretch;
            labelName.VerticalContentAlignment = System.Windows.VerticalAlignment.Stretch;
            labelName.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Center;
            labelName.VerticalContentAlignment = System.Windows.VerticalAlignment.Center;
            labelName.Margin = new Thickness(2);
            Binding bd = new Binding("Name");
            bd.Source = obj;
            bd.Mode = BindingMode.OneWay;
            labelName.SetBinding(Label.ContentProperty, bd);

            Label labelStatus = new Label();
            labelStatus.Height = Double.NaN;
            labelStatus.Width = Double.NaN;
            labelStatus.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Stretch;
            labelStatus.VerticalContentAlignment = System.Windows.VerticalAlignment.Stretch;
            labelStatus.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Center;
            labelStatus.VerticalContentAlignment = System.Windows.VerticalAlignment.Center;
            labelStatus.Margin = new Thickness(2);
            bd = new Binding("Status");
            bd.Source = obj;
            bd.Mode = BindingMode.OneWay;
            labelStatus.SetBinding(Label.ContentProperty, bd);

            Grid gridInputIOList = CreatePartInputIOList(part);
            Grid gridOutputIOList = CreatePartOutputIOList(part);

            Button buttonOn, buttonOff, buttonStop;
            Grid gridButton = CreateOnOffStopButtonGrid(out buttonOn, out buttonOff, out buttonStop);
            buttonOn.Content = onName;
            buttonOff.Content = offName;
            buttonStop.Content = "STOP";

            buttonOn.Click +=
                delegate(object sender, RoutedEventArgs e)
                {
                    OnAction(sender);
                };

            buttonOff.Click +=
                delegate(object sender, RoutedEventArgs e)
                {
                    OffAction(sender);
                };

            buttonStop.Click +=
                delegate(object sender, RoutedEventArgs e)
                {
                    StopAction(sender);
                };

            TextBox textBoxRepeat = new TextBox();
            textBoxRepeat.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
            textBoxRepeat.VerticalAlignment = System.Windows.VerticalAlignment.Stretch;
            textBoxRepeat.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Center;
            textBoxRepeat.VerticalContentAlignment = System.Windows.VerticalAlignment.Center;
            textBoxRepeat.Height = Double.NaN;
            textBoxRepeat.Width = Double.NaN;
            textBoxRepeat.Margin = new Thickness(2);
            bd = new Binding("RepeatTime");
            bd.Source = obj;
            bd.Mode = BindingMode.TwoWay;
            textBoxRepeat.SetBinding(TextBox.TextProperty, bd);

            CheckBox checkBoxRepeatUse = new CheckBox();
            checkBoxRepeatUse.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
            checkBoxRepeatUse.VerticalAlignment = System.Windows.VerticalAlignment.Center;
            checkBoxRepeatUse.LayoutTransform = new ScaleTransform(CHECKBOX_SIZE, CHECKBOX_SIZE);
            bd = new Binding("RepeatUse");
            bd.Source = obj;
            bd.Mode = BindingMode.TwoWay;
            checkBoxRepeatUse.SetBinding(CheckBox.IsCheckedProperty, bd);

            int rowCount = grid.RowDefinitions.Count - 1;
            grid.Children.Add(labelName);
            Grid.SetColumn(labelName, 0);
            Grid.SetRow(labelName, rowCount);

            grid.Children.Add(labelStatus);
            Grid.SetColumn(labelStatus, 1);
            Grid.SetRow(labelStatus, rowCount);

            grid.Children.Add(gridInputIOList);
            Grid.SetColumn(gridInputIOList, 2);
            Grid.SetRow(gridInputIOList, rowCount);

            grid.Children.Add(gridOutputIOList);
            Grid.SetColumn(gridOutputIOList, 3);
            Grid.SetRow(gridOutputIOList, rowCount);

            grid.Children.Add(gridButton);
            Grid.SetColumn(gridButton, 4);
            Grid.SetRow(gridButton, rowCount);

            grid.Children.Add(textBoxRepeat);
            Grid.SetColumn(textBoxRepeat, 5);
            Grid.SetRow(textBoxRepeat, rowCount);

            grid.Children.Add(checkBoxRepeatUse);
            Grid.SetColumn(checkBoxRepeatUse, 6);
            Grid.SetRow(checkBoxRepeatUse, rowCount);

            _ioOperationList.Add(obj);

            bd = new Binding("IsEnabledOutputIODirectControl");
            bd.Source = this;
            bd.Mode = BindingMode.OneWay;
            gridOutputIOList.SetBinding(ListView.IsEnabledProperty, bd);
        }
        private void CreateAndBindDynamicProperties(InstrumentComponent instrumentComponent, List<String> pidDocuments, List<String> specDocuments)
        {
            int rowCount = 5;

            var controlSystemComponentProperies = instrumentComponent.InstrumentComponentType.InstrumentComponentTypeProperties.OrderBy(x => x.Ordinal).ToList();

            CmsWebServiceClient cmsWebServiceClient = new CmsWebServiceClient(Utils.WcfBinding, Utils.WcfEndPoint);
            cmsWebServiceClient.GetAllPropertyListsCompleted += (s, e) =>
            {

                foreach (var controlSystemComponentProperty in controlSystemComponentProperies.Where(x => x.InstrumentProperty.IsVisible))
                {

                    Label label = new Label();

                    Binding labelBinding = new Binding("Name")
                    {
                        Mode = BindingMode.OneTime,
                        Source = controlSystemComponentProperty.InstrumentProperty
                    };

                    label.SetBinding(ContentControl.ContentProperty, labelBinding);
                    label.VerticalAlignment = VerticalAlignment.Center;
                    label.Margin = new Thickness(1);

                    PropertiesGrid.Children.Add(label);
                    Grid.SetRow(label, rowCount);
                    Grid.SetColumn(label, 0);

                    var propertyValue = GetPropertyValue(instrumentComponent, controlSystemComponentProperty);

                    var element = Utils.BindElement(controlSystemComponentProperty.InstrumentProperty, propertyValue, e.Result,
                        ComponentPropertyWrapViewModels, ControlChanged, pidDocuments, specDocuments);

                    PropertiesGrid.Children.Add(element);
                    Grid.SetRow((FrameworkElement)element, rowCount);
                    Grid.SetColumn((FrameworkElement)element, 1);

                    PropertiesGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(element.Height + 2) });

                    rowCount++;
                }

                LastInspectedTextBox.ResetOriginalValue();
                LastInspectedTextBox.ControlChanged += ControlChanged;

                NextInspectionTextBox.ResetOriginalValue();
                NextInspectionTextBox.ControlChanged += ControlChanged;

            };
            cmsWebServiceClient.GetAllPropertyListsAsync();
        }
示例#22
0
        protected override FrameworkElement BuildGUIConfiguration()
        {
            TextBox capacity = new TextBox() { Width = 20, Height = 20 };
            capacity.SetBinding(TextBox.TextProperty, new Binding("Capacity"));

            StackPanel capacityPanel = new StackPanel() { Orientation = Orientation.Horizontal };
            capacityPanel.Children.Add(new Label() { Content = "Capacity" });
            capacityPanel.Children.Add(capacity);

            TextBox entranceCapacity = new TextBox() { Width = 20, Height = 20 };
            entranceCapacity.SetBinding(TextBox.TextProperty, new Binding("EntranceCapacity"));

            StackPanel entranceCapacityPanel = new StackPanel() { Orientation = Orientation.Horizontal };
            entranceCapacityPanel.Children.Add(new Label() { Content = "Entrance capacity" });
            entranceCapacityPanel.Children.Add(entranceCapacity);

            TextBox delay = new TextBox() { Width = 20, Height = 20 };
            delay.SetBinding(TextBox.TextProperty, new Binding("Delay"));

            StackPanel delayPanel = new StackPanel() { Orientation = Orientation.Horizontal };
            delayPanel.Children.Add(new Label() { Content = "Delay" });
            delayPanel.Children.Add(delay);

            Label messageLabel = new Label();
            messageLabel.SetBinding(Label.ContentProperty, new Binding("Message"));

            StackPanel panel = new StackPanel();
            panel.Children.Add(entranceCapacityPanel);
            panel.Children.Add(capacityPanel);
            panel.Children.Add(delayPanel);
            panel.Children.Add(messageLabel);

            return panel;
        }
        private void BindLabel(CalibrationComponentTypeProperty calibrationComponentProperty, string path,int rowCount, int column, bool bindTooltip)
        {
            Label label = new Label();

            Binding labelBinding = new Binding(path)
            {
                Mode = BindingMode.OneTime,
                Source = calibrationComponentProperty
            };

            label.SetBinding(ContentControl.ContentProperty, labelBinding);
            label.Margin = new Thickness(1);

            if (bindTooltip)
            {
                Silverlight.Controls.ToolTips.ToolTip nameTip = new Silverlight.Controls.ToolTips.ToolTip
                {
                    Content = calibrationComponentProperty.CalibrationProperty.Name
                };
                ToolTipService.SetToolTip(label, nameTip);
            }

            PropertiesGrid.Children.Add(label);
            Grid.SetRow(label, rowCount);
            Grid.SetColumn(label, column);
        }
示例#24
0
        private FrameworkElement BuildHeaderArea()
        {
            Grid header = new Grid();
            header.ColumnDefinitions.Add(new ColumnDefinition());
            header.ColumnDefinitions.Add(new ColumnDefinition {Width = GridLength.Auto});
            header.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Auto });

            //Move grip containing the icon and title
            Grid moveGrip = new Grid();
            moveGrip.ColumnDefinitions.Add(new ColumnDefinition
            {
                Width = GridLength.Auto
            });
            moveGrip.ColumnDefinitions.Add(new ColumnDefinition());
            moveGrip.SetResourceReference(Border.BackgroundProperty, EnvironmentColors.ToolWindowBackgroundBrushKey);
            moveGrip.SetValue(Grid.ColumnProperty, 0);
            moveGrip.MouseLeftButtonDown += TitleBarLeftMouseButtonDown;

            Image icon = new Image
            {
                VerticalAlignment = VerticalAlignment.Center,
                Margin = new Thickness(10, 5, 4, 0)
            };
            icon.SetBinding(Image.SourceProperty, new Binding
            {
                Source = this,
                Path = new PropertyPath("Icon"),
                Mode = BindingMode.OneWay
            });
            moveGrip.Children.Add(icon);

            Label label = new Label
            {
                VerticalAlignment = VerticalAlignment.Center,
                Margin = new Thickness(0, 2, 0, 0)
            };
            label.SetValue(Grid.ColumnProperty, 1);
            label.SetBinding(ContentControl.ContentProperty, new Binding
            {
                Source = this,
                Path = new PropertyPath("Title"),
                Mode = BindingMode.OneWay
            });
            label.SetResourceReference(ForegroundProperty, EnvironmentColors.MainWindowActiveCaptionTextBrushKey);
            moveGrip.Children.Add(label);
            header.Children.Add(moveGrip);

            //Close button
            FrameworkElement closeGlyph;
            Path buttonPath;
            GenerateCloseGlyph(out closeGlyph, out buttonPath);

            Style closeButtonStyle = new Style(typeof(Button));
            closeButtonStyle.Setters.Add(new Setter(HeightProperty, (double)25));
            closeButtonStyle.Setters.Add(new Setter(WidthProperty, (double)25));
            closeButtonStyle.Setters.Add(new Setter(FocusVisualStyleProperty, null));
            closeButtonStyle.Setters.Add(new Setter(ForegroundProperty, new DynamicResourceExtension(EnvironmentColors.MainWindowButtonActiveGlyphBrushKey)));
            closeButtonStyle.Setters.Add(new Setter(BackgroundProperty, null));
            closeButtonStyle.Setters.Add(new Setter(BorderBrushProperty, new DynamicResourceExtension(EnvironmentColors.MainWindowButtonActiveBorderBrushKey)));
            closeButtonStyle.Setters.Add(new Setter(TemplateProperty, FindResource("FlatButton")));

            Trigger closeButtonHoverTrigger = new Trigger
            {
                Property = IsMouseOverProperty,
                Value = true
            };

            closeButtonHoverTrigger.Setters.Add(new Setter(ForegroundProperty, new DynamicResourceExtension(EnvironmentColors.MainWindowButtonHoverActiveGlyphBrushKey)));
            closeButtonHoverTrigger.Setters.Add(new Setter(BackgroundProperty, new DynamicResourceExtension(EnvironmentColors.MainWindowButtonHoverActiveBrushKey)));
            closeButtonHoverTrigger.Setters.Add(new Setter(BorderBrushProperty, new DynamicResourceExtension(EnvironmentColors.MainWindowButtonHoverActiveBorderBrushKey)));
            closeButtonStyle.Triggers.Add(closeButtonHoverTrigger);

            Trigger closeButtonPressTrigger = new Trigger
            {
                Property = ButtonBase.IsPressedProperty,
                Value = true
            };

            closeButtonPressTrigger.Setters.Add(new Setter(ForegroundProperty, new DynamicResourceExtension(EnvironmentColors.MainWindowButtonDownGlyphBrushKey)));
            closeButtonPressTrigger.Setters.Add(new Setter(BackgroundProperty, new DynamicResourceExtension(EnvironmentColors.MainWindowButtonDownBrushKey)));
            closeButtonPressTrigger.Setters.Add(new Setter(BorderBrushProperty, new DynamicResourceExtension(EnvironmentColors.MainWindowButtonDownBorderBrushKey)));
            closeButtonStyle.Triggers.Add(closeButtonPressTrigger);

            Button closeButton = new Button
            {
                Style = closeButtonStyle,
                Name = "closeButton",
                Content = closeGlyph,
                HorizontalContentAlignment = HorizontalAlignment.Center,
                VerticalContentAlignment = VerticalAlignment.Center
            };

            closeButton.SetValue(Grid.ColumnProperty, 2);
            header.Children.Add(closeButton);
            buttonPath.SetBinding(Shape.FillProperty, new Binding
            {
                Path = new PropertyPath("Foreground"),
                Source = closeButton,
                Mode = BindingMode.OneWay
            });

            closeButton.Click += CloseButtonClick;

            return header;
        }
示例#25
0
        private void AddCardColumn(GridLength columnWidth, IEnumerable<Card> cardGroup)
        {
            foreach (Card c in cardGroup) {
                matrix.ColumnDefinitions.Add(new ColumnDefinition() { Width = columnWidth });
                TextBlock cardBlock = new TextBlock() {
                    Style = (Style)Resources["VerticalText"]
                };
                cardBlock.DataContext = c;
                cardBlock.SetBinding(TextBlock.TextProperty, new Binding("Name"));
                cardBlock.SetValue(Grid.ColumnProperty, matrix.ColumnDefinitions.Count - 1);
                cardBlock.SetValue(Grid.RowProperty, 1);
                matrix.Children.Add(cardBlock);

                // Fill in the individual nodes for this card.
                foreach (Player player in game.Players) {
                    Node node = game.Nodes.Where(n => n.CardHolder == player && n.Card == c).First();
                    Label nodeLabel = new Label();
                    nodeLabel.SetValue(Grid.ColumnProperty, matrix.ColumnDefinitions.Count - 1);
                    nodeLabel.SetValue(Grid.RowProperty, game.Players.IndexOf(player) + 2);
                    nodeLabel.DataContext = node;
                    nodeLabel.SetBinding(Label.ContentProperty, new Binding("IsSelected"));
                    matrix.Children.Add(nodeLabel);
                }
            }
        }
        /// <summary>
        /// 具体刷新Tab内容的方法
        /// </summary>
        /// <param name="tab"></param>
        private void RefreshTabContent(TabItem tab)
        {
            //logger.Debug("刷新控件ing");

            if (tab.Tag == null)
                return;

            int index = (int)tab.Tag;

            var prompts = viewModel.Prompts.Where(it => it.TabIndex == index)
                                          .ToList();

            Grid grid = new Grid();

            ScrollViewer viewer = new ScrollViewer();
            viewer.VerticalScrollBarVisibility = ScrollBarVisibility.Auto;
            viewer.Content = grid;

            tab.Content = viewer;

            grid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(10) });
            grid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength() });
            grid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(20) });
            grid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(230) });
            grid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(220) });
            grid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(250, GridUnitType.Star) });
            StackPanel leftSP = new StackPanel();
            leftSP.Margin = new Thickness(5, 0, 30, 0);
            leftSP.SetValue(Grid.RowProperty, 1);
            leftSP.SetValue(Grid.ColumnProperty, 1);
            StackPanel middleSP = new StackPanel();
            middleSP.Margin = new Thickness(30, 0, 30, 0);
            middleSP.SetValue(Grid.RowProperty, 1);
            middleSP.SetValue(Grid.ColumnProperty, 2);
            StackPanel rightSP = new StackPanel();
            rightSP.Margin = new Thickness(30, 0, 0, 0);
            rightSP.SetValue(Grid.RowProperty, 1);
            rightSP.SetValue(Grid.ColumnProperty, 3);

            grid.Children.Add(leftSP);
            grid.Children.Add(middleSP);
            grid.Children.Add(rightSP);

            for (int i = 0; i < prompts.Count(); i++)
            {
                var prompt = prompts[i];

                if (prompt.ControlType == ControlType.TextBox
                    || prompt.ControlType == ControlType.UnEditabledTextBox
                    || prompt.ControlType == ControlType.Invisabled)
                {
                    Label label = new Label();
                    label.Foreground = getBrushById(prompt.ColorIndex);
                    label.DataContext = prompt;
                    label.SetBinding(Label.ContentProperty, new Binding("Name"));
                    label.SetBinding(Label.VisibilityProperty, new Binding("Visible") { Converter = new PromptValueToVisibilityConverter() });
                    label.SetBinding(Label.ToolTipProperty, new Binding("HelpMessage"));
                    leftSP.Children.Add(label);

                    TextBox tb = new TextBox();
                    //tb.MouseDoubleClick += tb_MouseDoubleClick;
                    tb.AddHandler(UIElement.MouseEnterEvent, new RoutedEventHandler(tb_MouseLeftButtonDown), true);
                    tb.DataContext = prompt;
                    tb.SetBinding(TextBox.TextProperty, new Binding("PromptValue") { ValidatesOnExceptions = true, ValidatesOnDataErrors = true, NotifyOnValidationError = true });
                    tb.SetBinding(TextBox.VisibilityProperty, new Binding("Visible") { Converter = new PromptValueToVisibilityConverter() });
                    tb.SetBinding(TextBox.IsEnabledProperty, new Binding("IsEnabled"));
                    tb.SetBinding(TextBox.ToolTipProperty, new Binding("HelpMessage"));
                    leftSP.Children.Add(tb);

                    TextBlock error = new TextBlock();
                    error.Foreground = Brushes.Red;
                    error.DataContext = prompt;
                    error.SetBinding(TextBlock.TextProperty, new Binding("ErrorMessage"));
                    error.SetBinding(Label.VisibilityProperty, new Binding("ErrorMessage") { Converter = new PromptValueToVisibilityConverter() });
                    leftSP.Children.Add(error);
                }
                else if (prompt.ControlType == ControlType.CheckBox)
                {
                    CheckBox cb = new CheckBox();
                    cb.Foreground = getBrushById(prompt.ColorIndex);
                    cb.Margin = new Thickness(0, 3, 0, 3);
                    cb.DataContext = prompt;
                    cb.AddHandler(UIElement.MouseEnterEvent, new RoutedEventHandler(tb_MouseLeftButtonDown), true);
                    cb.SetBinding(CheckBox.IsCheckedProperty, new Binding("PromptValue") { Converter = new PromptValueToCheckedConverter() });
                    cb.SetBinding(CheckBox.ContentProperty, new Binding("Name"));
                    cb.SetBinding(CheckBox.VisibilityProperty, new Binding("Visible") { Converter = new PromptValueToVisibilityConverter() });
                    cb.SetBinding(CheckBox.ToolTipProperty, new Binding("HelpMessage"));
                    rightSP.Children.Add(cb);
                }
                else if (prompt.ControlType == ControlType.ComboBox)
                {
                    Label label = new Label();
                    label.Foreground = getBrushById(prompt.ColorIndex);
                    label.DataContext = prompt;
                    label.SetBinding(Label.ContentProperty, new Binding("Name"));
                    label.SetBinding(Label.VisibilityProperty, new Binding("Visible") { Converter = new PromptValueToVisibilityConverter() });
                    label.SetBinding(Label.ToolTipProperty, new Binding("HelpMessage"));
                    leftSP.Children.Add(label);

                    ComboBox combo = new ComboBox();
                    combo.Foreground = getBrushById(prompt.ColorIndex);
                    combo.DataContext = prompt;
                    combo.AddHandler(UIElement.MouseEnterEvent, new RoutedEventHandler(tb_MouseLeftButtonDown), true);
                    combo.SetBinding(ComboBox.SelectedValueProperty, new Binding("PromptValue") { Converter = new PromptValueToIntConverter() });
                    combo.SetBinding(ComboBox.VisibilityProperty, new Binding("Visible") { Converter = new PromptValueToVisibilityConverter() });
                    combo.SetBinding(ComboBox.ToolTipProperty, new Binding("HelpMessage"));
                    combo.ItemsSource = prompt.ComboBoxItemsString.Split('|');

                    //DataTemplate dt = new DataTemplate();
                    //dt.DataType = typeof(string);
                    //FrameworkElementFactory spFactory = new FrameworkElementFactory(typeof(TextBlock));

                    leftSP.Children.Add(combo);
                }
                else if (prompt.ControlType == ControlType.RadioButton)
                {
                    GroupBox gb = new GroupBox();
                    gb.Foreground = getBrushById(prompt.ColorIndex);
                    gb.DataContext = prompt;
                    gb.SetBinding(GroupBox.HeaderProperty, new Binding("Tip"));
                    gb.SetBinding(GroupBox.VisibilityProperty, new Binding("Visible") { Converter = new PromptValueToVisibilityConverter() });
                    middleSP.Children.Add(gb);

                    StackPanel spinsder = new StackPanel();
                    gb.Content = spinsder;

                    RadioButton rb = new RadioButton();
                    rb.Foreground = getBrushById(prompt.ColorIndex);
                    rb.Margin = new Thickness(0, 5, 0, 5);
                    rb.DataContext = prompt;
                    rb.AddHandler(UIElement.MouseEnterEvent, new RoutedEventHandler(tb_MouseLeftButtonDown), true);
                    rb.SetBinding(RadioButton.ContentProperty, new Binding("Name"));
                    rb.SetBinding(RadioButton.IsCheckedProperty, new Binding("PromptValue") { Converter = new PromptValueToCheckedConverter() });
                    rb.SetBinding(RadioButton.VisibilityProperty, new Binding("Visible") { Converter = new PromptValueToVisibilityConverter() });
                    spinsder.Children.Add(rb);

                    for (int x = i + 1; x < prompts.Count; x++)
                    {
                        var nextPrompt = prompts[x];
                        if (nextPrompt.ControlType != ControlType.OtherRadioButton)
                        {
                            break;
                        }

                        RadioButton rb2 = new RadioButton();
                        rb2.Foreground = getBrushById(prompt.ColorIndex);
                        rb2.Margin = new Thickness(0, 5, 0, 5);
                        rb2.DataContext = nextPrompt;
                        rb2.AddHandler(UIElement.MouseEnterEvent, new RoutedEventHandler(tb_MouseLeftButtonDown), true);
                        rb2.SetBinding(RadioButton.ContentProperty, new Binding("Name"));
                        rb2.SetBinding(RadioButton.IsCheckedProperty, new Binding("PromptValue") { Converter = new PromptValueToCheckedConverter() });
                        rb2.SetBinding(RadioButton.VisibilityProperty, new Binding("Visible") { Converter = new PromptValueToVisibilityConverter() });
                        spinsder.Children.Add(rb2);

                    }
                }
            }
        }
        private void CreateAndBindDynamicProperties(ControlSystemComponent controlSystemComponent, List<String> pidDocuments, List<String> specDocuments)
        {
            int rowCount = 5;

            var controlSystemComponentProperies = controlSystemComponent.ControlSystemComponentType.ControlSystemComponentTypeProperties.ToList();

            CmsWebServiceClient cmsWebServiceClient = new CmsWebServiceClient(Utils.WcfBinding, Utils.WcfEndPoint);
            cmsWebServiceClient.GetAllPropertyListsCompleted += (s, e) =>
            {
                List<ComponentTypeGroup> addedGroups = new List<ComponentTypeGroup>();

                foreach (var controlSystemComponentProperty in controlSystemComponentProperies.OrderBy(x => x.Ordinal).ThenBy(x => x.GroupOrdinal))
                {
                    //Skip Properties that are not visible
                    if (controlSystemComponentProperty.ControlSystemPropertyId.HasValue && !controlSystemComponentProperty.ControlSystemProperty.IsVisible) continue;

                    //Render Group
                    if (controlSystemComponentProperty.ComponentTypeGroupId.HasValue && !addedGroups.Contains(controlSystemComponentProperty.ComponentTypeGroup))
                    {
                        Label groupLabel = new Label
                        {
                            Content = controlSystemComponentProperty.ComponentTypeGroup.Name,
                            VerticalAlignment = VerticalAlignment.Center,
                            Margin = new Thickness(1),
                            FontWeight = FontWeights.Bold
                        };

                        PropertiesGrid.Children.Add(groupLabel);
                        Grid.SetRow(groupLabel, rowCount);
                        Grid.SetColumn(groupLabel, 0);
                        PropertiesGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(26) });
                        rowCount++;
                        addedGroups.Add(controlSystemComponentProperty.ComponentTypeGroup);

                        //This is a empty Group so don't need to render a Property
                        if (!controlSystemComponentProperty.ControlSystemPropertyId.HasValue) continue;
                    }

                    Label label = new Label();

                    Binding labelBinding = new Binding("Name")
                    {
                        Mode = BindingMode.OneTime,
                        Source = controlSystemComponentProperty.ControlSystemProperty
                    };

                    label.SetBinding(ContentControl.ContentProperty, labelBinding);
                    label.VerticalAlignment = VerticalAlignment.Center;
                    label.Margin = new Thickness(1);

                    PropertiesGrid.Children.Add(label);
                    Grid.SetRow(label, rowCount);
                    Grid.SetColumn(label, 0);

                    var propertyValue = GetPropertyValue(controlSystemComponent, controlSystemComponentProperty);

                    FrameworkElement element = Utils.BindElement(controlSystemComponentProperty.ControlSystemProperty, propertyValue,
                        e.Result, ComponentPropertyWrapViewModels, ControlChanged, pidDocuments, specDocuments);

                    PropertiesGrid.Children.Add(element);
                    Grid.SetRow((FrameworkElement)element, rowCount);
                    Grid.SetColumn((FrameworkElement)element, 1);

                    PropertiesGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(element.Height + 2) });

                    rowCount++;
                }

                LastInspectedTextBox.ResetOriginalValue();
                LastInspectedTextBox.ControlChanged += ControlChanged;

                NextInspectionTextBox.ResetOriginalValue();
                NextInspectionTextBox.ControlChanged += ControlChanged;
            };
            cmsWebServiceClient.GetAllPropertyListsAsync();
        }
示例#28
0
        public Label buildMeta()
        {
            Label label = null;
            if (this.CalculatedDistance > 50)
            {
                label = new Label();
                label.Content = this.name;

                Binding xBinding = new Binding("MetaLabelX");
                xBinding.Source = this;
                label.SetBinding(Canvas.LeftProperty, xBinding);

                Binding yBinding = new Binding("MetaLabelY");
                yBinding.Source = this;
                label.SetBinding(Canvas.TopProperty, yBinding);
            }
            return label;
        }
示例#29
0
        private void CreateDuplexCaptureOperationInfo(Grid grid, FALibrary.Part.FAPart part, string name, Action<object> OnAction, Action<object> OffAction, Action<object> StopAction, Func<bool> IsOn, Func<bool> IsOff, string onName, string offName)
        {
            GeneralOperationInfo obj = new GeneralOperationInfo();
            RowDefinition rd = new RowDefinition();
            rd.Height = new GridLength(100, GridUnitType.Auto);
            rd.MinHeight = 100;
            SetOperationGridColor(grid, grid.RowDefinitions.Count - 1);

            grid.RowDefinitions.Add(rd);
            obj.Name = name;
            obj.On = OnAction;
            obj.Off = OffAction;
            obj.StatusOnName = onName;
            obj.StatusOffName = offName;
            obj.IsOn = IsOn;
            obj.IsOff = IsOff;

            Label labelName = new Label();
            labelName.Height = Double.NaN;
            labelName.Width = Double.NaN;
            labelName.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Stretch;
            labelName.VerticalContentAlignment = System.Windows.VerticalAlignment.Stretch;
            labelName.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Center;
            labelName.VerticalContentAlignment = System.Windows.VerticalAlignment.Center;
            labelName.Margin = new Thickness(2);
            Binding bd = new Binding("Name");
            bd.Source = obj;
            bd.Mode = BindingMode.OneWay;
            labelName.SetBinding(Label.ContentProperty, bd);

            Label labelStatus = new Label();
            labelStatus.Height = Double.NaN;
            labelStatus.Width = Double.NaN;
            labelStatus.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Stretch;
            labelStatus.VerticalContentAlignment = System.Windows.VerticalAlignment.Stretch;
            labelStatus.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Center;
            labelStatus.VerticalContentAlignment = System.Windows.VerticalAlignment.Center;
            labelStatus.Margin = new Thickness(2);
            bd = new Binding("Status");
            bd.Source = obj;
            bd.Mode = BindingMode.OneWay;
            labelStatus.SetBinding(Label.ContentProperty, bd);

            Grid gridInputIOList = CreatePartInputIOList(part);
            Grid gridOutputIOList = CreatePartOutputIOList(part);

            Button buttonOn = new Button();
            buttonOn.Height = Double.NaN;
            buttonOn.Width = Double.NaN;
            buttonOn.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Stretch;
            buttonOn.VerticalContentAlignment = System.Windows.VerticalAlignment.Stretch;
            buttonOn.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Center;
            buttonOn.VerticalContentAlignment = System.Windows.VerticalAlignment.Center;
            buttonOn.Content = onName;
            buttonOn.Margin = new Thickness(2);
            buttonOn.PreviewMouseDown +=
                delegate(object sender, MouseButtonEventArgs e)
                {
                    OnAction(sender);
                };

            buttonOn.PreviewMouseUp +=
                delegate(object sender, MouseButtonEventArgs e)
                {
                    StopAction(sender);
                };

            Button buttonOff = new Button();
            buttonOff.Height = Double.NaN;
            buttonOff.Width = Double.NaN;
            buttonOff.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Stretch;
            buttonOff.VerticalContentAlignment = System.Windows.VerticalAlignment.Stretch;
            buttonOff.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Center;
            buttonOff.VerticalContentAlignment = System.Windows.VerticalAlignment.Center;
            buttonOff.Content = offName;
            buttonOff.Margin = new Thickness(2);
            buttonOff.PreviewMouseDown +=
                delegate(object sender, MouseButtonEventArgs e)
                {
                    OffAction(sender);
                };

            buttonOff.PreviewMouseUp +=
                delegate(object sender, MouseButtonEventArgs e)
                {
                    StopAction(sender);
                };

            ColumnDefinition col1 = new ColumnDefinition();
            col1.Width = new GridLength(100, GridUnitType.Star);
            ColumnDefinition col2 = new ColumnDefinition();
            col2.Width = new GridLength(100, GridUnitType.Star);

            Grid buttonGrid = new Grid();
            buttonGrid.Width = double.NaN;
            buttonGrid.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
            buttonGrid.VerticalAlignment = System.Windows.VerticalAlignment.Stretch;
            buttonGrid.Height = double.NaN;
            buttonGrid.Margin = new Thickness(0);
            buttonGrid.ColumnDefinitions.Add(col1);
            buttonGrid.ColumnDefinitions.Add(col2);
            buttonGrid.Children.Add(buttonOn);
            buttonGrid.Children.Add(buttonOff);
            Grid.SetColumn(buttonOn, 0);
            Grid.SetColumn(buttonOff, 1);

            TextBox textBoxRepeat = new TextBox();
            textBoxRepeat.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
            textBoxRepeat.VerticalAlignment = System.Windows.VerticalAlignment.Stretch;
            textBoxRepeat.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Center;
            textBoxRepeat.VerticalContentAlignment = System.Windows.VerticalAlignment.Center;
            textBoxRepeat.Height = Double.NaN;
            textBoxRepeat.Width = Double.NaN;
            textBoxRepeat.Margin = new Thickness(2);
            bd = new Binding("RepeatTime");
            bd.Source = obj;
            bd.Mode = BindingMode.TwoWay;
            textBoxRepeat.SetBinding(TextBox.TextProperty, bd);

            CheckBox checkBoxRepeatUse = new CheckBox();
            checkBoxRepeatUse.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
            checkBoxRepeatUse.VerticalAlignment = System.Windows.VerticalAlignment.Center;
            bd = new Binding("RepeatUse");
            bd.Source = obj;
            bd.Mode = BindingMode.TwoWay;
            checkBoxRepeatUse.SetBinding(CheckBox.IsCheckedProperty, bd);

            int rowCount = grid.RowDefinitions.Count - 1;
            grid.Children.Add(labelName);
            Grid.SetColumn(labelName, 0);
            Grid.SetRow(labelName, rowCount);

            grid.Children.Add(labelStatus);
            Grid.SetColumn(labelStatus, 1);
            Grid.SetRow(labelStatus, rowCount);

            grid.Children.Add(buttonGrid);
            Grid.SetColumn(buttonGrid, 2);
            Grid.SetRow(buttonGrid, rowCount);

            grid.Children.Add(gridInputIOList);
            Grid.SetColumn(gridInputIOList, 3);
            Grid.SetRow(gridInputIOList, rowCount);

            grid.Children.Add(gridOutputIOList);
            Grid.SetColumn(gridOutputIOList, 4);
            Grid.SetRow(gridOutputIOList, rowCount);

            grid.Children.Add(textBoxRepeat);
            Grid.SetColumn(textBoxRepeat, 5);
            Grid.SetRow(textBoxRepeat, rowCount);

            grid.Children.Add(checkBoxRepeatUse);
            Grid.SetColumn(checkBoxRepeatUse, 6);
            Grid.SetRow(checkBoxRepeatUse, rowCount);

            _ioOperationList.Add(obj);

            bd = new Binding("IsEnabledOutputIODirectControl");
            bd.Source = this;
            bd.Mode = BindingMode.OneWay;
            gridOutputIOList.SetBinding(ListView.IsEnabledProperty, bd);
        }
示例#30
0
 private void CreateLabels()
 {
     // Create stage level label
     Label lblStage = new Label();
     lblStage.FontSize = 20;
     lblStage.Foreground = Brushes.White;
     lblStage.FontWeight = FontWeights.Bold;
     Label lblCurrStage = new Label();
     lblCurrStage.Content = String.Format("Stage ");
     lblCurrStage.FontSize = 20;
     lblCurrStage.Foreground = Brushes.White;
     lblCurrStage.FontWeight = FontWeights.Bold;
     // Create shots left label
     Label lblShots = new Label();
     lblShots.FontSize = 20;
     lblShots.Foreground = Brushes.White;
     lblShots.FontWeight = FontWeights.Bold;
     Label lblShotsLeft = new Label();
     lblShotsLeft.Content = String.Format("Shots left:");
     lblShotsLeft.FontSize = 20;
     lblShotsLeft.Foreground = Brushes.White;
     lblShotsLeft.FontWeight = FontWeights.Bold;
     // Create binding
     Binding binding = new Binding("ShotsLeft");
     binding.Source = game;
     lblShots.SetBinding(Label.ContentProperty, binding);
     // Create binding stage
     Binding stage = new Binding("Stage");
     stage.Source = game;
     lblStage.SetBinding(Label.ContentProperty, stage);
     // Add elements to canvas
     this.Children.Add(lblCurrStage);
     this.Children.Add(lblStage);
     this.Children.Add(lblShotsLeft);
     this.Children.Add(lblShots);
     Canvas.SetLeft(lblCurrStage, 10);
     Canvas.SetTop(lblCurrStage, 10);
     Canvas.SetLeft(lblStage, 70);
     Canvas.SetTop(lblStage, 10);
     Canvas.SetRight(lblShotsLeft, 80);
     Canvas.SetTop(lblShotsLeft, 10);
     Canvas.SetRight(lblShots, 50);
     Canvas.SetTop(lblShots, 10);
 }
        private static Label CreateLabel(object obj, string propertyName)
        {
            Label label = new Label();
            label.Padding = new System.Windows.Thickness(0);
            Binding bd = new Binding(propertyName);
            bd.Source = obj;
            bd.Mode = BindingMode.OneWay;
            label.SetBinding(Label.ContentProperty, bd);

            return label;
        }
        protected void HandleDoubleClick(object sender, MouseButtonEventArgs e)
        {
            if (iTabCount == 16)
            {
            MessageBox.Show(string.Format("Only 16 tabs may be open at a time",
                MessageBoxButton.OK, MessageBoxImage.Error));
            return;
            }

            ListViewItem lvi = sender as ListViewItem;
            var content = lvi.Content as AccountResultsViewModel;
            TabControl tabCtrl = FindParent(lvi, typeof (TabControl)) as TabControl;
            CloseableTabItem userItem = new CloseableTabItem();

            userItem.Header = content.AccountName;

            // get accountnum so we can keep the listboxes and listviews straight
            int accountnum = GetAcctNum((string)userItem.Header);
            AccountResultsViewModel ar = ViewModel.AccountResultsList[accountnum];

            try
            {

            if (urListView[accountnum] != null)
            {
                for (int i = 0; i < tabCtrl.Items.Count; i++)
                {
                    TabItem item = (TabItem)tabCtrl.Items[i];

                    if (item.Header.ToString() == content.AccountName)
                    {
                        tabCtrl.SelectedIndex = i;
                        break;
                    }
                }
                return;
            }
            iTabCount++;

            Grid urGrid = new Grid();

            // set up the grid's rows
            RowDefinition rowDef1 = new RowDefinition();
            RowDefinition rowDef2 = new RowDefinition();
            RowDefinition rowDef3 = new RowDefinition();
            RowDefinition rowDef4 = new RowDefinition();

            rowDef1.MaxHeight = 145;
            rowDef2.MaxHeight = 145;
            rowDef3.Height = GridLength.Auto;
            rowDef4.Height = GridLength.Auto;
            urGrid.Height = 330;                    // so we'll get  Vertical scrollviewer
            urGrid.RowDefinitions.Add(rowDef1);
            urGrid.RowDefinitions.Add(rowDef2);
            urGrid.RowDefinitions.Add(rowDef3);
            urGrid.RowDefinitions.Add(rowDef4);
            //

            // Set up the ListView
            urListView[accountnum] = new ListView();
            urListView[accountnum].FontSize = 11;
            urListView[accountnum].SetValue(Grid.RowProperty, 0);
            urListView[accountnum].Margin = new Thickness(5);
            urListView[accountnum].Name = "lstUserResults";

            GridView urGridView = new GridView();
            GridViewColumn gvc1 = new GridViewColumn();

            // set up columns widths so we won't get a horizontal scrollbar
            GridViewColumnHeader gvc1H = new GridViewColumnHeader();

            gvc1H.FontSize = 11;
            gvc1H.Width = 195;
            gvc1H.Content = " Folder";
            gvc1H.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Left;
            gvc1.DisplayMemberBinding = new Binding("FolderName");
            gvc1.Header = gvc1H;
            urGridView.Columns.Add(gvc1);

            GridViewColumn gvc2 = new GridViewColumn();
            GridViewColumnHeader gvc2H = new GridViewColumnHeader();

            gvc2H.FontSize = 11;
            gvc2H.Width = 130;
            gvc2H.Content = " Type";
            gvc2H.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Left;
            gvc2.DisplayMemberBinding = new Binding("TypeName");
            gvc2.Header = gvc2H;
            urGridView.Columns.Add(gvc2);

            GridViewColumn gvc3 = new GridViewColumn();
            GridViewColumnHeader gvc3H = new GridViewColumnHeader();

            gvc3H.FontSize = 11;
            gvc3H.Width = 120;
            gvc3H.Content = " Progress";
            gvc3H.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Left;
            gvc3.DisplayMemberBinding = new Binding("UserProgressMsg");
            gvc3.Header = gvc3H;
            urGridView.Columns.Add(gvc3);

            urListView[accountnum].View = urGridView;

            urGrid.Children.Add(urListView[accountnum]);
            //

            // now create Listbox for errors
            lbErrors[accountnum] = new ListBox();
            lbErrors[accountnum].FontSize = 11;
            lbErrors[accountnum].SetValue(Grid.RowProperty, 1);
            lbErrors[accountnum].Margin = new Thickness(5, 5, 5, 5);
            lbErrors[accountnum].MinHeight = 120;
            lbErrors[accountnum].MaxHeight = 120;
            lbErrors[accountnum].MinWidth = 450;
            lbErrors[accountnum].HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
            lbErrors[accountnum].VerticalAlignment = System.Windows.VerticalAlignment.Top;
            urGrid.Children.Add(lbErrors[accountnum]);
            //

            // Now set up the progressbar and message status in another grid
            userProgressBar = new ProgressBar();
            userProgressBar.SetValue(Grid.RowProperty, 2);
            userProgressBar.SetValue(Grid.ColumnProperty, 0);
            userProgressBar.SetValue(Grid.ColumnSpanProperty, 2);
            userProgressBar.IsIndeterminate = false;
            userProgressBar.Orientation = Orientation.Horizontal;
            userProgressBar.Width = 412;
            userProgressBar.Height = 18;
            userProgressBar.Margin = new Thickness(36, 0, 0, 0);
            userProgressBar.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;

            // FBS bug 74960 -- 6/1/12
            ToolTip tooltip = new ToolTip();
            Binding tbBinding = new Binding("GlobalAcctProgressMsg");
            tbBinding.Source = ar;
            tooltip.SetBinding(ContentControl.ContentProperty, tbBinding);
            ToolTipService.SetToolTip(userProgressBar, tooltip);

            // Change the background and foreground colors
            SolidColorBrush scbBack = new SolidColorBrush();
            scbBack.Color = Color.FromArgb(255, 218, 227, 235);   // #FFDAE3EB
            userProgressBar.Background = scbBack;
            userProgressBar.Foreground = Brushes.DodgerBlue;
            ///

            Binding upbBinding = new Binding("PBValue");
            upbBinding.Source = ar;
            userProgressBar.SetBinding(ProgressBar.ValueProperty, upbBinding);
            if (!ViewModel.GetScheduleViewModel().IsPreviewMode())
            {
                urGrid.Children.Add(userProgressBar);
            }

            userStatusMsg = new Label();
            userStatusMsg.Visibility = System.Windows.Visibility.Visible;
            userStatusMsg.SetValue(Grid.RowProperty, 3);
            userStatusMsg.SetValue(Grid.ColumnProperty, 0);
            userStatusMsg.SetValue(Grid.ColumnSpanProperty, 2);
            userStatusMsg.MinWidth = 300;
            userStatusMsg.Margin = new Thickness(30, 0, 0, 0);
            userStatusMsg.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
            userStatusMsg.FontStyle = FontStyles.Italic;
            Binding usmBinding = new Binding("PBMsgValue");
            usmBinding.Source = ar;
            userStatusMsg.SetBinding(Label.ContentProperty, usmBinding);
            urGrid.Children.Add(userStatusMsg);
            //////////////

            userItem.Content = urGrid;

            tabCtrl.Items.Add(userItem);
            userItem.IsSelected = true;

            Binding binding = new Binding();

            // wrap in NotifyCollectionChangedWrapper so we can update collection from a different thread
            binding.Source = new NotifyCollectionChangedWrapper<UserResultsViewModel>(ar.UserResultsList);
            //

            BindingOperations.SetBinding(urListView[accountnum], ListView.ItemsSourceProperty,
                binding);
            }
            catch (Exception excep)
            {
            Log.err("error when get usermigration information " + excep.Message);

            }
        }
示例#33
0
        public void SetContent(string label, bool useMnemonic, ImageDescription image, ContentPosition position)
        {
            var accessText = new SWC.AccessText ();
            accessText.Text = label;
            if (image.IsNull)
                if (useMnemonic)
                    Button.Content = accessText;
                else
                    Button.Content = accessText.Text.Replace ("_", "__");
            else {
                SWC.DockPanel grid = new SWC.DockPanel ();

                var imageCtrl = new ImageBox (Context);
                imageCtrl.ImageSource = image;

                SWC.DockPanel.SetDock (imageCtrl, DataConverter.ToWpfDock (position));
                grid.Children.Add (imageCtrl);

                if (!string.IsNullOrEmpty (label)) {
                    SWC.Label labelCtrl = new SWC.Label ();
                    if (useMnemonic)
                        labelCtrl.Content = accessText;
                    else
                        labelCtrl.Content = label;
                    labelCtrl.SetBinding (SWC.Label.ForegroundProperty, new Binding ("Foreground") { Source = Button });
                    grid.Children.Add (labelCtrl);
                }
                Button.Content = grid;
            }
            Button.InvalidateMeasure ();
        }
        ////initalize start screen//
        #region
        private void Initalize()
        {
            ////start button//
            startbutton         = new Button();
            startbutton.Content = "Start";
            LinearGradientBrush lg = new LinearGradientBrush((Color)ColorConverter.ConvertFromString("#FFFFFF"), (Color)ColorConverter.ConvertFromString("#FF252424"), new Point(0.5, 0), new Point(0.5, 1));

            startbutton.Background          = lg;
            startbutton.Width               = 100;
            startbutton.Height              = 40;
            startbutton.HorizontalAlignment = HorizontalAlignment.Center;
            startbutton.Margin              = new Thickness(-800, 500, 0, 0);
            startbutton.Click              += Startbutton_Click;
            this.start.Children.Add(startbutton);
            ////exit button//
            exitbutton                     = new Button();
            exitbutton.Content             = "Exit";
            exitbutton.Background          = lg;
            exitbutton.Width               = 100;
            exitbutton.Height              = 40;
            exitbutton.HorizontalAlignment = HorizontalAlignment.Center;
            exitbutton.Margin              = new Thickness(-450, 500, 0, 0);
            exitbutton.Click              += Exitbutton_Click;
            this.start.Children.Add(exitbutton);
            ////for character image//
            rect        = new Rectangle();
            rect.Width  = 220;
            rect.Height = 300;
            ImageBrush ib = new ImageBrush(new BitmapImage(new Uri(@"images\Mage.PNG", UriKind.Relative)));

            rect.Fill = ib;
            rect.HorizontalAlignment = HorizontalAlignment.Center;
            rect.Margin = new Thickness(0, 10, 0, 0);
            this.start.Children.Add(rect);
            ////if new character need because this is a new account//
            if (character.Name == null)
            {
                ////for write//
                tb                     = new TextBox();
                tb.Text                = null;
                tb.Width               = rect.Width;
                tb.Background          = null;
                tb.Foreground          = Brushes.White;
                tb.Height              = 23;
                tb.HorizontalAlignment = HorizontalAlignment.Center;
                tb.Margin              = new Thickness(0, 360, 0, 0);
                tb.PreviewKeyDown     += Tb_PreviewKeyDown;
                start.Children.Add(tb);
                ////info//
                nevmegadas                     = new System.Windows.Controls.Label();
                nevmegadas.Content             = "Give name to the Character";
                nevmegadas.Foreground          = Brushes.White;
                nevmegadas.HorizontalAlignment = HorizontalAlignment.Center;
                nevmegadas.Margin              = new Thickness(0, 600, 0, 0);
                start.Children.Add(nevmegadas);
                ////name change//
                ok                     = new Button();
                ok.Content             = "ok";
                ok.Background          = lg;
                ok.Width               = 20;
                ok.Height              = 23;
                ok.HorizontalAlignment = HorizontalAlignment.Center;
                ok.Margin              = new Thickness(250, 360, 0, 0);
                ok.Click              += Ok_Click;
                start.Children.Add(ok);
            }
            ////character name//
            System.Windows.Controls.Label nev = new System.Windows.Controls.Label();
            nev.SetBinding(System.Windows.Controls.Label.ContentProperty, new Binding("Name")
            {
                Source = character
            });
            nev.HorizontalAlignment = HorizontalAlignment.Center;
            nev.Margin     = new Thickness(0, 80, 0, 0);
            nev.FontSize   = 50;
            nev.Foreground = Brushes.White;
            start.Children.Add(nev);
            ////chose label//
            chose                     = new System.Windows.Controls.Label();
            chose.Content             = "Choose a map to START!";
            chose.HorizontalAlignment = HorizontalAlignment.Center;
            chose.Margin              = new Thickness(-20, 620, 0, 0);
            chose.FontSize            = 20;
            chose.Foreground          = Brushes.Red;
            start.Children.Add(chose);
            ////character level//
            System.Windows.Controls.Label level = new System.Windows.Controls.Label();
            level.SetBinding(System.Windows.Controls.Label.ContentProperty, new Binding("LVL")
            {
                Source = character
            });
            level.HorizontalAlignment = HorizontalAlignment.Center;
            level.Margin     = new Thickness(0, 180, 0, 0);
            level.FontSize   = 50;
            level.Foreground = Brushes.White;
            start.Children.Add(level);
            ////firstmap optional//
            firstmaplabel        = new System.Windows.Controls.Label();
            firstmaplabel.Width  = 300;
            firstmaplabel.Height = 150;
            firstmaplabel.HorizontalAlignment = HorizontalAlignment.Center;
            firstmaplabel.Margin      = new Thickness(0, -600, 600, 0);
            firstmaplabel.BorderBrush = null;
            firstmaplabel.Content     = "Naratos Map";
            firstmaplabel.Foreground  = Brushes.Gold;
            firstmaplabel.FontSize    = 40;
            firstmaplabel.HorizontalContentAlignment = HorizontalAlignment.Center;
            firstmaplabel.VerticalContentAlignment   = VerticalAlignment.Center;
            firstmaplabel.Background      = new ImageBrush(new BitmapImage(new Uri(@"images\Naratos.PNG", UriKind.Relative)));
            firstmaplabel.BorderThickness = new Thickness(2, 2, 2, 2);
            start.Children.Add(firstmaplabel);
            firstmaplabel.MouseDoubleClick += Firstmaplabel_MouseDoubleClick;
            ////secmap optional//
            secmaplabel        = new System.Windows.Controls.Label();
            secmaplabel.Width  = 300;
            secmaplabel.Height = 150;
            secmaplabel.HorizontalAlignment = HorizontalAlignment.Center;
            secmaplabel.Margin      = new Thickness(0, -200, 600, 0);
            secmaplabel.BorderBrush = null;
            secmaplabel.Content     = "Mariel Map";
            secmaplabel.Foreground  = Brushes.Gold;
            secmaplabel.FontSize    = 40;
            secmaplabel.HorizontalContentAlignment = HorizontalAlignment.Center;
            secmaplabel.VerticalContentAlignment   = VerticalAlignment.Center;
            secmaplabel.Background      = new ImageBrush(new BitmapImage(new Uri(@"images\Mariel.PNG", UriKind.Relative)));
            secmaplabel.BorderThickness = new Thickness(2, 2, 2, 2);
            start.Children.Add(secmaplabel);
            secmaplabel.MouseDoubleClick += Secmaplabel_MouseDoubleClick;
            ////thirdmap optional//
            thirdmaplabel        = new System.Windows.Controls.Label();
            thirdmaplabel.Width  = 300;
            thirdmaplabel.Height = 150;
            thirdmaplabel.HorizontalAlignment = HorizontalAlignment.Center;
            thirdmaplabel.Margin                     = new Thickness(0, 200, 600, 0);
            thirdmaplabel.BorderBrush                = null;
            thirdmaplabel.BorderThickness            = new Thickness(2, 2, 2, 2);
            thirdmaplabel.Content                    = "DeathKing Map";
            thirdmaplabel.Foreground                 = Brushes.Gold;
            thirdmaplabel.FontSize                   = 40;
            thirdmaplabel.HorizontalContentAlignment = HorizontalAlignment.Center;
            thirdmaplabel.VerticalContentAlignment   = VerticalAlignment.Center;
            thirdmaplabel.Background                 = new ImageBrush(new BitmapImage(new Uri(@"images\Deathking.PNG", UriKind.Relative)));
            start.Children.Add(thirdmaplabel);
            thirdmaplabel.MouseDoubleClick += Thirdmaplabel_MouseDoubleClick;
            ////previus game stats//
            System.Windows.Controls.Label prevstats = new System.Windows.Controls.Label();
            prevstats.Content             = "Previus Game Stats";
            prevstats.HorizontalAlignment = HorizontalAlignment.Center;
            prevstats.Margin      = new Thickness(600, 200, 0, 0);
            prevstats.BorderBrush = null;
            prevstats.Foreground  = Brushes.Turquoise;
            prevstats.FontSize    = 25;
            start.Children.Add(prevstats);
            ////killed monsters//
            System.Windows.Controls.Label killmons = new System.Windows.Controls.Label();
            killmons.Content             = "Killed Monsters:";
            killmons.HorizontalAlignment = HorizontalAlignment.Center;
            killmons.Margin      = new Thickness(390, 250, 0, 0);
            killmons.BorderBrush = null;
            killmons.Foreground  = Brushes.White;
            killmons.FontSize    = 15;
            start.Children.Add(killmons);
            System.Windows.Controls.Label killmonsnumb = new System.Windows.Controls.Label();
            killmonsnumb.SetBinding(System.Windows.Controls.Label.ContentProperty, new Binding("Killedmons")
            {
                Source = main.Vml.User.Chars
            });
            killmonsnumb.HorizontalAlignment = HorizontalAlignment.Center;
            killmonsnumb.Margin      = new Thickness(850, 250, 0, 0);
            killmonsnumb.BorderBrush = null;
            killmonsnumb.Foreground  = Brushes.Gold;
            killmonsnumb.FontSize    = 15;
            start.Children.Add(killmonsnumb);
            ////Total Damage dealt to monsters//
            System.Windows.Controls.Label damtomons = new System.Windows.Controls.Label();
            damtomons.Content             = "Total Damage Dealt to Monsters:";
            damtomons.HorizontalAlignment = HorizontalAlignment.Center;
            damtomons.Margin      = new Thickness(500, 350, 0, 0);
            damtomons.BorderBrush = null;
            damtomons.Foreground  = Brushes.White;
            damtomons.FontSize    = 15;
            start.Children.Add(damtomons);
            System.Windows.Controls.Label damtomonsnumb = new System.Windows.Controls.Label();
            damtomonsnumb.SetBinding(System.Windows.Controls.Label.ContentProperty, new Binding("Damagedealt")
            {
                Source = main.Vml.User.Chars
            });
            damtomonsnumb.HorizontalAlignment = HorizontalAlignment.Center;
            damtomonsnumb.Margin      = new Thickness(850, 350, 0, 0);
            damtomonsnumb.BorderBrush = null;
            damtomonsnumb.Foreground  = Brushes.Goldenrod;
            damtomonsnumb.FontSize    = 15;
            start.Children.Add(damtomonsnumb);
            ////total damage taken from monsters//
            System.Windows.Controls.Label damfrommons = new System.Windows.Controls.Label();
            damfrommons.Content             = "Total Damage Taken from Monsters:";
            damfrommons.HorizontalAlignment = HorizontalAlignment.Center;
            damfrommons.Margin      = new Thickness(530, 450, 0, 0);
            damfrommons.BorderBrush = null;
            damfrommons.Foreground  = Brushes.White;
            damfrommons.FontSize    = 15;
            start.Children.Add(damfrommons);
            System.Windows.Controls.Label damfrommonsnumb = new System.Windows.Controls.Label();
            damfrommonsnumb.SetBinding(System.Windows.Controls.Label.ContentProperty, new Binding("Damagetaken")
            {
                Source = main.Vml.User.Chars
            });
            damfrommonsnumb.HorizontalAlignment = HorizontalAlignment.Center;
            damfrommonsnumb.Margin      = new Thickness(850, 450, 0, 0);
            damfrommonsnumb.BorderBrush = null;
            damfrommonsnumb.Foreground  = Brushes.Red;
            damfrommonsnumb.FontSize    = 15;
            start.Children.Add(damfrommonsnumb);
        }