Esempio n. 1
0
        /// <summary>
        /// 获得操作系统名称
        /// </summary>
        /// <returns></returns>
        public static string GetOSVersionName()
        {
            OsEntry curEntry = OsEntry.CurrentOsEntry();
            var     kvs      = osEntries.Where(x => x.Value.Equals(curEntry));

            if (kvs.Any())
            {
                string osName = null;
                var    das    = kvs.Select(kv => DescriptionAttribute.GetDescription(kv.Key));
                if (das.Count() == 2)
                {
                    if (IsWindowsServer)
                    {
                        osName = das.First(da => da.Tag == 1).Text;
                    }
                    else
                    {
                        osName = das.First(da => da.Tag == 0).Text;
                    }
                }
                else
                {
                    osName = das.First().Text;
                }
                return($"{osName} ({(Environment.Is64BitOperatingSystem ? "64" : "32")}位)");
            }
            else
            {
                return("UnKnow");
            }
        }
Esempio n. 2
0
        public static EditableValue Create(object o, System.Reflection.PropertyInfo info)
        {
            var ret = new EditableValue();

            ret.Value = o;

            var p          = info;
            var attributes = p.GetCustomAttributes(false);

            var undo = attributes.Where(_ => _.GetType() == typeof(UndoAttribute)).FirstOrDefault() as UndoAttribute;

            if (undo != null && !undo.Undo)
            {
                ret.IsUndoEnabled = false;
            }
            else
            {
                ret.IsUndoEnabled = true;
            }

            var shown = attributes.Where(_ => _.GetType() == typeof(ShownAttribute)).FirstOrDefault() as ShownAttribute;

            if (shown != null && !shown.Shown)
            {
                ret.IsShown = false;
            }

            var selector_attribute = (from a in attributes where a is Data.SelectorAttribute select a).FirstOrDefault() as Data.SelectorAttribute;

            if (selector_attribute != null)
            {
                ret.SelfSelectorID = selector_attribute.ID;
            }

            // collect selected values
            var selectedAttributes = attributes.OfType <Data.SelectedAttribute>();

            if (selectedAttributes.Count() > 0)
            {
                if (selectedAttributes.Select(_ => _.ID).Distinct().Count() > 1)
                {
                    throw new Exception("Same IDs are required.");
                }

                ret.TargetSelectorID       = selectedAttributes.First().ID;
                ret.RequiredSelectorValues = selectedAttributes.Select(_ => _.Value).ToArray();
            }

            ret.Title       = NameAttribute.GetName(attributes);
            ret.Description = DescriptionAttribute.GetDescription(attributes);

            return(ret);
        }
Esempio n. 3
0
        public static EditableValue Create(object o, System.Reflection.PropertyInfo info)
        {
            var ret = new EditableValue();

            ret.Value = o;

            var p          = info;
            var attributes = p.GetCustomAttributes(false);

            ret.Title       = NameAttribute.GetName(attributes);
            ret.Description = DescriptionAttribute.GetDescription(attributes);

            var undo = attributes.Where(_ => _.GetType() == typeof(Effekseer.Data.UndoAttribute)).FirstOrDefault() as Effekseer.Data.UndoAttribute;

            if (undo != null && !undo.Undo)
            {
                ret.IsUndoEnabled = false;
            }
            else
            {
                ret.IsUndoEnabled = true;
            }

            var shown = attributes.Where(_ => _.GetType() == typeof(Effekseer.Data.ShownAttribute)).FirstOrDefault() as Effekseer.Data.ShownAttribute;

            if (shown != null && !shown.Shown)
            {
                ret.IsShown = false;
            }

            var selector_attribute = (from a in attributes where a is Data.SelectorAttribute select a).FirstOrDefault() as Data.SelectorAttribute;

            if (selector_attribute != null)
            {
                ret.SelectorID = selector_attribute.ID;
            }

            var selected_attribute = (from a in attributes where a is Data.SelectedAttribute select a).FirstOrDefault() as Data.SelectedAttribute;

            if (selected_attribute != null)
            {
                ret.SelectedID    = selected_attribute.ID;
                ret.SelectedValue = selected_attribute.Value;
            }

            return(ret);
        }
Esempio n. 4
0
        private void BitlyShortenCallback(BitlyResponse bitlyUrl)
        {
            try
            {
                Action updateUi;
                if (bitlyUrl.StatusCode == 200)
                {
                    updateUi = () => { Url = bitlyUrl.Data.Url; };
                }
                else
                {
                    updateUi = () => { Error = DescriptionAttribute.GetDescription(bitlyUrl.Error); };
                }

                DispatcherHelper.CheckBeginInvokeOnUI(updateUi);
            }
            finally
            {
                DispatcherHelper.CheckBeginInvokeOnUI(() => { IsLoading = false; UrlFocused = true; });
            }
        }
