Пример #1
0
        private void MoveThumb_DragStarted(object sender, DragStartedEventArgs e)
        {
            this.designerItem       = DataContext as DesignerBaseItem;
            designerItem.IsSelected = true;

            if (this.designerItem != null)
            {
                this.rotateTransform = this.designerItem.RenderTransform as RotateTransform;
            }
        }
Пример #2
0
        private void UpdateSelection()
        {
            designerCanvas.ClearSelection();

            Rect rubberBand = new Rect(startPoint.Value, endPoint.Value);

            foreach (UIElement item in designerCanvas.Children)
            {
                Rect itemRect   = VisualTreeHelper.GetDescendantBounds(item);
                Rect itemBounds = item.TransformToAncestor(designerCanvas).TransformBounds(itemRect);

                if (rubberBand.Contains(itemBounds))
                {
                    if (item is DesignerBaseItem)
                    {
                        DesignerBaseItem im = item as DesignerBaseItem;
                        im.IsSelected = true;
                        designerCanvas.SelectedItems.Add(im);
                    }
                }
            }
        }
Пример #3
0
        void LoadProjectFile()
        {
            FileStream fs;

            try
            {
                fs = new FileStream(filename, FileMode.Open);
            }
            catch (FileNotFoundException)
            {
                MessageBox.Show("The file not found. Sorry.");
                return;
            }
            catch (Exception)
            {
                MessageBox.Show("Can't open file");
                return;
            }

            XmlTextReader xmlIn = new XmlTextReader(fs);

            xmlIn.WhitespaceHandling = WhitespaceHandling.None;
            xmlIn.MoveToContent();

            if (xmlIn.Name != "PhotoWorkshopProject")
            {
                throw new ArgumentException("Incorrect file format.");
            }
            string version = xmlIn.GetAttribute(0);

            int xIndex = 1;

            do
            {
                if (!xmlIn.Read())
                {
                    throw new ArgumentException("An element was expected but could not be read in");
                }


                if ((xmlIn.NodeType == XmlNodeType.EndElement) && (xmlIn.Name == "PhotoWorkshopProject"))
                {
                    break;
                }

                if (xmlIn.NodeType == XmlNodeType.EndElement)
                {
                    continue;
                }

                if (xmlIn.Name == "PhotoPicture")
                {
                    LoadPictureFromFile(xmlIn);
                    continue;
                }

                if (xmlIn.Name == "DesignerItem")
                {
                    DesignerBaseItem item = DesignerBaseItem.CreateDesignerItemByID(Convert.ToInt32(xmlIn.GetAttribute("Kind")));
                    imageCanvas.Children.Add(item);
                    item.LoadFromFile(xmlIn);
                    Canvas.SetZIndex(item, xIndex);
                }
                if (xmlIn.Name == "BaseFrame")
                {
                    BasePhotoFrame frame = BasePhotoFrame.CreatePhotoFrameByID(Convert.ToInt32(xmlIn.GetAttribute("Kind")));
                    frame.LoadFromFile(xmlIn);
                    PhotoFrame = frame;
                }
                if (xmlIn.Name == "ProjectProperties")
                {
                    LoadProjectPropertiesFromFile(xmlIn);
                }

                xIndex++;
            } while (!xmlIn.EOF);

            xmlIn.Close();
            fs.Close();

            if (PhotoFrame != null)
            {
                PhotoFrame.Visualize(ImageCanvas, imageControl.Width, imageControl.Height);
            }
        }