Example #1
0
        private void AddFolderButton_Click(object sender, EventArgs e)
        {
            TreeNode n = new TreeNode(Strings.NewFolder, RepositoryIcons.RES_FOLDER, RepositoryIcons.RES_FOLDER);

            n.Tag = new ResourceItem("", "", "");
            (n.Tag as ResourceItem).EntryType = EntryTypeEnum.Added;
            (n.Tag as ResourceItem).IsFolder  = true;

            if (ResourceTree.SelectedNode == null || ResourceTree.SelectedNode.Parent == null)
            {
                ResourceTree.Nodes[0].Nodes.Add(n);
            }
            else if (ResourceTree.SelectedNode.Tag as ResourceItem != null)
            {
                if ((ResourceTree.SelectedNode.Tag as ResourceItem).IsFolder)
                {
                    ResourceTree.SelectedNode.Nodes.Add(n);
                }
                else if (ResourceTree.SelectedNode.Parent == null)
                {
                    ResourceTree.Nodes[0].Nodes.Add(n);
                }
                else
                {
                    ResourceTree.SelectedNode.Parent.Nodes.Add(n);
                }
            }

            n.EnsureVisible();
            ResourceTree.SelectedNode = n;
            ResourceTree.Focus();
        }
Example #2
0
        private void ResourceTree_DragDrop(object sender, DragEventArgs e)
        {
            TreeNode x = e.Data.GetData(typeof(TreeNode)) as TreeNode;

            if (x == null || x.Tag == null)
            {
                return;
            }

            TreeNode n = ResourceTree.GetNodeAt(ResourceTree.PointToClient(new Point(e.X, e.Y)));

            if (n != null && n.Tag as ResourceItem != null && (n.Tag as ResourceItem).IsFolder)
            {
                //Can't drag onto its' own child
                TreeNode t = n;
                while (t.Parent != null)
                {
                    if (t == x)
                    {
                        return;
                    }
                    else
                    {
                        t = t.Parent;
                    }
                }

                x.Remove();
                n.Nodes.Add(x);
            }
            else
            {
                return;
            }
        }
Example #3
0
        /// <summary>
        /// Handles the Click event of the BtnGetSelected control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Windows.RoutedEventArgs"/> instance containing the event data.</param>
        /// <remarks>Runs on the UI thread.</remarks>
        private void BtnGetSelected_Click(object sender, RoutedEventArgs e)
        {
            GetResourceJob.UpdateUIDelegate actUpdateUI = GetResourceCallback;

            if (ResourceTree.Selected == null)
            {
                MessageBox.Show("You must select a resource first.");
                return;
            }

            ResourceTree.StartDownload(ResourceTree.Selected, Master.JobType.GetResource);

            _workMaster.AddJob(new JobArgs()
            {
                CouchDB          = _couchdb,
                ErrorManager     = ErrorManager,
                FileSystem       = FileSystem,
                JobType          = Master.JobType.GetResource,
                RequestingUser   = TEMP_USERNAME,
                Requestor        = this,
                Resource         = ResourceTree.Selected,
                Timeout          = 150000,
                UpdateUICallback = actUpdateUI
            });
        }
Example #4
0
        public AdminLteTheme(string?title, IHandlerBuilder?logo, Func <IRequest, IHandler, ValueTask <UserProfile?> >?userProfile,
                             Func <IRequest, IHandler, ValueTask <string?> >?footerLeft, Func <IRequest, IHandler, ValueTask <string?> >?footerRight,
                             Func <IRequest, IHandler, ValueTask <string?> >?sidebar, Func <IRequest, IHandler, ValueTask <SearchBox?> >?searchBox,
                             Func <IRequest, IHandler, ValueTask <string?> >?notifications, IMenuProvider?headerMenu)
        {
            _Title = title;

            var resources = Layout.Create()
                            .Fallback(Modules.IO.Resources.From(ResourceTree.FromAssembly("AdminLTE.resources")));

            HasLogo = (logo != null);

            if (logo != null)
            {
                resources.Add("logo.png", logo);
            }

            _UserProfile = userProfile;

            _FooterLeft  = footerLeft;
            _FooterRight = footerRight;

            _Sidebar   = sidebar;
            _SearchBox = searchBox;

            _HeaderMenu    = headerMenu;
            _Notifications = notifications;

            Resources = resources;

            ErrorHandler = ModScriban.Template <ErrorModel>(Resource.FromAssembly("Error.html")).Build();

            Renderer = ModScriban.Template <WebsiteModel>(Resource.FromAssembly("Template.html")).Build();
        }
