public void FillList(Panel list, Action<AutoCompleteItem> selectWithClick, List<IRecyclable> recyclables)
 {
     foreach (var item in this.list)
     {
         item.CreateFrameworkElement(list, selectWithClick, recyclables, this);
     }
 }
Example #2
0
        public static LabeledRow AddLabeledRow(this Panel parent, TextBlock labelPart, UIElement contentPart, uint rowHeight = 0)
        {
            var row = CreateLabeledRow(labelPart, contentPart, rowHeight);

            parent.Children.Add(row);
            return(row);
        }
		private int GetInsertPosition(Panel panel)
		{
			if (placement == AxisPlacement.Bottom)
				return panel.Children.Count;
			else
				return 0;
		}
Example #4
0
        public pPointChart(string InstanceName)
        {
            Name = InstanceName;

            Element     = new DockPanel();
            ChartHost   = new WindowsFormsHost();
            ChartObject = new Chart();


            //Set Generic Chart Object & Properties
            ChartObject.AntiAliasing            = AntiAliasingStyles.All;
            ChartObject.TextAntiAliasingQuality = TextAntiAliasingQuality.High;

            ChartObject.Dock = DockStyle.Fill;

            ChartObject.BackColor = System.Drawing.Color.Transparent;

            //Set WPF Winform Chart
            ChartHost.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
            ChartHost.VerticalAlignment   = System.Windows.VerticalAlignment.Stretch;

            //Set Element Properties;
            Element.MinWidth  = 300;
            Element.MinHeight = 300;

            Element.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
            Element.VerticalAlignment   = System.Windows.VerticalAlignment.Stretch;

            Element.Name = Name;

            ChartHost.Child = ChartObject;
            Element.Children.Add(ChartHost);
        }
Example #5
0
 public void Detach()
 {
     if (this._panel == null)
         return;
     this._panel.LayoutUpdated -= new EventHandler(this.PanelLayoutUpdated);
     this._panel = (Panel)null;
 }
Example #6
0
        private void DrawTexture(Panel canvas)
        {
            if (_texture == 0)
            {
                return;
            }

            var bitmap = new BitmapImage();

            bitmap.BeginInit();
            bitmap.UriSource   = new Uri(string.Format(@"pack://application:,,,/Images/texture/{0}.png", _texture));
            bitmap.CacheOption = BitmapCacheOption.OnLoad;
            bitmap.EndInit();

            var image = new Image
            {
                Source  = bitmap,
                Width   = canvas.Width,
                Height  = canvas.Height,
                Stretch = Stretch.Fill
            };

            RenderOptions.SetBitmapScalingMode(image, BitmapScalingMode.HighQuality);

            canvas.Children.Add(image);
            Canvas.SetLeft(image, 0);
            Canvas.SetTop(image, 0);
        }
Example #7
0
 public RTCView(Panel startPanel)
 {
     InitializeComponent();
     StartPanel = startPanel;
     model = new RTCModel(txtUnitDate, txtCPUDate);
     messages.Add(model);
 }
        public void setgradient(Panel elm)
        {
            LinearGradientBrush myBrush = new LinearGradientBrush();

            Point startpoint = new Point();
            int angle = CommunConfig.getInstance().Angle;
            startpoint.X = System.Math.Cos(((double)angle / 180) * System.Math.PI)/2 + 0.5;
            startpoint.Y = System.Math.Sin(((double)angle / 180) * System.Math.PI)/2 + 0.5;

            angle -= 180;
            Point endpoint = new Point();
            endpoint.X = System.Math.Cos(((double)angle / 180) * System.Math.PI)/2 +0.5;
            endpoint.Y = System.Math.Sin(((double)angle / 180) * System.Math.PI)/2 +0.5;

            myBrush.StartPoint = startpoint;
            myBrush.EndPoint = endpoint;
            System.Windows.Media.Color c = new Color();
            System.Drawing.Color  drawingColor  = CommunConfig.getInstance().StartColor;
            c = System.Windows.Media.Color.FromRgb(drawingColor.R, drawingColor.G, drawingColor.B);
            myBrush.GradientStops.Add(new GradientStop(c, 1));

            drawingColor = CommunConfig.getInstance().EndColor;
            c = System.Windows.Media.Color.FromRgb(drawingColor.R, drawingColor.G, drawingColor.B);

            myBrush.GradientStops.Add(new GradientStop(c, 0));
            elm.Background = myBrush;
        }
Example #9
0
		public static bool FadeInBackground(Panel panel, Uri backgroundSourceUri, double opacity, 
			int msecs, Action completed = null)
		{
			if (backgroundSourceUri == null)
				return false;

			var brush = new ImageBrush();
			var image = new BitmapImage { UriSource = backgroundSourceUri };
			brush.Opacity = panel.Background != null ? panel.Background.Opacity : 0.0;
			brush.Stretch = Stretch.UniformToFill;
			brush.ImageSource = image;

			panel.Background = brush;
			brush.ImageOpened += delegate
			{
				var animation = new DoubleAnimation();
				animation.From = panel.Background != null ? panel.Background.Opacity : 0.0;
				animation.To = opacity;
				animation.Duration = new Duration(new TimeSpan(0, 0, 0, 0, msecs));

				var story = new Storyboard();
				story.Children.Add(animation);

				Storyboard.SetTarget(animation, brush);
				Storyboard.SetTargetProperty(animation, new PropertyPath("Opacity"));

				if (completed != null)
					story.Completed += delegate { completed(); };
				story.Begin();
			};
			return true; 
		}
        public void OnUpdate(Int64 lastMSec, Int64 curMSec, double scale, Panel container, NicoLabelListModel labels)
        {
            double w = container.ActualWidth;
            double h = container.ActualHeight;
            foreach (NicoComment comm in comments)
            {
                Int64 vposMSec = comm.VPos * 10;
                if (vposMSec >= lastMSec && vposMSec < curMSec)
                {
                    NicoLabel label = new NicoLabel();
            //                    label.Background = new SolidColorBrush(Color.FromArgb(0, 0, 0, 0));
                    // child of
                    container.Children.Add(label);

            //			        label->setAttribute(Qt::WA_TransparentForMouseEvents);
                    label.SetByNicoComment(comm);
                    if (_noShadow)
                    {
                        label.SetShadowDepth(0);
                    }
                    label.Birth(w, h, scale);

                    label.DoMove((int)(curMSec - vposMSec));

                    labels.checkCollision(label, scale, container);

                    labels.Add(label);
                }
            }
        }
