Пример #1
0
        /// <summary>
        /// Expands or collapses the control.
        /// </summary>
        /// <param name="smooth">if set to <c>true</c> animate the transition.</param>
        private void UpdateIsExpanded(bool smooth)
        {
            SurfaceListBoxItem selectedItem = GetSelectedItem();

            if (selectedItem == null)
            {
                return;
            }

            SizeChanged -= ListBox_SizeChanged;

            if (IsExpanded)
            {
                DoExpandTransition(smooth);

                if (DropDownOpened != null)
                {
                    DropDownOpened(this, EventArgs.Empty);
                }
            }
            else
            {
                DoCollapseTransition(smooth);

                if (DropDownClosed != null)
                {
                    DropDownClosed(this, EventArgs.Empty);
                }
            }

            VisualStateManager.GoToState(this, IsExpanded ? "IsExpandedState" : "NotExpandedState", true);
        }
        private void PinnedItems_Drop(object sender, SurfaceDragDropEventArgs e)
        {
            DragableImageItem  image = e.Cursor.Data as DragableImageItem;
            SurfaceListBoxItem s     = (SurfaceListBoxItem)sender;

            BluetoothHandler.SendBluetooth((s.Content as PhoneThumbVisualization).BTEndpoint, image.Image);
        }
        public void UpdateList()
        {
            SurfaceListBoxItem il;
            ItemListCategory ilc ;
            CategoriesXml xmlcat = globalDatasingleton.getInstance().getInfoCategories();

            List<String> name = xmlcat.GetNameCategories();
            List<String> bitmapname = xmlcat.GetBitmapsCategories();

            surfaceListBox1.Items.Clear();
            int i = 0;

            foreach (String n in name)
            {
                il = new SurfaceListBoxItem();
                ilc = new ItemListCategory();
                if (File.Exists(bitmapname[i]))
                {
                    ilc.ImageSource = bitmapname[i];
                }
                ilc.Label = n;
                il.Content = ilc;
                surfaceListBox1.Items.Add(il);
                i++;
            }
        }
Пример #4
0
        private void OnMainDrag(object sender, InputEventArgs e)
        {
            FrameworkElement   findSource     = e.OriginalSource as FrameworkElement;
            SurfaceListBoxItem draggedElement = null;

            // Find the touched SurfaceListBoxItem object.
            while (draggedElement == null && findSource != null)
            {
                if ((draggedElement = findSource as SurfaceListBoxItem) == null)
                {
                    findSource = VisualTreeHelper.GetParent(findSource) as FrameworkElement;
                }
            }

            if (draggedElement == null)
            {
                return;
            }

            // Create the cursor visual.
            ContentControl cursorVisual = new ContentControl()
            {
                Content = draggedElement.DataContext,
                Style   = FindResource("CursorStyle") as Style
            };

            // Add a handler. This will enable the application to change the visual cues.
            SurfaceDragDrop.AddTargetChangedHandler(cursorVisual, OnTargetChanged);

            // Create a list of input devices. Add the touches that
            // are currently captured within the dragged element and
            // the current touch (if it isn't already in the list).
            List <InputDevice> devices = new List <InputDevice>();

            devices.Add(e.Device);
            foreach (TouchDevice touch in draggedElement.TouchesCapturedWithin)
            {
                if (touch != e.Device)
                {
                    devices.Add(touch);
                }
            }

            // Get the drag source object
            ItemsControl dragSource = ItemsControl.ItemsControlFromItemContainer(draggedElement);

            SurfaceDragCursor startDragOkay =
                SurfaceDragDrop.BeginDragDrop(
                    dragSource,                 // The SurfaceListBox object that the cursor is dragged out from.
                    draggedElement,             // The SurfaceListBoxItem object that is dragged from the drag source.
                    cursorVisual,               // The visual element of the cursor.
                    draggedElement.DataContext, // The data associated with the cursor.
                    devices,                    // The input devices that start dragging the cursor.
                    DragDropEffects.Move);      // The allowed drag-and-drop effects of the operation.

            // If the drag began successfully, set e.Handled to true.
            // Otherwise SurfaceListBoxItem captures the touch
            // and causes the drag operation to fail.
            e.Handled = (startDragOkay != null);
        }
Пример #5
0
        private void lstBxChoices_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            SurfaceListBoxItem item = Utils.findLBIUnderTouch(e);

            if (item != null && item.Content != null)
            {
                select(item.Content);
            }

            lstBxChoices.Visibility = Visibility.Hidden;
        }
Пример #6
0
        /// <summary>
        /// Wait until the list has been created and the default item is selected, then set the initial size and position.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void ListBox_LayoutUpdated(object sender, EventArgs e)
        {
            SurfaceListBoxItem selectedItem = GetSelectedItem();

            if (selectedItem == null)
            {
                return;
            }

            _ListBox.LayoutUpdated -= ListBox_LayoutUpdated;
            UpdateIsExpanded(false);
        }
Пример #7
0
        private void ListBoxItem_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            /*
             * Get friend name
             */
            SurfaceListBoxItem b = sender as SurfaceListBoxItem;
            String             s = b.Content as String;

            /*
             * Call datacontext function.
             */
            ((ViewModel.VMFriend)(DataContext)).doubleClickAFriend(s);
        }
Пример #8
0
        void AddListItem(string FullPath)
        {
            XmlDocument xmlDoc = new XmlDocument();

            XML_IO.ReadXMLData(xmlDoc, FullPath);

            XmlNode     ImageNode = xmlDoc.SelectSingleNode("//GISData/GISImage");
            string      ImageFile = ImageNode.Attributes["file"].Value;
            BitmapImage BMPimage = new BitmapImage();
            double      width, height;

            try
            {
                BMPimage.BeginInit();
                BMPimage.UriSource = new Uri(ImageFile, UriKind.RelativeOrAbsolute);
                BMPimage.EndInit();
            }
            catch (FileNotFoundException i)
            {
                MessageBoxResult Result = MessageBox.Show("Network Error", "Please Manually Refresh");
            }

            width  = BMPimage.Width;
            height = BMPimage.Height;

            SurfaceListBoxItem NewImageItem = new SurfaceListBoxItem();

            int x = FileNames.Count;

            if (x <= 9)
            {
                NewImageItem.Name = "Image0" + x.ToString();
            }
            else
            {
                NewImageItem.Name = "Image" + x.ToString();
            }

            // ARList.Add(width / height);

            NewImageItem.Background = new ImageBrush(BMPimage);
            NewImageItem.Height     = 80;
            NewImageItem.Padding    = new Thickness(5.0);

            NewImageItem.Selected += new RoutedEventHandler(ImageItem_selected);

            NetBMPList.Items.Add(NewImageItem);
        }
Пример #9
0
        public static SurfaceListBoxItem findLBIUnderTouch(InputEventArgs e)
        {
            DependencyObject   findSource     = e.OriginalSource as FrameworkElement;
            SurfaceListBoxItem draggedElement = null;

            // Find the ScatterViewItem object that is being touched.
            while (draggedElement == null && findSource != null)
            {
                if ((draggedElement = findSource as SurfaceListBoxItem) == null)
                {
                    findSource = VisualTreeHelper.GetParent(findSource);
                }
            }

            return(draggedElement);
        }
Пример #10
0
        private void OnDragSourcePreviewTouchUp(object sender, InputEventArgs e)
        {
            FrameworkElement   findSource     = e.OriginalSource as FrameworkElement;
            SurfaceListBoxItem draggedElement = null;

            // Find the touched SurfaceListBoxItem object.
            while (draggedElement == null && findSource != null)
            {
                if ((draggedElement = findSource as SurfaceListBoxItem) == null)
                {
                    findSource = VisualTreeHelper.GetParent(findSource) as FrameworkElement;
                }
            }

            if (draggedElement == null)
            {
                return;
            }
        }
Пример #11
0
        private void StartDragDrop(ListBox sourceListBox, InputEventArgs e)
        {
            DependencyObject downSource = InputDeviceHelper.GetDragSource(e.Device);

            Debug.Assert(downSource != null);

            SurfaceListBoxItem draggedListBoxItem = GetVisualAncestor <SurfaceListBoxItem>(downSource);

            if (draggedListBoxItem == null)
            {
                return;
            }

            SimpleCard data = draggedListBoxItem.Content as SimpleCard;

            // Create a new ScatterViewItem as cursor visual.
            ScatterViewItem cursorVisual = new ScatterViewItem();

            cursorVisual.Style   = (Style)FindResource("ScatterItemStyle");
            cursorVisual.Content = data;

            IEnumerable <InputDevice> devices = null;

            TouchEventArgs touchEventArgs = e as TouchEventArgs;

            if (touchEventArgs != null)
            {
                devices = MergeInputDevices(draggedListBoxItem.TouchesCapturedWithin, e.Device);
            }
            else
            {
                devices = new List <InputDevice>(new InputDevice[] { e.Device });
            }

            SurfaceDragCursor cursor = SurfaceDragDrop.BeginDragDrop(HandListBox, draggedListBoxItem, cursorVisual, data, devices, DragDropEffects.All);

            // Reset the input device's state.

            InputDeviceHelper.ClearDeviceState(e.Device);

            ((ObservableCollection <SimpleCard>) this.HandListBox.ItemsSource).Remove(data);
        }
