Exemple #1
0
        private static void Init()
        {
            bool exists = true;

            ConfigPath = ConfigManager.GetInstance().SystemConfigDirectory + "desktop.config";
            if (!File.Exists(ConfigPath))
            {
                FileStream stream = File.Create(ConfigPath);
                stream.Close();

                File.WriteAllText(ConfigPath, MD5.Encrypt("[]"));

                exists = false;
            }

            string json = File.ReadAllText(ConfigPath);

            json = MD5.Decrypt(json);
            var ms = new MemoryStream(Encoding.UTF8.GetBytes(json));
            DataContractJsonSerializer deseralizer = new DataContractJsonSerializer(typeof(DesktopDataManager));

            desktopManager = (DesktopDataManager)deseralizer.ReadObject(ms);
            SecondDesktopMessager.GetInstance().CreateSubAppConfigNotify += desktopManager.CreateSubAppConfig;

            if (desktopManager.PageList.Count() == 0)
            {
                desktopManager.AddPage(0, "DESKTOP");
            }

            if (!exists)
            {
                desktopManager.SetThemeDark(true);
                desktopManager.SetThemeColor(2);
            }
        }
        private int CloseDesktop(bool pStatus)
        {
            if (pStatus)
            {
                DesktopDataManager.GetInstance().DeletePage(CurrentPage);
                CurrentPage = 0;
                Update();
            }

            return(0);
        }
 public void SelectPage(int Page)
 {
     wpDesktop.Children.Clear();
     foreach (DesktopItem item in DesktopDataManager.GetInstance().DesktopItemList)
     {
         if (item.Page == Page)
         {
             OpenSubApp(item);
         }
     }
 }
        public VMDesktopPanel()
        {
            Model = new MDesktopPanel();
            Width = SDSystem.WindowWidth - SDSystem.WindowMargin * 2;
            DesktopTitleReadOnly   = true;
            DesktopTitleBackground = "#2D2D2D";
            DesktopImage           = SDResource.DesktopImage;
            DesktopSettingImage    = SDResource.SettingsImage;
            DesktopAddImage        = SDResource.AddImage;
            DesktopDeleteImage     = SDResource.DeleteImage;

            DesktopDataManager.GetInstance().Update += Update;
            Update();
        }
        public void AddDesktop()
        {
            int page = 0;

            foreach (var item in DesktopDataManager.GetInstance().PageList)
            {
                if (page <= item.Key)
                {
                    page = item.Key + 1;
                }
            }

            DesktopDataManager.GetInstance().AddPage(page, "DESKTOP");
            CurrentPage = page;
            UpdateDesktop();
        }
        public void Update()
        {
            DesktopPageItems.Clear();
            foreach (var item in DesktopDataManager.GetInstance().PageList)
            {
                DesktopPageItem pageItem = new DesktopPageItem();
                pageItem.Page     = item.Key;
                pageItem.Title    = item.Value;
                pageItem.IsSelect = false;
                DesktopPageItems.Add(pageItem);
            }

            bool isExist = false;

            foreach (DesktopPageItem item in DesktopPageItems)
            {
                if (item.Page == CurrentPage)
                {
                    item.IsSelect = true;
                    isExist       = true;
                    break;
                }
            }

            if (!isExist)
            {
                CurrentPage = 0;
                foreach (DesktopPageItem item in DesktopPageItems)
                {
                    if (item.Page == CurrentPage)
                    {
                        item.IsSelect = true;
                        break;
                    }
                }
            }

            if (SelectPageNotify != null)
            {
                SelectPageNotify(CurrentPage);
            }

            if (DesktopDataManager.GetInstance().PageList.Count() > 0)
            {
                DesktopTitle = DesktopDataManager.GetInstance().PageList[CurrentPage];
            }
        }
Exemple #7
0
        public void Save()
        {
            DataContractJsonSerializer js = new DataContractJsonSerializer(typeof(DesktopDataManager));
            MemoryStream memoryStream     = new MemoryStream();

            js.WriteObject(memoryStream, DesktopDataManager.GetInstance());
            memoryStream.Position = 0;
            StreamReader streamReader = new StreamReader(memoryStream, Encoding.UTF8);
            string       json         = streamReader.ReadToEnd();

            streamReader.Close();
            memoryStream.Close();
            json = MD5.Encrypt(json);
            File.WriteAllText(ConfigPath, json);

            if (Update != null)
            {
                Update();
            }
        }
        public void CreateSubApp(string AppUID, int SubAppUID, string Config)
        {
            DesktopItem item = new DesktopItem();

            item.AppUID    = AppUID;
            item.SubAppUID = SubAppUID;
            item.Config    = Config;
            item.Page      = ViewModel.CurrentPage;

            Assembly   assembly = Assembly.LoadFrom(ConfigManager.GetInstance().ApplicationAppsDirectory + AppUID + "\\" + AppUID + ".dll");
            Type       factory  = assembly.GetType(AppUID + ".Factory");
            MethodInfo method   = factory.GetMethod("CreateWindow");
            Object     obj      = Activator.CreateInstance(factory);

            object[]    parameters = new object[] { SubAppUID, Config };
            UserControl uc         = (UserControl)method.Invoke(obj, parameters);
            SubAppFrame border     = new SubAppFrame(item);

            SecondDesktopMessager.GetInstance().DesktopSettings(!ViewModel.DesktopTitleReadOnly);
            border.Add(uc);
            wpDesktop.Children.Add(border);

            DesktopDataManager.GetInstance().AddSubApp(item);
        }
 public void UpdateDesktop()
 {
     DesktopDataManager.GetInstance().UpdateDesktop();
 }
 public void DeleteDesktop()
 {
     DesktopDataManager.GetInstance().DeletePage(CurrentPage);
     CurrentPage = 0;
     UpdateDesktop();
 }
Exemple #11
0
 private void CloseWindow()
 {
     ((WrapPanel)this.Parent).Children.Remove(this);
     DesktopDataManager.GetInstance().DeleteSubApp(DI);
 }