Exemple #1
0
        /// <summary>
        /// 获得预览信息
        /// </summary>
        /// <param name="fileName">文件物理路径</param>
        /// <param name="attachment">附件对象</param>
        /// <returns>预览信息的HTML</returns>
        public string GetPreview(string fileName, ShowtopicPageAttachmentInfo attachment)
        {
            if (!PreviewHelper.IsFileExist(fileName))
            {
                return("");
            }
            string        id   = Guid.NewGuid().ToString();
            EXIFextractor exif = new EXIFextractor(fileName, string.Empty, string.Empty);

            if (exif.Count < 1)
            {
                return(string.Empty);
            }
            StringBuilder builder = new StringBuilder();

            foreach (System.Web.UI.Pair s in exif)
            {
                if (s.Second.ToString().Trim() == "-" || s.Second.ToString().Trim() == string.Empty || s.Second.ToString().Trim() == "0")
                {
                    continue;
                }
                builder.Append("<li>");
                builder.Append(s.First.ToString().Trim() + " : " + s.Second.ToString().Replace("\0", string.Empty).Trim());
                builder.Append("</li>");
            }
            if (builder.Length == 0)
            {
                return(string.Empty);
            }
            builder.Append("</ul></div>");

            builder.Insert(0, string.Format("<span><a onclick=\"$('{0}').style.display=$('{0}').style.display=='none'?'':'none';\" style='cursor:pointer;' title='点击显示或隐藏'>EXIF信息</a></span><div class=\"preview{1}\"><ul id=\"{0}\" style='display: none;'>", id, "jpg"));

            return(builder.ToString());
        }