Example #11
0
        public void PopulateContainer(Panel panel)
        {
            panel.Children.Clear();
            for (int i = 0; i < meshIcons.Count; i++)
            {
                var   icon  = meshIcons[i];
                Image image = new Image();
                image.Margin = new Thickness(4);
                image.Source = icon;
                RenderOptions.SetBitmapScalingMode(image, BitmapScalingMode.HighQuality);
                panel.Children.Add(image);
                image.Width  = 96;
                image.Height = 96;
                int i1 = i;

                String fileName1  = protoPathDir + fileNames[i1] + "\\template.asciiproto";
                MyData objectData = new MyData(fileName1, ids[i]);

                image.MouseDown += (sender, args) => {
                    DataObject data = new DataObject("templateFilename", objectData);
                    DragDrop.DoDragDrop(image, data, DragDropEffects.All);
                };
            }
            panel.SizeChanged -= panel_SizeChanged;
            panel.SizeChanged += panel_SizeChanged;
        }
Example #12
0
 public DocUITabbed(XmlNode xmlNode, XmlSchemaAnnotated xsdNode, Panel contentpanel, Panel overlaypanel, DynamicForm parentForm)
     : base(xmlNode, xsdNode, contentpanel, overlaypanel, parentForm)
 {
     this.Sideways = true;
     _tabControl = new TabControl();
     this.Control = _tabControl;
     _optlist = new List<AbstractDocUIComponent>();
     XmlSchemaElement schemaEl = xsdNode as XmlSchemaElement;
     if (schemaEl != null)
     {
         XmlSchemaSequence seq = XmlSchemaUtilities.tryGetSequence(schemaEl.ElementSchemaType);
         if (seq != null)
         {
             foreach (XmlSchemaElement el in seq.Items)
             {
                 TabItem ti = new TabItem();
                 ti.Header = XmlSchemaUtilities.tryGetDocumentation(el); ;
                 Grid newpanel = new Grid();
                 ColumnDefinition cdnew1 = new ColumnDefinition();
                 cdnew1.Width = new GridLength(1, GridUnitType.Auto);
                 ColumnDefinition cdnew2 = new ColumnDefinition();
                 newpanel.ColumnDefinitions.Add(cdnew1);
                 newpanel.ColumnDefinitions.Add(cdnew2);
                 Utilities.recursive(el, xmlNode.SelectSingleNode(el.Name), newpanel, overlaypanel, (comp) =>
                 {
                     _optlist.Add(comp);
                     comp.placeOption();
                 }, parentForm);
                 ti.Content = newpanel;
                 this._tabControl.Items.Add(ti);
             }
         }
     }
 }
Example #13
0
        /// <summary>
        /// Creates a new instance of MultiSelectOption
        /// </summary>
        /// <param name="xmlNode">The xmlNode that contains the data.</param>
        /// <param name="xsdNode">The corresponding xsdNode.</param>
        /// <param name="panel">The panel on which the option should be placed.</param>
        /// <param name="parentForm">The form of which this option is a part.</param>
        public DocUIMultiSelect(XmlNode xmlNode, XmlSchemaAnnotated xsdNode, Panel contentpanel, Panel overlaypanel, DynamicForm parentForm) :
            base(xmlNode, xsdNode, contentpanel, overlaypanel, parentForm)
        {
            XmlSchemaElement schemaEl = xsdNode as XmlSchemaElement;
            if (schemaEl != null)
            {
                XmlSchemaSequence seq = XmlSchemaUtilities.tryGetSequence(schemaEl.ElementSchemaType);
                if (seq != null && seq.Items.Count > 0)
                {
                    XmlSchemaElement el = seq.Items[0] as XmlSchemaElement;

                    IEnumerable<XmlSchemaEnumerationFacet> restrictions = XmlSchemaUtilities.tryGetEnumRestrictions(el.ElementSchemaType);
                    foreach (XmlSchemaEnumerationFacet e in restrictions)
                    {

                        AddOption(e.Value, FontWeights.Normal);
                    }
                }

                CheckBox all = AddOption("All", FontWeights.Bold);
                all.Checked += (s, e) => { SelectAll(); };
                all.Unchecked += (s, e) => { UnselectAll(); };

                _wrapPanel.Orientation = Orientation.Horizontal;
                Control = _wrapPanel;

                setup();
            }
        }
        //string[] Headers = { ResetOption.Header };
        //

        public ResetChannelView(Panel startPanel)
        {
            InitializeComponent();
            messages.Add(model);
            ResetOption.SetResetOption(new CheckBox[] { resetChannel1, resetChannel2, resetChannel3, resetChannel4 });
            StartPanel = startPanel;
        }
Example #15
0
        private void InitAppIcons()
        {
            for (var i = 0; i < 3; ++i)
            {
                var list = new List <KeyValuePair <AppObj, Label> >();
                for (var j = 0; j < 3; ++j)
                {
                    var label = new Label
                    {
                        Style                      = Resources["RoundLabel"] as Style,
                        FontSize                   = 16,
                        Foreground                 = Brushes.Black,
                        Margin                     = new Thickness(0),
                        VerticalAlignment          = VerticalAlignment.Bottom,
                        HorizontalAlignment        = HorizontalAlignment.Center,
                        BorderThickness            = new Thickness(2),
                        BorderBrush                = Brushes.DarkSlateGray,
                        HorizontalContentAlignment = HorizontalAlignment.Center,
                        VerticalContentAlignment   = VerticalAlignment.Center,
                        Visibility                 = Visibility.Hidden,
                        Background                 = new SolidColorBrush
                        {
                            Color   = Colors.SkyBlue,
                            Opacity = 0.5
                        }
                    };

                    var app = new AppObj
                    {
                        Height = 100,
                        Width  = 100,
                        Margin = new Thickness(0)
                    };

                    var border = new Border
                    {
                        Width        = 100,
                        Height       = 100,
                        CornerRadius = new CornerRadius(10),
                        Child        = new Grid
                        {
                            Children =
                            {
                                label,
                                app
                            }
                        }
                    };
                    border.MouseDown += MouseClickOnApp;

                    AppPanel.Children.Add(border);
                    Grid.SetColumn(border, j);
                    Grid.SetRow(border, i);
                    Panel.SetZIndex(label, 2);
                    Panel.SetZIndex(app, 1);
                    list.Add(new KeyValuePair <AppObj, Label>(app, label));
                }
                _appObjList.Add(list);
            }
        }
        /// <summary>
        ///   Adds inspectors for the components of the specified blueprint and its parents.
        /// </summary>
        /// <param name="viewModel">Blueprint to add component inspectors for.</param>
        /// <param name="panel">Panel to add inspectors to.</param>
        /// <param name="getPropertyValue">Callback to get current value for a property.</param>
        /// <param name="onValueChanged">Callback to invoke when a property value changed.</param>
        public void AddComponentInspectorsRecursively(
            BlueprintViewModel viewModel,
            Panel panel,
            GetPropertyValueDelegate getPropertyValue,
            InspectorControlValueChangedDelegate onValueChanged)
        {
            // Add inspectors for parent blueprints.
            if (viewModel.Parent != null)
            {
                this.AddComponentInspectorsRecursively(viewModel.Parent, panel, getPropertyValue, onValueChanged);
            }

            // Add inspectors for specified blueprint.
            foreach (var componentType in viewModel.AddedComponents)
            {
                // Get attributes.
                InspectorType componentInfo = InspectorComponentTable.Instance.GetInspectorType(componentType);
                if (componentInfo == null)
                {
                    continue;
                }

                this.AddInspectorControls(componentInfo, panel, getPropertyValue, onValueChanged);
            }
        }