Пример #12
0
        private void OnDragSourcePreviewTouchDown(object sender, InputEventArgs e)
        {
            FrameworkElement   findSource     = e.OriginalSource as FrameworkElement;
            SurfaceListBoxItem draggedElement = null;

            // Find the touched SurfaceListBoxItem object.
            while (draggedElement == null && findSource != null)
            {
                if ((draggedElement = findSource as SurfaceListBoxItem) == null)
                {
                    findSource = VisualTreeHelper.GetParent(findSource) as FrameworkElement;
                }
            }

            if (draggedElement == null)
            {
                return;
            }

            TransformGroup     tGroup = new TransformGroup();
            ScaleTransform     sTrans = new ScaleTransform();
            TranslateTransform tTrans = new TranslateTransform();

            sTrans.ScaleX = 1;
            sTrans.ScaleY = 1;

            tTrans.X = 0;
            tTrans.Y = 0;

            tGroup.Children.Add(sTrans);
            tGroup.Children.Add(tTrans);
            draggedElement.RenderTransform = tGroup;

            Storyboard sb = (Storyboard)Resources["MyPress"];

            sb.Begin(draggedElement);
            SelectPage(draggedElement.DataContext as DataItem, sender);

            e.Handled = true;
        }
 /// <summary>
 /// Feed the hotspot navigator listbox with proper contents.
 /// Which hotspots are displayed are based on the search box above the listbox.
 /// </summary>
 private void fillHotspotNavListBox()
 {
     listHotspotNav.Items.Clear();
     m_hotspotCollection.unloadAllHotspotsIcon();
     if (m_hotspotCollection.Hotspots != null)
     {
         for (int i = 0; i < m_hotspotCollection.Hotspots.Length; i++)
         {
             if (m_hotspotCollection.IsSelected[i] == true)
             {
                 SurfaceListBoxItem item = new SurfaceListBoxItem();
                 item.Tag = i; // the tag stores the index (position of the hotspot in hotspotCollection)
                 item.Content = m_hotspotCollection.Hotspots[i].Name;
                 listHotspotNav.Items.Add(item);
                 if (m_hotspotOnOff == true)
                 {
                     m_hotspotCollection.loadHotspotIcon(i, HotspotOverlay, MSIScatterView, msi);
                 }
             }
         }
         _noHotspots = false;
         if (m_hotspotCollection.Hotspots.Length == 0)
         {
             SurfaceListBoxItem item = new SurfaceListBoxItem();
             item.Content = "(No hotspots for this artwork)";
             listHotspotNav.Items.Add(item);
         }
     }
     else
     {
         SurfaceListBoxItem item = new SurfaceListBoxItem();
         item.Content = "(No hotspots for this artwork)";
         listHotspotNav.Items.Add(item);
     }
 }
 private void populateFilterList(List<String> theItems)
 {
     filtItemList.Items.Clear();
     for (int i = 0; i < theItems.Count; i++)
     {
         SurfaceListBoxItem b = new SurfaceListBoxItem();
         b.Content = theItems[i];
         b.Background =new SolidColorBrush((Color)System.Windows.Media.ColorConverter.ConvertFromString("#665D9D8E"));
         filtItemList.Items.Add(b);
     }
 }
Пример #15
0
        private void select_DataSheet(object sender, RoutedEventArgs e)
        {
            //try
            //{
            //_thisRegDS = new RegDataSheet("http://partsregistry.org/wiki/index.php?title=Part:" + this.partName.Text);

            ds = new MenuDataSheet();
            ds.ContainerManipulationCompleted += new ContainerManipulationCompletedEventHandler(onDSManipulationCompleted);

            if (_myRegDS.Name != "test") //Already got data from registry, so just populate from it
            {
                #region Populating the data sheet's datasheet
                //Specifies the Length of the Sequence on the Sequence tab of the data sheet
                int Length = _myRegDS.BasicInfo.Length;
                TextBlock LengthBlock = new TextBlock();
                //ds.SeqTab.Children.Add(LengthBlock);
                LengthBlock.VerticalAlignment = VerticalAlignment.Top;
                LengthBlock.Text = "Length: " + Length.ToString();

                //This is all pulling information from the Reg Data Sheet associated with the part and inserting it in the data sheet
                ds.PopulateDataSheet(_myRegDS.Name, 0, 1, ds.DataSheet, "datasheet");
                ds.PopulateDataSheet(_myRegDS.BasicInfo.DescriptionName, 1, 1, ds.DataSheet, "datasheet");
                ds.PopulateDataSheet(_myRegDS.Type, 2, 1, ds.DataSheet, "datasheet");
                ds.PopulateDataSheet(_myRegDS.Promoter.getReg(), 3, 1, ds.DataSheet, "datasheet");
                ds.PopulateDataSheet(_myRegDS.BasicInfo.Availability, 4, 1, ds.DataSheet, "datasheet");
                ds.PopulateDataSheet(_myRegDS.BasicInfo.Usefulness, 5, 1, ds.DataSheet, "datasheet");
                ds.PopulateDataSheet(_myRegDS.Description.assembCompString(), 6, 1, ds.DataSheet, "datasheet");
                ds.PopulateDataSheet(_myRegDS.Description.chassisString(), 7, 1, ds.DataSheet, "datasheet");

                

                //Specific to sequence tab
                ds.PopulateDataSheet(_myRegDS.BasicInfo.Sequence, 1, 1, ds.SeqTab, "seq");
                ds.PopulateDataSheet(Length.ToString(), 0, 1, ds.SeqTab, "length");

                //Specific to AuthorInfo Tab
                ds.PopulateDataSheet(_myRegDS.Reference.Author, 0, 1, ds.AuthorInfo, "author");
                ds.PopulateDataSheet(_myRegDS.Reference.Group, 1, 1, ds.AuthorInfo, "author");
                ds.PopulateDataSheet(_myRegDS.Reference.Date, 2, 1, ds.AuthorInfo, "author");

                if (_myRegDS.Type == "rbs")
                {
                    RowDefinition rowDef1 = new RowDefinition();
                    ds.DataSheet.RowDefinitions.Add(rowDef1);
                    ds.PopulateDataSheet(_myRegDS.Rbs.FamilyName, 8, 1, ds.DataSheet);
                    TextBlock RBSFam = new TextBlock();
                    RBSFam.Text = "Family";
                    ds.DataSheet.Children.Add(RBSFam);
                    Grid.SetRow(RBSFam, 8);
                }
                else if (_myRegDS.Type == "terminator")
                {
                    RowDefinition rowDef1 = new RowDefinition();
                    RowDefinition rowDef2 = new RowDefinition();
                    RowDefinition rowDef3 = new RowDefinition();
                    RowDefinition rowDef4 = new RowDefinition();

                    ds.DataSheet.RowDefinitions.Add(rowDef1);
                    ds.DataSheet.RowDefinitions.Add(rowDef2);
                    ds.DataSheet.RowDefinitions.Add(rowDef3);
                    ds.DataSheet.RowDefinitions.Add(rowDef4);

                    TextBlock Direction = new TextBlock();
                    Direction.Text = "Direction";
                    Direction.FontSize = 18;
                    ds.DataSheet.Children.Add(Direction);
                    Grid.SetRow(Direction, 8);

                    ds.PopulateDataSheet(_myRegDS.Terminators.Direction, 8, 1, ds.DataSheet);
                    ds.PopulateDataSheet(_myRegDS.Terminators.ForwardEff, 9, 1, ds.DataSheet);
                    ds.PopulateDataSheet(_myRegDS.Terminators.ReversedEff, 10, 1, ds.DataSheet);
                    ds.PopulateDataSheet(_myRegDS.Terminators.ReversedVers, 11, 1, ds.DataSheet);
                }

                #endregion

                #region Populating Publications
                Func<String, PubList> _GetPublications =
                        delegate(String id) { return new PubList(id); };
                Action<PubList> callback = delegate(PubList result)
                {
                    //_thisRegDS = new RegDataSheet("http://partsregistry.org/wiki/index.php?title=Part:" + this.partName.Text);

                    int m = 0;

                    if (result.Titles.Count == 0)
                    {
                        int Count = result.Titles.Count;
                        SurfaceListBoxItem NoResults = new SurfaceListBoxItem();
                        TextBlock Content = new TextBlock();
                        Content.Text = "No Results Found";
                        NoResults.Content = Content;
                        ds.Publictions.Items.Add(NoResults);
                    }

                    if (result.Titles.Count > 0)
                    {
                        int TotalArticles = result.Titles.Count;
                        SurfaceListBoxItem ArticleCount = new SurfaceListBoxItem();
                        TextBlock CountContent = new TextBlock();
                        CountContent.Text = "Results Found: " + TotalArticles as string;
                        ArticleCount.Content = CountContent;
                        ds.Publictions.Items.Add(ArticleCount);
                    }

                    foreach (String Titles in result.Titles)
                    {

                        //To Test if titles are actually adding
                        SurfaceListBoxItem item = new SurfaceListBoxItem();
                        TextBlock PubTitles = new TextBlock();
                        item.Selected += new RoutedEventHandler(item_Selected);
                        item.Content = Titles;
                        PubTitles.Tag = result.Links.ElementAt(m);
                        //item.Tag = result.Authors.ElementAt(m); 
                        ds.Publictions.Items.Add(item);
                        RowDefinition rowDef1 = new RowDefinition();
                        RowDefinition rowDef2 = new RowDefinition();
                        RowDefinition rowDef3 = new RowDefinition();
                        RowDefinition rowDef4 = new RowDefinition();

                        abs = new PubAbstract(PubTitles.Tag as string, result.getAuthors());

                        item.Tag = "Title:  " + item.Content as string + "\r\n" + "\r\n" + "\r\n"

                            + "Authors:   " + result.Authors.ElementAt(m) as string + "\r\n" + "\r\n"

                            + "Abstract:" + "\r\n" + "\r\n"

                            + abs.getAbstract() as string;

                        m += 1;
                        Console.WriteLine(m);

                        if (m > 20)
                            break;
                    }

                    /*foreach (String Titles in result.Titles)
                    {
                        TextBlock Middle = new TextBlock();
                        Middle.Text = Titles;
                        //ds.Publications.Children.Add(Middle);
                        Grid.SetRow(Middle, m);
                        m += 1; 
            #endregion
            //publications location maybe
            //Creates a list of PubMed source related to the query

                    }*/
                };
                _Publist = _progressBarWrapper.execute<String, PubList>(_GetPublications, _myRegDS.BasicInfo.DescriptionName, callback);
        #endregion
                SurfaceWindow1.addData(sender, ds);
            }
            else
            {
                Func<String, RegDataSheet> _getRegDataSheet =
                delegate(String pName) { return new RegDataSheet("http://partsregistry.org/wiki/index.php?title=Part:" + pName); };
                Action<RegDataSheet> _getRegDataSheetCallback = delegate(RegDataSheet _regDS)
                {
                    _myRegDS = _regDS;
                    #region Populating the data sheet's datasheet
                    //Specifies the Length of the Sequence on the Sequence tab of the data sheet
                    int Length = _myRegDS.BasicInfo.Length;
                    TextBlock LengthBlock = new TextBlock();
                    //ds.SeqTab.Children.Add(LengthBlock);
                    LengthBlock.VerticalAlignment = VerticalAlignment.Top;
                    LengthBlock.Text = "Length: " + Length.ToString();

                    //This is all pulling information from the Reg Data Sheet associated with the part and inserting it in the data sheet
                    ds.PopulateDataSheet(_myRegDS.Name, 0, 1, ds.DataSheet, "datasheet");
                    ds.PopulateDataSheet(_myRegDS.BasicInfo.DescriptionName, 1, 1, ds.DataSheet, "datasheet");
                    ds.PopulateDataSheet(_myRegDS.Type, 2, 1, ds.DataSheet, "datasheet");
                    ds.PopulateDataSheet(_myRegDS.Promoter.getReg(), 3, 1, ds.DataSheet, "datasheet");
                    ds.PopulateDataSheet(_myRegDS.BasicInfo.Availability, 4, 1, ds.DataSheet, "datasheet");
                    ds.PopulateDataSheet(_myRegDS.BasicInfo.Usefulness, 5, 1, ds.DataSheet, "datasheet");
                    ds.PopulateDataSheet(_myRegDS.Description.assembCompString(), 6, 1, ds.DataSheet, "datasheet");
                    ds.PopulateDataSheet(_myRegDS.Description.chassisString(), 7, 1, ds.DataSheet, "datasheet");

                    //Specific to sequence tab
                    ds.PopulateDataSheet(_myRegDS.BasicInfo.Sequence, 1, 1, ds.SeqTab, "seq");
                    ds.PopulateDataSheet(Length.ToString(), 0, 1, ds.SeqTab, "length");

                    //Specific to AuthorInfo Tab
                    ds.PopulateDataSheet(_myRegDS.Reference.Author, 0, 1, ds.AuthorInfo, "author");
                    ds.PopulateDataSheet(_myRegDS.Reference.Group, 1, 1, ds.AuthorInfo, "author");
                    ds.PopulateDataSheet(_myRegDS.Reference.Date, 2, 1, ds.AuthorInfo, "author");

                    if (_myRegDS.Type == "rbs")
                    {
                        RowDefinition rowDef1 = new RowDefinition();
                        ds.DataSheet.RowDefinitions.Add(rowDef1);
                        ds.PopulateDataSheet(_myRegDS.Rbs.FamilyName, 8, 1, ds.DataSheet);
                        TextBlock RBSFam = new TextBlock();
                        RBSFam.Text = "Family";
                        RBSFam.FontSize= 14;
                        RBSFam.FontWeight = FontWeights.Bold;
                        RBSFam.VerticalAlignment = VerticalAlignment.Top;
                        // COME BACK TO THIS LATER

                        ds.DataSheet.Children.Add(RBSFam);
                        Grid.SetRow(RBSFam, 8);
                    }
                    else if (_myRegDS.Type == "terminator")
                    {
                        RowDefinition rowDef1 = new RowDefinition();
                        RowDefinition rowDef2 = new RowDefinition();
                        RowDefinition rowDef3 = new RowDefinition();
                        RowDefinition rowDef4 = new RowDefinition();

                        ds.DataSheet.RowDefinitions.Add(rowDef1);
                        ds.DataSheet.RowDefinitions.Add(rowDef2);
                        ds.DataSheet.RowDefinitions.Add(rowDef3);
                        ds.DataSheet.RowDefinitions.Add(rowDef4);

                        TextBlock Direction = new TextBlock();
                        Direction.Text = "Direction";
                        Direction.FontSize = 18;
                        ds.DataSheet.Children.Add(Direction);
                        Grid.SetRow(Direction, 8);

                        ds.PopulateDataSheet(_myRegDS.Terminators.Direction, 8, 1, ds.DataSheet);
                        ds.PopulateDataSheet(_myRegDS.Terminators.ForwardEff, 9, 1, ds.DataSheet);
                        ds.PopulateDataSheet(_myRegDS.Terminators.ReversedEff, 10, 1, ds.DataSheet);
                        ds.PopulateDataSheet(_myRegDS.Terminators.ReversedVers, 11, 1, ds.DataSheet);
                    }

                    #endregion

                    #region Populating Publications
                    Func<String, PubList> _GetPublications =
                            delegate(String id) { return new PubList(id); };
                    Action<PubList> callback = delegate(PubList result)
                    {
                        //_thisRegDS = new RegDataSheet("http://partsregistry.org/wiki/index.php?title=Part:" + this.partName.Text);

                        int m = 0;

                        if (result.Titles.Count == 0)
                        {
                            int Count = result.Titles.Count;
                            SurfaceListBoxItem NoResults = new SurfaceListBoxItem();
                            TextBlock Content = new TextBlock();
                            Content.Text = "No Results Found";
                            NoResults.Content = Content;
                            ds.Publictions.Items.Add(NoResults);
                        }

                        if (result.Titles.Count > 0)
                        {
                            int TotalArticles = result.Titles.Count;
                            SurfaceListBoxItem ArticleCount = new SurfaceListBoxItem();
                            TextBlock CountContent = new TextBlock();
                            CountContent.Text = "Results Found: " + TotalArticles as string;
                            ArticleCount.Content = CountContent;
                            ds.Publictions.Items.Add(ArticleCount);
                        }

                        foreach (String Titles in result.Titles)
                        {

                            //To Test if titles are actually adding
                            SurfaceListBoxItem item = new SurfaceListBoxItem();
                            TextBlock PubTitles = new TextBlock();
                            item.Selected += new RoutedEventHandler(item_Selected);
                            item.Content = Titles;
                            PubTitles.Tag = result.Links.ElementAt(m);
                            //item.Tag = result.Authors.ElementAt(m); 
                            ds.Publictions.Items.Add(item);
                            RowDefinition rowDef1 = new RowDefinition();
                            RowDefinition rowDef2 = new RowDefinition();
                            RowDefinition rowDef3 = new RowDefinition();
                            RowDefinition rowDef4 = new RowDefinition();

                            abs = new PubAbstract(PubTitles.Tag as string, result.getAuthors());

                            item.Tag = "Title:  " + item.Content as string + "\r\n" + "\r\n" + "\r\n"

                                + "Authors:   " + result.Authors.ElementAt(m) as string + "\r\n" + "\r\n"

                                + "Abstract:" + "\r\n" + "\r\n"

                                + abs.getAbstract() as string;

                            m += 1;
                            Console.WriteLine(m);

                            if (m > 20)
                                break;
                        }

                        /*foreach (String Titles in result.Titles)
                        {
                            TextBlock Middle = new TextBlock();
                            Middle.Text = Titles;
                            //ds.Publications.Children.Add(Middle);
                            Grid.SetRow(Middle, m);
                            m += 1; 
                #endregion
                //publications location maybe
                //Creates a list of PubMed source related to the query

                        }*/
                    };
                    _Publist = _progressBarWrapper.execute<String, PubList>(_GetPublications, _myRegDS.BasicInfo.DescriptionName, callback);
        #endregion
                    SurfaceWindow1.addData(sender, ds);
                };
                _dataSheet = _progressBarWrapper.execute<String, RegDataSheet>(_getRegDataSheet, partName.Text, _getRegDataSheetCallback);
            }
        }
