Example #1
0
        public static DesktopIcon Deserialize(string serial, DesktopManager sender)
        {
            string[] fields = serial.Split(new string[] { "~~" },
                                           StringSplitOptions.RemoveEmptyEntries);
            string _x    = fields[0];
            float  x     = float.Parse(_x);
            string _y    = fields[1];
            float  y     = float.Parse(_y);
            string name  = fields[2];
            string loc   = fields[3];
            string _spec = fields[4];
            bool   spec  = bool.Parse(_spec);

            if (spec)
            {
                string icoloc    = fields[5];
                string _icoindex = fields[6];
                int    icoindex  = int.Parse(_icoindex);
                return(new DesktopIcon(x, y, loc, name, icoloc, icoindex, sender));
            }
            else
            {
                return(new DesktopIcon(x, y, loc, name, sender));
            }
        }
Example #2
0
        private void Form1_Load(object sender, EventArgs e)
        {
            FormBorderStyle = FormBorderStyle.None;
            DoubleBuffered  = true;

            Screen[] screens = Screen.AllScreens;
            if (runOnMonitor == null)
            {
                monitorIndex = attemptToUseMonitor;
                runOnMonitor = screens[monitorIndex];
            }

            /*if(screens.Length > 1)
             * {
             *  List<int> leftOut = new List<int>();
             *  // Get remainder monitor(s)
             *  for(int i = 0; i < screens.Length; i++)
             *  {
             *      if (i == attemptToUseMonitor) continue;
             *      leftOut.Add(i);
             *  }
             *  leftOutMonitors = leftOut.ToArray();
             * } else
             *  leftOutMonitors = new int[0];
             *
             * if (!fromEnamel) {
             *  foreach (int toShow in leftOutMonitors)
             *  {
             *      string curPath = Assembly.GetExecutingAssembly().Location;
             *      Process newEnamel = Process.Start(curPath, toShow.ToString());
             *      extraEnamelInstances.Add(newEnamel);
             *  }
             * }*/

            Rectangle rct = runOnMonitor.WorkingArea;

            // Use working area.
            Win32.SetLocationAndSize(this, rct.Location, rct.Size);

            ShowInTaskbar = false;

            Win32.DEVMODE[] dvmodes;
            dvmodes = Win32.GetMonitorSettings();

            List <int> rf = GetAvailableRefreshRates(dvmodes);

            FRAME_CAP   = rf.Max();
            FRAME_DELAY = 1000.0f / FRAME_CAP;

            // Load as the last operation.
            if (!TryLoadLayout())
            {
                dm = new DesktopManager();
            }
        }
Example #3
0
        public DesktopIcon(float x, float y, string loc, string name, DesktopManager sender)
        {
            this.name   = name;
            this.loc    = loc;
            this.x      = x;
            this.y      = y;
            this.lastx  = x;
            this.lasty  = y;
            this.target = new PointF(x, y);

            Icon ic = Icon.ExtractAssociatedIcon(loc);

            if (ic.Width != ICON_SIZE &&
                ic.Height != ICON_SIZE)
            {
                Bitmap bm      = ic.ToBitmap();
                Bitmap toPaste = (Bitmap)bm.Clone();
                bm.Dispose();
                bm = new Bitmap(toPaste, new Size(ICON_SIZE, ICON_SIZE));
                Graphics  gr = Graphics.FromImage(bm);
                Rectangle r  = new Rectangle(new Point(0, 0), new Size(ICON_SIZE, ICON_SIZE));
                Rectangle sr = new Rectangle(new Point(shadowOffset, shadowOffset), new Size(ICON_SIZE, ICON_SIZE));
                gr.Clear(Color.FromArgb(0, 0, 0, 0));

                using (Bitmap shadow = DropShadow.CreateShadow(toPaste, shadowSize, shadowOpacity))
                    gr.DrawImage(shadow, sr);

                gr.DrawImage(toPaste, r);
                ic.Dispose();

                image = bm;

                toPaste.Dispose();
                gr.Dispose();
            }
            else
            {
                this.image = ic.ToBitmap();
                ic.Dispose();
            }

            IEnumerable <DesktopIcon> enu = sender.icons.Where(el => el != null);

            if (enu.Count() == 0)
            {
                ID = 1;
            }
            else
            {
                ID = enu.OrderByDescending(el => el.ID).First().ID + 1;
            }
        }
Example #4
0
        /// <summary>
        /// Returns if succeeded to load.
        /// </summary>
        /// <returns></returns>
        private bool TryLoadLayout()
        {
            if (!File.Exists("desktopSave.ser"))
            {
                return(false);
            }
            string rd = FromBase64(File.ReadAllText("desktopSave.ser"));

            string[] array        = rd.Split('|');
            bool     hasWallpaper = bool.Parse(array[0]);

            if (hasWallpaper)
            {
                string path = array[1];
                wp.SetWallpaper(runOnMonitor, path);
            }
            dm = new DesktopManager(rd.Split(new[] { "||||" }, StringSplitOptions.None)[1]);
            return(true);
        }