Esempio n. 1
0
        public static void LoadFontFile(AtlasModel atlasmodel)
        {
            // example?
            //  https://github.com/cyotek/Cyotek.Drawing.BitmapFont

            BitmapFont _font = new BitmapFont();

            _font.Load(atlasmodel.AngelcodeFontFile);

            FontModel newfont = new FontModel();

            newfont.Id          = (ushort)_font.FontSize;       // (ushort)fontSettings.FontSize,
            newfont.size        = _font.FontSize;               // fontSettings.FontSize,
            newfont.lineheight  = (int)(_font.LineHeight);      // glyphHeight, // 22,
            newfont.spacelength = (int)(_font.FontSize * 0.6f); //FIXME ----------  (int)(glyphWidth * 0.6f), //todo ?
            newfont.baseline    = _font.BaseHeight;             // 0,
                                                                // newfont.kerning = _font.kern - 0.5f,
                                                                //  newfont.monowidth = _font.mono fontSettings.FontSize + 1,
            newfont.letterspacing = 0;

            //  newfont.rangeFrom = _font.Characters[0];
            //  newfont.rangeTo = _font.Characters[_font.Characters.Length - 1];

            foreach (var character in _font.Characters)
            {
                newfont.SetGlyph(character.Key.ToString(), new Glyph()
                {
                    advance  = character.Value.XAdvance
                    , height = character.Value.Bounds.Height
                    , width  = character.Value.Bounds.Width
                    , X      = character.Value.Bounds.X
                    , Y      = character.Value.Bounds.Y
                });
                newfont.SetVerticalOffset(character.Key.ToString(), character.Value.Offset.Y);
                newfont.offset = new FontOffset()
                {
                    x = character.Value.Offset.X,
                    y = character.Value.Offset.Y
                };
                //  newfont.spacelength = character.Value.
            }

            foreach (var kerning in _font.Kernings)
            {
                //if(kerning.Key.FirstCharacter != 'o' && kerning.Key.FirstCharacter != 'v')
                //{
                //    continue;
                //}
                newfont.SetKerning(kerning.Key.FirstCharacter.ToString(), new Kerning()
                {
                    KerningValue = kerning.Value, RightGlyphID = kerning.Key.SecondCharacter
                });
            }


            atlasmodel.Fonts.Add(newfont);
        }
Esempio n. 2
0
        /// <summary>
        /// Set the current item
        /// </summary>
        /// <param name="guid">The guid of the item</param>
        /// <returns>true if the new item is set, false otherwise</returns>
        //public bool SetCurrent(Guid guid)
        //{
        //    var item = Items.Where(x => x.Guid == guid);
        //    if (item.Any())
        //    {
        //        IItem newItem = item.First();
        //        CurrentItem = newItem;

        //        //ResourceDictionary theme = Application.Current.MainWindow.Resources.MergedDictionaries[0];
        //        //ResourceDictionary appTheme = Application.Current.Resources.MergedDictionaries.Count > 0
        //        //                                  ? Application.Current.Resources.MergedDictionaries[0]
        //        //                                  : null;
        //        //theme.BeginInit();
        //        //theme.MergedDictionaries.Clear();
        //        //if (appTheme != null)
        //        //{
        //        //    appTheme.BeginInit();
        //        //    appTheme.MergedDictionaries.Clear();
        //        //}
        //        //else
        //        //{
        //        //    appTheme = new ResourceDictionary();
        //        //    appTheme.BeginInit();
        //        //    Application.Current.Resources.MergedDictionaries.Add(appTheme);
        //        //}
        //        //foreach (Uri uri in newTheme.UriList)
        //        //{
        //        //    ResourceDictionary newDict = new ResourceDictionary {Source = uri};
        //        //    /*AvalonDock and menu style needs to move to the application
        //        //     * 1. AvalonDock needs global styles as floatable windows can be created
        //        //     * 2. Menu's need global style as context menu can be created
        //        //    */
        //        //    if (uri.ToString().Contains("AvalonDock") ||
        //        //        uri.ToString().Contains("Wide;component/Interfaces/Styles/VS2012/Menu.xaml"))
        //        //    {
        //        //        appTheme.MergedDictionaries.Add(newDict);
        //        //    }
        //        //    else
        //        //    {
        //        //        theme.MergedDictionaries.Add(newDict);
        //        //    }
        //        //}
        //        //appTheme.EndInit();
        //        //theme.EndInit();
        //        _logger.Log("projectfile item set to " + newItem.Name, LogCategory.Info, LogPriority.None);
        //        _eventAggregator.GetEvent<ItemChangeEvent>().Publish(newItem);
        //    }
        //    return false;
        //}

        /// <summary>
        /// Adds a base item to the project-file manager
        /// </summary>
        /// <param name="theme">The item to add</param>
        /// <returns>true, if successful - false, otherwise</returns>
        public bool AddAtlas(AtlasModel Atlas)
        {
            if (!Atlass.Contains(Atlas))
            {
                Atlass.Add(Atlas);
                return(true);
            }
            return(false);
        }