Example #5
0
        /// <summary>
        /// Called when a search result is selected.
        /// </summary>
        /// <param name="guid">The <see cref="Guid"/> of the selected resource.</param>
        /// <remarks>Runs on the UI thread.</remarks>
        void search_OnResultSelected(Guid guid)
        {
            // If the tree already has it, then ignore this after telling the user
            if (ResourceTree.ResourceExistsInTree(guid))
            {
                MessageBox.Show("The selected item is already present.");
                return;
            }

            GetResourceJob.UpdateUIDelegate actUpdateUI = GetResourceCallback;
            MetaAsset ma       = new MetaAsset(guid, _couchdb);
            Version   resource = new Version(ma, _couchdb);

            ResourceTree.StartDownload(resource, Master.JobType.CheckoutJob);

            _workMaster.AddJob(new JobArgs()
            {
                CouchDB          = _couchdb,
                ErrorManager     = ErrorManager,
                FileSystem       = FileSystem,
                JobType          = Master.JobType.CheckoutJob,
                ProgressMethod   = JobBase.ProgressMethodType.Determinate,
                RequestingUser   = TEMP_USERNAME,
                Requestor        = this,
                Resource         = resource,
                Timeout          = 100000,
                UpdateUICallback = actUpdateUI
            });
        }
        public void WriteTo(Stream aStream)
        {
            if (FormatVersion != FormatConstants.GMVersion80 && FormatVersion != FormatConstants.GMVersion81)
            {
                throw new Exceptions.UnsupportedVersion(0, FormatVersion);
            }

            using (GMBinaryWriter writer = new GMBinaryWriter(aStream, CompressionMode)) {
                writer.Write(FormatConstants.GMMagicNumber);
                writer.Write(FormatVersion);

                Settings.WriteTo(writer);
                Triggers.WriteTo(writer);
                Constants.WriteTo(writer);
                Sounds.WriteTo(writer);
                Sprites.WriteTo(writer);
                Backgrounds.WriteTo(writer);
                Paths.WriteTo(writer);
                Scripts.WriteTo(writer);
                Fonts.WriteTo(writer);
                TimeLines.WriteTo(writer);
                Objects.WriteTo(writer);
                Rooms.WriteTo(writer);
                Includes.WriteTo(writer);
                m_extensions.WriteTo(writer);
                Information.WriteTo(writer);
                m_creationCodes.WriteTo(writer);
                m_roomOrder.WriteTo(writer);
                ResourceTree.WriteTo(writer);
            }
        }
Example #7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ResourceTree_MouseClick(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right)
            {
                Point    location = PointToScreen(e.Location);
                TreeNode node     = ResourceTree.GetNodeAt(e.Location);
                if (node == null)
                {
                    return;
                }

                // Root node
                if (node.Parent == null)
                {
                }
                // Asset type node
                else if (node.GetNodeCount(true) > 0)
                {
                    TypeContextMenu.Tag = node.Tag;
                    TypeContextMenu.Show(location);
                }

                else
                {
                    AssetContextMenu.Tag = node.Tag;
                    AssetContextMenu.Show(location);
                }
            }
        }
Example #8
0
 /// <summary>
 /// Called when a job has terminated on a Resource.
 /// </summary>
 /// <param name="result">The <see cref="JobResult"/>.</param>
 /// <remarks>
 /// Runs on the UI thread.
 /// </remarks>
 void ReleaseResourceCallback(JobResult result)
 {
     if (result.Job.IsFinished)
     {
         ResourceTree.RemoveLocalResource(result.Resource);
         FileSystem.Delete(result.Resource.MetaAsset.RelativePath);
         FileSystem.Delete(result.Resource.DataAsset.RelativePath);
     }
 }
