Beispiel #1
0
        /// <summary>
        /// Loads the contents of the specified filename in the given <see cref="Desktop"/> instance.
        /// </summary>
        /// <param name="desktop">The desktop.</param>
        /// <param name="filename">The filename.</param>
        public static void Load(Desktop desktop, string filename)
        {
            XElement root = LoadFromFile(filename);

            if (root == null)
            {
                return;
            }

            // Widget Deserialization
            IEnumerable<XElement> widgetsXML = root.Elements("WidgetElements").Elements("WidgetElement");

            foreach (XElement widgetXML in widgetsXML)
            {
                Guid id = new Guid(widgetXML.Element("Id").Value);
                WidgetElement item = DeserializeWidget(widgetXML, id, 0, 0);

                desktop.AddElement(item, item.GetPosition());
            }

            // Shortcut Deserialization
            IEnumerable<XElement> shortcutsXML = root.Elements("ShortcutElements").Elements("ShortcutElement");
            int ti = 0;

            foreach (XElement shortcutXML in shortcutsXML)
            {
                Guid id = new Guid(shortcutXML.Element("Id").Value);
                ShortcutElement item = DeserializeShortcut(shortcutXML, id, 0, 0);

                item.TabIndex = ++ti;

                desktop.AddElement(item, item.GetPosition());
            }
        }
Beispiel #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RubberbandAdorner"/> class.
        /// </summary>
        /// <param name="canvas">The canvas.</param>
        /// <param name="dragStartPoint">The drag start point.</param>
        public RubberbandAdorner(Desktop canvas, Point? dragStartPoint)
            : base(canvas)
        {
            ColorConverter cconverter = new ColorConverter();

            this.desktop                    = canvas;
            this.startPoint                 = dragStartPoint;
            this.rubberbandPen              = new Pen(new SolidColorBrush((Color)cconverter.ConvertFrom("#FF7AA3D4")), 1);
            this.rubberbandPen.DashStyle    = new DashStyle();
            this.backgroundBrush            = new SolidColorBrush((Color)cconverter.ConvertFrom("#FFC5D5E9"));
            this.backgroundBrush.Opacity    = 0.40;
        }
Beispiel #3
0
        /// <summary>
        /// Saves the contents of the specified <see cref="Desktop"/> instance in the given file.
        /// </summary>
        /// <param name="desktop">The desktop.</param>
        /// <param name="filename">The filename.</param>
        public static void Save(Desktop desktop, string filename)
        {
            IEnumerable<WidgetElement> widgets = desktop.Children.OfType<WidgetElement>();
            IEnumerable<ShortcutElement> shortcuts = desktop.Children.OfType<ShortcutElement>();

            XElement widgetsItemsXML = SerializeWidgets(widgets);
            XElement shortcutsItemsXML = SerializeShortcuts(shortcuts);

            XElement root = new XElement("Root");

            root.Add(widgetsItemsXML);
            root.Add(shortcutsItemsXML);

            SaveFile(filename, root);
        }
Beispiel #4
0
 public SelectionService(Desktop canvas)
 {
     this.canvas = canvas;
 }