コード例 #1
0
 public static int _bind_getName(Lua.lua_State L)
 {
     if (Lua.lua_gettop(L) != 1 ||
         Luna.get_uniqueid(L, 1) != 55459900)
     {
         Luna.printStack(L); Lua.luaL_error(L, "luna typecheck failed:getName(LWF.BitmapClip self ...)");
     }
     LWF.BitmapClip o = Luna_LWF_BitmapClip.check(L, 1);
     try {
         string ret = getName(o);
         Lua.lua_pushstring(L, ret);
     } catch (Exception e) { Lua.luaL_error(L, new Lua.CharPtr(e.ToString())); }
     return(1);
 }
コード例 #2
0
    public static int _bind_detachFromParent(Lua.lua_State L)
    {
        if (Lua.lua_gettop(L) != 1 ||
            Luna.get_uniqueid(L, 1) != 55459900)
        {
            Luna.printStack(L); Lua.luaL_error(L, "luna typecheck failed:detachFromParent(LWF.BitmapClip self)");
        }

        LWF.BitmapClip self = Luna_LWF_BitmapClip.check(L, 1);
        try {
            self.DetachFromParent();
        } catch (Exception e) { Lua.luaL_error(L, new Lua.CharPtr(e.ToString())); }
        return(0);
    }
コード例 #3
0
    public static int _bind_stop(Lua.lua_State L)
    {
        if (Lua.lua_gettop(L) != 1 ||
            Luna.get_uniqueid(L, 1) != 29625181)
        {
            Luna.printStack(L); Lua.luaL_error(L, "luna typecheck failed:stop(LWF.Movie self)");
        }

        LWF.Movie self = Luna_LWF_Movie.check(L, 1);
        try {
            self.Stop();
        } catch (Exception e) { Lua.luaL_error(L, new Lua.CharPtr(e.ToString())); }
        return(0);
    }
コード例 #4
0
 public static int _bind_getPointY(Lua.lua_State L)
 {
     if (Lua.lua_gettop(L) != 1 ||
         Luna.get_uniqueid(L, 1) != 7105034)
     {
         Luna.printStack(L); Lua.luaL_error(L, "luna typecheck failed:getPointY(LWF.LWF self ...)");
     }
     LWF.LWF o = Luna_LWF_LWF.check(L, 1);
     try {
         float ret = getPointY(o);
         Lua.lua_pushnumber(L, ret);
     } catch (Exception e) { Lua.luaL_error(L, new Lua.CharPtr(e.ToString())); }
     return(1);
 }
コード例 #5
0
    public static int _bind__property_get_originalHeight(Lua.lua_State L)
    {
        if (Lua.lua_gettop(L) != 1 ||
            Luna.get_uniqueid(L, 1) != 55459900)
        {
            Luna.printStack(L); Lua.luaL_error(L, "luna typecheck failed:_property_get_originalHeight(LWF.BitmapClip a)");
        }

        LWF.BitmapClip a = Luna_LWF_BitmapClip.check(L, 1);
        try {
            float ret = _property_get_originalHeight(a);
            Lua.lua_pushnumber(L, ret);
        } catch (Exception e) { Lua.luaL_error(L, new Lua.CharPtr(e.ToString())); }
        return(1);
    }
コード例 #6
0
    public static int _bind__property_get_x(Lua.lua_State L)
    {
        if (Lua.lua_gettop(L) != 1 ||
            Luna.get_uniqueid(L, 1) != 32383421)
        {
            Luna.printStack(L); Lua.luaL_error(L, "luna typecheck failed:_property_get_x(LWF.Point a)");
        }

        LWF.Point a = Luna_LWF_Point.check(L, 1);
        try {
            float ret = _property_get_x(a);
            Lua.lua_pushnumber(L, ret);
        } catch (Exception e) { Lua.luaL_error(L, new Lua.CharPtr(e.ToString())); }
        return(1);
    }
コード例 #7
0
    public static int _bind__property_get_visible(Lua.lua_State L)
    {
        if (Lua.lua_gettop(L) != 1 ||
            Luna.get_uniqueid(L, 1) != 55459900)
        {
            Luna.printStack(L); Lua.luaL_error(L, "luna typecheck failed:_property_get_visible(LWF.BitmapClip a)");
        }

        LWF.BitmapClip a = Luna_LWF_BitmapClip.check(L, 1);
        try {
            bool ret = _property_get_visible(a);
            Lua.lua_pushboolean(L, ret?1:0);
        } catch (Exception e) { Lua.luaL_error(L, new Lua.CharPtr(e.ToString())); }
        return(1);
    }
