Example #1
0
 public static void SetAutoScroll(ListBox instance, bool value)
 {
     var oldHandler = (AutoScrollHandler)instance.GetValue(AutoScrollHandlerProperty);
     if (oldHandler != null)
     {
         oldHandler.Dispose();
         instance.SetValue(AutoScrollHandlerProperty, null);
     }
     instance.SetValue(AutoScrollProperty, value);
     if (value)
         instance.SetValue(AutoScrollHandlerProperty, new AutoScrollHandler(instance));
 }
Example #2
0
        public static void SetAutoScroll(System.Windows.Controls.ListBox instance, bool value)
        {
            AutoScrollHandler OldHandler = (AutoScrollHandler)instance.GetValue(AutoScrollHandlerProperty);

            if (OldHandler != null)
            {
                OldHandler.Dispose();
                instance.SetValue(AutoScrollHandlerProperty, null);
            }
            instance.SetValue(AutoScrollProperty, value);
            if (value)
            {
                instance.SetValue(AutoScrollHandlerProperty, new AutoScrollHandler(instance));
            }
        }
Example #3
0
 public static void SetSelectedItemsBinding(ListBox element, bool value)
 {
     element.SetValue(SelectedItemsProperty, value);
     if (value)
     {
         element.SelectionChanged += (sender, args) =>
         {
             var x = element.SelectedItems;
         };
     }
 }
Example #4
0
        private static SelectedItemsBehavior GetOrCreateBehavior(ListBox target, IList list)
        {
            var behavior = target.GetValue(SelectedItemsBehaviorProperty) as SelectedItemsBehavior;
            if (behavior == null)
            {
                behavior = new SelectedItemsBehavior(target, list);
                target.SetValue(SelectedItemsBehaviorProperty, behavior);
            }

            return behavior;
        }
 public static void SetHasBindableSelectedItems(ListBox source, bool value)
 {
     SelectionChangedHandler Handler = (SelectionChangedHandler)source.GetValue(SelectionChangedHandlerProperty);
     if (value && Handler == null)
     {
         Handler = new SelectionChangedHandler(source);
         source.SetValue(SelectionChangedHandlerProperty, Handler);
     }
     else if (!value && Handler != null)
     { source.ClearValue(SelectionChangedHandlerProperty); }
 }
Example #6
0
        private static ListSelectCommandBehavior GetOrCreateBehavior(ListBox selector)
        {
            var behavior = selector.GetValue(SelectCommandBehaviorProperty) as ListSelectCommandBehavior;
            if (behavior == null)
            {
                behavior = new ListSelectCommandBehavior(selector);
                selector.SetValue(SelectCommandBehaviorProperty, behavior);
            }

            return behavior;
        }
        private static ListBoxSelectionChangedCommandBehavior GetOrCreateBehavior(ListBox ListBox)
        {
            ListBoxSelectionChangedCommandBehavior behavior =
            ListBox.GetValue(SelectCommandBehaviorProperty) as ListBoxSelectionChangedCommandBehavior;

              if (behavior == null)
              {
            behavior = new ListBoxSelectionChangedCommandBehavior(ListBox);
            ListBox.SetValue(SelectCommandBehaviorProperty, behavior);
              }
              return behavior;
        }
Example #8
0
        public static void SetHasBindableSelectedItems(System.Windows.Controls.ListBox source, bool value)
        {
            var handler = (SelectionChangedHandler)source.GetValue(SelectionChangedHandlerProperty);

            if (value && handler == null)
            {
                handler = new SelectionChangedHandler(source);
                source.SetValue(SelectionChangedHandlerProperty, handler);
            }
            else if (!value && handler != null)
            {
                source.ClearValue(SelectionChangedHandlerProperty);
            }
        }
        public void ListBox(ListBox control)
        {
            // Setup initial conditions.
            control.Width = 300;
            control.Height = 200;

            // Populate listbox with random data.
            var list = new List<string>();
            for (int i = 1; i <= 200; i++)
            {
                list.Add(string.Format("{0} - {1}", i, RandomData.LoremIpsum(1,3)));
            }
            control.ItemsSource = list;

            // Apply the behavior.
            control.SetValue(Behaviors.ListBoxMouseWheelScrollerProperty, new ListBoxMouseWheelScroller());
        }
Example #10
0
        public static void SetForceSingleSelectionModeItemIndex(System.Windows.Controls.ListBox source, int value)
        {
            if (source != null)
            {
                source.SelectionChanged += (sender, e) =>
                {
                    if (e.AddedItems.Count == 0)
                    {
                        return;
                    }
                    var selectedItem  = e.AddedItems[0];
                    var lb            = sender as System.Windows.Controls.ListBox;
                    var selectedIndex = lb.Items.IndexOf(selectedItem);

                    var itemIndexValue = (int)source.GetValue(ForceSingleSelectionModeItemIndexProperty);
                    var selectedItems  = (IList)source.GetValue(BindableSelectedItemsProperty);

                    if (selectedIndex == itemIndexValue)
                    {
                        foreach (var item in lb.Items)
                        {
                            if (item != selectedItem)
                            {
                                if (selectedItems.Contains(item))
                                {
                                    selectedItems.Remove(item);
                                }
                            }
                        }
                    }
                    else
                    {
                        selectedItems.Remove(lb.Items[itemIndexValue]);
                    }
                };

                source.SetValue(ForceSingleSelectionModeItemIndexProperty, value);
            }
        }
        public void RenderClusterMap(DashboardHelper dashboardHelper, string latVar, string longVar, Brush clusterColor, string timeVar, string description)
        {
            this.dashboardHelper = dashboardHelper;
            this.latVar          = latVar;
            this.longVar         = longVar;
            this.timeVar         = timeVar;
            this.description     = description;
            this.clusterColor    = (SolidColorBrush)clusterColor;

            GraphicsLayer clusterLayer = myMap.Layers[layerId.ToString()] as GraphicsLayer;

            if (clusterLayer != null)
            {
                clusterLayer.Graphics.Clear();
            }
            else
            {
                clusterLayer    = new GraphicsLayer();
                clusterLayer.ID = layerId.ToString();
                myMap.Layers.Add(clusterLayer);
            }

            CustomCoordinateList coordinateList = GetCoordinates(dashboardHelper, latVar, longVar, timeVar);

            for (int i = 0; i < coordinateList.Coordinates.Count; i++)
            {
                ExtendedGraphic graphic = new ExtendedGraphic()
                {
                    Geometry = new MapPoint(coordinateList.Coordinates[i].X, coordinateList.Coordinates[i].Y, geoReference),
                    RecordId = coordinateList.Coordinates[i].RecordId,
                    Symbol   = MarkerSymbol
                };
                if (coordinateList.Coordinates[i].TimeSpan.HasValue)
                {
                    graphic.TimeExtent = new TimeExtent(coordinateList.Coordinates[i].TimeSpan.Value);
                }
                else
                {
                    graphic.TimeExtent = new TimeExtent(DateTime.MinValue, DateTime.MaxValue);
                }
                graphic.MouseLeftButtonUp += new MouseButtonEventHandler(graphic_MouseLeftButtonUp);
                clusterLayer.Graphics.Add(graphic);
            }
            Brush flareForeground;

            if (System.Drawing.Color.FromArgb(this.clusterColor.Color.A, this.clusterColor.Color.R, this.clusterColor.Color.G, this.clusterColor.Color.B).GetBrightness() > 0.5)
            {
                flareForeground = new SolidColorBrush(Colors.Black);
            }
            else
            {
                flareForeground = new SolidColorBrush(Colors.White);
            }
            FlareClusterer clusterer = new FlareClusterer()
            {
                FlareBackground   = clusterColor,
                FlareForeground   = flareForeground,
                MaximumFlareCount = 10,
                Radius            = 15,
                Gradient          = ClustererGradient
            };

            clusterLayer.Clusterer = clusterer;

            if (LegendStackPanel == null)
            {
                LegendStackPanel = new StackPanel();
            }

            LegendStackPanel.Children.Clear();

            if (string.IsNullOrEmpty(description))
            {
                description = SharedStrings.CASES;
            }

            System.Windows.Controls.ListBox legendList = new System.Windows.Controls.ListBox();
            legendList.Padding         = new Thickness(0, 10, 0, 0);
            legendList.Background      = Brushes.White;
            legendList.BorderBrush     = Brushes.Black;
            legendList.BorderThickness = new Thickness(0);
            legendList.SetValue(ScrollViewer.HorizontalScrollBarVisibilityProperty, ScrollBarVisibility.Disabled);

            TextBlock classTextBlock = new TextBlock();

            classTextBlock.Text                = description;
            classTextBlock.FontFamily          = new FontFamily("Segoe");
            classTextBlock.FontSize            = 12;
            classTextBlock.MaxWidth            = 256;
            classTextBlock.TextWrapping        = TextWrapping.Wrap;
            classTextBlock.HorizontalAlignment = HorizontalAlignment.Center;
            classTextBlock.VerticalAlignment   = VerticalAlignment.Center;
            classTextBlock.SetValue(ScrollViewer.HorizontalScrollBarVisibilityProperty, ScrollBarVisibility.Disabled);

            Ellipse circle = new Ellipse();

            circle.Width             = 14;
            circle.Height            = 14;
            circle.VerticalAlignment = VerticalAlignment.Top;
            circle.Margin            = new Thickness(0, 4, 7, 4);
            circle.Fill = this.clusterColor;

            StackPanel classStackPanel = new StackPanel();

            classStackPanel.Margin      = new Thickness(10, 0, 10, 10);
            classStackPanel.Orientation = System.Windows.Controls.Orientation.Horizontal;
            classStackPanel.Children.Add(circle);
            classStackPanel.Children.Add(classTextBlock);

            legendList.Items.Add(classStackPanel);

            LegendStackPanel.Children.Add(legendList);


            if (coordinateList.Coordinates.Count > 0)
            {
                myMap.Extent = new Envelope(ESRI.ArcGIS.Client.Bing.Transform.GeographicToWebMercator(new MapPoint(minX - 0.01, minY - 0.01, geoReference)), ESRI.ArcGIS.Client.Bing.Transform.GeographicToWebMercator(new MapPoint(maxX + 0.01, maxY + 0.01, geoReference)));
                if (!string.IsNullOrEmpty(timeVar))
                {
                    if (minTime != null && maxTime != null)
                    {
                        intervalCounts = new List <KeyValuePair <DateTime, int> >();
                        DateTime previousInterval        = DateTime.MinValue;
                        IEnumerable <DateTime> intervals = TimeSlider.CreateTimeStopsByTimeInterval(new TimeExtent(minTime, maxTime), new TimeSpan(1, 0, 0, 0));
                        foreach (DateTime interval in intervals)
                        {
                            int count = clusterLayer.Graphics.Count(x => x.TimeExtent.Start <= interval && x.TimeExtent.Start >= previousInterval);
                            intervalCounts.Add(new KeyValuePair <DateTime, int>(interval.Date, count));
                            previousInterval = interval;
                        }
                        if (DateRangeDefined != null)
                        {
                            DateRangeDefined(minTime, maxTime, intervalCounts);
                        }
                    }
                }
            }
        }
 public static void SetItems(ListBox listBox, IList list)
 {
     listBox.SetValue(ItemsProperty, list);
 }