Example #9
0
        /// <summary>
        /// Handles the Click event of the BtnAddResource control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Windows.RoutedEventArgs"/> instance containing the event data.</param>
        private void BtnAddResource_Click(object sender, RoutedEventArgs e)
        {
            Version       resource;
            string        dataExt;
            Guid          guid  = Guid.NewGuid();
            List <string> uprop = new List <string>();

            System.Windows.Forms.OpenFileDialog ofd;

            if (MessageBox.Show("This process will make a copy of the selected resource adding it to the repository.  Understand " +
                                "that this will not affect your original file and changes made to your original file will not be made in the " +
                                "repository.  Would you like to add a resource at this time?",
                                "Add a Resource", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.Yes) == MessageBoxResult.Yes)
            {
                ofd             = new System.Windows.Forms.OpenFileDialog();
                ofd.Multiselect = false;

                if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    dataExt = System.IO.Path.GetExtension(ofd.FileName);
                    while (FileSystem.ResourceExists(Common.FileSystem.Path.RelativeDataPath + guid.ToString("N") + dataExt) ||
                           FileSystem.ResourceExists(Common.FileSystem.Path.RelativeMetaPath + guid.ToString("N") + ".xml"))
                    {
                        guid = Guid.NewGuid();
                    }

                    // Create Resource
                    resource = new Version(guid, dataExt, _couchdb);

                    // Copy DataAsset
                    File.Copy(ofd.FileName,
                              FileSystem.RootPath + Common.FileSystem.Path.RelativeDataPath + guid.ToString("N") + dataExt);

                    // Fill out the MA info
                    resource.MetaAsset.Extension  = dataExt;
                    resource.MetaAsset.Created    = DateTime.Now;
                    resource.MetaAsset.Creator    = TEMP_USERNAME;
                    resource.MetaAsset.LastAccess = DateTime.Now;
                    resource.MetaAsset.Length     = FileSystem.GetFileLength(resource.DataAsset.RelativePath);
                    resource.MetaAsset.LockedAt   = DateTime.Now;
                    resource.MetaAsset.LockedBy   = TEMP_USERNAME;
                    resource.MetaAsset.Title      = "Temporary Title";
                    resource.MetaAsset.Md5        = FileSystem.ComputeMd5(resource.DataAsset.RelativePath);

                    resource.MetaAsset.Tags.Add("Seperate tags");
                    resource.MetaAsset.Tags.Add("by a return");

                    resource.MetaAsset.UserProperties.Add("prop1", (int)1);
                    resource.MetaAsset.UserProperties.Add("prop2", DateTime.Now);
                    resource.MetaAsset.UserProperties.Add("prop3", "string1");

                    resource.MetaAsset.SaveToLocal(null, FileSystem);

                    ResourceTree.AddNewExistingLocalResource(resource);
                }
            }
        }
Example #10
0
        public FileOverlay(IHandler parent, Func <IHandler, IHandler> contentFactory, Environment environment)
        {
            Parent = parent;

            DataDirectory = new DirectoryInfo(environment.Data).FullName;

            Overlay = Resources.From(ResourceTree.FromDirectory(environment.Data))
                      .Build(this);

            Content = contentFactory(this);
        }
Example #11
0
 private string GetCurrentActivity(ResourceTree item)
 {
     if (item.CurrentClientID == 0)
     {
         return("No activity at the present time");
     }
     else
     {
         return(string.Format("Being used by {0} {1} for {2}", item.CurrentFirstName, item.CurrentLastName, item.CurrentActivityName));
     }
 }
Example #12
0
        public void Parser_should_parse()
        {
            // Prepare
            var tree = new ResourceTree();

            tree.Location = "myLocation";
            var resources      = new List <ResourceSpecification>();
            var storageAccount = new ResourceSpecification
            {
                ResourceType = "StorageAccount"
            };

            storageAccount.ListProperties.Add("containers", new[] { "abc" });
            storageAccount.StringProperties.Add("queues", "queueName");
            storageAccount.StringProperties.Add("ResourceGroup", "someGroup");
            storageAccount.ListProperties.Add("name", new string[] { "a", "name" });
            resources.Add(storageAccount);
            var resourceGroup = new ResourceSpecification
            {
                ResourceType = "ResourceGroup",
            };

            resourceGroup.StringProperties.Add("Location", "otherLocation");
            resources.Add(resourceGroup);
            tree.Resources = resources;

            // Execute
            var context = Parser.Parse(tree);

            // Assess
            Assert.Equal(tree.Location, context.DefaultLocation);
            var parsedStorageAccount = context.Resources.FirstOrDefault(resource =>
                                                                        resource.GetType() == typeof(StorageAccount) &&
                                                                        resource.Name == "a name" &&
                                                                        ((StorageAccount)resource).Containers.Length == 1 &&
                                                                        ((StorageAccount)resource).Containers[0] == "abc" &&
                                                                        ((StorageAccount)resource).Queues.Length == 1 &&
                                                                        ((StorageAccount)resource).Queues[0] == "queueName"
                                                                        );

            Assert.NotNull(parsedStorageAccount);

            Assert.Single(context.ExplicitDependencyRequirements[parsedStorageAccount],
                          req =>
                          req.Property.PropertyType == typeof(ResourceGroup) &&
                          req.Property.Name == "ResourceGroup" &&
                          req.ValueName == "someGroup");

            Assert.Single(context.Resources, resource =>
                          resource.GetType() == typeof(ResourceGroup) &&
                          ((ResourceGroup)resource).Location == "otherLocation"
                          );
        }
