public WidgetProxy CreateFriendWidget(string id, string name)
        {
            var widget = new WidgetProxy(id, name, false, true);

            Widgets.Add(widget);
            return(widget);
        }
        //puts widget from source folder to the Mosaic\Widgets folder
        public void InstallWidget(string source, string name)
        {
            if (!Directory.Exists(source))
            {
                return;
            }
            if (!Directory.Exists(Envi.WidgetsRoot + "\\" + name))
            {
                Directory.CreateDirectory(Envi.WidgetsRoot + "\\" + name);
            }
            foreach (var file in Directory.GetFiles(source))
            {
                File.Copy(file, Envi.WidgetsRoot + "\\" + name + "\\" + Path.GetFileName(file));
            }

            if (HasWidget(name))
            {
                return;
            }
            string widgetDll = Envi.WidgetsRoot + "\\" + name + "\\" + name + ".dll";

            if (File.Exists(widgetDll))
            {
                var w = new WidgetProxy(widgetDll);
                //w.Load();
                if (w.HasErrors)
                {
                    return;
                }
                Widgets.Add(w);
            }
        }
        public WidgetProxy CreateWidget(string url)
        {
            var widget = new WidgetProxy(url, null, true);

            Widgets.Add(widget);
            return(widget);
        }
        public void FindWidgets()
        {
            if (!Directory.Exists(Envi.WidgetsRoot))
            {
                return;
            }
            var files = from x in Directory.GetDirectories(Envi.WidgetsRoot)
                        where File.Exists(x + "\\" + Path.GetFileNameWithoutExtension(x) + ".dll")
                        select x + "\\" + Path.GetFileNameWithoutExtension(x) + ".dll";

            foreach (var f in files)
            {
                var w = new WidgetProxy(f);
                //w.Load();
                if (w.HasErrors)
                {
                    continue;
                }
                Widgets.Add(w);
            }

            foreach (var file in Directory.GetFiles(Envi.WidgetsRoot, "*.bak", SearchOption.AllDirectories))
            {
                File.Delete(file);
            }
            Widgets = Widgets.OrderBy(x => x.Name).ToList();
        }
 public void LoadWidget(WidgetProxy widget)
 {
     if (WidgetLoaded != null)
     {
         WidgetLoaded(widget);
     }
 }
 void WidgetManagerWidgetLoaded(WidgetProxy widget)
 {
     var control = new WidgetControl(widget) { Order = WidgetHost.Children.Count };
     control.Load();
     PlaceWidget(control);
     //WidgetHost.HorizontalAlignment = HorizontalAlignment.Right;
     WidgetHost.Children.Add(control);
 }
        private void WindowLoaded(object sender, RoutedEventArgs e)
        {
            App.WindowManager.Initialize();
            //MarkupGrid();
            var wid = new WidgetProxy { WidgetComponent = new WidgetDerived() };
            WidgetManagerWidgetLoaded(wid);

            var widClock = new WidgetProxy { WidgetComponent = new WidgetClock() };
            WidgetManagerWidgetLoaded(widClock);
        }
 public void UnloadWidget(WidgetProxy widget)
 {
     if (widget.WidgetType == WidgetType.Generated)
     {
         Widgets.Remove(widget);
     }
     widget.Unload();
     if (WidgetUnloaded != null)
     {
         WidgetUnloaded(widget);
     }
 }
        public void LoadExternalWidget(string file, int row = 0, int column = 0)
        {
            if (!File.Exists(file))
            {
                return;
            }
            var w = new WidgetProxy(file);

            if (w.HasErrors)
            {
                return;
            }
            Widgets.Add(w);
            w.Row    = row;
            w.Column = column;
            w.Load();
            if (WidgetLoaded != null)
            {
                WidgetLoaded(w);
            }
        }
        public void FindWidgets()
        {
            if (!Directory.Exists(Envi.WidgetsRoot))
                return;
            var files = from x in Directory.GetDirectories(Envi.WidgetsRoot)
                        where File.Exists(x + "\\" + Path.GetFileNameWithoutExtension(x) + ".dll")
                        select x + "\\" + Path.GetFileNameWithoutExtension(x) + ".dll";

            foreach (var f in files)
            {
                var w = new WidgetProxy(f);
                //w.Load();
                if (w.HasErrors)
                    continue;
                Widgets.Add(w);
            }

            foreach (var file in Directory.GetFiles(Envi.WidgetsRoot, "*.bak", SearchOption.AllDirectories))
            {
                File.Delete(file);
            }
            Widgets = Widgets.OrderBy(x => x.Name).ToList();
        }
 public WidgetProxy CreateWidget(string url)
 {
     var widget = new WidgetProxy(url, null, true);
     Widgets.Add(widget);
     return widget;
 }
        public WidgetControl(WidgetProxy widgetProxy)
        {
            InitializeComponent();

            this.WidgetProxy = widgetProxy;
        }
        //puts widget from source folder to the Mosaic\Widgets folder
        public void InstallWidget(string source, string name)
        {
            if (!Directory.Exists(source))
                return;
            if (!Directory.Exists(Envi.WidgetsRoot + "\\" + name))
                Directory.CreateDirectory(Envi.WidgetsRoot + "\\" + name);
            foreach (var file in Directory.GetFiles(source))
            {
                File.Copy(file, Envi.WidgetsRoot + "\\" + name + "\\" + Path.GetFileName(file));
            }

            if (HasWidget(name))
                return;
            string widgetDll = Envi.WidgetsRoot + "\\" + name + "\\" + name + ".dll";
            if (File.Exists(widgetDll))
            {
                var w = new WidgetProxy(widgetDll);
                //w.Load();
                if (w.HasErrors)
                    return;
                Widgets.Add(w);
            }
        }
 public void LoadExternalWidget(string file, int row = 0, int column = 0)
 {
     if (!File.Exists(file))
         return;
     var w = new WidgetProxy(file);
     if (w.HasErrors)
         return;
     Widgets.Add(w);
     w.Row = row;
     w.Column = column;
     w.Load();
     if (WidgetLoaded != null)
         WidgetLoaded(w);
 }
 public void LoadWidget(WidgetProxy widget)
 {
     if (WidgetLoaded != null)
         WidgetLoaded(widget);
 }
 public WidgetProxy CreateFriendWidget(string id, string name)
 {
     var widget = new WidgetProxy(id, name, false, true);
     Widgets.Add(widget);
     return widget;
 }
 public void UnloadWidget(WidgetProxy widget)
 {
     if (widget.WidgetType == WidgetType.Generated)
         Widgets.Remove(widget);
     widget.Unload();
     if (WidgetUnloaded != null)
         WidgetUnloaded(widget);
 }