Changeset 117


Ignore:
Timestamp:
Dec 18, 2008, 8:03:25 PM (15 years ago)
Author:
rryu
Message:

とりあえずOptimus Mini Threeに対応してみた。

Location:
trunk/MacFaceFloat
Files:
2 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/MacFaceFloat/MacFaceApp.cs

    r111 r117  
    1313using System.IO;
    1414using System.Reflection;
     15using System.Drawing.Imaging;
     16using System.Runtime.InteropServices;
    1517
    1618namespace MacFace.FloatApp
     
    4143                private MacFace.FaceDef curFaceDef;
    4244
    43                 [STAThread]
     45        private IOptimusMini optimusMini;
     46
     47        [STAThread]
    4448                public static void Main(string[] args)
    4549                {
     
    126130                        }
    127131
     132            //IOptimusMini.OnKeyDownCallbackDelegate oKD = new IOptimusMini.OnKeyDownCallbackDelegate(OnKeyDownCallbackHandler);
     133            //IOptimusMini.OnDeviceStateChangedCallbackDelegate oDSC = new IOptimusMini.OnDeviceStateChangedCallbackDelegate(OnDeviceStateChangedCallbackHandler);
     134            //IOptimusMini.RegisterEventHandler(oKD, oDSC);
     135
    128136            patternWindow = null;
    129137            statusWindow = null;
    130138
    131139            InitializeComponent();
     140
     141            optimusMini = new IOptimusMini();
     142            optimusMini.DisplayOn();
    132143
    133144            CountProcessorUsage(null, null);
     
    138149                        updateTimer.Tick += new EventHandler(this.CountProcessorUsage);
    139150                }
     151
     152        void OnKeyDownCallbackHandler(int key)
     153        {
     154            Console.Write("Keydown {0}\n", key);
     155        }
     156
     157        void OnDeviceStateChangedCallbackHandler(int state)
     158        {
     159            //useOptimusMini = (state > 0);
     160        }
    140161
    141162                void InitializeComponent()
     
    232253                {
    233254                        notifyIcon.Visible = false;
    234 
    235255                        config.Save();
    236                 }
     256            optimusMini.Dispose();
     257        }
    237258
    238259                public bool LoadFaceDefine(string path)
     
    302323                        if (pageio_count < 0) pageio_count = 0;
    303324
     325                        int pattern = cpuUsage.Active / 10;
     326                        pattern += memUsage.Pageout / 15;
     327                        pattern += memUsage.Pagein / 30;
     328                        if (pattern > 10) pattern = 10;
     329
     330                        FaceDef.PatternSuite suite = FaceDef.PatternSuite.Normal;
     331
     332                        UInt64 avilable = (UInt64)memStats.TotalVisibleMemorySize * 1024 - memUsage.Used;
     333            if (pageio_count > 100)
     334                        {
     335                                suite = FaceDef.PatternSuite.MemoryInsufficient;
     336                        }
     337            else if (avilable < 0)
     338                        {
     339                                suite = FaceDef.PatternSuite.MemoryDecline;
     340                        }
     341
     342                        int markers = FaceDef.MarkerNone;
     343                        if (memUsage.Pagein > 0) markers += FaceDef.MarkerPageIn;
     344                        if (memUsage.Pageout > 0) markers += FaceDef.MarkerPageOut;
     345
    304346                        if (patternWindow != null)
    305347                        {
    306                                 int pattern = cpuUsage.Active / 10;
    307                                 pattern += memUsage.Pageout / 15;
    308                                 pattern += memUsage.Pagein / 30;
    309                                 if (pattern > 10) pattern = 10;
    310 
    311                                 FaceDef.PatternSuite suite = FaceDef.PatternSuite.Normal;
    312 
    313                                 UInt64 avilable = (UInt64)memStats.TotalVisibleMemorySize * 1024 - memUsage.Used;
    314                 if (pageio_count > 100)
    315                                 {
    316                                         suite = FaceDef.PatternSuite.MemoryInsufficient;
    317                                 }
    318                 else if (avilable < 0)
    319                                 {
    320                                         suite = FaceDef.PatternSuite.MemoryDecline;
    321                                 }
    322 
    323                                 int markers = FaceDef.MarkerNone;
    324                                 if (memUsage.Pagein > 0) markers += FaceDef.MarkerPageIn;
    325                                 if (memUsage.Pageout > 0) markers += FaceDef.MarkerPageOut;
    326 
    327348                                patternWindow.UpdatePattern(suite, pattern, markers);
    328349                        }
     
    332353                                statusWindow.UpdateGraph();
    333354                        }
     355
     356            if (optimusMini.IsAlive && curFaceDef != null)
     357            {
     358                Bitmap image = new Bitmap(96, 96);
     359                Graphics g = Graphics.FromImage(image);
     360                g.FillRectangle(new SolidBrush(Color.White), 0, 0, image.Width, image.Height);
     361                curFaceDef.DrawPatternImage(g, suite, pattern, markers, 96F / 128F);
     362                g.Dispose();
     363
     364                optimusMini.ShowPicture(1, image);
     365            }
    334366                }
    335367
     
    414446                private void configForm_ConfigChanged()
    415447                {
    416                         if (patternWindow.FaceDef.Path != config.FaceDefPath)
    417                         {
    418                                 bool result = LoadFaceDefine(config.FaceDefPath);
    419                                 // ƒpƒ^[ƒ“•ÏX‚ÉŽ¸”s‚µ‚½‚çÝ’è‚ðŒ³‚É–ß‚·
    420                                 if (!result)
    421                                 {
    422                                         config.FaceDefPath = patternWindow.FaceDef.Path;
    423                                 }
    424                         }
    425 
    426                         if (patternWindow != null)
     448            if (curFaceDef.Path != config.FaceDefPath)
     449            {
     450                bool result = LoadFaceDefine(config.FaceDefPath);
     451                // ƒpƒ^[ƒ“•ÏX‚ÉŽ¸”s‚µ‚½‚çÝ’è‚ðŒ³‚É–ß‚·
     452                if (!result)
     453                {
     454                    config.FaceDefPath = patternWindow.FaceDef.Path;
     455                }
     456            }
     457
     458            if (patternWindow != null)
    427459                        {
    428460                                patternWindow.Opacity = (float)config.Opacity / 100;
  • trunk/MacFaceFloat/MacFaceFloat.csproj

    r115 r117  
    22  <PropertyGroup>
    33    <ProjectType>Local</ProjectType>
    4     <ProductVersion>9.0.30729</ProductVersion>
     4    <ProductVersion>9.0.21022</ProductVersion>
    55    <SchemaVersion>2.0</SchemaVersion>
    66    <ProjectGuid>{60DE0E19-7B98-41E8-8001-A8C7A75AF08E}</ProjectGuid>
     
    150150      <SubType>Form</SubType>
    151151    </Compile>
     152    <Compile Include="IOptimusMini.cs">
     153      <SubType>Code</SubType>
     154    </Compile>
    152155    <Compile Include="MacFaceApp.cs">
    153156      <SubType>Code</SubType>
     
    252255    <Content Include="kikiki-rin.mcface\note.tiff" />
    253256    <Content Include="kikiki-rin.mcface\shock.tiff" />
     257    <Content Include="OptimusMini.dll" />
    254258  </ItemGroup>
    255259  <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
    256260  <PropertyGroup>
    257261    <PreBuildEvent>"$(ProjectDir)PreBuild_GenerateAssemblyInfoVersionPart.cmd" &gt; "$(ProjectDir)AssemblyInfoVersionPart.cs"</PreBuildEvent>
    258     <PostBuildEvent>xcopy /Y /I "$(ProjectDir)default.mcface" "$(TargetDir)default.mcface"</PostBuildEvent>
     262    <PostBuildEvent>xcopy /Y /I "$(ProjectDir)default.mcface" "$(TargetDir)default.mcface"
     263copy "$(ProjectDir)OptimusMini.dll" "$(TargetDir)OptimusMini.dll"
     264</PostBuildEvent>
    259265  </PropertyGroup>
    260266</Project>
Note: See TracChangeset for help on using the changeset viewer.