Example #13
0
        private IEnumerable <IResourceTree> CreateResourceTreeModels(DataTable dt)
        {
            List <IResourceTree> result = new List <IResourceTree>();

            foreach (DataRow dr in dt.Rows)
            {
                var rt = new ResourceTree();
                SetResourceTreeProperties(rt, dr);
                result.Add(rt);
            }
            return(result);
        }
Example #14
0
        protected override void ProcessResource(ResourceTree aResourceTree)
        {
            System.Action <XElement, ResourceTreeNode> ReadChildren = null;
            var excludedGroups = new NodeGroup[] {
                NodeGroup.ExtensionPackages, NodeGroup.GameInformation, NodeGroup.GlobalGameSettings, NodeGroup.Invalid
            };

            ReadChildren = (aBranch, aParent) => {
                foreach (var element in aBranch.Elements())
                {
                    if (element.Name == "Node")
                    {
                        aParent.Add(new ResourceTreeNode()
                        {
                            Name  = element.Attribute("Name").Value,
                            ID    = int.Parse(element.Attribute("ID").Value),
                            Type  = NodeTypes.Child,
                            Group = aParent.Group
                        });
                    }
                    else if (element.Name == "Group")
                    {
                        var node = new ResourceTreeNode()
                        {
                            Name  = element.Attribute("Name").Value,
                            Type  = NodeTypes.Group,
                            Group = aParent.Group
                        };

                        ReadChildren(element, node);
                        aParent.Add(node);
                    }
                }
            };

            var document = LoadXml(Filenames.Tree + ".xml");

            if (document != null)
            {
                OnCategoryProcessing(ResourceTypes.ResourceTree);

                foreach (var node in aResourceTree)
                {
                    if (!excludedGroups.Contains(node.Group))
                    {
                        ReadChildren(document.Element(node.Group.ToString()), node);
                    }
                }

                OnCategoryProcessed(ResourceTypes.ResourceTree);
            }
        }
        public ArcanaTheme(string?title, string?copyright, Func <IRequest, IHandler, ValueTask <string?> >?footer)
        {
            _Title     = title;
            _Copyright = copyright;

            _Footer = footer;

            Resources = Modules.IO.Resources.From(ResourceTree.FromAssembly("Arcana.resources"));

            ErrorHandler = ModScriban.Template <ErrorModel>(Resource.FromAssembly("Error.html")).Build();

            Renderer = ModScriban.Template <WebsiteModel>(Resource.FromAssembly("Template.html")).Build();
        }
Example #16
0
        /// <summary>
        /// Called when a <see cref="CheckUpdateStatus"/> has terminated.
        /// </summary>
        /// <param name="result">The <see cref="JobResult"/>.</param>
        /// <remarks>
        /// Runs on the UI thread.
        /// </remarks>
        void CheckUpdateStatus(JobResult result)
        {
            string localResourceMd5 = null;

            if (result.Job.IsFinished)
            {
                localResourceMd5 = new Common.FileSystem.DataResource(result.Resource.DataAsset, FileSystem).ComputeMd5();
                ResourceTree.FinishStatusCheck(result, localResourceMd5);
            }
            else
            {
                ResourceTree.FinishStatusCheck(result, null);
            }
        }