Пример #16
0
        public SearchTab(SideBar mySideBar, SurfaceWindow1 surfaceWindow)
            : base(mySideBar)
        {
            unreturnedResults = 0;
            sideBar = mySideBar;
            this.surfaceWindow = surfaceWindow;
            searchPrompt = new TextBlock();
            searchTabHeader = new TextBlock();
            searchQueryBox = new TextBox();
            goSearch = new Button();
            moreOptions = new Button();
            topLine = new Line();

            closeLanguageList = new Button();
            fewerOptions = new Button();
            upArrow = new Image();
            caseSensitive = new CheckBox();
            wholeWordOnly = new CheckBox();
            exactPhraseOnly = new CheckBox();
            st = new ScaleTransform();
            bottomLine = new Line();

            selectLanguage = new SurfaceListBox();
            pickLanguage = new SurfaceListBoxItem();
            oldFrench = new SurfaceListBoxItem();
            modernFrench = new SurfaceListBoxItem();
            English = new SurfaceListBoxItem();
            selectLanguageButton = new Button();

            searchResults = new TabControl();
            poetryTab = new TabItem();
            lyricsTab = new TabItem();
            imagesTab = new TabItem();
            poetryCanvas = new Canvas();
            poetryScroll = new SurfaceScrollViewer();
            poetryPanel = new StackPanel();
            lyricsCanvas = new Canvas();
            lyricsScroll = new SurfaceScrollViewer();
            lyricsPanel = new StackPanel();
            imagesCanvas = new Canvas();
            imagesScroll = new SurfaceScrollViewer();
            imagesPanel = new StackPanel();

            loadImage = new Image();
            loadImage.Source = new BitmapImage(new Uri(@"..\..\icons\magnifyingglass.png", UriKind.Relative));
            canvas.Children.Add(loadImage);

            headerImage.Source = new BitmapImage(new Uri(@"..\..\icons\search.png", UriKind.Relative));

            searchTabHeader.HorizontalAlignment = HorizontalAlignment.Center;
            searchTabHeader.VerticalAlignment = VerticalAlignment.Center;
            searchTabHeader.FontSize = 21;

            searchPrompt.FontSize = 30;
            searchPrompt.Text = "Search:";
            Canvas.SetLeft(searchPrompt, 32);
            Canvas.SetTop(searchPrompt, 26);

            searchQueryBox.Height = 40;
            searchQueryBox.Width = 380; //315
            searchQueryBox.Foreground = Brushes.Gray;
            searchQueryBox.FontSize = 21;
            searchQueryBox.Text = "Enter text";
            Canvas.SetLeft(searchQueryBox, 40);
            Canvas.SetTop(searchQueryBox, 90);

            goSearch.Height = 40;
            goSearch.Width = 95;
            goSearch.FontSize = 21;
            goSearch.Content = "Go!";
            goSearch.IsEnabled = false;
            Canvas.SetLeft(goSearch, 450); // 378
            Canvas.SetTop(goSearch, 90);

            downArrow = new Image();
            downArrow.Source = new BitmapImage(new Uri(@"/downArrow.png", UriKind.Relative));
            downArrow.Opacity = 0.3;
            downArrow.HorizontalAlignment = HorizontalAlignment.Center;
            moreOptText = new TextBlock();
            moreOptText.Text = "More Options";
            moreOptText.FontSize = 18; /// Might need to adjust height
            optionsGrid = new Grid();
            moreOptions.Content = optionsGrid;
            moreOptions.Width = 135; // 100
            moreOptions.Height = 28; // 20
            moreOptions.HorizontalContentAlignment = HorizontalAlignment.Center;
            optionsGrid.Children.Add(downArrow);
            optionsGrid.Children.Add(moreOptText);
            Canvas.SetLeft(moreOptions, 230); //210
            Canvas.SetTop(moreOptions, 145);

            topLine.X1 = 40;
            topLine.Y1 = 160;
            topLine.X2 = 540; // 500
            topLine.Y2 = 160;
            topLine.Stroke = Brushes.Black;
            topLine.StrokeThickness = 2;

            closeLanguageList.Width = 600; // 550
            closeLanguageList.Height = 1000; //900
            closeLanguageList.Style = sideBar.tabBar.FindResource("InvisibleButton") as Style;

            /// The objects for extended search options
            st.ScaleX = 2;
            st.ScaleY = 2;

            caseSensitive.FontSize = 10;
            caseSensitive.LayoutTransform = st;
            caseSensitive.Content = (string)"Case sensitive";
            Canvas.SetLeft(caseSensitive, 55); //40
            Canvas.SetTop(caseSensitive, 170);

            wholeWordOnly.FontSize = 10;
            wholeWordOnly.LayoutTransform = st;
            wholeWordOnly.Content = (string)"Match whole word only";
            Canvas.SetLeft(wholeWordOnly, 300); //243
            Canvas.SetTop(wholeWordOnly, 170);

            exactPhraseOnly.FontSize = 10;
            exactPhraseOnly.LayoutTransform = st;
            exactPhraseOnly.Content = (string)"Match exact phrase only";
            Canvas.SetLeft(exactPhraseOnly, 300); // 243
            Canvas.SetTop(exactPhraseOnly, 227);

            selectLanguage.Background = Brushes.LightGray;
            selectLanguage.Visibility = Visibility.Collapsed;
            selectLanguage.Width = 175;
            selectLanguage.FontSize = 21;
            selectLanguage.HorizontalContentAlignment = HorizontalAlignment.Center;
            selectLanguage.SelectedIndex = 0;

            Canvas.SetLeft(selectLanguage, 50); //34
            Canvas.SetTop(selectLanguage, 220);
            Canvas.SetLeft(selectLanguageButton, 50); //34
            Canvas.SetTop(selectLanguageButton, 220);
            selectLanguageButton.Width = 175;
            selectLanguageButton.Height = 40;
            selectLanguageButton.Visibility = Visibility.Hidden;
            selectLanguageButton.Content = (string)"Old French";
            selectLanguageButton.FontSize = 21;

            pickLanguage.Content = (string)"Pick a language:";
            oldFrench.Content = (string)"Old French";
            modernFrench.Content = (string)"Modern French";
            English.Content = (string)"English";

            selectLanguage.Items.Add(pickLanguage);
            selectLanguage.Items.Add(oldFrench);
            selectLanguage.Items.Add(modernFrench);
            selectLanguage.Items.Add(English);

            foreach (SurfaceListBoxItem s in selectLanguage.Items)
            {
                s.FontFamily = new FontFamily("Cambria");
                s.VerticalContentAlignment = System.Windows.VerticalAlignment.Center;
                s.FontSize = 21;
                s.Height = 40;
            }

            bottomLine.X1 = 40;
            bottomLine.Y1 = 183;
            bottomLine.X2 = 540; //500
            bottomLine.Y2 = 183;
            bottomLine.Stroke = Brushes.Black;
            bottomLine.StrokeThickness = 2;
            Canvas.SetTop(bottomLine, 113);

            upArrow.Source = new BitmapImage(new Uri(@"/upArrow.png", UriKind.Relative));
            upArrow.Opacity = 0.3;
            upArrow.HorizontalAlignment = HorizontalAlignment.Center;
            fewerOptText = new TextBlock();
            fewerOptText.Text = "Fewer Options";
            fewerOptText.FontSize = 18; /// Might need to adjust height
            fewerOptGrid = new Grid();
            fewerOptions.Content = fewerOptGrid;
            fewerOptions.Width = 135;
            fewerOptions.Height = 28;
            fewerOptions.HorizontalContentAlignment = HorizontalAlignment.Center;
            fewerOptGrid.Children.Add(upArrow);
            fewerOptGrid.Children.Add(fewerOptText);
            Canvas.SetLeft(fewerOptions, 230); // 210
            Canvas.SetTop(fewerOptions, 280); // 285

            /// The objects on the search results section
            searchResults.Visibility = Visibility.Hidden;
            searchResults.Height = 800; //677
            searchResults.Width = 525; //482
            searchResults.FontSize = 21;
            Canvas.SetLeft(searchResults, 35); //30
            Canvas.SetTop(searchResults, 180);
            searchResults.Items.Add(poetryTab);
            searchResults.Items.Add(lyricsTab);
            searchResults.Items.Add(imagesTab);

            poetryBorder = new Border();
            poetryBorder.Child = poetryPanel;
            poetryBorder.Style = sideBar.tabBar.FindResource("ResultBorder") as Style;

            poetryTab.Header = "Poetry";
            poetryTab.Height = 40;
            poetryTab.Width = 170;
            poetryTab.Content = poetryCanvas;

            poetryCanvas.Height = 750;
            poetryCanvas.Children.Add(poetryScroll);
            poetryCanvas.Children.Add(poetryBorder);

            poetryScroll.Height = 410;
            poetryScroll.Width = 513;
            poetryScroll.VerticalScrollBarVisibility = ScrollBarVisibility.Auto;
            poetryScroll.HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled;
            poetryScroll.PanningMode = PanningMode.VerticalOnly;
            poetryPanel.Orientation = Orientation.Horizontal;

            lyricsBorder = new Border();
            lyricsBorder.Child = lyricsPanel;
            lyricsBorder.Style = sideBar.tabBar.FindResource("ResultBorder") as Style;

            lyricsTab.Header = "Lyrics";
            lyricsTab.Height = 40;
            lyricsTab.Width = 170;
            lyricsTab.Content = lyricsCanvas;
            lyricsCanvas.Height = 750;
            lyricsCanvas.Children.Add(lyricsScroll);
            lyricsCanvas.Children.Add(lyricsBorder);
            lyricsScroll.Height = 410;
            lyricsScroll.Width = 513;
            lyricsScroll.HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled;
            lyricsScroll.PanningMode = PanningMode.VerticalOnly;
            lyricsPanel.Orientation = Orientation.Horizontal;

            imagesBorder = new Border();
            imagesBorder.Child = imagesPanel;
            imagesBorder.Style = sideBar.tabBar.FindResource("ResultBorder") as Style;

            imagesTab.Header = "Images";
            imagesTab.Height = 40;
            imagesTab.Width = 170;
            imagesTab.Content = imagesCanvas;
            imagesCanvas.Height = 750;
            imagesCanvas.Children.Add(imagesScroll);
            imagesCanvas.Children.Add(imagesBorder);
            imagesScroll.Height = 410;
            imagesScroll.Width = 513;

            imagesScroll.HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled;
            imagesScroll.PanningMode = PanningMode.VerticalOnly;
            imagesPanel.Orientation = Orientation.Horizontal;

            /// Adding everything

            headerGrid.Children.Add(searchTabHeader);

            canvas.Children.Add(closeLanguageList); // Should add to the very back...
            canvas.Children.Add(searchPrompt);
            canvas.Children.Add(searchQueryBox);
            canvas.Children.Add(goSearch);
            canvas.Children.Add(topLine);
            canvas.Children.Add(moreOptions);

            canvas.Children.Add(searchResults);
            canvas.Children.Add(caseSensitive);
            canvas.Children.Add(bottomLine);
            canvas.Children.Add(selectLanguage);
            canvas.Children.Add(selectLanguageButton);
            canvas.Children.Add(fewerOptions);
            canvas.Children.Add(wholeWordOnly);
            canvas.Children.Add(exactPhraseOnly);
            caseSensitive.Visibility = Visibility.Hidden;
            selectLanguage.Visibility = Visibility.Hidden;
            bottomLine.Visibility = Visibility.Hidden;
            fewerOptions.Visibility = Visibility.Hidden;
            wholeWordOnly.Visibility = Visibility.Hidden;
            exactPhraseOnly.Visibility = Visibility.Hidden;

            closeLanguageList.TouchEnter += new EventHandler<TouchEventArgs>(closeLanguageList_TouchEnter);
            closeLanguageList.MouseLeave += new MouseEventHandler(closeLanguageList_MouseLeave);
            closeLanguageList.Click += new RoutedEventHandler(closeLanguageList_Click);
            moreOptions.Click += new RoutedEventHandler(Show_Options);
            moreOptions.TouchDown += new EventHandler<TouchEventArgs>(Show_Options);
            fewerOptions.Click += new RoutedEventHandler(Hide_Options);
            fewerOptions.TouchDown += new EventHandler<TouchEventArgs>(Hide_Options);
            searchQueryBox.GotFocus += new RoutedEventHandler(Focus_SearchBox);
            searchQueryBox.TouchDown += new EventHandler<TouchEventArgs>(Focus_SearchBox);
            goSearch.Click += new RoutedEventHandler(newSearch);
            goSearch.TouchDown += new EventHandler<TouchEventArgs>(newSearch);
            searchQueryBox.PreviewKeyDown += new KeyEventHandler(Enter_Clicked);
            caseSensitive.TouchDown += new EventHandler<TouchEventArgs>(changeCheck);
            exactPhraseOnly.TouchDown += new EventHandler<TouchEventArgs>(changeCheck);
            wholeWordOnly.TouchDown += new EventHandler<TouchEventArgs>(changeCheck);

            //selectLanguage.TouchDown += new EventHandler<TouchEventArgs>(displaySearchLanguages);
            //selectLanguage.SelectionChanged += new SelectionChangedEventHandler(searchLanguageChanged);
            selectLanguage.Visibility = Visibility.Collapsed;
            selectLanguageButton.TouchDown += new EventHandler<TouchEventArgs>(displaySearchLanguages);
            selectLanguageButton.Click += new RoutedEventHandler(displaySearchLanguages);
            pickLanguage.Selected += new RoutedEventHandler(searchLanguageChanged);
            oldFrench.Selected += new RoutedEventHandler(searchLanguageChanged);
            modernFrench.Selected += new RoutedEventHandler(searchLanguageChanged);
            English.Selected += new RoutedEventHandler(searchLanguageChanged);
        }
        public void UpdateList()
        {
            typeOfSelection = globalDatasingleton.TypeOfSelection.BYCATEGORY;
            SurfaceListBoxItem il = null;
            ItemListCategory ilc = null;
            List<String> name = null;
            List<String> bitmapname = null;

            if (currentElm == null)
            {
                name = xmlCat.GetNameCategories();
                bitmapname = xmlCat.GetBitmapsCategories();
            }
            else
            {
                name = xmlCat.GetNameChildCategories(ref currentElm);
                bitmapname = xmlCat.GetBitmapsChildCategories(ref currentElm);
            }

            surfaceListBox1.Items.Clear();
            int i = 0;

            if (currentElm != null)
            {
                il = new SurfaceListBoxItem();
                ilc = new ItemListCategory();

                textBlockName.Text = xmlCat.getLanguageName(currentElm);

                //ilc.Label = LocalizationManager.ResourceManager.GetString("Back");
                //ilc.ImageSource = "pack://application:,,,/Images/previous.png";
                //il.Content = ilc;
                //surfaceListBox1.Items.Add(il);
            }
            else
            {
                textBlockName.Text = "";
            }

            foreach (String n in name)
            {
                il = new SurfaceListBoxItem();
                ilc = new ItemListCategory();
                ilc.GrowingStep = 0;
                if (File.Exists(bitmapname[i]) == true)
                {
                    ilc.ImageSource = bitmapname[i];
                }
                ilc.Label = n;
                il.Content = ilc;
                surfaceListBox1.Items.Add(il);
                i++;
            }
        }
        private void SendTimerForLoading()
        {
            // Set the callback to just show the time ticking away
            // NOTE: We are using a control so this has to run on
            // the UI thread
            _timer.Tick += new EventHandler(delegate(object s, EventArgs a)
            {
                if (cursor >= imgList.Count)
                {
                    WaitingAnimation.IsAnimated = false;
                    gridWating.Visibility = System.Windows.Visibility.Hidden;
                    _timer.Stop();
                }
                else
                {

                    /*
                    MyImage img = new MyImage();
                    img.OriginalPath = imgList[cursor].path;
                    //System.Windows.Controls.Image img = new System.Windows.Controls.Image();
                    img.Source =  BitmapUtil.GetImageSource(imgList[cursor].path); //new BitmapImage(new Uri(imgList[cursor].path));
                    AddElementToPuzzleList(img);

                    */

                    SurfaceListBoxItem il = new SurfaceListBoxItem();
                    StackPanel sp = new StackPanel();
                    sp.Orientation = Orientation.Horizontal;

                    MyImage img = new MyImage();
                    img.OriginalPath = imgList[cursor].path;
                    //System.Windows.Controls.Image img = new System.Windows.Controls.Image();
                    img.Source = BitmapUtil.GetImageSource(imgList[cursor].path); //new BitmapImage(new Uri(imgList[cursor].path));

                    Viewbox vb = new Viewbox { Width = 200, Child = img };
                    vb.TouchDown += ViewBox_TouchDown;
                    //vb.MouseDown += ViewBox_MouseDown;
                    vb.Margin = new Thickness(2);
                    sp.Children.Add(vb);

                    int nbImageToInsert = 0;
                    while (nbImageToInsert < nbItemInRow-1)
                    {
                        if (cursor + 1 < imgList.Count)
                        {
                            cursor++;

                            MyImage img2 = new MyImage();
                            img2.OriginalPath = imgList[cursor].path;
                            //System.Windows.Controls.Image img = new System.Windows.Controls.Image();
                            img2.Source = BitmapUtil.GetImageSource(imgList[cursor].path); //new BitmapImage(new Uri(imgList[cursor].path));

                            Viewbox vb2 = new Viewbox { Width = 200, Child = img2 };
                            vb2.TouchDown += ViewBox_TouchDown;
                            vb2.Margin = new Thickness(2);
                            sp.Children.Add(vb2);
                        }
                        nbImageToInsert++;
                    }
                    il.Content = sp;
                    surfaceListBox1.Items.Add(il);

                    cursor++;
                }
            });

            // Start the timer
            _timer.Start();
        }
        private void SendTimerForLoading()
        {
            // Set the callback to just show the time ticking away
            // NOTE: We are using a control so this has to run on
            // the UI thread
            _timer.Tick += new EventHandler(delegate(object s, EventArgs a)
            {
                SurfaceListBoxItem il;
                StackPanel sp;

                if (listFile.Count == 0 || nbLoadedImage >= stepLoading)
                {
                    //surfaceSlider1.Minimum = 0;
                    //surfaceSlider1.Maximum = nbItem / nbColumn;
                    //surfaceSlider1.Value = nbItem / nbColumn;
                    loadFinished = true;
                    chargementLabel.Content = "Loading finish ";
                    _timer.Stop();
                    WaitingAnimation.IsAnimated = false;
                    WaitingAnimation.Visibility = System.Windows.Visibility.Hidden;
                    gridWating.Visibility = System.Windows.Visibility.Hidden;

                    SurfaceWindow1.changeMessagePage(LocalizationManager.ResourceManager.GetString("TouchTwoTimeToSelect"));
                    return;
                }

                il = new SurfaceListBoxItem();
                sp = new StackPanel();
                sp.Orientation = Orientation.Horizontal;
                for (int i = 0; i < nbColumn; i++)
                {
                    if (listFile.Count == 0 || nbLoadedImage >= stepLoading) break;
                    AddImageToStackPanel(ref sp);
                }
                il.Content = sp;
                surfaceListBox1.Items.Add(il);
            });

            // Start the timer
            _timer.Start();
        }