Example #13
0
 public static void SetIsSelectedItemScrolledIntoView(ListBox listBox, bool value)
 {
     listBox.SetValue(IsSelectedItemScrolledIntoViewProperty, value);
 }
        void FncNextQuestion()
        {
            try
            {
            cnvMain.Children.Clear();
            currentQuestion = -1;

            for (int i = 0; i < lstQuestions.Count; i++)
            {
                if (lstQuestions[i].Header == StartQuestion)
                {
                    currentQuestion = i;
                    break;
                }
            }

            if (currentQuestion == -1)
                goto exit;
            
            Label lblHeader = new Label();
            lblHeader.Content = lstQuestions[currentQuestion].Header;
            lblHeader.Height = 30;
            lblHeader.Width = 600;
            lblHeader.SetValue(Canvas.LeftProperty, 10.0);
            lblHeader.SetValue(Canvas.TopProperty, 10.0);

            if (lstQuestions[currentQuestion].Type == TypeOfOptions.RadioButton)
            {
                RadioButton[] rdo = new RadioButton[lstQuestions[currentQuestion].NoOfOptions];
                List<string> strOpt = lstQuestions[currentQuestion].Options;
                for (int i = 0; i < lstQuestions[currentQuestion].NoOfOptions; i++)
                {
                    rdo[i] = new RadioButton();
                    string[] str = strOpt[i].Split(new string[] {"*****"}, StringSplitOptions.None);
                    rdo[i].Content = str[0];
                    rdo[i].Tag = str[1];
                    rdo[i].Height = 25;
                    rdo[i].Width = 600;
                    rdo[i].SetValue(Canvas.LeftProperty, 80.0);
                    rdo[i].SetValue(Canvas.TopProperty, 10.0 + ((i + 1) * 30));
                    cnvMain.Children.Add(rdo[i]);
                }
            }

            else if (lstQuestions[currentQuestion].Type == TypeOfOptions.CheckBox)
            {

                CheckBox[] rdo = new CheckBox[lstQuestions[currentQuestion].NoOfOptions];
                List<string> strOpt = lstQuestions[currentQuestion].Options;
                for (int i = 0; i < lstQuestions[currentQuestion].NoOfOptions; i++)
                {

                    rdo[i] = new CheckBox();
                    string[] str = strOpt[i].Split(new string[] { "*****" }, StringSplitOptions.None);
                    rdo[i].Content = str[0];
                    rdo[i].Tag = str[1];
                    rdo[i].Height = 25;
                    rdo[i].Width = 600;
                    rdo[i].SetValue(Canvas.LeftProperty, 80.0);
                    rdo[i].SetValue(Canvas.TopProperty, 10.0 + ((i + 1) * 30));
                    cnvMain.Children.Add(rdo[i]);
                }
            }

            else if (lstQuestions[currentQuestion].Type == TypeOfOptions.ListBox)
            {

                ListBox lst = new ListBox();
                lst.Height = 250;
                lst.Width = 250;
                lst.SetValue(Canvas.LeftProperty, 80.0);
                lst.SetValue(Canvas.TopProperty, 80.0);
                cnvMain.Children.Add(lst);
                ListBoxItem[] lbi = new ListBoxItem[lstQuestions[currentQuestion].NoOfOptions];
                List<string> strOpt = lstQuestions[currentQuestion].Options;
                for (int i = 0; i < lstQuestions[currentQuestion].NoOfOptions; i++)
                {
                    lbi[i] = new ListBoxItem();
                    string[] str = strOpt[i].Split(new string[] { "*****" }, StringSplitOptions.None);
                    lbi[i].Content = str[0];
                    lbi[i].Tag = str[1];
                    lst.Items.Add(lbi[i]);
                }
            }

            else if (lstQuestions[currentQuestion].Type == TypeOfOptions.ComboBox)
            {
                ComboBox cmb = new ComboBox();
                cmb.Height = 30;
                cmb.Width = 250;
                cmb.SetValue(Canvas.LeftProperty, 80.0);
                cmb.SetValue(Canvas.TopProperty, 80.0);
                cnvMain.Children.Add(cmb);
                ComboBoxItem[] cbi = new ComboBoxItem[lstQuestions[currentQuestion].NoOfOptions];
                List<string> strOpt = lstQuestions[currentQuestion].Options;
                for (int i = 0; i < lstQuestions[currentQuestion].NoOfOptions; i++)
                {
                    cbi[i] = new ComboBoxItem();
                    string[] str = strOpt[i].Split(new string[] { "*****" }, StringSplitOptions.None);
                    cbi[i].Content = str[0];
                    cbi[i].Tag = str[1];
                    cmb.Items.Add(cbi[i]);
                }
            }

            else if (lstQuestions[currentQuestion].Type == TypeOfOptions.TextBox)
            {
                Label[] lbl = new Label[lstQuestions[currentQuestion].NoOfOptions];
                TextBox[] txt = new TextBox[lstQuestions[currentQuestion].NoOfOptions];
                List<string> strOpt = lstQuestions[currentQuestion].Options;
                for (int i = 0; i < lstQuestions[currentQuestion].NoOfOptions; i++)
                {

                    lbl[i] = new Label();
                    string[] str = strOpt[i].Split(new string[] { "*****" }, StringSplitOptions.None);
                    lbl[i].Content = str[0];
                    lbl[i].Height = 25;
                    lbl[i].Width = 600;
                    lbl[i].SetValue(Canvas.LeftProperty, 80.0);
                    lbl[i].SetValue(Canvas.TopProperty, 10.0 + ((i + 1) * 30));
                    cnvMain.Children.Add(lbl[i]);

                    txt[i] = new TextBox();

                    //string[] str = strOpt[i].Split(new string[] { "*****" }, StringSplitOptions.None);
                    txt[i].Text = str[0];
                    txt[i].Tag = str[1];

                    txt[i].Height = 25;
                    txt[i].Width = 400;
                    txt[i].SetValue(Canvas.LeftProperty, 280.0);
                    txt[i].SetValue(Canvas.TopProperty, 10.0 + ((i + 1) * 30));
                    cnvMain.Children.Add(txt[i]);
                }
            }

            
            cnvMain.Children.Add(lblHeader);
            currentQuestion++;
        exit: ;
        }
            catch (Exception exp)
            {
                VMuktiAPI.VMuktiHelper.ExceptionHandler(exp, "FncNextQuestion()", "ctlQuestion.xaml.cs");
            }
        }
 public static void SetCommandParameter(ListBox ListBox, object parameter)
 {
     ListBox.SetValue(CommandParameterProperty, parameter);
 }
        void cnvPaint_Drop(object sender, DragEventArgs e)
        {
            if (e.Data.GetData(typeof(Button)) != null)
            {
                if (((Canvas)((Button)e.Data.GetData(typeof(Button))).Parent).Name.ToString() == "cnvControls")
                {

                    Point p = e.GetPosition((IInputElement)cnvPaint);
                    Button btn = new Button();
                    btn.Height = 25;
                    btn.Width = 100;
                    btn.Content = "Button";
                    btn.Background = Brushes.Transparent;
                    btn.PreviewMouseDown += new MouseButtonEventHandler(btnDrag_PreviewMouseDown);
                    btn.SetValue(Canvas.LeftProperty, 10.0);
                    btn.SetValue(Canvas.TopProperty, 10.0);

                    ctlPOD objPOD = new ctlPOD();
                    objPOD.AllowDrop = true;
                    objPOD.Height = 25;
                    objPOD.Width = 100;
                    
                    objPOD.SetValue(Canvas.LeftProperty, p.X);
                    objPOD.SetValue(Canvas.TopProperty, p.Y);
                    MyPropGrid.ControlToBind = objPOD;
                    objPOD.PreviewMouseDown += new MouseButtonEventHandler(objPOD_PreviewMouseDown);

                    objPOD.cnvPOD.Children.Add(btn);
                    currentControl = objPOD;
                    cnvPaint.Children.Add(objPOD);
                }
                else if ((((Canvas)((Button)e.Data.GetData(typeof(Button))).Parent).Parent).GetType() == typeof(ctlPOD))
                {
                    //v
                   // if (currentControl.rect.Visibility == Visibility.Visible)
                    {
                        Point p = e.GetPosition((IInputElement)cnvPaint);
                        ((Canvas)((Button)e.Data.GetData(typeof(Button))).Parent).Parent.SetValue(Canvas.LeftProperty, p.X - PrePoint.X);
                        ((Canvas)((Button)e.Data.GetData(typeof(Button))).Parent).Parent.SetValue(Canvas.TopProperty, p.Y - PrePoint.Y);
                    }
                }
            }

            else if (e.Data.GetData(typeof(Label)) != null)
            {
                if (((Canvas)((Label)e.Data.GetData(typeof(Label))).Parent).Name.ToString() == "cnvControls")
                {
                    Point p = e.GetPosition((IInputElement)cnvPaint);
                    Label lbl = new Label();
                    lbl.Content = "Label";
                    lbl.Background = Brushes.Transparent;
                    lbl.Foreground = Brushes.Black ;
                    lbl.HorizontalContentAlignment = HorizontalAlignment.Center;
                    lbl.Height = 25;
                    lbl.Width = 100;
                    lbl.PreviewMouseDown += new MouseButtonEventHandler(lblDrag_PreviewMouseDown);
                    lbl.SetValue(Canvas.LeftProperty, 10.0);
                    lbl.SetValue(Canvas.TopProperty, 10.0);

                    ctlPOD objPOD = new ctlPOD();
                    objPOD.cnvPOD.Children.Add(lbl);
                    objPOD.AllowDrop = true;
                    objPOD.Height = 25;
                    objPOD.Width = 100;
                    objPOD.SetValue(Canvas.LeftProperty, p.X);
                    objPOD.SetValue(Canvas.TopProperty, p.Y);
                    MyPropGrid.ControlToBind = objPOD;
                    objPOD.KeyDown += new KeyEventHandler(objPOD_KeyDown);
                    objPOD.PreviewMouseDown += new MouseButtonEventHandler(objPOD_PreviewMouseDown);
                    currentControl = objPOD;
                    cnvPaint.Children.Add(objPOD);
                }

                else if ((((Canvas)((Label)e.Data.GetData(typeof(Label))).Parent).Parent).GetType() == typeof(ctlPOD))
                {
                    Point p = e.GetPosition((IInputElement)cnvPaint);
                    ((Canvas)((Label)e.Data.GetData(typeof(Label))).Parent).Parent.SetValue(Canvas.LeftProperty, p.X - PrePoint.X);
                    ((Canvas)((Label)e.Data.GetData(typeof(Label))).Parent).Parent.SetValue(Canvas.TopProperty, p.Y - PrePoint.Y);

                }
            }

            else if (e.Data.GetData(typeof(TextBox)) != null)
            {
                if (((Canvas)((TextBox)e.Data.GetData(typeof(TextBox))).Parent).Name.ToString() == "cnvControls")
                {
                    Point p = e.GetPosition((IInputElement)cnvPaint);
                    TextBox txt = new TextBox();
                    txt.Cursor = Cursors.Arrow;
                    txt.Background = Brushes.Transparent;
                    txt.Height = 25;
                    txt.Width = 100;
                    txt.Text = "TextBox";
                    txt.MouseDown += new MouseButtonEventHandler(txt_MouseDown);
                    txt.PreviewMouseDown += new MouseButtonEventHandler(txtDrag_PreviewMouseDown);
                    txt.SetValue(Canvas.LeftProperty, 10.0);
                    txt.SetValue(Canvas.TopProperty, 10.0);


                    ctlPOD objPOD = new ctlPOD();
                    objPOD.AllowDrop = true;
                    objPOD.Height = 25;
                    objPOD.Width = 100;
                    objPOD.PreviewMouseDown += new MouseButtonEventHandler(objPOD_PreviewMouseDown);
                    objPOD.SetValue(Canvas.LeftProperty, p.X);
                    objPOD.SetValue(Canvas.TopProperty, p.Y);
                    MyPropGrid.ControlToBind = objPOD;
                    objPOD.cnvPOD.Children.Add(txt);
                    currentControl = objPOD;
                    cnvPaint.Children.Add(objPOD);
                }
                else if ((((Canvas)((TextBox)e.Data.GetData(typeof(TextBox))).Parent).Parent).GetType() == typeof(ctlPOD))
                {
                    Point p = e.GetPosition((IInputElement)cnvPaint);
                    ((Canvas)((TextBox)e.Data.GetData(typeof(TextBox))).Parent).Parent.SetValue(Canvas.LeftProperty, p.X - PrePoint.X);
                    ((Canvas)((TextBox)e.Data.GetData(typeof(TextBox))).Parent).Parent.SetValue(Canvas.TopProperty, p.Y - PrePoint.Y);
                }
            }

            else if (e.Data.GetData(typeof(TextBlock)) != null)
            {
                if (((Canvas)((TextBlock)e.Data.GetData(typeof(TextBlock))).Parent).Name.ToString() == "cnvControls")
                {
                    Point p = e.GetPosition((IInputElement)cnvPaint);
                    TextBlock txb = new TextBlock();

                    txb.Cursor = Cursors.Arrow;
                    txb.Height = 25;
                    txb.Width = 100;
                    txb.Background = Brushes.Transparent;
                    txb.TextWrapping = TextWrapping.Wrap;
                    txb.Text = "TextBlock";
                    txb.PreviewMouseDown += new MouseButtonEventHandler(txbDrag999_PreviewMouseDown);
                    txb.SetValue(Canvas.LeftProperty, 10.0);
                    txb.SetValue(Canvas.TopProperty, 10.0);
                    txb.Foreground = Brushes.Black;

                    ctlPOD objPOD = new ctlPOD();
                    objPOD.AllowDrop = true;
                    objPOD.Height = 25;
                    objPOD.Width = 100;
                    objPOD.PreviewMouseDown += new MouseButtonEventHandler(objPOD_PreviewMouseDown);
                    objPOD.SetValue(Canvas.LeftProperty, p.X);
                    objPOD.SetValue(Canvas.TopProperty, p.Y);
                    MyPropGrid.ControlToBind = objPOD;
                    objPOD.cnvPOD.Children.Add(txb);
                    currentControl = objPOD;
                    cnvPaint.Children.Add(objPOD);
                }
                else if ((((Canvas)((TextBlock)e.Data.GetData(typeof(TextBlock))).Parent).Parent).GetType() == typeof(ctlPOD))
                {
                    Point p = e.GetPosition((IInputElement)cnvPaint);
                    ((Canvas)((TextBlock)e.Data.GetData(typeof(TextBlock))).Parent).Parent.SetValue(Canvas.LeftProperty, p.X - PrePoint.X);
                    ((Canvas)((TextBlock)e.Data.GetData(typeof(TextBlock))).Parent).Parent.SetValue(Canvas.TopProperty, p.Y - PrePoint.Y);
                }
            }

            else if (e.Data.GetData(typeof(ComboBox)) != null)
            {
                if (((Canvas)((ComboBox)e.Data.GetData(typeof(ComboBox))).Parent).Name.ToString() == "cnvControls")
                {
                    Point p = e.GetPosition((IInputElement)cnvPaint);
                    ComboBox cmb = new ComboBox();
                    cmb.Cursor = Cursors.Arrow;
                    cmb.Height = 25;
                    cmb.Width = 100;
                    cmb.Background = Brushes.Transparent;
                    cmb.Text = "ComboBox";
                    cmb.PreviewMouseDown += new MouseButtonEventHandler(cmb_PreviewMouseDown);
                    cmb.SetValue(Canvas.LeftProperty, 10.0);
                    cmb.SetValue(Canvas.TopProperty, 10.0);

                    ctlPOD objPOD = new ctlPOD();
                    objPOD.AllowDrop = true;
                    objPOD.Height = 25;
                    objPOD.Width = 100;
                    objPOD.PreviewMouseDown += new MouseButtonEventHandler(objPOD_PreviewMouseDown);
                    objPOD.SetValue(Canvas.LeftProperty, p.X);
                    objPOD.SetValue(Canvas.TopProperty, p.Y);
                    MyPropGrid.ControlToBind = objPOD;
                    objPOD.cnvPOD.Children.Add(cmb);
                    currentControl = objPOD;
                    cnvPaint.Children.Add(objPOD);
                }
                else if ((((Canvas)((ComboBox)e.Data.GetData(typeof(ComboBox))).Parent).Parent).GetType() == typeof(ctlPOD))
                {
                    Point p = e.GetPosition((IInputElement)cnvPaint);
                    ((Canvas)((ComboBox)e.Data.GetData(typeof(ComboBox))).Parent).Parent.SetValue(Canvas.LeftProperty, p.X - PrePoint.X);
                    ((Canvas)((ComboBox)e.Data.GetData(typeof(ComboBox))).Parent).Parent.SetValue(Canvas.TopProperty, p.Y - PrePoint.Y);
                }
            }

            else if (e.Data.GetData(typeof(ListBox)) != null)
            {
                if (((Canvas)((ListBox)e.Data.GetData(typeof(ListBox))).Parent).Name.ToString() == "cnvControls")
                {
                    Point p = e.GetPosition((IInputElement)cnvPaint);
                    ListBox lst = new ListBox();
                    lst.Cursor = Cursors.Arrow;
                    lst.Height = 25;
                    lst.Width = 100;
                    lst.Background = Brushes.Transparent;
                    lst.PreviewMouseDown += new MouseButtonEventHandler(lst_PreviewMouseDown);
                    lst.SetValue(Canvas.LeftProperty, 10.0);
                    lst.SetValue(Canvas.TopProperty, 10.0);

                    ctlPOD objPOD = new ctlPOD();
                    objPOD.AllowDrop = true;
                    objPOD.Height = 25;
                    objPOD.Width = 100;
                    objPOD.PreviewMouseDown += new MouseButtonEventHandler(objPOD_PreviewMouseDown);
                    objPOD.SetValue(Canvas.LeftProperty, p.X);
                    objPOD.SetValue(Canvas.TopProperty, p.Y);
                    MyPropGrid.ControlToBind = objPOD;
                    objPOD.cnvPOD.Children.Add(lst);
                    currentControl = objPOD;
                    cnvPaint.Children.Add(objPOD);
                }
                else if ((((Canvas)((ListBox)e.Data.GetData(typeof(ListBox))).Parent).Parent).GetType() == typeof(ctlPOD))
                {
                    Point p = e.GetPosition((IInputElement)cnvPaint);
                    ((Canvas)((ListBox)e.Data.GetData(typeof(ListBox))).Parent).Parent.SetValue(Canvas.LeftProperty, p.X - PrePoint.X);
                    ((Canvas)((ListBox)e.Data.GetData(typeof(ListBox))).Parent).Parent.SetValue(Canvas.TopProperty, p.Y - PrePoint.Y);
                }
            }

            else if (e.Data.GetData(typeof(CheckBox)) != null)
            {
                if (((Canvas)((CheckBox)e.Data.GetData(typeof(CheckBox))).Parent).Name.ToString() == "cnvControls")
                {
                    Point p = e.GetPosition((IInputElement)cnvPaint);
                    CheckBox chk = new CheckBox();
                    chk.Cursor = Cursors.Arrow;
                    chk.Height = 25;
                    chk.Width = 100;
                    chk.Content = "Check Box";
                    chk.Background = Brushes.Transparent;
                    chk.PreviewMouseDown += new MouseButtonEventHandler(chk_PreviewMouseDown);
                    chk.SetValue(Canvas.LeftProperty, 10.0);
                    chk.SetValue(Canvas.TopProperty, 10.0);

                    ctlPOD objPOD = new ctlPOD();
                    objPOD.AllowDrop = true;
                    objPOD.Height = 25;
                    objPOD.Width = 100;
                    objPOD.PreviewMouseDown += new MouseButtonEventHandler(objPOD_PreviewMouseDown);
                    objPOD.SetValue(Canvas.LeftProperty, p.X);
                    objPOD.SetValue(Canvas.TopProperty, p.Y);
                    MyPropGrid.ControlToBind = objPOD;
                    objPOD.cnvPOD.Children.Add(chk);
                    currentControl = objPOD;
                    cnvPaint.Children.Add(objPOD);
                }
                else if ((((Canvas)((CheckBox)e.Data.GetData(typeof(CheckBox))).Parent).Parent).GetType() == typeof(ctlPOD))
                {
                    Point p = e.GetPosition((IInputElement)cnvPaint);
                    ((Canvas)((CheckBox)e.Data.GetData(typeof(CheckBox))).Parent).Parent.SetValue(Canvas.LeftProperty, p.X - PrePoint.X);
                    ((Canvas)((CheckBox)e.Data.GetData(typeof(CheckBox))).Parent).Parent.SetValue(Canvas.TopProperty, p.Y - PrePoint.Y);
                }
            }

            else if (e.Data.GetData(typeof(RadioButton)) != null)
            {
                if (((Canvas)((RadioButton)e.Data.GetData(typeof(RadioButton))).Parent).Name.ToString() == "cnvControls")
                {
                    Point p = e.GetPosition((IInputElement)cnvPaint);
                    RadioButton rad = new RadioButton();
                    rad.Cursor = Cursors.Arrow;
                    rad.Height = 25;
                    rad.Width = 100;
                    rad.Content = "Radio Button";
                    rad.Background = Brushes.Transparent;
                    rad.PreviewMouseDown += new MouseButtonEventHandler(rad_PreviewMouseDown);
                    rad.SetValue(Canvas.LeftProperty, 10.0);
                    rad.SetValue(Canvas.TopProperty, 10.0);

                    ctlPOD objPOD = new ctlPOD();
                    objPOD.AllowDrop = true;
                    objPOD.Height = 25;
                    objPOD.Width = 100;
                    objPOD.PreviewMouseDown += new MouseButtonEventHandler(objPOD_PreviewMouseDown);
                    objPOD.SetValue(Canvas.LeftProperty, p.X);
                    objPOD.SetValue(Canvas.TopProperty, p.Y);
                    MyPropGrid.ControlToBind = objPOD;
                    objPOD.cnvPOD.Children.Add(rad);
                    currentControl = objPOD;
                    cnvPaint.Children.Add(objPOD);
                }
                else if ((((Canvas)((RadioButton)e.Data.GetData(typeof(RadioButton))).Parent).Parent).GetType() == typeof(ctlPOD))
                {
                    Point p = e.GetPosition((IInputElement)cnvPaint);
                    ((Canvas)((RadioButton)e.Data.GetData(typeof(RadioButton))).Parent).Parent.SetValue(Canvas.LeftProperty, p.X - PrePoint.X);
                    ((Canvas)((RadioButton)e.Data.GetData(typeof(RadioButton))).Parent).Parent.SetValue(Canvas.TopProperty, p.Y - PrePoint.Y);
                }
            }

            newDrag = 1;
            r1.Visibility = Visibility.Collapsed;
            MyPropGrid.ControlToBind = currentControl;
        }