Example #17
0
        /// <summary>
        /// Handles the Click event of the BtnOpenSelected control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Windows.RoutedEventArgs"/> instance containing the event data.</param>
        /// <remarks>Runs on the UI thread.</remarks>
        private void BtnOpenSelected_Click(object sender, RoutedEventArgs e)
        {
            ResourceDelegate actOpenResource = OpenResource;

            if (ResourceTree.Selected == null)
            {
                MessageBox.Show("You must select a resource first.");
                return;
            }

            actOpenResource.BeginInvoke(ResourceTree.Selected,
                                        OpenResource_AsyncCallback, actOpenResource);

            ResourceTree.SetResourceTreeSelectedIndex(-1);
        }
Example #18
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MainWindow"/> class.
        /// </summary>
        public MainWindow()
        {
            // DO NOT REORDER variable instantiation unless you know what you are doing!!!

            InitializeComponent();

            // Settings should come first
            Settings.Instance = Settings.Load(Utilities.GetAppDataPath() + "Settings.xml");
            if (Settings.Instance == null)
            {
                SettingsWindow win = new SettingsWindow();
                Settings.Instance = new Settings();
                win.ShowDialog();
            }

            // File System must be set after settings
            FileSystem = new Common.FileSystem.IO(Settings.Instance.StorageLocation);

            // Logger can be started after FileSystem
            Logger = new Common.Logger(Utilities.GetAppDataPath());

            // CouchDB can be instantiated after both FileSystem and Logger
            _couchdb = new Common.CouchDB.Database(Settings.Instance.CouchDatabaseName,
                                                   new Common.CouchDB.Server(Settings.Instance.CouchServerIp, Settings.Instance.CouchServerPort));

            Common.ErrorManager.UpdateUI actErrorUpdateUI = ErrorUpdateUI;

            ErrorManager       = new Common.ErrorManager(actErrorUpdateUI);
            _statusBarItemGuid = Guid.Empty;
            _workMaster        = new Master(ErrorManager, FileSystem, _couchdb);
            IdTranslation      = new Dictionary <Guid, Guid>();
            _fsWatcher         = new FileSystemWatcher(Settings.Instance.StorageLocation);
            _fsWatcher.IncludeSubdirectories = true;
            _fsWatcher.NotifyFilter          = NotifyFilters.LastWrite;
            _fsWatcher.Changed            += new FileSystemEventHandler(FS_Changed);
            _fsWatcher.EnableRaisingEvents = true;
            _addedFileMappings             = new Dictionary <string, Guid>();
            this.Loaded += new RoutedEventHandler(MainWindow_Loaded);


            ResourceTree.OnRelease      += new ResourceTreeView.EventDelegate(ResourceTree_OnRelease);
            ResourceTree.OnCancel       += new ResourceTreeView.EventDelegate(ResourceTree_OnCancel);
            ResourceTree.OnItemSelect   += new ResourceTreeView.EventDelegate(ResourceTree_OnItemSelect);
            ResourceTree.OnReload       += new ResourceTreeView.EventDelegate(ResourceTree_OnReload);
            ResourceTree.OnStatusUpdate += new ResourceTreeView.StatusUpdateDelegate(ResourceTree_OnStatusUpdate);

            ResourceTree.RegisterStatusBarItem(SBItem);
        }
 public GameMakerFile()
 {
     Sprites      = new SpriteCollection();
     Sounds       = new SoundCollection();
     Backgrounds  = new BackgroundCollection();
     Paths        = new PathCollection();
     Scripts      = new ScriptCollection();
     Fonts        = new FontCollection();
     TimeLines    = new TimeLineCollection();
     Objects      = new ObjectCollection();
     Rooms        = new RoomCollection();
     Triggers     = new TriggerCollection();
     Includes     = new IncludedFileCollection();
     Constants    = new ConstantCollection();
     Information  = new GameInformation();
     Settings     = new GameSettings();
     ResourceTree = new ResourceTree();
 }
 public GameMakerFile()
 {
     Sprites = new SpriteCollection();
       Sounds = new SoundCollection();
       Backgrounds = new BackgroundCollection();
       Paths = new PathCollection();
       Scripts = new ScriptCollection();
       Fonts = new FontCollection();
       TimeLines = new TimeLineCollection();
       Objects = new ObjectCollection();
       Rooms = new RoomCollection();
       Triggers = new TriggerCollection();
       Includes = new IncludedFileCollection();
       Constants = new ConstantCollection();
       Information = new GameInformation();
       Settings = new GameSettings();
       ResourceTree = new ResourceTree();
 }