Esempio n. 5
0
            /// <summary>
            /// プロパティから生成
            /// </summary>
            /// <param name="properties"></param>
            public TypeRow(PropertyInfo[] properties, List <TypeRow> sameLayer, TypeRow parent)
            {
                Parent = parent;

                var p          = properties.LastOrDefault();
                var attributes = p.GetCustomAttributes(false);

                Control gui = null;

                var undo = attributes.Where(_ => _.GetType() == typeof(Effekseer.Data.UndoAttribute)).FirstOrDefault() as Effekseer.Data.UndoAttribute;

                if (undo != null && !undo.Undo)
                {
                    EnableUndo = false;
                }
                else
                {
                    EnableUndo = true;
                }

                var shown = attributes.Where(_ => _.GetType() == typeof(Effekseer.Data.ShownAttribute)).FirstOrDefault() as Effekseer.Data.ShownAttribute;

                if (shown != null && !shown.Shown)
                {
                    gui = null;
                    return;
                }
                else if (p.PropertyType == typeof(Data.Value.String))
                {
                    gui = new String();
                }
                else if (p.PropertyType == typeof(Data.Value.Boolean))
                {
                    gui = new Boolean();
                }
                else if (p.PropertyType == typeof(Data.Value.Int))
                {
                    gui = new Int();
                }
                else if (p.PropertyType == typeof(Data.Value.IntWithInifinite))
                {
                    gui = new IntWithInifinite();
                }
                else if (p.PropertyType == typeof(Data.Value.IntWithRandom))
                {
                    gui = new IntWithRandom();
                }
                else if (p.PropertyType == typeof(Data.Value.Float))
                {
                    gui = new Float();
                }
                else if (p.PropertyType == typeof(Data.Value.FloatWithRandom))
                {
                    gui = new FloatWithRandom();
                }
                else if (p.PropertyType == typeof(Data.Value.Vector2D))
                {
                    gui = new Vector2D();
                }
                else if (p.PropertyType == typeof(Data.Value.Vector2DWithRandom))
                {
                    gui = new Vector2DWithRandom();
                }
                else if (p.PropertyType == typeof(Data.Value.Vector3D))
                {
                    gui = new Vector3D();
                }
                else if (p.PropertyType == typeof(Data.Value.Vector3DWithRandom))
                {
                    gui = new Vector3DWithRandom();
                }
                else if (p.PropertyType == typeof(Data.Value.Color))
                {
                    gui = new ColorCtrl();
                }
                else if (p.PropertyType == typeof(Data.Value.ColorWithRandom))
                {
                    gui = new ColorWithRandom();
                }
                else if (p.PropertyType == typeof(Data.Value.Path))
                {
                    gui = new Path();
                }
                else if (p.PropertyType == typeof(Data.Value.PathForModel))
                {
                    gui = new PathForModel();
                }
                else if (p.PropertyType == typeof(Data.Value.PathForImage))
                {
                    gui = new PathForImage();
                }
                else if (p.PropertyType == typeof(Data.Value.PathForSound))
                {
                    gui = new PathForSound();
                }
                else if (p.PropertyType == typeof(Data.Value.FCurveVector2D))
                {
                    FCurveButton button = new FCurveButton();
                    gui = button;
                }
                else if (p.PropertyType == typeof(Data.Value.FCurveVector3D))
                {
                    FCurveButton button = new FCurveButton();
                    gui = button;
                }
                else if (p.PropertyType == typeof(Data.Value.FCurveColorRGBA))
                {
                    FCurveButton button = new FCurveButton();
                    gui = button;
                }
                else if (p.PropertyType == typeof(Data.Value.FCurve <float>))
                {
                    gui = null;
                    return;
                }
                else if (p.PropertyType == typeof(Data.Value.FCurve <byte>))
                {
                    gui = null;
                    return;
                }
                else if (p.PropertyType == typeof(Data.Value.IFCurveKey))
                {
                    gui = null;
                    return;
                }
                else if (p.PropertyType == typeof(Data.Value.Enum <Language>))
                {
                    gui = new GuiLanguage();
                }
                else if (p.PropertyType.IsGenericType)
                {
                    var types = p.PropertyType.GetGenericArguments();
                    gui = new Enum();

                    var dgui = (dynamic)gui;
                    dgui.Initialize(types[0]);
                }

                var selector_attribute = (from a in attributes where a is Data.SelectorAttribute select a).FirstOrDefault() as Data.SelectorAttribute;

                if (selector_attribute != null)
                {
                    IsSelector = true;
                    SelectorID = selector_attribute.ID;
                }
                else
                {
                    IsSelector = false;
                    SelectorID = -1;
                }

                Properties  = properties.Clone() as PropertyInfo[];
                Title       = NameAttribute.GetName(attributes);
                Description = DescriptionAttribute.GetDescription(attributes);
                Control     = gui;

                // Selector
                var selected_attribute = (from a in attributes where a is Data.SelectedAttribute select a).FirstOrDefault() as Data.SelectedAttribute;

                if (selected_attribute != null)
                {
                    var selector = sameLayer.Where(_ => _.IsSelector && _.SelectorID == selected_attribute.ID).LastOrDefault();

                    if (selector != null)
                    {
                        Selector      = selector;
                        SelectorValue = selected_attribute.Value;
                    }
                }

                Label           = new Label();
                Label.Width     = 0;
                Label.AutoSize  = true;
                Label.Text      = Title;
                Label.TextAlign = ContentAlignment.MiddleCenter;
                Label.Font      = new Font(Label.Font.FontFamily, 9);
                ControlDynamic  = Control;

                if (Control != null && !(Control is Button))
                {
                    ControlDynamic.EnableUndo = EnableUndo;
                }
            }