Esempio n. 3
0
        public ContentViewModel NewContent(object parameter)
        {
            var vm    = VEFModule.UnityContainer.Resolve(typeof(AtlasViewModel), "") as AtlasViewModel;
            var model = VEFModule.UnityContainer.Resolve(typeof(AtlasModel), "") as AtlasModel;
            var view  = VEFModule.UnityContainer.Resolve(typeof(AtlasView), "") as AtlasView;

            //Model details
            _loggerService.Log("Creating a new simple file using AtlasHandler", LogCategory.Info, LogPriority.Low);

            //Clear the undo stack
            //   model.Document.UndoStack.ClearAll();

            //Set the model and view
            vm.SetModel(model);
            vm.SetView(view);
            vm.Title = "Atlas";
            (vm.View as UserControl).DataContext = model;
            vm.SetHandler(this);
            model.SetDirty(true);

            model.SetLocation("AtlasID:##:");

            IProjectTreeService pfExplorerService = VEFModule.UnityContainer.Resolve(typeof(IProjectTreeService), "") as IProjectTreeService;
            IAtlasService       AtlasService      = VEFModule.UnityContainer.Resolve(typeof(IAtlasService), "") as IAtlasService;

            PItem parent = null;

            if (pfExplorerService.SelectedItem != null)
            {
                parent = pfExplorerService.SelectedItem;
            }

            AtlasModel newAtlas = new AtlasModel();

            newAtlas.Parent = parent;

            if (pfExplorerService.SelectedItem != null)
            {
                pfExplorerService.SelectedItem.Items.Add(newAtlas);
            }

            AtlasService.Atlass.Add(newAtlas);
            //  AtlasService.SelectedAtlas = newAtlas;
            newAtlas.Open(-1);


            return(vm);
        }
Esempio n. 4
0
        public void Execute(object parameter)
        {
            Type t = parameter as Type;

            //if (t.Name == "VEXDBFileModel")
            //    UICategoyModel parent = parameter as UICategoyModel;

            UInt32 id = 0;

            if (mpm != null)
            {
                var tableModel = mpm.Parent as DBTableModel;
                if (tableModel != null)
                {
                    id = tableModel.AutoIncrement();
                }
            }

            //if (id > 0)
            //{
            //    if (t.Name == "RenderableComponent")
            //    {
            //        EntityX newEntity = new EntityX() {  Name = "New Entity" };
            //        RenderableComponent pom = new RenderableComponent() { Parent = newEntity };


            //      //  pom.Create();
            //        mpm.Items.Add(newEntity);
            //        newEntity.Components.Add(pom);
            //    }

            if (t.Name == "AtlasModel")
            {
                // EntityX newEntity = new EntityX() { Name = "New Entity" };
                AtlasModel pom = new AtlasModel();// { Parent = newEntity };

                //  pom.Create();
                mpm.Items.Add(pom);
                //  newEntity.Components.Add(pom);
            }
            //}
            //else
            //{
            //    (VEFModule.UnityContainer.Resolve(typeof(ILoggerService), "") as ILoggerService).Log("Error: CmdCreateStaticObj id =  (" + id.ToString() + ")", LogCategory.Error, LogPriority.High);
            //}
        }
Esempio n. 5
0
 public AtlasItemEventArgs(AtlasModel AtlasItem)
 {
     AtlasItem = AtlasItem;
 }
Esempio n. 6
0
        /// <summary>
        /// Opens a file and returns the corresponding MDViewModel
        /// </summary>
        /// <param name="info">The string location of the file</param>
        /// <returns>The <see cref="MDViewModel"/> for the file.</returns>
        public ContentViewModel OpenContent(object info, object param)
        {
            var location = info as string;

            if (location != null)
            {
                AtlasModel     model = null;
                AtlasViewModel vm    = VEFModule.UnityContainer.Resolve(typeof(AtlasViewModel), "") as AtlasViewModel;
                var            view  = VEFModule.UnityContainer.Resolve(typeof(AtlasView), "") as AtlasView;

                try
                {
                    IAtlasService       AtlasService      = VEFModule.UnityContainer.Resolve(typeof(IAtlasService), "") as IAtlasService;
                    IProjectTreeService pfExplorerService = VEFModule.UnityContainer.Resolve(typeof(IProjectTreeService), "") as IProjectTreeService;

                    //          string[] split = Regex.Split(info.ToString(), ":##:");
                    //if (split.Count() == 2)
                    //{
                    //    string identifier = split[0];
                    //    string ID = split[1];
                    //    if (identifier == "AtlasID")
                    //    {
                    var Atlas = AtlasService.Atlass.Where(x => x.ContentID == info.ToString());
                    if (Atlas.Any())
                    {
                        AtlasService.SelectedAtlas = Atlas.First();
                        AtlasService.SelectedAtlas.Open(info);
                    }
                    else //new Atlas
                    {
                        //    AtlasModel newAtlas = new AtlasModel() { Name = "Atlas NEW", ContentID = "AtlasID:##:" };
                        // newAtlas.Parent = parent;

                        if (pfExplorerService.SelectedItem is AtlasModel)
                        {    // pfExplorerService.SelectedItem.Items.Add(newAtlas);
                            var newAtlas = pfExplorerService.SelectedItem as AtlasModel;
                            if (newAtlas != null)
                            {
                                AtlasService.Atlass.Add(newAtlas);
                                //  AtlasService.SelectedAtlas = newAtlas;
                                newAtlas.Open(-1);

                                model = newAtlas;
                            }
                        }
                    }

                    //Model details
                    if (model == null)
                    {
                        model = VEFModule.UnityContainer.Resolve(typeof(AtlasModel), "") as AtlasModel;
                    }

                    model.SetLocation(info);

                    //  model.SetLocation("AuftragID:##:" + info + "");

                    //      model.Document.Text = File.ReadAllText(location);
                    model.SetDirty(true);
                    //   }
                }



                catch (Exception exception)
                {
                    _loggerService.Log(exception.Message, LogCategory.Exception, LogPriority.High);
                    _loggerService.Log(exception.StackTrace, LogCategory.Exception, LogPriority.High);
                    return(null);
                }

                //Clear the undo stack
                // model.Document.UndoStack.ClearAll();

                //Set the model and view
                vm.SetModel(model);
                vm.SetView(view);
                vm.Title = "AtlasViewer";//model.nae  // Path.GetFileName("Atlas gefunden");
                (vm.View as UserControl).DataContext = model;

                return(vm);
            }
            return(null);
        }