Example #21
0
        /// <summary>
        /// Rebuilds the resource TreeView
        /// </summary>
        public void RebuildResourceTree()
        {
            ResourceTree.BeginUpdate();

            ResourceTree.Nodes.Clear();
            TreeNode bank = ResourceTree.Nodes.Add("Assets");

            bank.ImageIndex         = 31;
            bank.SelectedImageIndex = 31;


            // for each registred asset
            foreach (RegisteredAsset ra in ResourceManager.RegisteredAssets)
            {
                // Get the number of asset
                if (ra.Count == 0)
                {
                    continue;
                }

                TreeNode node = bank.Nodes.Add(ra.Tag + " (" + ra.Count.ToString() + ")");
                node.Tag                = ra;
                node.ImageIndex         = 34;
                node.SelectedImageIndex = 35;

                List <string> list = new List <string>();
                foreach (string str in ra.GetList(list))
                {
                    AddNode(node, str, ra.Type);
                }
            }

            // Trie le tout
            ResourceTree.Sort();


            // Binaries
            //TreeNode sub = ResourceTree.Nodes.Insert(0, "Binaries (" + ResourceManager.Binaries.Count + ")");

            ResourceTree.EndUpdate();

            bank.Expand();
        }
        private static IHandlerBuilder GetHandler(RouteConfiguration config)
        {
            var layout = Layout.Create();

            var content = GetContent(config);

            if (content != null)
            {
                layout.Fallback(content);
            }
            else if (config.Listing != null)
            {
                layout.Fallback(Listing.From(ResourceTree.FromDirectory(config.Listing)));
            }
            else if (config.Content != null)
            {
                if (config.Content.Directory != null)
                {
                    var directory = Resources.From(ResourceTree.FromDirectory(config.Content.Directory));

                    var staticContent = Layout.Create().Fallback(directory);

                    if (config.Content.Index != null)
                    {
                        var indexFile = Path.Combine(config.Content.Directory, config.Content.Index);
                        layout.Index(Download.From(Resource.FromFile(indexFile)));
                    }

                    layout.Fallback(staticContent);
                }
            }

            if (config.Routes != null)
            {
                foreach (var route in config.Routes)
                {
                    layout.Add(route.Key, GetHandler(route.Value));
                }
            }

            return(layout);
        }
Example #23
0
        public LorahostTheme(IResource?header, string?copyright, string?title, string?subtitle, string?action, string?actionTitle)
        {
            _Copyright   = copyright;
            _Title       = title;
            _Subtitle    = subtitle;
            _Action      = action;
            _ActionTitle = actionTitle;

            var resources = Layout.Create()
                            .Fallback(Modules.IO.Resources.From(ResourceTree.FromAssembly("Lorahost.resources")));

            if (header != null)
            {
                resources.Add("header.jpg", Download.From(header).Type(ContentType.ImageJpg));
            }

            Resources = resources;

            ErrorHandler = ModScriban.Template <ErrorModel>(Resource.FromAssembly("Error.html")).Build();

            Renderer = ModScriban.Template <WebsiteModel>(Resource.FromAssembly("Template.html")).Build();
        }
        public void ReadFrom(Stream aStream)
        {
            using (GMBinaryReader reader = new GMBinaryReader(aStream)) {
                int magicNumber = reader.ReadInt32();
                if (magicNumber != FormatConstants.GMMagicNumber)
                {
                    throw new Exceptions.UnknownFormat();
                }

                int version = reader.ReadInt32();
                if (version != FormatConstants.GMVersion80 && version != FormatConstants.GMVersion81)
                {
                    throw new Exceptions.UnsupportedVersion(aStream.Position - 4, version);
                }

                FormatVersion = version;

                Settings.ReadFrom(reader);
                Triggers.ReadFrom(reader);
                Constants.ReadFrom(reader);
                Sounds.ReadFrom(reader);
                Sprites.ReadFrom(reader);
                Backgrounds.ReadFrom(reader);
                Paths.ReadFrom(reader);
                Scripts.ReadFrom(reader);
                Fonts.ReadFrom(reader);
                TimeLines.ReadFrom(reader);
                Objects.ReadFrom(reader);
                Rooms.ReadFrom(reader);
                Includes.ReadFrom(reader);
                m_extensions.ReadFrom(reader);
                Information.ReadFrom(reader);
                m_creationCodes.ReadFrom(reader);
                m_roomOrder.ReadFrom(reader);
                ResourceTree.ReadFrom(reader);
            }
        }
        public static IHandlerBuilder Create()
        {
            var auth = BasicAuthentication.Create(AccessControl.AuthenticateAsync);

            var resources = Resources.From(ResourceTree.FromAssembly("Resources"));

            var logo = Content.From(Resource.FromAssembly("eye.png"));

            var theme = Theme.Create()
                        .Title("Blickkontakt")
                        .FooterRight(RenderFooterRight)
                        .UserProfile(RenderUser)
                        .Logo(logo);

            var content = Layout.Create()
                          .Fallback(Controller.From <DashboardController>())
                          .AddController <CustomerController>("customers")
                          .AddController <AnnounceController>("announces")
                          .AddController <LetterController>("letters")
                          .AddController <AccountController>("accounts")
                          .Add("static", resources)
                          .Authentication(auth);

            var menu = Menu.Empty()
                       .Add("{website}", "Übersicht")
                       .Add("/customers/", "Kunden")
                       .Add("/announces/", "Anzeigen")
                       .Add("/letters/", "Infobriefe")
                       .Add("/accounts/", "Mitarbeiter");

            return(Website.Create()
                   .Theme(theme)
                   .Content(content)
                   .Menu(menu)
                   .AddScript("jquery-validate.js", Resource.FromAssembly("jquery.validate.min.js"))
                   .AddStyle("project.css", Resource.FromAssembly("project.css")));
        }