Example #17
0
        public HtmlRenderer(System.Windows.Controls.Panel controlPanel)
        {
            // setup and host the internet explorer web browser that is built into the .net Windows Forms framework
            try
            {
                _myBrowser = new Microsoft.Web.WebView2.Wpf.WebView2();

                bool navigateFiredOnce = false;

                _myBrowser.NavigationStarting += (sender, args) =>
                {
                    // suppress script errors
                    if (navigateFiredOnce == false)
                    {
                        // do whatever you might want to do only one time, in the entire browser navigation cycle
                        // Used to do the suppress script errors of IE here
                        // TODO: Probably remove this whole code block later
                        navigateFiredOnce = true;
                    }
                };


                _myBrowser.NavigationCompleted += async(sender, args) =>
                {
                    // TODO: Need to setup document click stuff
                    // We lost all the IE document selection stuff, so would need to do that with javascript and events and stuff
                };

                controlPanel.Children.Add(_myBrowser);
            }
            catch (Exception ex)
            {
                System.Windows.MessageBox.Show($"Problem occured loading browser.  Exception: {ex}", "Browser Load Failed", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Error);
            }
        }
Example #18
0
		public QuestionControl(QuestionBase question, Panel panel)
		{
			m_question = question;
			if (m_question.Hidden)
				return;

			// Initialize the statement panel
			panel.Children.Add(m_StatementPanel);
			m_StatementPanel.Orientation = Orientation.Horizontal;

			int nIndent = question.Indent;
			if (nIndent > 0 || m_question.Image.Length != 0)
			{
				if (m_question.Image.Length != 0)
				{
					BitmapImage bm = new BitmapImage(); 
					bm.UriSource = UriHelper.UriAppRelative(m_question.Image);

					Image image = new Image(); 
					m_StatementPanel.Children.Add(image);
					image.ApplyStyle(panel, "SurveyImage");
					image.Source = bm;
					image.Stretch = Stretch.None;
					image.VerticalAlignment = VerticalAlignment.Top;
					image.HorizontalAlignment = HorizontalAlignment.Center;
					if (Double.IsNaN(image.Width))
						image.Width = 0;
					if (nIndent < image.Width)
						nIndent = (int)image.Width;
					if (nIndent != 0 && image.Width < nIndent)
						image.Width = nIndent;
				}
				else
				{
					StackPanel spacerPanel = new StackPanel();
					m_StatementPanel.Children.Add(spacerPanel);
					spacerPanel.Width = nIndent;
				}
			}

			RichTextBlock textBlock = new RichTextBlock();
			m_StatementPanel.Children.Add(textBlock);
			textBlock.MaxWidth = 700;
			textBlock.TextWrapping = TextWrapping.Wrap;
			textBlock.ApplyStyle(panel, "SurveyStatement");
			textBlock.SetHtml(m_question.Statement);

			// Initialize the response panel
			panel.Children.Add(m_ResponsePanel);
			m_ResponsePanel.Tag = question.Name;
			m_ResponsePanel.Orientation = question.ResponseLayoutDirection;
			m_ResponsePanel.HorizontalAlignment = HorizontalAlignment.Left;
			
			if (nIndent > 0)
			{
				StackPanel spacerPanel = new StackPanel();
				m_ResponsePanel.Children.Add(spacerPanel);
				spacerPanel.Width = nIndent;
			}
		}
Example #19
0
        /// <internalonly />
        protected override ProceduralAnimation CreateTransitionAnimation(Panel container, EffectDirection direction)
        {
            if (_scaleTransform == null) {
                _scaleTransform = new ScaleTransform();
                container.RenderTransform = _scaleTransform;

                container.RenderTransformOrigin = new Point(0.5, 0.5);
            }

            TweenInterpolation interpolation = GetEffectiveInterpolation();
            TimeSpan shortDuration = TimeSpan.FromMilliseconds(Duration.TotalMilliseconds / 3);

            FlipScaleAnimation scaleAnimation =
                new FlipScaleAnimation(Duration, _scaleTransform,
                                       (direction == EffectDirection.Forward ? 180 : -180));
            scaleAnimation.Interpolation = interpolation;

            DoubleAnimation frontAnimation =
                new DoubleAnimation(container.Children[1], UIElement.OpacityProperty, shortDuration,
                                    (direction == EffectDirection.Forward ? 0 : 1));
            frontAnimation.Interpolation = interpolation;
            frontAnimation.StartDelay = shortDuration;

            DoubleAnimation backAnimation =
                new DoubleAnimation(container.Children[0], UIElement.OpacityProperty, shortDuration,
                                    (direction == EffectDirection.Forward ? 1 : 0));
            backAnimation.Interpolation = interpolation;
            backAnimation.StartDelay = shortDuration;

            return new ProceduralAnimationSet(scaleAnimation, frontAnimation, backAnimation);
        }
 private void AddLabel(Panel parent, string labelString)
 {
     Label dname = new Label();
     dname.Content = labelString;
     dname.Style = (Style)FindResource("AddressStyle");
     parent.Children.Add(dname);
 }
Example #21
0
		internal override UIElement GetDefaultTemplate ()
		{
			// ItemsPresenter only works when it's attached to an ItemsControl
			// but the user may try to attach it to any custom control
			ItemsControl c = TemplateOwner as ItemsControl;
			if (c == null)
				return null;

			if (_elementRoot != null)
				return _elementRoot;

			if (c.ItemsPanel != null) {
				DependencyObject root = c.ItemsPanel.GetVisualTree (this);
				if (root != null && !(root is Panel))
					throw new InvalidOperationException ("The root element of an ItemsPanelTemplate must be a Panel subclass");
				_elementRoot = (Panel) root;
			}

#if false
			if (_elementRoot == null) {
				if (c is ListBox)
					_elementRoot = new VirtualizingStackPanel ();
				else
					_elementRoot = new StackPanel ();
			}
#else
			if (_elementRoot == null) {
				_elementRoot = (Panel) (c is ListBox ? VirtualizingStackPanelFallbackTemplate : StackPanelFallbackTemplate).GetVisualTree (this);
			}
#endif

			_elementRoot.IsItemsHost = true;
			return _elementRoot;
		}
Example #22
0
        public static DockPanel AddGroupDockPanel(this Panel parent, [NotNull] GroupHeader groupHeader, int depth = 0)
        {
            var dockPanel = CreateGroupPanel(groupHeader, depth);

            parent.Children.Add(dockPanel);
            return(dockPanel);
        }