Example #17
0
 public static void SetCommand(ListBox selector, ICommand command)
 {
     selector.SetValue(CommandProperty, command);
 }
Example #18
0
        private void createParameterList()
        {
            flag_hasSocks = false;
            StackPanel webby2 = new StackPanel();
            webby2.Orientation = Orientation.Vertical;
            innerPane.Children.Add(webby2);
            for (int i = 0; i < parameterList.Count; i++)
            {
                flag_hasSocks = true;
                SocketDragDropTarget target = new SocketDragDropTarget();
                target.socketType = parameterList[i];

                Style style = new Style(typeof(ListBoxItem));
                style.Setters.Add(new Setter(ListBoxItem.PaddingProperty, new Thickness(-1)));

                if (type.Contains("CONDITION"))
                    target.isCondition = true;
                if (type.Contains("CONSTANT"))
                    target.isConstant = true;

                ListBox listBox = new ListBox();
                ObservableCollection<Block> collection = new ObservableCollection<Block>();
                listBox.Height = 40;
                listBox.SetValue(ScrollViewer.HorizontalScrollBarVisibilityProperty, ScrollBarVisibility.Hidden);
                listBox.ItemContainerStyle = style;
                listBox.Width = LayoutRoot.Width * .6;
                listBox.BorderThickness = new Thickness(2);
                listBox.Background = new SolidColorBrush(Colors.LightGray);
                listBox.ItemsSource = collection;
                target.Content = listBox;
                if(i > 0)
                    LayoutRoot.Height = LayoutRoot.Height + listBox.Height;
                webby2.Children.Add(target);
            }
        }