Example #26
0
        private void AddResourceButton_Click(object sender, EventArgs e)
        {
            var dlg = new AddResourceEntryDialog();

            if (dlg.ShowDialog(this) == DialogResult.OK)
            {
                int          imageindex = RepositoryIcons.GetImageIndexForResourceType(Path.GetExtension(dlg.ResourceName).Replace(".", ""));
                TreeNode     n          = new TreeNode(dlg.ResourceName, imageindex, imageindex);
                ResourceItem i          = new ResourceItem("", dlg.HeaderFilepath, dlg.ContentFilepath);
                i.EntryType = EntryTypeEnum.Added;
                n.Tag       = i;

                if (ResourceTree.SelectedNode == null || ResourceTree.SelectedNode.Parent == null)
                {
                    ResourceTree.Nodes[0].Nodes.Add(n);
                }
                else if (ResourceTree.SelectedNode.Tag as ResourceItem != null)
                {
                    if ((ResourceTree.SelectedNode.Tag as ResourceItem).IsFolder)
                    {
                        ResourceTree.SelectedNode.Nodes.Add(n);
                    }
                    else if (ResourceTree.SelectedNode.Parent == null)
                    {
                        ResourceTree.Nodes[0].Nodes.Add(n);
                    }
                    else
                    {
                        ResourceTree.SelectedNode.Parent.Nodes.Add(n);
                    }
                }

                n.EnsureVisible();
                ResourceTree.SelectedNode = n;
                ResourceTree.Focus();
            }
        }
Example #27
0
        void ResourceTree_OnCancel(ResourceTreeView.State state)
        {
            Common.Storage.Version resource = null;

            // If the resource of the state exists then cancel it
            // This happens when a translation is not required - non CreateResourceJob
            if ((resource = ResourceTree.GetResourceFromTree(state.Resource.Guid)) != null)
            {
                _workMaster.CancelJobForResource(resource);
                return;
            }

            if (IdTranslation.ContainsValue(state.Resource.Guid))
            {
                Guid oldGuid = Guid.Empty;

                lock (IdTranslation)
                {
                    Dictionary <Guid, Guid> .Enumerator en = IdTranslation.GetEnumerator();
                    while (en.MoveNext())
                    {
                        if (en.Current.Value == state.Resource.Guid)
                        {
                            oldGuid = en.Current.Key;
                            break;
                        }
                    }
                }

                resource = ResourceTree.GetResourceFromTree(oldGuid);
                _workMaster.CancelJobForResource(resource);
                return;
            }

            throw new InvalidOperationException("Could not locate resource.");
        }