Example #23
0
        public DocUIList(XmlNode xmlNode, XmlSchemaAnnotated xsdNode, Panel contentpanel, Panel overlaypanel, DynamicForm parentForm, bool horizontal = true)
            : base(xmlNode, xsdNode, contentpanel, overlaypanel, parentForm)
        {
            _optlist = new List<ListItemComponent>();
            _parent = xmlNode;
            _listpanel = new StackPanel();
            _listpanel.Orientation = horizontal ? Orientation.Horizontal : Orientation.Vertical;
            XmlSchemaElement schemaEl = xsdNode as XmlSchemaElement;
            if (schemaEl != null)
            {
                XmlSchemaSequence seq = XmlSchemaUtilities.tryGetSequence(schemaEl.ElementSchemaType);
                if (seq != null && seq.Items.Count == 1 && seq.Items[0] is XmlSchemaElement)
                {
                    _el = seq.Items[0] as XmlSchemaElement;
                    //get all elements from current node
                    foreach (XmlNode node in xmlNode.ChildNodes)
                    {
                        ListItemComponent lio = new ListItemComponent(node, _el, _listpanel, overlaypanel, _optlist, parentForm);
                        _optlist.Add(lio);
                    }
                }

                Button add = new Button();
                add.Content = "Add item";
                add.Click += AddItem;
                _listpanel.Children.Add(add);
                contentpanel.Children.Add(_listpanel);
            }
        }
Example #24
0
 //! 构造普通绘图视图
 public WPFGraphView(Panel container)
 {
     this._view = new WPFViewAdapter(this);
     this.CoreView = GiCoreView.createView(this._view);
     init(container);
     ActiveView = this;
 }
            protected override void AddOptions(Panel panel)
            {
                // add force low memory mode option
                var lowMemoryGroup = new WrapPanel();

                var cb = new CheckBox { Content = "Forced Low Memory Mode: allocate" };
                BindToOption(cb, ForceLowMemoryMode.Enabled);
                lowMemoryGroup.Children.Add(cb);

                var textBox = new TextBox { MinWidth = 60 };
                BindToOption(textBox, ForceLowMemoryMode.SizeInMegabytes);
                lowMemoryGroup.Children.Add(textBox);

                lowMemoryGroup.Children.Add(new TextBlock { Text = "megabytes of extra memory in devenv.exe" });

                panel.Children.Add(lowMemoryGroup);

                // add OOP feature options
                var oopFeatureGroup = new StackPanel();

                AddOption(oopFeatureGroup, NavigateToOptions.OutOfProcessAllowed, nameof(NavigateToOptions));
                AddOption(oopFeatureGroup, SymbolFinderOptions.OutOfProcessAllowed, nameof(SymbolFinderOptions));
                AddOption(oopFeatureGroup, SymbolSearchOptions.OutOfProcessAllowed, nameof(SymbolSearchOptions));

                panel.Children.Add(oopFeatureGroup);

                // and add the rest of the options
                base.AddOptions(panel);
            }
 public override void OnApplyTemplate()
 {
     base.OnApplyTemplate();
     _tabScrollViewer = GetTemplateChild("TabScrollViewerTop") as ScrollViewer;
     _tabPanelTop = GetTemplateChild("HeaderPanel") as Panel;
     SelectionChanged += (s, e) => scrollToSelectedItem();
 }
Example #27
0
 protected override Panel createFrameworkElement(Panel parent, List<IRecyclable> recyclables)
 {
     Panel newPanel;
     this.element = this.createElement(out newPanel, recyclables);
     parent.Children.Add(this.element);
     return newPanel;
 }
 public void FillList(Panel list, Action<AutoCompleteItem> selectWithClick)
 {
     foreach (var item in this.list)
     {
         item.CreateFrameworkElement(list, selectWithClick);
     }
 }
        private void ShowLoader(Panel control)
        {
            var rect = new Rectangle
            {
                Margin = new Thickness(0),
                Fill   = new SolidColorBrush(WPFColor.FromArgb(192, 40, 40, 40)),
                Name   = "prLoaderContainer"
            };

            var loader = new ProgressRing
            {
                Foreground          = (Brush)FindResource("AccentColorBrush"),
                VerticalAlignment   = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Center,
                Width    = 80,
                Height   = 80,
                IsActive = true,
                Name     = "prLoader"
            };

            Panel.SetZIndex(rect, 10000);
            Panel.SetZIndex(loader, 10001);

            control.Children.Add(rect);
            control.Children.Add(loader);
        }
Example #30
0
 public void DrawKeys(Panel parentControl)
 {
     foreach (var key in _keyDictionary.Keys.Values)
     {
         parentControl.Children.Add(key);
     }
 }
 protected override Panel createFrameworkElement(Panel parent, List<IRecyclable> recyclables)
 {
     this.element = this.createElement(recyclables);
     this.element.Visibility = Visibility.Visible;
     parent.Children.Add(this.element);
     return parent;
 }
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
            HorizontalContentAlignment = System.Windows.HorizontalAlignment.Stretch;

            _templateRoot = MoreVisualTreeExtensions.FindFirstChildOfType<Panel>(this);
            if (_templateRoot == null)
            {
                throw new InvalidOperationException("Must include a Panel in the root of the template.");
            }

            if (!_transitionedIn)
            {
                var @in = GetTransitionIn();
                if (@in != null && _templateRoot != null)
                {
                    var transition = @in.GetTransition(_templateRoot);
                    transition.Completed += (x, xe) => transition.Stop();
                    transition.Begin();
                }
                _transitionedIn = true;
            }
        }
            public ProcessorFamily(Panel parentPanel, int idx, string name)
            {
                Index = idx;
                Name = name;
                SelectedProcessor = null;

                LabelName = new Label();
                LabelName.Content = "Choose " + name;
                DockPanel.SetDock(LabelName, Dock.Top);
                LabelName.Height = 30.0;
                LabelName.HorizontalContentAlignment = HorizontalAlignment.Center;
                parentPanel.Children.Add(LabelName);

                ComboProcessors = new ComboBox();
                DockPanel.SetDock(ComboProcessors, Dock.Top);
                ComboProcessors.Height = 25.0;
                ComboProcessors.Margin = new Thickness(30.0, 5.0, 30.0, 5.0);
                ComboProcessors.HorizontalContentAlignment = HorizontalAlignment.Center;
                parentPanel.Children.Add(ComboProcessors);

                ComboProcessors.SelectionChanged += ComboProcessors_SelectionChanged;

                ParametersPanel = new ParametersSelectionPanel();
                ParametersPanel.MinHeight = 20.0;
                DockPanel.SetDock(ParametersPanel, Dock.Top);
                parentPanel.Children.Add(ParametersPanel);
            }
Example #34
0
 //! 构造放大镜绘图视图
 public WPFGraphView(WPFGraphView mainView, Panel container)
 {
     this.CoreView = new GiCoreView(mainView.CoreView);
     this._view = new WPFViewAdapter(this);
     this.CoreView.createMagnifierView(this._view, mainView.ViewAdapter);
     init(container);
 }