コード例 #8
0
    public static int _bind_getFullName(Lua.lua_State L)
    {
        if (Lua.lua_gettop(L) != 1 ||
            Luna.get_uniqueid(L, 1) != 8952431)
        {
            Luna.printStack(L); Lua.luaL_error(L, "luna typecheck failed:getFullName(LWF.Button self)");
        }

        LWF.Button self = Luna_LWF_Button.check(L, 1);
        try {
            string ret = self.GetFullName();
            Lua.lua_pushstring(L, ret);
        } catch (Exception e) { Lua.luaL_error(L, new Lua.CharPtr(e.ToString())); }
        return(1);
    }
コード例 #9
0
    public static int __index(Lua.lua_State L)
    {
        if (Lua.lua_gettop(L) == 2 && Luna.get_uniqueid(L, 1) ==
            LunaTraits_LWF_Movie.uniqueID)
        {
            LWF.Movie o =
                Luna_LWF_Movie.check(L, 1);
            string name = Lua.lua_tostring(L, 2).ToString();
            if (o.lwf.GetFieldLua(o, name))
            {
                return(1);
            }
            LWF.Movie movie = o.SearchMovieInstance(name, false);
            if (movie != null)
            {
                Lua.lua_pop(L, 1);
                Luna_LWF_Movie.push(L, movie, false);
                return(1);
            }
            LWF.Button button = o.SearchButtonInstance(name, false);
            if (button != null)
            {
                Lua.lua_pop(L, 1);
                Luna_LWF_Button.push(L, button, false);
                return(1);
            }
        }


        {
            Lua.lua_CFunction fnc = null;
            if (LunaTraits_LWF_Movie.properties.TryGetValue(Lua.lua_tostring(L, 2).ToString(), out fnc))
            {
                Lua.lua_pop(L, 1);                // remove self
                return(fnc(L));
            }
        }

        int mt = Lua.lua_getmetatable(L, 1);

        if (mt == 0)
        {
            Lua.luaL_error(L, "__index");             //end
        }
        Lua.lua_pushstring(L, Lua.lua_tostring(L, 2));
        Lua.lua_rawget(L, -2);
        return(1);
    }
コード例 #10
0
        private void Awake()
        {
            Instance = this;
            DontDestroyOnLoad(gameObject);

            sw.Start();

            Luna.ReadBytes = ReadBytes;

            loader = new ResScriptLoader
            {
#if LUNA_SCRIPT
                ScriptPath = "luna/"
#else
                ScriptPath = "lua/"
#endif
            };

            loader.AddSearchPath("core");
            loader.AddSearchPath("math");

            OnPreInit();

            sw.Stop();

            Debug.Log($"Luna preinit time : {sw.ElapsedMilliseconds} ms");

            sw.Start();

            luna           = new Luna(modules.ToArray());
            luna.PostInit += OnPostInit;

            OnInit();

            sw.Stop();

            Debug.Log($"Luna init time : { sw.ElapsedMilliseconds} ms");

            sw.Start();

            luna.Start();

            sw.Stop();

            Debug.Log($"Luna start time : {sw.ElapsedMilliseconds} ms");

            LunaCreate?.Invoke(luna);
        }
コード例 #11
0
        void OnEnable()
        {
            // Check whether there is already a serialized view state (state
            // that survived assembly reloading)
            if (m_TreeViewState == null)
            {
                m_TreeViewState = new TreeViewState();
            }

            m_TableTreeView = new LunaTableView(m_TreeViewState);
            luna            = LunaClient.Luna;
            m_TableTreeView.Refresh(luna);

            LunaClient.LunaCreate  += LunaClient_LunaCreate;
            LunaClient.LunaDestroy += LunaClient_LunaDestroy;
        }
コード例 #12
0
    public static int _bind_setVisible(Lua.lua_State L)
    {
        if (Lua.lua_gettop(L) != 2 ||
            Luna.get_uniqueid(L, 1) != 29625181 ||
            Lua.lua_isboolean(L, 2))
        {
            Luna.printStack(L); Lua.luaL_error(L, "luna typecheck failed:setVisible(LWF.Movie self ...)");
        }
        LWF.Movie o = Luna_LWF_Movie.check(L, 1);
        bool      v = Lua.lua_toboolean(L, 2) != 0;

        try {
            setVisible(o, v);
        } catch (Exception e) { Lua.luaL_error(L, new Lua.CharPtr(e.ToString())); }
        return(0);
    }
コード例 #13
0
    public static int _bind_setBlue(Lua.lua_State L)
    {
        if (Lua.lua_gettop(L) != 2 ||
            Luna.get_uniqueid(L, 1) != 29625181 ||
            Lua.lua_isnumber(L, 2) == 0)
        {
            Luna.printStack(L); Lua.luaL_error(L, "luna typecheck failed:setBlue(LWF.Movie self ...)");
        }
        LWF.Movie o = Luna_LWF_Movie.check(L, 1);
        float     v = (float)Lua.lua_tonumber(L, 2);

        try {
            setBlue(o, v);
        } catch (Exception e) { Lua.luaL_error(L, new Lua.CharPtr(e.ToString())); }
        return(0);
    }