Пример #20
0
        private void item_Selected(Object sender, RoutedEventArgs e)
        {
            try
            {
                SurfaceListBoxItem i = sender as SurfaceListBoxItem;

                //abs = new PubAbstract(result.Links.ElementAt(ds.Publictions.Items.IndexOf(i)), result.getAuthors());

                ScatterViewItem absBox = new ScatterViewItem();
                absBox.CanRotate = false;
                absBox.CanScale  = false;
                TextBlock abstext = new TextBlock();
                abstext.Text = i.Tag as string;

                SurfaceWindow1.addData(sender, absBox);

                absBox.Content = abstext;

                //absBox.absgrid.Children.Add(abstext);


                absBox.Background  = Brushes.SteelBlue;
                abstext.Background = Brushes.White;
                abstext.Margin     = new Thickness(10);

                absBox.Width      = 800;
                absBox.MinHeight  = 600;
                abstext.Width     = 780;
                abstext.MinHeight = 580;

                absBox.ContainerManipulationCompleted += new ContainerManipulationCompletedEventHandler(absBox_ContainerManipulationCompleted);

                /*TextBlock Title = new TextBlock();
                 * Title.Text = i.Content as string;
                 * absBox.absgrid.Children.Add(Title);
                 * Grid.SetRow(Title, 0);
                 * Grid.SetColumn(Title, 1);
                 *
                 * TextBlock Authors = new TextBlock();
                 * Authors.Text = result.Authors.ElementAt(ds.Publictions.Items.IndexOf(i));
                 * absBox.absgrid.Children.Add(Title);
                 * Grid.SetRow(Authors, 1);
                 * Grid.SetColumn(Authors, 1);
                 *
                 * TextBlock Journal = new TextBlock();
                 * Journal.Text = abs.getJournal();
                 * absBox.absgrid.Children.Add(Journal);
                 * Grid.SetRow(Journal, 2);
                 * Grid.SetColumn(Journal, 1);
                 *
                 *
                 * ds.Publictions.Items.IndexOf(i);
                 *
                 * /*ScatterViewItem abstractbox = new ScatterViewItem();
                 * TextBlock abstext = new TextBlock();
                 * SurfaceListBoxItem i = sender as SurfaceListBoxItem;
                 * abstext.Text = i.Tag as string;
                 * abstractbox.Content = abstext;*/

                sw1.L0.L0_SV.Items.Add(absBox);
            }
            catch (Exception exc) { Console.WriteLine(exc); }
        }