Example #35
0
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            _expandCollapseButton = GetTemplateChild(ExpandCollapseButton) as FrameworkElement;
            _contentContainer = GetTemplateChild(ContentContainer) as Panel;
            _content = GetTemplateChild(PanelContent) as FrameworkElement;

            if (_contentContainer != null)
            {
                _contentContainer.SizeChanged += new SizeChangedEventHandler(_contentContainer_SizeChanged);
            }

            if (_content != null)
            {
                _content.SizeChanged += new SizeChangedEventHandler(_content_SizeChanged);
            }

            if (_expandCollapseButton != null)
            {
                if (_expandCollapseButton is ButtonBase)
                {
                    (_expandCollapseButton as ButtonBase).Click += new RoutedEventHandler(_expandCollapseButton_Click);
                }
                else
                {
                    _expandCollapseButton.MouseLeftButtonUp += new MouseButtonEventHandler(_expandCollapseButton_MouseLeftButtonUp);
                }
            }
        }
 public void Loading(Panel parent)
 {
     ContentBorder.Visibility = Visibility.Collapsed;
     parent.Children.Add(this);
     FadeInBackground.Begin();
     _wait = true;
 }
        /// <summary>
        /// Builds the visual tree for the ColorPicker control when the template is applied. 
        /// </summary>
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            m_rootElement = GetTemplateChild("RootElement") as Panel;
            m_hueMonitor = GetTemplateChild("HueMonitor") as Rectangle;
            m_sampleSelector = GetTemplateChild("SampleSelector") as Canvas;
            m_hueSelector = GetTemplateChild("HueSelector") as Canvas;
            m_selectedColorView = GetTemplateChild("SelectedColorView") as Rectangle;
            m_colorSample = GetTemplateChild("ColorSample") as Rectangle;
            m_hexValue = GetTemplateChild("HexValue") as TextBlock;


            m_rootElement.RenderTransform = m_scale = new ScaleTransform();

            m_hueMonitor.MouseLeftButtonDown += rectHueMonitor_MouseLeftButtonDown;
            m_hueMonitor.MouseLeftButtonUp += rectHueMonitor_MouseLeftButtonUp;
            m_hueMonitor.MouseMove += rectHueMonitor_MouseMove;

            m_colorSample.MouseLeftButtonDown += rectSampleMonitor_MouseLeftButtonDown;
            m_colorSample.MouseLeftButtonUp += rectSampleMonitor_MouseLeftButtonUp;
            m_colorSample.MouseMove += rectSampleMonitor_MouseMove;

            m_sampleX = m_colorSample.Width;
            m_sampleY = 0;
            m_huePos = 0;

            UpdateVisuals();
        }
        // Event raised on mouse down in the ZoomAndPanControl
        public static void MouseDown(object sender, MouseButtonEventArgs e,Panel p, ZoomAndPanControl z)
        {
            p.Focus();
            Keyboard.Focus(p);

            mouseButtonDown = e.ChangedButton;
            origZoomAndPanControlMouseDownPoint = e.GetPosition(z);
            origContentMouseDownPoint = e.GetPosition(p);

            if ((Keyboard.Modifiers & ModifierKeys.Shift) != 0 &&
                (e.ChangedButton == MouseButton.Left ||
                 e.ChangedButton == MouseButton.Right))
            {
                // Shift + left- or right-down initiates zooming mode.
                mouseHandlingMode = MouseHandlingMode.Zooming;
            }
            else if (mouseButtonDown == MouseButton.Left)
            {
                // Just a plain old left-down initiates panning mode.
                mouseHandlingMode = MouseHandlingMode.Panning;
            }

            if (mouseHandlingMode != MouseHandlingMode.None)
            {
                // Capture the mouse so that we eventually receive the mouse up event.
                z.CaptureMouse();
                e.Handled = true;
            }
        }
Example #39
0
        // The parameters are formatted like that because it's just way too long otherwise.
        /// <summary>
        /// Functions like `populateDropDownWithT` but also populates a `Panel` using `TInfoControl`.
        ///
        /// Note: `TInfoControl` must have a constructor that takes `T` as it's only parameter.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <typeparam name="TInfoControl"></typeparam>
        /// <param name="panel"></param>
        public static void populateDropDownAndPanelWithT <T, TInfoControl>(this DatabaseCon db,
                                                                           System.Windows.Controls.ComboBox dropDown,
                                                                           System.Windows.Controls.Panel panel,
                                                                           out List <T> list,
                                                                           Action <T> additionalProcessing = null) where T : class
        {
            if (panel == null)
            {
                throw new ArgumentNullException("panel");
            }

            Action <T> action =
                (tValue) =>
            {
                if (additionalProcessing != null)
                {
                    additionalProcessing(tValue);
                }

                var info = Activator.CreateInstance(typeof(TInfoControl), tValue) as System.Windows.Controls.UserControl;
                info.Margin = new Thickness(0, 2, 0, 0);
                info.Width  = double.NaN; // auto width

                panel.Children.Add(info);
            };

            db.populateDropDownWithT <T>(dropDown, out list, action);
        }
Example #40
0
        public static StackPanel AddGroupStackPanel(this Panel parent, string header, string description = null)
        {
            var stackPanel = new StackPanel();

            stackPanel.Children.Add(CreateGroupHeader(header, description));
            parent.Children.Add(stackPanel);
            return(stackPanel);
        }