Example #19
0
        private static void UpdateActivatedIndex(ListBox listBox, object value)
        {
            // find index of activated item
            int index;
            if (value == null)
            {
                index = -1;
            }
            else
            {
                index = 0;
                foreach (var item in listBox.Items)
                {
                    if (item == value)
                        break;
                    index++;
                }
            }

            if (index >= listBox.Items.Count)
                index = -1;

            listBox.SetValue(ActiveIndexPropertyKey, index);
        }
        void cnvPaint_Drop(object sender, DragEventArgs e)
        {
            try
            {
                if (e.Data.GetData(typeof(Button)) != null)
                {
                    if (((Canvas)((Button)e.Data.GetData(typeof(Button))).Parent).Name.ToString() == "cnvControls")
                    {

                        Point p = e.GetPosition((IInputElement)cnvPaint);
                        Button btn = new Button();
                        btn.Height = 25;
                        btn.Width = 100;
                        btn.Content = "Button";
                        btn.PreviewMouseDown += new MouseButtonEventHandler(btnDrag_PreviewMouseDown);
                        btn.SetValue(Canvas.LeftProperty, 10.0);
                        btn.SetValue(Canvas.TopProperty, 10.0);

                        ctlPOD objPOD = new ctlPOD();
                        objPOD.AllowDrop = true;
                        objPOD.Height = 25;
                        objPOD.Width = 100;
                        objPOD.PreviewMouseDown += new MouseButtonEventHandler(objPOD_PreviewMouseDown);
                        objPOD.SetValue(Canvas.LeftProperty, p.X);
                        objPOD.SetValue(Canvas.TopProperty, p.Y);
                        MyPropGrid.ControlToBind = objPOD;
                        objPOD.cnvPOD.Children.Add(btn);
                        currentControl = objPOD;
                        cnvPaint.Children.Add(objPOD);
                    }
                    else if ((((Canvas)((Button)e.Data.GetData(typeof(Button))).Parent).Parent).GetType() == typeof(ctlPOD))
                    {
                        if (currentControl.rect.Visibility == Visibility.Visible)
                        {
                            Point p = e.GetPosition((IInputElement)cnvPaint);
                            ((Canvas)((Button)e.Data.GetData(typeof(Button))).Parent).Parent.SetValue(Canvas.LeftProperty, p.X - PrePoint.X);
                            ((Canvas)((Button)e.Data.GetData(typeof(Button))).Parent).Parent.SetValue(Canvas.TopProperty, p.Y - PrePoint.Y);
                        }
                    }
                }
                else if (e.Data.GetData(typeof(TabControl)) != null)
                {
                    if (((Canvas)((TabControl)e.Data.GetData(typeof(TabControl))).Parent).Name.ToString() == "cnvControls")
                    {
                        Point p = e.GetPosition((IInputElement)cnvPaint);
                        TabControl lbl = new TabControl();
                        //lbl.Content = "TabControl";
                        lbl.HorizontalContentAlignment = HorizontalAlignment.Center;
                        lbl.Height = 25;
                        lbl.Width = 100;
                        lbl.PreviewMouseDown += new MouseButtonEventHandler(tabDrag999_PreviewMouseDown);
                        lbl.SetValue(Canvas.LeftProperty, 10.0);
                        lbl.SetValue(Canvas.TopProperty, 10.0);

                        ctlPOD objPOD = new ctlPOD();
                        objPOD.cnvPOD.Children.Add(lbl);
                        objPOD.AllowDrop = true;
                        objPOD.Height = 25;
                        objPOD.Width = 100;
                        objPOD.SetValue(Canvas.LeftProperty, p.X);
                        objPOD.SetValue(Canvas.TopProperty, p.Y);
                        MyPropGrid.ControlToBind = objPOD;
                        objPOD.KeyDown += new KeyEventHandler(objPOD_KeyDown);
                        objPOD.PreviewMouseDown += new MouseButtonEventHandler(objPOD_PreviewMouseDown);
                        currentControl = objPOD;
                        cnvPaint.Children.Add(objPOD);
                    }

                    else if ((((Canvas)((TabControl)e.Data.GetData(typeof(TabControl))).Parent).Parent).GetType() == typeof(ctlPOD))
                    {
                        Point p = e.GetPosition((IInputElement)cnvPaint);
                        ((Canvas)((TabControl)e.Data.GetData(typeof(TabControl))).Parent).Parent.SetValue(Canvas.LeftProperty, p.X - PrePoint.X);
                        ((Canvas)((TabControl)e.Data.GetData(typeof(TabControl))).Parent).Parent.SetValue(Canvas.TopProperty, p.Y - PrePoint.Y);

                    }

                }
                else if (e.Data.GetData(typeof(Label)) != null)
                {
                    if (((Canvas)((Label)e.Data.GetData(typeof(Label))).Parent).Name.ToString() == "cnvControls")
                    {
                        Point p = e.GetPosition((IInputElement)cnvPaint);
                        Label lbl = new Label();
                        lbl.Content = "Label";
                        lbl.HorizontalContentAlignment = HorizontalAlignment.Center;
                        lbl.Height = 25;
                        lbl.Width = 100;
                        lbl.PreviewMouseDown += new MouseButtonEventHandler(lblDrag_PreviewMouseDown);
                        lbl.SetValue(Canvas.LeftProperty, 10.0);
                        lbl.SetValue(Canvas.TopProperty, 10.0);

                        ctlPOD objPOD = new ctlPOD();
                        objPOD.cnvPOD.Children.Add(lbl);
                        objPOD.AllowDrop = true;
                        objPOD.Height = 25;
                        objPOD.Width = 100;
                        objPOD.SetValue(Canvas.LeftProperty, p.X);
                        objPOD.SetValue(Canvas.TopProperty, p.Y);
                        MyPropGrid.ControlToBind = objPOD;
                        objPOD.KeyDown += new KeyEventHandler(objPOD_KeyDown);
                        objPOD.PreviewMouseDown += new MouseButtonEventHandler(objPOD_PreviewMouseDown);
                        currentControl = objPOD;
                        cnvPaint.Children.Add(objPOD);
                    }

                    else if ((((Canvas)((Label)e.Data.GetData(typeof(Label))).Parent).Parent).GetType() == typeof(ctlPOD))
                    {
                        Point p = e.GetPosition((IInputElement)cnvPaint);
                        ((Canvas)((Label)e.Data.GetData(typeof(Label))).Parent).Parent.SetValue(Canvas.LeftProperty, p.X - PrePoint.X);
                        ((Canvas)((Label)e.Data.GetData(typeof(Label))).Parent).Parent.SetValue(Canvas.TopProperty, p.Y - PrePoint.Y);

                    }
                }

                else if (e.Data.GetData(typeof(TextBox)) != null)
                {
                    if (((Canvas)((TextBox)e.Data.GetData(typeof(TextBox))).Parent).Name.ToString() == "cnvControls")
                    {
                        Point p = e.GetPosition((IInputElement)cnvPaint);
                        TextBox txt = new TextBox();
                        txt.IsReadOnly = true;
                        txt.Cursor = Cursors.Arrow;
                        txt.Height = 25;
                        txt.Width = 100;
                        txt.Text = "TextBox";
                        txt.MouseDown += new MouseButtonEventHandler(txt_MouseDown);
                        txt.PreviewMouseDown += new MouseButtonEventHandler(txtDrag_PreviewMouseDown);
                        txt.SetValue(Canvas.LeftProperty, 10.0);
                        txt.SetValue(Canvas.TopProperty, 10.0);

                        ctlPOD objPOD = new ctlPOD();
                        objPOD.AllowDrop = true;
                        objPOD.Height = 25;
                        objPOD.Width = 100;
                        objPOD.PreviewMouseDown += new MouseButtonEventHandler(objPOD_PreviewMouseDown);
                        objPOD.SetValue(Canvas.LeftProperty, p.X);
                        objPOD.SetValue(Canvas.TopProperty, p.Y);
                        MyPropGrid.ControlToBind = objPOD;
                        objPOD.cnvPOD.Children.Add(txt);
                        currentControl = objPOD;
                        cnvPaint.Children.Add(objPOD);
                    }
                    else if ((((Canvas)((TextBox)e.Data.GetData(typeof(TextBox))).Parent).Parent).GetType() == typeof(ctlPOD))
                    {
                        Point p = e.GetPosition((IInputElement)cnvPaint);
                        ((Canvas)((TextBox)e.Data.GetData(typeof(TextBox))).Parent).Parent.SetValue(Canvas.LeftProperty, p.X - PrePoint.X);
                        ((Canvas)((TextBox)e.Data.GetData(typeof(TextBox))).Parent).Parent.SetValue(Canvas.TopProperty, p.Y - PrePoint.Y);
                    }
                }


                else if (e.Data.GetData(typeof(ComboBox)) != null)
                {
                    if (((Canvas)((ComboBox)e.Data.GetData(typeof(ComboBox))).Parent).Name.ToString() == "cnvControls")
                    {
                        Point p = e.GetPosition((IInputElement)cnvPaint);
                        ComboBox cmb = new ComboBox();
                        cmb.Cursor = Cursors.Arrow;
                        cmb.Height = 25;
                        cmb.Width = 100;
                        cmb.Text = "ComboBox";
                        cmb.PreviewMouseDown += new MouseButtonEventHandler(cmb_PreviewMouseDown);
                        cmb.SetValue(Canvas.LeftProperty, 10.0);
                        cmb.SetValue(Canvas.TopProperty, 10.0);

                        ctlPOD objPOD = new ctlPOD();
                        objPOD.AllowDrop = true;
                        objPOD.Height = 25;
                        objPOD.Width = 100;
                        objPOD.PreviewMouseDown += new MouseButtonEventHandler(objPOD_PreviewMouseDown);
                        objPOD.SetValue(Canvas.LeftProperty, p.X);
                        objPOD.SetValue(Canvas.TopProperty, p.Y);
                        MyPropGrid.ControlToBind = objPOD;
                        objPOD.cnvPOD.Children.Add(cmb);
                        currentControl = objPOD;
                        cnvPaint.Children.Add(objPOD);
                    }
                    else if ((((Canvas)((ComboBox)e.Data.GetData(typeof(ComboBox))).Parent).Parent).GetType() == typeof(ctlPOD))
                    {
                        Point p = e.GetPosition((IInputElement)cnvPaint);
                        ((Canvas)((ComboBox)e.Data.GetData(typeof(ComboBox))).Parent).Parent.SetValue(Canvas.LeftProperty, p.X - PrePoint.X);
                        ((Canvas)((ComboBox)e.Data.GetData(typeof(ComboBox))).Parent).Parent.SetValue(Canvas.TopProperty, p.Y - PrePoint.Y);
                    }
                }

                else if (e.Data.GetData(typeof(ListBox)) != null)
                {
                    if (((Canvas)((ListBox)e.Data.GetData(typeof(ListBox))).Parent).Name.ToString() == "cnvControls")
                    {
                        Point p = e.GetPosition((IInputElement)cnvPaint);
                        ListBox lst = new ListBox();
                        lst.Cursor = Cursors.Arrow;
                        lst.Height = 25;
                        lst.Width = 100;
                        lst.PreviewMouseDown += new MouseButtonEventHandler(lst_PreviewMouseDown);
                        lst.SetValue(Canvas.LeftProperty, 10.0);
                        lst.SetValue(Canvas.TopProperty, 10.0);

                        ctlPOD objPOD = new ctlPOD();
                        objPOD.AllowDrop = true;
                        objPOD.Height = 25;
                        objPOD.Width = 100;
                        objPOD.PreviewMouseDown += new MouseButtonEventHandler(objPOD_PreviewMouseDown);
                        objPOD.SetValue(Canvas.LeftProperty, p.X);
                        objPOD.SetValue(Canvas.TopProperty, p.Y);
                        MyPropGrid.ControlToBind = objPOD;
                        objPOD.cnvPOD.Children.Add(lst);
                        currentControl = objPOD;
                        cnvPaint.Children.Add(objPOD);
                    }
                    else if ((((Canvas)((ListBox)e.Data.GetData(typeof(ListBox))).Parent).Parent).GetType() == typeof(ctlPOD))
                    {
                        Point p = e.GetPosition((IInputElement)cnvPaint);
                        ((Canvas)((ListBox)e.Data.GetData(typeof(ListBox))).Parent).Parent.SetValue(Canvas.LeftProperty, p.X - PrePoint.X);
                        ((Canvas)((ListBox)e.Data.GetData(typeof(ListBox))).Parent).Parent.SetValue(Canvas.TopProperty, p.Y - PrePoint.Y);
                    }
                }

                else if (e.Data.GetData(typeof(CheckBox)) != null)
                {
                    if (((Canvas)((CheckBox)e.Data.GetData(typeof(CheckBox))).Parent).Name.ToString() == "cnvControls")
                    {
                        Point p = e.GetPosition((IInputElement)cnvPaint);
                        CheckBox chk = new CheckBox();
                        chk.Cursor = Cursors.Arrow;
                        chk.Height = 25;
                        chk.Width = 100;
                        chk.Content = "Check Box";
                        chk.PreviewMouseDown += new MouseButtonEventHandler(chk_PreviewMouseDown);
                        chk.SetValue(Canvas.LeftProperty, 10.0);
                        chk.SetValue(Canvas.TopProperty, 10.0);

                        ctlPOD objPOD = new ctlPOD();
                        objPOD.AllowDrop = true;
                        objPOD.Height = 25;
                        objPOD.Width = 100;
                        objPOD.PreviewMouseDown += new MouseButtonEventHandler(objPOD_PreviewMouseDown);
                        objPOD.SetValue(Canvas.LeftProperty, p.X);
                        objPOD.SetValue(Canvas.TopProperty, p.Y);
                        MyPropGrid.ControlToBind = objPOD;
                        objPOD.cnvPOD.Children.Add(chk);
                        currentControl = objPOD;
                        cnvPaint.Children.Add(objPOD);
                    }
                    else if ((((Canvas)((CheckBox)e.Data.GetData(typeof(CheckBox))).Parent).Parent).GetType() == typeof(ctlPOD))
                    {
                        Point p = e.GetPosition((IInputElement)cnvPaint);
                        ((Canvas)((CheckBox)e.Data.GetData(typeof(CheckBox))).Parent).Parent.SetValue(Canvas.LeftProperty, p.X - PrePoint.X);
                        ((Canvas)((CheckBox)e.Data.GetData(typeof(CheckBox))).Parent).Parent.SetValue(Canvas.TopProperty, p.Y - PrePoint.Y);
                    }
                }

                else if (e.Data.GetData(typeof(RadioButton)) != null)
                {
                    if (((Canvas)((RadioButton)e.Data.GetData(typeof(RadioButton))).Parent).Name.ToString() == "cnvControls")
                    {
                        Point p = e.GetPosition((IInputElement)cnvPaint);
                        RadioButton rad = new RadioButton();
                        rad.Cursor = Cursors.Arrow;
                        rad.Height = 25;
                        rad.Width = 100;
                        rad.Content = "Radio Button";
                        rad.PreviewMouseDown += new MouseButtonEventHandler(rad_PreviewMouseDown);
                        rad.SetValue(Canvas.LeftProperty, 10.0);
                        rad.SetValue(Canvas.TopProperty, 10.0);

                        ctlPOD objPOD = new ctlPOD();
                        objPOD.AllowDrop = true;
                        objPOD.Height = 25;
                        objPOD.Width = 100;
                        objPOD.PreviewMouseDown += new MouseButtonEventHandler(objPOD_PreviewMouseDown);
                        objPOD.SetValue(Canvas.LeftProperty, p.X);
                        objPOD.SetValue(Canvas.TopProperty, p.Y);
                        MyPropGrid.ControlToBind = objPOD;
                        objPOD.cnvPOD.Children.Add(rad);
                        currentControl = objPOD;
                        cnvPaint.Children.Add(objPOD);
                    }
                    else if ((((Canvas)((RadioButton)e.Data.GetData(typeof(RadioButton))).Parent).Parent).GetType() == typeof(ctlPOD))
                    {
                        Point p = e.GetPosition((IInputElement)cnvPaint);
                        ((Canvas)((RadioButton)e.Data.GetData(typeof(RadioButton))).Parent).Parent.SetValue(Canvas.LeftProperty, p.X - PrePoint.X);
                        ((Canvas)((RadioButton)e.Data.GetData(typeof(RadioButton))).Parent).Parent.SetValue(Canvas.TopProperty, p.Y - PrePoint.Y);
                    }
                }

                newDrag = 1;
                r1.Visibility = Visibility.Collapsed;
                MyPropGrid.ControlToBind = currentControl;
            }
            catch (Exception ex)
            {
                ex.Data.Add("My Key", "VMukti--:--VmuktiModules--:--Call Center--:--CRMDesigner--:--CRMDesigner.Presentation--:--ctlCRMDesigner.xaml.cs--:--cnvPaint_Drop()--");
                //ClsException.LogError(ex);
                //ClsException.WriteToErrorLogFile(ex);
                System.Text.StringBuilder sb = new StringBuilder();
                sb.AppendLine(ex.Message);
                sb.AppendLine();
                sb.AppendLine("StackTrace : " + ex.StackTrace);
                sb.AppendLine();
                sb.AppendLine("Location : " + ex.Data["My Key"].ToString());
                sb.AppendLine();
                sb1 = CreateTressInfo();
                sb.Append(sb1.ToString());
                VMuktiAPI.ClsLogging.WriteToTresslog(sb);
            }
        }
 public static void SetIsBroughtIntoViewWhenInserted(ListBox listBox, bool value)
 {
     listBox.SetValue(IsBroughtIntoViewWhenInsertedProperty, value);
 }