Exemple #2
0
        public static string GetSpriteFromJob(MultiGrfReader grf, Job job, PreviewHelper helper, string sprite, ViewIdTypes type)
        {
            switch (type)
            {
            case ViewIdTypes.Garment:
                return(GetSpritePathFromJob(grf, job, @"data\sprite\·Îºê\" + sprite + @"\" + helper.GenderString + "\\{0}_" + helper.GenderString, helper.Gender, null, sprite));

            case ViewIdTypes.Shield:
                return(GetSpritePathFromJob(grf, job, @"data\sprite\¹æÆÐ\{0}\{0}_" + helper.GenderString + sprite, helper.Gender, "¹æÆÐ", sprite));

            case ViewIdTypes.Weapon:
                return(GetSpritePathFromJob(grf, job, @"data\sprite\Àΰ£Á·\{0}\{0}_" + helper.GenderString + sprite, helper.Gender, "Àΰ£Á·", sprite));

            case ViewIdTypes.Headgear:
                return(EncodingService.FromAnyToDisplayEncoding(@"data\sprite\¾Ç¼¼»ç¸®\" + helper.GenderString + "\\" + EncodingService.FromAnyToDisplayEncoding(helper.GenderString + "_") + helper.PreviewSprite));

            case ViewIdTypes.Npc:
                if (helper.PreviewSprite != null && helper.PreviewSprite.EndsWith(".gr2", StringComparison.OrdinalIgnoreCase))
                {
                    return(EncodingService.FromAnyToDisplayEncoding(@"data\model\3dmob\" + helper.PreviewSprite));
                }

                return(EncodingService.FromAnyToDisplayEncoding(@"data\sprite\npc\" + helper.PreviewSprite));
            }

            return(null);
        }
Exemple #3
0
        public ViewIdPreviewDialog(SdeEditor editor, GDbTab tab) : base("View ID preview", "eye.png", SizeToContent.Manual, ResizeMode.CanResize)
        {
            _tab    = tab;
            _editor = editor;
            _editor._mainTabControl.SelectionChanged += _mainTabControl_SelectionChanged;

            InitializeComponent();
            WindowStartupLocation = WindowStartupLocation.CenterOwner;
            Owner       = WpfUtilities.TopWindow;
            WindowStyle = WindowStyle.ToolWindow;

            _helper = new PreviewHelper(_listView, _tab.DbComponent.To <int>(), _selector, _frameViewer, _gridSpriteMissing, _tbSpriteMissing);

            this.Loaded += delegate {
                Width    = 400;
                Height   = 300;
                IsOpened = true;
            };

            ListViewDataTemplateHelper.GenerateListViewTemplateNew(_listView, new ListViewDataTemplateHelper.GeneralColumnInfo[] {
                new ListViewDataTemplateHelper.RangeColumnInfo {
                    Header = "Job Name", DisplayExpression = "Name", SearchGetAccessor = "Name", IsFill = true, ToolTipBinding = "Name", TextWrapping = TextWrapping.Wrap
                }
            }, null, new string[] { "Normal", "{DynamicResource TextForeground}" });

            _tupleUpdate();
        }
Exemple #4
0
        /// <summary>
        /// 获得预览信息
        /// </summary>
        /// <param name="fileName">文件物理路径</param>
        /// <param name="attachment">附件对象</param>
        /// <returns>预览信息的HTML</returns>
        public string GetPreview(string fileName, ShowtopicPageAttachmentInfo attachment)
        {
            string Result = string.Empty;

            if (!PreviewHelper.IsFileExist(fileName))
            {
                return("");
            }
            WmaMessage mp3msg = new WmaMessage(fileName);

            Result = string.Format("<div style=\"overflow:hidden; zoom:1; border:1px solid #999; font-size:13px; width:360px;\">" +
                                   "<dl style=\"margin:8px;\"><dt style=\"clear:both; float:left; width:80px;\">标题:</dt><dd>{1}</dd>" +
                                   "<dt style=\"clear:both; float:left; width:100px;\">演唱者:</dt><dd>{2}</dd>" +
                                   "<dt style=\"clear:both; float:left; width:100px;\">专辑:</dt><dd>{4}</dd>" +
                                   "<dt style=\"clear:both; float:left; width:100px;\">流派:</dt><dd>{3}</dd>" +
                                   "<dt style=\"clear:both; float:left; width:100px;\">文件类型:</dt><dd>{9}</dd>" +
                                   "<dt style=\"clear:both; float:left; width:100px;\">比特率:</dt><dd>{6}</dd>" +
                                   "<dt style=\"clear:both; float:left; width:100px;\">声道:</dt><dd>{8}</dd>" +
                                   "<dt style=\"clear:both; float:left; width:100px;\">文件大小:</dt><dd>{7}</dd>" +
                                   "<dt style=\"clear:both; float:left; width:100px;\">发行年份:</dt><dd>{5}</dd></dl>" +
                                   "<div><object classid=\"CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6\" width=\"360\" height=\"64\"><param name=\"autostart\" value=\"1\" />" +
                                   "<param name=\"url\" value=\"{0}\" />" +
                                   "<embed src=\"{0}\" autostart=\"0\"type=\"video/x-ms-wmv\" width=\"260\"height=\"42\"></embed></object></div></div>", @"upload/" + attachment.Filename, mp3msg.Title, mp3msg.Artist, mp3msg.Genre, mp3msg.Album, mp3msg.PublishYear, mp3msg.BPS, mp3msg.Size, mp3msg.Track, mp3msg.Type);
            return(Result);
        }
Exemple #5
0
 //隐藏物体
 protected void SetEnabledRecursive(bool value)
 {
     if (m_MapObjects.Count > 0)
     {
         foreach (KeyValuePair <int, GameObject> item in m_MapObjects)
         {
             if (item.Value != null)
             {
                 PreviewHelper.SetEnabledRecursive(item.Value, value);
             }
         }
     }
 }
Exemple #6
0
    //添加GO 到预览窗体
    virtual public GameObject AddGameObject(GameObject go, bool cloneInstance = true)
    {
        AssertInit();

        if (go == null)
        {
            return(null);
        }

        if (m_MapObjects.ContainsKey(go.GetInstanceID()))
        {
            Debug.LogError(string.Format("GameObject[{0}] target is Exit in PreviewWindow", go.GetInstanceID()));
            return(go);
        }

        GameObject target = null;

        if (cloneInstance)
        {
            target = PreviewHelper.InstantiateGameObject(go);
        }
        else
        {
            PreviewHelper.FormatGameObject(go);
            target = go;
        }

        target.transform.position = Vector3.zero;

        //加入到目标列表
        m_MapObjects.Add(target.GetInstanceID(), target);

        SetEnabledRecursive(false);

#if UNITY_2017_1_OR_NEWER
        m_Preview.AddSingleGO(target);
#endif
        return(target);
    }
Exemple #7
0
        private void _findResourceErrors(List <ValidationErrorView> errors)
        {
            var itemDb  = _database.GetMetaTable <int>(ServerDbs.Items);
            var citemDb = _database.GetMetaTable <int>(ServerDbs.CItems);

            HashSet <string> processed = new HashSet <string>();

            _helper = new PreviewHelper(
                new RangeListView(),
                _database.GetDb <int>(ServerDbs.Items),
                null,
                null,
                null,
                null
                );

            Dictionary <int, string> npcsIds = new Dictionary <int, string>();

            if (SdeAppConfiguration.VaResNpc)
            {
                string error;
                LuaHelper.GetIdToSpriteTable(_database.GetDb <int>(ServerDbs.Items), LuaHelper.ViewIdTypes.Npc, out npcsIds, out error);
            }

            int totalEntries = citemDb.Count + itemDb.Count + npcsIds.Count;
            int current      = 0;

            char[] invalid = Path.GetInvalidFileNameChars();

            foreach (var citem in citemDb.FastItems)
            {
                AProgress.IsCancelling(this);
                Progress = (float)current / totalEntries * 100f;
                current++;

                if (SdeAppConfiguration.VaResExistingOnly)
                {
                    if (itemDb.TryGetTuple(citem.Key) == null)
                    {
                        continue;
                    }
                }

                var idresource = citem.GetValue <string>(ClientItemAttributes.IdentifiedResourceName) ?? "";
                var unresource = citem.GetValue <string>(ClientItemAttributes.UnidentifiedResourceName) ?? "";

                if (idresource == "")
                {
                    if (SdeAppConfiguration.VaResEmpty)
                    {
                        errors.Add(new ResourceError(ValidationErrors.ResEmpty, citem.Key, "Empty identified resource.", ServerDbs.CItems, this, null));
                    }
                }
                else if (invalid.Any(idresource.Contains))
                {
                    if (SdeAppConfiguration.VaResInvalidCharacters)
                    {
                        errors.Add(new ResourceError(ValidationErrors.ResInvalidName, citem.Key, "Illegal characters found in resource name.", ServerDbs.CItems, this, null));
                    }
                }
                else
                {
                    _resource(citem, ResourceType.Identified, idresource, processed, errors);
                }

                if (unresource == "")
                {
                    if (SdeAppConfiguration.VaResEmpty)
                    {
                        errors.Add(new ResourceError(ValidationErrors.ResEmpty, citem.Key, "Empty identified resource.", ServerDbs.CItems, this, null));
                    }
                }
                else if (invalid.Any(unresource.Contains))
                {
                    if (SdeAppConfiguration.VaResInvalidCharacters)
                    {
                        errors.Add(new ResourceError(ValidationErrors.ResInvalidName, citem.Key, "Illegal characters found in resource name.", ServerDbs.CItems, this, null));
                    }
                }
                else
                {
                    _resource(citem, ResourceType.Unidentified, unresource, processed, errors);
                }
            }

            foreach (var item in itemDb.FastItems)
            {
                AProgress.IsCancelling(this);
                Progress = (float)current / totalEntries * 100f;
                current++;

                var citem = citemDb.TryGetTuple(item.Key);

                if (citem == null)
                {
                    if (SdeAppConfiguration.VaResClientItemMissing)
                    {
                        errors.Add(new ResourceError(ValidationErrors.ResClientMissing, item.Key, "Client Items: " + item.Key + " missing", ServerDbs.Items, this, null));
                    }

                    continue;
                }

                if (SdeAppConfiguration.VaResHeadgear)
                {
                    var sprites = _helper.TestItem(item, _database.MetaGrf, typeof(HeadgearPreview));

                    foreach (var sprite in sprites)
                    {
                        _checkResource(sprite, errors, item, processed, ValidationErrors.ResHeadgear, "Headgear", ServerDbs.Items);
                    }
                }

                if (SdeAppConfiguration.VaResShield)
                {
                    var sprites = _helper.TestItem(item, _database.MetaGrf, typeof(ShieldPreview));

                    foreach (var sprite in sprites)
                    {
                        _checkResource(sprite, errors, item, processed, ValidationErrors.ResShield, "Shield", ServerDbs.Items);
                    }
                }

                if (SdeAppConfiguration.VaResWeapon)
                {
                    var sprites = _helper.TestItem(item, _database.MetaGrf, typeof(WeaponPreview));

                    foreach (var sprite in sprites)
                    {
                        _checkResource(sprite, errors, item, processed, ValidationErrors.ResWeapon, "Weapon", ServerDbs.Items);
                    }
                }

                if (SdeAppConfiguration.VaResGarment)
                {
                    var sprites = _helper.TestItem(item, _database.MetaGrf, typeof(GarmentPreview));

                    foreach (var sprite in sprites)
                    {
                        _checkResource(sprite, errors, item, processed, ValidationErrors.ResGarment, "Garment", ServerDbs.Items);
                    }
                }
            }

            if (SdeAppConfiguration.VaResNpc)
            {
                NpcPreview preview = new NpcPreview();

                foreach (var id in npcsIds.OrderBy(p => p.Key))
                {
                    AProgress.IsCancelling(this);
                    Progress = (float)current / totalEntries * 100f;
                    current++;

                    _helper.ViewId = id.Key;
                    preview.Read(null, _helper, new List <Job>());
                    var sprite = preview.GetSpriteFromJob(null, _helper);

                    _checkResource(sprite, errors, id.Key, processed, ValidationErrors.ResNpc, "NPC", ServerDbs.Zero);

                    if (!sprite.EndsWith(".gr2", StringComparison.OrdinalIgnoreCase))
                    {
                        _checkResource(sprite.ReplaceExtension(".spr"), errors, id.Key, processed, ValidationErrors.ResNpc, "NPC", ServerDbs.Zero);
                    }
                }
            }
        }
        public ShopSimulatorDialog()
            : base("Shop simulator", "editor.png", SizeToContent.Height, ResizeMode.NoResize)
        {
            InitializeComponent();
            WindowStartupLocation = WindowStartupLocation.CenterOwner;
            Owner = WpfUtilities.TopWindow;

            _shopItems           = new RangeObservableCollection <ShopItem>();
            _lvItems.ItemsSource = _shopItems;

            Binder.Bind(_cbColorZeny, () => SdeAppConfiguration.UseZenyColors, () => _shopItems.ToList().ForEach(p => p.Update()));
            Binder.Bind(_cbDiscount, () => SdeAppConfiguration.UseDiscount, () => _shopItems.ToList().ForEach(p => p.Update()));
            Binder.Bind(_cbUseViewId, () => SdeAppConfiguration.AlwaysUseViewId, () => {
                if (!_enableEvents || _primaryShop == null)
                {
                    return;
                }

                try {
                    _enableEvents = false;

                    string viewId = _primaryShop.NpcViewId;
                    int ival;

                    if (SdeAppConfiguration.AlwaysUseViewId)
                    {
                        if (!Int32.TryParse(viewId, out ival))
                        {
                            var constDb = SdeEditor.Instance.ProjectDatabase.GetDb <string>(ServerDbs.Constants);
                            var tuple   = constDb.Table.TryGetTuple(viewId);

                            if (tuple != null)
                            {
                                ival = tuple.GetValue <int>(ServerConstantsAttributes.Value);
                            }
                            else
                            {
                                ival = -1;
                            }

                            _primaryShop.NpcViewId = ival.ToString(CultureInfo.InvariantCulture);
                            _tbNpcViewId.Text      = _primaryShop.NpcViewId;
                            _primaryShop.Reload();
                        }
                    }
                    else
                    {
                        if (Int32.TryParse(viewId, out ival))
                        {
                            viewId = _viewIdToString(ival);

                            if (!String.IsNullOrEmpty(viewId))
                            {
                                if (viewId.IsExtension(".act", ".spr"))
                                {
                                    _primaryShop.NpcViewId = Path.GetFileNameWithoutExtension(viewId.ToUpper());
                                }
                                else
                                {
                                    _primaryShop.NpcViewId = Path.GetFileName(viewId);
                                }

                                _tbNpcViewId.Text = _primaryShop.NpcViewId;
                                _primaryShop.Reload();
                            }
                        }
                    }
                }
                catch (Exception err) {
                    ErrorHandler.HandleException(err);
                }
                finally {
                    _enableEvents = true;
                }
            });

            _shop.TextChanged += new EventHandler(_shop_TextChanged);

            AvalonLoader.Load(_shop);
            WpfUtils.AddMouseInOutEffectsBox(_cbColorZeny, _cbDiscount, _cbUseViewId);

            _helper = new PreviewHelper(new RangeListView(), SdeEditor.Instance.ProjectDatabase.GetDb <int>(ServerDbs.Items), null, null, null, null);

            FrameViewerSettings settings = new FrameViewerSettings();

            settings.Act            = () => _act;
            settings.SelectedAction = () => _actIndexSelected.SelectedAction;
            settings.SelectedFrame  = () => _actIndexSelected.SelectedFrame;
            _frameViewer.InitComponent(settings);

            _actIndexSelected.Init(_frameViewer);
            _actIndexSelected.Load(_act);
            _actIndexSelected.FrameChanged  += (s, p) => _frameViewer.Update();
            _actIndexSelected.ActionChanged += (s, p) => {
                _frameViewer.Update();

                if (!_enableEvents || _primaryShop == null)
                {
                    return;
                }

                try {
                    _enableEvents = false;

                    var elements = _tbNpcPosition.Text.Split(',');
                    var dir      = _convertAction(_actIndexSelected.SelectedAction);

                    if (elements.Length == 4)
                    {
                        elements[3] = dir.ToString(CultureInfo.InvariantCulture);
                        _primaryShop.ShopLocation = string.Join(",", elements);
                        _primaryShop.Reload();
                    }
                    else
                    {
                        _primaryShop.ShopLocation = "prontera,150,150," + dir.ToString(CultureInfo.InvariantCulture);
                        _primaryShop.Reload();
                    }

                    _tbNpcPosition.Text = _primaryShop.ShopLocation;
                }
                catch (Exception err) {
                    ErrorHandler.HandleException(err);
                }
                finally {
                    _enableEvents = true;
                }
            };

            _actIndexSelected.SpecialFrameChanged += (s, p) => _frameViewer.Update();

            _lvItems.MouseRightButtonUp += new MouseButtonEventHandler(_lvItems_MouseRightButtonUp);
            _lvItems.SelectionChanged   += new SelectionChangedEventHandler(_lvItems_SelectionChanged);

            _tbItemId.TextChanged          += new TextChangedEventHandler(_tbItemId_TextChanged);
            _tbPrice.TextChanged           += new TextChangedEventHandler(_tbPrice_TextChanged);
            _tbNpcViewId.TextChanged       += new TextChangedEventHandler(_tbNpcViewId_TextChanged);
            _tbNpcPosition.TextChanged     += new TextChangedEventHandler(_tbNpcPosition_TextChanged);
            _tbNpcDisplayName.TextChanged  += new TextChangedEventHandler(_tbNpcDisplayName_TextChanged);
            _tbNpcShopCurrency.TextChanged += new TextChangedEventHandler(_tbNpcShopCurrency_TextChanged);

            _comboBoxShopType.SelectionChanged += new SelectionChangedEventHandler(_comboBoxShopType_SelectionChanged);

            _buttonResetPrice.Click += delegate {
                _tbPrice.Text = "-1";
            };

            _buttonCurItemQuery.Click += delegate {
                try {
                    Table <int, ReadableTuple <int> > btable = SdeEditor.Instance.ProjectDatabase.GetMetaTable <int>(ServerDbs.Items);

                    SelectFromDialog select = new SelectFromDialog(btable, ServerDbs.Items, _tbNpcShopCurrency.Text);
                    select.Owner = WpfUtilities.TopWindow;

                    if (select.ShowDialog() == true)
                    {
                        _tbNpcShopCurrency.Text = select.Id;
                    }
                }
                catch (Exception err) {
                    ErrorHandler.HandleException(err);
                }
            };

            _buttonViewIdQuery.Click += delegate {
                try {
                    MultiGrfExplorer dialog = new MultiGrfExplorer(SdeEditor.Instance.ProjectDatabase.MetaGrf, "data\\sprite\\npc", "", _viewIdToString(FormatConverters.IntOrHexConverter(_primaryShop.NpcViewId ?? "")));

                    if (dialog.ShowDialog() == true)
                    {
                        var    path = dialog.SelectedPath.GetFullPath();
                        string result;

                        if (path.IsExtension(".act", ".spr"))
                        {
                            result = Path.GetFileNameWithoutExtension(path.ToUpper());
                        }
                        else
                        {
                            result = Path.GetFileName(path);
                        }

                        if (SdeAppConfiguration.AlwaysUseViewId)
                        {
                            var constDb = SdeEditor.Instance.ProjectDatabase.GetDb <string>(ServerDbs.Constants);
                            var tuple   = constDb.Table.TryGetTuple(result);
                            int ival;

                            if (tuple != null)
                            {
                                ival = tuple.GetValue <int>(ServerConstantsAttributes.Value);
                            }
                            else
                            {
                                _tbNpcViewId.Text = result;
                                return;
                            }

                            if (!_enableEvents || _primaryShop == null)
                            {
                                return;
                            }

                            try {
                                _enableEvents = false;

                                _primaryShop.NpcViewId = ival.ToString(CultureInfo.InvariantCulture);
                                _tbNpcViewId.Text      = _primaryShop.NpcViewId;
                                _updateViewShop();
                                _primaryShop.Reload();
                            }
                            catch (Exception err) {
                                ErrorHandler.HandleException(err);
                            }
                            finally {
                                _enableEvents = true;
                            }
                        }
                        else
                        {
                            _tbNpcViewId.Text = result;
                        }
                    }
                }
                catch (Exception err) {
                    ErrorHandler.HandleException(err);
                }
            };

            _buttonQueryItem.Click += delegate {
                try {
                    Table <int, ReadableTuple <int> > btable = SdeEditor.Instance.ProjectDatabase.GetMetaTable <int>(ServerDbs.Items);

                    SelectFromDialog select = new SelectFromDialog(btable, ServerDbs.Items, _tbItemId.Text);
                    select.Owner = WpfUtilities.TopWindow;

                    if (select.ShowDialog() == true)
                    {
                        _tbItemId.Text = select.Id;
                    }
                }
                catch (Exception err) {
                    ErrorHandler.HandleException(err);
                }
            };

            _gridColumnPrimary.Width = new GridLength(230 + SystemParameters.VerticalScrollBarWidth + 7);

            this.Loaded += delegate {
                this.MinHeight  = this.ActualHeight + 10;
                this.MinWidth   = this.ActualWidth;
                this.ResizeMode = ResizeMode.CanResize;
                SizeToContent   = SizeToContent.Manual;
            };

            ApplicationShortcut.Link(ApplicationShortcut.Delete, () => _buttonDelete_Click(null, null), _lvItems);
            ApplicationShortcut.Link(ApplicationShortcut.New, () => _buttonNew_Click(null, null), this);
            ApplicationShortcut.Link(ApplicationShortcut.FromString("Ctrl-Up", "MoveUp"), () => _buttonUp_Click(null, null), _lvItems);
            ApplicationShortcut.Link(ApplicationShortcut.FromString("Ctrl-Down", "MoveDown"), () => _buttonDown_Click(null, null), _lvItems);
            ApplicationShortcut.Link(ApplicationShortcut.Undo, () => _undo(), this);
            ApplicationShortcut.Link(ApplicationShortcut.Redo, () => _redo(), this);
            //_shop.Text = "alberta_in,182,97,0	shop	Tool Dealer#alb2	73,1750:-1,611:-1,501:-1,502:-1,503:-1,504:-1,506:-1,645:-1,656:-1,601:-1,602:-1,2243:-1";
        }