Example #41
0
        public void AddTempFrame(Page page)
        {
            Frame fr = new Frame();

            BaseGrid.Children.Add(fr);
            Panel.SetZIndex(fr, 1000);
            fr.Content = page;
        }
        private void Window_Loaded()
        {
            _dots     = new ObservableCollection <Dot>();
            _circuits = new ObservableCollection <Circuit>();

            #region 初始化图层
            //高亮蒙版
            _maskCanvas = new Canvas {
                Opacity = 0
            };
            Panel.SetZIndex(_maskCanvas, MaskLayer); //图层
            ZoomCanvas.Children.Add(_maskCanvas);

            //选择框
            _selectCanvas = new Canvas {
                Opacity = 0
            };
            ZoomCanvas.Children.Add(_selectCanvas);

            //辅助线
            _auxiliaryLineCanvas = new Canvas {
                Opacity = 0
            };
            ZoomCanvas.Children.Add(_auxiliaryLineCanvas);
            #endregion

            //回路
            CircuitsTreeView.ItemsSource = _circuits;
            List <CircuitInfo> allCircuits;
            CacheGraph.GetCircuits(out allCircuits);
            var circuits = allCircuits.Where(circuit => circuit.ParentCableId == Cable.CableId);
            foreach (var circuit in circuits)
            {
                GraphAddCircuit(circuit);
            }
            //点
            List <DotInfo> alldots;
            CacheGraph.GetDos(out alldots);
            foreach (var circuit in _circuits)
            {
                var dots = alldots.Where(dot => (dot.ParentCableId == Cable.CableId && dot.ParentCircuitId == circuit.Info.CircuitId))
                           .ToList();
                foreach (var dotInfo in dots)
                {
                    GraphAddDot(dotInfo, circuit);
                }
                circuit.GetAllLines(_zoomScale);
            }
            LoadPointLocation();
            //信息
            LbCableName.Content = Cable.CableName;
            LbRemark.Content    = Cable.Remark;
            LbOperator.Content  = User.UserName;
            //背景
            InitBgConfig();
        }
        private static void HideLoader(Panel control)
        {
            var loaders          = control.FindLogicalChildren <ProgressRing>().Where(c => c.Name == "prLoader").ToArray();
            var loaderContainers = control.FindLogicalChildren <Rectangle>().Where(c => c.Name == "prLoaderContainer").ToArray();

            loaders.ForEach(l => l.IsActive = false);

            loaders.ForEach(l => control.Children.Remove(l));
            loaderContainers.ForEach(r => control.Children.Remove(r));
        }
        private void HightLightCircuit(Circuit curCircuit)
        {
            _maskCanvas.Opacity = 0.8;
            Panel.SetZIndex(_maskCanvas, HightLightMaskLayer);

            foreach (var dot in curCircuit.CircuitDots)
            {
                Panel.SetZIndex(dot.DotCanvas, HightLightDotLayer);
            }
            Panel.SetZIndex(curCircuit.CircuitCanvas, HightLightCircuitLayer);
        }
        private byte _createBitmask(System.Windows.Controls.Panel panel)
        {
            byte mask = 0;

            foreach (var child in panel.Children)
            {
                dynamic dyChild = child;
                mask |= 1 << Convert.ToByte(dyChild.labelIndex.Content.ToString()); // Will only work as long as ApplicationInfo and DeviceInfo have this field.
            }

            return(mask);
        }
Example #46
0
 private static IEnumerable <RouteData> GetElements(
     b.Panel gridLines,
     b.Panel gridButtons,
     LineColor color) =>
 gridLines.Children.OfType <p.Path>()
 .Zip(gridButtons.Children.OfType <b.Button>(),
      (path, btn) =>
      new RouteData
 {
     Pair  = Tuple.Create(path, btn),
     Color = color
 });
Example #47
0
        public NewConversation(LCPClient client, System.Windows.Controls.Panel root)
        {
            Client = client;
            Root   = root;

            DataContext = this;
            InitializeComponent();

            ResultBox.ItemsSource       = SearchResults;
            ParticipantsBox.ItemsSource = Participants;

            Client.SearchResultEvent += UpdateSearchResults;
        }
 private void UpdataDotPhyAddr(Dot dot, string phyAddr)
 {
     dot.Info.PhyAddr = phyAddr;
     foreach (var curDot in _dots)
     {
         if (curDot.Info.PhyAddr == phyAddr && curDot != dot)
         {
             InfoBox.ErrorMsg(dot.Info.Name + "与" + curDot.Info.Name + "物理地址重复");
         }
     }
     InfoBox.PlaySound(true);
     Panel.SetZIndex(dot.DotCanvas, DotLayer);         //暗光
     dot.FlushDotStyle(dot.Info.DotStyle, _zoomScale); //去边框
 }
Example #49
0
        /// <summary>
        /// Adds a splitter control to the specified grid row. The splitter control will always have its Z Index set to 1 so that
        /// it displays on the bottom of the Windows Forms control residing inside the grid row.
        /// </summary>
        /// <param name="rowNumber"></param>
        private void AddSplitterToGrid(int rowNumber)
        {
            var splitter = new GridSplitter
            {
                Name   = $"Splitter{rowNumber}",
                Height = 5,
                HorizontalAlignment = HorizontalAlignment.Stretch,
                VerticalAlignment   = VerticalAlignment.Bottom
            };

            LayoutGrid.Children.Add(splitter);
            Grid.SetRow(splitter, rowNumber);
            Panel.SetZIndex(splitter, 1);
        }
        public EditConversation(LCPClient client, System.Windows.Controls.Panel root, Conversation conv)
        {
            Client       = client;
            Root         = root;
            Conversation = conv;
            Participants = new ObservableCollection <User>(Conversation.Participants);

            DataContext = Conversation;
            InitializeComponent();

            ResultBox.ItemsSource       = SearchResults;
            ParticipantsBox.ItemsSource = Participants;

            Client.SearchResultEvent += UpdateSearchResults;
        }
Example #51
0
        private void updateValidMoves(PlayerEventArgs e)
        {
            Board      board  = e.Board;
            BoardState state  = e.State;
            Player     player = e.Player;

            // Reset all current valid moves excluding the just played move
            foreach (Move move in validMoves.Where(move => !playedMoves.Contains(move)))
            {
                PlayableGameBoardGridEventListener.Children.Remove(activeImages[move.Row, move.Col]);

                inactiveImages[move.Row, move.Col].Opacity = 0;
                activeImages[move.Row, move.Col]           = null;
            }

            if (player is HumanPlayer)
            {
                validMoves = board.GetPossibleMoves(state);
            }
            else
            {
                validMoves = new Move[0];
            }

            if (PlayerTwo is HardAiPlayer)
            {
                return;
            }

            foreach (Move move in validMoves)
            {
                Sprite duplicate = originalPossibleMoveSprite.Duplicate();
                duplicate.Margin = inactiveImages[move.Row, move.Col].Margin;

                duplicate.Margin = new Thickness(
                    duplicate.Margin.Left + 20,
                    duplicate.Margin.Top,
                    duplicate.Margin.Right,
                    duplicate.Margin.Bottom);

                inactiveImages[move.Row, move.Col].Opacity = 0;

                activeImages[move.Row, move.Col] = duplicate;
                PlayableGameBoardGridEventListener.Children.Add(duplicate);
                Panel.SetZIndex(duplicate, 2);
            }
        }