コード例 #14
0
    public static int _bind__property_set_visible(Lua.lua_State L)
    {
        if (Lua.lua_gettop(L) != 2 ||
            Luna.get_uniqueid(L, 1) != 55459900 ||
            !Lua.lua_isboolean(L, 2))
        {
            Luna.printStack(L); Lua.luaL_error(L, "luna typecheck failed:_property_set_visible(LWF.BitmapClip a, bool b)");
        }

        LWF.BitmapClip a = Luna_LWF_BitmapClip.check(L, 1);
        bool           b = (bool)(Lua.lua_toboolean(L, 2) != 0);

        try {
            _property_set_visible(a, b);
        } catch (Exception e) { Lua.luaL_error(L, new Lua.CharPtr(e.ToString())); }
        return(0);
    }
コード例 #15
0
    public static int _bind__property_set_originalHeight(Lua.lua_State L)
    {
        if (Lua.lua_gettop(L) != 2 ||
            Luna.get_uniqueid(L, 1) != 55459900 ||
            Lua.lua_isnumber(L, 2) == 0)
        {
            Luna.printStack(L); Lua.luaL_error(L, "luna typecheck failed:_property_set_originalHeight(LWF.BitmapClip a, float b)");
        }

        LWF.BitmapClip a = Luna_LWF_BitmapClip.check(L, 1);
        float          b = (float)(float)Lua.lua_tonumber(L, 2);

        try {
            _property_set_originalHeight(a, b);
        } catch (Exception e) { Lua.luaL_error(L, new Lua.CharPtr(e.ToString())); }
        return(0);
    }
コード例 #16
0
    public static int _bind_localToGlobal(Lua.lua_State L)
    {
        if (Lua.lua_gettop(L) != 2 ||
            Luna.get_uniqueid(L, 1) != 29625181 ||
            Luna.get_uniqueid(L, 2) != LunaTraits_LWF_Point.uniqueID)
        {
            Luna.printStack(L); Lua.luaL_error(L, "luna typecheck failed:localToGlobal(LWF.Movie self)");
        }

        LWF.Movie self  = Luna_LWF_Movie.check(L, 1);
        LWF.Point point = Luna_LWF_Point.check(L, 2);
        try {
            LWF.Point ret = self.LocalToGlobal(point);
            Luna_LWF_Point.push(L, ret, true, "LWF_Point");
        } catch (Exception e) { Lua.luaL_error(L, new Lua.CharPtr(e.ToString())); }
        return(1);
    }
コード例 #17
0
 public bool dizAddField(int fid, string fieldname, string fielddata = "")
 {
     try
     {
         if (fielddata == "")
         {
             return(Luna.dizAddField(fid, fieldname, (IntPtr)0));
         }
         IntPtr ptr = MallocIntptr(fielddata);
         ptr = ptr + 4;//将内存指针位置加 4 以兼容易语言内存操作模式
         return(Luna.dizAddField(fid, fieldname, ptr));
     }
     catch
     {
         return(false);
     }
 }
コード例 #18
0
    public static int _bind_gotoFrame(Lua.lua_State L)
    {
        if (Lua.lua_gettop(L) != 2 ||
            Luna.get_uniqueid(L, 1) != 29625181 ||
            Lua.lua_isnumber(L, 2) == 0)
        {
            Luna.printStack(L); Lua.luaL_error(L, "luna typecheck failed:gotoFrame(LWF.Movie self)");
        }

        LWF.Movie self    = Luna_LWF_Movie.check(L, 1);
        int       frameNo = (int)Lua.lua_tonumber(L, 2);

        try {
            self.GotoFrame(frameNo);
        } catch (Exception e) { Lua.luaL_error(L, new Lua.CharPtr(e.ToString())); }
        return(0);
    }
コード例 #19
0
        protected virtual void OnInit()
        {
            Luna.LoadAssembly("mscorlib");
            Luna.LoadAssembly("UnityEngine");
            Luna.LoadAssembly("UnityEngine.UI");

            Converter.RegisterAction <UnityEngine.Object>();
            Converter.RegisterAction <GameObject>();
            Converter.RegisterAction <AsyncOperation>();

            Converter.RegisterFunc <UnityEngine.Object>();
            Converter.RegisterFunc <GameObject>();

            Converter.RegDelegateFactory(IEnumeratorBridge.Create);

            Converter.RegDelegateFactory(CreateUnityAction);
        }
