private void can_Drop(object sender, DragEventArgs e)
        {
            Point p = new Point(e.GetPosition(map).X - 45, e.GetPosition(map).Y - 50);

            if (p.X < 0)
            {
                p.X = 0;
            }
            if (p.Y < 0)
            {
                p.Y = 0;
            }

            if (SearchPosition(e.GetPosition(map)) == null && !move)
            {
                dragItem.setPosition(p);
                mc.resOnCanvas.Add(dragItem);
            }
            else if (SearchPosition(p) != null && move)
            {
                dragItem.setPosition(mi.getPosition());
                move = false;
            }
            else if (SearchPosition(p) == null && move)
            {
                mc.resOnCanvas.Remove(dragItem);
                dragItem.setPosition(p);
                mc.resOnCanvas.Add(dragItem);
            }
            Console.WriteLine("Item spusten na X:" + p.X + " Y:" + p.Y);
            move = false;
            GlowingEarth.getInstance().getMaster().notifyChange();
        }
 public static GlowingEarth getInstance()
 {
     if (ge == null)
     {
         ge = new GlowingEarth();
     }
     return(ge);
 }
        private void Login_Click(object sender, RoutedEventArgs e)
        {
            u = new User(UserBox.GetLineText(0), PwBox.Password);

            if (!Reg_success.Content.Equals(""))
            {
                Error.Content       = "";
                Reg_success.Content = "";
            }
            if (UserBox.GetLineText(0).Length == 0 && PwBox.Password.Length == 0)
            {
                Error.Content = "Login information missing";
            }
            else if (UserBox.GetLineText(0).Length == 0)
            {
                Error.Content = "Missing username";
            }

            else if (PwBox.Password.Length == 0)
            {
                Error.Content = "Missing Password";
            }
            else
            {
                if (existance(u))
                {
                    GlowingEarth ge = GlowingEarth.getInstance();
                    this.Close();
                    ge.Show();
                }
                else
                {
                    Error.Content = "Wrong username or password";
                }
            }
        }
        public void refresh()
        {
            ThisWasLastController twl = new ThisWasLastController("load");

            path = twl.GetFromHere();

            BinaryFormatter fm = new BinaryFormatter();
            FileStream      sm = null;

            try
            {
                sm = File.OpenRead(path);
                Model.MasterClass x = (Model.MasterClass)fm.Deserialize(sm);
                GlowingEarth.getInstance().getMaster().setTags(x.getTags());
                GlowingEarth.getInstance().getMaster().setTypes(x.getTypes());
                GlowingEarth.getInstance().getMaster().setResources(x.getResources());
                GlowingEarth.getInstance().getMaster().setTitle(x.getTitle());
                GlowingEarth.getInstance().getMaster().setSerPath(x.getSerPath());
                GlowingEarth.getInstance().getMaster().setMapItems(x.getMapItems());
            }
            catch (Exception e)
            {
                NewProjectDialog npd = new NewProjectDialog();
                npd.ShowDialog();
                twl.save();
            }
            finally
            {
                if (sm != null)
                {
                    sm.Dispose();
                    sm.Close();
                }
            }
            this.DataContext = this;
        }