Пример #21
0
        private void select_DataSheet(object sender, RoutedEventArgs e)
        {
            //try
            //{
            //_thisRegDS = new RegDataSheet("http://partsregistry.org/wiki/index.php?title=Part:" + this.partName.Text);

            ds = new MenuDataSheet();
            ds.ContainerManipulationCompleted += new ContainerManipulationCompletedEventHandler(onDSManipulationCompleted);

            if (_myRegDS.Name != "test") //Already got data from registry, so just populate from it
            {
                #region Populating the data sheet's datasheet
                //Specifies the Length of the Sequence on the Sequence tab of the data sheet
                int       Length      = _myRegDS.BasicInfo.Length;
                TextBlock LengthBlock = new TextBlock();
                //ds.SeqTab.Children.Add(LengthBlock);
                LengthBlock.VerticalAlignment = VerticalAlignment.Top;
                LengthBlock.Text = "Length: " + Length.ToString();

                //This is all pulling information from the Reg Data Sheet associated with the part and inserting it in the data sheet
                ds.PopulateDataSheet(_myRegDS.Name, 0, 1, ds.DataSheet, "datasheet");
                ds.PopulateDataSheet(_myRegDS.BasicInfo.DescriptionName, 1, 1, ds.DataSheet, "datasheet");
                ds.PopulateDataSheet(_myRegDS.Type, 2, 1, ds.DataSheet, "datasheet");
                ds.PopulateDataSheet(_myRegDS.Promoter.getReg(), 3, 1, ds.DataSheet, "datasheet");
                ds.PopulateDataSheet(_myRegDS.BasicInfo.Availability, 4, 1, ds.DataSheet, "datasheet");
                ds.PopulateDataSheet(_myRegDS.BasicInfo.Usefulness, 5, 1, ds.DataSheet, "datasheet");
                ds.PopulateDataSheet(_myRegDS.Description.assembCompString(), 6, 1, ds.DataSheet, "datasheet");
                ds.PopulateDataSheet(_myRegDS.Description.chassisString(), 7, 1, ds.DataSheet, "datasheet");



                //Specific to sequence tab
                ds.PopulateDataSheet(_myRegDS.BasicInfo.Sequence, 1, 1, ds.SeqTab, "seq");
                ds.PopulateDataSheet(Length.ToString(), 0, 1, ds.SeqTab, "length");

                //Specific to AuthorInfo Tab
                ds.PopulateDataSheet(_myRegDS.Reference.Author, 0, 1, ds.AuthorInfo, "author");
                ds.PopulateDataSheet(_myRegDS.Reference.Group, 1, 1, ds.AuthorInfo, "author");
                ds.PopulateDataSheet(_myRegDS.Reference.Date, 2, 1, ds.AuthorInfo, "author");

                if (_myRegDS.Type == "rbs")
                {
                    RowDefinition rowDef1 = new RowDefinition();
                    ds.DataSheet.RowDefinitions.Add(rowDef1);
                    ds.PopulateDataSheet(_myRegDS.Rbs.FamilyName, 8, 1, ds.DataSheet);
                    TextBlock RBSFam = new TextBlock();
                    RBSFam.Text = "Family";
                    ds.DataSheet.Children.Add(RBSFam);
                    Grid.SetRow(RBSFam, 8);
                }
                else if (_myRegDS.Type == "terminator")
                {
                    RowDefinition rowDef1 = new RowDefinition();
                    RowDefinition rowDef2 = new RowDefinition();
                    RowDefinition rowDef3 = new RowDefinition();
                    RowDefinition rowDef4 = new RowDefinition();

                    ds.DataSheet.RowDefinitions.Add(rowDef1);
                    ds.DataSheet.RowDefinitions.Add(rowDef2);
                    ds.DataSheet.RowDefinitions.Add(rowDef3);
                    ds.DataSheet.RowDefinitions.Add(rowDef4);

                    TextBlock Direction = new TextBlock();
                    Direction.Text     = "Direction";
                    Direction.FontSize = 18;
                    ds.DataSheet.Children.Add(Direction);
                    Grid.SetRow(Direction, 8);

                    ds.PopulateDataSheet(_myRegDS.Terminators.Direction, 8, 1, ds.DataSheet);
                    ds.PopulateDataSheet(_myRegDS.Terminators.ForwardEff, 9, 1, ds.DataSheet);
                    ds.PopulateDataSheet(_myRegDS.Terminators.ReversedEff, 10, 1, ds.DataSheet);
                    ds.PopulateDataSheet(_myRegDS.Terminators.ReversedVers, 11, 1, ds.DataSheet);
                }

                #endregion

                #region Populating Publications
                Func <String, PubList> _GetPublications =
                    delegate(String id) { return(new PubList(id)); };
                Action <PubList> callback = delegate(PubList result)
                {
                    //_thisRegDS = new RegDataSheet("http://partsregistry.org/wiki/index.php?title=Part:" + this.partName.Text);

                    int m = 0;

                    if (result.Titles.Count == 0)
                    {
                        int Count = result.Titles.Count;
                        SurfaceListBoxItem NoResults = new SurfaceListBoxItem();
                        TextBlock          Content   = new TextBlock();
                        Content.Text      = "No Results Found";
                        NoResults.Content = Content;
                        ds.Publictions.Items.Add(NoResults);
                    }

                    if (result.Titles.Count > 0)
                    {
                        int TotalArticles = result.Titles.Count;
                        SurfaceListBoxItem ArticleCount = new SurfaceListBoxItem();
                        TextBlock          CountContent = new TextBlock();
                        CountContent.Text    = "Results Found: " + TotalArticles as string;
                        ArticleCount.Content = CountContent;
                        ds.Publictions.Items.Add(ArticleCount);
                    }

                    foreach (String Titles in result.Titles)
                    {
                        //To Test if titles are actually adding
                        SurfaceListBoxItem item      = new SurfaceListBoxItem();
                        TextBlock          PubTitles = new TextBlock();
                        item.Selected += new RoutedEventHandler(item_Selected);
                        item.Content   = Titles;
                        PubTitles.Tag  = result.Links.ElementAt(m);
                        //item.Tag = result.Authors.ElementAt(m);
                        ds.Publictions.Items.Add(item);
                        RowDefinition rowDef1 = new RowDefinition();
                        RowDefinition rowDef2 = new RowDefinition();
                        RowDefinition rowDef3 = new RowDefinition();
                        RowDefinition rowDef4 = new RowDefinition();

                        abs = new PubAbstract(PubTitles.Tag as string, result.getAuthors());

                        item.Tag = "Title:  " + item.Content as string + "\r\n" + "\r\n" + "\r\n"

                                   + "Authors:   " + result.Authors.ElementAt(m) as string + "\r\n" + "\r\n"

                                   + "Abstract:" + "\r\n" + "\r\n"

                                   + abs.getAbstract() as string;

                        m += 1;
                        Console.WriteLine(m);

                        if (m > 20)
                        {
                            break;
                        }
                    }

                    /*foreach (String Titles in result.Titles)
                     * {
                     *  TextBlock Middle = new TextBlock();
                     *  Middle.Text = Titles;
                     *  //ds.Publications.Children.Add(Middle);
                     *  Grid.SetRow(Middle, m);
                     *  m += 1;
                     #endregion
                     * //publications location maybe
                     * //Creates a list of PubMed source related to the query
                     *
                     * }*/
                };
                _Publist = _progressBarWrapper.execute <String, PubList>(_GetPublications, _myRegDS.BasicInfo.DescriptionName, callback);
                #endregion
                SurfaceWindow1.addData(sender, ds);
            }
            else
            {
                Func <String, RegDataSheet> _getRegDataSheet =
                    delegate(String pName) { return(new RegDataSheet("http://partsregistry.org/wiki/index.php?title=Part:" + pName)); };
                Action <RegDataSheet> _getRegDataSheetCallback = delegate(RegDataSheet _regDS)
                {
                    _myRegDS = _regDS;
                    #region Populating the data sheet's datasheet
                    //Specifies the Length of the Sequence on the Sequence tab of the data sheet
                    int       Length      = _myRegDS.BasicInfo.Length;
                    TextBlock LengthBlock = new TextBlock();
                    //ds.SeqTab.Children.Add(LengthBlock);
                    LengthBlock.VerticalAlignment = VerticalAlignment.Top;
                    LengthBlock.Text = "Length: " + Length.ToString();

                    //This is all pulling information from the Reg Data Sheet associated with the part and inserting it in the data sheet
                    ds.PopulateDataSheet(_myRegDS.Name, 0, 1, ds.DataSheet, "datasheet");
                    ds.PopulateDataSheet(_myRegDS.BasicInfo.DescriptionName, 1, 1, ds.DataSheet, "datasheet");
                    ds.PopulateDataSheet(_myRegDS.Type, 2, 1, ds.DataSheet, "datasheet");
                    ds.PopulateDataSheet(_myRegDS.Promoter.getReg(), 3, 1, ds.DataSheet, "datasheet");
                    ds.PopulateDataSheet(_myRegDS.BasicInfo.Availability, 4, 1, ds.DataSheet, "datasheet");
                    ds.PopulateDataSheet(_myRegDS.BasicInfo.Usefulness, 5, 1, ds.DataSheet, "datasheet");
                    ds.PopulateDataSheet(_myRegDS.Description.assembCompString(), 6, 1, ds.DataSheet, "datasheet");
                    ds.PopulateDataSheet(_myRegDS.Description.chassisString(), 7, 1, ds.DataSheet, "datasheet");

                    //Specific to sequence tab
                    ds.PopulateDataSheet(_myRegDS.BasicInfo.Sequence, 1, 1, ds.SeqTab, "seq");
                    ds.PopulateDataSheet(Length.ToString(), 0, 1, ds.SeqTab, "length");

                    //Specific to AuthorInfo Tab
                    ds.PopulateDataSheet(_myRegDS.Reference.Author, 0, 1, ds.AuthorInfo, "author");
                    ds.PopulateDataSheet(_myRegDS.Reference.Group, 1, 1, ds.AuthorInfo, "author");
                    ds.PopulateDataSheet(_myRegDS.Reference.Date, 2, 1, ds.AuthorInfo, "author");

                    if (_myRegDS.Type == "rbs")
                    {
                        RowDefinition rowDef1 = new RowDefinition();
                        ds.DataSheet.RowDefinitions.Add(rowDef1);
                        ds.PopulateDataSheet(_myRegDS.Rbs.FamilyName, 8, 1, ds.DataSheet);
                        TextBlock RBSFam = new TextBlock();
                        RBSFam.Text              = "Family";
                        RBSFam.FontSize          = 14;
                        RBSFam.FontWeight        = FontWeights.Bold;
                        RBSFam.VerticalAlignment = VerticalAlignment.Top;
                        // COME BACK TO THIS LATER

                        ds.DataSheet.Children.Add(RBSFam);
                        Grid.SetRow(RBSFam, 8);
                    }
                    else if (_myRegDS.Type == "terminator")
                    {
                        RowDefinition rowDef1 = new RowDefinition();
                        RowDefinition rowDef2 = new RowDefinition();
                        RowDefinition rowDef3 = new RowDefinition();
                        RowDefinition rowDef4 = new RowDefinition();

                        ds.DataSheet.RowDefinitions.Add(rowDef1);
                        ds.DataSheet.RowDefinitions.Add(rowDef2);
                        ds.DataSheet.RowDefinitions.Add(rowDef3);
                        ds.DataSheet.RowDefinitions.Add(rowDef4);

                        TextBlock Direction = new TextBlock();
                        Direction.Text     = "Direction";
                        Direction.FontSize = 18;
                        ds.DataSheet.Children.Add(Direction);
                        Grid.SetRow(Direction, 8);

                        ds.PopulateDataSheet(_myRegDS.Terminators.Direction, 8, 1, ds.DataSheet);
                        ds.PopulateDataSheet(_myRegDS.Terminators.ForwardEff, 9, 1, ds.DataSheet);
                        ds.PopulateDataSheet(_myRegDS.Terminators.ReversedEff, 10, 1, ds.DataSheet);
                        ds.PopulateDataSheet(_myRegDS.Terminators.ReversedVers, 11, 1, ds.DataSheet);
                    }

                    #endregion

                    #region Populating Publications
                    Func <String, PubList> _GetPublications =
                        delegate(String id) { return(new PubList(id)); };
                    Action <PubList> callback = delegate(PubList result)
                    {
                        //_thisRegDS = new RegDataSheet("http://partsregistry.org/wiki/index.php?title=Part:" + this.partName.Text);

                        int m = 0;

                        if (result.Titles.Count == 0)
                        {
                            int Count = result.Titles.Count;
                            SurfaceListBoxItem NoResults = new SurfaceListBoxItem();
                            TextBlock          Content   = new TextBlock();
                            Content.Text      = "No Results Found";
                            NoResults.Content = Content;
                            ds.Publictions.Items.Add(NoResults);
                        }

                        if (result.Titles.Count > 0)
                        {
                            int TotalArticles = result.Titles.Count;
                            SurfaceListBoxItem ArticleCount = new SurfaceListBoxItem();
                            TextBlock          CountContent = new TextBlock();
                            CountContent.Text    = "Results Found: " + TotalArticles as string;
                            ArticleCount.Content = CountContent;
                            ds.Publictions.Items.Add(ArticleCount);
                        }

                        foreach (String Titles in result.Titles)
                        {
                            //To Test if titles are actually adding
                            SurfaceListBoxItem item      = new SurfaceListBoxItem();
                            TextBlock          PubTitles = new TextBlock();
                            item.Selected += new RoutedEventHandler(item_Selected);
                            item.Content   = Titles;
                            PubTitles.Tag  = result.Links.ElementAt(m);
                            //item.Tag = result.Authors.ElementAt(m);
                            ds.Publictions.Items.Add(item);
                            RowDefinition rowDef1 = new RowDefinition();
                            RowDefinition rowDef2 = new RowDefinition();
                            RowDefinition rowDef3 = new RowDefinition();
                            RowDefinition rowDef4 = new RowDefinition();

                            abs = new PubAbstract(PubTitles.Tag as string, result.getAuthors());

                            item.Tag = "Title:  " + item.Content as string + "\r\n" + "\r\n" + "\r\n"

                                       + "Authors:   " + result.Authors.ElementAt(m) as string + "\r\n" + "\r\n"

                                       + "Abstract:" + "\r\n" + "\r\n"

                                       + abs.getAbstract() as string;

                            m += 1;
                            Console.WriteLine(m);

                            if (m > 20)
                            {
                                break;
                            }
                        }

                        /*foreach (String Titles in result.Titles)
                         * {
                         *  TextBlock Middle = new TextBlock();
                         *  Middle.Text = Titles;
                         *  //ds.Publications.Children.Add(Middle);
                         *  Grid.SetRow(Middle, m);
                         *  m += 1;
                         #endregion
                         * //publications location maybe
                         * //Creates a list of PubMed source related to the query
                         *
                         * }*/
                    };
                    _Publist = _progressBarWrapper.execute <String, PubList>(_GetPublications, _myRegDS.BasicInfo.DescriptionName, callback);
                    #endregion
                    SurfaceWindow1.addData(sender, ds);
                };
                _dataSheet = _progressBarWrapper.execute <String, RegDataSheet>(_getRegDataSheet, partName.Text, _getRegDataSheetCallback);
            }
        }