コード例 #20
0
    public static int _bind__property_set_y(Lua.lua_State L)
    {
        if (Lua.lua_gettop(L) != 2 ||
            Luna.get_uniqueid(L, 1) != 32383421 ||
            Lua.lua_isnumber(L, 2) == 0)
        {
            Luna.printStack(L); Lua.luaL_error(L, "luna typecheck failed:_property_set_y(LWF.Point a, float b)");
        }

        LWF.Point a = Luna_LWF_Point.check(L, 1);
        float     b = (float)(float)Lua.lua_tonumber(L, 2);

        try {
            _property_set_y(a, b);
        } catch (Exception e) { Lua.luaL_error(L, new Lua.CharPtr(e.ToString())); }
        return(0);
    }
コード例 #21
0
    public static int _bind_clearEventListener(Lua.lua_State L)
    {
        if (Lua.lua_gettop(L) != 2 ||
            Luna.get_uniqueid(L, 1) != 8952431 ||
            Lua.lua_isstring(L, 2) == 0)
        {
            Luna.printStack(L); Lua.luaL_error(L, "luna typecheck failed:clearEventListener(LWF.Button self)");
        }

        LWF.Button self      = Luna_LWF_Button.check(L, 1);
        string     eventName = Lua.lua_tostring(L, 2).ToString();

        try {
            self.ClearEventHandler(eventName);
        } catch (Exception e) { Lua.luaL_error(L, new Lua.CharPtr(e.ToString())); }
        return(0);
    }
コード例 #22
0
    public static int _bind_prevFrameMovie(Lua.lua_State L)
    {
        if (Lua.lua_gettop(L) != 2 ||
            Luna.get_uniqueid(L, 1) != 7105034 ||
            Lua.lua_isstring(L, 2) == 0)
        {
            Luna.printStack(L); Lua.luaL_error(L, "luna typecheck failed:prevFrameMovie(LWF.LWF self)");
        }

        LWF.LWF self         = Luna_LWF_LWF.check(L, 1);
        string  instanceName = Lua.lua_tostring(L, 2).ToString();

        try {
            self.PrevFrameMovie(instanceName);
        } catch (Exception e) { Lua.luaL_error(L, new Lua.CharPtr(e.ToString())); }
        return(0);
    }
コード例 #23
0
    public static int _bind_getText(Lua.lua_State L)
    {
        if (Lua.lua_gettop(L) != 2 ||
            Luna.get_uniqueid(L, 1) != 7105034 ||
            Lua.lua_isstring(L, 2) == 0)
        {
            Luna.printStack(L); Lua.luaL_error(L, "luna typecheck failed:getText(LWF.LWF self)");
        }

        LWF.LWF self     = Luna_LWF_LWF.check(L, 1);
        string  textName = Lua.lua_tostring(L, 2).ToString();

        try {
            string ret = self.GetText(textName);
            Lua.lua_pushstring(L, ret);
        } catch (Exception e) { Lua.luaL_error(L, new Lua.CharPtr(e.ToString())); }
        return(1);
    }
コード例 #24
0
    private static int tostring_T(Lua.lua_State L)
    {
        byte[] d = (byte[])Lua.lua_touserdata(L, 1);
        if (d == null)
        {
            Luna.print("checkRaw: ud==nil\n"); Lua.luaL_typerror(L, 1, LunaTraits_LWF_Point.className);
        }
        Luna.userdataType ud  = new Luna.userdataType(d);
        LWF.Point         obj = null;
        if (!objects[L].TryGetValue(ud.ObjectId, out obj))
        {
            return(0);
        }

        char[] buff = obj.ToString().ToCharArray(0, 32);
        Lua.lua_pushfstring(L, "%s (%s)", new object[] { LunaTraits_LWF_Point.className, buff });
        return(1);
    }
コード例 #25
0
    public static int _bind_gotoAndPlay(Lua.lua_State L)
    {
        if (Lua.lua_gettop(L) != 2 ||
            Luna.get_uniqueid(L, 1) != 29625181 ||
            Lua.lua_isstring(L, 2) == 0)
        {
            return(_bind_gotoAndPlay_overload_1(L));
        }
        if (Lua.lua_gettop(L) != 2 ||
            Luna.get_uniqueid(L, 1) != 29625181 ||
            Lua.lua_isnumber(L, 2) == 0)
        {
            return(_bind_gotoAndPlay_overload_2(L));
        }
        Lua.luaL_error(L, "gotoAndPlay cannot find overloads.");

        return(0);
    }