Example #28
0
        public void Parser_should_parse_ints()
        {
            // Prepare
            var tree      = new ResourceTree();
            var resources = new List <ResourceSpecification>();
            var snippet   = new ResourceSpecification
            {
                ResourceType = "Snippet",
            };

            snippet.StringProperties.Add("order", "3");
            resources.Add(snippet);
            tree.Resources = resources;

            // Execute
            var context = Parser.Parse(tree);

            // Assess
            var parsedSnippet = context.Resources.FirstOrDefault(resource =>
                                                                 resource.GetType() == typeof(Snippet));

            Assert.NotNull(parsedSnippet);
            Assert.Equal(3, parsedSnippet.Order);
        }
Example #29
0
        /// <summary>
        /// Handles the Click event of the BtnSaveSelected control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Windows.RoutedEventArgs"/> instance containing the event data.</param>
        /// <remarks>Runs on the UI thread.</remarks>
        private void BtnSaveSelected_Click(object sender, RoutedEventArgs e)
        {
            MetaPropWindow win;

            ResourceTreeView.State state;

            if (ResourceTree.Selected == null)
            {
                MessageBox.Show("You must select a resource first.");
                return;
            }

            win = new MetaPropWindow(ResourceTree.Selected.Guid, FileSystem, _couchdb);

            if (!win.ShowDialog().Value)
            {
                return;
            }

            // Reload the meta
            ResourceTree.Selected.MetaAsset.LoadFromLocal(null,
                                                          Common.FileSystem.Path.RelativeMetaPath +
                                                          ResourceTree.Selected.Guid.ToString("N") + ".xml", FileSystem);

            lock (IdTranslation)
            {
                IdTranslation.Add(ResourceTree.Selected.Guid, Guid.Empty);
            }

            state = ResourceTree.StartSaveToRemote(ResourceTree.Selected);

            // If this resource does not exist on the server then create, else update
            if (state.IsCreating)
            {
                _workMaster.AddJob(new JobArgs()
                {
                    CouchDB          = _couchdb,
                    ErrorManager     = ErrorManager,
                    FileSystem       = FileSystem,
                    JobType          = Master.JobType.CreateResource,
                    RequestingUser   = TEMP_USERNAME,
                    Requestor        = this,
                    Resource         = state.Resource,
                    Timeout          = 100000,
                    UpdateUICallback = CreateResourceCallback
                });
            }
            else
            {
                _workMaster.AddJob(new JobArgs()
                {
                    CouchDB          = _couchdb,
                    ErrorManager     = ErrorManager,
                    FileSystem       = FileSystem,
                    JobType          = Master.JobType.SaveResource,
                    RequestingUser   = TEMP_USERNAME,
                    Requestor        = this,
                    Resource         = state.Resource,
                    Timeout          = 100000,
                    UpdateUICallback = SaveResourceCallback
                });
            }
        }
 protected abstract void ProcessResource( ResourceTree aResourceTree );
 protected abstract void ProcessResource(ResourceTree aResourceTree);
Example #32
0
 /// <summary>
 /// Called when the <see cref="SaveResourceJob"/> has terminated.
 /// </summary>
 /// <param name="result">The <see cref="JobResult"/>.</param>
 /// <remarks>
 /// Runs on the UI thread.
 /// </remarks>
 void SaveResourceCallback(JobResult result)
 {
     ResourceTree.FinishSaveToRemote(result);
 }
        protected override void ProcessResource( ResourceTree aResourceTree )
        {
            System.Func<ResourceTreeNode, XElement, XElement> GetChildren = null;
              var excludedGroups = new NodeGroup[] {
            NodeGroup.ExtensionPackages, NodeGroup.GameInformation, NodeGroup.GlobalGameSettings, NodeGroup.Invalid
              };

              GetChildren = ( aNode, aParent ) => {
            foreach ( var node in aNode ) {
              if ( node.Type == NodeTypes.Group )
            aParent.Add( GetChildren( node, new XElement( "Group", new XAttribute( "Name", node.Name ) ) ) );
              else
            aParent.Add( new XElement( "Node", new XAttribute( "Name", node.Name ), new XAttribute( "ID", node.ID ) ) );
            }

            return aParent;
              };

              var document =
            new XElement( "Tree",
              from node in aResourceTree
              where !excludedGroups.Contains( node.Group )
              select GetChildren( node, new XElement( node.Group.ToString() ) )
            );

              SaveDocument( document, Filenames.Tree + ".xml" );
        }