Пример #22
0
        /* public XmlDocument ReadXMLData(XmlDocument xmlDoc, string FullPath)
         * {
         *   xmlDoc.Load(FullPath);
         *
         *   return xmlDoc;
         * } */

        public void ImageItem_selected(object sender, RoutedEventArgs e)
        {
            SurfaceListBoxItem Item = e.Source as SurfaceListBoxItem;

            System.Windows.Point Center = new System.Windows.Point(950.0, 450.0);
            string          ScatterName = Item.Name;
            ScatterViewItem Obj         = LogicalTreeHelper.FindLogicalNode(scatterView1, ScatterName) as ScatterViewItem;

            if (Obj == null)  // if the object does not already exists create it
            {
                XmlDocument xmlDoc = new XmlDocument();

                int index = Convert.ToInt32(Item.Name.Substring(5, 2));

                if (Item.Name.Substring(0, 5) == "Local")
                {
                    XML_IO.ReadXMLData(xmlDoc, LocalFileNames[index - 1].ToString());
                }
                else
                {
                    XML_IO.ReadXMLData(xmlDoc, FileNames[index - 1].ToString());
                }

                ScatterViewItem newScatterViewItem = new ScatterViewItem();
                newScatterViewItem.Name       = Item.Name;
                newScatterViewItem.Background = Item.Background;
                newScatterViewItem.Height     = 270;
                newScatterViewItem.Width      = 360;

                newScatterViewItem.Center = Center;

                // add a resize event to scale the grid
                newScatterViewItem.SizeChanged += new SizeChangedEventHandler(newScatterViewItem_SizeChanged);

                //  Grid newGrid = new Grid();
                SURGISControl1 newGrid = new SURGISControl1(this);

                XmlNode GISData = xmlDoc.SelectSingleNode("//GISData/MapLoc");

                newGrid.Longitude   = Convert.ToDouble(GISData.Attributes["long"].Value);
                newGrid.Lattitude   = Convert.ToDouble(GISData.Attributes["lat"].Value);
                newGrid.CameraLevel = Convert.ToDouble(GISData.Attributes["alt"].Value);

                XmlNodeList Polygons = xmlDoc.SelectNodes("//GISData/Polygons/Polygon");

                foreach (XmlNode Polygon in Polygons)
                {
                    MapPolygon NewGridPoly = new MapPolygon();
                    NewGridPoly.Locations = new LocationCollection();
                    NewGridPoly.Name      = Item.Name + Polygon.Attributes.GetNamedItem("name").Value;

                    XmlNodeList Points = Polygon.ChildNodes;

                    foreach (XmlNode Point in Points)
                    {
                        Location NewGridPolyPoint = new Location();

                        NewGridPolyPoint.Latitude  = Convert.ToDouble(Point.Attributes.GetNamedItem("lat").Value);
                        NewGridPolyPoint.Longitude = Convert.ToDouble(Point.Attributes.GetNamedItem("long").Value);

                        NewGridPoly.Locations.Add(NewGridPolyPoint);
                    }

                    newGrid.Polygons.Add(NewGridPoly);
                }

                newGrid.Background = Item.Background;

                newScatterViewItem.Content = newGrid;

                scatterView1.Items.Add(newScatterViewItem);
            }    // if obj== null

            else /// object exists
            {
                if (Obj.Visibility == Visibility.Collapsed)
                {
                    Obj.Visibility = Visibility.Visible;
                    Obj.Width      = 360;
                    Obj.Height     = 270;
                }
            }
            Item.IsSelected = false;
        }
        /// <summary>
        /// Occurs when the player enter his name and type on the enter key.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void SurfaceTextBox_KeyDown(object sender, KeyEventArgs e)
        {
            Key enter = Key.Return;
            if (e.Key.Equals(enter))
            {
                // Create the score
                Score s = new Score(this.name.Text, this.duration, this.currentShape.getIndex);

                //undisplay the SurfaceTextBox for enter the name
                this.name.Visibility = (Visibility)1;

                //display all the scores for the shape
                SurfaceListBox score = (SurfaceListBox)Resources["top"];
                String[] scores = Score.scoreTable(this.currentShape.getIndex);
                foreach (String c in scores)
                {
                    SurfaceListBoxItem item = new SurfaceListBoxItem();
                    item.Content = c;
                    score.Items.Add(item);
                }
                this.grid.Children.Add(score);
            }
        }
        public void loadMetadata(string filename)
        {
            int count = 0;
            string dataDir = "data/";
            Helpers helpers = new Helpers();
            XmlDocument doc = new XmlDocument();
            doc.Load("data/NewCollection.xml");
            if (doc.HasChildNodes)
            {
                foreach (XmlNode docNode in doc.ChildNodes)
                {
                    if (docNode.Name == "Collection")
                    {
                        foreach (XmlNode node in docNode.ChildNodes)
                        {
                            if (node.Name == "Image")
                            {
                                if (filename != node.Attributes.GetNamedItem("path").InnerText)
                                    continue;
                                foreach (XmlNode imgnode in node.ChildNodes)
                                {
                                    if (imgnode.Name == "Metadata")
                                    {
                                        foreach (XmlNode group in imgnode.ChildNodes)
                                        {
                                            foreach (XmlNode file in group.ChildNodes)
                                            {
                                                string metadatafilename = file.Attributes.GetNamedItem("Filename").InnerText;
                                                count++;
                                                string name;
                                                string description = "";
                                                try
                                                {
                                                    name = file.Attributes.GetNamedItem("Name").InnerText;
                                                }
                                                catch (Exception exc)
                                                {
                                                    name = "Untitled";
                                                }
                                                try
                                                {
                                                    description = file.Attributes.GetNamedItem("Description").InnerText;
                                                }
                                                catch (Exception exc)
                                                {

                                                }

                                                if (helpers.IsImageFile(metadatafilename))
                                                {
                                                    new AssociatedDocListBoxItem(name, "Data\\Images\\Metadata\\" + metadatafilename, System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "\\Data\\Images\\Metadata\\" + metadatafilename, this, description);
                                                }
                                                else if (helpers.IsVideoFile(metadatafilename))
                                                {
                                                    new AssociatedDocListBoxItem(name, "Data\\Videos\\Metadata\\" + metadatafilename, "Data\\Videos\\Metadata\\" + metadatafilename, this, description);
                                                }
                                            }

                                        }
                                    }

                                }

                            }
                        }
                    }
                }
            }
            if (count == 0)
            {
                SurfaceListBoxItem item = new SurfaceListBoxItem();
                item.Content = "(No assets for this artwork)";
                treeDocs.Items.Add(item);
            }
        }
        private void FillListByDate()
        {
            typeOfSelection = globalDatasingleton.TypeOfSelection.BYDATE;
            SurfaceListBoxItem il = null;
            ItemListCategory ilc = null;

            CategoriesXml xmlcat = globalDatasingleton.getInstance().getCategories();

            if (fs.isEmpty == true)
            {
                foreach (string dirs in xmlcat.getListDirectory())
                {
                    fs.AddDirectory(dirs);
                }
            }

            surfaceListBox1.Items.Clear();

            il = new SurfaceListBoxItem();
            ilc = new ItemListCategory();
            ilc.Label = LocalizationManager.ResourceManager.GetString("ChoicebyCategory");
            il.Content = ilc;
            surfaceListBox1.Items.Add(il);

            // On ajoute un item dans la liste pour correspondre au index de la surfaceListbox
            dateTimeItemsList.Add(DateTime.Today);

            DateTime curTime = DateTime.Today;
            for (int i = 0; i < 15; i++)
            {
                if (fs.getFiles(curTime).Count > 0)
                {
                  //  string spaceString = "";
                    il = new SurfaceListBoxItem();
                    ilc = new ItemListCategory();
                    ilc.GrowingStep = 0;
                    /*for (int n = 20-curTime.DayOfWeek.ToString().Length; n>0 ; n--)
                    {
                        spaceString += " ";
                    }
                     */

                    ilc.Label = curTime.Day.ToString() + " / " + curTime.Month + " / " + curTime.Year;
                    il.Content = ilc;
                    surfaceListBox1.Items.Add(il);
                    DateTime dateTmp = new DateTime(curTime.Year, curTime.Month, curTime.Day);
                    dateTimeItemsList.Add(dateTmp);
                }
                curTime = curTime.AddDays(-1);
            }
        }