コード例 #26
0
    public static int _bind_setVisibleMovie(Lua.lua_State L)
    {
        if (Lua.lua_gettop(L) != 3 ||
            Luna.get_uniqueid(L, 1) != 7105034 ||
            Lua.lua_isstring(L, 2) == 0 ||
            !Lua.lua_isboolean(L, 3))
        {
            Luna.printStack(L); Lua.luaL_error(L, "luna typecheck failed:setVisibleMovie(LWF.LWF self)");
        }

        LWF.LWF self         = Luna_LWF_LWF.check(L, 1);
        string  instanceName = Lua.lua_tostring(L, 2).ToString();
        bool    visible      = (Lua.lua_toboolean(L, 3) != 0);

        try {
            self.SetVisibleMovie(instanceName, visible);
        } catch (Exception e) { Lua.luaL_error(L, new Lua.CharPtr(e.ToString())); }
        return(0);
    }
コード例 #27
0
    public static int _bind_setAlphaMovie(Lua.lua_State L)
    {
        if (Lua.lua_gettop(L) != 3 ||
            Luna.get_uniqueid(L, 1) != 7105034 ||
            Lua.lua_isstring(L, 2) == 0 ||
            Lua.lua_isnumber(L, 3) == 0)
        {
            Luna.printStack(L); Lua.luaL_error(L, "luna typecheck failed:setAlphaMovie(LWF.LWF self)");
        }

        LWF.LWF self         = Luna_LWF_LWF.check(L, 1);
        string  instanceName = Lua.lua_tostring(L, 2).ToString();
        float   v            = (float)Lua.lua_tonumber(L, 3);

        try {
            self.SetAlphaMovie(instanceName, v);
        } catch (Exception e) { Lua.luaL_error(L, new Lua.CharPtr(e.ToString())); }
        return(0);
    }
コード例 #28
0
    public static int _bind_removeButtonEventListener(Lua.lua_State L)
    {
        if (Lua.lua_gettop(L) != 3 ||
            Luna.get_uniqueid(L, 1) != 7105034 ||
            Lua.lua_isstring(L, 2) == 0 ||
            Lua.lua_isnumber(L, 3) == 0)
        {
            Luna.printStack(L); Lua.luaL_error(L, "luna typecheck failed:removeButtonEventListener(LWF.LWF self)");
        }

        LWF.LWF self         = Luna_LWF_LWF.check(L, 1);
        string  instanceName = Lua.lua_tostring(L, 2).ToString();
        int     id           = (int)Lua.lua_tonumber(L, 3);

        try {
            self.RemoveButtonEventHandler(instanceName, id);
        } catch (Exception e) { Lua.luaL_error(L, new Lua.CharPtr(e.ToString())); }
        return(0);
    }
コード例 #29
0
    public static int _bind_scaleTo(Lua.lua_State L)
    {
        if (Lua.lua_gettop(L) != 3 ||
            Luna.get_uniqueid(L, 1) != 29625181 ||
            Lua.lua_isnumber(L, 2) == 0 ||
            Lua.lua_isnumber(L, 3) == 0)
        {
            Luna.printStack(L); Lua.luaL_error(L, "luna typecheck failed:scaleTo(LWF.Movie self)");
        }

        LWF.Movie self = Luna_LWF_Movie.check(L, 1);
        float     vx   = (float)Lua.lua_tonumber(L, 2);
        float     vy   = (float)Lua.lua_tonumber(L, 3);

        try {
            self.ScaleTo(vx, vy);
        } catch (Exception e) { Lua.luaL_error(L, new Lua.CharPtr(e.ToString())); }
        return(0);
    }
コード例 #30
0
 static public LWF.Point check(Lua.lua_State L, int narg)
 {
     byte[] d = (byte[])Lua.lua_touserdata(L, narg);
     if (d == null)
     {
         Luna.print("checkRaw: ud==nil\n"); Lua.luaL_typerror(L, narg, LunaTraits_LWF_Point.className);
     }
     Luna.userdataType ud = new Luna.userdataType(d);
     if (ud.TypeId != LunaTraits_LWF_Point.uniqueID)       // type checking with almost no overhead
     {
         Luna.print(String.Format("ud.uid: {0} != interface::uid : {1}\n", ud.TypeId, LunaTraits_LWF_Point.uniqueID));
         Lua.luaL_typerror(L, narg, LunaTraits_LWF_Point.className);
     }
     LWF.Point obj = null;
     if (!objects[L].TryGetValue(ud.ObjectId, out obj))
     {
         return(null);
     }
     return(obj);
 }