Example #22
0
        public void RenderPointMap(DashboardHelper dashboardHelper, string latVar, string longVar, Brush pointColor, string timeVar, SimpleMarkerSymbol.SimpleMarkerStyle style, string description)
        {
            this.dashboardHelper = dashboardHelper;
            this.latVar          = latVar;
            this.longVar         = longVar;
            this.timeVar         = timeVar;
            this.style           = style;
            this.description     = description;
            this.pointColor      = (SolidColorBrush)pointColor;

            GraphicsLayer pointLayer = myMap.Layers[layerId.ToString()] as GraphicsLayer;

            if (pointLayer != null)
            {
                pointLayer.Graphics.Clear();
            }
            else
            {
                pointLayer    = new GraphicsLayer();
                pointLayer.ID = layerId.ToString();
                myMap.Layers.Add(pointLayer);
            }

            CustomCoordinateList coordinateList = GetCoordinates(dashboardHelper, latVar, longVar, timeVar);

            for (int i = 0; i < coordinateList.Coordinates.Count; i++)
            {
                ExtendedGraphic graphic = new ExtendedGraphic()
                {
                    Geometry = new MapPoint(coordinateList.Coordinates[i].X, coordinateList.Coordinates[i].Y, geoReference),
                    RecordId = coordinateList.Coordinates[i].RecordId,
                    Symbol   = MarkerSymbol
                };
                if (coordinateList.Coordinates[i].TimeSpan.HasValue)
                {
                    graphic.TimeExtent = new TimeExtent(coordinateList.Coordinates[i].TimeSpan.Value);
                }
                else
                {
                    graphic.TimeExtent = new TimeExtent(DateTime.MinValue, DateTime.MaxValue);
                }
                graphic.MouseLeftButtonUp += new MouseButtonEventHandler(graphic_MouseLeftButtonUp);
                pointLayer.Graphics.Add(graphic);
            }

            if (LegendStackPanel == null)
            {
                LegendStackPanel = new StackPanel();
            }

            LegendStackPanel.Children.Clear();

            if (string.IsNullOrEmpty(description))
            {
                description = SharedStrings.CASES;
            }

            if (!string.IsNullOrEmpty(description))
            {
                System.Windows.Controls.ListBox legendList = new System.Windows.Controls.ListBox();
                legendList.Padding         = new Thickness(0, 10, 0, 0);
                legendList.Background      = Brushes.White;
                legendList.BorderBrush     = Brushes.Black;
                legendList.BorderThickness = new Thickness(0);
                legendList.SetValue(ScrollViewer.HorizontalScrollBarVisibilityProperty, ScrollBarVisibility.Disabled);

                TextBlock classTextBlock = new TextBlock();
                classTextBlock.Text                = description;
                classTextBlock.FontFamily          = new FontFamily("Segoe");
                classTextBlock.FontSize            = 12;
                classTextBlock.MaxWidth            = 256;
                classTextBlock.TextWrapping        = TextWrapping.Wrap;
                classTextBlock.HorizontalAlignment = HorizontalAlignment.Center;
                classTextBlock.VerticalAlignment   = VerticalAlignment.Center;
                classTextBlock.SetValue(ScrollViewer.HorizontalScrollBarVisibilityProperty, ScrollBarVisibility.Disabled);

                TextBlock symbolTextBlock = new TextBlock();
                switch (style)
                {
                case SimpleMarkerSymbol.SimpleMarkerStyle.Circle:
                    symbolTextBlock.Text     = "●";
                    symbolTextBlock.FontSize = 16;
                    break;

                case SimpleMarkerSymbol.SimpleMarkerStyle.Cross:
                    symbolTextBlock.Text       = "+";
                    symbolTextBlock.FontSize   = 18;
                    symbolTextBlock.FontWeight = FontWeights.Bold;
                    break;

                case SimpleMarkerSymbol.SimpleMarkerStyle.Diamond:
                    symbolTextBlock.Text     = "♦";
                    symbolTextBlock.FontSize = 17;
                    break;

                case SimpleMarkerSymbol.SimpleMarkerStyle.Square:
                    symbolTextBlock.Text     = "■";
                    symbolTextBlock.FontSize = 16;
                    break;

                case SimpleMarkerSymbol.SimpleMarkerStyle.Triangle:
                    symbolTextBlock.Text     = "▲";
                    symbolTextBlock.FontSize = 16;
                    break;

                default:
                    symbolTextBlock.Text     = "▲";
                    symbolTextBlock.FontSize = 16;
                    break;
                }
                symbolTextBlock.FontSize = 28;

                symbolTextBlock.VerticalAlignment = VerticalAlignment.Top;
                symbolTextBlock.Margin            = new Thickness(0, 4, 7, 4);
                symbolTextBlock.Foreground        = this.pointColor;

                StackPanel classStackPanel = new StackPanel();
                classStackPanel.Margin      = new Thickness(10, 0, 10, 10);
                classStackPanel.Orientation = System.Windows.Controls.Orientation.Horizontal;
                classStackPanel.Children.Add(symbolTextBlock);
                classStackPanel.Children.Add(classTextBlock);

                legendList.Items.Add(classStackPanel);

                LegendStackPanel.Children.Add(legendList);
            }

            if (coordinateList.Coordinates.Count > 0)
            {
                myMap.Extent = new Envelope(ESRI.ArcGIS.Client.Bing.Transform.GeographicToWebMercator(new MapPoint(minX - 0.01, minY - 0.01, geoReference)), ESRI.ArcGIS.Client.Bing.Transform.GeographicToWebMercator(new MapPoint(maxX + 0.01, maxY + 0.01, geoReference)));
                if (!string.IsNullOrEmpty(timeVar))
                {
                    if (minTime != null && maxTime != null)
                    {
                        intervalCounts = new List <KeyValuePair <DateTime, int> >();
                        DateTime previousInterval        = DateTime.MinValue;
                        IEnumerable <DateTime> intervals = TimeSlider.CreateTimeStopsByTimeInterval(new TimeExtent(minTime, maxTime), new TimeSpan(1, 0, 0, 0));
                        foreach (DateTime interval in intervals)
                        {
                            int count = pointLayer.Graphics.Count(x => x.TimeExtent.Start <= interval && x.TimeExtent.Start >= previousInterval);
                            intervalCounts.Add(new KeyValuePair <DateTime, int>(interval.Date, count));
                            previousInterval = interval;
                        }
                        if (DateRangeDefined != null)
                        {
                            DateRangeDefined(minTime, maxTime, intervalCounts);
                        }
                    }
                }
            }
        }
Example #23
0
        //Currently creates numeric text boxes
        public void createSocket(string type, bool multiple)
        {
            SocketDragDropTarget target = new SocketDragDropTarget();
            target.socketType = type;

            Style style = new Style(typeof(ListBoxItem));
            style.Setters.Add(new Setter(ListBoxItem.PaddingProperty, new Thickness(-1)));

            if (type.Contains("CONDITION"))
                target.isCondition = true;
            if (type.Contains("CONSTANT"))
                target.isConstant = true;

            ListBox listBox = new ListBox();
            listBox.Height = LayoutRoot.Height - 2;
            listBox.SetValue(ScrollViewer.HorizontalScrollBarVisibilityProperty, ScrollBarVisibility.Hidden);
            listBox.ItemContainerStyle = style;
            /*if (multiple)
            {
                listBox.Width = LayoutRoot.Width * .6;
                //listBox.MinWidth = LayoutRoot.Width * .75;

                //listBox.Width = LayoutRoot.Width * .33;//175;
            }
            else*/
                listBox.Width = LayoutRoot.Width * .75;//350;

            listBox.BorderThickness = new Thickness(2);
            listBox.Background = new SolidColorBrush(Colors.LightGray);
            target.Content = listBox;
            innerPane.Children.Add(target);
        }
Example #24
0
        public void ListFollowings()
        {
            this.Dispatch(() =>
            {
                TabItem ti = new TabItem();

                StackPanel h = new StackPanel();
                h.Orientation = Orientation.Horizontal;
                TextBlock tx = new TextBlock { Text = String.Format(MessageHeaderUserFollowingFormat, ViewingUser.ScreenName) };
                Button cl = new Button();
                cl.Margin = new Thickness(2);
                cl.Content = new TextBlock { FontFamily = new FontFamily("Marlett"), FontSize = 7, Text = "r" };
                cl.Tag = ti;
                cl.Click += cl_Click;
                cl.Template = GetTemplate("FlatButton");
                cl.Background = Brushes.LightGray;
                h.Children.Add(tx);
                h.Children.Add(cl);
                ti.Header = h;

                ListBox lb = new ListBox();
                lb.SetValue(ScrollViewer.HorizontalScrollBarVisibilityProperty, ScrollBarVisibility.Auto);
                lb.HorizontalContentAlignment = HorizontalAlignment.Stretch;
                lb.SetValue(ScrollViewer.CanContentScrollProperty, false);
                ti.Content = lb;
                MainTab.Items.Add(ti);
                MainTab.SelectedItem = ti;
                Service.ListFriends(new ListFriendsOptions { UserId = ViewingUser.Id, Count = (byte)ListFollowingCount }, (tl, res) =>
                {
                    lb.Dispatch(() =>
                    {
                        //TwitterState.Dispatch(() => TwitterState.Content = res.ToString());
                        if (tl == null) return;
                        foreach (var u in tl)
                        {
                            lb.Items.Add(CreateUserPanel(u));
                        }

                        if (tl.NextCursor == 0) return;
                        Button morefw = new Button();
                        morefw.Content = "さらに表示";
                        morefw.Click += morefr_Click;
                        morefw.Tag = new FFInfo { Cursor = tl.NextCursor, User = ViewingUser, TargetListBox = lb };
                        lb.Items.Add(morefw);
                    });

                });
            });
        }
 public static void SetListBoxMouseWheelScroller(ListBox element, ListBoxMouseWheelScroller value) { element.SetValue(ListBoxMouseWheelScrollerProperty, value); }
Example #26
0
 private static void SetChangedHandler(ListBox obj, ListChangedHandler value)
 {
     obj.SetValue(ChangedHandlerProperty, value);
 }
Example #27
0
 public static void SetIsListboxItemBringIntoView(ListBox listBox, bool value)
 {
     listBox.SetValue(IsListboxItemBringIntoViewProperty, value);
 }
