OF









How do I use O F
Below are practical examples compiled from projects for learning and reference purposes

Featured Snippets


File name: FormXemDiem.cs Copy
85         private void btnXuatRaExcel_Click(object sender, EventArgs e)
86         {
87             try
88             {
89
90                 Excel.Application objExcelApp = new Excel.Application();
91                 Excel.Workbook objExcelWorkbook = objExcelApp.Workbooks.Add(Excel.XlWBATemplate.xlWBATWorksheet);
92                 Excel.Worksheet objSheet = (Excel.Worksheet)objExcelWorkbook.Worksheets[1];
93                 //objSheet.Cells.Interior.Color.ToString() = 'blue';
94                 objSheet = (Excel.Worksheet)objExcelWorkbook.Sheets[1];
95                 objSheet.Cells.HorizontalAlignment = Excel.Constants.xlCenter;
96                 objSheet.Cells[2, 5] = "BẢNG ĐIỂM CỦA SINH VIÊN";
97                 objSheet.Cells[5, 3] = "Mã Học Phần";
98                 objSheet.Cells[5, 4] = "Mã Nhóm Học Phần";
99                 objSheet.Cells[5, 5] = "Tên Học Phần";
100                 objSheet.Cells[5, 6] = "Điểm Thi";
101                 objSheet.Cells[5, 7] = "Điểm Quá Trình";
102                 objSheet.Cells[5, 8] = "Điểm Xếp Loại";
103                 objSheet.Cells[3, 3] = "Mã Học Kỳ : "+cmbMaHK.SelectedValue.ToString()+"";
104                 objSheet.Cells[4, 3] = "Mã SV : " + txtMaSV.Text + "";
105                 objSheet.Cells[9,10] = "ĐIỂM TỔNG KẾT";
106                 objSheet.Cells[10,10] = "Hệ 10 : "+txtHe10.Text+"";
107                 objSheet.Cells[11,10] = "Hệ 4 : "+txtHe4.Text+"";
108                 for (int i = 0; i < dgvKetQua.Rows.Count ; i++)
109                 {
110                     for (int j = 0; j < dgvKetQua.Columns.GetColumnCount(DataGridViewElementStates.Displayed); j++)
111                     {
112                         objSheet.Cells[i + 6, j + 3] = dgvKetQua.Rows[i].Cells[j].Value.ToString();
113                         objSheet.Columns.AutoFit();
114                     }
115                 }
116                 objExcelApp.Visible = true;
117             }
118             catch (Exception ex)
119             {
120                 MessageBox.Show(ex.Message);
121             }
122         }
File name: FormXemDiemLop.cs Copy
77         private void btnXuatRaExcel_Click(object sender, EventArgs e)
78         {
79              try
80             {
81
82                 Excel.Application objExcelApp = new Excel.Application();
83                 Excel.Workbook objExcelWorkbook = objExcelApp.Workbooks.Add(Excel.XlWBATemplate.xlWBATWorksheet);
84                 Excel.Worksheet objSheet = (Excel.Worksheet)objExcelWorkbook.Worksheets[1];
85                 //objSheet.Cells.Interior.Color.ToString() = 'blue';
86                 objSheet = (Excel.Worksheet)objExcelWorkbook.Sheets[1];
87                 objSheet.Cells.HorizontalAlignment = Excel.Constants.xlCenter;
88                 objSheet.Cells[2, 5] = "BẢNG ĐIỂM CỦA LỚP";
89                 objSheet.Cells[3, 3] = "Mã Học Kỳ : "+cmbMaHK.SelectedValue.ToString()+"";
90                 objSheet.Cells[4, 3] = "Mã Lớp : " + cmbMaLop.SelectedValue.ToString() + "";
91                 objSheet.Cells[5, 4] = "Mã Sinh Viên";
92                 objSheet.Cells[5, 5] = "Tên Sinh Viên";
93                 objSheet.Cells[5, 6] = "Điểm Trung Bình";
94                 //select sv.MaSV,TenSV,TrungBinhCuoiKyHe10
95
96                 for (int i = 0; i < dgvKetQua.Rows.Count ; i++)
97                 {
98                     for (int j = 0; j < dgvKetQua.Columns.GetColumnCount(DataGridViewElementStates.Displayed); j++)
99                     {
100                         objSheet.Cells[i + 6, j + 4] = dgvKetQua.Rows[i].Cells[j].Value.ToString();
101                         objSheet.Columns.AutoFit();
102                     }
103                 }
104                 objExcelApp.Visible = true;
105             }
106             catch (Exception ex)
107             {
108                 MessageBox.Show(ex.Message);
109             }
110         }
File name: DemoOwnershipGui.cs Copy
8     public void OnOwnershipRequest(object[] viewAndPlayer)
9     {
10         PhotonView view = viewAndPlayer[0] as PhotonView;
11         PhotonPlayer requestingPlayer = viewAndPlayer[1] as PhotonPlayer;
12
13         Debug.Log("OnOwnershipRequest(): Player " + requestingPlayer + " requests ownership of: " + view + ".");
14         if (this.TransferOwnershipOnRequest)
15         {
16             view.TransferOwnership(requestingPlayer.ID);
17         }
18     }
File name: ChatGui.cs Copy
95     public void Update()
96     {
97         if (this.chatClient != null)
98         {
99             this.chatClient.Service(); // make sure to call this regularly! it limits effort internally, so calling often is ok!
100         }
101     }
File name: ChatGui.cs Copy
103     public void OnGUI()
104     {
105         if (!this.IsVisible)
106         {
107             return;
108         }
109
110         GUI.skin.label.wordWrap = true;
111         //GUI.skin.button.richText = true; // this allows toolbar buttons to have bold/colored text. nice to indicate new msgs
112         //GUILayout.Button("lala"); // as richText, html tags could be in text
113
114
115         if (Event.current.type == EventType.KeyDown && (Event.current.keyCode == KeyCode.KeypadEnter || Event.current.keyCode == KeyCode.Return))
116         {
117             if ("ChatInput".Equals(GUI.GetNameOfFocusedControl()))
118             {
119                 // focus on input -> submit it
120                 GuiSendsMsg();
121                 return; // showing the now modified list would result in an error. to avoid this, we just skip this single frame
122             }
123             else
124             {
125                 // assign focus to input
126                 GUI.FocusControl("ChatInput");
127             }
128         }
129
130         GUI.SetNextControlName("");
131         GUILayout.BeginArea(this.GuiRect);
132
133         GUILayout.FlexibleSpace();
134
135         if (this.chatClient.State != ChatState.ConnectedToFrontEnd)
136         {
137             GUILayout.Label("Not in chat yet.");
138         }
139         else
140         {
141             List channels = new List(this.chatClient.PublicChannels.Keys); // this could be cached
142             int countOfPublicChannels = channels.Count;
143             channels.AddRange(this.chatClient.PrivateChannels.Keys);
144
145             if (channels.Count > 0)
146             {
147                 int previouslySelectedChannelIndex = this.selectedChannelIndex;
148                 int channelIndex = channels.IndexOf(this.selectedChannelName);
149                 this.selectedChannelIndex = (channelIndex >= 0) ? channelIndex : 0;
150
151                 this.selectedChannelIndex = GUILayout.Toolbar(this.selectedChannelIndex, channels.ToArray(), GUILayout.ExpandWidth(false));
152                 this.scrollPos = GUILayout.BeginScrollView(this.scrollPos);
153
154                 this.doingPrivateChat = (this.selectedChannelIndex >= countOfPublicChannels);
155                 this.selectedChannelName = channels[this.selectedChannelIndex];
156
157                 if (this.selectedChannelIndex != previouslySelectedChannelIndex)
158                 {
159                     // changed channel -> scroll down, if private: pre-fill "to" field with target user's name
160                     this.scrollPos.y = float.MaxValue;
161                     if (this.doingPrivateChat)
162                     {
163                         string[] pieces = this.selectedChannelName.Split(new char[] {':'}, 3);
164                         this.userIdInput = pieces[1];
165                     }
166                 }
167
168                 GUILayout.Label(ChatGui.WelcomeText);
169
170                 if (this.chatClient.TryGetChannel(selectedChannelName, this.doingPrivateChat, out this.selectedChannel))
171                 {
172                     for (int i = 0; i < this.selectedChannel.Messages.Count; i++)
173                     {
174                         string sender = this.selectedChannel.Senders[i];
175                         object message = this.selectedChannel.Messages[i];
176                         GUILayout.Label(string.Format("{0}: {1}", sender, message));
177                     }
178                 }
179
180                 GUILayout.EndScrollView();
181             }
182         }
183
184
185         GUILayout.BeginHorizontal();
186         if (doingPrivateChat)
187         {
188             GUILayout.Label("to:", GUILayout.ExpandWidth(false));
189             GUI.SetNextControlName("WhisperTo");
190             this.userIdInput = GUILayout.TextField(this.userIdInput, GUILayout.MinWidth(100), GUILayout.ExpandWidth(false));
191             string focussed = GUI.GetNameOfFocusedControl();
192             if (focussed.Equals("WhisperTo"))
193             {
194                 if (this.userIdInput.Equals("username"))
195                 {
196                     this.userIdInput = "";
197                 }
198             }
199             else if (string.IsNullOrEmpty(this.userIdInput))
200             {
201                 this.userIdInput = "username";
202             }
203
204         }
205         GUI.SetNextControlName("ChatInput");
206         inputLine = GUILayout.TextField(inputLine);
207         if (GUILayout.Button("Send", GUILayout.ExpandWidth(false)))
208         {
209             GuiSendsMsg();
210         }
211         GUILayout.EndHorizontal();
212         GUILayout.EndArea();
213     }
File name: ChatGui.cs Copy
296     public void OnConnected()
297     {
298         if (this.ChannelsToJoinOnConnect != null && this.ChannelsToJoinOnConnect.Length > 0)
299         {
300             this.chatClient.Subscribe(this.ChannelsToJoinOnConnect, this.HistoryLengthToFetch);
301         }
302
303         this.chatClient.AddFriends(new string[] {"tobi", "ilya"}); // Add some users to the server-list to get their status updates
304         this.chatClient.SetOnlineStatus(ChatUserStatus.Online); // You can set your online state (without a mesage).
305     }
File name: GUICustomAuth.cs Copy
46     public void SetStateAuthInput()
47     {
48         RootOf3dButtons.SetActive(false);
49         guiState = GuiState.AuthInput;
50     }
File name: GUICustomAuth.cs Copy
52     public void SetStateAuthHelp()
53     {
54         RootOf3dButtons.SetActive(false);
55         guiState = GuiState.AuthHelp;
56     }
File name: GUICustomAuth.cs Copy
58     public void SetStateAuthOrNot()
59     {
60         RootOf3dButtons.SetActive(true);
61         guiState = GuiState.AuthOrNot;
62     }
File name: GUICustomAuth.cs Copy
64     public void SetStateAuthFailed()
65     {
66         RootOf3dButtons.SetActive(false);
67         guiState = GuiState.AuthFailed;
68     }

Download file with original file name:OF

OF 136 lượt xem

Gõ tìm kiếm nhanh...