Example #52
0
        public void attachPresetManager(wincon.Panel container, int comboBoxMinWidth = 200)
        {
            if (_configAdapter == null)
            {
                throw new Exception("Cannot create a preset manager before attaching a config via BindConfig()");
            }

            wincon.GroupBox groupbox = new wincon.GroupBox();
            groupbox.Header = "Presets";
            wincon.WrapPanel groupboxInner = new wincon.WrapPanel();
            groupbox.Content = groupboxInner;

            wincon.ComboBox comboBox = new wincon.ComboBox();
            comboBox.ItemsSource   = _configAdapter.getAvailableConfigs();
            comboBox.IsEditable    = true;
            comboBox.MinWidth      = comboBoxMinWidth;
            comboBox.SelectedValue = "default";

            wincon.Button btnLoadPreset = new wincon.Button();
            wincon.Image  imgLoad       = new wincon.Image();
            imgLoad.Stretch       = Stretch.None;
            imgLoad.Source        = new BitmapImage(new Uri("pack://application:,,,/PresetManager;component/images/Open_16x.png"));
            btnLoadPreset.Content = imgLoad;
            btnLoadPreset.Click  += (a, b) => { loadFromPreset(comboBox.Text); };

            wincon.Button btnSavePreset = new wincon.Button();
            wincon.Image  imgSave       = new wincon.Image();
            imgSave.Stretch       = Stretch.None;
            imgSave.Source        = new BitmapImage(new Uri("pack://application:,,,/PresetManager;component/images/Save_16x.png"));
            btnSavePreset.Content = imgSave;
            btnSavePreset.Click  += (a, b) => { saveToPreset(comboBox.Text); comboBox.ItemsSource = _configAdapter.getAvailableConfigs(); };

            wincon.Button btnRefreshPresets = new wincon.Button();
            wincon.Image  imgRefresh        = new wincon.Image();
            imgRefresh.Stretch        = Stretch.None;
            imgRefresh.Source         = new BitmapImage(new Uri("pack://application:,,,/PresetManager;component/images/Refresh_16x.png"));
            btnRefreshPresets.Content = imgRefresh;
            btnRefreshPresets.Click  += (a, b) => { comboBox.ItemsSource = _configAdapter.getAvailableConfigs(); };

            container.Children.Add(groupbox);
            groupboxInner.Children.Add(btnRefreshPresets);
            groupboxInner.Children.Add(comboBox);
            groupboxInner.Children.Add(btnLoadPreset);
            groupboxInner.Children.Add(btnSavePreset);
        }
Example #53
0
        private void ShowHoverBox(Grid grid, Point position)
        {
            this.HoverFoundation = grid;
            this.Position        = position;

            if (this.HoverAsWindow == false)
            {
                this.Parent.Children.Add(this.HoverFoundation);
                CanvasExt.SetUpperLeft(this.HoverFoundation, this.Position.Value);
            }
            else
            {
                EnsureHoverWindow();
                this.HoverWindow.Content       = this.HoverFoundation;
                this.HoverWindow.ShowActivated = false;
                this.HoverWindow.Show();
            }
        }
 private void ResetLayers()
 {
     _maskCanvas.Background = Brushes.White;
     _maskCanvas.Opacity    = 0;
     _maskCanvas.Height     = ZoomCanvas.Height;
     _maskCanvas.Width      = ZoomCanvas.Width;
     Panel.SetZIndex(_maskCanvas, MaskLayer);           //蒙版层
     Panel.SetZIndex(ImgBackGround, BackgroundLayer);   //背景层
     //暗光层
     foreach (var dot in _dots)
     {
         Panel.SetZIndex(dot.DotCanvas, DotLayer);      //所有点
     }
     foreach (var circuit in _circuits)
     {
         Panel.SetZIndex(circuit.CircuitCanvas, CircuitLayer);//所有回路
     }
 }
        private void InsertSprites()
        {
            // Sprite resource name and width
            Sprite hardRobotSprite = new Sprite("HardRobotIdle", 311, AnimationType.AnimateForever)
            {
                Width  = 310,
                Height = 310,
                HorizontalAlignment = HorizontalAlignment.Left,
                VerticalAlignment   = VerticalAlignment.Top,
                Stretch             = Stretch.Fill,
                Name   = "HardRobotIdle",
                Margin = new Thickness(0, 0, 0, 0)
            };

            //Easy or Hard AI
            PlayerTwoSpriteCanvas.Children.Add(hardRobotSprite);
            Panel.SetZIndex(hardRobotSprite, 3);

            VolumeManager.play(@"Resources/Audio/RobotPodDown.wav");
        }
Example #56
0
 public void RemoveHoverBox( )
 {
     if (this.HoverAsWindow == false)
     {
         if (this.HoverFoundation != null)
         {
             this.Parent.Children.Remove(this.HoverFoundation);
             this.HoverFoundation = null;
             this.Position        = null;
         }
     }
     else
     {
         if (this.HoverWindow != null)
         {
             this.HoverWindow.Content = null;
             this.HoverFoundation     = null;
             this.Position            = null;
             this.HoverWindow.Hide();
         }
     }
 }
Example #57
0
        public void AddGrid_FillPanel(Panel Parent)
        {
            double kP;
            double kCh;
            Grid   FillGrid = _drawingArea;

            kP  = Parent.Width / Parent.Height;
            kCh = FillGrid.Width / FillGrid.Height;
            double k = kCh >= kP ? (Parent.Width / FillGrid.Width) : (Parent.Height / FillGrid.Height);
            //if (kCh >= kP)
            //    k = Parent.Width / _drawingArea.Width;
            //else
            //    k = Parent.Height / _drawingArea.Height;
            ScaleTransform ST = new ScaleTransform(k, k);

            //FillGrid.RenderTransform = ST;
            foreach (UIElement Child in FillGrid.Children)
            {
                Child.RenderTransform = ST;
            }
            Parent.Children.Add(FillGrid);
        }
Example #58
0
        private static void AddParamToPanel(Param param, Panel panel)
        {
            var element = AddToolTipToParam(param);

            panel.Children.Add(element);
        }