Example #28
0
 public static void SetIsActivatable(ListBox obj, bool value)
 {
     obj.SetValue(IsActivatableProperty, value);
 }
        void cnvPaint_Drop(object sender, DragEventArgs e)
        {
            try
            {
                if (e.Data.GetData(typeof(Button)) != null)
                {
                    if (((Canvas)((Button)e.Data.GetData(typeof(Button))).Parent).Name.ToString() == "cnvControls")
                    {

                        Point p = e.GetPosition((IInputElement)cnvPaint);
                        Button btn = new Button();
                        btn.Height = 25;
                        btn.Width = 100;
                        btn.Content = "Button";
                        btn.PreviewMouseDown += new MouseButtonEventHandler(btnDrag_PreviewMouseDown);
                        btn.SetValue(Canvas.LeftProperty, 10.0);
                        btn.SetValue(Canvas.TopProperty, 10.0);

                        ctlPOD objPOD = new ctlPOD();
                        objPOD.AllowDrop = true;
                        objPOD.Height = 25;
                        objPOD.Width = 100;
                        objPOD.PreviewMouseDown += new MouseButtonEventHandler(objPOD_PreviewMouseDown);
                        objPOD.SetValue(Canvas.LeftProperty, p.X);
                        objPOD.SetValue(Canvas.TopProperty, p.Y);
                        MyPropGrid.ControlToBind = objPOD;
                        objPOD.cnvPOD.Children.Add(btn);
                        currentControl = objPOD;
                        cnvPaint.Children.Add(objPOD);
                    }
                    else if ((((Canvas)((Button)e.Data.GetData(typeof(Button))).Parent).Parent).GetType() == typeof(ctlPOD))
                    {
                        if (currentControl.rect.Visibility == Visibility.Visible)
                        {
                            Point p = e.GetPosition((IInputElement)cnvPaint);
                            ((Canvas)((Button)e.Data.GetData(typeof(Button))).Parent).Parent.SetValue(Canvas.LeftProperty, p.X - PrePoint.X);
                            ((Canvas)((Button)e.Data.GetData(typeof(Button))).Parent).Parent.SetValue(Canvas.TopProperty, p.Y - PrePoint.Y);
                        }
                    }
                }
                else if (e.Data.GetData(typeof(TabControl)) != null)
                {
                    if (((Canvas)((TabControl)e.Data.GetData(typeof(TabControl))).Parent).Name.ToString() == "cnvControls")
                    {
                        Point p = e.GetPosition((IInputElement)cnvPaint);
                        TabControl lbl = new TabControl();
                        //lbl.Content = "TabControl";
                        lbl.HorizontalContentAlignment = HorizontalAlignment.Center;
                        lbl.Height = 25;
                        lbl.Width = 100;
                        lbl.PreviewMouseDown += new MouseButtonEventHandler(tabDrag999_PreviewMouseDown);
                        lbl.SetValue(Canvas.LeftProperty, 10.0);
                        lbl.SetValue(Canvas.TopProperty, 10.0);

                        ctlPOD objPOD = new ctlPOD();
                        objPOD.cnvPOD.Children.Add(lbl);
                        objPOD.AllowDrop = true;
                        objPOD.Height = 25;
                        objPOD.Width = 100;
                        objPOD.SetValue(Canvas.LeftProperty, p.X);
                        objPOD.SetValue(Canvas.TopProperty, p.Y);
                        MyPropGrid.ControlToBind = objPOD;
                        objPOD.KeyDown += new KeyEventHandler(objPOD_KeyDown);
                        objPOD.PreviewMouseDown += new MouseButtonEventHandler(objPOD_PreviewMouseDown);
                        currentControl = objPOD;
                        cnvPaint.Children.Add(objPOD);
                    }

                    else if ((((Canvas)((TabControl)e.Data.GetData(typeof(TabControl))).Parent).Parent).GetType() == typeof(ctlPOD))
                    {
                        Point p = e.GetPosition((IInputElement)cnvPaint);
                        ((Canvas)((TabControl)e.Data.GetData(typeof(TabControl))).Parent).Parent.SetValue(Canvas.LeftProperty, p.X - PrePoint.X);
                        ((Canvas)((TabControl)e.Data.GetData(typeof(TabControl))).Parent).Parent.SetValue(Canvas.TopProperty, p.Y - PrePoint.Y);

                    }

                }
                else if (e.Data.GetData(typeof(Label)) != null)
                {
                    if (((Canvas)((Label)e.Data.GetData(typeof(Label))).Parent).Name.ToString() == "cnvControls")
                    {
                        Point p = e.GetPosition((IInputElement)cnvPaint);
                        Label lbl = new Label();
                        lbl.Content = "Label";
                        lbl.HorizontalContentAlignment = HorizontalAlignment.Center;
                        lbl.Height = 25;
                        lbl.Width = 100;
                        lbl.PreviewMouseDown += new MouseButtonEventHandler(lblDrag_PreviewMouseDown);
                        lbl.SetValue(Canvas.LeftProperty, 10.0);
                        lbl.SetValue(Canvas.TopProperty, 10.0);

                        ctlPOD objPOD = new ctlPOD();
                        objPOD.cnvPOD.Children.Add(lbl);
                        objPOD.AllowDrop = true;
                        objPOD.Height = 25;
                        objPOD.Width = 100;
                        objPOD.SetValue(Canvas.LeftProperty, p.X);
                        objPOD.SetValue(Canvas.TopProperty, p.Y);
                        MyPropGrid.ControlToBind = objPOD;
                        objPOD.KeyDown += new KeyEventHandler(objPOD_KeyDown);
                        objPOD.PreviewMouseDown += new MouseButtonEventHandler(objPOD_PreviewMouseDown);
                        currentControl = objPOD;
                        cnvPaint.Children.Add(objPOD);
                    }

                    else if ((((Canvas)((Label)e.Data.GetData(typeof(Label))).Parent).Parent).GetType() == typeof(ctlPOD))
                    {
                        Point p = e.GetPosition((IInputElement)cnvPaint);
                        ((Canvas)((Label)e.Data.GetData(typeof(Label))).Parent).Parent.SetValue(Canvas.LeftProperty, p.X - PrePoint.X);
                        ((Canvas)((Label)e.Data.GetData(typeof(Label))).Parent).Parent.SetValue(Canvas.TopProperty, p.Y - PrePoint.Y);

                    }
                }

                else if (e.Data.GetData(typeof(TextBox)) != null)
                {
                    if (((Canvas)((TextBox)e.Data.GetData(typeof(TextBox))).Parent).Name.ToString() == "cnvControls")
                    {
                        Point p = e.GetPosition((IInputElement)cnvPaint);
                        TextBox txt = new TextBox();
                        txt.IsReadOnly = true;
                        txt.Cursor = Cursors.Arrow;
                        txt.Height = 25;
                        txt.Width = 100;
                        txt.Text = "TextBox";
                        txt.MouseDown += new MouseButtonEventHandler(txt_MouseDown);
                        txt.PreviewMouseDown += new MouseButtonEventHandler(txtDrag_PreviewMouseDown);
                        txt.SetValue(Canvas.LeftProperty, 10.0);
                        txt.SetValue(Canvas.TopProperty, 10.0);

                        ctlPOD objPOD = new ctlPOD();
                        objPOD.AllowDrop = true;
                        objPOD.Height = 25;
                        objPOD.Width = 100;
                        objPOD.PreviewMouseDown += new MouseButtonEventHandler(objPOD_PreviewMouseDown);
                        objPOD.SetValue(Canvas.LeftProperty, p.X);
                        objPOD.SetValue(Canvas.TopProperty, p.Y);
                        MyPropGrid.ControlToBind = objPOD;
                        objPOD.cnvPOD.Children.Add(txt);
                        currentControl = objPOD;
                        cnvPaint.Children.Add(objPOD);
                    }
                    else if ((((Canvas)((TextBox)e.Data.GetData(typeof(TextBox))).Parent).Parent).GetType() == typeof(ctlPOD))
                    {
                        Point p = e.GetPosition((IInputElement)cnvPaint);
                        ((Canvas)((TextBox)e.Data.GetData(typeof(TextBox))).Parent).Parent.SetValue(Canvas.LeftProperty, p.X - PrePoint.X);
                        ((Canvas)((TextBox)e.Data.GetData(typeof(TextBox))).Parent).Parent.SetValue(Canvas.TopProperty, p.Y - PrePoint.Y);
                    }
                }


                else if (e.Data.GetData(typeof(ComboBox)) != null)
                {
                    if (((Canvas)((ComboBox)e.Data.GetData(typeof(ComboBox))).Parent).Name.ToString() == "cnvControls")
                    {
                        Point p = e.GetPosition((IInputElement)cnvPaint);
                        ComboBox cmb = new ComboBox();
                        cmb.Cursor = Cursors.Arrow;
                        cmb.Height = 25;
                        cmb.Width = 100;
                        cmb.Text = "ComboBox";
                        cmb.PreviewMouseDown += new MouseButtonEventHandler(cmb_PreviewMouseDown);
                        cmb.SetValue(Canvas.LeftProperty, 10.0);
                        cmb.SetValue(Canvas.TopProperty, 10.0);

                        ctlPOD objPOD = new ctlPOD();
                        objPOD.AllowDrop = true;
                        objPOD.Height = 25;
                        objPOD.Width = 100;
                        objPOD.PreviewMouseDown += new MouseButtonEventHandler(objPOD_PreviewMouseDown);
                        objPOD.SetValue(Canvas.LeftProperty, p.X);
                        objPOD.SetValue(Canvas.TopProperty, p.Y);
                        MyPropGrid.ControlToBind = objPOD;
                        objPOD.cnvPOD.Children.Add(cmb);
                        currentControl = objPOD;
                        cnvPaint.Children.Add(objPOD);
                    }
                    else if ((((Canvas)((ComboBox)e.Data.GetData(typeof(ComboBox))).Parent).Parent).GetType() == typeof(ctlPOD))
                    {
                        Point p = e.GetPosition((IInputElement)cnvPaint);
                        ((Canvas)((ComboBox)e.Data.GetData(typeof(ComboBox))).Parent).Parent.SetValue(Canvas.LeftProperty, p.X - PrePoint.X);
                        ((Canvas)((ComboBox)e.Data.GetData(typeof(ComboBox))).Parent).Parent.SetValue(Canvas.TopProperty, p.Y - PrePoint.Y);
                    }
                }

                else if (e.Data.GetData(typeof(ListBox)) != null)
                {
                    if (((Canvas)((ListBox)e.Data.GetData(typeof(ListBox))).Parent).Name.ToString() == "cnvControls")
                    {
                        Point p = e.GetPosition((IInputElement)cnvPaint);
                        ListBox lst = new ListBox();
                        lst.Cursor = Cursors.Arrow;
                        lst.Height = 25;
                        lst.Width = 100;
                        lst.PreviewMouseDown += new MouseButtonEventHandler(lst_PreviewMouseDown);
                        lst.SetValue(Canvas.LeftProperty, 10.0);
                        lst.SetValue(Canvas.TopProperty, 10.0);

                        ctlPOD objPOD = new ctlPOD();
                        objPOD.AllowDrop = true;
                        objPOD.Height = 25;
                        objPOD.Width = 100;
                        objPOD.PreviewMouseDown += new MouseButtonEventHandler(objPOD_PreviewMouseDown);
                        objPOD.SetValue(Canvas.LeftProperty, p.X);
                        objPOD.SetValue(Canvas.TopProperty, p.Y);
                        MyPropGrid.ControlToBind = objPOD;
                        objPOD.cnvPOD.Children.Add(lst);
                        currentControl = objPOD;
                        cnvPaint.Children.Add(objPOD);
                    }
                    else if ((((Canvas)((ListBox)e.Data.GetData(typeof(ListBox))).Parent).Parent).GetType() == typeof(ctlPOD))
                    {
                        Point p = e.GetPosition((IInputElement)cnvPaint);
                        ((Canvas)((ListBox)e.Data.GetData(typeof(ListBox))).Parent).Parent.SetValue(Canvas.LeftProperty, p.X - PrePoint.X);
                        ((Canvas)((ListBox)e.Data.GetData(typeof(ListBox))).Parent).Parent.SetValue(Canvas.TopProperty, p.Y - PrePoint.Y);
                    }
                }

                else if (e.Data.GetData(typeof(CheckBox)) != null)
                {
                    if (((Canvas)((CheckBox)e.Data.GetData(typeof(CheckBox))).Parent).Name.ToString() == "cnvControls")
                    {
                        Point p = e.GetPosition((IInputElement)cnvPaint);
                        CheckBox chk = new CheckBox();
                        chk.Cursor = Cursors.Arrow;
                        chk.Height = 25;
                        chk.Width = 100;
                        chk.Content = "Check Box";
                        chk.PreviewMouseDown += new MouseButtonEventHandler(chk_PreviewMouseDown);
                        chk.SetValue(Canvas.LeftProperty, 10.0);
                        chk.SetValue(Canvas.TopProperty, 10.0);

                        ctlPOD objPOD = new ctlPOD();
                        objPOD.AllowDrop = true;
                        objPOD.Height = 25;
                        objPOD.Width = 100;
                        objPOD.PreviewMouseDown += new MouseButtonEventHandler(objPOD_PreviewMouseDown);
                        objPOD.SetValue(Canvas.LeftProperty, p.X);
                        objPOD.SetValue(Canvas.TopProperty, p.Y);
                        MyPropGrid.ControlToBind = objPOD;
                        objPOD.cnvPOD.Children.Add(chk);
                        currentControl = objPOD;
                        cnvPaint.Children.Add(objPOD);
                    }
                    else if ((((Canvas)((CheckBox)e.Data.GetData(typeof(CheckBox))).Parent).Parent).GetType() == typeof(ctlPOD))
                    {
                        Point p = e.GetPosition((IInputElement)cnvPaint);
                        ((Canvas)((CheckBox)e.Data.GetData(typeof(CheckBox))).Parent).Parent.SetValue(Canvas.LeftProperty, p.X - PrePoint.X);
                        ((Canvas)((CheckBox)e.Data.GetData(typeof(CheckBox))).Parent).Parent.SetValue(Canvas.TopProperty, p.Y - PrePoint.Y);
                    }
                }

                else if (e.Data.GetData(typeof(RadioButton)) != null)
                {
                    if (((Canvas)((RadioButton)e.Data.GetData(typeof(RadioButton))).Parent).Name.ToString() == "cnvControls")
                    {
                        Point p = e.GetPosition((IInputElement)cnvPaint);
                        RadioButton rad = new RadioButton();
                        rad.Cursor = Cursors.Arrow;
                        rad.Height = 25;
                        rad.Width = 100;
                        rad.Content = "Radio Button";
                        rad.PreviewMouseDown += new MouseButtonEventHandler(rad_PreviewMouseDown);
                        rad.SetValue(Canvas.LeftProperty, 10.0);
                        rad.SetValue(Canvas.TopProperty, 10.0);

                        ctlPOD objPOD = new ctlPOD();
                        objPOD.AllowDrop = true;
                        objPOD.Height = 25;
                        objPOD.Width = 100;
                        objPOD.PreviewMouseDown += new MouseButtonEventHandler(objPOD_PreviewMouseDown);
                        objPOD.SetValue(Canvas.LeftProperty, p.X);
                        objPOD.SetValue(Canvas.TopProperty, p.Y);
                        MyPropGrid.ControlToBind = objPOD;
                        objPOD.cnvPOD.Children.Add(rad);
                        currentControl = objPOD;
                        cnvPaint.Children.Add(objPOD);
                    }
                    else if ((((Canvas)((RadioButton)e.Data.GetData(typeof(RadioButton))).Parent).Parent).GetType() == typeof(ctlPOD))
                    {
                        Point p = e.GetPosition((IInputElement)cnvPaint);
                        ((Canvas)((RadioButton)e.Data.GetData(typeof(RadioButton))).Parent).Parent.SetValue(Canvas.LeftProperty, p.X - PrePoint.X);
                        ((Canvas)((RadioButton)e.Data.GetData(typeof(RadioButton))).Parent).Parent.SetValue(Canvas.TopProperty, p.Y - PrePoint.Y);
                    }
                }

                newDrag = 1;
                r1.Visibility = Visibility.Collapsed;
                MyPropGrid.ControlToBind = currentControl;
            }
            catch (Exception ex)
            {
                VMuktiHelper.ExceptionHandler(ex, "cnvPaint_Drop()", "ctlCRMDesigner.xaml.cs");
            }
        }
 public static void SetIsAutoCenterItem(ListBox element, bool Value)
 {
     element.SetValue(IsAutoCenterItemProperty, Value);
 }