コード例 #31
0
ファイル: ScheduleManagerModel.cs プロジェクト: Mrding/Ribbon
        public Schedule CreateNewSchedule(Campaign campaign, out Luna.Core.Tuple<IEnumerable<ServiceQueue>, IEnumerable<Organization>> relations)
        {
            var last = _repository.FindLast(campaign);

            relations = new Core.Tuple<IEnumerable<ServiceQueue>, IEnumerable<Organization>>(
               _serviceQueueRepository.GetServiceQueueByCampaign(campaign),
               campaign.Organizations.OfType<Organization>());

            IDictionary<ServiceQueue, int> defaultSvcQueues;
            ICollection<Entity> defaultOrgs;

            if (last != null)
            {
                defaultSvcQueues = new Dictionary<ServiceQueue, int>(last.ServiceQueues);
                defaultOrgs = new HashedSet<Entity>(last.Organizations);
            }
            else
            {
                defaultSvcQueues = relations.Item1.ToDictionary(o => o, o => 0);
                defaultOrgs = new HashedSet<Entity>(relations.Item2.Cast<Entity>().ToList());
            }

            var defaultStart = last == null ? DateTime.Today : last.End;

            var schedule = _entityFactory.Create<Schedule>(new Dictionary<string, object>
                                                               {
                                                                   {"Campaign", campaign},
                                                                   { "ServiceQueues", defaultSvcQueues },
                                                                   {"Organizations",defaultOrgs},
                                                                   {"Start", defaultStart},
                                                                   {"End", defaultStart.AddMonths(1)},
                                                                   {"Name", string.Format("{0:MMM}", defaultStart)}
                                                               });

            return schedule;
        }