Example #59
0
        public FunnelExample()
        {
            InitializeComponent();

            //Credit https://dribbble.com/shots/2673159-Funnel-UI-concept
            //Icons http://www.flaticon.com/authors/madebyoliver

            BackColor = Color.FromArgb(255, 20, 20, 75);

            cartesianChart1.Series.Add(new LineSeries
            {
                Values = new ChartValues <double> {
                    100, 85, 50, 35, 5, 3
                },
                Fill            = new SolidColorBrush(System.Windows.Media.Color.FromRgb(33, 106, 254)),
                PointGeometry   = null,
                AreaLimit       = 0,
                StrokeThickness = 0
            });
            cartesianChart1.Series.Add(new LineSeries
            {
                Values = new ChartValues <double> {
                    -100, -85, -50, -35, -5, 3
                },
                Fill            = new SolidColorBrush(System.Windows.Media.Color.FromRgb(33, 106, 254)),
                PointGeometry   = null,
                AreaLimit       = 0,
                StrokeThickness = 0
            });

            var s2 = new LineSeries
            {
                Values = new ChartValues <double> {
                    110, 94, 60, 40, 10, 10
                },
                Fill            = new SolidColorBrush(System.Windows.Media.Color.FromRgb(34, 44, 120)),
                PointGeometry   = null,
                AreaLimit       = 0,
                StrokeThickness = 0
            };
            var s3 = new LineSeries
            {
                Values = new ChartValues <double> {
                    -110, -94, -60, -40, -10, -10
                },
                Fill            = new SolidColorBrush(System.Windows.Media.Color.FromRgb(34, 44, 120)),
                PointGeometry   = null,
                AreaLimit       = 0,
                StrokeThickness = 0
            };
            var s4 = new LineSeries
            {
                Values = new ChartValues <double> {
                    120, 104, 70, 50, 15, 15
                },
                Fill            = new SolidColorBrush(System.Windows.Media.Color.FromRgb(20, 24, 89)),
                PointGeometry   = null,
                AreaLimit       = 0,
                StrokeThickness = 0
            };
            var s5 = new LineSeries
            {
                Values = new ChartValues <double> {
                    -120, -104, -70, -50, -15, -15
                },
                Fill            = new SolidColorBrush(System.Windows.Media.Color.FromRgb(20, 24, 89)),
                PointGeometry   = null,
                AreaLimit       = 0,
                StrokeThickness = 0
            };

            Panel.SetZIndex(s2, -1);
            Panel.SetZIndex(s3, -1);
            Panel.SetZIndex(s4, -2);
            Panel.SetZIndex(s5, -2);

            cartesianChart1.Series.Add(s2);
            cartesianChart1.Series.Add(s3);
            cartesianChart1.Series.Add(s4);
            cartesianChart1.Series.Add(s5);

            cartesianChart1.AxisY.Add(new Axis {
                IsEnabled = false, ShowLabels = false
            });
            var section1 = new AxisSection
            {
                Value           = 1.5,
                Stroke          = new SolidColorBrush(System.Windows.Media.Color.FromArgb(38, 255, 255, 255)),
                StrokeThickness = 5
            };
            var section2 = new AxisSection
            {
                Value           = 3.5,
                Stroke          = new SolidColorBrush(System.Windows.Media.Color.FromArgb(38, 255, 255, 255)),
                StrokeThickness = 5
            };

            Panel.SetZIndex(section1, 1);
            Panel.SetZIndex(section2, 1);
            cartesianChart1.AxisX.Add(new Axis
            {
                IsEnabled  = false,
                ShowLabels = false,
                Sections   = new SectionsCollection
                {
                    section1,
                    section2
                }
            });

            var userUri   = new Uri(@"Cartesian/FunnelChart/Resources/user.png", UriKind.Relative);
            var fingerUri = new Uri("Cartesian/FunnelChart/Resources/fingerprint.png", UriKind.Relative);
            var viewUri   = new Uri("Cartesian/FunnelChart/Resources/view.png", UriKind.Relative);

            var ve1 = new VisualElement
            {
                X = 0.75,
                Y = 120,
                VerticalAlignment   = VerticalAlignment.Bottom,
                HorizontalAlignment = HorizontalAlignment.Center,
                UIElement           = new StackPanel
                {
                    Children =
                    {
                        new Image     {
                            Source = new BitmapImage(userUri)
                        },
                        new TextBlock {
                            Text = "LOADED THE AD", FontSize = 16, Foreground = Brushes.White
                        }
                    }
                }
            };
            var ve2 = new VisualElement
            {
                X = 0.75,
                Y = 0,
                VerticalAlignment   = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Center,
                UIElement           = new TextBlock {
                    Text = "100 %", FontSize = 40, Foreground = Brushes.White
                }
            };

            var ve3 = new VisualElement
            {
                X = 2.5,
                Y = 120,
                VerticalAlignment   = VerticalAlignment.Bottom,
                HorizontalAlignment = HorizontalAlignment.Center,
                UIElement           = new StackPanel
                {
                    Children =
                    {
                        new Image     {
                            Source = new BitmapImage(viewUri)
                        },
                        new TextBlock {
                            Text = "SAW THE AD", FontSize = 16, Foreground = Brushes.White
                        }
                    }
                }
            };

            var ve4 = new VisualElement
            {
                X = 2.5,
                Y = 0,
                VerticalAlignment   = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Center,
                UIElement           = new TextBlock {
                    Text = "50 %", FontSize = 40, Foreground = Brushes.White
                }
            };

            var ve5 = new VisualElement
            {
                X = 4.25,
                Y = 120,
                VerticalAlignment   = VerticalAlignment.Bottom,
                HorizontalAlignment = HorizontalAlignment.Center,
                UIElement           = new StackPanel
                {
                    Children =
                    {
                        new Image     {
                            Source = new BitmapImage(fingerUri)
                        },
                        new TextBlock {
                            Text = "INTERACTED", FontSize = 16, Foreground = Brushes.White
                        }
                    }
                }
            };
            var ve6 = new VisualElement
            {
                X = 4.25,
                Y = 0,
                VerticalAlignment   = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Center,
                UIElement           = new TextBlock {
                    Text = "100 %", FontSize = 40, Foreground = Brushes.White
                }
            };

            cartesianChart1.VisualElements.AddRange(new[]
            {
                ve1, ve2, ve3, ve4, ve5, ve6
            });
        }
Example #60
0
        private void SetLines()
        {
            var points = new List <Point>();

            foreach (var child in canvas.Children)
            {
                if (child is Button button)
                {
                    points.Add(new Point(Canvas.GetLeft(button), Canvas.GetTop(button)));
                }
            }

            for (var i = 1; i < points.Count; i++)
            {
                var button1 = (Button)canvas.Children[i - 1];
                var button2 = (Button)canvas.Children[i];

                var width1  = button1.Width;
                var height1 = button1.Height;

                var width2  = button2.Width;
                var height2 = button2.Height;

                var x1 = points[i - 1].X + width1 / 2;
                var y1 = points[i - 1].Y + height1 / 2;

                var x2 = points[i].X + width2 / 2;
                var y2 = points[i].Y + height2 / 2;

                var line2 = new Line
                {
                    Stroke          = new SolidColorBrush(Color.FromRgb(0, 0, 0)),
                    StrokeThickness = 5,
                    X2 = x2,
                    Y2 = y2
                };

                if (!string.IsNullOrEmpty(button1.Uid))
                {
                    // если угол
                    double tempX, tempY;

                    var line1 = new Line
                    {
                        Stroke          = new SolidColorBrush(Color.FromRgb(0, 0, 0)),
                        StrokeThickness = 5,
                        X1 = x1,
                        Y1 = y1
                    };

                    switch (int.Parse(button1.Uid))
                    {
                    case 0:
                        tempX = x2;
                        tempY = y1;
                        break;

                    case 1:
                        tempX = x1;
                        tempY = y2;
                        break;

                    case 2:
                        tempX = x2;
                        tempY = y1;
                        break;

                    case 3:
                        tempX = x1;
                        tempY = y2;
                        break;

                    default: throw new Exception("Angles");
                    }

                    line1.X2 = tempX;
                    line1.Y2 = tempY;

                    line2.X1 = tempX;
                    line2.Y1 = tempY;

                    Panel.SetZIndex(line1, 1);
                    Panel.SetZIndex(line2, 1);

                    canvas.Children.Add(line1);
                    canvas.Children.Add(line2);
                }
                else
                {
                    var line = new Line
                    {
                        Stroke          = new SolidColorBrush(Color.FromRgb(0, 0, 0)),
                        StrokeThickness = 5,
                        X1 = x1,
                        X2 = x2,
                        Y1 = y1,
                        Y2 = y2
                    };

                    Panel.SetZIndex(line, 1);

                    canvas.Children.Add(line);
                }
            }
        }