Example #31
0
        public void SetShapeRangeValues(DashboardHelper dashboardHelper, string shapeKey, string dataKey, string valueField, Color dotColor, int dotValue)
        {
            try
            {
                this.dotValue        = dotValue;
                this.dashboardHelper = dashboardHelper;
                this.shapeKey        = shapeKey;
                this.dataKey         = dataKey;
                this.valueField      = valueField;
                this.dotColor        = dotColor;

                List <string> columnNames = new List <string>();
                if (dashboardHelper.IsUsingEpiProject)
                {
                    columnNames.Add("UniqueKey");
                }
                columnNames.Add(valueField);
                columnNames.Add(dataKey);

                DataTable loadedData;

                if (valueField.Equals("{Record Count}"))
                {
                    GadgetParameters gadgetOptions = new GadgetParameters();
                    gadgetOptions.MainVariableName = dataKey;

                    Dictionary <string, string> inputVariableList = new Dictionary <string, string>();
                    inputVariableList.Add("freqvar", dataKey);
                    inputVariableList.Add("allvalues", "false");
                    inputVariableList.Add("showconflimits", "false");
                    inputVariableList.Add("showcumulativepercent", "false");
                    inputVariableList.Add("includemissing", "false");
                    inputVariableList.Add("maxrows", "500");

                    gadgetOptions.InputVariableList = inputVariableList;
                    loadedData = dashboardHelper.GenerateFrequencyTableforMap(gadgetOptions).First().Key;
                    foreach (DataRow dr in loadedData.Rows)
                    {
                        dr[0] = dr[0].ToString().Trim();
                    }
                    valueField = "freq";
                }
                else
                {
                    loadedData = dashboardHelper.GenerateTable(columnNames);
                }


                GraphicsLayer graphicsLayer = myMap.Layers[layerId.ToString()] as GraphicsLayer;

                List <double>    valueList         = new List <double>();
                List <Graphic>   graphicsToBeAdded = new List <Graphic>();
                SpatialReference geoReference      = new SpatialReference(4326);
                for (int i = 0; i < graphicsLayer.Graphics.Count; i++)
                {
                    Graphic graphicFeature = graphicsLayer.Graphics[i];

                    double xmin = graphicFeature.Geometry.Extent.XMin;
                    double xmax = graphicFeature.Geometry.Extent.XMax;
                    double ymin = graphicFeature.Geometry.Extent.YMin;
                    double ymax = graphicFeature.Geometry.Extent.YMax;

                    Random rnd = new Random();

                    string shapeValue = graphicFeature.Attributes[shapeKey].ToString().Replace("'", "''").Trim();


                    string filterExpression = "";
                    if (dataKey.Contains(" ") || dataKey.Contains("$") || dataKey.Contains("#"))
                    {
                        filterExpression += "[";
                    }
                    filterExpression += dataKey;
                    if (dataKey.Contains(" ") || dataKey.Contains("$") || dataKey.Contains("#"))
                    {
                        filterExpression += "]";
                    }
                    filterExpression += " = '" + shapeValue + "'";

                    double graphicValue = Double.PositiveInfinity;
                    try
                    {
                        graphicValue = Convert.ToDouble(loadedData.Select(filterExpression)[0][valueField]);

                        for (int counter = 0; counter < graphicValue; counter += dotValue)
                        {
                            bool pointInGraphic = false;

                            ExtendedGraphic graphic = new ExtendedGraphic();
                            while (!pointInGraphic)
                            {
                                double rndX = xmin + (rnd.NextDouble() * (xmax - xmin));
                                double rndY = ymin + (rnd.NextDouble() * (ymax - ymin));
                                graphic.Geometry = new MapPoint(rndX, rndY, geoReference);
                                graphic.Symbol   = MarkerSymbol;

                                bool foundBottomLeft  = false;
                                bool foundBottomRight = false;
                                bool foundTopLeft     = false;
                                bool foundTopRight    = false;
                                foreach (ESRI.ArcGIS.Client.Geometry.PointCollection pc in ((ESRI.ArcGIS.Client.Geometry.Polygon)graphicFeature.Geometry).Rings)
                                {
                                    foundBottomLeft  = pc.Any((point) => point.Y <= ((MapPoint)graphic.Geometry).Y && point.X <= ((MapPoint)graphic.Geometry).X);
                                    foundBottomRight = pc.Any((point) => point.Y <= ((MapPoint)graphic.Geometry).Y && point.X >= ((MapPoint)graphic.Geometry).X);
                                    foundTopLeft     = pc.Any((point) => point.Y >= ((MapPoint)graphic.Geometry).Y && point.X <= ((MapPoint)graphic.Geometry).X);
                                    foundTopRight    = pc.Any((point) => point.Y >= ((MapPoint)graphic.Geometry).Y && point.X >= ((MapPoint)graphic.Geometry).X);

                                    if (foundBottomLeft && foundBottomRight && foundTopLeft && foundTopRight)
                                    {
                                        try
                                        {
                                            MapPoint firstBottomLeft  = pc.First((point) => point.Y <= ((MapPoint)graphic.Geometry).Y && point.X <= ((MapPoint)graphic.Geometry).X);
                                            MapPoint firstBottomRight = pc.First((point) => point.Y <= ((MapPoint)graphic.Geometry).Y && point.X >= ((MapPoint)graphic.Geometry).X);
                                            MapPoint firstTopLeft     = pc.First((point) => point.Y >= ((MapPoint)graphic.Geometry).Y && point.X <= ((MapPoint)graphic.Geometry).X);
                                            MapPoint firstTopRight    = pc.First((point) => point.Y >= ((MapPoint)graphic.Geometry).Y && point.X >= ((MapPoint)graphic.Geometry).X);

                                            int indexBL = pc.IndexOf(firstBottomLeft);
                                            int indexBR = pc.IndexOf(firstBottomRight);
                                            int indexTL = pc.IndexOf(firstTopLeft);
                                            int indexTR = pc.IndexOf(firstTopRight);

                                            MapPoint lastBottomLeft  = pc.Last((point) => point.Y <= ((MapPoint)graphic.Geometry).Y && point.X <= ((MapPoint)graphic.Geometry).X);
                                            MapPoint lastBottomRight = pc.Last((point) => point.Y <= ((MapPoint)graphic.Geometry).Y && point.X >= ((MapPoint)graphic.Geometry).X);
                                            MapPoint lastTopLeft     = pc.Last((point) => point.Y >= ((MapPoint)graphic.Geometry).Y && point.X <= ((MapPoint)graphic.Geometry).X);
                                            MapPoint lastTopRight    = pc.Last((point) => point.Y >= ((MapPoint)graphic.Geometry).Y && point.X >= ((MapPoint)graphic.Geometry).X);

                                            int indexBL2 = pc.IndexOf(lastBottomLeft);
                                            int indexBR2 = pc.IndexOf(lastBottomRight);
                                            int indexTL2 = pc.IndexOf(lastTopLeft);
                                            int indexTR2 = pc.IndexOf(lastTopRight);

                                            if ((Math.Abs(indexTL - indexTR2) == 1 && Math.Abs(indexTR - indexBR2) == 1) || (Math.Abs(indexBL - indexTL2) == 1 && Math.Abs(indexTL - indexTR2) == 1) || (Math.Abs(indexBR - indexBL2) == 1 && Math.Abs(indexTR - indexBR2) == 1))
                                            {
                                                pointInGraphic = true;
                                                break;
                                            }
                                            else if ((Math.Abs(indexBL - indexBR2) == 1 && Math.Abs(indexTL - indexBL2) == 1) || (Math.Abs(indexTL - indexBL2) == 1 && Math.Abs(indexTR - indexTL2) == 1) || (Math.Abs(indexBR - indexTR2) == 1 && Math.Abs(indexTR - indexTL2) == 1))
                                            {
                                                pointInGraphic = true;
                                                break;
                                            }
                                        }
                                        catch (Exception ex)
                                        {
                                            pointInGraphic = false;
                                        }
                                    }
                                }
                            }
                            graphicsToBeAdded.Add(graphic);
                        }
                    }
                    catch (Exception ex)
                    {
                        graphicValue = Double.PositiveInfinity;
                    }
                }

                foreach (Graphic g in graphicsLayer.Graphics)
                {
                    SimpleFillSymbol symbol = new SimpleFillSymbol()
                    {
                        Fill            = new SolidColorBrush(Colors.Transparent),
                        BorderBrush     = new SolidColorBrush(Colors.Black),
                        BorderThickness = 1
                    };

                    g.Symbol = symbol;
                }

                GraphicsLayer dotLayer        = myMap.Layers[layerId.ToString() + "_dotLayer"] as GraphicsLayer;
                int           currentDotIndex = myMap.Layers.Count;
                if (dotLayer != null)
                {
                    currentDotIndex = myMap.Layers.IndexOf(dotLayer);
                    myMap.Layers.Remove(dotLayer);
                }
                dotLayer    = new GraphicsLayer();
                dotLayer.ID = layerId.ToString() + "_dotLayer";
                myMap.Layers.Insert(currentDotIndex, dotLayer);
                foreach (Graphic g in graphicsToBeAdded)
                {
                    dotLayer.Graphics.Add(g);
                }

                if (LegendStackPanel == null)
                {
                    LegendStackPanel = new StackPanel();
                }

                LegendStackPanel.Children.Clear();

                string description = "";

                if (string.IsNullOrEmpty(description))
                {
                    description = dotValue.ToString() + "  " + valueField;
                }

                System.Windows.Controls.ListBox legendList = new System.Windows.Controls.ListBox();
                legendList.Padding         = new Thickness(0, 10, 0, 0);
                legendList.Background      = Brushes.White;
                legendList.BorderBrush     = Brushes.Black;
                legendList.BorderThickness = new Thickness(0);
                legendList.SetValue(ScrollViewer.HorizontalScrollBarVisibilityProperty, ScrollBarVisibility.Disabled);

                TextBlock classTextBlock = new TextBlock();
                classTextBlock.Text                = description;
                classTextBlock.FontFamily          = new FontFamily("Segoe");
                classTextBlock.FontSize            = 12;
                classTextBlock.MaxWidth            = 256;
                classTextBlock.TextWrapping        = TextWrapping.Wrap;
                classTextBlock.HorizontalAlignment = HorizontalAlignment.Center;
                classTextBlock.VerticalAlignment   = VerticalAlignment.Center;
                classTextBlock.SetValue(ScrollViewer.HorizontalScrollBarVisibilityProperty, ScrollBarVisibility.Disabled);

                Ellipse circle = new Ellipse();
                circle.Width             = 14;
                circle.Height            = 14;
                circle.VerticalAlignment = VerticalAlignment.Top;
                circle.Margin            = new Thickness(0, 4, 7, 4);
                circle.Fill = new SolidColorBrush(dotColor);// this.clusterColor; //dpb

                StackPanel classStackPanel = new StackPanel();
                classStackPanel.Margin      = new Thickness(10, 0, 10, 10);
                classStackPanel.Orientation = System.Windows.Controls.Orientation.Horizontal;
                classStackPanel.Children.Add(circle);
                classStackPanel.Children.Add(classTextBlock);

                legendList.Items.Add(classStackPanel);

                LegendStackPanel.Children.Add(legendList);
            }
            catch (Exception ex)
            {
            }
        }
        private static void ResynchList(ListBox listBox)
        {
            if (listBox != null)
            {
                listBox.SetValue(IsResynchingPropertyKey, true);

                IList list = GetSelectedItemsSource(listBox);
                if (listBox.SelectionMode == SelectionMode.Single)
                {
                    listBox.SelectedItem = null; if (list != null)
                    {
                        if (list.Count > 1)
                        {
                            // There is more than one item selected, but the listbox is in Single selection mode
                            throw new InvalidOperationException("ListBox is in Single selection mode, but was given more than one selected value.");
                        }
                        if (list.Count == 1)
                            listBox.SelectedItem = list[0];
                    }
                }
                else
                {
                    listBox.SelectedItems.Clear();
                    if (list != null)
                    {
                        foreach (object obj in listBox.Items)
                        {
                            if (list.Contains(obj))
                                listBox.SelectedItems.Add(obj);
                        }
                    }
                }
                listBox.SetValue(IsResynchingPropertyKey, false);
            }
        }
        public void When_constructed_with_a_ListBox_then_selected_item_binder_is_set_to_selected_convention()
        {
            ListBox customerList = new ListBox();
            customerList.Name = "Customers";
            CustomerListViewModel vm = new CustomerListViewModel("Jeff", "Glenn");
            customerList.SetValue(ViewBinder.ModelProperty, vm);

            ListBinder<Customer, CustomerListViewModel> binder = new ListBinder<Customer, CustomerListViewModel>(customerList);
            Assert.AreEqual("SelectedCustomer", binder.SelectedItemBinder.TargetPath);
        }