Пример #26
0
        public void UpdateDomainList()
        {
            // check domains for new or changed items
            lock (Plugin.domains)
            {
                foreach (DomainNewEvent domain in Plugin.domains.Values)
                {
                    bool found = false;
                    foreach (SurfaceListBoxItem lbi in LayersListBox.Items)
                    {
                        if ((string)lbi.Tag == domain.domain)
                        {
                            found = true;
                            break;
                        }
                    }
                    if (!found)
                    {
                        // create here because of image thread ownership problems
                        domain.dynamicImage = new DynamicImage(this,
                            Plugin.Connection.Subscribe(domain.eventName, false),
                            Plugin.Connection.Subscribe(Plugin.privateEvent.EventName + "." + domain.domain, false),
                            domain.cols, domain.rows);
                                    
                        Image im = new Image();
                        im.Source = domain.dynamicImage.ImageSrc;
                        im.Stretch = Stretch.Uniform;
                        im.Height = 100;
                        im.Tag = domain.domain;
                        im.IsHitTestVisible = false;
                        
                        Label lbl = new Label();
                        lbl.Content = domain.domain;
                        lbl.FontSize = 10;
                        lbl.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Center;

                        Path pathZoom = new Path();
                        pathZoom.Data = ZoomPath.Data;
                        pathZoom.Stretch = ZoomPath.Stretch;
                        pathZoom.Fill = ZoomPath.Fill;
                        pathZoom.Width = ZoomPath.Width;
                        pathZoom.Height = ZoomPath.Height;
                        pathZoom.Margin = ZoomPath.Margin;
                        pathZoom.RenderTransformOrigin = ZoomPath.RenderTransformOrigin;
                        pathZoom.IsHitTestVisible = false;

                        SurfaceButton sbZoom = new SurfaceButton();
                        sbZoom.Height = 15;
                        sbZoom.Width = 15;
                        sbZoom.Tag = domain.domain;
                        sbZoom.Background = Brushes.Transparent;
                        sbZoom.Content = pathZoom;
                        sbZoom.Click += sbZoom_Click;

                        Path pathLegend = new Path();
                        pathLegend.Data = LegendPath.Data;
                        pathLegend.Stretch = LegendPath.Stretch;
                        pathLegend.Fill = LegendPath.Fill;
                        pathLegend.Width = LegendPath.Width;
                        pathLegend.Height = LegendPath.Height;
                        pathLegend.Margin = LegendPath.Margin;
                        pathLegend.RenderTransformOrigin = LegendPath.RenderTransformOrigin;
                        pathLegend.IsHitTestVisible = false;

                        SurfaceButton sbLegend = new SurfaceButton();
                        sbLegend.Height = 15;
                        sbLegend.Width = 15;
                        sbLegend.Tag = domain.domain;
                        sbLegend.Background = Brushes.Transparent;
                        sbLegend.Content = pathLegend;
                        sbLegend.Click += sbLegend_Click;

                        SurfaceButton sbPlus = new SurfaceButton();
                        sbPlus.Height = 15;
                        sbPlus.Width = 15;
                        sbPlus.Tag = domain.domain;
                        sbPlus.Background = Brushes.Transparent;
                        //sbPlus.Content = pathPlus;
                        sbPlus.Click += sbPlus_Click;

                        StackPanel spButtons = new StackPanel();
                        spButtons.Orientation = Orientation.Vertical;
                        spButtons.Children.Add(sbZoom);
                        spButtons.Children.Add(sbLegend);
                        spButtons.Children.Add(sbPlus);

                        StackPanel spImage = new StackPanel();
                        spImage.Orientation = Orientation.Vertical;
                        spImage.Tag = domain.domain;
                        spImage.Children.Add(lbl);
                        spImage.Children.Add(im);

                        StackPanel sp = new StackPanel();
                        sp.Orientation = Orientation.Horizontal;
                        sp.Tag = domain.domain;
                        //sp.Background = Brushes.LightBlue;
                        sp.Children.Add(spButtons);
                        sp.Children.Add(spImage);
                        
                        SurfaceListBoxItem lbi = new SurfaceListBoxItem();
                        lbi.Tag = domain.domain;
                        lbi.Content = sp;
                        lbi.Selected += new RoutedEventHandler(Domain_Selected);
                        
                        lbi.Background = Brushes.LightBlue;
                        lbi.Width = LayersListBox.Width;
                        
                        LayersListBox.Items.Add(lbi);
                    }
                }

                // remove domains
                for (int i = LayersListBox.Items.Count - 1; i >= 0; i--)
                {
                    string key = (string)(LayersListBox.Items[i] as SurfaceListBoxItem).Tag;
                    if (!Plugin.domains.ContainsKey(key))
                        LayersListBox.Items.RemoveAt(i);
                }

            }
        }
        void AddLocalListItem(string FullPath)
        {
            XmlDocument xmlDoc = new XmlDocument();

            XML_IO.ReadXMLData(xmlDoc, FullPath);

            XmlNode ImageNode = xmlDoc.SelectSingleNode("//GISData/GISImage");
            string ImageFile = ImageNode.Attributes["file"].Value;
            BitmapImage BMPimage = new BitmapImage();
            double width, height;

            try
            {
                BMPimage.BeginInit();
                BMPimage.UriSource = new Uri(ImageFile, UriKind.RelativeOrAbsolute);
                BMPimage.EndInit();
            }
            catch (FileNotFoundException i)
            {

                MessageBoxResult Result = MessageBox.Show("Network Error", "Please Manually Refresh");
            }
            width = BMPimage.Width;
            height = BMPimage.Height;

            SurfaceListBoxItem NewImageItem = new SurfaceListBoxItem();

            int x = LocalFileNames.Count;

            if (x <= 9)
                NewImageItem.Name = "Local0" + x.ToString();
            else
                NewImageItem.Name = "Local" + x.ToString();

               // ARList.Add(width / height);

            NewImageItem.Background = new ImageBrush(BMPimage);
            NewImageItem.Height = 80;
            NewImageItem.Padding = new Thickness(5.0);

            NewImageItem.Selected += new RoutedEventHandler(ImageItem_selected);

            LocalBMPList.Items.Add(NewImageItem);
        }