コード例 #32
0
        private void RenderLuna(DrawingContext dc, Luna colorVariant)
        {
            Size size = RenderSize;
            bool horizontal = Orientation == Orientation.Horizontal;
            bool isClickable = IsClickable && IsEnabled;
            bool isHovered = isClickable && IsHovered;
            bool isPressed = isClickable && IsPressed;
            ListSortDirection? sortDirection = SortDirection;
            bool isSorted = sortDirection != null;
            bool isSelected = IsSelected;

            EnsureCache((int)LunaFreezables.NumFreezables);

            if (horizontal)
            {
                // When horizontal, rotate the rendering by -90 degrees
                Matrix m1 = new Matrix();
                m1.RotateAt(-90.0, 0.0, 0.0);
                Matrix m2 = new Matrix();
                m2.Translate(0.0, size.Height);

                MatrixTransform horizontalRotate = new MatrixTransform(m1 * m2);
                horizontalRotate.Freeze();
                dc.PushTransform(horizontalRotate);

                double temp = size.Width;
                size.Width = size.Height;
                size.Height = temp;
            }

            // Draw the background
            LunaFreezables backgroundType = isPressed ? LunaFreezables.PressedBackground : isHovered ? LunaFreezables.HoveredBackground : LunaFreezables.NormalBackground;
            LinearGradientBrush background = (LinearGradientBrush)GetCachedFreezable((int)backgroundType);
            if (background == null)
            {
                background = new LinearGradientBrush();
                background.StartPoint = new Point();
                background.EndPoint = new Point(0.0, 1.0);

                if (isPressed)
                {
                    if (colorVariant == Luna.Metallic)
                    {
                        background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xB9, 0xB9, 0xC8), 0.0));
                        background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xEC, 0xEC, 0xF3), 0.1));
                        background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xEC, 0xEC, 0xF3), 1.0));
                    }
                    else
                    {
                        background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xC1, 0xC2, 0xB8), 0.0));
                        background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xDE, 0xDF, 0xD8), 0.1));
                        background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xDE, 0xDF, 0xD8), 1.0));
                    }
                }
                else if (isHovered || isSelected)
                {
                    if (colorVariant == Luna.Metallic)
                    {
                        background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xFE, 0xFE, 0xFE), 0.0));
                        background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xFE, 0xFE, 0xFE), 0.85));
                        background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xBD, 0xBE, 0xCE), 1.0));
                    }
                    else
                    {
                        background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xFA, 0xF9, 0xF4), 0.0));
                        background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xFA, 0xF9, 0xF4), 0.85));
                        background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xEC, 0xE9, 0xD8), 1.0));
                    }
                }
                else
                {
                    if (colorVariant == Luna.Metallic)
                    {
                        background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xF9, 0xFA, 0xFD), 0.0));
                        background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xF9, 0xFA, 0xFD), 0.85));
                        background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xBD, 0xBE, 0xCE), 1.0));
                    }
                    else
                    {
                        background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xEB, 0xEA, 0xDB), 0.0));
                        background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xEB, 0xEA, 0xDB), 0.85));
                        background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xCB, 0xC7, 0xB8), 1.0));
                    }
                }

                background.Freeze();
                CacheFreezable(background, (int)backgroundType);
            }

            dc.DrawRectangle(background, null, new Rect(0.0, 0.0, size.Width, size.Height));

            if (isHovered && !isPressed && (size.Width >= 6.0) && (size.Height >= 4.0))
            {
                // When hovered, there is a colored tab at the bottom
                TranslateTransform positionTransform = new TranslateTransform(0.0, size.Height - 3.0);
                positionTransform.Freeze();
                dc.PushTransform(positionTransform);

                PathGeometry tabGeometry = new PathGeometry();
                PathFigure tabFigure = new PathFigure();

                tabFigure.StartPoint = new Point(0.5, 0.5);

                LineSegment line = new LineSegment(new Point(size.Width - 0.5, 0.5), true);
                line.Freeze();
                tabFigure.Segments.Add(line);

                ArcSegment arc = new ArcSegment(new Point(size.Width - 2.5, 2.5), new Size(2.0, 2.0), 90.0, false, SweepDirection.Clockwise, true);
                arc.Freeze();
                tabFigure.Segments.Add(arc);

                line = new LineSegment(new Point(2.5, 2.5), true);
                line.Freeze();
                tabFigure.Segments.Add(line);

                arc = new ArcSegment(new Point(0.5, 0.5), new Size(2.0, 2.0), 90.0, false, SweepDirection.Clockwise, true);
                arc.Freeze();
                tabFigure.Segments.Add(arc);

                tabFigure.IsClosed = true;
                tabFigure.Freeze();

                tabGeometry.Figures.Add(tabFigure);
                tabGeometry.Freeze();

                Pen tabStroke = (Pen)GetCachedFreezable((int)LunaFreezables.TabStroke);
                if (tabStroke == null)
                {
                    SolidColorBrush tabStrokeBrush = new SolidColorBrush((colorVariant == Luna.HomeStead) ? Color.FromArgb(0xFF, 0xCF, 0x72, 0x25) : Color.FromArgb(0xFF, 0xF8, 0xA9, 0x00));
                    tabStrokeBrush.Freeze();

                    tabStroke = new Pen(tabStrokeBrush, 1.0);
                    tabStroke.Freeze();

                    CacheFreezable(tabStroke, (int)LunaFreezables.TabStroke);
                }

                LinearGradientBrush tabFill = (LinearGradientBrush)GetCachedFreezable((int)LunaFreezables.TabFill);
                if (tabFill == null)
                {
                    tabFill = new LinearGradientBrush();
                    tabFill.StartPoint = new Point();
                    tabFill.EndPoint = new Point(1.0, 0.0);
                    if (colorVariant == Luna.HomeStead)
                    {
                        tabFill.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xE3, 0x91, 0x4F), 0.0));
                        tabFill.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xE3, 0x91, 0x4F), 1.0));
                    }
                    else
                    {
                        tabFill.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xFC, 0xE0, 0xA6), 0.0));
                        tabFill.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xF6, 0xC4, 0x56), 0.1));
                        tabFill.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xF6, 0xC4, 0x56), 0.9));
                        tabFill.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xDF, 0x97, 0x00), 1.0));
                    }

                    tabFill.Freeze();
                    CacheFreezable(tabFill, (int)LunaFreezables.TabFill);
                }

                dc.DrawGeometry(tabFill, tabStroke, tabGeometry);
                
                dc.Pop(); // Translate Transform
            }

            if (isPressed && (size.Width >= 2.0) && (size.Height >= 2.0))
            {
                // When pressed, there is a border on the left and bottom
                SolidColorBrush border = (SolidColorBrush)GetCachedFreezable((int)LunaFreezables.PressedBorder);
                if (border == null)
                {
                    border = new SolidColorBrush((colorVariant == Luna.Metallic) ? Color.FromArgb(0xFF, 0x80, 0x80, 0x99) : Color.FromArgb(0xFF, 0xA5, 0xA5, 0x97));
                    border.Freeze();
                    CacheFreezable(border, (int)LunaFreezables.PressedBorder);
                }

                dc.DrawRectangle(border, null, new Rect(0.0, 0.0, 1.0, size.Height));
                dc.DrawRectangle(border, null, new Rect(0.0, Max0(size.Height - 1.0), size.Width, 1.0));
            }

            if (!isPressed && !isHovered && (size.Width >= 4.0))
            {
                if (SeparatorVisibility == Visibility.Visible)
                {
                    Brush sideBrush;
                    if (SeparatorBrush != null)
                    {
                        sideBrush = SeparatorBrush;
                    }
                    else
                    {
                        // When not pressed or hovered, draw the resize gripper
                        LinearGradientBrush gripper = (LinearGradientBrush)GetCachedFreezable((int)(horizontal ? LunaFreezables.HorizontalGripper : LunaFreezables.VerticalGripper));
                        if (gripper == null)
                        {
                            gripper = new LinearGradientBrush();
                            gripper.StartPoint = new Point();
                            gripper.EndPoint = new Point(1.0, 0.0);

                            Color highlight = Color.FromArgb(0xFF, 0xFF, 0xFF, 0xFF);
                            Color shadow = Color.FromArgb(0xFF, 0xC7, 0xC5, 0xB2);

                            if (horizontal)
                            {
                                gripper.GradientStops.Add(new GradientStop(highlight, 0.0));
                                gripper.GradientStops.Add(new GradientStop(highlight, 0.25));
                                gripper.GradientStops.Add(new GradientStop(shadow, 0.75));
                                gripper.GradientStops.Add(new GradientStop(shadow, 1.0));
                            }
                            else
                            {
                                gripper.GradientStops.Add(new GradientStop(shadow, 0.0));
                                gripper.GradientStops.Add(new GradientStop(shadow, 0.25));
                                gripper.GradientStops.Add(new GradientStop(highlight, 0.75));
                                gripper.GradientStops.Add(new GradientStop(highlight, 1.0));
                            }

                            gripper.Freeze();
                            CacheFreezable(gripper, (int)(horizontal ? LunaFreezables.HorizontalGripper : LunaFreezables.VerticalGripper));
                        }

                        sideBrush = gripper;
                    }

                    dc.DrawRectangle(sideBrush, null, new Rect(horizontal ? 0.0 : Max0(size.Width - 2.0), 4.0, 2.0, Max0(size.Height - 8.0)));
                }
            }

            if (isSorted && (size.Width > 14.0) && (size.Height > 10.0))
            {
                // When sorted, draw an arrow on the right
                TranslateTransform positionTransform = new TranslateTransform(size.Width - 15.0, (size.Height - 5.0) * 0.5);
                positionTransform.Freeze();
                dc.PushTransform(positionTransform);

                bool ascending = (sortDirection == ListSortDirection.Ascending);
                PathGeometry arrowGeometry = (PathGeometry)GetCachedFreezable(ascending ? (int)LunaFreezables.ArrowUpGeometry : (int)LunaFreezables.ArrowDownGeometry);
                if (arrowGeometry == null)
                {
                    arrowGeometry = new PathGeometry();
                    PathFigure arrowFigure = new PathFigure();

                    if (ascending)
                    {
                        arrowFigure.StartPoint = new Point(0.0, 5.0);

                        LineSegment line = new LineSegment(new Point(5.0, 0.0), false);
                        line.Freeze();
                        arrowFigure.Segments.Add(line);

                        line = new LineSegment(new Point(10.0, 5.0), false);
                        line.Freeze();
                        arrowFigure.Segments.Add(line);
                    }
                    else
                    {
                        arrowFigure.StartPoint = new Point(0.0, 0.0);

                        LineSegment line = new LineSegment(new Point(10.0, 0.0), false);
                        line.Freeze();
                        arrowFigure.Segments.Add(line);

                        line = new LineSegment(new Point(5.0, 5.0), false);
                        line.Freeze();
                        arrowFigure.Segments.Add(line);
                    }

                    arrowFigure.IsClosed = true;
                    arrowFigure.Freeze();

                    arrowGeometry.Figures.Add(arrowFigure);
                    arrowGeometry.Freeze();

                    CacheFreezable(arrowGeometry, ascending ? (int)LunaFreezables.ArrowUpGeometry : (int)LunaFreezables.ArrowDownGeometry);
                }

                SolidColorBrush arrowFill = (SolidColorBrush)GetCachedFreezable((int)LunaFreezables.ArrowFill);
                if (arrowFill == null)
                {
                    arrowFill = new SolidColorBrush(Color.FromArgb(0xFF, 0xAC, 0xA8, 0x99));
                    arrowFill.Freeze();
                    CacheFreezable(arrowFill, (int)LunaFreezables.ArrowFill);
                }

                dc.DrawGeometry(arrowFill, null, arrowGeometry);

                dc.Pop(); // Position Transform
            }

            if (horizontal)
            {
                dc.Pop(); // Horizontal Rotate
            }
        }
コード例 #33
0
ファイル: ScheduleManagerModel.cs プロジェクト: Mrding/Ribbon
 public Schedule EditSchedule(Guid scheduleId, out Luna.Core.Tuple<IEnumerable<ServiceQueue>, IEnumerable<Organization>> relations)
 {
     var schedule = _repository.Get(scheduleId);
     relations = new Core.Tuple<IEnumerable<ServiceQueue>, IEnumerable<Organization>>(
     _serviceQueueRepository.GetServiceQueueByCampaign(schedule.Campaign as Campaign),
     _organizationRepository.GetByCampaign(schedule.Campaign));
     return schedule;
 }