Example #34
0
 public static void SetIsScrollIntoViewWhenSelected(System.Windows.Controls.ListBox obj, bool value)
 {
     obj.SetValue(IsScrollIntoViewWhenSelectedProperty, value);
 }
 public static void SetCommand(ListBox ListBox, ICommand command)
 {
     ListBox.SetValue(CommandProperty, command);
 }
        void FncSetInnerCanvas()
        {
            //cnvPaint.Height = 280;
            //cnvPaint.Width = 700;

            Label lblHeader = new Label();
            lblHeader.Content = "KLSCRM Designer";
            lblHeader.PreviewMouseDown += new MouseButtonEventHandler(lblDrag_PreviewMouseDown);
            lblHeader.FontSize = 19;

            ctlPOD objPOD1 = new ctlPOD();
            objPOD1.AllowDrop = true;
            objPOD1.Height = 45;
            objPOD1.Width = 700;
            objPOD1.PreviewMouseDown += new MouseButtonEventHandler(objPOD_PreviewMouseDown);
            objPOD1.SetValue(Canvas.LeftProperty, 25.0);
            objPOD1.SetValue(Canvas.TopProperty, 0.0);
            MyPropGrid.ControlToBind = objPOD1;
            objPOD1.cnvPOD.Children.Add(lblHeader);
            currentControl = objPOD1;
            cnvPaint.Children.Add(objPOD1);

            Label lblQuestion = new Label();
            lblQuestion.Content = "KLSCRM Designer2";
            lblQuestion.PreviewMouseDown += new MouseButtonEventHandler(lblDrag_PreviewMouseDown);
            lblQuestion.FontSize = 17;

            ctlPOD objPOD2 = new ctlPOD();
            objPOD2.AllowDrop = true;
            objPOD2.Height = 45;
            objPOD2.Width = 700;
            objPOD2.PreviewMouseDown += new MouseButtonEventHandler(objPOD_PreviewMouseDown);
            objPOD2.SetValue(Canvas.LeftProperty, 0.0);
            objPOD2.SetValue(Canvas.TopProperty, 60.0);
            MyPropGrid.ControlToBind = objPOD2;
            objPOD2.cnvPOD.Children.Add(lblQuestion);
            currentControl = objPOD2;
            cnvPaint.Children.Add(objPOD2);

            ClsOptionCollection objOptCollection = ClsOptionCollection.GetAll(objQueCollection[CurrentQueCount].ID);

            varType = objQueCollection[CurrentQueCount].Category;

            if (varType == "CheckBox")
            {
                for (int i = 0; i < objOptCollection.Count; i++)
                {
                    CheckBox chk = new CheckBox();
                    chk.Content = objOptCollection[i].Options;
                    chk.Tag = objOptCollection[i].ActionQueueID.ToString() + "," + objOptCollection[i].ID.ToString();
                    chk.PreviewMouseDown += new MouseButtonEventHandler(chkDrag999_PreviewMouseDown);
                    chk.Height = 18;
                    chk.FontSize = 14;
                    varTop = 120 + (30 * i);

                    ctlPOD objPOD = new ctlPOD();
                    objPOD.AllowDrop = true;
                    objPOD.Height = 25;
                    objPOD.Width = 700;
                    objPOD.PreviewMouseDown += new MouseButtonEventHandler(objPOD_PreviewMouseDown);
                    objPOD.SetValue(Canvas.LeftProperty, 25.0);
                    objPOD.SetValue(Canvas.TopProperty, varTop);
                    MyPropGrid.ControlToBind = objPOD;
                    objPOD.cnvPOD.Children.Add(chk);
                    currentControl = objPOD;
                    cnvPaint.Children.Add(objPOD);
                }
            }
            else if (varType == "RadioButton")
            {
                for (int i = 0; i < objOptCollection.Count; i++)
                {
                    RadioButton chk = new RadioButton();
                    chk.Content = objOptCollection[i].Options;
                    chk.Tag = objOptCollection[i].ActionQueueID.ToString() + "," + objOptCollection[i].ID.ToString();
                    chk.PreviewMouseDown += new MouseButtonEventHandler(radDrag999_PreviewMouseDown);
                    chk.Height = 18;
                    chk.FontSize = 14;
                    varTop = 120 + (30 * i);

                    ctlPOD objPOD = new ctlPOD();
                    objPOD.AllowDrop = true;
                    objPOD.Height = 25;
                    objPOD.Width = 700;
                    objPOD.PreviewMouseDown += new MouseButtonEventHandler(objPOD_PreviewMouseDown);
                    objPOD.SetValue(Canvas.LeftProperty, 25.0);
                    objPOD.SetValue(Canvas.TopProperty, varTop);
                    MyPropGrid.ControlToBind = objPOD;
                    objPOD.cnvPOD.Children.Add(chk);
                    currentControl = objPOD;
                    cnvPaint.Children.Add(objPOD);
                }
            }
            else if (varType == "ListBox")
            {
                ListBox lst = new ListBox();
                lst.Height = 250;
                lst.Width = 700;
                lst.Tag = "code";
                lst.SetValue(Canvas.LeftProperty, 0.0);
                lst.SetValue(Canvas.TopProperty, 0.0);
                lst.PreviewMouseDown += new MouseButtonEventHandler(lstDrag999_PreviewMouseDown);
                //cnvMain.Children.Add(lst);

                for (int i = 0; i < objOptCollection.Count; i++)
                {
                    ListBoxItem lbi = new ListBoxItem();
                    //lbi.IsEnabled = false;
                    lbi.Content = objOptCollection[i].Options;
                    lbi.Tag = objOptCollection[i].ActionQueueID.ToString() + "," + objOptCollection[i].ID.ToString();
                    lst.Items.Add(lbi);
                }

                ctlPOD objPOD = new ctlPOD();
                objPOD.AllowDrop = true;
                objPOD.Height = 250;
                objPOD.Width = 700;
                objPOD.PreviewMouseDown += new MouseButtonEventHandler(objPOD_PreviewMouseDown);
                objPOD.SetValue(Canvas.LeftProperty, 25.0);
                objPOD.SetValue(Canvas.TopProperty, 120.0);
                MyPropGrid.ControlToBind = objPOD;
                objPOD.cnvPOD.Children.Add(lst);
                currentControl = objPOD;
                cnvPaint.Children.Add(objPOD);
            }
            else if (varType == "ComboBox")
            {
                ComboBox cmb = new ComboBox();
                cmb.Height = 25;
                cmb.Width = 700;
                cmb.Tag = "code";
                cmb.PreviewMouseDown += new MouseButtonEventHandler(cmbDrag999_PreviewMouseDown);
                //lst.PreviewMouseDown += new MouseButtonEventHandler(lstDrag999_PreviewMouseDown);
                //cnvMain.Children.Add(lst);

                for (int i = 0; i < objOptCollection.Count; i++)
                {
                    ComboBoxItem cbi = new ComboBoxItem();
                    //cbi.IsEnabled = false;
                    cbi.Content = objOptCollection[i].Options;
                    cbi.Tag = objOptCollection[i].ActionQueueID.ToString() + "," + objOptCollection[i].ID.ToString();
                    cmb.Items.Add(cbi);
                }

                ctlPOD objPOD = new ctlPOD();
                objPOD.AllowDrop = true;
                objPOD.Height = 25;
                objPOD.Width = 700;
                objPOD.PreviewMouseDown += new MouseButtonEventHandler(objPOD_PreviewMouseDown);
                objPOD.SetValue(Canvas.LeftProperty, 25.0);
                objPOD.SetValue(Canvas.TopProperty, 120.0);
                MyPropGrid.ControlToBind = objPOD;
                objPOD.cnvPOD.Children.Add(cmb);
                currentControl = objPOD;
                cnvPaint.Children.Add(objPOD);
            }

            Button btnNext = new Button();
            btnNext.Content = "Next >> ";
            // To Identify That is has some coding and it's Next Button //
            btnNext.Tag = varType.ToString().ToLower();
            btnNext.PreviewMouseDown += new MouseButtonEventHandler(btnDrag_PreviewMouseDown);
            btnNext.FontSize = 16;

            ctlPOD objPOD3 = new ctlPOD();
            objPOD3.AllowDrop = true;
            objPOD3.Height = 35;
            objPOD3.Width = 100;
            objPOD3.PreviewMouseDown += new MouseButtonEventHandler(objPOD_PreviewMouseDown);
            objPOD3.SetValue(Canvas.LeftProperty, 25.0);

            if (varType.ToLower() != "listbox" && varType.ToLower() != "combobox")
            {
                objPOD3.SetValue(Canvas.TopProperty, varTop + 35.0);
            }
            else if (varType.ToLower() == "listbox")
            {
                objPOD3.SetValue(Canvas.TopProperty, 400.0);
            }
            else if (varType.ToLower() == "combobox")
            {
                objPOD3.SetValue(Canvas.TopProperty, 200.0);
            }

            MyPropGrid.ControlToBind = objPOD3;
            objPOD3.cnvPOD.Children.Add(btnNext);
            currentControl = objPOD3;
            cnvPaint.Children.Add(objPOD3);
            varTop = 0;
        }
        void FncNextQuestion()
        {
            try
            {
            cnvMain.Children.Clear();
            currentQuestion = -1;

            for (int i = 0; i < lstQuestions.Count; i++)
            {
                if (lstQuestions[i].Header == StartQuestion)
                {
                    currentQuestion = i;
                    break;
                }
            }

            if (currentQuestion == -1)
                goto exit;
            
            Label lblHeader = new Label();
            lblHeader.Content = lstQuestions[currentQuestion].Header;
            lblHeader.Height = 30;
            lblHeader.Width = 600;
            lblHeader.SetValue(Canvas.LeftProperty, 10.0);
            lblHeader.SetValue(Canvas.TopProperty, 10.0);

            if (lstQuestions[currentQuestion].Type == TypeOfOptions.RadioButton)
            {
                RadioButton[] rdo = new RadioButton[lstQuestions[currentQuestion].NoOfOptions];
                List<string> strOpt = lstQuestions[currentQuestion].Options;
                for (int i = 0; i < lstQuestions[currentQuestion].NoOfOptions; i++)
                {
                    rdo[i] = new RadioButton();
                    string[] str = strOpt[i].Split(new string[] {"*****"}, StringSplitOptions.None);
                    rdo[i].Content = str[0];
                    rdo[i].Tag = str[1];
                    rdo[i].Height = 25;
                    rdo[i].Width = 600;
                    rdo[i].SetValue(Canvas.LeftProperty, 80.0);
                    rdo[i].SetValue(Canvas.TopProperty, 10.0 + ((i + 1) * 30));
                    cnvMain.Children.Add(rdo[i]);
                }
            }

            else if (lstQuestions[currentQuestion].Type == TypeOfOptions.CheckBox)
            {

                CheckBox[] rdo = new CheckBox[lstQuestions[currentQuestion].NoOfOptions];
                List<string> strOpt = lstQuestions[currentQuestion].Options;
                for (int i = 0; i < lstQuestions[currentQuestion].NoOfOptions; i++)
                {

                    rdo[i] = new CheckBox();
                    string[] str = strOpt[i].Split(new string[] { "*****" }, StringSplitOptions.None);
                    rdo[i].Content = str[0];
                    rdo[i].Tag = str[1];
                    rdo[i].Height = 25;
                    rdo[i].Width = 600;
                    rdo[i].SetValue(Canvas.LeftProperty, 80.0);
                    rdo[i].SetValue(Canvas.TopProperty, 10.0 + ((i + 1) * 30));
                    cnvMain.Children.Add(rdo[i]);
                }
            }

            else if (lstQuestions[currentQuestion].Type == TypeOfOptions.ListBox)
            {

                ListBox lst = new ListBox();
                lst.Height = 250;
                lst.Width = 250;
                lst.SetValue(Canvas.LeftProperty, 80.0);
                lst.SetValue(Canvas.TopProperty, 80.0);
                cnvMain.Children.Add(lst);
                ListBoxItem[] lbi = new ListBoxItem[lstQuestions[currentQuestion].NoOfOptions];
                List<string> strOpt = lstQuestions[currentQuestion].Options;
                for (int i = 0; i < lstQuestions[currentQuestion].NoOfOptions; i++)
                {
                    lbi[i] = new ListBoxItem();
                    string[] str = strOpt[i].Split(new string[] { "*****" }, StringSplitOptions.None);
                    lbi[i].Content = str[0];
                    lbi[i].Tag = str[1];
                    lst.Items.Add(lbi[i]);
                }
            }

            else if (lstQuestions[currentQuestion].Type == TypeOfOptions.ComboBox)
            {
                ComboBox cmb = new ComboBox();
                cmb.Height = 30;
                cmb.Width = 250;
                cmb.SetValue(Canvas.LeftProperty, 80.0);
                cmb.SetValue(Canvas.TopProperty, 80.0);
                cnvMain.Children.Add(cmb);
                ComboBoxItem[] cbi = new ComboBoxItem[lstQuestions[currentQuestion].NoOfOptions];
                List<string> strOpt = lstQuestions[currentQuestion].Options;
                for (int i = 0; i < lstQuestions[currentQuestion].NoOfOptions; i++)
                {
                    cbi[i] = new ComboBoxItem();
                    string[] str = strOpt[i].Split(new string[] { "*****" }, StringSplitOptions.None);
                    cbi[i].Content = str[0];
                    cbi[i].Tag = str[1];
                    cmb.Items.Add(cbi[i]);
                }
            }

            else if (lstQuestions[currentQuestion].Type == TypeOfOptions.TextBox)
            {
                Label[] lbl = new Label[lstQuestions[currentQuestion].NoOfOptions];
                TextBox[] txt = new TextBox[lstQuestions[currentQuestion].NoOfOptions];
                List<string> strOpt = lstQuestions[currentQuestion].Options;
                for (int i = 0; i < lstQuestions[currentQuestion].NoOfOptions; i++)
                {

                    lbl[i] = new Label();
                    string[] str = strOpt[i].Split(new string[] { "*****" }, StringSplitOptions.None);
                    lbl[i].Content = str[0];
                    lbl[i].Height = 25;
                    lbl[i].Width = 600;
                    lbl[i].SetValue(Canvas.LeftProperty, 80.0);
                    lbl[i].SetValue(Canvas.TopProperty, 10.0 + ((i + 1) * 30));
                    cnvMain.Children.Add(lbl[i]);

                    txt[i] = new TextBox();

                    //string[] str = strOpt[i].Split(new string[] { "*****" }, StringSplitOptions.None);
                    txt[i].Text = str[0];
                    txt[i].Tag = str[1];

                    txt[i].Height = 25;
                    txt[i].Width = 400;
                    txt[i].SetValue(Canvas.LeftProperty, 280.0);
                    txt[i].SetValue(Canvas.TopProperty, 10.0 + ((i + 1) * 30));
                    cnvMain.Children.Add(txt[i]);
                }
            }

            
            cnvMain.Children.Add(lblHeader);
            currentQuestion++;
        exit: ;
        }
            catch (Exception exp)
            {
                exp.Data.Add("My Key", "FncNextQuestion()--:--clsQuestion.xaml.cs--:--" + exp.Message + " :--:--");
                //ClsException.LogError(ex);
                //ClsException.WriteToErrorLogFile(ex);
                System.Text.StringBuilder sb = new StringBuilder();
                sb.AppendLine(exp.Message);
                sb.AppendLine();
                sb.AppendLine("StackTrace : " + exp.StackTrace);
                sb.AppendLine();
                sb.AppendLine("Location : " + exp.Data["My Key"].ToString());
                sb.AppendLine();
                sb1 = CreateTressInfo();
                sb.Append(sb1.ToString());
                VMuktiAPI.ClsLogging.WriteToTresslog(sb);
            }
        }