Пример #28
0
 public void UpdateSessionList()
 {
     // check sessions for new or changed items
     lock (Plugin.sessions)
     {
         foreach (SessionNewEvent session in Plugin.sessions.Values)
         {
             bool found = false;
             for (int i = 0; i < SessionsListBox.Items.Count; i++)
             {
                 if ((int)(SessionsListBox.Items[i] as SurfaceListBoxItem).Tag == session.sessionID)
                 {
                     (SessionsListBox.Items[i] as SurfaceListBoxItem).Content = session.GenerateUI();
                     found = true;
                     break;
                 }
             }
             if (!found)
             {
                 SurfaceListBoxItem slbi = new SurfaceListBoxItem();
                 slbi.Content = session.GenerateUI();
                 slbi.Tag = session.sessionID;
                 slbi.Selected += new RoutedEventHandler(Session_Selected);
                 SessionsListBox.Items.Add(slbi);
             }
         }
         // check list box for deleted items
         for (int i = SessionsListBox.Items.Count - 1; i >= 0; i--)
         {
             if (!Plugin.sessions.ContainsKey((int)(SessionsListBox.Items[i] as SurfaceListBoxItem).Tag))
                 SessionsListBox.Items.RemoveAt(i);
         }
         if (Plugin.sessions.Count == 0)
             CurrentSession.Text = "NO sessions";
         else
         {
             if ("NO sessions".CompareTo(CurrentSession.Text) == 0)
                 CurrentSession.Text = "<select session>";
         }
     }
 }
        /*
        private void updatePriceAndImage()
        {
             LoginManager m = LoginControler.getLoginManager();
            if (m != null)
            {
               numberOfTotalPhoto.Content = m.getNbDifferentPicture().ToString();
               numberOfPrintPhoto.Content = m.nbNbPhotoOnCD().ToString();
               UpdateShowPrice();
            }
        }
         * */
        private void addImageFromListView(Viewbox img)
        {
            for (int n = 0; n < surfaceListBox1.Items.Count; n++)
            {
                SurfaceListBoxItem li = surfaceListBox1.Items.GetItemAt(n) as SurfaceListBoxItem;
                StackPanel sp = li.Content as StackPanel;

                if (sp.Children.Count < nbItemInRow)
                {
                    sp.Children.Add(img);
                    return;
                }
            }

            SurfaceListBoxItem il = new SurfaceListBoxItem();
            StackPanel sp2 = new StackPanel();
            sp2.Orientation = Orientation.Horizontal;
            il.Content = sp2;
            surfaceListBox1.Items.Add(il);
        }
Пример #30
0
        /// <summary>
        /// Does the collapse transition.
        /// </summary>
        /// <param name="smooth">if set to <c>true</c> [smooth].</param>
        private void DoCollapseTransition(bool smooth)
        {
            if (smooth)
            {
                IsHitTestVisible = false;
            }

            _TriggerButton.Visibility = Visibility.Visible;

            // Find the selected list box item.
            SurfaceListBoxItem selectedItem = GetSelectedItem();

            if (selectedItem == null)
            {
                return;
            }

            SurfaceScrollViewer sv = _ListBox.FindVisualChild <SurfaceScrollViewer>();
            double offset          = selectedItem.TransformToVisual(sv).Transform(new Point()).Y + sv.VerticalOffset;

            sv.PanningMode = PanningMode.None;

            if (!smooth)
            {
                _ListBox.Height = selectedItem.ActualHeight;
                _ListBox.Margin = new Thickness();
                sv.ScrollToVerticalOffset(offset);
                SizeChanged += ListBox_SizeChanged;
                return;
            }

            Storyboard storyboard = new Storyboard();

            DoubleAnimation height = new DoubleAnimation();

            Storyboard.SetTarget(height, _ListBox);
            Storyboard.SetTargetProperty(height, new PropertyPath(ListBox.HeightProperty));
            height.To             = selectedItem.ActualHeight;
            height.EasingFunction = new SineEase {
                EasingMode = EasingMode.EaseOut
            };
            height.Duration = _ExpandDuration;
            storyboard.Children.Add(height);

            ThicknessAnimation margin = new ThicknessAnimation();

            Storyboard.SetTarget(margin, _ListBox);
            Storyboard.SetTargetProperty(margin, new PropertyPath(ListBox.MarginProperty));
            margin.To             = new Thickness();
            margin.EasingFunction = new SineEase {
                EasingMode = EasingMode.EaseOut
            };
            margin.Duration = _ExpandDuration;
            storyboard.Children.Add(margin);

            DoubleAnimation verticalOffset = new DoubleAnimation();

            Storyboard.SetTarget(verticalOffset, this.FindVisualChild <ScrollViewerOffsetMediator>());
            Storyboard.SetTargetProperty(verticalOffset, new PropertyPath(ScrollViewerOffsetMediator.VerticalOffsetProperty));
            verticalOffset.To             = offset;
            verticalOffset.EasingFunction = new SineEase {
                EasingMode = EasingMode.EaseOut
            };
            verticalOffset.Duration = _ExpandDuration;
            storyboard.Children.Add(verticalOffset);

            ScrollBar scrollbar = this.FindVisualChild <ScrollBar>();

            if (scrollbar != null)
            {
                DoubleAnimation scroll = new DoubleAnimation();
                Storyboard.SetTarget(scroll, scrollbar);
                Storyboard.SetTargetProperty(scroll, new PropertyPath(UIElement.OpacityProperty));
                scroll.To             = 0;
                scroll.EasingFunction = new SineEase {
                    EasingMode = EasingMode.EaseOut
                };
                scroll.Duration = _ExpandDuration;
                storyboard.Children.Add(scroll);
            }

            height.Completed += (sender, e) =>
            {
                IsHitTestVisible = true;
                SizeChanged     += ListBox_SizeChanged;
            };

            storyboard.Begin(this, true);
        }