Esempio n. 6
0
        public static EditableValue Create(object o, System.Reflection.PropertyInfo info)
        {
            var ret = new EditableValue();

            ret.Value = o;

            var p          = info;
            var attributes = p.GetCustomAttributes(false);

            var undo = attributes.Where(_ => _.GetType() == typeof(UndoAttribute)).FirstOrDefault() as UndoAttribute;

            if (undo != null && !undo.Undo)
            {
                ret.IsUndoEnabled = false;
            }
            else
            {
                ret.IsUndoEnabled = true;
            }

            var shown = attributes.Where(_ => _.GetType() == typeof(ShownAttribute)).FirstOrDefault() as ShownAttribute;

            if (shown != null && !shown.Shown)
            {
                ret.IsShown = false;
            }

            var selector_attribute = (from a in attributes where a is Data.SelectorAttribute select a).FirstOrDefault() as Data.SelectorAttribute;

            if (selector_attribute != null)
            {
                ret.SelfSelectorID = selector_attribute.ID;
            }

            // collect selected values
            var selectedAttributes = attributes.OfType <Data.SelectedAttribute>();

            if (selectedAttributes.Count() > 0)
            {
                if (selectedAttributes.Select(_ => _.ID).Distinct().Count() > 1)
                {
                    throw new Exception("Same IDs are required.");
                }

                ret.TargetSelectorID       = selectedAttributes.First().ID;
                ret.RequiredSelectorValues = selectedAttributes.Select(_ => _.Value).ToArray();
            }

            var key     = KeyAttribute.GetKey(attributes);
            var nameKey = key + "_Name";

            if (string.IsNullOrEmpty(key))
            {
                nameKey = info.ReflectedType.Name + "_" + info.Name + "_Name";
            }

            if (MultiLanguageTextProvider.HasKey(nameKey))
            {
                ret.Title = new MultiLanguageString(nameKey);
            }
            else
            {
                ret.Title = NameAttribute.GetName(attributes);
                //if (!string.IsNullOrEmpty(ret.Title.ToString()))
                //{
                //	System.IO.File.AppendAllText("kv.csv", nameKey + ","  + "\"" + ret.Title.ToString() + "\"" + "\r\n");
                //}
            }

            var descKey = key + "_Desc";

            if (string.IsNullOrEmpty(key))
            {
                descKey = info.ReflectedType.Name + "_" + info.Name + "_Desc";
            }

            if (MultiLanguageTextProvider.HasKey(descKey))
            {
                ret.Description = new MultiLanguageString(descKey);
            }
            else
            {
                ret.Description = DescriptionAttribute.GetDescription(attributes);

                //if(!string.IsNullOrEmpty(ret.Description.ToString()))
                //{
                //	System.IO.File.AppendAllText("kv.csv", descKey + "," + "\"" + ret.Description.ToString() + "\"" + "\r\n");
                //}
            }

            var treeNode = attributes.OfType <TreeNodeAttribute>().FirstOrDefault();

            if (treeNode != null)
            {
                ret.TreeNodeID = treeNode.id;

                if (MultiLanguageTextProvider.HasKey(treeNode.key))
                {
                    ret.Title = new MultiLanguageString(treeNode.key);
                }
            }

            return(ret);
        }